@nativestudio/local-runtime 0.3.0-rc.25 → 0.3.0-rc.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture.mjs +354 -354
- package/dist/entry.js +1140 -469
- package/dist/execution-identity.json +1 -1
- package/dist/hyperframe-dependencies.json +1 -1
- package/dist/hyperframe-notices.txt +1 -1
- package/package.json +1 -1
package/dist/entry.js
CHANGED
|
@@ -38,9 +38,9 @@ async function windowsHelper() {
|
|
|
38
38
|
}
|
|
39
39
|
async function bootstrap() {
|
|
40
40
|
const directory = assetDirectory ?? fileURLToPath(new URL("./native/", import.meta.url));
|
|
41
|
-
const read = async (name2,
|
|
41
|
+
const read = async (name2, maximum4) => {
|
|
42
42
|
const path = join(directory, name2), stat12 = await lstat(path);
|
|
43
|
-
if (!stat12.isFile() || stat12.isSymbolicLink() || stat12.nlink !== 1 || stat12.size < 1 || stat12.size >
|
|
43
|
+
if (!stat12.isFile() || stat12.isSymbolicLink() || stat12.nlink !== 1 || stat12.size < 1 || stat12.size > maximum4)
|
|
44
44
|
throw Error("WINDOWS_HELPER_INVALID");
|
|
45
45
|
const bytes2 = await readFile(path);
|
|
46
46
|
if (bytes2.length !== stat12.size) throw Error("WINDOWS_HELPER_INVALID");
|
|
@@ -2833,7 +2833,7 @@ var init_checks = __esm({
|
|
|
2833
2833
|
def.format = def.format || "float64";
|
|
2834
2834
|
const isInt = def.format?.includes("int");
|
|
2835
2835
|
const origin = isInt ? "int" : "number";
|
|
2836
|
-
const [minimum,
|
|
2836
|
+
const [minimum, maximum4] = NUMBER_FORMAT_RANGES[def.format];
|
|
2837
2837
|
inst._zod.check = (payload) => {
|
|
2838
2838
|
const input3 = payload.value;
|
|
2839
2839
|
if (isInt) {
|
|
@@ -2886,12 +2886,12 @@ var init_checks = __esm({
|
|
|
2886
2886
|
continue: !def.abort
|
|
2887
2887
|
});
|
|
2888
2888
|
}
|
|
2889
|
-
if (input3 >
|
|
2889
|
+
if (input3 > maximum4) {
|
|
2890
2890
|
payload.issues.push({
|
|
2891
2891
|
origin: "number",
|
|
2892
2892
|
input: input3,
|
|
2893
2893
|
code: "too_big",
|
|
2894
|
-
maximum:
|
|
2894
|
+
maximum: maximum4,
|
|
2895
2895
|
inclusive: true,
|
|
2896
2896
|
inst,
|
|
2897
2897
|
continue: !def.abort
|
|
@@ -2901,7 +2901,7 @@ var init_checks = __esm({
|
|
|
2901
2901
|
});
|
|
2902
2902
|
$ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat", (inst, def) => {
|
|
2903
2903
|
$ZodCheck.init(inst, def);
|
|
2904
|
-
const [minimum,
|
|
2904
|
+
const [minimum, maximum4] = BIGINT_FORMAT_RANGES[def.format];
|
|
2905
2905
|
inst._zod.check = (payload) => {
|
|
2906
2906
|
const input3 = payload.value;
|
|
2907
2907
|
if (input3 < minimum) {
|
|
@@ -2915,12 +2915,12 @@ var init_checks = __esm({
|
|
|
2915
2915
|
continue: !def.abort
|
|
2916
2916
|
});
|
|
2917
2917
|
}
|
|
2918
|
-
if (input3 >
|
|
2918
|
+
if (input3 > maximum4) {
|
|
2919
2919
|
payload.issues.push({
|
|
2920
2920
|
origin: "bigint",
|
|
2921
2921
|
input: input3,
|
|
2922
2922
|
code: "too_big",
|
|
2923
|
-
maximum:
|
|
2923
|
+
maximum: maximum4,
|
|
2924
2924
|
inclusive: true,
|
|
2925
2925
|
inst,
|
|
2926
2926
|
continue: !def.abort
|
|
@@ -3903,7 +3903,7 @@ function leafPattern(schema2) {
|
|
|
3903
3903
|
let pattern = def.pattern;
|
|
3904
3904
|
let isInt = !!def.format?.includes("int");
|
|
3905
3905
|
let minimum;
|
|
3906
|
-
let
|
|
3906
|
+
let maximum4;
|
|
3907
3907
|
for (const ch of def.checks ?? []) {
|
|
3908
3908
|
const d = ch._zod.def;
|
|
3909
3909
|
if (d.pattern)
|
|
@@ -3913,15 +3913,15 @@ function leafPattern(schema2) {
|
|
|
3913
3913
|
const hi = d.maximum ?? d.length;
|
|
3914
3914
|
if (lo !== void 0 && (minimum === void 0 || lo > minimum))
|
|
3915
3915
|
minimum = lo;
|
|
3916
|
-
if (hi !== void 0 && (
|
|
3917
|
-
|
|
3916
|
+
if (hi !== void 0 && (maximum4 === void 0 || hi < maximum4))
|
|
3917
|
+
maximum4 = hi;
|
|
3918
3918
|
}
|
|
3919
3919
|
if (pattern)
|
|
3920
3920
|
return pattern.source;
|
|
3921
|
-
if (minimum !== void 0 &&
|
|
3921
|
+
if (minimum !== void 0 && maximum4 !== void 0 && minimum > maximum4)
|
|
3922
3922
|
return "(?!)";
|
|
3923
|
-
if (minimum !== void 0 ||
|
|
3924
|
-
return string({ minimum, maximum:
|
|
3923
|
+
if (minimum !== void 0 || maximum4 !== void 0)
|
|
3924
|
+
return string({ minimum, maximum: maximum4 }).source;
|
|
3925
3925
|
const own2 = schema2._zod.pattern;
|
|
3926
3926
|
return (isInt && own2 === number ? integer : own2)?.source;
|
|
3927
3927
|
}
|
|
@@ -16249,11 +16249,11 @@ function _multipleOf(value2, params) {
|
|
|
16249
16249
|
});
|
|
16250
16250
|
}
|
|
16251
16251
|
// @__NO_SIDE_EFFECTS__
|
|
16252
|
-
function _maxSize(
|
|
16252
|
+
function _maxSize(maximum4, params) {
|
|
16253
16253
|
return new $ZodCheckMaxSize({
|
|
16254
16254
|
check: "max_size",
|
|
16255
16255
|
...normalizeParams(params),
|
|
16256
|
-
maximum:
|
|
16256
|
+
maximum: maximum4
|
|
16257
16257
|
});
|
|
16258
16258
|
}
|
|
16259
16259
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -16273,11 +16273,11 @@ function _size(size, params) {
|
|
|
16273
16273
|
});
|
|
16274
16274
|
}
|
|
16275
16275
|
// @__NO_SIDE_EFFECTS__
|
|
16276
|
-
function _maxLength(
|
|
16276
|
+
function _maxLength(maximum4, params) {
|
|
16277
16277
|
const ch = new $ZodCheckMaxLength({
|
|
16278
16278
|
check: "max_length",
|
|
16279
16279
|
...normalizeParams(params),
|
|
16280
|
-
maximum:
|
|
16280
|
+
maximum: maximum4
|
|
16281
16281
|
});
|
|
16282
16282
|
return ch;
|
|
16283
16283
|
}
|
|
@@ -17372,7 +17372,7 @@ function stringifyKeyNames(bySchema, json3, visited) {
|
|
|
17372
17372
|
const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
|
|
17373
17373
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
17374
17374
|
return json3;
|
|
17375
|
-
const { minimum, maximum:
|
|
17375
|
+
const { minimum, maximum: maximum4, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id: id18, ...rest } = json3;
|
|
17376
17376
|
if (rest.enum)
|
|
17377
17377
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
17378
17378
|
else if (typeof rest.const === "number")
|
|
@@ -17497,9 +17497,9 @@ var init_json_schema_processors = __esm({
|
|
|
17497
17497
|
maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
17498
17498
|
formatContributor = (ranges) => (agg, def) => {
|
|
17499
17499
|
setFormat(agg, def.format);
|
|
17500
|
-
const [minimum,
|
|
17500
|
+
const [minimum, maximum4] = ranges[def.format];
|
|
17501
17501
|
narrowMin(agg, "minimum", minimum);
|
|
17502
|
-
narrowMax(agg, "maximum",
|
|
17502
|
+
narrowMax(agg, "maximum", maximum4);
|
|
17503
17503
|
};
|
|
17504
17504
|
contributors = {
|
|
17505
17505
|
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
@@ -17540,11 +17540,11 @@ var init_json_schema_processors = __esm({
|
|
|
17540
17540
|
stringProcessor = (schema2, ctx, _json, _params) => {
|
|
17541
17541
|
const json3 = _json;
|
|
17542
17542
|
json3.type = "string";
|
|
17543
|
-
const { minimum, maximum:
|
|
17543
|
+
const { minimum, maximum: maximum4, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema2);
|
|
17544
17544
|
if (typeof minimum === "number")
|
|
17545
17545
|
json3.minLength = minimum;
|
|
17546
|
-
if (typeof
|
|
17547
|
-
json3.maxLength =
|
|
17546
|
+
if (typeof maximum4 === "number")
|
|
17547
|
+
json3.maxLength = maximum4;
|
|
17548
17548
|
if (format) {
|
|
17549
17549
|
json3.format = formatMap[format] ?? format;
|
|
17550
17550
|
if (json3.format === "")
|
|
@@ -17571,10 +17571,10 @@ var init_json_schema_processors = __esm({
|
|
|
17571
17571
|
};
|
|
17572
17572
|
numberProcessor = (schema2, ctx, _json, params) => {
|
|
17573
17573
|
const json3 = _json;
|
|
17574
|
-
const { minimum, maximum:
|
|
17574
|
+
const { minimum, maximum: maximum4, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema2);
|
|
17575
17575
|
json3.type = isInt ? "integer" : "number";
|
|
17576
17576
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
17577
|
-
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (
|
|
17577
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum4 ?? Number.POSITIVE_INFINITY);
|
|
17578
17578
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
17579
17579
|
if (exMin) {
|
|
17580
17580
|
if (legacy) {
|
|
@@ -17593,8 +17593,8 @@ var init_json_schema_processors = __esm({
|
|
|
17593
17593
|
} else {
|
|
17594
17594
|
json3.exclusiveMaximum = exclusiveMaximum;
|
|
17595
17595
|
}
|
|
17596
|
-
} else if (typeof
|
|
17597
|
-
json3.maximum =
|
|
17596
|
+
} else if (typeof maximum4 === "number") {
|
|
17597
|
+
json3.maximum = maximum4;
|
|
17598
17598
|
}
|
|
17599
17599
|
if (multipleOf) {
|
|
17600
17600
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -17714,11 +17714,11 @@ var init_json_schema_processors = __esm({
|
|
|
17714
17714
|
_json.type = "string";
|
|
17715
17715
|
_json.format = "binary";
|
|
17716
17716
|
_json.contentEncoding = "binary";
|
|
17717
|
-
const { minimum, maximum:
|
|
17717
|
+
const { minimum, maximum: maximum4, mime } = aggregateChecks(schema2);
|
|
17718
17718
|
if (minimum !== void 0)
|
|
17719
17719
|
_json.minLength = minimum;
|
|
17720
|
-
if (
|
|
17721
|
-
_json.maxLength =
|
|
17720
|
+
if (maximum4 !== void 0)
|
|
17721
|
+
_json.maxLength = maximum4;
|
|
17722
17722
|
if (!mime)
|
|
17723
17723
|
return;
|
|
17724
17724
|
if (mime.length === 0)
|
|
@@ -17749,11 +17749,11 @@ var init_json_schema_processors = __esm({
|
|
|
17749
17749
|
arrayProcessor = (schema2, ctx, _json, params) => {
|
|
17750
17750
|
const json3 = _json;
|
|
17751
17751
|
const def = schema2._zod.def;
|
|
17752
|
-
const { minimum, maximum:
|
|
17752
|
+
const { minimum, maximum: maximum4 } = aggregateChecks(schema2);
|
|
17753
17753
|
if (typeof minimum === "number")
|
|
17754
17754
|
json3.minItems = minimum;
|
|
17755
|
-
if (typeof
|
|
17756
|
-
json3.maxItems =
|
|
17755
|
+
if (typeof maximum4 === "number")
|
|
17756
|
+
json3.maxItems = maximum4;
|
|
17757
17757
|
json3.type = "array";
|
|
17758
17758
|
json3.items = processSchema(def.element, ctx, {
|
|
17759
17759
|
...params,
|
|
@@ -17887,11 +17887,11 @@ var init_json_schema_processors = __esm({
|
|
|
17887
17887
|
if (isClosed)
|
|
17888
17888
|
json3.maxItems = maxItems;
|
|
17889
17889
|
}
|
|
17890
|
-
const { minimum, maximum:
|
|
17890
|
+
const { minimum, maximum: maximum4 } = aggregateChecks(schema2);
|
|
17891
17891
|
if (typeof minimum === "number")
|
|
17892
17892
|
json3.minItems = minimum;
|
|
17893
|
-
if (typeof
|
|
17894
|
-
json3.maxItems =
|
|
17893
|
+
if (typeof maximum4 === "number")
|
|
17894
|
+
json3.maxItems = maximum4;
|
|
17895
17895
|
};
|
|
17896
17896
|
pendingRecords = /* @__PURE__ */ new WeakMap();
|
|
17897
17897
|
recordProcessor = (schema2, ctx, _json, params) => {
|
|
@@ -19740,8 +19740,8 @@ var init_schemas2 = __esm({
|
|
|
19740
19740
|
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
19741
19741
|
},
|
|
19742
19742
|
maxValue: (inst) => {
|
|
19743
|
-
const { maximum:
|
|
19744
|
-
return Math.min(
|
|
19743
|
+
const { maximum: maximum4, exclusiveMaximum } = aggregateChecks(inst);
|
|
19744
|
+
return Math.min(maximum4 ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
19745
19745
|
},
|
|
19746
19746
|
isInt: (inst) => {
|
|
19747
19747
|
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
@@ -19906,8 +19906,8 @@ var init_schemas2 = __esm({
|
|
|
19906
19906
|
return minimum ? new Date(minimum) : null;
|
|
19907
19907
|
},
|
|
19908
19908
|
maxDate: (inst) => {
|
|
19909
|
-
const { maximum:
|
|
19910
|
-
return
|
|
19909
|
+
const { maximum: maximum4 } = aggregateChecks(inst);
|
|
19910
|
+
return maximum4 ? new Date(maximum4) : null;
|
|
19911
19911
|
}
|
|
19912
19912
|
}, {})
|
|
19913
19913
|
);
|
|
@@ -23047,6 +23047,22 @@ var init_accepted_shot = __esm({
|
|
|
23047
23047
|
}
|
|
23048
23048
|
});
|
|
23049
23049
|
|
|
23050
|
+
// packages/contracts/src/local-execution/canonical.ts
|
|
23051
|
+
function canonicalLocalJson(value2) {
|
|
23052
|
+
if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean")
|
|
23053
|
+
return JSON.stringify(value2);
|
|
23054
|
+
if (typeof value2 === "number" && Number.isFinite(value2)) return JSON.stringify(value2);
|
|
23055
|
+
if (Array.isArray(value2)) return "[" + value2.map(canonicalLocalJson).join(",") + "]";
|
|
23056
|
+
if (typeof value2 === "object")
|
|
23057
|
+
return "{" + Object.entries(value2).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => JSON.stringify(k) + ":" + canonicalLocalJson(v)).join(",") + "}";
|
|
23058
|
+
throw new Error("Fingerprint input must be finite JSON data");
|
|
23059
|
+
}
|
|
23060
|
+
var init_canonical = __esm({
|
|
23061
|
+
"packages/contracts/src/local-execution/canonical.ts"() {
|
|
23062
|
+
"use strict";
|
|
23063
|
+
}
|
|
23064
|
+
});
|
|
23065
|
+
|
|
23050
23066
|
// packages/contracts/src/native-speech-http.ts
|
|
23051
23067
|
var NativeSpeechOriginSchema, NativeSpeechHttpModelSchema, NativeSpeechModelIdSchema;
|
|
23052
23068
|
var init_native_speech_http = __esm({
|
|
@@ -23198,7 +23214,12 @@ var init_provider = __esm({
|
|
|
23198
23214
|
// 旧连接读合同仅返回原字段,外部授权随持久化连接版本管理。
|
|
23199
23215
|
configuration: external_exports.object(providerConfigurationFields),
|
|
23200
23216
|
createdByPrincipalId: PrincipalIdSchema,
|
|
23201
|
-
updatedAt: external_exports.iso.datetime({ offset: true })
|
|
23217
|
+
updatedAt: external_exports.iso.datetime({ offset: true }),
|
|
23218
|
+
// 协商回执只存在于本次配置响应,不回显密钥或项目授权正文。
|
|
23219
|
+
configurationReceipt: external_exports.strictObject({
|
|
23220
|
+
protocol: external_exports.literal("NVS_PROVIDER_CONFIGURATION_RECEIPT_V1"),
|
|
23221
|
+
intentSha256: external_exports.string().regex(/^[a-f0-9]{64}$/)
|
|
23222
|
+
}).optional()
|
|
23202
23223
|
});
|
|
23203
23224
|
ProviderConnectionCommandSchema = external_exports.strictObject({
|
|
23204
23225
|
tenantId: TenantIdSchema,
|
|
@@ -24861,7 +24882,7 @@ var init_matrix_parameter_rule = __esm({
|
|
|
24861
24882
|
});
|
|
24862
24883
|
|
|
24863
24884
|
// packages/contracts/src/transcription.ts
|
|
24864
|
-
var AsrProfileSchema, TranscriptText, TimedText, TranscriptSchema;
|
|
24885
|
+
var AsrProfileSchema, TranscriptText, TimedTextFields, TimedWord, TimedText, TranscriptSchema;
|
|
24865
24886
|
var init_transcription = __esm({
|
|
24866
24887
|
"packages/contracts/src/transcription.ts"() {
|
|
24867
24888
|
"use strict";
|
|
@@ -24923,11 +24944,13 @@ var init_transcription = __esm({
|
|
|
24923
24944
|
text: external_exports.string().max(6e4),
|
|
24924
24945
|
languages: external_exports.array(external_exports.string().min(2).max(40)).max(32)
|
|
24925
24946
|
};
|
|
24926
|
-
|
|
24947
|
+
TimedTextFields = {
|
|
24927
24948
|
text: external_exports.string().min(1).max(2500),
|
|
24928
24949
|
startMs: external_exports.int().nonnegative().max(6e4),
|
|
24929
|
-
endMs: external_exports.int().
|
|
24930
|
-
}
|
|
24950
|
+
endMs: external_exports.int().nonnegative().max(6e4)
|
|
24951
|
+
};
|
|
24952
|
+
TimedWord = external_exports.strictObject(TimedTextFields).refine((v) => v.endMs >= v.startMs);
|
|
24953
|
+
TimedText = external_exports.strictObject(TimedTextFields).refine((v) => v.endMs > v.startMs);
|
|
24931
24954
|
TranscriptSchema = external_exports.discriminatedUnion("timing", [
|
|
24932
24955
|
external_exports.strictObject({ ...TranscriptText, timing: external_exports.literal("UNAVAILABLE") }),
|
|
24933
24956
|
external_exports.strictObject({
|
|
@@ -24935,7 +24958,7 @@ var init_transcription = __esm({
|
|
|
24935
24958
|
timing: external_exports.literal("PROVIDER_REPORTED"),
|
|
24936
24959
|
timeBase: external_exports.literal("ORIGINAL_MEDIA_MS"),
|
|
24937
24960
|
granularities: external_exports.array(external_exports.enum(["word", "segment"])).min(1).max(2),
|
|
24938
|
-
words: external_exports.array(
|
|
24961
|
+
words: external_exports.array(TimedWord).max(1200),
|
|
24939
24962
|
segments: external_exports.array(TimedText).max(240)
|
|
24940
24963
|
}).superRefine((v, c) => {
|
|
24941
24964
|
if (new Set(v.granularities).size !== v.granularities.length)
|
|
@@ -28276,22 +28299,6 @@ var init_workspace = __esm({
|
|
|
28276
28299
|
}
|
|
28277
28300
|
});
|
|
28278
28301
|
|
|
28279
|
-
// packages/contracts/src/local-execution/canonical.ts
|
|
28280
|
-
function canonicalLocalJson(value2) {
|
|
28281
|
-
if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean")
|
|
28282
|
-
return JSON.stringify(value2);
|
|
28283
|
-
if (typeof value2 === "number" && Number.isFinite(value2)) return JSON.stringify(value2);
|
|
28284
|
-
if (Array.isArray(value2)) return "[" + value2.map(canonicalLocalJson).join(",") + "]";
|
|
28285
|
-
if (typeof value2 === "object")
|
|
28286
|
-
return "{" + Object.entries(value2).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => JSON.stringify(k) + ":" + canonicalLocalJson(v)).join(",") + "}";
|
|
28287
|
-
throw new Error("Fingerprint input must be finite JSON data");
|
|
28288
|
-
}
|
|
28289
|
-
var init_canonical = __esm({
|
|
28290
|
-
"packages/contracts/src/local-execution/canonical.ts"() {
|
|
28291
|
-
"use strict";
|
|
28292
|
-
}
|
|
28293
|
-
});
|
|
28294
|
-
|
|
28295
28302
|
// packages/contracts/src/review-limits.ts
|
|
28296
28303
|
var MAX_SHOT_REVIEW_REQUIREMENTS;
|
|
28297
28304
|
var init_review_limits = __esm({
|
|
@@ -29887,6 +29894,7 @@ var init_ipc = __esm({
|
|
|
29887
29894
|
"INVALID_INPUT",
|
|
29888
29895
|
"FRAME_LIMIT",
|
|
29889
29896
|
"BUSY",
|
|
29897
|
+
"PROVIDER_INVENTORY_INVALID",
|
|
29890
29898
|
"AUTHORIZATION_REQUIRED",
|
|
29891
29899
|
"REVISION_CONFLICT",
|
|
29892
29900
|
"CAPABILITY_UNAVAILABLE",
|
|
@@ -30028,8 +30036,14 @@ function qwenVideoGeometry(resolution, aspect) {
|
|
|
30028
30036
|
}
|
|
30029
30037
|
function matchesVideoWorkingGeometry(profile, aspect, width, height) {
|
|
30030
30038
|
const [longEdge, shortEdge] = aspect === "16:9" ? [width, height] : [height, width];
|
|
30031
|
-
|
|
30032
|
-
|
|
30039
|
+
const knownTier = Object.values(qwenVideoWorkingPixels).some(
|
|
30040
|
+
([long, short]) => profile.workingWidth === long && profile.workingHeight === short
|
|
30041
|
+
);
|
|
30042
|
+
if (profile.model === "wan3.0-video" && knownTier) {
|
|
30043
|
+
const exactLong = profile.workingHeight * 16 / 9;
|
|
30044
|
+
const lower = Math.floor(exactLong / 32) * 32;
|
|
30045
|
+
const upper = Math.ceil(exactLong / 32) * 32;
|
|
30046
|
+
return shortEdge === profile.workingHeight && Number.isInteger(longEdge) && longEdge >= lower && longEdge <= upper && longEdge % 2 === 0;
|
|
30033
30047
|
}
|
|
30034
30048
|
return shortEdge === profile.workingHeight && longEdge === profile.workingWidth;
|
|
30035
30049
|
}
|
|
@@ -30080,6 +30094,8 @@ var init_external_generation = __esm({
|
|
|
30080
30094
|
quoteFingerprint: LocalDigestSchema,
|
|
30081
30095
|
// 缺字段表示历史配方;新任务明确记录供应商水印开关。
|
|
30082
30096
|
watermark: external_exports.boolean().optional(),
|
|
30097
|
+
// 仅图片配方冻结补画布策略,旧配方缺省为严格比例。
|
|
30098
|
+
geometryPolicy: external_exports.literal("PAD_TO_ASPECT").optional(),
|
|
30083
30099
|
prompt: external_exports.string().trim().min(1).refine((value2) => new TextEncoder().encode(value2).length <= 1300),
|
|
30084
30100
|
aspectRatio: external_exports.enum(["16:9", "9:16"]),
|
|
30085
30101
|
sources: external_exports.array(qwenSource).min(1).max(3)
|
|
@@ -30088,7 +30104,8 @@ var init_external_generation = __esm({
|
|
|
30088
30104
|
processor: externalKeyframe,
|
|
30089
30105
|
providerExecutionId: external_exports.string().regex(/^[A-Za-z0-9_.:-]{1,500}$/),
|
|
30090
30106
|
providerResultId: LocalDigestSchema,
|
|
30091
|
-
image: keyframeBytes
|
|
30107
|
+
image: keyframeBytes,
|
|
30108
|
+
original: keyframeBytes.optional()
|
|
30092
30109
|
});
|
|
30093
30110
|
QwenVideoOutputSchema = external_exports.strictObject({
|
|
30094
30111
|
resolution: VideoWorkingResolutionSchema,
|
|
@@ -30102,6 +30119,7 @@ var init_external_generation = __esm({
|
|
|
30102
30119
|
};
|
|
30103
30120
|
QwenVideoRecipeSchema = QwenKeyframeRecipeSchema.extend({
|
|
30104
30121
|
processor: external_exports.literal("VIDEO_GENERATE"),
|
|
30122
|
+
geometryPolicy: external_exports.never().optional(),
|
|
30105
30123
|
prompt: external_exports.string().trim().min(1).max(2e4),
|
|
30106
30124
|
mode: external_exports.enum(["REFERENCE_TO_VIDEO", "FIRST_FRAME_TO_VIDEO", "FIRST_LAST_FRAME_TO_VIDEO"]),
|
|
30107
30125
|
durationSeconds: external_exports.int().min(2).max(30),
|
|
@@ -30220,7 +30238,15 @@ var init_preview = __esm({
|
|
|
30220
30238
|
whisperIdentity: LocalWhisperIdentitySchema.optional(),
|
|
30221
30239
|
qwenIdentities: external_exports.array(QwenDeviceCredentialIdentitySchema).min(1).max(16).optional(),
|
|
30222
30240
|
// 新档位须由运行进程明确声明,允许旧节点继续领取原静音配方。
|
|
30223
|
-
mediaOptions: external_exports.array(
|
|
30241
|
+
mediaOptions: external_exports.array(
|
|
30242
|
+
external_exports.enum([
|
|
30243
|
+
"LIBRARY_WAV",
|
|
30244
|
+
"QWEN_WATERMARK",
|
|
30245
|
+
"QWEN_IMAGE_PADDING",
|
|
30246
|
+
"OPENAI_WHISPER_TIMED",
|
|
30247
|
+
"IMPORTED_PRESERVE_V2"
|
|
30248
|
+
])
|
|
30249
|
+
).max(5).optional(),
|
|
30224
30250
|
wanVideoOutput: external_exports.literal("WAN_VIDEO_OUTPUT_V1").optional(),
|
|
30225
30251
|
processorCapabilities: external_exports.array(TenantProcessorKindSchema).min(1).max(TenantProcessorKindSchema.options.length).optional()
|
|
30226
30252
|
}).superRefine(
|
|
@@ -30749,7 +30775,11 @@ var init_component_status = __esm({
|
|
|
30749
30775
|
tenantId: external_exports.uuid(),
|
|
30750
30776
|
agentGrantId: external_exports.uuid().optional()
|
|
30751
30777
|
});
|
|
30752
|
-
DeviceStatusInputSchema = external_exports.strictObject({
|
|
30778
|
+
DeviceStatusInputSchema = external_exports.strictObject({
|
|
30779
|
+
tenantId: external_exports.uuid(),
|
|
30780
|
+
deviceId: external_exports.uuid(),
|
|
30781
|
+
reportsVersion: external_exports.literal(1).optional()
|
|
30782
|
+
});
|
|
30753
30783
|
DeviceStatusSchema = ComponentStatusSchema.extend({
|
|
30754
30784
|
component: external_exports.literal("EXECUTION_NODE"),
|
|
30755
30785
|
source: external_exports.literal("DEVICE_HEARTBEAT_AND_NATIVE_WORK"),
|
|
@@ -30758,7 +30788,12 @@ var init_component_status = __esm({
|
|
|
30758
30788
|
deviceRevision: external_exports.int().positive(),
|
|
30759
30789
|
runtimeVersion: external_exports.string().min(1).max(120).nullable(),
|
|
30760
30790
|
runtimeVersionObservedAt: timestamp.nullable(),
|
|
30761
|
-
capabilityMismatch: CapabilityVersionMismatchSchema.optional()
|
|
30791
|
+
capabilityMismatch: CapabilityVersionMismatchSchema.optional(),
|
|
30792
|
+
// 云端只证明存在原报告请求,不能从心跳判断本机期刊或安装状态。
|
|
30793
|
+
reportReconciliation: external_exports.strictObject({
|
|
30794
|
+
center: external_exports.enum(["PREPARED_REPORT_OBSERVED", "NONE_OBSERVED", "NOT_APPLICABLE"]),
|
|
30795
|
+
hostJournal: external_exports.literal("UNKNOWN")
|
|
30796
|
+
}).optional()
|
|
30762
30797
|
});
|
|
30763
30798
|
}
|
|
30764
30799
|
});
|
|
@@ -31026,13 +31061,15 @@ var init_openai_realtime_speech = __esm({
|
|
|
31026
31061
|
});
|
|
31027
31062
|
|
|
31028
31063
|
// packages/contracts/src/openai-asr.ts
|
|
31029
|
-
var openAiAsrModelId, openAiAsrProfileId, openAiAsrTranscriptMaxBytes, OpenAiAsrParametersSchema, tokens, TokenUsage, OpenAiAsrUsageSchema, OpenAiAsrProviderSchema;
|
|
31064
|
+
var openAiAsrModelId, openAiAsrProfileId, openAiWhisperModelId, openAiWhisperProfileId, openAiAsrTranscriptMaxBytes, OpenAiAsrParametersSchema, OpenAiWhisperParametersSchema, tokens, TokenUsage, OpenAiAsrUsageSchema, receiptFields, OpenAiAsrProviderSchema;
|
|
31030
31065
|
var init_openai_asr = __esm({
|
|
31031
31066
|
"packages/contracts/src/openai-asr.ts"() {
|
|
31032
31067
|
"use strict";
|
|
31033
31068
|
init_zod();
|
|
31034
31069
|
openAiAsrModelId = "gpt-transcribe";
|
|
31035
31070
|
openAiAsrProfileId = "openai-gpt-transcribe";
|
|
31071
|
+
openAiWhisperModelId = "whisper-1";
|
|
31072
|
+
openAiWhisperProfileId = "openai-whisper-timed";
|
|
31036
31073
|
openAiAsrTranscriptMaxBytes = 66 * 1024;
|
|
31037
31074
|
OpenAiAsrParametersSchema = external_exports.strictObject({
|
|
31038
31075
|
prompt: external_exports.string().max(2e3).refine((v) => v.isWellFormed() && !v.includes("\0")).optional(),
|
|
@@ -31041,6 +31078,12 @@ var init_openai_asr = __esm({
|
|
|
31041
31078
|
external_exports.string().min(1).max(100).refine((v) => v.isWellFormed() && !/[<>\r\n\0]/.test(v))
|
|
31042
31079
|
).max(100).optional()
|
|
31043
31080
|
});
|
|
31081
|
+
OpenAiWhisperParametersSchema = external_exports.strictObject({
|
|
31082
|
+
timestamp_granularities: external_exports.array(external_exports.enum(["word", "segment"])).min(1).max(2).refine((v) => new Set(v).size === v.length),
|
|
31083
|
+
language: external_exports.string().regex(/^[a-z]{2}$/i).optional(),
|
|
31084
|
+
prompt: external_exports.string().max(2e3).refine((v) => v.isWellFormed() && !v.includes("\0")).optional(),
|
|
31085
|
+
temperature: external_exports.number().min(0).max(1).optional()
|
|
31086
|
+
});
|
|
31044
31087
|
tokens = external_exports.int().min(0).max(1e7);
|
|
31045
31088
|
TokenUsage = external_exports.strictObject({
|
|
31046
31089
|
input_tokens: tokens,
|
|
@@ -31052,13 +31095,23 @@ var init_openai_asr = __esm({
|
|
|
31052
31095
|
TokenUsage,
|
|
31053
31096
|
external_exports.strictObject({})
|
|
31054
31097
|
]);
|
|
31055
|
-
|
|
31056
|
-
protocol: external_exports.literal("OPENAI_TRANSCRIPTION_V1"),
|
|
31057
|
-
model: external_exports.literal(openAiAsrModelId),
|
|
31098
|
+
receiptFields = {
|
|
31058
31099
|
requestId: external_exports.string().regex(/^[A-Za-z0-9_.:-]{1,500}$/),
|
|
31059
31100
|
requestSha256: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
31060
31101
|
usage: OpenAiAsrUsageSchema
|
|
31061
|
-
}
|
|
31102
|
+
};
|
|
31103
|
+
OpenAiAsrProviderSchema = external_exports.discriminatedUnion("protocol", [
|
|
31104
|
+
external_exports.strictObject({
|
|
31105
|
+
protocol: external_exports.literal("OPENAI_TRANSCRIPTION_V1"),
|
|
31106
|
+
model: external_exports.literal(openAiAsrModelId),
|
|
31107
|
+
...receiptFields
|
|
31108
|
+
}),
|
|
31109
|
+
external_exports.strictObject({
|
|
31110
|
+
protocol: external_exports.literal("OPENAI_WHISPER_TRANSCRIPTION_V1"),
|
|
31111
|
+
model: external_exports.literal(openAiWhisperModelId),
|
|
31112
|
+
...receiptFields
|
|
31113
|
+
})
|
|
31114
|
+
]);
|
|
31062
31115
|
}
|
|
31063
31116
|
});
|
|
31064
31117
|
|
|
@@ -31125,8 +31178,14 @@ var init_recognition = __esm({
|
|
|
31125
31178
|
});
|
|
31126
31179
|
|
|
31127
31180
|
// packages/contracts/src/local-execution/openai-asr.ts
|
|
31128
|
-
function openAiAsrRequestIdentity({ source: source5, parameters }) {
|
|
31129
|
-
return {
|
|
31181
|
+
function openAiAsrRequestIdentity({ source: source5, parameters, model: model3 }) {
|
|
31182
|
+
return {
|
|
31183
|
+
model: model3 ?? openAiAsrModelId,
|
|
31184
|
+
responseFormat: model3 ? "verbose_json" : "json",
|
|
31185
|
+
stream: false,
|
|
31186
|
+
source: source5,
|
|
31187
|
+
parameters
|
|
31188
|
+
};
|
|
31130
31189
|
}
|
|
31131
31190
|
var OpenAiAsrRecipeSchema, OpenAiAsrEvidenceSchema;
|
|
31132
31191
|
var init_openai_asr2 = __esm({
|
|
@@ -31144,8 +31203,14 @@ var init_openai_asr2 = __esm({
|
|
|
31144
31203
|
connectionVersion: LocalRevisionSchema,
|
|
31145
31204
|
credentialVersion: LocalRevisionSchema,
|
|
31146
31205
|
source: TranscribeAudioRecipeSchema.shape.source,
|
|
31147
|
-
|
|
31148
|
-
|
|
31206
|
+
model: external_exports.literal(openAiWhisperModelId).optional(),
|
|
31207
|
+
parameters: external_exports.union([OpenAiAsrParametersSchema, OpenAiWhisperParametersSchema])
|
|
31208
|
+
}).refine(
|
|
31209
|
+
(recipe) => (recipe.model ? OpenAiWhisperParametersSchema : OpenAiAsrParametersSchema).safeParse(
|
|
31210
|
+
recipe.parameters
|
|
31211
|
+
).success,
|
|
31212
|
+
"Transcription parameters must match the selected model"
|
|
31213
|
+
);
|
|
31149
31214
|
OpenAiAsrEvidenceSchema = external_exports.strictObject({
|
|
31150
31215
|
processor: OpenAiAsrRecipeSchema.shape.processor,
|
|
31151
31216
|
provider: OpenAiAsrProviderSchema,
|
|
@@ -31158,6 +31223,27 @@ var init_openai_asr2 = __esm({
|
|
|
31158
31223
|
});
|
|
31159
31224
|
|
|
31160
31225
|
// packages/contracts/src/imported-visual-normalization.ts
|
|
31226
|
+
function validateImportedVisualClock(v, ctx) {
|
|
31227
|
+
if (![
|
|
31228
|
+
v.durationTicks,
|
|
31229
|
+
v.timeBase.numerator,
|
|
31230
|
+
v.timeBase.denominator,
|
|
31231
|
+
v.frameRate.numerator,
|
|
31232
|
+
v.frameRate.denominator,
|
|
31233
|
+
v.frameCount,
|
|
31234
|
+
v.availableCfr30Frames
|
|
31235
|
+
].every(Number.isSafeInteger) || v.timeBase.denominator <= 0 || v.frameRate.numerator <= 0 || v.frameRate.denominator <= 0)
|
|
31236
|
+
return;
|
|
31237
|
+
const ticks = BigInt(v.durationTicks) * BigInt(v.timeBase.numerator);
|
|
31238
|
+
const base5 = BigInt(v.timeBase.denominator);
|
|
31239
|
+
const declaredFrames = ticks * BigInt(v.frameRate.numerator);
|
|
31240
|
+
const expectedFrames = BigInt(v.frameCount) * base5 * BigInt(v.frameRate.denominator);
|
|
31241
|
+
if (ticks > 60n * base5 || declaredFrames !== expectedFrames || BigInt(v.availableCfr30Frames) !== ticks * 30n / base5 || v.audio && BigInt(v.audio.durationTicks) * BigInt(v.audio.timeBase.numerator) > 60n * BigInt(v.audio.timeBase.denominator))
|
|
31242
|
+
ctx.addIssue({
|
|
31243
|
+
code: "custom",
|
|
31244
|
+
message: "Media clock/count/duration metadata is inconsistent"
|
|
31245
|
+
});
|
|
31246
|
+
}
|
|
31161
31247
|
var IMPORTED_VISUAL_PROFILE_ID, IMPORTED_VISUAL_MAX_BYTES, Hash, PositiveInteger, ImportedVisualRationalSchema, geometry, ImportedVisualToolchainSchema, ImportedVisualSourceInputSchema, ImportedVisualSourceRangeSchema, ImportedVisualNormalizationRequestSchema, ImportedVisualSourceMetadataSchema, ImportedVisualInspectionSchema, ImportedVisualNormalizationReceiptSchema;
|
|
31162
31248
|
var init_imported_visual_normalization = __esm({
|
|
31163
31249
|
"packages/contracts/src/imported-visual-normalization.ts"() {
|
|
@@ -31234,27 +31320,7 @@ var init_imported_visual_normalization = __esm({
|
|
|
31234
31320
|
}).nullable(),
|
|
31235
31321
|
fullDecode: external_exports.literal(true),
|
|
31236
31322
|
cfrTimestampsVerified: external_exports.literal(true)
|
|
31237
|
-
}).superRefine(
|
|
31238
|
-
if (![
|
|
31239
|
-
v.durationTicks,
|
|
31240
|
-
v.timeBase.numerator,
|
|
31241
|
-
v.timeBase.denominator,
|
|
31242
|
-
v.frameRate.numerator,
|
|
31243
|
-
v.frameRate.denominator,
|
|
31244
|
-
v.frameCount,
|
|
31245
|
-
v.availableCfr30Frames
|
|
31246
|
-
].every(Number.isSafeInteger) || v.timeBase.denominator <= 0 || v.frameRate.numerator <= 0 || v.frameRate.denominator <= 0)
|
|
31247
|
-
return;
|
|
31248
|
-
const ticks = BigInt(v.durationTicks) * BigInt(v.timeBase.numerator);
|
|
31249
|
-
const base5 = BigInt(v.timeBase.denominator);
|
|
31250
|
-
const declaredFrames = ticks * BigInt(v.frameRate.numerator);
|
|
31251
|
-
const expectedFrames = BigInt(v.frameCount) * base5 * BigInt(v.frameRate.denominator);
|
|
31252
|
-
if (ticks > 60n * base5 || declaredFrames !== expectedFrames || BigInt(v.availableCfr30Frames) !== ticks * 30n / base5 || v.audio && BigInt(v.audio.durationTicks) * BigInt(v.audio.timeBase.numerator) > 60n * BigInt(v.audio.timeBase.denominator))
|
|
31253
|
-
ctx.addIssue({
|
|
31254
|
-
code: "custom",
|
|
31255
|
-
message: "Media clock/count/duration metadata is inconsistent"
|
|
31256
|
-
});
|
|
31257
|
-
});
|
|
31323
|
+
}).superRefine(validateImportedVisualClock);
|
|
31258
31324
|
ImportedVisualInspectionSchema = external_exports.strictObject({
|
|
31259
31325
|
profileId: external_exports.literal(IMPORTED_VISUAL_PROFILE_ID),
|
|
31260
31326
|
source: ImportedVisualSourceMetadataSchema,
|
|
@@ -31308,6 +31374,92 @@ var init_imported_visual_normalization = __esm({
|
|
|
31308
31374
|
}
|
|
31309
31375
|
});
|
|
31310
31376
|
|
|
31377
|
+
// packages/contracts/src/imported-visual/preserve.ts
|
|
31378
|
+
function preservesEncodedAspect(source5, output3) {
|
|
31379
|
+
if (![source5.width, source5.height, output3.width, output3.height].every(
|
|
31380
|
+
(n) => Number.isSafeInteger(n) && n >= 2 && n % 2 === 0
|
|
31381
|
+
))
|
|
31382
|
+
return false;
|
|
31383
|
+
const sourceLandscape = source5.width >= source5.height;
|
|
31384
|
+
const outputLandscape = output3.width >= output3.height;
|
|
31385
|
+
return output3.width <= source5.width && output3.height <= source5.height && sourceLandscape === outputLandscape && Math.abs(output3.width * source5.height - output3.height * source5.width) <= Math.max(source5.width, source5.height);
|
|
31386
|
+
}
|
|
31387
|
+
var PRESERVE_VISUAL_PROFILE_ID, geometry2, PreserveVisualSourceMetadataSchema, PreserveVisualNormalizationRequestSchema, PreserveVisualInspectionSchema, PreserveVisualNormalizationReceiptSchema, AnyImportedVisualSourceMetadataSchema, AnyImportedVisualNormalizationRequestSchema, AnyImportedVisualNormalizationReceiptSchema;
|
|
31388
|
+
var init_preserve = __esm({
|
|
31389
|
+
"packages/contracts/src/imported-visual/preserve.ts"() {
|
|
31390
|
+
"use strict";
|
|
31391
|
+
init_zod();
|
|
31392
|
+
init_imported_visual_normalization();
|
|
31393
|
+
PRESERVE_VISUAL_PROFILE_ID = "IMPORTED_H264_SDR_CFR30_PRESERVE_V2";
|
|
31394
|
+
geometry2 = (max) => external_exports.strictObject({
|
|
31395
|
+
width: external_exports.int().min(2).max(max).multipleOf(2),
|
|
31396
|
+
height: external_exports.int().min(2).max(max).multipleOf(2)
|
|
31397
|
+
});
|
|
31398
|
+
PreserveVisualSourceMetadataSchema = external_exports.strictObject({
|
|
31399
|
+
...ImportedVisualSourceMetadataSchema.shape,
|
|
31400
|
+
geometryProfile: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID),
|
|
31401
|
+
geometry: geometry2(3840),
|
|
31402
|
+
sampleAspectRatio: external_exports.enum(["1:1", "UNSPECIFIED"]),
|
|
31403
|
+
fieldOrder: external_exports.enum(["PROGRESSIVE", "UNSPECIFIED"])
|
|
31404
|
+
}).superRefine(validateImportedVisualClock);
|
|
31405
|
+
PreserveVisualNormalizationRequestSchema = ImportedVisualNormalizationRequestSchema.extend({
|
|
31406
|
+
schemaVersion: external_exports.literal(2),
|
|
31407
|
+
profileId: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID),
|
|
31408
|
+
output: geometry2(1920),
|
|
31409
|
+
framing: external_exports.literal("PRESERVE_SOURCE"),
|
|
31410
|
+
pixelAspectPolicy: external_exports.enum(["REQUIRE_SQUARE", "ASSUME_SQUARE_WHEN_UNSPECIFIED"])
|
|
31411
|
+
});
|
|
31412
|
+
PreserveVisualInspectionSchema = external_exports.strictObject({
|
|
31413
|
+
profileId: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID),
|
|
31414
|
+
source: PreserveVisualSourceMetadataSchema,
|
|
31415
|
+
toolchain: ImportedVisualToolchainSchema,
|
|
31416
|
+
evidenceScope: external_exports.literal("TECHNICAL_MEDIA_ONLY")
|
|
31417
|
+
});
|
|
31418
|
+
PreserveVisualNormalizationReceiptSchema = external_exports.strictObject({
|
|
31419
|
+
schemaVersion: external_exports.literal(2),
|
|
31420
|
+
request: PreserveVisualNormalizationRequestSchema,
|
|
31421
|
+
original: PreserveVisualSourceMetadataSchema,
|
|
31422
|
+
output: PreserveVisualSourceMetadataSchema,
|
|
31423
|
+
toolchain: ImportedVisualToolchainSchema,
|
|
31424
|
+
frameMap: ImportedVisualNormalizationReceiptSchema.shape.frameMap,
|
|
31425
|
+
audioDisposition: external_exports.enum(["NO_AUDIO_PRESENT", "REMOVED_FROM_DERIVATIVE_ONLY"]),
|
|
31426
|
+
evidenceScope: external_exports.literal("TECHNICAL_MEDIA_ONLY")
|
|
31427
|
+
}).superRefine((v, ctx) => {
|
|
31428
|
+
const { original: source5, request, output: output3 } = v;
|
|
31429
|
+
if (![
|
|
31430
|
+
source5.frameRate.numerator,
|
|
31431
|
+
source5.frameRate.denominator,
|
|
31432
|
+
source5.timeBase.numerator,
|
|
31433
|
+
source5.timeBase.denominator
|
|
31434
|
+
].every(Number.isSafeInteger))
|
|
31435
|
+
return;
|
|
31436
|
+
const count3 = request.sourceRange.endFrame - request.sourceRange.startFrame;
|
|
31437
|
+
const rounded = (i) => (2n * BigInt(i) * 30n * BigInt(source5.frameRate.denominator) + BigInt(source5.frameRate.numerator)) / (2n * BigInt(source5.frameRate.numerator));
|
|
31438
|
+
const frames = v.frameMap.every((f, i) => {
|
|
31439
|
+
const absolute = BigInt(request.sourceRange.startFrame + i);
|
|
31440
|
+
return f.outputFrame === i && f.sourceFrame < source5.frameCount && BigInt(f.sourcePts) * BigInt(source5.timeBase.numerator) * BigInt(source5.frameRate.numerator) === BigInt(f.sourceFrame) * BigInt(source5.timeBase.denominator) * BigInt(source5.frameRate.denominator) && rounded(f.sourceFrame) <= absolute && (f.sourceFrame + 1 === source5.frameCount || rounded(f.sourceFrame + 1) > absolute);
|
|
31441
|
+
});
|
|
31442
|
+
if (!frames || v.frameMap.length !== count3 || request.sourceRange.endFrame > source5.availableCfr30Frames || !preservesEncodedAspect(source5.geometry, request.output) || source5.sampleAspectRatio === "UNSPECIFIED" && request.pixelAspectPolicy !== "ASSUME_SQUARE_WHEN_UNSPECIFIED" || output3.sampleAspectRatio !== "1:1" || output3.geometry.width !== request.output.width || output3.geometry.height !== request.output.height || output3.frameCount !== count3 || output3.frameRate.numerator !== 30 || output3.frameRate.denominator !== 1 || output3.audio !== null || source5.checksumSha256 !== request.source.checksumSha256 || source5.byteSize !== request.source.byteSize || source5.executionClass !== request.source.executionClass || output3.executionClass !== source5.executionClass || v.toolchain.ffmpegVersion !== request.expectedToolchain.ffmpegVersion || v.toolchain.ffprobeVersion !== request.expectedToolchain.ffprobeVersion || v.audioDisposition !== (source5.audio ? "REMOVED_FROM_DERIVATIVE_ONLY" : "NO_AUDIO_PRESENT") || source5.audio !== null && request.audioPolicy !== "SILENT_DERIVATIVE")
|
|
31443
|
+
ctx.addIssue({
|
|
31444
|
+
code: "custom",
|
|
31445
|
+
message: "Preserved normalization must match its source, proportional output, frame clock and audio policy"
|
|
31446
|
+
});
|
|
31447
|
+
});
|
|
31448
|
+
AnyImportedVisualSourceMetadataSchema = external_exports.union([
|
|
31449
|
+
ImportedVisualSourceMetadataSchema,
|
|
31450
|
+
PreserveVisualSourceMetadataSchema
|
|
31451
|
+
]);
|
|
31452
|
+
AnyImportedVisualNormalizationRequestSchema = external_exports.union([
|
|
31453
|
+
ImportedVisualNormalizationRequestSchema,
|
|
31454
|
+
PreserveVisualNormalizationRequestSchema
|
|
31455
|
+
]);
|
|
31456
|
+
AnyImportedVisualNormalizationReceiptSchema = external_exports.union([
|
|
31457
|
+
ImportedVisualNormalizationReceiptSchema,
|
|
31458
|
+
PreserveVisualNormalizationReceiptSchema
|
|
31459
|
+
]);
|
|
31460
|
+
}
|
|
31461
|
+
});
|
|
31462
|
+
|
|
31311
31463
|
// packages/contracts/src/imported-visual/owner.ts
|
|
31312
31464
|
var Uuid, Hash2, ImportedVisualOriginalRegisterSchema, ImportedVisualFromProjectSourceSchema, ImportedVisualOriginalReviseSchema, ImportedVisualNormalizeStartSchema, ImportedVisualGetSchema, ImportedVisualReviewSchema, ImportedVisualDecisionSchema, ImportedVisualOriginalViewSchema, ImportedVisualNormalizationViewSchema;
|
|
31313
31465
|
var init_owner = __esm({
|
|
@@ -31315,14 +31467,18 @@ var init_owner = __esm({
|
|
|
31315
31467
|
"use strict";
|
|
31316
31468
|
init_review_limits();
|
|
31317
31469
|
init_zod();
|
|
31318
|
-
init_imported_visual_normalization();
|
|
31319
31470
|
init_video_review();
|
|
31320
31471
|
init_device_render();
|
|
31472
|
+
init_preserve();
|
|
31321
31473
|
Uuid = external_exports.uuid();
|
|
31322
31474
|
Hash2 = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
31323
31475
|
ImportedVisualOriginalRegisterSchema = external_exports.strictObject({
|
|
31324
31476
|
// 直传设备受理将目标纳入原请求指纹,旧同步入口拒绝此字段的执行要求。
|
|
31325
31477
|
deviceId: external_exports.uuid().toLowerCase().optional(),
|
|
31478
|
+
// 显式冻结新几何档;省略仍沿历史 V1 处理。
|
|
31479
|
+
geometryProfile: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID).optional().describe(
|
|
31480
|
+
"Select the actual-dimensions device profile for a new original; importing an existing Project SOURCE inherits its frozen profile."
|
|
31481
|
+
),
|
|
31326
31482
|
projectSourceArtifactId: external_exports.uuid().optional(),
|
|
31327
31483
|
tenantId: Uuid,
|
|
31328
31484
|
projectId: Uuid,
|
|
@@ -31360,7 +31516,7 @@ var init_owner = __esm({
|
|
|
31360
31516
|
sourceId: Uuid,
|
|
31361
31517
|
sourceVersionId: Uuid,
|
|
31362
31518
|
expectedProductionRevision: external_exports.int().nonnegative(),
|
|
31363
|
-
request:
|
|
31519
|
+
request: AnyImportedVisualNormalizationRequestSchema,
|
|
31364
31520
|
idempotencyKey: external_exports.string().trim().min(1).max(200)
|
|
31365
31521
|
});
|
|
31366
31522
|
ImportedVisualGetSchema = external_exports.strictObject({
|
|
@@ -31400,7 +31556,7 @@ var init_owner = __esm({
|
|
|
31400
31556
|
shotId: Uuid,
|
|
31401
31557
|
artifactId: Uuid,
|
|
31402
31558
|
representationId: Uuid,
|
|
31403
|
-
metadata:
|
|
31559
|
+
metadata: AnyImportedVisualSourceMetadataSchema,
|
|
31404
31560
|
declaredProvenance: ImportedVisualOriginalRegisterSchema.shape.declaredProvenance.optional(),
|
|
31405
31561
|
executionClass: external_exports.enum(["LIVE", "TEST_ONLY"]),
|
|
31406
31562
|
current: external_exports.boolean(),
|
|
@@ -31413,7 +31569,7 @@ var init_owner = __esm({
|
|
|
31413
31569
|
sourceVersionId: Uuid,
|
|
31414
31570
|
lifecycle: external_exports.string(),
|
|
31415
31571
|
cancellationRequested: external_exports.boolean(),
|
|
31416
|
-
receipt:
|
|
31572
|
+
receipt: AnyImportedVisualNormalizationReceiptSchema.nullable(),
|
|
31417
31573
|
output: external_exports.strictObject({
|
|
31418
31574
|
artifactId: Uuid,
|
|
31419
31575
|
representationId: Uuid,
|
|
@@ -31735,6 +31891,7 @@ var init_imported_visual = __esm({
|
|
|
31735
31891
|
"packages/contracts/src/imported-visual/index.ts"() {
|
|
31736
31892
|
"use strict";
|
|
31737
31893
|
init_imported_visual_normalization();
|
|
31894
|
+
init_preserve();
|
|
31738
31895
|
init_owner();
|
|
31739
31896
|
init_synchronous_audio();
|
|
31740
31897
|
init_source_sync_owner();
|
|
@@ -31801,6 +31958,7 @@ var init_artifact = __esm({
|
|
|
31801
31958
|
"packages/contracts/src/artifact.ts"() {
|
|
31802
31959
|
"use strict";
|
|
31803
31960
|
init_zod();
|
|
31961
|
+
init_preserve();
|
|
31804
31962
|
init_ids();
|
|
31805
31963
|
ArtifactLifecycleSchema = external_exports.enum([
|
|
31806
31964
|
"CREATING",
|
|
@@ -31896,6 +32054,10 @@ var init_artifact = __esm({
|
|
|
31896
32054
|
idempotencyKey: external_exports.string().trim().min(1).max(200).optional(),
|
|
31897
32055
|
tenantId: TenantIdSchema,
|
|
31898
32056
|
kind: external_exports.enum(["PRODUCT_INFORMATION", "REFERENCE_IMAGE", "REFERENCE_VIDEO"]),
|
|
32057
|
+
// 仅视频直传可显式选择版本化几何档,不改变旧请求的严格默认值。
|
|
32058
|
+
videoGeometryProfile: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID).optional().describe(
|
|
32059
|
+
"Select this profile for device video intake that preserves actual encoded dimensions; omission retains the historical strict V1 contract."
|
|
32060
|
+
),
|
|
31899
32061
|
contentType: external_exports.enum([
|
|
31900
32062
|
"text/plain",
|
|
31901
32063
|
"application/json",
|
|
@@ -31936,7 +32098,7 @@ var init_project_source_direct = __esm({
|
|
|
31936
32098
|
{ message: "Video SOURCE is limited to 128 MiB; image SOURCE is limited to 8 MiB" }
|
|
31937
32099
|
).refine(
|
|
31938
32100
|
({ metadata: metadata2 }) => metadata2.kind === "REFERENCE_VIDEO" ? metadata2.contentType === "video/mp4" : metadata2.kind === "REFERENCE_IMAGE" && ["image/png", "image/jpeg", "image/webp"].includes(metadata2.contentType)
|
|
31939
|
-
);
|
|
32101
|
+
).refine(({ metadata: metadata2 }) => !metadata2.videoGeometryProfile || metadata2.kind === "REFERENCE_VIDEO");
|
|
31940
32102
|
DirectProjectSourceKeySchema = LocalProjectScopeSchema.extend({
|
|
31941
32103
|
intakeId: LocalIdSchema
|
|
31942
32104
|
});
|
|
@@ -31983,6 +32145,11 @@ function destinationMatches(destination, reference2) {
|
|
|
31983
32145
|
const { command: command4 } = destination;
|
|
31984
32146
|
return sameId(command4.metadata.tenantId, reference2.tenantId) && sameId(command4.projectId, reference2.projectId) && (!command4.requestedDeviceId || sameId(command4.requestedDeviceId, reference2.deviceId)) && command4.metadata.contentType === reference2.contentType && command4.byteSize === reference2.byteSize && command4.checksumSha256 === reference2.checksumSha256;
|
|
31985
32147
|
}
|
|
32148
|
+
function localLibraryVideoGeometry(recipe) {
|
|
32149
|
+
if (recipe.processor === "LOCAL_MEDIA_INSPECT") return recipe.geometryProfile;
|
|
32150
|
+
const d = recipe.destination;
|
|
32151
|
+
return d.kind === "ORIGINAL" ? d.command.input.geometryProfile : d.kind === "PROJECT_SOURCE" ? d.command.metadata.videoGeometryProfile : void 0;
|
|
32152
|
+
}
|
|
31986
32153
|
var LocalLibraryDestinationSchema, sameId, command, LocalLibraryCommandSchema, LocalLibraryCommandQuerySchema, LocalLibraryAdmissionSchema, LocalLibraryInspectionSchema, LocalLibraryInspectRecipeSchema, LocalLibraryPublishRecipeSchema, LocalLibraryInspectEvidenceSchema, LocalLibraryPublishEvidenceSchema;
|
|
31987
32154
|
var init_library_command = __esm({
|
|
31988
32155
|
"packages/contracts/src/local-execution/library-command.ts"() {
|
|
@@ -32008,14 +32175,21 @@ var init_library_command = __esm({
|
|
|
32008
32175
|
accessRevision: external_exports.int().positive()
|
|
32009
32176
|
});
|
|
32010
32177
|
LocalLibraryCommandSchema = external_exports.discriminatedUnion("action", [
|
|
32011
|
-
command.extend({
|
|
32178
|
+
command.extend({
|
|
32179
|
+
action: external_exports.literal("INSPECT"),
|
|
32180
|
+
geometryProfile: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID).optional()
|
|
32181
|
+
}),
|
|
32012
32182
|
command.extend({ action: external_exports.literal("PUBLISH"), destination: LocalLibraryDestinationSchema })
|
|
32013
32183
|
]).superRefine((value2, ctx) => {
|
|
32014
32184
|
if (value2.reference.tenantId !== value2.tenantId || value2.reference.projectId !== value2.projectId)
|
|
32015
32185
|
ctx.addIssue({ code: "custom", message: "Exact local file project required" });
|
|
32016
32186
|
if (!localLibraryInspectable(value2.reference))
|
|
32017
32187
|
ctx.addIssue({ code: "custom", message: "A qualified media file version is required" });
|
|
32018
|
-
if (value2.action !== "PUBLISH")
|
|
32188
|
+
if (value2.action !== "PUBLISH") {
|
|
32189
|
+
if (value2.geometryProfile && value2.reference.contentType !== "video/mp4")
|
|
32190
|
+
ctx.addIssue({ code: "custom", message: "Video geometry requires a video file" });
|
|
32191
|
+
return;
|
|
32192
|
+
}
|
|
32019
32193
|
const d = value2.destination;
|
|
32020
32194
|
if (d.kind === "AUDIO") {
|
|
32021
32195
|
if (!sameId(d.command.productionId, value2.productionId) || !destinationMatches(d, value2.reference) || d.command.idempotencyKey.startsWith("resource-use:"))
|
|
@@ -32041,7 +32215,7 @@ var init_library_command = __esm({
|
|
|
32041
32215
|
accessRevision: external_exports.int().positive()
|
|
32042
32216
|
});
|
|
32043
32217
|
LocalLibraryInspectionSchema = external_exports.discriminatedUnion("kind", [
|
|
32044
|
-
external_exports.strictObject({ kind: external_exports.literal("VIDEO"), metadata:
|
|
32218
|
+
external_exports.strictObject({ kind: external_exports.literal("VIDEO"), metadata: AnyImportedVisualSourceMetadataSchema }),
|
|
32045
32219
|
external_exports.strictObject({
|
|
32046
32220
|
kind: external_exports.literal("AUDIO"),
|
|
32047
32221
|
checksumSha256: LocalDigestSchema,
|
|
@@ -32060,9 +32234,10 @@ var init_library_command = __esm({
|
|
|
32060
32234
|
processor: external_exports.literal("LOCAL_MEDIA_INSPECT"),
|
|
32061
32235
|
reference: LocalLibraryReferenceSchema,
|
|
32062
32236
|
accessRevision: external_exports.int().positive(),
|
|
32063
|
-
libraryProfileDigest: LocalDigestSchema
|
|
32237
|
+
libraryProfileDigest: LocalDigestSchema,
|
|
32238
|
+
geometryProfile: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID).optional()
|
|
32064
32239
|
}).refine(
|
|
32065
|
-
({ reference: reference2 }) => localLibraryInspectable(reference2),
|
|
32240
|
+
({ reference: reference2, geometryProfile }) => localLibraryInspectable(reference2) && (!geometryProfile || reference2.contentType === "video/mp4"),
|
|
32066
32241
|
"Qualified local inspection required"
|
|
32067
32242
|
);
|
|
32068
32243
|
LocalLibraryPublishRecipeSchema = external_exports.strictObject({
|
|
@@ -32815,7 +32990,10 @@ function processorOutputSlots(recipe) {
|
|
|
32815
32990
|
case "REFERENCE_PREVIEW":
|
|
32816
32991
|
return [{ role: "POSTER", ordinal: 0 }];
|
|
32817
32992
|
case "KEYFRAME_GENERATE":
|
|
32818
|
-
return [
|
|
32993
|
+
return [
|
|
32994
|
+
{ role: "FRAME", ordinal: 0 },
|
|
32995
|
+
...recipe.geometryPolicy === "PAD_TO_ASPECT" ? [{ role: "FRAME", ordinal: 1 }] : []
|
|
32996
|
+
];
|
|
32819
32997
|
case "VIDEO_GENERATE":
|
|
32820
32998
|
return [
|
|
32821
32999
|
{ role: "VIDEO", ordinal: 0 },
|
|
@@ -32874,13 +33052,15 @@ var init_processor_recipes = __esm({
|
|
|
32874
33052
|
normalize = external_exports.strictObject({
|
|
32875
33053
|
processor: external_exports.literal("IMPORTED_VISUAL_NORMALIZE"),
|
|
32876
33054
|
source: source2,
|
|
32877
|
-
request:
|
|
33055
|
+
request: AnyImportedVisualNormalizationRequestSchema
|
|
32878
33056
|
}).refine(
|
|
32879
33057
|
({ request, source: source5 }) => request.source.byteSize === source5.byteSize && request.source.checksumSha256 === source5.checksumSha256,
|
|
32880
33058
|
"Original representation must match the normalization request"
|
|
32881
33059
|
);
|
|
32882
33060
|
audio = external_exports.strictObject({
|
|
32883
33061
|
processor: external_exports.literal("SOURCE_SYNC_AUDIO"),
|
|
33062
|
+
// 同步音轨跟随原片的几何协议,不能退回旧解析器。
|
|
33063
|
+
sourceGeometryProfile: external_exports.literal(PRESERVE_VISUAL_PROFILE_ID).optional(),
|
|
32884
33064
|
source: source2,
|
|
32885
33065
|
input: ImportedVisualSourceInputSchema,
|
|
32886
33066
|
extraction: ImportedSynchronousAudioExtractionSchema
|
|
@@ -32941,7 +33121,8 @@ var init_processor_recipes = __esm({
|
|
|
32941
33121
|
projectId: LocalIdSchema,
|
|
32942
33122
|
object: MediaObjectVersionSchema.extend({ role: external_exports.literal("SOURCE") })
|
|
32943
33123
|
}).refine(
|
|
32944
|
-
({ metadata: metadata2, projectId, object: object3 }) => metadata2.tenantId === object3.tenantId && projectId === object3.projectId &&
|
|
33124
|
+
({ metadata: metadata2, projectId, object: object3 }) => metadata2.tenantId === object3.tenantId && projectId === object3.projectId && // 设备配方与现有直传合同一致:视频 128 MiB、图片 8 MiB。
|
|
33125
|
+
object3.byteSize <= (metadata2.kind === "REFERENCE_VIDEO" ? 128 : 8) * 1024 * 1024 && (!metadata2.videoGeometryProfile || metadata2.kind === "REFERENCE_VIDEO") && (metadata2.kind === "REFERENCE_VIDEO" ? metadata2.contentType === "video/mp4" : metadata2.kind === "REFERENCE_IMAGE" && ["image/png", "image/jpeg", "image/webp"].includes(metadata2.contentType))
|
|
32945
33126
|
);
|
|
32946
33127
|
visualSequence = external_exports.strictObject({
|
|
32947
33128
|
processor: external_exports.literal("REGISTER_VISUAL_SEQUENCE"),
|
|
@@ -33021,7 +33202,7 @@ function matchesEvidence(outputs, evidence2) {
|
|
|
33021
33202
|
case "TRANSCRIBE_EXTERNAL_OPENAI":
|
|
33022
33203
|
return outputs.length === 1 && matches(0, "MANIFEST", evidence2.transcriptDigest);
|
|
33023
33204
|
case "KEYFRAME_GENERATE":
|
|
33024
|
-
return outputs.length ===
|
|
33205
|
+
return matches(0, "FRAME", evidence2.image) && (evidence2.original ? outputs.length === 2 && matches(1, "FRAME", evidence2.original) : outputs.length === 1);
|
|
33025
33206
|
case "VIDEO_GENERATE":
|
|
33026
33207
|
return outputs.length === (evidence2.sound ? 3 : 2) && matches(0, "VIDEO", evidence2.video) && matches(1, "POSTER", evidence2.poster) && (!evidence2.sound || matches(2, "AUDIO", evidence2.sound));
|
|
33027
33208
|
case "COMPOSITION_RENDER":
|
|
@@ -33151,7 +33332,7 @@ var init_processor = __esm({
|
|
|
33151
33332
|
LocalLibraryPublishEvidenceSchema,
|
|
33152
33333
|
external_exports.strictObject({
|
|
33153
33334
|
processor: external_exports.literal("IMPORTED_VISUAL_NORMALIZE"),
|
|
33154
|
-
receipt:
|
|
33335
|
+
receipt: AnyImportedVisualNormalizationReceiptSchema,
|
|
33155
33336
|
posterEvidence: poster
|
|
33156
33337
|
}),
|
|
33157
33338
|
external_exports.strictObject({
|
|
@@ -33189,16 +33370,19 @@ var init_processor = __esm({
|
|
|
33189
33370
|
}),
|
|
33190
33371
|
external_exports.strictObject({
|
|
33191
33372
|
processor: external_exports.literal("IMPORT_ORIGINAL"),
|
|
33192
|
-
metadata:
|
|
33373
|
+
metadata: AnyImportedVisualSourceMetadataSchema
|
|
33193
33374
|
}),
|
|
33194
33375
|
external_exports.strictObject({
|
|
33195
33376
|
processor: external_exports.literal("IMPORT_PROJECT_SOURCE"),
|
|
33196
33377
|
validated: external_exports.strictObject({
|
|
33197
33378
|
checksumSha256: LocalDigestSchema,
|
|
33198
|
-
byteSize: external_exports.int().positive().max(
|
|
33379
|
+
byteSize: external_exports.int().positive().max(128 * 1024 * 1024),
|
|
33199
33380
|
width: external_exports.int().positive().max(4096),
|
|
33200
33381
|
height: external_exports.int().positive().max(4096),
|
|
33201
|
-
video:
|
|
33382
|
+
video: AnyImportedVisualSourceMetadataSchema.optional()
|
|
33383
|
+
}).refine((value2) => {
|
|
33384
|
+
const video = value2.video;
|
|
33385
|
+
return video ? video.byteSize === value2.byteSize && video.checksumSha256 === value2.checksumSha256 && video.geometry.width === value2.width && video.geometry.height === value2.height : value2.byteSize <= 8 * 1024 * 1024;
|
|
33202
33386
|
})
|
|
33203
33387
|
}),
|
|
33204
33388
|
external_exports.strictObject({
|
|
@@ -33707,7 +33891,7 @@ var init_claim_resolution = __esm({
|
|
|
33707
33891
|
});
|
|
33708
33892
|
|
|
33709
33893
|
// packages/contracts/src/local-execution/processor-outcomes.ts
|
|
33710
|
-
var TenantProcessorStateSchema, TenantProcessorFailureSchema, TenantProcessorProviderOutcomeSchema, TenantProcessorProviderTaskSchema, TenantProcessorInvalidSpeechSchema;
|
|
33894
|
+
var TenantProcessorReportRejectionQuerySchema, TenantProcessorReportRejectionSchema, TenantProcessorStateSchema, TenantProcessorFailureSchema, TenantProcessorProviderOutcomeSchema, TenantProcessorProviderTaskSchema, TenantProcessorInvalidSpeechSchema;
|
|
33711
33895
|
var init_processor_outcomes = __esm({
|
|
33712
33896
|
"packages/contracts/src/local-execution/processor-outcomes.ts"() {
|
|
33713
33897
|
"use strict";
|
|
@@ -33716,6 +33900,28 @@ var init_processor_outcomes = __esm({
|
|
|
33716
33900
|
init_work();
|
|
33717
33901
|
init_external_generation();
|
|
33718
33902
|
init_speech();
|
|
33903
|
+
init_processor();
|
|
33904
|
+
init_common();
|
|
33905
|
+
init_ids();
|
|
33906
|
+
TenantProcessorReportRejectionQuerySchema = TenantProcessorReceiptQuerySchema.extend({
|
|
33907
|
+
version: external_exports.literal(2).optional()
|
|
33908
|
+
});
|
|
33909
|
+
TenantProcessorReportRejectionSchema = TenantProcessorReceiptQuerySchema.extend({
|
|
33910
|
+
disposition: external_exports.literal("REJECTED"),
|
|
33911
|
+
operationId: OperationIdSchema,
|
|
33912
|
+
reportFingerprint: LocalDigestSchema,
|
|
33913
|
+
reason: external_exports.enum([
|
|
33914
|
+
"ORIGINAL_PRODUCTION_REVISION_CHANGED",
|
|
33915
|
+
"ORIGINAL_SHOT_BASIS_CHANGED",
|
|
33916
|
+
"ORIGINAL_SOURCE_VERSION_CHANGED",
|
|
33917
|
+
"ORIGINAL_PROJECT_SOURCE_CHANGED"
|
|
33918
|
+
]),
|
|
33919
|
+
expectedProductionRevision: external_exports.int().nonnegative(),
|
|
33920
|
+
observedProductionRevision: external_exports.int().nonnegative(),
|
|
33921
|
+
decidedAt: external_exports.iso.datetime()
|
|
33922
|
+
}).refine(
|
|
33923
|
+
(value2) => value2.reason !== "ORIGINAL_PRODUCTION_REVISION_CHANGED" || value2.expectedProductionRevision !== value2.observedProductionRevision
|
|
33924
|
+
);
|
|
33719
33925
|
TenantProcessorStateSchema = external_exports.strictObject({
|
|
33720
33926
|
binding: LocalLeaseBindingSchema,
|
|
33721
33927
|
state: external_exports.enum(["FENCED", "PENDING", "PROVIDER_TERMINAL"]),
|
|
@@ -33819,8 +34025,8 @@ var init_model_cleanup = __esm({
|
|
|
33819
34025
|
});
|
|
33820
34026
|
|
|
33821
34027
|
// packages/contracts/src/local-execution/provider-release.ts
|
|
33822
|
-
function base64UrlBytes(minimum,
|
|
33823
|
-
return external_exports.base64url().min(Math.ceil(minimum * 4 / 3)).max(Math.ceil(
|
|
34028
|
+
function base64UrlBytes(minimum, maximum4 = minimum) {
|
|
34029
|
+
return external_exports.base64url().min(Math.ceil(minimum * 4 / 3)).max(Math.ceil(maximum4 * 4 / 3)).refine((value2) => {
|
|
33824
34030
|
const tail = value2.at(-1) ?? "";
|
|
33825
34031
|
const remainder = value2.length % 4;
|
|
33826
34032
|
return remainder === 0 || remainder === 2 && /^[AQgw]$/.test(tail) || remainder === 3 && /^[AEIMQUYcgkosw048]$/.test(tail);
|
|
@@ -33944,6 +34150,26 @@ var init_local_execution = __esm({
|
|
|
33944
34150
|
}
|
|
33945
34151
|
});
|
|
33946
34152
|
|
|
34153
|
+
// packages/media-execution/src/preview/identity.mjs
|
|
34154
|
+
var platformIdentityFiles;
|
|
34155
|
+
var init_identity2 = __esm({
|
|
34156
|
+
"packages/media-execution/src/preview/identity.mjs"() {
|
|
34157
|
+
"use strict";
|
|
34158
|
+
platformIdentityFiles = [
|
|
34159
|
+
"index.ts",
|
|
34160
|
+
"private.ts",
|
|
34161
|
+
"file-digest.ts",
|
|
34162
|
+
"pipe.ts",
|
|
34163
|
+
"process.ts",
|
|
34164
|
+
"windows-helper.ts",
|
|
34165
|
+
"native-assets.ts",
|
|
34166
|
+
...["NativeMain.cs", "PrivateAccess.cs", "PipeBridge.cs", "JobNative.cs", "JobRunner.cs"].map(
|
|
34167
|
+
(name2) => "native/" + name2
|
|
34168
|
+
)
|
|
34169
|
+
];
|
|
34170
|
+
}
|
|
34171
|
+
});
|
|
34172
|
+
|
|
33947
34173
|
// packages/media-execution/src/preview/profile.ts
|
|
33948
34174
|
var profile_exports = {};
|
|
33949
34175
|
__export(profile_exports, {
|
|
@@ -33965,7 +34191,7 @@ function requirePlainPreview(manifest) {
|
|
|
33965
34191
|
}
|
|
33966
34192
|
async function previewRendererDigest() {
|
|
33967
34193
|
const metadata2 = JSON.parse(await readFile5(new URL("./execution-identity.json", import.meta.url), "utf8"));
|
|
33968
|
-
if (metadata2.sourceDigest !== "
|
|
34194
|
+
if (metadata2.sourceDigest !== "eaa6d1228b833d6bc91f1dc418a8c743a22ff6bd12191afbcd78b024d6b30866") throw Error("BUNDLE_IDENTITY_INVALID");
|
|
33969
34195
|
for (const name2 of ["entry.js", "supervisor.mjs", "parent-lifetime.mjs", "agent-supervisor.mjs", "kokoro-worker.mjs", "native/helper.exe", "native/helper.json"]) {
|
|
33970
34196
|
const bytes = await readFile5(new URL("./" + name2, import.meta.url));
|
|
33971
34197
|
if (previewDigest(bytes) !== metadata2.files[name2]) throw Error("BUNDLE_IDENTITY_INVALID");
|
|
@@ -33976,6 +34202,7 @@ var previewDigest, LOCAL_PREVIEW_PROFILE_DIGEST, PREVIEW_RENDERER_VERSION;
|
|
|
33976
34202
|
var init_profile = __esm({
|
|
33977
34203
|
"packages/media-execution/src/preview/profile.ts"() {
|
|
33978
34204
|
"use strict";
|
|
34205
|
+
init_identity2();
|
|
33979
34206
|
init_local_execution();
|
|
33980
34207
|
previewDigest = (value2) => createHash5("sha256").update(value2).digest("hex");
|
|
33981
34208
|
LOCAL_PREVIEW_PROFILE_DIGEST = previewDigest(
|
|
@@ -33994,7 +34221,7 @@ function crc32(bytes) {
|
|
|
33994
34221
|
}
|
|
33995
34222
|
return (crc ^ 4294967295) >>> 0;
|
|
33996
34223
|
}
|
|
33997
|
-
function validatePreviewPng(bytes,
|
|
34224
|
+
function validatePreviewPng(bytes, geometry4 = { width: 320, height: 180 }) {
|
|
33998
34225
|
if (bytes.length < 45 || bytes.length > 2097152 || bytes.subarray(0, 8).toString("hex") !== "89504e470d0a1a0a")
|
|
33999
34226
|
throw Error("PREVIEW_POSTER_INVALID");
|
|
34000
34227
|
let offset2 = 8, header = false, data = false, end = false;
|
|
@@ -34005,7 +34232,7 @@ function validatePreviewPng(bytes, geometry3 = { width: 320, height: 180 }) {
|
|
|
34005
34232
|
throw Error("PREVIEW_POSTER_INVALID");
|
|
34006
34233
|
if (!header && type !== "IHDR") throw Error("PREVIEW_POSTER_INVALID");
|
|
34007
34234
|
if (type === "IHDR") {
|
|
34008
|
-
if (header || size !== 13 || bytes.readUInt32BE(offset2 + 8) !==
|
|
34235
|
+
if (header || size !== 13 || bytes.readUInt32BE(offset2 + 8) !== geometry4.width || bytes.readUInt32BE(offset2 + 12) !== geometry4.height || bytes[offset2 + 16] !== 8 || ![2, 6].includes(bytes[offset2 + 17]) || bytes[offset2 + 18] !== 0 || bytes[offset2 + 19] !== 0 || bytes[offset2 + 20] !== 0)
|
|
34009
34236
|
throw Error("PREVIEW_POSTER_INVALID");
|
|
34010
34237
|
header = true;
|
|
34011
34238
|
} else if (type === "IDAT") data = true;
|
|
@@ -34812,7 +35039,7 @@ var init_graphics = __esm({
|
|
|
34812
35039
|
});
|
|
34813
35040
|
|
|
34814
35041
|
// packages/contracts/src/interface/operation.ts
|
|
34815
|
-
var OperationTargetSchema, OperationFailureReasonSchema, productionScope, OperationFailureSchema, OperationSummarySchema;
|
|
35042
|
+
var OperationTargetSchema, OperationFailureReasonSchema, productionScope, OperationReadInputSchema, OperationFailureSchema, ProcessorReportObservationSchema, OperationSummarySchema;
|
|
34816
35043
|
var init_operation = __esm({
|
|
34817
35044
|
"packages/contracts/src/interface/operation.ts"() {
|
|
34818
35045
|
"use strict";
|
|
@@ -34837,6 +35064,10 @@ var init_operation = __esm({
|
|
|
34837
35064
|
tenantId: TenantIdSchema,
|
|
34838
35065
|
productionId: ProductionIdSchema
|
|
34839
35066
|
});
|
|
35067
|
+
OperationReadInputSchema = productionScope.extend({
|
|
35068
|
+
operationId: OperationIdSchema,
|
|
35069
|
+
reportsVersion: external_exports.literal(1).optional()
|
|
35070
|
+
});
|
|
34840
35071
|
OperationFailureSchema = external_exports.strictObject({
|
|
34841
35072
|
reasonCodes: external_exports.array(OperationFailureReasonSchema).min(1).max(OperationFailureReasonSchema.options.length).refine((codes) => new Set(codes).size === codes.length),
|
|
34842
35073
|
summary: external_exports.string().min(1).max(1e3),
|
|
@@ -34848,6 +35079,29 @@ var init_operation = __esm({
|
|
|
34848
35079
|
external_exports.strictObject({ capability: external_exports.literal("production.snapshot"), input: productionScope })
|
|
34849
35080
|
])
|
|
34850
35081
|
});
|
|
35082
|
+
ProcessorReportObservationSchema = external_exports.strictObject({
|
|
35083
|
+
runtimeJobId: external_exports.uuid(),
|
|
35084
|
+
attemptId: external_exports.uuid(),
|
|
35085
|
+
deviceId: external_exports.uuid(),
|
|
35086
|
+
requestId: external_exports.uuid(),
|
|
35087
|
+
state: external_exports.enum(["PREPARED", "REJECTED", "ACCEPTED", "FENCED"]),
|
|
35088
|
+
reason: external_exports.string().min(1).max(120).nullable(),
|
|
35089
|
+
observedAt: external_exports.iso.datetime(),
|
|
35090
|
+
terminalAt: external_exports.iso.datetime().nullable(),
|
|
35091
|
+
inspect: external_exports.strictObject({
|
|
35092
|
+
tool: external_exports.literal("studio_capability_query"),
|
|
35093
|
+
arguments: external_exports.strictObject({
|
|
35094
|
+
tenantId: TenantIdSchema,
|
|
35095
|
+
tool: external_exports.enum(["device_status", "production_snapshot"]),
|
|
35096
|
+
arguments: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.literal(1)]))
|
|
35097
|
+
})
|
|
35098
|
+
}).optional(),
|
|
35099
|
+
next: external_exports.enum(["INSPECT_ORIGIN_DEVICE", "CHECK_CURRENT_PRODUCTION", "NONE"]),
|
|
35100
|
+
hostInspection: external_exports.strictObject({
|
|
35101
|
+
owner: external_exports.literal("HOST_OWNER"),
|
|
35102
|
+
command: external_exports.tuple([external_exports.literal("nvs"), external_exports.literal("local"), external_exports.literal("status")])
|
|
35103
|
+
}).optional()
|
|
35104
|
+
});
|
|
34851
35105
|
OperationSummarySchema = external_exports.object({
|
|
34852
35106
|
humanLinks: HumanLinksSchema.optional(),
|
|
34853
35107
|
id: OperationIdSchema,
|
|
@@ -34857,6 +35111,10 @@ var init_operation = __esm({
|
|
|
34857
35111
|
work: WorkSummarySchema,
|
|
34858
35112
|
blockers: external_exports.array(external_exports.string().min(1).max(1e3)).max(100),
|
|
34859
35113
|
failure: OperationFailureSchema.optional(),
|
|
35114
|
+
processorReports: external_exports.strictObject({
|
|
35115
|
+
items: external_exports.array(ProcessorReportObservationSchema).max(10),
|
|
35116
|
+
truncated: external_exports.boolean()
|
|
35117
|
+
}).optional(),
|
|
34860
35118
|
nextActions: external_exports.array(NextActionSchema).max(50),
|
|
34861
35119
|
startedAt: external_exports.iso.datetime({ offset: true }),
|
|
34862
35120
|
updatedAt: external_exports.iso.datetime({ offset: true })
|
|
@@ -35374,7 +35632,7 @@ var init_production = __esm({
|
|
|
35374
35632
|
});
|
|
35375
35633
|
|
|
35376
35634
|
// packages/contracts/src/interface/production-snapshot.ts
|
|
35377
|
-
var NullableVersionSchema, ProductionBlockerSchema, ProductionSnapshotSchema;
|
|
35635
|
+
var NullableVersionSchema, ProductionBlockerSchema, PRODUCTION_SNAPSHOT_ACTION_LIMIT, ProductionSnapshotSchema;
|
|
35378
35636
|
var init_production_snapshot = __esm({
|
|
35379
35637
|
"packages/contracts/src/interface/production-snapshot.ts"() {
|
|
35380
35638
|
"use strict";
|
|
@@ -35402,6 +35660,7 @@ var init_production_snapshot = __esm({
|
|
|
35402
35660
|
targetType: external_exports.string().min(1).max(80),
|
|
35403
35661
|
targetId: external_exports.string().min(1).max(2048)
|
|
35404
35662
|
});
|
|
35663
|
+
PRODUCTION_SNAPSHOT_ACTION_LIMIT = 50;
|
|
35405
35664
|
ProductionSnapshotSchema = external_exports.object({
|
|
35406
35665
|
humanLinks: HumanLinksSchema.optional(),
|
|
35407
35666
|
tenantId: TenantIdSchema,
|
|
@@ -35451,7 +35710,7 @@ var init_production_snapshot = __esm({
|
|
|
35451
35710
|
activeOperations: external_exports.array(OperationSummarySchema).max(20),
|
|
35452
35711
|
blockers: external_exports.array(ProductionBlockerSchema).max(100),
|
|
35453
35712
|
latestDecisions: external_exports.array(external_exports.string().min(1).max(1e3)).max(50),
|
|
35454
|
-
nextActions: external_exports.array(NextActionSchema).max(
|
|
35713
|
+
nextActions: external_exports.array(NextActionSchema).max(PRODUCTION_SNAPSHOT_ACTION_LIMIT),
|
|
35455
35714
|
generatedAt: external_exports.iso.datetime({ offset: true })
|
|
35456
35715
|
});
|
|
35457
35716
|
}
|
|
@@ -35623,11 +35882,14 @@ var init_project_library = __esm({
|
|
|
35623
35882
|
"application/json",
|
|
35624
35883
|
"video/mp4"
|
|
35625
35884
|
]),
|
|
35626
|
-
byteSize: external_exports.int().positive().max(
|
|
35885
|
+
byteSize: external_exports.int().positive().max(128 * 1024 * 1024),
|
|
35627
35886
|
width: external_exports.int().positive().nullable(),
|
|
35628
35887
|
height: external_exports.int().positive().nullable(),
|
|
35629
35888
|
createdAt: external_exports.iso.datetime({ offset: true })
|
|
35630
|
-
})
|
|
35889
|
+
}).refine(
|
|
35890
|
+
(value2) => value2.kind === "REFERENCE_VIDEO" && value2.contentType === "video/mp4" ? true : value2.byteSize <= 8 * 1024 * 1024,
|
|
35891
|
+
{ message: "Video SOURCE is limited to 128 MiB; other SOURCE kinds remain limited to 8 MiB" }
|
|
35892
|
+
);
|
|
35631
35893
|
SourceLibraryPageSchema = external_exports.strictObject({
|
|
35632
35894
|
items: external_exports.array(SourceLibraryItemSchema).max(100),
|
|
35633
35895
|
page: QueryPageInfoSchema
|
|
@@ -35682,10 +35944,14 @@ var init_agent_host_execution = __esm({
|
|
|
35682
35944
|
artifactId: id9,
|
|
35683
35945
|
representationId: id9,
|
|
35684
35946
|
checksumSha256: sha20,
|
|
35685
|
-
|
|
35947
|
+
// Host 接收的是引用元数据:视频上限与 Project SOURCE 一致,图像/文本不放宽。
|
|
35948
|
+
byteSize: external_exports.int().positive().max(128 * 1024 * 1024),
|
|
35686
35949
|
contentType: external_exports.string().min(1).max(100),
|
|
35687
35950
|
kind: external_exports.enum(["PRODUCT_INFORMATION", "REFERENCE_IMAGE", "REFERENCE_VIDEO"])
|
|
35688
|
-
})
|
|
35951
|
+
}).refine(
|
|
35952
|
+
(source5) => source5.kind === "REFERENCE_VIDEO" && source5.contentType === "video/mp4" || source5.byteSize <= 8 * 1024 * 1024,
|
|
35953
|
+
{ message: "Non-video Host source references remain limited to 8 MiB" }
|
|
35954
|
+
);
|
|
35689
35955
|
AgentHostExecutionInputSchema = AgentHostExecutionScopeSchema.extend({
|
|
35690
35956
|
protocol: external_exports.literal("NATIVESTUDIO_PRODUCTION_V1"),
|
|
35691
35957
|
executionId: id9,
|
|
@@ -36289,8 +36555,12 @@ var init_media_output = __esm({
|
|
|
36289
36555
|
SourceLibraryMediaSchema.extend({
|
|
36290
36556
|
contentType: external_exports.literal("video/mp4"),
|
|
36291
36557
|
checksumSha256: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
36292
|
-
|
|
36293
|
-
|
|
36558
|
+
// 视频描述只携带元数据,沿用原生视频上限与相应执行入口。
|
|
36559
|
+
byteSize: external_exports.int().positive().max(128 * 1024 * 1024),
|
|
36560
|
+
importOperation: external_exports.enum([
|
|
36561
|
+
"imported-visual.register-source",
|
|
36562
|
+
"imported-visual.start-from-source"
|
|
36563
|
+
])
|
|
36294
36564
|
}).strict()
|
|
36295
36565
|
]);
|
|
36296
36566
|
}
|
|
@@ -36445,22 +36715,59 @@ var init_tenant = __esm({
|
|
|
36445
36715
|
});
|
|
36446
36716
|
|
|
36447
36717
|
// packages/contracts/src/render-readiness.ts
|
|
36448
|
-
var RenderReadinessInputSchema, RenderReadinessSchema;
|
|
36718
|
+
var ProgressRequestSchema, TimelineProgressSchema, RenderReadinessInputSchema, RenderReadinessSchema;
|
|
36449
36719
|
var init_render_readiness = __esm({
|
|
36450
36720
|
"packages/contracts/src/render-readiness.ts"() {
|
|
36451
36721
|
"use strict";
|
|
36452
36722
|
init_zod();
|
|
36453
36723
|
init_device_render();
|
|
36454
36724
|
init_final_render();
|
|
36725
|
+
ProgressRequestSchema = external_exports.strictObject({
|
|
36726
|
+
version: external_exports.literal(1),
|
|
36727
|
+
after: external_exports.strictObject({
|
|
36728
|
+
productionRevision: external_exports.int().positive(),
|
|
36729
|
+
ordinal: external_exports.int().positive().max(200),
|
|
36730
|
+
fingerprint: external_exports.string().regex(/^[a-f0-9]{64}$/)
|
|
36731
|
+
}).optional()
|
|
36732
|
+
});
|
|
36733
|
+
TimelineProgressSchema = external_exports.strictObject({
|
|
36734
|
+
productionRevision: external_exports.int().positive(),
|
|
36735
|
+
stage: external_exports.enum([
|
|
36736
|
+
"PRODUCTION_BLOCKED",
|
|
36737
|
+
"PLANNING_REQUIRED",
|
|
36738
|
+
"ACCEPT_SOURCE",
|
|
36739
|
+
"BUILD_DRAFT",
|
|
36740
|
+
"COMPLETE_DRAFT",
|
|
36741
|
+
"BUILD_TIMELINE",
|
|
36742
|
+
"REBUILD_TIMELINE",
|
|
36743
|
+
"PREVIEW_READY",
|
|
36744
|
+
"BASIS_CHANGED"
|
|
36745
|
+
]),
|
|
36746
|
+
canBuildDraft: external_exports.boolean(),
|
|
36747
|
+
accepted: external_exports.int().nonnegative(),
|
|
36748
|
+
planned: external_exports.int().nonnegative(),
|
|
36749
|
+
missing: external_exports.array(
|
|
36750
|
+
external_exports.strictObject({
|
|
36751
|
+
shotId: external_exports.uuid(),
|
|
36752
|
+
ordinal: external_exports.int().positive(),
|
|
36753
|
+
reason: external_exports.enum(["NONE", "STALE"])
|
|
36754
|
+
})
|
|
36755
|
+
).max(10),
|
|
36756
|
+
next: ProgressRequestSchema.shape.after.unwrap().nullable()
|
|
36757
|
+
});
|
|
36455
36758
|
RenderReadinessInputSchema = external_exports.strictObject({
|
|
36456
36759
|
tenantId: external_exports.uuid(),
|
|
36457
36760
|
projectId: external_exports.uuid().optional(),
|
|
36458
36761
|
productionId: external_exports.uuid().optional(),
|
|
36459
36762
|
kind: external_exports.enum(["preview", "final"]),
|
|
36460
36763
|
deviceId: external_exports.uuid().optional(),
|
|
36764
|
+
progress: ProgressRequestSchema.optional(),
|
|
36461
36765
|
hostAccess: external_exports.enum(["MCP_ONLY", "AUTHORIZED_HOST"]).optional()
|
|
36462
36766
|
});
|
|
36463
|
-
RenderReadinessSchema = RenderReadinessInputSchema.omit({
|
|
36767
|
+
RenderReadinessSchema = RenderReadinessInputSchema.omit({
|
|
36768
|
+
hostAccess: true,
|
|
36769
|
+
progress: true
|
|
36770
|
+
}).extend({
|
|
36464
36771
|
protocol: external_exports.literal("NVS_RENDER_READINESS_V1"),
|
|
36465
36772
|
observedAt: external_exports.iso.datetime(),
|
|
36466
36773
|
state: external_exports.enum([
|
|
@@ -36481,6 +36788,7 @@ var init_render_readiness = __esm({
|
|
|
36481
36788
|
blockers: FinalRenderEligibilitySchema.shape.blockers.optional(),
|
|
36482
36789
|
sourceBlockers: FinalRenderEligibilitySchema.shape.sourceBlockers.optional(),
|
|
36483
36790
|
candidates: ProjectDeviceListSchema.optional(),
|
|
36791
|
+
timelineProgress: TimelineProgressSchema.optional(),
|
|
36484
36792
|
executionTarget: DeviceRenderTargetSchema.optional(),
|
|
36485
36793
|
nextAction: external_exports.strictObject({
|
|
36486
36794
|
owner: external_exports.enum(["AGENT", "HOST_OWNER", "AUTHORIZED_MEMBER", "TENANT_OPERATOR"]),
|
|
@@ -41320,12 +41628,18 @@ var init_device_openai_asr = __esm({
|
|
|
41320
41628
|
init_openai_asr();
|
|
41321
41629
|
OpenAiAsrDeviceStartSchema = QwenAsrDeviceQuoteInputSchema.extend({
|
|
41322
41630
|
selection: QwenAsrDeviceQuoteInputSchema.shape.selection.extend({
|
|
41323
|
-
modelProfileId: external_exports.
|
|
41631
|
+
modelProfileId: external_exports.enum([openAiAsrProfileId, openAiWhisperProfileId])
|
|
41324
41632
|
}),
|
|
41325
41633
|
expectedModelProfileVersion: external_exports.int().positive(),
|
|
41326
|
-
parameters:
|
|
41634
|
+
parameters: external_exports.union([
|
|
41635
|
+
OpenAiAsrParametersSchema,
|
|
41636
|
+
OpenAiWhisperParametersSchema.partial({ timestamp_granularities: true })
|
|
41637
|
+
]).default({}),
|
|
41327
41638
|
acceptActualUsage: external_exports.literal(true)
|
|
41328
|
-
})
|
|
41639
|
+
}).refine(
|
|
41640
|
+
(request) => (request.selection.modelProfileId === openAiWhisperProfileId ? OpenAiWhisperParametersSchema.partial({ timestamp_granularities: true }) : OpenAiAsrParametersSchema).safeParse(request.parameters).success,
|
|
41641
|
+
"Transcription parameters must match the selected model"
|
|
41642
|
+
);
|
|
41329
41643
|
OpenAiAsrDeviceResultSchema = external_exports.strictObject({
|
|
41330
41644
|
schemaVersion: external_exports.literal(2),
|
|
41331
41645
|
advisory: external_exports.literal(true),
|
|
@@ -41335,7 +41649,7 @@ var init_device_openai_asr = __esm({
|
|
|
41335
41649
|
observedAt: external_exports.iso.datetime(),
|
|
41336
41650
|
report: external_exports.strictObject({
|
|
41337
41651
|
task: external_exports.literal("SPEECH_RECOGNITION"),
|
|
41338
|
-
timing: external_exports.
|
|
41652
|
+
timing: external_exports.enum(["UNAVAILABLE", "PROVIDER_REPORTED"])
|
|
41339
41653
|
}),
|
|
41340
41654
|
limitations: external_exports.array(external_exports.string().max(200)).max(20),
|
|
41341
41655
|
transcriptObject: MediaObjectVersionSchema.extend({
|
|
@@ -41344,6 +41658,8 @@ var init_device_openai_asr = __esm({
|
|
|
41344
41658
|
})
|
|
41345
41659
|
}).refine(
|
|
41346
41660
|
({ source: source5, transcriptObject }) => source5.tenantId === transcriptObject.tenantId && source5.projectId === transcriptObject.projectId
|
|
41661
|
+
).refine(
|
|
41662
|
+
({ provider, report }) => provider.protocol === "OPENAI_WHISPER_TRANSCRIPTION_V1" === (report.timing === "PROVIDER_REPORTED")
|
|
41347
41663
|
);
|
|
41348
41664
|
OpenAiAsrDeviceViewSchema = QwenAsrDeviceViewSchema.extend({
|
|
41349
41665
|
request: OpenAiAsrDeviceStartSchema,
|
|
@@ -41541,7 +41857,7 @@ async function overlayResolvedVisualFrames(raw, tools, base5, output3, read, sig
|
|
|
41541
41857
|
if (base5.byteLength < 32 || base5.byteLength > VISUAL_FRAME_OVERLAY_CAPABILITY.maxOutputBytes || ![18, 23].includes(output3.crf) || output3.width % 2 || output3.height % 2)
|
|
41542
41858
|
throw new Error("VISUAL_FRAME_INVALID");
|
|
41543
41859
|
const baseBytes = Uint8Array.from(base5);
|
|
41544
|
-
const
|
|
41860
|
+
const geometry4 = { ...output3 };
|
|
41545
41861
|
const directory = await mkdtemp2(join9(tmpdir2(), "nvs-visual-layers-"));
|
|
41546
41862
|
const options = {
|
|
41547
41863
|
signal: executionSignal,
|
|
@@ -41561,7 +41877,7 @@ async function overlayResolvedVisualFrames(raw, tools, base5, output3, read, sig
|
|
|
41561
41877
|
)).toString()
|
|
41562
41878
|
);
|
|
41563
41879
|
const video = probe.streams?.[0];
|
|
41564
|
-
if (probe.streams?.length !== 1 || video.codec_type !== "video" || video.codec_name !== "h264" || video.width !==
|
|
41880
|
+
if (probe.streams?.length !== 1 || video.codec_type !== "video" || video.codec_name !== "h264" || video.width !== geometry4.width || video.height !== geometry4.height || video.sample_aspect_ratio !== "1:1" || video.avg_frame_rate !== "30/1" || clock !== "n" && Number(video.start_time) !== 0 || Number(video.nb_read_frames) !== composition2.totalFrames)
|
|
41565
41881
|
throw new Error("VISUAL_FRAME_INVALID");
|
|
41566
41882
|
await runControlledProcess(
|
|
41567
41883
|
tools.ffmpeg,
|
|
@@ -41656,7 +41972,7 @@ async function overlayResolvedVisualFrames(raw, tools, base5, output3, read, sig
|
|
|
41656
41972
|
"-preset",
|
|
41657
41973
|
"veryfast",
|
|
41658
41974
|
"-crf",
|
|
41659
|
-
String(
|
|
41975
|
+
String(geometry4.crf),
|
|
41660
41976
|
"-pix_fmt",
|
|
41661
41977
|
"yuv420p",
|
|
41662
41978
|
"-r",
|
|
@@ -41691,7 +42007,7 @@ async function overlayResolvedVisualFrames(raw, tools, base5, output3, read, sig
|
|
|
41691
42007
|
);
|
|
41692
42008
|
const stream = physical.streams?.[0];
|
|
41693
42009
|
const size = (await stat4(file2)).size;
|
|
41694
|
-
if (size < 32 || size > VISUAL_FRAME_OVERLAY_CAPABILITY.maxOutputBytes || physical.streams?.length !== 1 || stream.codec_name !== "h264" || stream.width !==
|
|
42010
|
+
if (size < 32 || size > VISUAL_FRAME_OVERLAY_CAPABILITY.maxOutputBytes || physical.streams?.length !== 1 || stream.codec_name !== "h264" || stream.width !== geometry4.width || stream.height !== geometry4.height || stream.pix_fmt !== "yuv420p" || stream.avg_frame_rate !== "30/1" || stream.sample_aspect_ratio !== "1:1" || Number(stream.nb_read_frames) !== composition2.totalFrames || Math.abs(Number(stream.duration) - composition2.totalFrames / 30) > 1e-3)
|
|
41695
42011
|
throw new Error("VISUAL_FRAME_INVALID");
|
|
41696
42012
|
await runControlledProcess(
|
|
41697
42013
|
tools.ffmpeg,
|
|
@@ -41790,7 +42106,7 @@ async function inspectStudioVideo(video, tools, frames, signal, recipe, strictDe
|
|
|
41790
42106
|
if (recipe.audio) {
|
|
41791
42107
|
const directory = await mkdtemp3(join10(tmpdir3(), "nvs-audio-inspection-"));
|
|
41792
42108
|
try {
|
|
41793
|
-
const decoded = join10(directory, "decoded.pcm"),
|
|
42109
|
+
const decoded = join10(directory, "decoded.pcm"), maximum4 = (frames * 1600 + 1023) * 4;
|
|
41794
42110
|
await runControlledProcess(
|
|
41795
42111
|
tools.ffmpeg,
|
|
41796
42112
|
[
|
|
@@ -41813,13 +42129,13 @@ async function inspectStudioVideo(video, tools, frames, signal, recipe, strictDe
|
|
|
41813
42129
|
"-f",
|
|
41814
42130
|
"s16le",
|
|
41815
42131
|
"-fs",
|
|
41816
|
-
String(
|
|
42132
|
+
String(maximum4 + 1),
|
|
41817
42133
|
decoded
|
|
41818
42134
|
],
|
|
41819
42135
|
opts
|
|
41820
42136
|
);
|
|
41821
42137
|
const size = (await stat5(decoded)).size;
|
|
41822
|
-
if (strictDelivery && size % 4 || size < frames * 6400 || size >
|
|
42138
|
+
if (strictDelivery && size % 4 || size < frames * 6400 || size > maximum4)
|
|
41823
42139
|
throw Error("STUDIO_AUDIO_INVALID");
|
|
41824
42140
|
} finally {
|
|
41825
42141
|
await rm3(directory, { recursive: true, force: true });
|
|
@@ -41917,13 +42233,13 @@ var init_inspect2 = __esm({
|
|
|
41917
42233
|
|
|
41918
42234
|
// packages/media-execution/src/studio/profile.ts
|
|
41919
42235
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
41920
|
-
function studioContractSupportsPolicy(
|
|
41921
|
-
return
|
|
42236
|
+
function studioContractSupportsPolicy(digest16) {
|
|
42237
|
+
return digest16 === LOCAL_STUDIO_PROFILE_DIGEST;
|
|
41922
42238
|
}
|
|
41923
42239
|
async function studioRendererDigest() {
|
|
41924
42240
|
await previewRendererDigest();
|
|
41925
42241
|
const metadata2 = JSON.parse(await readFile10(new URL("./execution-identity.json", import.meta.url), "utf8"));
|
|
41926
|
-
if (metadata2.studioSourceDigest !== "
|
|
42242
|
+
if (metadata2.studioSourceDigest !== "6fd5f79e6e034b8102af4356c9d9e809903c8693520cebe10d730cb18b59534f") throw Error("BUNDLE_IDENTITY_INVALID");
|
|
41927
42243
|
return metadata2.studioSourceDigest;
|
|
41928
42244
|
}
|
|
41929
42245
|
async function studioToolchain(tools) {
|
|
@@ -42424,7 +42740,7 @@ async function deriveAgentEvidence(source5, directory, input3, tools, signal) {
|
|
|
42424
42740
|
}
|
|
42425
42741
|
let audio2 = null;
|
|
42426
42742
|
if (video && input3.hasAudio) {
|
|
42427
|
-
const file2 = join13(directory, "audio.pcm"),
|
|
42743
|
+
const file2 = join13(directory, "audio.pcm"), maximum4 = (Math.ceil(input3.durationMs * 48) + 1024) * 2;
|
|
42428
42744
|
await runControlledProcess(
|
|
42429
42745
|
tools.ffmpeg,
|
|
42430
42746
|
[
|
|
@@ -42444,13 +42760,13 @@ async function deriveAgentEvidence(source5, directory, input3, tools, signal) {
|
|
|
42444
42760
|
"-f",
|
|
42445
42761
|
"s16le",
|
|
42446
42762
|
"-fs",
|
|
42447
|
-
String(
|
|
42763
|
+
String(maximum4 + 1),
|
|
42448
42764
|
file2
|
|
42449
42765
|
],
|
|
42450
42766
|
options
|
|
42451
42767
|
);
|
|
42452
42768
|
const size = (await stat7(file2)).size;
|
|
42453
|
-
if (!size || size % 2 || size >
|
|
42769
|
+
if (!size || size % 2 || size > maximum4) throw Error("AGENT_MEDIA_INVALID");
|
|
42454
42770
|
const bytes2 = await readFile12(file2);
|
|
42455
42771
|
let sum = 0, peak = 0, clippedSamples = 0;
|
|
42456
42772
|
for (let i = 0; i < bytes2.length; i += 2) {
|
|
@@ -42593,7 +42909,7 @@ var init_common3 = __esm({
|
|
|
42593
42909
|
});
|
|
42594
42910
|
|
|
42595
42911
|
// packages/media-execution/src/imported-visual/probe.ts
|
|
42596
|
-
function parseImportedHeader(raw, input3) {
|
|
42912
|
+
function parseImportedHeader(raw, input3, profile) {
|
|
42597
42913
|
const d = record2(raw);
|
|
42598
42914
|
if (!Array.isArray(d.streams) || d.streams.length < 1 || d.streams.length > 2)
|
|
42599
42915
|
importedFailure("STREAM_LAYOUT_UNSUPPORTED");
|
|
@@ -42610,7 +42926,10 @@ function parseImportedHeader(raw, input3) {
|
|
|
42610
42926
|
importedFailure("MP4_BRAND_UNSUPPORTED");
|
|
42611
42927
|
if (v.codec_name !== "h264" || v.codec_tag_string !== "avc1" || v.pix_fmt !== "yuv420p")
|
|
42612
42928
|
importedFailure("VIDEO_CODEC_UNSUPPORTED");
|
|
42613
|
-
|
|
42929
|
+
const preserve = profile === PRESERVE_VISUAL_PROFILE_ID;
|
|
42930
|
+
const aspectUnknown = v.sample_aspect_ratio === void 0 || v.sample_aspect_ratio === "N/A" || v.sample_aspect_ratio === "unknown" || v.sample_aspect_ratio === "0:1";
|
|
42931
|
+
const fieldUnknown = v.field_order === void 0 || v.field_order === "unknown";
|
|
42932
|
+
if (!preserve && (v.sample_aspect_ratio !== "1:1" || v.field_order !== "progressive") || preserve && (!aspectUnknown && v.sample_aspect_ratio !== "1:1" || !fieldUnknown && v.field_order !== "progressive"))
|
|
42614
42933
|
importedFailure("PIXEL_OR_SCAN_LAYOUT_UNSUPPORTED");
|
|
42615
42934
|
if (integer2(v.start_pts) !== 0) importedFailure("NONZERO_VIDEO_START_UNSUPPORTED");
|
|
42616
42935
|
if (record2(v.tags ?? {}).rotate !== void 0 && Number(record2(v.tags).rotate) !== 0)
|
|
@@ -42620,8 +42939,13 @@ function parseImportedHeader(raw, input3) {
|
|
|
42620
42939
|
))
|
|
42621
42940
|
importedFailure("TRANSFORM_OR_HDR_METADATA_UNSUPPORTED");
|
|
42622
42941
|
const width = integer2(v.width, 2, 3840), height = integer2(v.height, 2, 3840);
|
|
42623
|
-
if (width % 2 || height % 2 || !(width * 9 === height * 16 || width * 16 === height * 9))
|
|
42942
|
+
if (width % 2 || height % 2 || !preserve && !(width * 9 === height * 16 || width * 16 === height * 9))
|
|
42624
42943
|
importedFailure("SOURCE_GEOMETRY_UNSUPPORTED");
|
|
42944
|
+
if (preserve && typeof v.display_aspect_ratio === "string" && !["N/A", "0:1", "unknown"].includes(v.display_aspect_ratio)) {
|
|
42945
|
+
const match = /^(\d+):(\d+)$/.exec(v.display_aspect_ratio);
|
|
42946
|
+
if (!match || Number(match[1]) * height !== Number(match[2]) * width)
|
|
42947
|
+
importedFailure("PIXEL_OR_SCAN_LAYOUT_UNSUPPORTED");
|
|
42948
|
+
}
|
|
42625
42949
|
const timeBase = rational(v.time_base), fps = rational(v.avg_frame_rate);
|
|
42626
42950
|
if (!clocks.has(fps.numerator + "/" + fps.denominator)) importedFailure("SOURCE_CFR_UNSUPPORTED");
|
|
42627
42951
|
const durationTicks = integer2(v.duration_ts, 1);
|
|
@@ -42651,12 +42975,12 @@ function parseImportedHeader(raw, input3) {
|
|
|
42651
42975
|
durationTicks: duration3
|
|
42652
42976
|
};
|
|
42653
42977
|
}
|
|
42654
|
-
|
|
42978
|
+
const metadata2 = {
|
|
42655
42979
|
...input3,
|
|
42656
42980
|
geometry: { width, height },
|
|
42657
42981
|
videoCodec: "h264",
|
|
42658
42982
|
pixelFormat: "yuv420p",
|
|
42659
|
-
sampleAspectRatio: "1:1",
|
|
42983
|
+
sampleAspectRatio: preserve && aspectUnknown ? "UNSPECIFIED" : "1:1",
|
|
42660
42984
|
rotationDegrees: 0,
|
|
42661
42985
|
startPts: 0,
|
|
42662
42986
|
timeBase,
|
|
@@ -42673,9 +42997,14 @@ function parseImportedHeader(raw, input3) {
|
|
|
42673
42997
|
audio: audio2,
|
|
42674
42998
|
fullDecode: true,
|
|
42675
42999
|
cfrTimestampsVerified: true
|
|
42676
|
-
}
|
|
43000
|
+
};
|
|
43001
|
+
return preserve ? PreserveVisualSourceMetadataSchema.parse({
|
|
43002
|
+
...metadata2,
|
|
43003
|
+
geometryProfile: PRESERVE_VISUAL_PROFILE_ID,
|
|
43004
|
+
fieldOrder: fieldUnknown ? "UNSPECIFIED" : "PROGRESSIVE"
|
|
43005
|
+
}) : ImportedVisualSourceMetadataSchema.parse(metadata2);
|
|
42677
43006
|
}
|
|
42678
|
-
function verifyImportedFrameClock(raw, source5) {
|
|
43007
|
+
function verifyImportedFrameClock(raw, source5, profile) {
|
|
42679
43008
|
const frames = record2(raw).frames;
|
|
42680
43009
|
if (!Array.isArray(frames) || frames.length !== source5.frameCount)
|
|
42681
43010
|
importedFailure("DECODED_FRAME_COUNT_MISMATCH");
|
|
@@ -42683,7 +43012,13 @@ function verifyImportedFrameClock(raw, source5) {
|
|
|
42683
43012
|
const step = BigInt(source5.timeBase.denominator) * BigInt(source5.frameRate.denominator);
|
|
42684
43013
|
for (const [index, value2] of frames.entries()) {
|
|
42685
43014
|
const f = record2(value2);
|
|
42686
|
-
|
|
43015
|
+
const pts = profile ? f.pts ?? f.pkt_pts : f.pts;
|
|
43016
|
+
let duration3 = profile ? f.duration ?? f.pkt_duration : f.duration;
|
|
43017
|
+
if (profile && duration3 === void 0) {
|
|
43018
|
+
const next = index + 1 < frames.length ? integer2(record2(frames[index + 1]).best_effort_timestamp) : source5.durationTicks;
|
|
43019
|
+
duration3 = next - integer2(f.best_effort_timestamp);
|
|
43020
|
+
}
|
|
43021
|
+
if (integer2(f.interlaced_frame) !== 0 || integer2(pts) !== integer2(f.best_effort_timestamp) || profile && f.pts !== void 0 && f.pkt_pts !== void 0 && integer2(f.pts) !== integer2(f.pkt_pts) || profile && f.duration !== void 0 && f.pkt_duration !== void 0 && integer2(f.duration) !== integer2(f.pkt_duration) || BigInt(integer2(f.best_effort_timestamp)) * unit !== BigInt(index) * step || BigInt(integer2(duration3, 1)) * unit !== step)
|
|
42687
43022
|
importedFailure("DECODED_CFR_TIMESTAMPS_MISMATCH");
|
|
42688
43023
|
}
|
|
42689
43024
|
}
|
|
@@ -42715,14 +43050,15 @@ var init_probe = __esm({
|
|
|
42715
43050
|
import { mkdtemp as mkdtemp6, writeFile as writeFile8, rm as rm6 } from "node:fs/promises";
|
|
42716
43051
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
42717
43052
|
import { join as join14 } from "node:path";
|
|
42718
|
-
async function inspectImportedFile(file2, input3, signal, tools) {
|
|
43053
|
+
async function inspectImportedFile(file2, input3, signal, tools, profile) {
|
|
42719
43054
|
const header = await importedProcess(
|
|
42720
43055
|
tools.ffprobe,
|
|
42721
43056
|
["-v", "error", ...localImportedInput(file2), "-show_streams", "-show_format", "-of", "json"],
|
|
42722
43057
|
signal,
|
|
42723
43058
|
"INPUT_PROBE"
|
|
42724
43059
|
);
|
|
42725
|
-
const
|
|
43060
|
+
const probe = JSON.parse(header.toString("utf8"));
|
|
43061
|
+
const source5 = profile === PRESERVE_VISUAL_PROFILE_ID ? parseImportedHeader(probe, input3, profile) : parseImportedHeader(probe, input3);
|
|
42726
43062
|
const frames = await importedProcess(
|
|
42727
43063
|
tools.ffprobe,
|
|
42728
43064
|
[
|
|
@@ -42733,7 +43069,7 @@ async function inspectImportedFile(file2, input3, signal, tools) {
|
|
|
42733
43069
|
"v:0",
|
|
42734
43070
|
"-show_frames",
|
|
42735
43071
|
"-show_entries",
|
|
42736
|
-
"frame=pts,best_effort_timestamp,duration,interlaced_frame",
|
|
43072
|
+
profile ? "frame=pts,pkt_pts,best_effort_timestamp,duration,pkt_duration,interlaced_frame" : "frame=pts,best_effort_timestamp,duration,interlaced_frame",
|
|
42737
43073
|
"-of",
|
|
42738
43074
|
"json"
|
|
42739
43075
|
],
|
|
@@ -42741,7 +43077,7 @@ async function inspectImportedFile(file2, input3, signal, tools) {
|
|
|
42741
43077
|
"INPUT_DECODE",
|
|
42742
43078
|
2 * 1024 * 1024
|
|
42743
43079
|
);
|
|
42744
|
-
verifyImportedFrameClock(JSON.parse(frames.toString("utf8")), source5);
|
|
43080
|
+
verifyImportedFrameClock(JSON.parse(frames.toString("utf8")), source5, profile);
|
|
42745
43081
|
await importedProcess(
|
|
42746
43082
|
tools.ffmpeg,
|
|
42747
43083
|
[
|
|
@@ -42768,7 +43104,7 @@ async function inspectImportedFile(file2, input3, signal, tools) {
|
|
|
42768
43104
|
);
|
|
42769
43105
|
return source5;
|
|
42770
43106
|
}
|
|
42771
|
-
async function inspectImportedVisualSource(raw, input3, signal, tools) {
|
|
43107
|
+
async function inspectImportedVisualSource(raw, input3, signal, tools, profile) {
|
|
42772
43108
|
if (signal.aborted) throw new ImportedVisualNormalizationError("CANCELLED", "PREFLIGHT");
|
|
42773
43109
|
const owned = ownedImportedBytes(raw, input3);
|
|
42774
43110
|
const deadline2 = AbortSignal.timeout(3e5), bounded3 = AbortSignal.any([signal, deadline2]);
|
|
@@ -42777,6 +43113,15 @@ async function inspectImportedVisualSource(raw, input3, signal, tools) {
|
|
|
42777
43113
|
const file2 = join14(directory, "source.mp4");
|
|
42778
43114
|
await writeFile8(file2, owned.bytes, { flag: "wx", mode: 384 });
|
|
42779
43115
|
const toolchain = await importedToolchain(bounded3, tools);
|
|
43116
|
+
if (profile) {
|
|
43117
|
+
const source6 = await inspectImportedFile(file2, owned.input, bounded3, tools, profile);
|
|
43118
|
+
return PreserveVisualInspectionSchema.parse({
|
|
43119
|
+
profileId: profile,
|
|
43120
|
+
source: source6,
|
|
43121
|
+
toolchain,
|
|
43122
|
+
evidenceScope: "TECHNICAL_MEDIA_ONLY"
|
|
43123
|
+
});
|
|
43124
|
+
}
|
|
42780
43125
|
const source5 = await inspectImportedFile(file2, owned.input, bounded3, tools);
|
|
42781
43126
|
return ImportedVisualInspectionSchema.parse({
|
|
42782
43127
|
profileId: IMPORTED_VISUAL_PROFILE_ID,
|
|
@@ -42817,6 +43162,20 @@ function importedFramePlan(source5, request) {
|
|
|
42817
43162
|
throw new ImportedVisualNormalizationError("UPSCALE_NOT_ALLOWED", "NORMALIZE");
|
|
42818
43163
|
if (source5.audio && request.audioPolicy !== "SILENT_DERIVATIVE")
|
|
42819
43164
|
throw new ImportedVisualNormalizationError("AUDIO_POLICY_REQUIRES_SILENT_SOURCE", "NORMALIZE");
|
|
43165
|
+
return mapFrames(source5, request);
|
|
43166
|
+
}
|
|
43167
|
+
function preserveImportedFramePlan(source5, request) {
|
|
43168
|
+
if (!preservesEncodedAspect(source5.geometry, request.output))
|
|
43169
|
+
throw new ImportedVisualNormalizationError("OUTPUT_GEOMETRY_MISMATCH", "NORMALIZE");
|
|
43170
|
+
if (source5.sampleAspectRatio === "UNSPECIFIED" && request.pixelAspectPolicy !== "ASSUME_SQUARE_WHEN_UNSPECIFIED")
|
|
43171
|
+
throw new ImportedVisualNormalizationError("OUTPUT_GEOMETRY_MISMATCH", "NORMALIZE");
|
|
43172
|
+
if (request.sourceRange.endFrame > source5.availableCfr30Frames)
|
|
43173
|
+
throw new ImportedVisualNormalizationError("SOURCE_RANGE_OUT_OF_BOUNDS", "NORMALIZE");
|
|
43174
|
+
if (source5.audio && request.audioPolicy !== "SILENT_DERIVATIVE")
|
|
43175
|
+
throw new ImportedVisualNormalizationError("AUDIO_POLICY_REQUIRES_SILENT_SOURCE", "NORMALIZE");
|
|
43176
|
+
return mapFrames(source5, request);
|
|
43177
|
+
}
|
|
43178
|
+
function mapFrames(source5, request) {
|
|
42820
43179
|
const fps = source5.frameRate;
|
|
42821
43180
|
const ptsUnit = BigInt(source5.timeBase.denominator) * BigInt(fps.denominator);
|
|
42822
43181
|
const ptsDivisor = BigInt(source5.timeBase.numerator) * BigInt(fps.numerator);
|
|
@@ -42839,6 +43198,22 @@ var init_frame_plan = __esm({
|
|
|
42839
43198
|
"packages/media-execution/src/imported-visual/frame-plan.ts"() {
|
|
42840
43199
|
"use strict";
|
|
42841
43200
|
init_imported_visual();
|
|
43201
|
+
init_imported_visual();
|
|
43202
|
+
}
|
|
43203
|
+
});
|
|
43204
|
+
|
|
43205
|
+
// packages/media-execution/src/imported-visual/geometry.ts
|
|
43206
|
+
function preservedPosterGeometry(width, height) {
|
|
43207
|
+
const portrait = width < height;
|
|
43208
|
+
const scale = Math.min(1, (portrait ? 180 : 320) / width, (portrait ? 320 : 180) / height);
|
|
43209
|
+
return {
|
|
43210
|
+
width: Math.max(1, Math.round(width * scale)),
|
|
43211
|
+
height: Math.max(1, Math.round(height * scale))
|
|
43212
|
+
};
|
|
43213
|
+
}
|
|
43214
|
+
var init_geometry = __esm({
|
|
43215
|
+
"packages/media-execution/src/imported-visual/geometry.ts"() {
|
|
43216
|
+
"use strict";
|
|
42842
43217
|
}
|
|
42843
43218
|
});
|
|
42844
43219
|
|
|
@@ -42851,8 +43226,16 @@ function requireToolchain(expected, actual) {
|
|
|
42851
43226
|
throw new ImportedVisualNormalizationError("TOOLCHAIN_MISMATCH", "PREFLIGHT");
|
|
42852
43227
|
}
|
|
42853
43228
|
async function normalizeImportedVisual(raw, input3, signal, tools) {
|
|
43229
|
+
const result = await normalize2(raw, input3, signal, tools, false);
|
|
43230
|
+
return { ...result, receipt: ImportedVisualNormalizationReceiptSchema.parse(result.receipt) };
|
|
43231
|
+
}
|
|
43232
|
+
async function normalizePreserveImportedVisual(raw, input3, signal, tools) {
|
|
43233
|
+
const result = await normalize2(raw, input3, signal, tools, true);
|
|
43234
|
+
return { ...result, receipt: PreserveVisualNormalizationReceiptSchema.parse(result.receipt) };
|
|
43235
|
+
}
|
|
43236
|
+
async function normalize2(raw, input3, signal, tools, preserve) {
|
|
42854
43237
|
if (signal.aborted) throw new ImportedVisualNormalizationError("CANCELLED", "PREFLIGHT");
|
|
42855
|
-
const parsed = ImportedVisualNormalizationRequestSchema.safeParse(raw);
|
|
43238
|
+
const parsed = preserve ? PreserveVisualNormalizationRequestSchema.safeParse(raw) : ImportedVisualNormalizationRequestSchema.safeParse(raw);
|
|
42856
43239
|
if (!parsed.success) throw new ImportedVisualNormalizationError("INVALID_REQUEST", "PREFLIGHT");
|
|
42857
43240
|
const request = parsed.data, owned = ownedImportedBytes(request.source, input3);
|
|
42858
43241
|
const deadline2 = AbortSignal.timeout(3e5), bounded3 = AbortSignal.any([signal, deadline2]);
|
|
@@ -42864,9 +43247,11 @@ async function normalizeImportedVisual(raw, input3, signal, tools) {
|
|
|
42864
43247
|
const file2 = join15(directory, "source.mp4"), outputFile = join15(directory, "normalized.mp4");
|
|
42865
43248
|
await writeFile9(file2, owned.bytes, { flag: "wx", mode: 384 });
|
|
42866
43249
|
stage2 = "INPUT_PROBE";
|
|
42867
|
-
const original2 = await inspectImportedFile(file2, owned.input, bounded3, tools);
|
|
43250
|
+
const original2 = preserve ? await inspectImportedFile(file2, owned.input, bounded3, tools, PRESERVE_VISUAL_PROFILE_ID) : await inspectImportedFile(file2, owned.input, bounded3, tools);
|
|
42868
43251
|
stage2 = "NORMALIZE";
|
|
42869
|
-
const frameMap = importedFramePlan(original2, request)
|
|
43252
|
+
const frameMap = request.schemaVersion === 2 && "geometryProfile" in original2 ? preserveImportedFramePlan(original2, request) : request.schemaVersion === 1 && !("geometryProfile" in original2) ? importedFramePlan(original2, request) : (() => {
|
|
43253
|
+
throw new ImportedVisualNormalizationError("INVALID_REQUEST", "PREFLIGHT");
|
|
43254
|
+
})();
|
|
42870
43255
|
const { startFrame, endFrame } = request.sourceRange, { width, height } = request.output;
|
|
42871
43256
|
const filters = [
|
|
42872
43257
|
"setpts=PTS-STARTPTS",
|
|
@@ -42913,14 +43298,13 @@ async function normalizeImportedVisual(raw, input3, signal, tools) {
|
|
|
42913
43298
|
"yuv420p",
|
|
42914
43299
|
"-frames:v",
|
|
42915
43300
|
String(endFrame - startFrame),
|
|
42916
|
-
|
|
42917
|
-
"passthrough",
|
|
43301
|
+
// V2 保持同一 CFR 语义,也兼容已资格认证的旧版 FFmpeg。
|
|
43302
|
+
...preserve ? ["-vsync", "0"] : ["-fps_mode", "passthrough"],
|
|
42918
43303
|
"-enc_time_base",
|
|
42919
43304
|
"1:30",
|
|
42920
43305
|
"-video_track_timescale",
|
|
42921
43306
|
"30000",
|
|
42922
|
-
"-movie_timescale",
|
|
42923
|
-
"30000",
|
|
43307
|
+
...preserve ? [] : ["-movie_timescale", "30000"],
|
|
42924
43308
|
"-movflags",
|
|
42925
43309
|
"+frag_keyframe+empty_moov+default_base_moof",
|
|
42926
43310
|
"-f",
|
|
@@ -42933,15 +43317,21 @@ async function normalizeImportedVisual(raw, input3, signal, tools) {
|
|
|
42933
43317
|
);
|
|
42934
43318
|
stage2 = "OUTPUT_VERIFY";
|
|
42935
43319
|
await writeFile9(outputFile, bytes, { flag: "wx", mode: 384 });
|
|
42936
|
-
const
|
|
43320
|
+
const outputInput = derivedImportedInput(owned.input, bytes);
|
|
43321
|
+
const output3 = preserve ? await inspectImportedFile(
|
|
42937
43322
|
outputFile,
|
|
42938
|
-
|
|
43323
|
+
outputInput,
|
|
42939
43324
|
bounded3,
|
|
42940
|
-
tools
|
|
42941
|
-
|
|
43325
|
+
tools,
|
|
43326
|
+
PRESERVE_VISUAL_PROFILE_ID
|
|
43327
|
+
) : await inspectImportedFile(outputFile, outputInput, bounded3, tools);
|
|
42942
43328
|
if (output3.frameCount !== frameMap.length || output3.frameRate.numerator !== 30 || output3.frameRate.denominator !== 1 || output3.audio || output3.geometry.width !== width || output3.geometry.height !== height)
|
|
42943
43329
|
throw new ImportedVisualNormalizationError("OUTPUT_VALIDATION_FAILED", stage2);
|
|
42944
|
-
const portrait = width < height
|
|
43330
|
+
const portrait = width < height;
|
|
43331
|
+
const { width: posterWidth, height: posterHeight } = preserve ? preservedPosterGeometry(width, height) : {
|
|
43332
|
+
width: Math.min(width, portrait ? 180 : 320),
|
|
43333
|
+
height: Math.min(height, portrait ? 320 : 180)
|
|
43334
|
+
};
|
|
42945
43335
|
const poster2 = await importedProcess(
|
|
42946
43336
|
tools.ffmpeg,
|
|
42947
43337
|
[
|
|
@@ -42977,8 +43367,8 @@ async function normalizeImportedVisual(raw, input3, signal, tools) {
|
|
|
42977
43367
|
"POSTER_INVALID"
|
|
42978
43368
|
);
|
|
42979
43369
|
requireToolchain(toolchain, await importedToolchain(bounded3, tools));
|
|
42980
|
-
const receipt2 = ImportedVisualNormalizationReceiptSchema.parse({
|
|
42981
|
-
schemaVersion:
|
|
43370
|
+
const receipt2 = (preserve ? PreserveVisualNormalizationReceiptSchema : ImportedVisualNormalizationReceiptSchema).parse({
|
|
43371
|
+
schemaVersion: request.schemaVersion,
|
|
42982
43372
|
request,
|
|
42983
43373
|
original: original2,
|
|
42984
43374
|
output: output3,
|
|
@@ -43020,6 +43410,7 @@ var init_normalize = __esm({
|
|
|
43020
43410
|
init_common3();
|
|
43021
43411
|
init_inspect3();
|
|
43022
43412
|
init_frame_plan();
|
|
43413
|
+
init_geometry();
|
|
43023
43414
|
}
|
|
43024
43415
|
});
|
|
43025
43416
|
|
|
@@ -43028,17 +43419,25 @@ import { mkdtemp as mkdtemp8, rm as rm8, writeFile as writeFile10 } from "node:f
|
|
|
43028
43419
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
43029
43420
|
import { isAbsolute as isAbsolute4, join as join16 } from "node:path";
|
|
43030
43421
|
async function inspectImportedVisualReadback(rawRequest, rawReceipt, video, poster2, tools, signal) {
|
|
43422
|
+
const result = await readback(rawRequest, rawReceipt, video, poster2, tools, signal, false);
|
|
43423
|
+
return { ...result, receipt: ImportedVisualNormalizationReceiptSchema.parse(result.receipt) };
|
|
43424
|
+
}
|
|
43425
|
+
async function inspectPreserveImportedVisualReadback(rawRequest, rawReceipt, video, poster2, tools, signal) {
|
|
43426
|
+
const result = await readback(rawRequest, rawReceipt, video, poster2, tools, signal, true);
|
|
43427
|
+
return { ...result, receipt: PreserveVisualNormalizationReceiptSchema.parse(result.receipt) };
|
|
43428
|
+
}
|
|
43429
|
+
async function readback(rawRequest, rawReceipt, video, poster2, tools, signal, preserve) {
|
|
43031
43430
|
const stage2 = "OUTPUT_VERIFY";
|
|
43032
43431
|
if (signal.aborted) throw new ImportedVisualNormalizationError("CANCELLED", stage2);
|
|
43033
|
-
const request = ImportedVisualNormalizationRequestSchema.parse(rawRequest);
|
|
43034
|
-
const receipt2 = ImportedVisualNormalizationReceiptSchema.parse(rawReceipt);
|
|
43432
|
+
const request = (preserve ? PreserveVisualNormalizationRequestSchema : ImportedVisualNormalizationRequestSchema).parse(rawRequest);
|
|
43433
|
+
const receipt2 = (preserve ? PreserveVisualNormalizationReceiptSchema : ImportedVisualNormalizationReceiptSchema).parse(rawReceipt);
|
|
43035
43434
|
if (canonicalLocalJson(request) !== canonicalLocalJson(receipt2.request))
|
|
43036
43435
|
throw new ImportedVisualNormalizationError("INVALID_REQUEST", stage2);
|
|
43037
43436
|
if (!isAbsolute4(tools.ffmpeg) || !isAbsolute4(tools.ffprobe))
|
|
43038
43437
|
throw new ImportedVisualNormalizationError("TOOLCHAIN_MISMATCH", stage2);
|
|
43039
43438
|
const { width, height } = request.output;
|
|
43040
43439
|
const portrait = width < height;
|
|
43041
|
-
const
|
|
43440
|
+
const geometry4 = preserve ? preservedPosterGeometry(width, height) : {
|
|
43042
43441
|
width: Math.min(width, portrait ? 180 : 320),
|
|
43043
43442
|
height: Math.min(height, portrait ? 320 : 180)
|
|
43044
43443
|
};
|
|
@@ -43050,7 +43449,7 @@ async function inspectImportedVisualReadback(rawRequest, rawReceipt, video, post
|
|
|
43050
43449
|
if (!(poster2 instanceof Uint8Array) || poster2.byteLength > 2 * 1024 * 1024)
|
|
43051
43450
|
throw new ImportedVisualNormalizationError("OUTPUT_VALIDATION_FAILED", stage2);
|
|
43052
43451
|
const image = Buffer.from(poster2);
|
|
43053
|
-
validatePreviewPng(image,
|
|
43452
|
+
validatePreviewPng(image, geometry4);
|
|
43054
43453
|
const owned = ownedImportedBytes(
|
|
43055
43454
|
{ contentType, byteSize, checksumSha256, executionClass },
|
|
43056
43455
|
video
|
|
@@ -43065,10 +43464,16 @@ async function inspectImportedVisualReadback(rawRequest, rawReceipt, video, post
|
|
|
43065
43464
|
throw new ImportedVisualNormalizationError("TOOLCHAIN_MISMATCH", stage2);
|
|
43066
43465
|
};
|
|
43067
43466
|
await checkToolchain();
|
|
43068
|
-
const output3 = await inspectImportedFile(
|
|
43467
|
+
const output3 = preserve ? await inspectImportedFile(
|
|
43468
|
+
videoPath,
|
|
43469
|
+
owned.input,
|
|
43470
|
+
bounded3,
|
|
43471
|
+
tools,
|
|
43472
|
+
PRESERVE_VISUAL_PROFILE_ID
|
|
43473
|
+
) : await inspectImportedFile(videoPath, owned.input, bounded3, tools);
|
|
43069
43474
|
if (canonicalLocalJson(output3) !== canonicalLocalJson(receipt2.output))
|
|
43070
43475
|
throw new ImportedVisualNormalizationError("OUTPUT_VALIDATION_FAILED", stage2);
|
|
43071
|
-
const decodedSize =
|
|
43476
|
+
const decodedSize = geometry4.width * geometry4.height * 3;
|
|
43072
43477
|
const decoded = await importedProcess(
|
|
43073
43478
|
tools.ffmpeg,
|
|
43074
43479
|
[
|
|
@@ -43113,7 +43518,7 @@ async function inspectImportedVisualReadback(rawRequest, rawReceipt, video, post
|
|
|
43113
43518
|
return {
|
|
43114
43519
|
receipt: receipt2,
|
|
43115
43520
|
posterEvidence: {
|
|
43116
|
-
...
|
|
43521
|
+
...geometry4,
|
|
43117
43522
|
byteSize: image.length,
|
|
43118
43523
|
checksumSha256: hashImportedBytes(image)
|
|
43119
43524
|
}
|
|
@@ -43141,6 +43546,7 @@ var init_readback = __esm({
|
|
|
43141
43546
|
init_png();
|
|
43142
43547
|
init_common3();
|
|
43143
43548
|
init_inspect3();
|
|
43549
|
+
init_geometry();
|
|
43144
43550
|
}
|
|
43145
43551
|
});
|
|
43146
43552
|
|
|
@@ -43149,7 +43555,7 @@ import { mkdtemp as mkdtemp9, readFile as readFile13, rm as rm9, writeFile as wr
|
|
|
43149
43555
|
import { join as join17 } from "node:path";
|
|
43150
43556
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
43151
43557
|
import { createHash as createHash12 } from "node:crypto";
|
|
43152
|
-
async function extractImportedSourceSynchronousAudio(raw, source5, input3, signal, tools) {
|
|
43558
|
+
async function extractImportedSourceSynchronousAudio(raw, source5, input3, signal, tools, sourceGeometryProfile) {
|
|
43153
43559
|
const parsed = ImportedSynchronousAudioExtractionSchema.safeParse(raw);
|
|
43154
43560
|
if (!parsed.success) throw new ImportedVisualNormalizationError("INVALID_REQUEST", "PREFLIGHT");
|
|
43155
43561
|
const intent = parsed.data;
|
|
@@ -43164,7 +43570,7 @@ async function extractImportedSourceSynchronousAudio(raw, source5, input3, signa
|
|
|
43164
43570
|
try {
|
|
43165
43571
|
const file2 = join17(dir, "original.mp4"), target2 = join17(dir, "source-sync.wav");
|
|
43166
43572
|
await writeFile11(file2, owned.bytes, { flag: "wx", mode: 384 });
|
|
43167
|
-
const checked = await inspectImportedFile(file2, owned.input, bounded3, tools);
|
|
43573
|
+
const checked = sourceGeometryProfile ? await inspectImportedFile(file2, owned.input, bounded3, tools, sourceGeometryProfile) : await inspectImportedFile(file2, owned.input, bounded3, tools);
|
|
43168
43574
|
if (!checked.audio || intent.sourceRange.endFrame > checked.availableCfr30Frames)
|
|
43169
43575
|
throw new ImportedVisualNormalizationError("SOURCE_RANGE_OUT_OF_BOUNDS", "INPUT_PROBE");
|
|
43170
43576
|
const from = intent.sourceRange.startFrame * 1600;
|
|
@@ -44087,7 +44493,7 @@ var init_black_frames = __esm({
|
|
|
44087
44493
|
"use strict";
|
|
44088
44494
|
init_runner();
|
|
44089
44495
|
init_picture();
|
|
44090
|
-
integer3 = (value2, minimum,
|
|
44496
|
+
integer3 = (value2, minimum, maximum4) => Number.isSafeInteger(value2) && value2 >= minimum && value2 <= maximum4;
|
|
44091
44497
|
input2 = (file2) => [
|
|
44092
44498
|
"-v",
|
|
44093
44499
|
"error",
|
|
@@ -45402,7 +45808,7 @@ var init_kokoro = __esm({
|
|
|
45402
45808
|
|
|
45403
45809
|
// packages/media-execution/src/speech/identity.mjs
|
|
45404
45810
|
var audioPlatformIdentityFiles;
|
|
45405
|
-
var
|
|
45811
|
+
var init_identity3 = __esm({
|
|
45406
45812
|
"packages/media-execution/src/speech/identity.mjs"() {
|
|
45407
45813
|
"use strict";
|
|
45408
45814
|
audioPlatformIdentityFiles = [
|
|
@@ -45435,7 +45841,7 @@ var init_profile3 = __esm({
|
|
|
45435
45841
|
"packages/media-execution/src/speech/profile.ts"() {
|
|
45436
45842
|
"use strict";
|
|
45437
45843
|
init_local_execution();
|
|
45438
|
-
|
|
45844
|
+
init_identity3();
|
|
45439
45845
|
digest12 = (bytes) => createHash27("sha256").update(bytes).digest("hex");
|
|
45440
45846
|
AUDIO_RENDERER_VERSION = "0.1.0";
|
|
45441
45847
|
LOCAL_AUDIO_PROFILE_DIGEST = digest12(canonicalLocalJson(LOCAL_AUDIO_PROFILE_SPEC));
|
|
@@ -45447,12 +45853,12 @@ import { realpath as realpath6 } from "node:fs/promises";
|
|
|
45447
45853
|
import { isAbsolute as isAbsolute11 } from "node:path";
|
|
45448
45854
|
async function qualifyAudioToolchain(tools, outer = AbortSignal.timeout(2e4)) {
|
|
45449
45855
|
const signal = AbortSignal.any([outer, AbortSignal.timeout(2e4)]);
|
|
45450
|
-
const
|
|
45856
|
+
const digest16 = async (path) => (await speechFileDigest(path, signal)).sha256;
|
|
45451
45857
|
const binary = async (name2) => {
|
|
45452
45858
|
const path = tools[name2];
|
|
45453
45859
|
if (!isAbsolute11(path) || await realpath6(path) !== path) throw Error("AUDIO_TOOL_INVALID");
|
|
45454
45860
|
await assertExecutable(path);
|
|
45455
|
-
const before = await
|
|
45861
|
+
const before = await digest16(path);
|
|
45456
45862
|
const version4 = (await runControlledProcess(path, ["-version"], {
|
|
45457
45863
|
signal,
|
|
45458
45864
|
timeoutMs: 1e4,
|
|
@@ -45460,7 +45866,7 @@ async function qualifyAudioToolchain(tools, outer = AbortSignal.timeout(2e4)) {
|
|
|
45460
45866
|
})).toString().split("\n")[0];
|
|
45461
45867
|
if (!version4.startsWith(name2 + " version ") || version4.length > 160)
|
|
45462
45868
|
throw Error("AUDIO_TOOL_INVALID");
|
|
45463
|
-
if (before !== await
|
|
45869
|
+
if (before !== await digest16(path)) throw Error("AUDIO_TOOL_CHANGED");
|
|
45464
45870
|
return { version: version4, binaryDigest: before };
|
|
45465
45871
|
};
|
|
45466
45872
|
const ffmpeg = await binary("ffmpeg"), ffprobe = await binary("ffprobe");
|
|
@@ -45468,11 +45874,11 @@ async function qualifyAudioToolchain(tools, outer = AbortSignal.timeout(2e4)) {
|
|
|
45468
45874
|
for (let i = 0; i < 3200; i++)
|
|
45469
45875
|
pcm.writeInt16LE(Math.round(Math.sin(i * 2 * Math.PI * 440 / 24e3) * 1e3), i * 2);
|
|
45470
45876
|
const normalized = await normalizeSpeechPcm(writePcmWave(pcm, 24e3, 1), tools, signal);
|
|
45471
|
-
const
|
|
45472
|
-
if (
|
|
45877
|
+
const readback3 = readPcmWaveStructure(normalized.bytes);
|
|
45878
|
+
if (readback3.channels !== 1 || readback3.sampleCount !== 6432 || !normalized.bytes.subarray(44).some((b) => b !== 0))
|
|
45473
45879
|
throw Error("AUDIO_TOOL_UNQUALIFIED");
|
|
45474
45880
|
const rendererDigest = await audioRendererDigest();
|
|
45475
|
-
if (await
|
|
45881
|
+
if (await digest16(tools.ffmpeg) !== ffmpeg.binaryDigest || await digest16(tools.ffprobe) !== ffprobe.binaryDigest)
|
|
45476
45882
|
throw Error("AUDIO_TOOL_CHANGED");
|
|
45477
45883
|
signal.throwIfAborted();
|
|
45478
45884
|
return LocalToolchainSchema.parse({
|
|
@@ -45520,7 +45926,7 @@ function setParameters(form, parameters) {
|
|
|
45520
45926
|
}
|
|
45521
45927
|
function prepareOpenAiTranscription(input3) {
|
|
45522
45928
|
const { source: source5, bytes, parameters = {} } = input3;
|
|
45523
|
-
if (source5.contentType !== "audio/wav" || !(bytes instanceof Uint8Array) || bytes.byteLength !== source5.byteSize || bytes.byteLength < 44 || bytes.byteLength > maxAudioBytes2 || !Number.isFinite(source5.durationMs) || source5.durationMs <= 0 || source5.durationMs > maxDurationMs2)
|
|
45929
|
+
if (source5.contentType !== "audio/wav" || input3.model !== void 0 && input3.model !== openAiWhisperModelId || !(bytes instanceof Uint8Array) || bytes.byteLength !== source5.byteSize || bytes.byteLength < 44 || bytes.byteLength > maxAudioBytes2 || !Number.isFinite(source5.durationMs) || source5.durationMs <= 0 || source5.durationMs > maxDurationMs2)
|
|
45524
45930
|
throw new OpenAiTranscriptionError("INPUT_INVALID");
|
|
45525
45931
|
try {
|
|
45526
45932
|
const snapshot2 = Uint8Array.from(bytes);
|
|
@@ -45528,13 +45934,27 @@ function prepareOpenAiTranscription(input3) {
|
|
|
45528
45934
|
if (snapshot2.byteLength !== source5.byteSize || createHash28("sha256").update(snapshot2).digest("hex") !== source5.checksumSha256 || wav.sampleCount / 48 !== source5.durationMs || source5.audioChannels !== void 0 && source5.audioChannels !== wav.channels)
|
|
45529
45935
|
throw new OpenAiTranscriptionError("INPUT_INVALID");
|
|
45530
45936
|
const form = new FormData();
|
|
45531
|
-
|
|
45937
|
+
const selected = input3.model ?? model2;
|
|
45938
|
+
form.set("model", selected);
|
|
45532
45939
|
form.set("file", new Blob([snapshot2], { type: "audio/wav" }), "managed.wav");
|
|
45533
|
-
form.set("response_format", "json");
|
|
45940
|
+
form.set("response_format", input3.model ? "verbose_json" : "json");
|
|
45534
45941
|
form.set("stream", "false");
|
|
45535
|
-
|
|
45942
|
+
let granularities;
|
|
45943
|
+
if (input3.model) {
|
|
45944
|
+
const parsed = OpenAiWhisperParametersSchema.parse(parameters);
|
|
45945
|
+
granularities = parsed.timestamp_granularities;
|
|
45946
|
+
for (const item of granularities) form.append("timestamp_granularities[]", item);
|
|
45947
|
+
if (parsed.language !== void 0) form.set("language", parsed.language);
|
|
45948
|
+
if (parsed.prompt !== void 0) form.set("prompt", parsed.prompt);
|
|
45949
|
+
if (parsed.temperature !== void 0) form.set("temperature", String(parsed.temperature));
|
|
45950
|
+
} else setParameters(form, parameters);
|
|
45536
45951
|
const prepared2 = Object.freeze({ [preparedKey2]: true });
|
|
45537
|
-
preparedBodies2.set(prepared2,
|
|
45952
|
+
preparedBodies2.set(prepared2, {
|
|
45953
|
+
form,
|
|
45954
|
+
model: selected,
|
|
45955
|
+
durationMs: source5.durationMs,
|
|
45956
|
+
...granularities && { granularities }
|
|
45957
|
+
});
|
|
45538
45958
|
return prepared2;
|
|
45539
45959
|
} catch {
|
|
45540
45960
|
throw new OpenAiTranscriptionError("INPUT_INVALID");
|
|
@@ -45554,29 +45974,60 @@ function readUsage(value2) {
|
|
|
45554
45974
|
return { input_tokens, output_tokens, total_tokens };
|
|
45555
45975
|
throw new Error();
|
|
45556
45976
|
}
|
|
45557
|
-
function readReceipt2(value2, requestId3) {
|
|
45977
|
+
function readReceipt2(value2, requestId3, prepared2) {
|
|
45558
45978
|
const { text: text5, languages = [], usage } = record4(value2);
|
|
45559
45979
|
if (typeof text5 !== "string" || !text5.isWellFormed() || text5.includes("\0") || Buffer.byteLength(text5) > 6e4 || !Array.isArray(languages) || languages.length > 32)
|
|
45560
45980
|
throw new Error();
|
|
45561
|
-
const transcript = TranscriptSchema.options[0].parse({
|
|
45981
|
+
const transcript = prepared2.model === openAiWhisperModelId ? readWhisperTranscript(value2, text5, prepared2.durationMs, prepared2.granularities) : TranscriptSchema.options[0].parse({
|
|
45562
45982
|
schemaVersion: 1,
|
|
45563
45983
|
text: text5,
|
|
45564
45984
|
languages: languages.map((value3) => {
|
|
45565
45985
|
const { code } = record4(value3);
|
|
45566
|
-
if (typeof code !== "string" || !/^[a-zA-Z][a-zA-Z0-9-]{1,39}$/.test(code))
|
|
45986
|
+
if (typeof code !== "string" || !/^[a-zA-Z][a-zA-Z0-9-]{1,39}$/.test(code))
|
|
45987
|
+
throw new Error();
|
|
45567
45988
|
return code;
|
|
45568
45989
|
}),
|
|
45569
45990
|
timing: "UNAVAILABLE"
|
|
45570
45991
|
});
|
|
45571
45992
|
const receipt2 = {
|
|
45572
45993
|
providerRequestId: requestId3 && /^[A-Za-z0-9_.:-]{1,500}$/.test(requestId3) ? requestId3 : null,
|
|
45573
|
-
model:
|
|
45994
|
+
model: prepared2.model,
|
|
45574
45995
|
usage: readUsage(usage),
|
|
45575
45996
|
transcript
|
|
45576
45997
|
};
|
|
45577
45998
|
if (Buffer.byteLength(JSON.stringify(receipt2)) > maxReceiptBytes2) throw new Error();
|
|
45578
45999
|
return receipt2;
|
|
45579
46000
|
}
|
|
46001
|
+
function readWhisperTranscript(value2, text5, durationMs, granularities) {
|
|
46002
|
+
const raw = record4(value2);
|
|
46003
|
+
const readSpans = (kind, enabled) => {
|
|
46004
|
+
if (!enabled) return [];
|
|
46005
|
+
const items = raw[kind] ?? [];
|
|
46006
|
+
if (!Array.isArray(items) || items.length > (kind === "words" ? 1200 : 240)) throw new Error();
|
|
46007
|
+
return items.map((value3) => {
|
|
46008
|
+
const item = record4(value3);
|
|
46009
|
+
const start = item.start, end = item.end;
|
|
46010
|
+
if (typeof start !== "number" || typeof end !== "number" || !Number.isFinite(start) || !Number.isFinite(end) || start < 0 || (kind === "words" ? end < start : end <= start) || end * 1e3 > durationMs + 0.5)
|
|
46011
|
+
throw new Error();
|
|
46012
|
+
return {
|
|
46013
|
+
text: item[kind === "words" ? "word" : "text"],
|
|
46014
|
+
startMs: Math.round(start * 1e3),
|
|
46015
|
+
endMs: Math.round(end * 1e3)
|
|
46016
|
+
};
|
|
46017
|
+
});
|
|
46018
|
+
};
|
|
46019
|
+
const language = raw.language;
|
|
46020
|
+
return TranscriptSchema.parse({
|
|
46021
|
+
schemaVersion: 1,
|
|
46022
|
+
text: text5,
|
|
46023
|
+
languages: typeof language === "string" && language.length >= 2 && language.length <= 40 ? [language] : [],
|
|
46024
|
+
timing: "PROVIDER_REPORTED",
|
|
46025
|
+
timeBase: "ORIGINAL_MEDIA_MS",
|
|
46026
|
+
granularities,
|
|
46027
|
+
words: readSpans("words", granularities.includes("word")),
|
|
46028
|
+
segments: readSpans("segments", granularities.includes("segment"))
|
|
46029
|
+
});
|
|
46030
|
+
}
|
|
45580
46031
|
async function readResponse(response, signal) {
|
|
45581
46032
|
const body = response.body;
|
|
45582
46033
|
const declared = response.headers.get("content-length");
|
|
@@ -45607,8 +46058,8 @@ async function readResponse(response, signal) {
|
|
|
45607
46058
|
}
|
|
45608
46059
|
}
|
|
45609
46060
|
async function submitOpenAiTranscription(input3, request = fetch) {
|
|
45610
|
-
const
|
|
45611
|
-
if (!
|
|
46061
|
+
const prepared2 = preparedBodies2.get(input3.prepared);
|
|
46062
|
+
if (!prepared2 || typeof input3.apiKey !== "string" || !/^[!-~]{8,4096}$/.test(input3.apiKey))
|
|
45612
46063
|
throw new OpenAiTranscriptionError("INPUT_INVALID");
|
|
45613
46064
|
if (input3.signal.aborted) throw new OpenAiTranscriptionError("CANCELLED");
|
|
45614
46065
|
const signal = AbortSignal.any([input3.signal, AbortSignal.timeout(timeoutMs2)]);
|
|
@@ -45621,7 +46072,7 @@ async function submitOpenAiTranscription(input3, request = fetch) {
|
|
|
45621
46072
|
cache: "no-store",
|
|
45622
46073
|
credentials: "omit",
|
|
45623
46074
|
headers: { authorization: `Bearer ${input3.apiKey}` },
|
|
45624
|
-
body,
|
|
46075
|
+
body: prepared2.form,
|
|
45625
46076
|
signal
|
|
45626
46077
|
});
|
|
45627
46078
|
} catch {
|
|
@@ -45640,7 +46091,7 @@ async function submitOpenAiTranscription(input3, request = fetch) {
|
|
|
45640
46091
|
const bytes = await readResponse(response, signal);
|
|
45641
46092
|
signal.throwIfAborted();
|
|
45642
46093
|
const value2 = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
45643
|
-
return readReceipt2(value2, response.headers.get("x-request-id"));
|
|
46094
|
+
return readReceipt2(value2, response.headers.get("x-request-id"), prepared2);
|
|
45644
46095
|
} catch {
|
|
45645
46096
|
throw new OpenAiTranscriptionError("PROVIDER_OUTCOME_UNKNOWN");
|
|
45646
46097
|
}
|
|
@@ -45692,6 +46143,8 @@ var init_src3 = __esm({
|
|
|
45692
46143
|
init_inspect3();
|
|
45693
46144
|
init_normalize();
|
|
45694
46145
|
init_readback();
|
|
46146
|
+
init_normalize();
|
|
46147
|
+
init_readback();
|
|
45695
46148
|
init_probe();
|
|
45696
46149
|
init_source_sync();
|
|
45697
46150
|
init_extract();
|
|
@@ -45856,14 +46309,14 @@ var init_version = __esm({
|
|
|
45856
46309
|
"use strict";
|
|
45857
46310
|
init_src3();
|
|
45858
46311
|
init_local_execution();
|
|
45859
|
-
runtimeVersion = true ? "0.3.0-rc.
|
|
46312
|
+
runtimeVersion = true ? "0.3.0-rc.27" : "0.2.0";
|
|
45860
46313
|
}
|
|
45861
46314
|
});
|
|
45862
46315
|
|
|
45863
46316
|
// apps/local-runtime/src/identity.ts
|
|
45864
46317
|
import { createHash as createHash36 } from "node:crypto";
|
|
45865
46318
|
var digest13, fingerprint2;
|
|
45866
|
-
var
|
|
46319
|
+
var init_identity4 = __esm({
|
|
45867
46320
|
"apps/local-runtime/src/identity.ts"() {
|
|
45868
46321
|
"use strict";
|
|
45869
46322
|
init_local_execution();
|
|
@@ -45902,7 +46355,7 @@ var init_executions = __esm({
|
|
|
45902
46355
|
"use strict";
|
|
45903
46356
|
init_zod();
|
|
45904
46357
|
init_local_execution();
|
|
45905
|
-
|
|
46358
|
+
init_identity4();
|
|
45906
46359
|
init_error();
|
|
45907
46360
|
ExecutionEntrySchema = external_exports.strictObject({
|
|
45908
46361
|
assignment: LocalWorkAssignmentSchema,
|
|
@@ -45995,7 +46448,7 @@ var init_claim = __esm({
|
|
|
45995
46448
|
"use strict";
|
|
45996
46449
|
init_zod();
|
|
45997
46450
|
init_local_execution();
|
|
45998
|
-
|
|
46451
|
+
init_identity4();
|
|
45999
46452
|
RenderClaimSchema = external_exports.strictObject({
|
|
46000
46453
|
scope: LocalProjectScopeSchema,
|
|
46001
46454
|
requestId: external_exports.uuid(),
|
|
@@ -46024,7 +46477,7 @@ var init_requests = __esm({
|
|
|
46024
46477
|
"use strict";
|
|
46025
46478
|
init_zod();
|
|
46026
46479
|
init_local_execution();
|
|
46027
|
-
|
|
46480
|
+
init_identity4();
|
|
46028
46481
|
init_error();
|
|
46029
46482
|
init_executions();
|
|
46030
46483
|
RequestEntrySchema = external_exports.strictObject({
|
|
@@ -46287,7 +46740,7 @@ var init_provider_submission = __esm({
|
|
|
46287
46740
|
init_zod();
|
|
46288
46741
|
init_local_execution();
|
|
46289
46742
|
init_error();
|
|
46290
|
-
|
|
46743
|
+
init_identity4();
|
|
46291
46744
|
init_provider_credential();
|
|
46292
46745
|
SubmissionScope = external_exports.strictObject({
|
|
46293
46746
|
tenantId: LocalIdSchema,
|
|
@@ -46703,7 +47156,7 @@ import { createHash as createHash39 } from "node:crypto";
|
|
|
46703
47156
|
import { mkdtemp as mkdtemp23, rm as rm23, writeFile as writeFile27 } from "node:fs/promises";
|
|
46704
47157
|
import { tmpdir as tmpdir23 } from "node:os";
|
|
46705
47158
|
import { isAbsolute as isAbsolute16, join as join38 } from "node:path";
|
|
46706
|
-
function
|
|
47159
|
+
function geometry3(aspect) {
|
|
46707
47160
|
if (aspect !== "16:9" && aspect !== "9:16") throw badResult();
|
|
46708
47161
|
return aspect === "16:9" ? [1280, 720, 320, 180] : [720, 1280, 180, 320];
|
|
46709
47162
|
}
|
|
@@ -46744,7 +47197,7 @@ async function inspectQwenReferences(references, mode, signal, tools) {
|
|
|
46744
47197
|
}
|
|
46745
47198
|
}
|
|
46746
47199
|
async function inspectQwenKeyframe(bytes, aspect, signal, tools) {
|
|
46747
|
-
const [width, height] =
|
|
47200
|
+
const [width, height] = geometry3(aspect);
|
|
46748
47201
|
if (!(bytes instanceof Uint8Array) || bytes.byteLength < 1 || bytes.byteLength > qwenMaxImageBytes)
|
|
46749
47202
|
throw badResult();
|
|
46750
47203
|
const contentType = "image/png";
|
|
@@ -46920,6 +47373,88 @@ var init_inspect6 = __esm({
|
|
|
46920
47373
|
}
|
|
46921
47374
|
});
|
|
46922
47375
|
|
|
47376
|
+
// packages/media-execution/src/generation/keyframe-pad.ts
|
|
47377
|
+
import { createHash as createHash40 } from "node:crypto";
|
|
47378
|
+
import { mkdtemp as mkdtemp24, rm as rm24, writeFile as writeFile28 } from "node:fs/promises";
|
|
47379
|
+
import { tmpdir as tmpdir24 } from "node:os";
|
|
47380
|
+
import { join as join39 } from "node:path";
|
|
47381
|
+
async function normalizeQwenKeyframe(bytes, aspect, signal, tools) {
|
|
47382
|
+
const fail = () => new QwenGenerationError("RESULT_INVALID");
|
|
47383
|
+
if (!(bytes instanceof Uint8Array) || !bytes.length || bytes.length > maximum3 || !["16:9", "9:16"].includes(aspect))
|
|
47384
|
+
throw fail();
|
|
47385
|
+
const originalBytes = Uint8Array.from(bytes);
|
|
47386
|
+
const inspect3 = (value2) => inspectProjectImageSource(
|
|
47387
|
+
{ contentType: "image/png", checksumSha256: digest15(value2), byteSize: value2.length },
|
|
47388
|
+
value2,
|
|
47389
|
+
signal,
|
|
47390
|
+
tools
|
|
47391
|
+
);
|
|
47392
|
+
try {
|
|
47393
|
+
const original2 = { bytes: originalBytes, ...await inspect3(originalBytes) };
|
|
47394
|
+
const [rw, rh] = aspect === "16:9" ? [16, 9] : [9, 16];
|
|
47395
|
+
const scale = Math.ceil(Math.max(original2.width / rw, original2.height / rh));
|
|
47396
|
+
const width = scale * rw, height = scale * rh;
|
|
47397
|
+
if (width * height > 16e6 || width * height > original2.width * original2.height * 1.02)
|
|
47398
|
+
throw fail();
|
|
47399
|
+
if (width === original2.width && height === original2.height)
|
|
47400
|
+
return { original: original2, image: original2 };
|
|
47401
|
+
const root = await mkdtemp24(join39(tmpdir24(), "nvs-qwen-pad-"));
|
|
47402
|
+
try {
|
|
47403
|
+
const path = join39(root, "original.png");
|
|
47404
|
+
await writeFile28(path, originalBytes, { flag: "wx", mode: 384, signal });
|
|
47405
|
+
const padded = await runControlledProcess(
|
|
47406
|
+
tools.ffmpeg,
|
|
47407
|
+
[
|
|
47408
|
+
"-v",
|
|
47409
|
+
"error",
|
|
47410
|
+
"-nostdin",
|
|
47411
|
+
"-xerror",
|
|
47412
|
+
"-threads",
|
|
47413
|
+
"1",
|
|
47414
|
+
"-protocol_whitelist",
|
|
47415
|
+
"file,pipe",
|
|
47416
|
+
"-f",
|
|
47417
|
+
"png_pipe",
|
|
47418
|
+
"-i",
|
|
47419
|
+
path,
|
|
47420
|
+
"-vf",
|
|
47421
|
+
`pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2:black`,
|
|
47422
|
+
"-frames:v",
|
|
47423
|
+
"1",
|
|
47424
|
+
"-threads",
|
|
47425
|
+
"1",
|
|
47426
|
+
"-c:v",
|
|
47427
|
+
"png",
|
|
47428
|
+
"-f",
|
|
47429
|
+
"image2pipe",
|
|
47430
|
+
"pipe:1"
|
|
47431
|
+
],
|
|
47432
|
+
{ signal, timeoutMs: 6e4, maxOutputBytes: maximum3 }
|
|
47433
|
+
);
|
|
47434
|
+
const image = { bytes: padded, ...await inspect3(padded) };
|
|
47435
|
+
if (image.width !== width || image.height !== height) throw fail();
|
|
47436
|
+
return { original: original2, image };
|
|
47437
|
+
} finally {
|
|
47438
|
+
await rm24(root, { recursive: true, force: true });
|
|
47439
|
+
}
|
|
47440
|
+
} catch (error62) {
|
|
47441
|
+
signal.throwIfAborted();
|
|
47442
|
+
if (error62 instanceof InvalidProjectImage) throw fail();
|
|
47443
|
+
throw error62;
|
|
47444
|
+
}
|
|
47445
|
+
}
|
|
47446
|
+
var maximum3, digest15;
|
|
47447
|
+
var init_keyframe_pad = __esm({
|
|
47448
|
+
"packages/media-execution/src/generation/keyframe-pad.ts"() {
|
|
47449
|
+
"use strict";
|
|
47450
|
+
init_runner();
|
|
47451
|
+
init_image();
|
|
47452
|
+
init_transport();
|
|
47453
|
+
maximum3 = 8 * 1024 * 1024;
|
|
47454
|
+
digest15 = (bytes) => createHash40("sha256").update(bytes).digest("hex");
|
|
47455
|
+
}
|
|
47456
|
+
});
|
|
47457
|
+
|
|
46923
47458
|
// packages/media-execution/src/generation/provider-release.ts
|
|
46924
47459
|
import {
|
|
46925
47460
|
createCipheriv,
|
|
@@ -47028,6 +47563,7 @@ var init_generation = __esm({
|
|
|
47028
47563
|
"use strict";
|
|
47029
47564
|
init_qwen();
|
|
47030
47565
|
init_inspect6();
|
|
47566
|
+
init_keyframe_pad();
|
|
47031
47567
|
init_transport();
|
|
47032
47568
|
init_audio3();
|
|
47033
47569
|
init_provider_release2();
|
|
@@ -47089,12 +47625,16 @@ async function executeQwenKeyframe(input3) {
|
|
|
47089
47625
|
const { descriptor, requestId: requestId3, resultId } = recorded.receipt;
|
|
47090
47626
|
if (!requestId3) return { state: "UNKNOWN" };
|
|
47091
47627
|
const downloaded = await downloadQwenResult(descriptor, signal, input3.request);
|
|
47092
|
-
const inspected = await
|
|
47093
|
-
downloaded.bytes,
|
|
47094
|
-
|
|
47095
|
-
|
|
47096
|
-
|
|
47097
|
-
|
|
47628
|
+
const inspected = await (async () => {
|
|
47629
|
+
const padded = recipe.geometryPolicy === "PAD_TO_ASPECT" ? await normalizeQwenKeyframe(downloaded.bytes, recipe.aspectRatio, signal, tools) : void 0;
|
|
47630
|
+
const image = await inspectQwenKeyframe(
|
|
47631
|
+
padded?.image.bytes ?? downloaded.bytes,
|
|
47632
|
+
recipe.aspectRatio,
|
|
47633
|
+
signal,
|
|
47634
|
+
tools
|
|
47635
|
+
);
|
|
47636
|
+
return { image, original: padded?.original };
|
|
47637
|
+
})().catch((error62) => {
|
|
47098
47638
|
signal.throwIfAborted();
|
|
47099
47639
|
if (error62 instanceof QwenGenerationError && error62.code === "RESULT_INVALID") return null;
|
|
47100
47640
|
throw error62;
|
|
@@ -47102,17 +47642,26 @@ async function executeQwenKeyframe(input3) {
|
|
|
47102
47642
|
if (!inspected) return { state: "INVALID_RESULT" };
|
|
47103
47643
|
return {
|
|
47104
47644
|
state: "READY",
|
|
47105
|
-
bytes: inspected.bytes,
|
|
47645
|
+
bytes: inspected.image.bytes,
|
|
47646
|
+
originalBytes: inspected.original?.bytes,
|
|
47106
47647
|
evidence: QwenKeyframeEvidenceSchema.parse({
|
|
47107
47648
|
processor: recipe.processor,
|
|
47108
47649
|
providerExecutionId: requestId3,
|
|
47109
47650
|
providerResultId: resultId,
|
|
47110
47651
|
image: {
|
|
47111
|
-
checksumSha256: inspected.checksumSha256,
|
|
47112
|
-
byteSize: inspected.byteSize,
|
|
47113
|
-
width: inspected.width,
|
|
47114
|
-
height: inspected.height
|
|
47115
|
-
}
|
|
47652
|
+
checksumSha256: inspected.image.checksumSha256,
|
|
47653
|
+
byteSize: inspected.image.byteSize,
|
|
47654
|
+
width: inspected.image.width,
|
|
47655
|
+
height: inspected.image.height
|
|
47656
|
+
},
|
|
47657
|
+
...inspected.original ? {
|
|
47658
|
+
original: {
|
|
47659
|
+
checksumSha256: inspected.original.checksumSha256,
|
|
47660
|
+
byteSize: inspected.original.byteSize,
|
|
47661
|
+
width: inspected.original.width,
|
|
47662
|
+
height: inspected.original.height
|
|
47663
|
+
}
|
|
47664
|
+
} : {}
|
|
47116
47665
|
})
|
|
47117
47666
|
};
|
|
47118
47667
|
}
|
|
@@ -47132,7 +47681,11 @@ async function renderDeviceKeyframe(input3) {
|
|
|
47132
47681
|
signal
|
|
47133
47682
|
)).maySubmit
|
|
47134
47683
|
});
|
|
47135
|
-
if (result.state === "READY")
|
|
47684
|
+
if (result.state === "READY")
|
|
47685
|
+
return {
|
|
47686
|
+
outputs: [result.bytes, ...result.originalBytes ? [result.originalBytes] : []],
|
|
47687
|
+
evidence: result.evidence
|
|
47688
|
+
};
|
|
47136
47689
|
await cloud.processor(
|
|
47137
47690
|
"finishProvider",
|
|
47138
47691
|
{ ...binding, outcome: result.state },
|
|
@@ -47411,7 +47964,7 @@ var init_processor_checkpoint = __esm({
|
|
|
47411
47964
|
"use strict";
|
|
47412
47965
|
init_zod();
|
|
47413
47966
|
init_local_execution();
|
|
47414
|
-
|
|
47967
|
+
init_identity4();
|
|
47415
47968
|
init_error();
|
|
47416
47969
|
init_executions();
|
|
47417
47970
|
rendered = external_exports.strictObject({
|
|
@@ -47555,7 +48108,9 @@ function pendingProviderWork(journal, deadline2) {
|
|
|
47555
48108
|
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
47556
48109
|
if ((recipe.processor === "TRANSCRIBE_EXTERNAL_QWEN" || recipe.processor === "TRANSCRIBE_EXTERNAL_OPENAI") && (!("observationId" in receipt2.result) || receipt2.result.observationId !== recipe.observationId))
|
|
47557
48110
|
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
47558
|
-
if ((recipe.processor === "SPEECH_EXTERNAL_QWEN" || recipe.processor === "SPEECH_EXTERNAL_OPENAI_REALTIME") && (!("generationId" in receipt2.result) || receipt2.result.generationId !== recipe.generationId || !("audio" in receipt2.result) || receipt2.result.audio.version.tenantId !== assignment.work.tenantId || receipt2.result.audio.version.projectId !== assignment.work.projectId || receipt2.result.audio.version.productionId !== assignment.work.productionId ||
|
|
48111
|
+
if ((recipe.processor === "SPEECH_EXTERNAL_QWEN" || recipe.processor === "SPEECH_EXTERNAL_OPENAI_REALTIME") && (!("generationId" in receipt2.result) || receipt2.result.generationId !== recipe.generationId || !("audio" in receipt2.result) || receipt2.result.audio.version.tenantId !== assignment.work.tenantId || receipt2.result.audio.version.projectId !== assignment.work.projectId || receipt2.result.audio.version.productionId !== assignment.work.productionId || // 语音试听与正式旁白共用供应商执行链,但音乐不属于语音生成终态。
|
|
48112
|
+
!["VOICEOVER", "VOICE_SAMPLE"].includes(receipt2.result.audio.version.purpose) || receipt2.result.audio.version.generation?.generationId !== recipe.generationId || // 外部供应商语音的既有音频回执可以省略设备标记;签名绑定和原任务仍须精确一致。
|
|
48113
|
+
receipt2.result.audio.version.generation.executionTarget !== void 0 && receipt2.result.audio.version.generation.executionTarget !== "TENANT_DEVICE"))
|
|
47559
48114
|
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
47560
48115
|
completed.add(work);
|
|
47561
48116
|
if (recipe.processor === "VIDEO_GENERATE") completedVideos.add(work);
|
|
@@ -47603,7 +48158,7 @@ var init_provider_pending = __esm({
|
|
|
47603
48158
|
init_zod();
|
|
47604
48159
|
init_local_execution();
|
|
47605
48160
|
init_executions();
|
|
47606
|
-
|
|
48161
|
+
init_identity4();
|
|
47607
48162
|
init_error();
|
|
47608
48163
|
init_provider_submission();
|
|
47609
48164
|
init_qwen_keyframe();
|
|
@@ -47692,7 +48247,7 @@ var init_inventory = __esm({
|
|
|
47692
48247
|
init_version();
|
|
47693
48248
|
init_executions();
|
|
47694
48249
|
init_claim();
|
|
47695
|
-
|
|
48250
|
+
init_identity4();
|
|
47696
48251
|
init_requests();
|
|
47697
48252
|
init_error();
|
|
47698
48253
|
init_provider_pending();
|
|
@@ -47738,7 +48293,7 @@ var init_backup_dependencies = __esm({
|
|
|
47738
48293
|
});
|
|
47739
48294
|
|
|
47740
48295
|
// apps/local-runtime/src/journal/journal-evidence.ts
|
|
47741
|
-
import { createHash as
|
|
48296
|
+
import { createHash as createHash41 } from "node:crypto";
|
|
47742
48297
|
function inspectJournalEvidence(db, dependencies, expectedBytes) {
|
|
47743
48298
|
const scalar = (sql) => Number(Object.values(db.prepare(sql).get() ?? {})[0]);
|
|
47744
48299
|
const application = scalar("PRAGMA application_id"), version4 = scalar("PRAGMA user_version"), pageSize2 = scalar("PRAGMA page_size"), pageCount = scalar("PRAGMA page_count");
|
|
@@ -47778,7 +48333,7 @@ function inspectJournalEvidence(db, dependencies, expectedBytes) {
|
|
|
47778
48333
|
if (!Number.isSafeInteger(recordCount) || recordCount < 0 || recordCount > maxBackupRecords)
|
|
47779
48334
|
runtimeError("JOURNAL_BACKUP_LIMIT");
|
|
47780
48335
|
const counts = /* @__PURE__ */ new Map();
|
|
47781
|
-
const recordsHash =
|
|
48336
|
+
const recordsHash = createHash41("sha256");
|
|
47782
48337
|
for (const row of db.prepare("SELECT kind,id,revision,payload FROM records ORDER BY kind,id").iterate()) {
|
|
47783
48338
|
const kind = String(row.kind), id18 = String(row.id), revision3 = Number(row.revision), payload = String(row.payload);
|
|
47784
48339
|
if (!journalKinds.has(kind) || !id18 || id18.length > 256 || !Number.isSafeInteger(revision3) || revision3 < 1 || Buffer.byteLength(payload) > 18 * 1024 * 1024)
|
|
@@ -47818,7 +48373,7 @@ var init_journal_evidence = __esm({
|
|
|
47818
48373
|
"apps/local-runtime/src/journal/journal-evidence.ts"() {
|
|
47819
48374
|
"use strict";
|
|
47820
48375
|
init_error();
|
|
47821
|
-
|
|
48376
|
+
init_identity4();
|
|
47822
48377
|
init_backup_dependencies();
|
|
47823
48378
|
applicationId = 1314280268;
|
|
47824
48379
|
journalKinds = /* @__PURE__ */ new Set([
|
|
@@ -47853,26 +48408,26 @@ var init_journal_evidence = __esm({
|
|
|
47853
48408
|
});
|
|
47854
48409
|
|
|
47855
48410
|
// apps/local-runtime/src/journal/backup-inspection.ts
|
|
47856
|
-
import { createHash as
|
|
47857
|
-
import { lstat as lstat4, mkdtemp as
|
|
47858
|
-
import { basename, dirname as dirname3, join as
|
|
47859
|
-
import { tmpdir as
|
|
48411
|
+
import { createHash as createHash42 } from "node:crypto";
|
|
48412
|
+
import { lstat as lstat4, mkdtemp as mkdtemp25, open as open11, realpath as realpath10, rm as rm25 } from "node:fs/promises";
|
|
48413
|
+
import { basename, dirname as dirname3, join as join40, resolve as resolve3 } from "node:path";
|
|
48414
|
+
import { tmpdir as tmpdir25 } from "node:os";
|
|
47860
48415
|
import { DatabaseSync } from "node:sqlite";
|
|
47861
48416
|
async function inspectLocalJournalBackup(stateDirectory, rawPath, dependencies = false, visit2) {
|
|
47862
|
-
const root = await realpath10(stateDirectory), directory = await realpath10(
|
|
48417
|
+
const root = await realpath10(stateDirectory), directory = await realpath10(join40(root, "backups")), path = resolve3(rawPath), match = backupName.exec(basename(path));
|
|
47863
48418
|
if (root !== resolve3(stateDirectory) || dirname3(path) !== directory || !match || await realpath10(path) !== path)
|
|
47864
48419
|
runtimeError("JOURNAL_BACKUP_INVALID");
|
|
47865
48420
|
await privateAccess(directory, "directory");
|
|
47866
|
-
const inspectionDirectory = await
|
|
48421
|
+
const inspectionDirectory = await mkdtemp25(join40(tmpdir25(), "nvs-backup-inspect-"));
|
|
47867
48422
|
let source5, target2, db;
|
|
47868
48423
|
try {
|
|
47869
48424
|
source5 = await privateFile(path, false, false);
|
|
47870
48425
|
const before = await source5.stat({ bigint: true });
|
|
47871
48426
|
if (before.size < 4096n || before.size > 2n * 1024n * 1024n * 1024n || before.nlink !== 1n)
|
|
47872
48427
|
runtimeError("JOURNAL_BACKUP_INVALID");
|
|
47873
|
-
const inspectionPath =
|
|
48428
|
+
const inspectionPath = join40(inspectionDirectory, "snapshot.sqlite");
|
|
47874
48429
|
target2 = await open11(inspectionPath, "wx", 384);
|
|
47875
|
-
const hash10 =
|
|
48430
|
+
const hash10 = createHash42("sha256"), chunk = Buffer.allocUnsafe(1024 * 1024);
|
|
47876
48431
|
let offset2 = 0;
|
|
47877
48432
|
while (true) {
|
|
47878
48433
|
const { bytesRead } = await source5.read(chunk, 0, chunk.length, offset2);
|
|
@@ -47912,7 +48467,7 @@ async function inspectLocalJournalBackup(stateDirectory, rawPath, dependencies =
|
|
|
47912
48467
|
db?.close();
|
|
47913
48468
|
await target2?.close();
|
|
47914
48469
|
await source5?.close();
|
|
47915
|
-
await
|
|
48470
|
+
await rm25(inspectionDirectory, { recursive: true, force: true });
|
|
47916
48471
|
}
|
|
47917
48472
|
}
|
|
47918
48473
|
var backupName;
|
|
@@ -47929,7 +48484,7 @@ var init_backup_inspection = __esm({
|
|
|
47929
48484
|
});
|
|
47930
48485
|
|
|
47931
48486
|
// apps/local-runtime/src/preview/cpu-speech.ts
|
|
47932
|
-
import { join as
|
|
48487
|
+
import { join as join55 } from "node:path";
|
|
47933
48488
|
async function qualifyInstalledCpuSpeech(tools, root, outer) {
|
|
47934
48489
|
const deadline2 = AbortSignal.timeout(21e4);
|
|
47935
48490
|
try {
|
|
@@ -47949,7 +48504,7 @@ async function readInstalledCpuSpeech(tools, root, signal) {
|
|
|
47949
48504
|
modelDirectory: tools.modelDirectory
|
|
47950
48505
|
};
|
|
47951
48506
|
const identity5 = await inspectCpuSpeechIdentity(selection, signal), voiceIds = [...tools.voiceIds].sort((a, b) => a - b), key13 = fingerprint2({ probeVersion: 1, identity: identity5, voiceIds });
|
|
47952
|
-
const directory = await privateDirectory2(
|
|
48507
|
+
const directory = await privateDirectory2(join55(root, "cache")), path = join55(directory, "cpu-speech-" + key13 + ".json");
|
|
47953
48508
|
let qualification = CpuSpeechQualificationSchema.safeParse(
|
|
47954
48509
|
await readPrivate(path, 65536).then((b) => JSON.parse(b.toString())).catch(() => null)
|
|
47955
48510
|
);
|
|
@@ -47982,16 +48537,16 @@ var init_cpu_speech2 = __esm({
|
|
|
47982
48537
|
"use strict";
|
|
47983
48538
|
init_local_execution();
|
|
47984
48539
|
init_src3();
|
|
47985
|
-
|
|
48540
|
+
init_identity4();
|
|
47986
48541
|
init_private_state();
|
|
47987
48542
|
}
|
|
47988
48543
|
});
|
|
47989
48544
|
|
|
47990
48545
|
// apps/local-runtime/src/dependencies/download.ts
|
|
47991
|
-
import { createHash as
|
|
48546
|
+
import { createHash as createHash48, randomUUID as randomUUID14 } from "node:crypto";
|
|
47992
48547
|
import { constants as constants12 } from "node:fs";
|
|
47993
48548
|
import { open as open17, link as link3, unlink as unlink10, statfs as statfs4 } from "node:fs/promises";
|
|
47994
|
-
import { join as
|
|
48549
|
+
import { join as join60 } from "node:path";
|
|
47995
48550
|
async function publicResponse(address, signal) {
|
|
47996
48551
|
for (let redirects = 0; redirects <= 3; redirects++) {
|
|
47997
48552
|
const url2 = new URL(address);
|
|
@@ -48018,13 +48573,13 @@ async function publicResponse(address, signal) {
|
|
|
48018
48573
|
throw Error("CPU_RESOURCE_SOURCE_INVALID");
|
|
48019
48574
|
}
|
|
48020
48575
|
async function verifiedResource(root, resource, signal) {
|
|
48021
|
-
const directory = await privateDirectory2(
|
|
48576
|
+
const directory = await privateDirectory2(join60(root, "downloads")), path = join60(directory, resource.sha256 + ".archive");
|
|
48022
48577
|
async function valid() {
|
|
48023
48578
|
const file3 = await privateFile(path, false, false);
|
|
48024
48579
|
try {
|
|
48025
48580
|
const before = await file3.stat();
|
|
48026
48581
|
if (before.size !== resource.byteSize) throw Error("CPU_RESOURCE_INTEGRITY_INVALID");
|
|
48027
|
-
const hash10 =
|
|
48582
|
+
const hash10 = createHash48("sha256"), buffer = Buffer.alloc(1024 * 1024);
|
|
48028
48583
|
let offset2 = 0;
|
|
48029
48584
|
while (offset2 < before.size) {
|
|
48030
48585
|
signal.throwIfAborted();
|
|
@@ -48054,14 +48609,14 @@ async function verifiedResource(root, resource, signal) {
|
|
|
48054
48609
|
const disk = await statfs4(directory);
|
|
48055
48610
|
if (disk.bavail * disk.bsize < resource.byteSize + 384 * 1024 * 1024)
|
|
48056
48611
|
throw Error("CPU_RESOURCE_SPACE_REQUIRED");
|
|
48057
|
-
const temporary =
|
|
48612
|
+
const temporary = join60(directory, ".download-" + randomUUID14());
|
|
48058
48613
|
const file2 = await open17(
|
|
48059
48614
|
temporary,
|
|
48060
48615
|
constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | constants12.O_NOFOLLOW,
|
|
48061
48616
|
384
|
|
48062
48617
|
);
|
|
48063
48618
|
try {
|
|
48064
|
-
const response = await publicResponse(resource.url, signal), hash10 =
|
|
48619
|
+
const response = await publicResponse(resource.url, signal), hash10 = createHash48("sha256");
|
|
48065
48620
|
const length = response.headers.get("content-length");
|
|
48066
48621
|
if (length !== null && Number(length) !== resource.byteSize) {
|
|
48067
48622
|
await response.body.cancel();
|
|
@@ -48112,7 +48667,7 @@ var init_download = __esm({
|
|
|
48112
48667
|
// apps/local-runtime/src/dependencies/archive.ts
|
|
48113
48668
|
import { constants as constants13 } from "node:fs";
|
|
48114
48669
|
import { open as open18, realpath as realpath13 } from "node:fs/promises";
|
|
48115
|
-
import { join as
|
|
48670
|
+
import { join as join61, resolve as resolve5 } from "node:path";
|
|
48116
48671
|
async function privateDirectory3(path) {
|
|
48117
48672
|
await privateDirectory(path, true);
|
|
48118
48673
|
if (await realpath13(path) !== resolve5(path)) throw Error("CPU_ARCHIVE_PATH_INVALID");
|
|
@@ -48156,13 +48711,13 @@ async function extractCpuTar(data, prefix, root, signal) {
|
|
|
48156
48711
|
throw Error("CPU_ARCHIVE_INVALID");
|
|
48157
48712
|
if (type === "5") {
|
|
48158
48713
|
if (size) throw Error("CPU_ARCHIVE_INVALID");
|
|
48159
|
-
if (parts.length) await privateDirectory3(
|
|
48714
|
+
if (parts.length) await privateDirectory3(join61(root, ...parts));
|
|
48160
48715
|
} else {
|
|
48161
48716
|
if (type !== "0" && type !== "" || !parts.length || ++total > 512)
|
|
48162
48717
|
throw Error("CPU_ARCHIVE_MEMBER_REFUSED");
|
|
48163
|
-
const directory = await privateDirectory3(
|
|
48718
|
+
const directory = await privateDirectory3(join61(root, ...parts.slice(0, -1)));
|
|
48164
48719
|
const file2 = await open18(
|
|
48165
|
-
|
|
48720
|
+
join61(directory, parts.at(-1)),
|
|
48166
48721
|
constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL | constants13.O_NOFOLLOW,
|
|
48167
48722
|
384
|
|
48168
48723
|
);
|
|
@@ -48187,18 +48742,18 @@ var init_archive = __esm({
|
|
|
48187
48742
|
|
|
48188
48743
|
// apps/local-runtime/src/dependencies/cpu.ts
|
|
48189
48744
|
import { gunzipSync } from "node:zlib";
|
|
48190
|
-
import { lstat as lstat9, mkdtemp as
|
|
48191
|
-
import { join as
|
|
48745
|
+
import { lstat as lstat9, mkdtemp as mkdtemp26, rename as rename3, rm as rm27, realpath as realpath14 } from "node:fs/promises";
|
|
48746
|
+
import { join as join62 } from "node:path";
|
|
48192
48747
|
async function prepareCpuSpeechResources(root, signal, progress = () => {
|
|
48193
48748
|
}) {
|
|
48194
48749
|
const selected = cpuSpeechResources.engines.find(
|
|
48195
48750
|
(e) => e.platform === process.platform + "-" + process.arch
|
|
48196
48751
|
);
|
|
48197
48752
|
if (!selected) throw Error("CPU_SPEECH_PLATFORM_UNAVAILABLE");
|
|
48198
|
-
const resources = await privateDirectory2(
|
|
48753
|
+
const resources = await privateDirectory2(join62(root, "cpu-speech"));
|
|
48199
48754
|
progress("CHECKING");
|
|
48200
48755
|
async function prepared2(name2, expected, produce) {
|
|
48201
|
-
const parent = await privateDirectory2(
|
|
48756
|
+
const parent = await privateDirectory2(join62(resources, name2)), destination = join62(parent, expected);
|
|
48202
48757
|
try {
|
|
48203
48758
|
const stat12 = await lstat9(destination);
|
|
48204
48759
|
if (!stat12.isDirectory() || await speechTreeDigest(destination, signal) !== expected)
|
|
@@ -48207,7 +48762,7 @@ async function prepareCpuSpeechResources(root, signal, progress = () => {
|
|
|
48207
48762
|
} catch (error62) {
|
|
48208
48763
|
if (error62.code !== "ENOENT") throw error62;
|
|
48209
48764
|
}
|
|
48210
|
-
const temporary = await
|
|
48765
|
+
const temporary = await mkdtemp26(join62(parent, ".prepare-"));
|
|
48211
48766
|
try {
|
|
48212
48767
|
await produce(temporary);
|
|
48213
48768
|
signal.throwIfAborted();
|
|
@@ -48223,7 +48778,7 @@ async function prepareCpuSpeechResources(root, signal, progress = () => {
|
|
|
48223
48778
|
throw Error("CPU_RESOURCE_TREE_INVALID");
|
|
48224
48779
|
return { path: destination, reused: false };
|
|
48225
48780
|
} finally {
|
|
48226
|
-
await
|
|
48781
|
+
await rm27(temporary, { recursive: true, force: true });
|
|
48227
48782
|
}
|
|
48228
48783
|
}
|
|
48229
48784
|
return withProcessBudget({ cpuCores: 1, memoryBytes: 1536 * 1024 * 1024 }, async () => {
|
|
@@ -48236,7 +48791,7 @@ async function prepareCpuSpeechResources(root, signal, progress = () => {
|
|
|
48236
48791
|
const bytes = gunzipSync(await readPrivate(archive, entry.byteSize), {
|
|
48237
48792
|
maxOutputLength: 384 * 1024 * 1024
|
|
48238
48793
|
});
|
|
48239
|
-
await extractCpuTar(bytes, "package",
|
|
48794
|
+
await extractCpuTar(bytes, "package", join62(path, "node_modules", entry.name), signal);
|
|
48240
48795
|
}
|
|
48241
48796
|
});
|
|
48242
48797
|
const model3 = await prepared2("models", cpuSpeechResources.model.treeDigest, async (path) => {
|
|
@@ -48448,12 +49003,12 @@ __export(stopped_journal_exports, {
|
|
|
48448
49003
|
});
|
|
48449
49004
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
48450
49005
|
import { lstat as lstat10, realpath as realpath15 } from "node:fs/promises";
|
|
48451
|
-
import { join as
|
|
49006
|
+
import { join as join63, resolve as resolve7 } from "node:path";
|
|
48452
49007
|
async function withStoppedJournalEvidence(stateDirectory, work) {
|
|
48453
49008
|
const root = await realpath15(stateDirectory);
|
|
48454
49009
|
if (root !== resolve7(stateDirectory)) runtimeError("JOURNAL_OWNER_NOT_PROVEN");
|
|
48455
49010
|
await privateAccess(root, "directory");
|
|
48456
|
-
const path =
|
|
49011
|
+
const path = join63(root, "journal.sqlite");
|
|
48457
49012
|
if (await realpath15(path) !== path) runtimeError("JOURNAL_OWNER_NOT_PROVEN");
|
|
48458
49013
|
const file2 = await privateFile(path, false, false);
|
|
48459
49014
|
let db;
|
|
@@ -49319,9 +49874,9 @@ import { readFile as readFile19 } from "node:fs/promises";
|
|
|
49319
49874
|
async function verifyHyperframeInstallation(profile) {
|
|
49320
49875
|
const versions = { "@hyperframes/engine": "0.8.134", "@hyperframes/producer": "0.8.134", "gsap": "3.15.0", "yauzl": "3.4.0" };
|
|
49321
49876
|
if (profile.engine !== versions["@hyperframes/engine"] || profile.producer !== versions["@hyperframes/producer"] || profile.gsap !== versions.gsap) throw Error("DEPENDENCY_VERSION_MISMATCH");
|
|
49322
|
-
for (const [name2,
|
|
49877
|
+
for (const [name2, digest16] of Object.entries({ "capture.mjs": "a53af93e4b6a0c8d6287290f135c5c227ea182a2263ed749c77ec701abc7cb59", "hyperframe.manifest.json": "b18030afa0dde20c0c220bf3bcdf8f12614267ed3615eed19e09218ca62410dc", "hyperframe.runtime.iife.js": "767f9ae12880fb1cfb79c85be8f4b951040c712386e9c433d90fd63f4f1b2d1d", "hyperframe-gsap.js": "92bb9a96476f983d212a2bc4f54c889039c1696dd4461d40a736860938570fbb", "hyperframe-dependencies.json": "83a610a800b82c34d773a1dd38b22004a1a79d35efd32cd3dc21146598554b27", "hyperframe-notices.txt": "e6e31d2463e689b6fe1b33d89a3dbd971859cdf71f393eb192ee8203b5f77cbb" })) {
|
|
49323
49878
|
const bytes = await readFile19(new URL("./" + name2, import.meta.url));
|
|
49324
|
-
if (createHash32("sha256").update(bytes).digest("hex") !==
|
|
49879
|
+
if (createHash32("sha256").update(bytes).digest("hex") !== digest16)
|
|
49325
49880
|
throw Error("HYPERFRAME_RUNTIME_DIGEST_MISMATCH");
|
|
49326
49881
|
}
|
|
49327
49882
|
}
|
|
@@ -49357,8 +49912,8 @@ async function qualifyDeviceHyperframeTools(profile, tools, signal) {
|
|
|
49357
49912
|
const deadline2 = AbortSignal.any([signal, AbortSignal.timeout(45e3)]);
|
|
49358
49913
|
deadline2.throwIfAborted();
|
|
49359
49914
|
await verifyHyperframeInstallation(profile);
|
|
49360
|
-
async function inspect3(path,
|
|
49361
|
-
const verifiedPath = await binaryDigest(path,
|
|
49915
|
+
async function inspect3(path, digest16, flag, expected) {
|
|
49916
|
+
const verifiedPath = await binaryDigest(path, digest16, deadline2);
|
|
49362
49917
|
const result = await runControlledProcess(verifiedPath, [flag], {
|
|
49363
49918
|
signal: deadline2,
|
|
49364
49919
|
timeoutMs: 1e4,
|
|
@@ -49367,7 +49922,7 @@ async function qualifyDeviceHyperframeTools(profile, tools, signal) {
|
|
|
49367
49922
|
const version4 = result.toString("utf8").split("\n")[0].trim();
|
|
49368
49923
|
if (flag === "-version" && expected.startsWith("ffprobe ") ? version4.split(/\s+/).slice(0, 3).join(" ") !== expected : version4 !== expected)
|
|
49369
49924
|
throw Error("HYPERFRAME_TOOL_VERSION_MISMATCH");
|
|
49370
|
-
return { path: verifiedPath, version: version4, binaryDigest:
|
|
49925
|
+
return { path: verifiedPath, version: version4, binaryDigest: digest16 };
|
|
49371
49926
|
}
|
|
49372
49927
|
const qualify = async () => ({
|
|
49373
49928
|
node: process.version,
|
|
@@ -49660,7 +50215,7 @@ init_private_state();
|
|
|
49660
50215
|
init_src();
|
|
49661
50216
|
init_inventory();
|
|
49662
50217
|
init_version();
|
|
49663
|
-
|
|
50218
|
+
init_identity4();
|
|
49664
50219
|
init_local_execution();
|
|
49665
50220
|
init_private_state();
|
|
49666
50221
|
|
|
@@ -49668,14 +50223,14 @@ init_private_state();
|
|
|
49668
50223
|
init_local_execution();
|
|
49669
50224
|
init_private_state();
|
|
49670
50225
|
init_backup_inspection();
|
|
49671
|
-
|
|
50226
|
+
init_identity4();
|
|
49672
50227
|
init_error();
|
|
49673
50228
|
import { DatabaseSync as DatabaseSync2, backup } from "node:sqlite";
|
|
49674
|
-
import { join as
|
|
50229
|
+
import { join as join41 } from "node:path";
|
|
49675
50230
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
49676
50231
|
|
|
49677
50232
|
// apps/local-runtime/src/journal/task-query.ts
|
|
49678
|
-
|
|
50233
|
+
init_identity4();
|
|
49679
50234
|
init_error();
|
|
49680
50235
|
function registerTaskKey(db) {
|
|
49681
50236
|
db.function("native_task_key", { deterministic: true }, (tenant2, project2, production2, job) => {
|
|
@@ -49739,7 +50294,7 @@ var LocalJournal = class _LocalJournal {
|
|
|
49739
50294
|
static async open(root) {
|
|
49740
50295
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
49741
50296
|
if (major !== 24 || minor < 12) runtimeError("NODE_VERSION_UNSUPPORTED");
|
|
49742
|
-
const path =
|
|
50297
|
+
const path = join41(root, "journal.sqlite");
|
|
49743
50298
|
await (await privateFile(path, true)).close();
|
|
49744
50299
|
for (const suffix of ["-wal", "-shm", "-journal"]) {
|
|
49745
50300
|
try {
|
|
@@ -49954,7 +50509,7 @@ var LocalJournal = class _LocalJournal {
|
|
|
49954
50509
|
return inspectLocalJournalBackup(stateDirectory, rawPath, dependencies);
|
|
49955
50510
|
}
|
|
49956
50511
|
async backup() {
|
|
49957
|
-
const path =
|
|
50512
|
+
const path = join41(this.root, "backups", randomUUID4() + ".sqlite");
|
|
49958
50513
|
await (await privateFile(path, true)).close();
|
|
49959
50514
|
await backup(this.db, path);
|
|
49960
50515
|
await (await privateFile(path)).close();
|
|
@@ -49971,7 +50526,7 @@ init_requests();
|
|
|
49971
50526
|
|
|
49972
50527
|
// apps/local-runtime/src/authority.ts
|
|
49973
50528
|
init_local_execution();
|
|
49974
|
-
|
|
50529
|
+
init_identity4();
|
|
49975
50530
|
init_executions();
|
|
49976
50531
|
init_error();
|
|
49977
50532
|
var LOCAL_AUTHORITY_BUDGET_MS = 2e4;
|
|
@@ -50100,24 +50655,24 @@ var RuntimeAuthority = class {
|
|
|
50100
50655
|
init_src();
|
|
50101
50656
|
init_zod();
|
|
50102
50657
|
init_local_execution();
|
|
50103
|
-
|
|
50658
|
+
init_identity4();
|
|
50104
50659
|
init_private_state();
|
|
50105
50660
|
init_error();
|
|
50106
50661
|
init_executions();
|
|
50107
|
-
import { join as
|
|
50662
|
+
import { join as join43 } from "node:path";
|
|
50108
50663
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
50109
50664
|
import { open as open12, unlink as unlink3 } from "node:fs/promises";
|
|
50110
50665
|
|
|
50111
50666
|
// apps/local-runtime/src/workspace/files.ts
|
|
50112
50667
|
init_error();
|
|
50113
50668
|
import { opendir as opendir3, lstat as lstat5 } from "node:fs/promises";
|
|
50114
|
-
import { join as
|
|
50669
|
+
import { join as join42 } from "node:path";
|
|
50115
50670
|
async function directoryFileSizes(root, child) {
|
|
50116
50671
|
const sizes = /* @__PURE__ */ new Map();
|
|
50117
|
-
const directory = await opendir3(
|
|
50672
|
+
const directory = await opendir3(join42(root, child));
|
|
50118
50673
|
for await (const entry of directory) {
|
|
50119
50674
|
if (sizes.size >= 5e4) runtimeError("QUERY_LIMIT");
|
|
50120
|
-
const info = await lstat5(
|
|
50675
|
+
const info = await lstat5(join42(root, child, entry.name));
|
|
50121
50676
|
if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1)
|
|
50122
50677
|
runtimeError("STATE_PERMISSIONS");
|
|
50123
50678
|
sizes.set(entry.name, info.size);
|
|
@@ -50140,7 +50695,7 @@ async function retainedDirectoryBytes(root, children) {
|
|
|
50140
50695
|
}
|
|
50141
50696
|
for await (const entry of directory) {
|
|
50142
50697
|
if (++count3 > 5e4) runtimeError("QUERY_LIMIT");
|
|
50143
|
-
const file2 =
|
|
50698
|
+
const file2 = join42(path, entry.name), info = await lstat5(file2);
|
|
50144
50699
|
if (info.isSymbolicLink() || process.platform !== "win32" && (info.uid !== process.getuid?.() || info.mode & 63))
|
|
50145
50700
|
runtimeError("STATE_PERMISSIONS");
|
|
50146
50701
|
if (info.isDirectory()) await visit2(file2, depth2 + 1);
|
|
@@ -50148,7 +50703,7 @@ async function retainedDirectoryBytes(root, children) {
|
|
|
50148
50703
|
else runtimeError("STATE_PERMISSIONS");
|
|
50149
50704
|
}
|
|
50150
50705
|
}
|
|
50151
|
-
for (const child of children) await visit2(
|
|
50706
|
+
for (const child of children) await visit2(join42(root, child), 0);
|
|
50152
50707
|
return bytes;
|
|
50153
50708
|
}
|
|
50154
50709
|
|
|
@@ -50237,7 +50792,7 @@ var RuntimeCache = class {
|
|
|
50237
50792
|
if (!files.has(data.digest) && used + data.byteSize > this.quota())
|
|
50238
50793
|
runtimeError("CACHE_QUOTA_EXCEEDED");
|
|
50239
50794
|
}
|
|
50240
|
-
const path =
|
|
50795
|
+
const path = join43(this.db.root, "cache", data.digest);
|
|
50241
50796
|
let exists = false;
|
|
50242
50797
|
try {
|
|
50243
50798
|
const existing = await inspectPrivateDigest(path, data.byteSize);
|
|
@@ -50248,7 +50803,7 @@ var RuntimeCache = class {
|
|
|
50248
50803
|
if (e.code !== "ENOENT") throw e;
|
|
50249
50804
|
}
|
|
50250
50805
|
if (!exists) {
|
|
50251
|
-
const temp =
|
|
50806
|
+
const temp = join43(this.db.root, "cache", randomUUID5() + ".tmp");
|
|
50252
50807
|
const f = await open12(temp, "wx", 384);
|
|
50253
50808
|
try {
|
|
50254
50809
|
try {
|
|
@@ -50280,7 +50835,7 @@ var RuntimeCache = class {
|
|
|
50280
50835
|
await this.authority.binding(binding);
|
|
50281
50836
|
const row = this.db.get("CACHE", this.key(binding, hash10));
|
|
50282
50837
|
if (!row) runtimeError("CACHE_NOT_FOUND");
|
|
50283
|
-
const entry = CacheEntrySchema.parse(row.payload), bytes = await readPrivate(
|
|
50838
|
+
const entry = CacheEntrySchema.parse(row.payload), bytes = await readPrivate(join43(this.db.root, "cache", hash10), entry.byteSize);
|
|
50284
50839
|
if (bytes.byteLength !== entry.byteSize || digest13(bytes) !== hash10)
|
|
50285
50840
|
runtimeError("CACHE_CORRUPT");
|
|
50286
50841
|
await this.authority.binding(binding);
|
|
@@ -50323,7 +50878,7 @@ var RuntimeCache = class {
|
|
|
50323
50878
|
const e = CacheEntrySchema.parse(row.payload);
|
|
50324
50879
|
if (e.pinned || running.has(fingerprint2(e.binding))) continue;
|
|
50325
50880
|
if (!pinned.has(e.digest)) {
|
|
50326
|
-
const path =
|
|
50881
|
+
const path = join43(this.db.root, "cache", e.digest);
|
|
50327
50882
|
try {
|
|
50328
50883
|
await (await privateFile(path, false, false)).close();
|
|
50329
50884
|
await unlink3(path);
|
|
@@ -50359,10 +50914,10 @@ var RuntimeCache = class {
|
|
|
50359
50914
|
// apps/local-runtime/src/transfers.ts
|
|
50360
50915
|
init_zod();
|
|
50361
50916
|
init_local_execution();
|
|
50362
|
-
|
|
50917
|
+
init_identity4();
|
|
50363
50918
|
init_private_state();
|
|
50364
50919
|
init_error();
|
|
50365
|
-
import { join as
|
|
50920
|
+
import { join as join44 } from "node:path";
|
|
50366
50921
|
import { unlink as unlink4 } from "node:fs/promises";
|
|
50367
50922
|
var schema = external_exports.strictObject({
|
|
50368
50923
|
transferId: LocalIdSchema,
|
|
@@ -50416,7 +50971,7 @@ var TransferJournal = class {
|
|
|
50416
50971
|
try {
|
|
50417
50972
|
const current = this.db.get("TRANSFER", row.id);
|
|
50418
50973
|
if (!current || current.revision !== row.revision) runtimeError("REVISION_CONFLICT");
|
|
50419
|
-
const path =
|
|
50974
|
+
const path = join44(this.db.root, "staging", entry.transferId + ".part");
|
|
50420
50975
|
try {
|
|
50421
50976
|
const actual = await inspectPrivateDigest(path, entry.byteSize);
|
|
50422
50977
|
if (actual.byteSize !== entry.byteSize || actual.sha256 !== entry.digest)
|
|
@@ -50456,7 +51011,7 @@ var TransferJournal = class {
|
|
|
50456
51011
|
const e = schema.parse(row.payload);
|
|
50457
51012
|
if (fingerprint2(e.binding) !== fingerprint2(binding) || e.phase === "VERIFIED" || bytes.byteLength < 1 || bytes.byteLength > 1024 * 1024 || e.completedBytes + bytes.byteLength > e.byteSize)
|
|
50458
51013
|
runtimeError("TRANSFER_INVALID");
|
|
50459
|
-
const f = await privateFile(
|
|
51014
|
+
const f = await privateFile(join44(this.db.root, "staging", transferId + ".part"), true);
|
|
50460
51015
|
try {
|
|
50461
51016
|
if ((await f.stat()).size < e.completedBytes) runtimeError("TRANSFER_CORRUPT");
|
|
50462
51017
|
await f.truncate(e.completedBytes);
|
|
@@ -50498,7 +51053,7 @@ var TransferJournal = class {
|
|
|
50498
51053
|
runtimeError("TRANSFER_INCOMPLETE");
|
|
50499
51054
|
if (e.phase === "VERIFIED") return row.revision;
|
|
50500
51055
|
const bytes = await readPrivate(
|
|
50501
|
-
|
|
51056
|
+
join44(this.db.root, "staging", transferId + ".part"),
|
|
50502
51057
|
e.byteSize
|
|
50503
51058
|
);
|
|
50504
51059
|
if (digest13(bytes) !== e.digest) runtimeError("BYTES_INVALID");
|
|
@@ -50521,7 +51076,7 @@ var TransferJournal = class {
|
|
|
50521
51076
|
// apps/local-runtime/src/sessions.ts
|
|
50522
51077
|
init_zod();
|
|
50523
51078
|
init_local_execution();
|
|
50524
|
-
|
|
51079
|
+
init_identity4();
|
|
50525
51080
|
init_error();
|
|
50526
51081
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
50527
51082
|
var sessionSchema = external_exports.strictObject({
|
|
@@ -50570,23 +51125,23 @@ init_error();
|
|
|
50570
51125
|
|
|
50571
51126
|
// apps/local-runtime/src/review/manager.ts
|
|
50572
51127
|
init_local_execution();
|
|
50573
|
-
|
|
51128
|
+
init_identity4();
|
|
50574
51129
|
init_error();
|
|
50575
51130
|
init_private_state();
|
|
50576
51131
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
50577
|
-
import { join as
|
|
51132
|
+
import { join as join49 } from "node:path";
|
|
50578
51133
|
|
|
50579
51134
|
// apps/local-runtime/src/review/codex.ts
|
|
50580
51135
|
init_src();
|
|
50581
51136
|
init_private_state();
|
|
50582
51137
|
import { constants as constants9 } from "node:fs";
|
|
50583
|
-
import { open as open13, writeFile as
|
|
50584
|
-
import { createHash as
|
|
50585
|
-
import { join as
|
|
51138
|
+
import { open as open13, writeFile as writeFile29 } from "node:fs/promises";
|
|
51139
|
+
import { createHash as createHash44 } from "node:crypto";
|
|
51140
|
+
import { join as join45 } from "node:path";
|
|
50586
51141
|
|
|
50587
51142
|
// apps/local-runtime/src/review/png.ts
|
|
50588
51143
|
init_error();
|
|
50589
|
-
import { createHash as
|
|
51144
|
+
import { createHash as createHash43 } from "node:crypto";
|
|
50590
51145
|
import { inflateSync } from "node:zlib";
|
|
50591
51146
|
function crc324(b) {
|
|
50592
51147
|
let crc = 4294967295;
|
|
@@ -50598,7 +51153,7 @@ function crc324(b) {
|
|
|
50598
51153
|
}
|
|
50599
51154
|
function verifyAgentPng(bytes, s) {
|
|
50600
51155
|
const expected = s.image;
|
|
50601
|
-
if (!expected || bytes.length !== expected.byteSize || bytes.length > 8388608 ||
|
|
51156
|
+
if (!expected || bytes.length !== expected.byteSize || bytes.length > 8388608 || createHash43("sha256").update(bytes).digest("hex") !== s.media.checksumSha256 || bytes.subarray(0, 8).toString("hex") !== "89504e470d0a1a0a")
|
|
50602
51157
|
runtimeError("AGENT_IMAGE_INVALID");
|
|
50603
51158
|
let offset2 = 8, header = false, end = false, channels = 0, chunks = 0, dataEnded = false;
|
|
50604
51159
|
const data = [];
|
|
@@ -50740,14 +51295,14 @@ async function inspectAgentCommand(binary, args, environment, signal = new Abort
|
|
|
50740
51295
|
init_src3();
|
|
50741
51296
|
init_local_execution();
|
|
50742
51297
|
async function verifyAttachment(snapshot2, cwd) {
|
|
50743
|
-
if (snapshot2.image) verifyAgentPng(await readPrivate(
|
|
51298
|
+
if (snapshot2.image) verifyAgentPng(await readPrivate(join45(cwd, "input.png"), 8388608), snapshot2);
|
|
50744
51299
|
if (!snapshot2.evidence) return;
|
|
50745
51300
|
const receipt2 = LocalAgentEvidenceReceiptSchema.parse(
|
|
50746
|
-
JSON.parse((await readPrivate(
|
|
51301
|
+
JSON.parse((await readPrivate(join45(cwd, "evidence.json"), 16384)).toString())
|
|
50747
51302
|
);
|
|
50748
51303
|
if (JSON.stringify(receipt2.media) !== JSON.stringify(snapshot2.media))
|
|
50749
51304
|
throw Error("AGENT_IMAGE_INVALID");
|
|
50750
|
-
verifyAgentPng(await readPrivate(
|
|
51305
|
+
verifyAgentPng(await readPrivate(join45(cwd, "input.png"), 8388608), {
|
|
50751
51306
|
...snapshot2,
|
|
50752
51307
|
image: { ...receipt2.attachment, contentType: "image/png" },
|
|
50753
51308
|
media: { ...snapshot2.media, checksumSha256: receipt2.attachment.checksumSha256 }
|
|
@@ -50764,7 +51319,7 @@ async function verifyAgentBinary(grant, signal) {
|
|
|
50764
51319
|
throw Error("AGENT_BINARY_CHANGED");
|
|
50765
51320
|
const header = Buffer.alloc(4);
|
|
50766
51321
|
await f.read(header, 0, 4, 0);
|
|
50767
|
-
const hash10 =
|
|
51322
|
+
const hash10 = createHash44("sha256");
|
|
50768
51323
|
for await (const part of f.createReadStream({
|
|
50769
51324
|
start: 0,
|
|
50770
51325
|
end: stat12.size - 1,
|
|
@@ -50859,13 +51414,13 @@ var codexAgent = {
|
|
|
50859
51414
|
},
|
|
50860
51415
|
async run(g, snapshot2, cwd, signal) {
|
|
50861
51416
|
await verifyAgentBinary(g);
|
|
50862
|
-
const schema2 =
|
|
51417
|
+
const schema2 = join45(cwd, "answer-schema.json");
|
|
50863
51418
|
if (snapshot2.image && !g.imageDisclosureApproved || snapshot2.evidence && !g.mediaDisclosureApproved)
|
|
50864
51419
|
throw Error("AGENT_IMAGE_AUTHORIZATION_REQUIRED");
|
|
50865
51420
|
const evidence2 = await verifyAttachment(snapshot2, cwd);
|
|
50866
|
-
await
|
|
51421
|
+
await writeFile29(join45(cwd, ".nvs-agent-root"), "", { flag: "wx", mode: 384 });
|
|
50867
51422
|
const { z: z2 } = await Promise.resolve().then(() => (init_zod(), zod_exports));
|
|
50868
|
-
await
|
|
51423
|
+
await writeFile29(schema2, JSON.stringify(z2.toJSONSchema(codexAnswerSchema(snapshot2))), {
|
|
50869
51424
|
flag: "wx",
|
|
50870
51425
|
mode: 384
|
|
50871
51426
|
});
|
|
@@ -50878,7 +51433,7 @@ var codexAgent = {
|
|
|
50878
51433
|
"read-only",
|
|
50879
51434
|
"--model",
|
|
50880
51435
|
g.model,
|
|
50881
|
-
...snapshot2.image || snapshot2.evidence ? ["--image",
|
|
51436
|
+
...snapshot2.image || snapshot2.evidence ? ["--image", join45(cwd, "input.png")] : [],
|
|
50882
51437
|
"--json",
|
|
50883
51438
|
"--output-schema",
|
|
50884
51439
|
schema2,
|
|
@@ -50899,7 +51454,7 @@ var codexAgent = {
|
|
|
50899
51454
|
environment: safeEnvironment()
|
|
50900
51455
|
});
|
|
50901
51456
|
const decoded = decodeCodexOutput(bytes);
|
|
50902
|
-
await
|
|
51457
|
+
await writeFile29(join45(cwd, "invocation-events.json"), JSON.stringify(decoded.diagnostics), {
|
|
50903
51458
|
flag: "wx",
|
|
50904
51459
|
mode: 384
|
|
50905
51460
|
});
|
|
@@ -50916,17 +51471,17 @@ init_local_execution();
|
|
|
50916
51471
|
init_private_state();
|
|
50917
51472
|
init_error();
|
|
50918
51473
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
50919
|
-
import { join as
|
|
50920
|
-
import { open as open14, link as link2, unlink as unlink5, writeFile as
|
|
51474
|
+
import { join as join47 } from "node:path";
|
|
51475
|
+
import { open as open14, link as link2, unlink as unlink5, writeFile as writeFile30 } from "node:fs/promises";
|
|
50921
51476
|
|
|
50922
51477
|
// apps/local-runtime/src/review/image-budget.ts
|
|
50923
51478
|
init_src();
|
|
50924
51479
|
init_error();
|
|
50925
51480
|
import { lstat as lstat6, opendir as opendir4 } from "node:fs/promises";
|
|
50926
|
-
import { join as
|
|
51481
|
+
import { join as join46 } from "node:path";
|
|
50927
51482
|
var AgentImageBudget = class {
|
|
50928
|
-
constructor(
|
|
50929
|
-
this.maximum =
|
|
51483
|
+
constructor(maximum4 = { bytes: 64 * 1024 * 1024, files: 64 }) {
|
|
51484
|
+
this.maximum = maximum4;
|
|
50930
51485
|
}
|
|
50931
51486
|
maximum;
|
|
50932
51487
|
pendingBytes = 0;
|
|
@@ -50944,13 +51499,13 @@ var AgentImageBudget = class {
|
|
|
50944
51499
|
const dir = await opendir4(directory);
|
|
50945
51500
|
for await (const entry of dir) {
|
|
50946
51501
|
if (++count3 > this.maximum.files) runtimeError("AGENT_IMAGE_BUDGET_EXCEEDED");
|
|
50947
|
-
const s = await lstat6(
|
|
51502
|
+
const s = await lstat6(join46(directory, entry.name)).catch((e) => {
|
|
50948
51503
|
if (e.code === "ENOENT") return null;
|
|
50949
51504
|
throw e;
|
|
50950
51505
|
});
|
|
50951
51506
|
if (!s) continue;
|
|
50952
51507
|
try {
|
|
50953
|
-
await privateAccess(
|
|
51508
|
+
await privateAccess(join46(directory, entry.name), "file");
|
|
50954
51509
|
} catch {
|
|
50955
51510
|
runtimeError("STATE_PERMISSIONS");
|
|
50956
51511
|
}
|
|
@@ -50985,13 +51540,13 @@ var AgentImages = class {
|
|
|
50985
51540
|
root;
|
|
50986
51541
|
budget;
|
|
50987
51542
|
path(id18) {
|
|
50988
|
-
return
|
|
51543
|
+
return join47(this.root, "agent-images", id18 + ".png");
|
|
50989
51544
|
}
|
|
50990
51545
|
async stage(v, stream, authorize) {
|
|
50991
51546
|
const s = v.plan.snapshot;
|
|
50992
51547
|
if (!s.image || v.phase !== "PREPARED") runtimeError("AGENT_IMAGE_REQUIRED");
|
|
50993
51548
|
await authorize();
|
|
50994
|
-
const dir = await privateDirectory2(
|
|
51549
|
+
const dir = await privateDirectory2(join47(this.root, "agent-images")), temporary = join47(dir, ".part-" + randomUUID6());
|
|
50995
51550
|
let existing = false;
|
|
50996
51551
|
try {
|
|
50997
51552
|
verifyAgentPng(await readPrivate(this.path(v.plan.id), s.image.byteSize), s);
|
|
@@ -51073,7 +51628,7 @@ var AgentImages = class {
|
|
|
51073
51628
|
runtimeError("AGENT_IMAGE_REQUIRED");
|
|
51074
51629
|
const bytes = await readPrivate(this.path(v.plan.id), s.image.byteSize);
|
|
51075
51630
|
verifyAgentPng(bytes, s);
|
|
51076
|
-
await
|
|
51631
|
+
await writeFile30(join47(cwd, "input.png"), bytes, { flag: "wx", mode: 256 });
|
|
51077
51632
|
}
|
|
51078
51633
|
};
|
|
51079
51634
|
|
|
@@ -51131,7 +51686,7 @@ var AgentReviewAuthority = class {
|
|
|
51131
51686
|
};
|
|
51132
51687
|
|
|
51133
51688
|
// apps/local-runtime/src/review/probes.ts
|
|
51134
|
-
|
|
51689
|
+
init_identity4();
|
|
51135
51690
|
init_error();
|
|
51136
51691
|
var AgentProbes = class {
|
|
51137
51692
|
constructor(port) {
|
|
@@ -51174,9 +51729,9 @@ init_src3();
|
|
|
51174
51729
|
init_local_execution();
|
|
51175
51730
|
init_private_state();
|
|
51176
51731
|
init_error();
|
|
51177
|
-
import { createHash as
|
|
51178
|
-
import { join as
|
|
51179
|
-
import { open as open15, writeFile as
|
|
51732
|
+
import { createHash as createHash45, randomUUID as randomUUID8 } from "node:crypto";
|
|
51733
|
+
import { join as join48 } from "node:path";
|
|
51734
|
+
import { open as open15, writeFile as writeFile31, rm as rm26, copyFile } from "node:fs/promises";
|
|
51180
51735
|
import { constants as constants10 } from "node:fs";
|
|
51181
51736
|
var AgentMedia = class {
|
|
51182
51737
|
constructor(root, tools) {
|
|
@@ -51188,7 +51743,7 @@ var AgentMedia = class {
|
|
|
51188
51743
|
budget = new AgentImageBudget({ bytes: 512 * 1024 * 1024, files: 64 });
|
|
51189
51744
|
pending = /* @__PURE__ */ new Set();
|
|
51190
51745
|
file(id18, ext) {
|
|
51191
|
-
return
|
|
51746
|
+
return join48(this.root, "agent-evidence", id18 + ext);
|
|
51192
51747
|
}
|
|
51193
51748
|
async attachment(v, receipt2) {
|
|
51194
51749
|
const bytes = await readPrivate(this.file(v.plan.id, ".png"), 8388608);
|
|
@@ -51204,8 +51759,8 @@ var AgentMedia = class {
|
|
|
51204
51759
|
if (!input3 || !this.tools || v.phase !== "PREPARED") runtimeError("AGENT_IMAGE_REQUIRED");
|
|
51205
51760
|
if (this.pending.has(v.plan.id)) runtimeError("BUSY");
|
|
51206
51761
|
this.pending.add(v.plan.id);
|
|
51207
|
-
const dir =
|
|
51208
|
-
const temporary =
|
|
51762
|
+
const dir = join48(this.root, "agent-evidence");
|
|
51763
|
+
const temporary = join48(dir, ".part-" + randomUUID8()), record6 = join48(dir, ".receipt-" + randomUUID8());
|
|
51209
51764
|
let release = () => {
|
|
51210
51765
|
}, work;
|
|
51211
51766
|
try {
|
|
@@ -51222,7 +51777,7 @@ var AgentMedia = class {
|
|
|
51222
51777
|
if (existing) {
|
|
51223
51778
|
if (existing.draftId !== v.plan.id || canonicalLocalJson(existing.media) !== canonicalLocalJson(v.plan.snapshot.media))
|
|
51224
51779
|
runtimeError("AGENT_IMAGE_INVALID");
|
|
51225
|
-
const hash11 =
|
|
51780
|
+
const hash11 = createHash45("sha256");
|
|
51226
51781
|
let size2 = 0;
|
|
51227
51782
|
for await (const bytes of stream) {
|
|
51228
51783
|
size2 += bytes.length;
|
|
@@ -51236,7 +51791,7 @@ var AgentMedia = class {
|
|
|
51236
51791
|
return existing;
|
|
51237
51792
|
}
|
|
51238
51793
|
release = await this.budget.reserve(dir, input3.byteSize + 8388608);
|
|
51239
|
-
const f = await open15(temporary, "wx", 384), hash10 =
|
|
51794
|
+
const f = await open15(temporary, "wx", 384), hash10 = createHash45("sha256");
|
|
51240
51795
|
let size = 0;
|
|
51241
51796
|
try {
|
|
51242
51797
|
for await (const chunk of stream) {
|
|
@@ -51254,7 +51809,7 @@ var AgentMedia = class {
|
|
|
51254
51809
|
await authorize();
|
|
51255
51810
|
const tools = await this.tools();
|
|
51256
51811
|
await authorize();
|
|
51257
|
-
work = await privateDirectory2(
|
|
51812
|
+
work = await privateDirectory2(join48(this.root, "agent-derivation", randomUUID8()));
|
|
51258
51813
|
const derived2 = await deriveAgentEvidence(
|
|
51259
51814
|
temporary,
|
|
51260
51815
|
work,
|
|
@@ -51286,20 +51841,20 @@ var AgentMedia = class {
|
|
|
51286
51841
|
});
|
|
51287
51842
|
const image = this.file(v.plan.id, ".png");
|
|
51288
51843
|
try {
|
|
51289
|
-
await
|
|
51844
|
+
await writeFile31(image, derived2.bytes, { mode: 384, flag: "wx" });
|
|
51290
51845
|
} catch (e) {
|
|
51291
51846
|
if (e.code !== "EEXIST") throw e;
|
|
51292
51847
|
await this.attachment(v, receipt2);
|
|
51293
51848
|
}
|
|
51294
|
-
await
|
|
51849
|
+
await writeFile31(record6, JSON.stringify(receipt2), { mode: 384, flag: "wx" });
|
|
51295
51850
|
await authorize();
|
|
51296
51851
|
await atomicMove(record6, this.file(v.plan.id, ".json"), true);
|
|
51297
51852
|
await syncDirectory(dir);
|
|
51298
51853
|
return receipt2;
|
|
51299
51854
|
} finally {
|
|
51300
|
-
await
|
|
51301
|
-
await
|
|
51302
|
-
if (work) await
|
|
51855
|
+
await rm26(temporary, { force: true });
|
|
51856
|
+
await rm26(record6, { force: true });
|
|
51857
|
+
if (work) await rm26(work, { recursive: true, force: true });
|
|
51303
51858
|
release();
|
|
51304
51859
|
this.pending.delete(v.plan.id);
|
|
51305
51860
|
}
|
|
@@ -51307,8 +51862,8 @@ var AgentMedia = class {
|
|
|
51307
51862
|
async attach(v, cwd) {
|
|
51308
51863
|
if (!v.evidenceReceipt) runtimeError("AGENT_IMAGE_REQUIRED");
|
|
51309
51864
|
await this.attachment(v, v.evidenceReceipt);
|
|
51310
|
-
await copyFile(this.file(v.plan.id, ".png"),
|
|
51311
|
-
await
|
|
51865
|
+
await copyFile(this.file(v.plan.id, ".png"), join48(cwd, "input.png"), constants10.COPYFILE_EXCL);
|
|
51866
|
+
await writeFile31(join48(cwd, "evidence.json"), JSON.stringify(v.evidenceReceipt), {
|
|
51312
51867
|
mode: 384,
|
|
51313
51868
|
flag: "wx"
|
|
51314
51869
|
});
|
|
@@ -51567,7 +52122,7 @@ var LocalAgentReviews = class {
|
|
|
51567
52122
|
await this.permitted(g, v.plan.snapshot.basis.scope, authority);
|
|
51568
52123
|
if (this.busy || !this.idle()) runtimeError("BUSY");
|
|
51569
52124
|
if (Date.parse(v.plan.expiresAt) <= Date.now()) runtimeError("AGENT_GRANT_REQUIRED");
|
|
51570
|
-
const cwd = await privateDirectory2(
|
|
52125
|
+
const cwd = await privateDirectory2(join49(this.journal.root, "agent-reviews", id18));
|
|
51571
52126
|
await this.permitted(g, v.plan.snapshot.basis.scope, authority);
|
|
51572
52127
|
if (this.busy || !this.idle()) runtimeError("BUSY");
|
|
51573
52128
|
if (Date.parse(v.plan.expiresAt) <= Date.now()) runtimeError("AGENT_GRANT_REQUIRED");
|
|
@@ -51721,13 +52276,13 @@ var RuntimeScheduler = class {
|
|
|
51721
52276
|
// apps/local-runtime/src/workspace/storage.ts
|
|
51722
52277
|
init_local_execution();
|
|
51723
52278
|
import { stat as stat11, statfs } from "node:fs/promises";
|
|
51724
|
-
import { join as
|
|
52279
|
+
import { join as join50 } from "node:path";
|
|
51725
52280
|
|
|
51726
52281
|
// apps/local-runtime/src/workspace/tasks.ts
|
|
51727
52282
|
init_local_execution();
|
|
51728
52283
|
init_zod();
|
|
51729
52284
|
init_error();
|
|
51730
|
-
|
|
52285
|
+
init_identity4();
|
|
51731
52286
|
init_executions();
|
|
51732
52287
|
var TaskFailureSchema = external_exports.strictObject({
|
|
51733
52288
|
binding: LocalLeaseBindingSchema,
|
|
@@ -51804,7 +52359,7 @@ function taskInspection(db, row) {
|
|
|
51804
52359
|
|
|
51805
52360
|
// apps/local-runtime/src/workspace/storage.ts
|
|
51806
52361
|
init_version();
|
|
51807
|
-
|
|
52362
|
+
init_identity4();
|
|
51808
52363
|
var RuntimeStorage = class {
|
|
51809
52364
|
constructor(db, cache, scheduler) {
|
|
51810
52365
|
this.db = db;
|
|
@@ -51826,7 +52381,7 @@ var RuntimeStorage = class {
|
|
|
51826
52381
|
let journalBytes = 0;
|
|
51827
52382
|
for (const name2 of ["journal.sqlite", "journal.sqlite-wal", "journal.sqlite-shm"]) {
|
|
51828
52383
|
try {
|
|
51829
|
-
journalBytes += (await stat11(
|
|
52384
|
+
journalBytes += (await stat11(join50(this.db.root, name2))).size;
|
|
51830
52385
|
} catch (e) {
|
|
51831
52386
|
if (e.code !== "ENOENT") throw e;
|
|
51832
52387
|
}
|
|
@@ -51909,7 +52464,7 @@ var RuntimeStorage = class {
|
|
|
51909
52464
|
init_zod();
|
|
51910
52465
|
init_local_execution();
|
|
51911
52466
|
init_executions();
|
|
51912
|
-
|
|
52467
|
+
init_identity4();
|
|
51913
52468
|
init_error();
|
|
51914
52469
|
var stored = external_exports.object({
|
|
51915
52470
|
assignment: TenantProcessorAssignmentSchema,
|
|
@@ -51944,7 +52499,10 @@ function terminalProviderOutcome(assignment, outcome) {
|
|
|
51944
52499
|
"KEYFRAME_GENERATE",
|
|
51945
52500
|
"VIDEO_GENERATE",
|
|
51946
52501
|
"TRANSCRIBE_EXTERNAL_QWEN",
|
|
51947
|
-
"SPEECH_EXTERNAL_QWEN"
|
|
52502
|
+
"SPEECH_EXTERNAL_QWEN",
|
|
52503
|
+
// OpenAI 的确认拒绝也能归档;未知发送状态仍由清单保护。
|
|
52504
|
+
"TRANSCRIBE_EXTERNAL_OPENAI",
|
|
52505
|
+
"SPEECH_EXTERNAL_OPENAI_REALTIME"
|
|
51948
52506
|
].includes(processor);
|
|
51949
52507
|
}
|
|
51950
52508
|
function rememberOutcome(db, binding, value2) {
|
|
@@ -52072,7 +52630,7 @@ function observeSystemActivity(scheduler, read = systemIdleSeconds) {
|
|
|
52072
52630
|
|
|
52073
52631
|
// apps/local-runtime/src/workspace/offline.ts
|
|
52074
52632
|
init_local_execution();
|
|
52075
|
-
|
|
52633
|
+
init_identity4();
|
|
52076
52634
|
init_error();
|
|
52077
52635
|
init_zod();
|
|
52078
52636
|
var record5 = external_exports.strictObject({
|
|
@@ -52149,17 +52707,17 @@ function offlineWorkspace(db, raw) {
|
|
|
52149
52707
|
|
|
52150
52708
|
// apps/local-runtime/src/library/service.ts
|
|
52151
52709
|
init_local_execution();
|
|
52152
|
-
|
|
52710
|
+
init_identity4();
|
|
52153
52711
|
init_error();
|
|
52154
52712
|
import { statfs as statfs2 } from "node:fs/promises";
|
|
52155
52713
|
|
|
52156
52714
|
// apps/local-runtime/src/library/files.ts
|
|
52157
52715
|
init_src();
|
|
52158
52716
|
init_private_state();
|
|
52159
|
-
|
|
52717
|
+
init_identity4();
|
|
52160
52718
|
init_error();
|
|
52161
|
-
import { createHash as
|
|
52162
|
-
import { join as
|
|
52719
|
+
import { createHash as createHash46 } from "node:crypto";
|
|
52720
|
+
import { join as join51 } from "node:path";
|
|
52163
52721
|
import { unlink as unlink6, opendir as opendir5 } from "node:fs/promises";
|
|
52164
52722
|
function libraryKey(reference2) {
|
|
52165
52723
|
const { tenantId, projectId, deviceId, fileId, versionId } = reference2;
|
|
@@ -52173,8 +52731,8 @@ var LibraryFiles = class {
|
|
|
52173
52731
|
root;
|
|
52174
52732
|
identities = /* @__PURE__ */ new WeakMap();
|
|
52175
52733
|
async folders() {
|
|
52176
|
-
await privateDirectory2(
|
|
52177
|
-
return privateDirectory2(
|
|
52734
|
+
await privateDirectory2(join51(this.root, "library"));
|
|
52735
|
+
return privateDirectory2(join51(this.root, "library", "objects"));
|
|
52178
52736
|
}
|
|
52179
52737
|
/** 配额包含中断导入的实际占用,同一版本重传只预留尚缺的空间。 */
|
|
52180
52738
|
async reservation(reference2) {
|
|
@@ -52183,7 +52741,7 @@ var LibraryFiles = class {
|
|
|
52183
52741
|
const names = /* @__PURE__ */ new Set([libraryKey(reference2), libraryKey(reference2) + ".part"]);
|
|
52184
52742
|
for await (const entry of await opendir5(folder)) {
|
|
52185
52743
|
if (++count3 > 5e4) runtimeError("QUERY_LIMIT");
|
|
52186
|
-
const file2 = await privateFile(
|
|
52744
|
+
const file2 = await privateFile(join51(folder, entry.name), false, false);
|
|
52187
52745
|
try {
|
|
52188
52746
|
const size = (await file2.stat()).size;
|
|
52189
52747
|
bytes += size;
|
|
@@ -52195,10 +52753,10 @@ var LibraryFiles = class {
|
|
|
52195
52753
|
return bytes + Math.max(0, reference2.byteSize - existing);
|
|
52196
52754
|
}
|
|
52197
52755
|
async import(reference2, bytes, authorize) {
|
|
52198
|
-
const staging = await this.folders(), temporary =
|
|
52756
|
+
const staging = await this.folders(), temporary = join51(staging, libraryKey(reference2) + ".part");
|
|
52199
52757
|
const file2 = await privateFile(temporary, true);
|
|
52200
52758
|
let count3 = 0;
|
|
52201
|
-
const hash10 =
|
|
52759
|
+
const hash10 = createHash46("sha256");
|
|
52202
52760
|
try {
|
|
52203
52761
|
await file2.truncate(0);
|
|
52204
52762
|
for await (const part of bytes) {
|
|
@@ -52213,7 +52771,7 @@ var LibraryFiles = class {
|
|
|
52213
52771
|
runtimeError("LIBRARY_BYTES_INVALID");
|
|
52214
52772
|
await file2.sync();
|
|
52215
52773
|
await file2.close();
|
|
52216
|
-
const target2 =
|
|
52774
|
+
const target2 = join51(this.root, "library", "objects", libraryKey(reference2));
|
|
52217
52775
|
let existing;
|
|
52218
52776
|
try {
|
|
52219
52777
|
existing = await this.open(reference2, authorize);
|
|
@@ -52235,12 +52793,12 @@ var LibraryFiles = class {
|
|
|
52235
52793
|
async open(reference2, authorize) {
|
|
52236
52794
|
authorize();
|
|
52237
52795
|
const file2 = await privateFile(
|
|
52238
|
-
|
|
52796
|
+
join51(this.root, "library", "objects", libraryKey(reference2)),
|
|
52239
52797
|
false,
|
|
52240
52798
|
false
|
|
52241
52799
|
);
|
|
52242
52800
|
try {
|
|
52243
|
-
const before = await file2.stat(), hash10 =
|
|
52801
|
+
const before = await file2.stat(), hash10 = createHash46("sha256"), buffer = Buffer.alloc(128 * 1024);
|
|
52244
52802
|
if (before.size !== reference2.byteSize) runtimeError("LIBRARY_BYTES_INVALID");
|
|
52245
52803
|
let offset2 = 0;
|
|
52246
52804
|
for (; ; ) {
|
|
@@ -52282,7 +52840,7 @@ var LibraryFiles = class {
|
|
|
52282
52840
|
if (!bytesRead) runtimeError("LIBRARY_BYTES_INVALID");
|
|
52283
52841
|
offset2 += bytesRead;
|
|
52284
52842
|
}
|
|
52285
|
-
if (!unchanged(before, await file2.stat()) ||
|
|
52843
|
+
if (!unchanged(before, await file2.stat()) || createHash46("sha256").update(result).digest("hex") !== reference2.checksumSha256)
|
|
52286
52844
|
runtimeError("LIBRARY_BYTES_INVALID");
|
|
52287
52845
|
authorize();
|
|
52288
52846
|
return result;
|
|
@@ -52295,7 +52853,7 @@ var LibraryFiles = class {
|
|
|
52295
52853
|
// apps/local-runtime/src/library/records.ts
|
|
52296
52854
|
init_zod();
|
|
52297
52855
|
init_local_execution();
|
|
52298
|
-
|
|
52856
|
+
init_identity4();
|
|
52299
52857
|
init_error();
|
|
52300
52858
|
var AccessOutboxSchema = external_exports.strictObject({
|
|
52301
52859
|
ownerKey: external_exports.string(),
|
|
@@ -52349,7 +52907,7 @@ var LibraryRecords = class {
|
|
|
52349
52907
|
|
|
52350
52908
|
// apps/local-runtime/src/library/access.ts
|
|
52351
52909
|
init_local_execution();
|
|
52352
|
-
|
|
52910
|
+
init_identity4();
|
|
52353
52911
|
init_error();
|
|
52354
52912
|
var LibraryAccess = class {
|
|
52355
52913
|
constructor(records, cloud, signal) {
|
|
@@ -52570,13 +53128,13 @@ var LocalLibrary = class {
|
|
|
52570
53128
|
);
|
|
52571
53129
|
}
|
|
52572
53130
|
async receive(raw, bytes, authorize) {
|
|
52573
|
-
const input3 = LocalLibraryImportSchema.parse(raw), key13 = importKey(input3),
|
|
53131
|
+
const input3 = LocalLibraryImportSchema.parse(raw), key13 = importKey(input3), digest16 = fingerprint2(input3);
|
|
52574
53132
|
if (this.importing) runtimeError("BUSY");
|
|
52575
53133
|
this.importing = true;
|
|
52576
53134
|
try {
|
|
52577
53135
|
authorize();
|
|
52578
53136
|
const prior = this.db.get("LOCAL_MEDIA_IMPORT", key13);
|
|
52579
|
-
if (prior && prior.payload.fingerprint !==
|
|
53137
|
+
if (prior && prior.payload.fingerprint !== digest16)
|
|
52580
53138
|
runtimeError("LIBRARY_CONFLICT");
|
|
52581
53139
|
let existing = null;
|
|
52582
53140
|
try {
|
|
@@ -52611,7 +53169,7 @@ var LocalLibrary = class {
|
|
|
52611
53169
|
this.db.put(
|
|
52612
53170
|
"LOCAL_MEDIA_IMPORT",
|
|
52613
53171
|
key13,
|
|
52614
|
-
{ fingerprint:
|
|
53172
|
+
{ fingerprint: digest16, reference: input3.reference, ownerKey: input3.ownerKey },
|
|
52615
53173
|
0
|
|
52616
53174
|
);
|
|
52617
53175
|
return item;
|
|
@@ -52791,7 +53349,7 @@ var PreviewResultSchema = external_exports.strictObject({
|
|
|
52791
53349
|
var resultKey = (b) => workKey(b) + ":" + b.attemptId;
|
|
52792
53350
|
|
|
52793
53351
|
// apps/local-runtime/src/preview/fenced-render-recovery.ts
|
|
52794
|
-
|
|
53352
|
+
init_identity4();
|
|
52795
53353
|
init_error();
|
|
52796
53354
|
function hasCleanup(journal, entry, verifiedTransfers) {
|
|
52797
53355
|
const binding = bindingFor(entry.submission);
|
|
@@ -52881,7 +53439,7 @@ init_processor_checkpoint();
|
|
|
52881
53439
|
// apps/local-runtime/src/preview/processor-terminal.ts
|
|
52882
53440
|
init_local_execution();
|
|
52883
53441
|
init_executions();
|
|
52884
|
-
|
|
53442
|
+
init_identity4();
|
|
52885
53443
|
init_error();
|
|
52886
53444
|
|
|
52887
53445
|
// apps/local-runtime/src/cloud/client.ts
|
|
@@ -52889,12 +53447,12 @@ init_zod();
|
|
|
52889
53447
|
init_local_execution();
|
|
52890
53448
|
init_error();
|
|
52891
53449
|
init_version();
|
|
52892
|
-
|
|
53450
|
+
init_identity4();
|
|
52893
53451
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
52894
53452
|
|
|
52895
53453
|
// apps/local-runtime/src/cloud/object-transfer.ts
|
|
52896
53454
|
init_local_execution();
|
|
52897
|
-
|
|
53455
|
+
init_identity4();
|
|
52898
53456
|
init_error();
|
|
52899
53457
|
async function transfer(raw, method, signal, bytes) {
|
|
52900
53458
|
const ticket = MediaObjectTicketSchema.parse(raw);
|
|
@@ -52953,7 +53511,7 @@ function localRequestTimeout(path, body, binary) {
|
|
|
52953
53511
|
|
|
52954
53512
|
// apps/local-runtime/src/cloud/processor-heartbeat.ts
|
|
52955
53513
|
init_local_execution();
|
|
52956
|
-
|
|
53514
|
+
init_identity4();
|
|
52957
53515
|
function processorHeartbeat(config2, toolchain) {
|
|
52958
53516
|
if (!config2.tenantMediaProcessing) return {};
|
|
52959
53517
|
if (!config2.processorCapabilities?.length) throw Error("DEVICE_CAPABILITIES_REQUIRED");
|
|
@@ -52969,7 +53527,20 @@ function processorHeartbeat(config2, toolchain) {
|
|
|
52969
53527
|
...capabilities.some(
|
|
52970
53528
|
(kind) => kind === "LOCAL_MEDIA_INSPECT" || kind === "LOCAL_MEDIA_PUBLISH"
|
|
52971
53529
|
) ? ["LIBRARY_WAV"] : [],
|
|
52972
|
-
...capabilities.some((kind) => kind === "KEYFRAME_GENERATE" || kind === "VIDEO_GENERATE") ? ["QWEN_WATERMARK"] : []
|
|
53530
|
+
...capabilities.some((kind) => kind === "KEYFRAME_GENERATE" || kind === "VIDEO_GENERATE") ? ["QWEN_WATERMARK"] : [],
|
|
53531
|
+
...capabilities.includes("TRANSCRIBE_EXTERNAL_OPENAI") ? ["OPENAI_WHISPER_TIMED"] : [],
|
|
53532
|
+
...capabilities.includes("KEYFRAME_GENERATE") ? ["QWEN_IMAGE_PADDING"] : [],
|
|
53533
|
+
// 只有运行该版本内核的设备才声明保留实际编码尺寸的 V2 能力。
|
|
53534
|
+
...capabilities.some(
|
|
53535
|
+
(kind) => [
|
|
53536
|
+
"IMPORT_PROJECT_SOURCE",
|
|
53537
|
+
"IMPORT_ORIGINAL",
|
|
53538
|
+
"IMPORTED_VISUAL_NORMALIZE",
|
|
53539
|
+
"SOURCE_SYNC_AUDIO",
|
|
53540
|
+
"LOCAL_MEDIA_INSPECT",
|
|
53541
|
+
"LOCAL_MEDIA_PUBLISH"
|
|
53542
|
+
].includes(kind)
|
|
53543
|
+
) ? ["IMPORTED_PRESERVE_V2"] : []
|
|
52973
53544
|
],
|
|
52974
53545
|
...capabilities.includes("VIDEO_GENERATE") && config2.qwenIdentities?.length ? { wanVideoOutput: "WAN_VIDEO_OUTPUT_V1" } : {},
|
|
52975
53546
|
// 文件配方单独声明实际协议摘要,不能借其他处理器的摘要推断资格。
|
|
@@ -53075,15 +53646,17 @@ async function signDeviceMessage(privateKeyFile, message) {
|
|
|
53075
53646
|
// apps/local-runtime/src/cloud/failure.ts
|
|
53076
53647
|
init_common2();
|
|
53077
53648
|
var CloudRequestError = class extends Error {
|
|
53078
|
-
constructor(code, outcome, capabilityMismatch) {
|
|
53649
|
+
constructor(code, outcome, capabilityMismatch, status) {
|
|
53079
53650
|
super("LOCAL_CLOUD_" + code);
|
|
53080
53651
|
this.code = code;
|
|
53081
53652
|
this.outcome = outcome;
|
|
53082
53653
|
this.capabilityMismatch = capabilityMismatch;
|
|
53654
|
+
this.status = status;
|
|
53083
53655
|
}
|
|
53084
53656
|
code;
|
|
53085
53657
|
outcome;
|
|
53086
53658
|
capabilityMismatch;
|
|
53659
|
+
status;
|
|
53087
53660
|
};
|
|
53088
53661
|
async function cloudFailure(response, read) {
|
|
53089
53662
|
if (response.status === 409 && response.headers.get("content-type")?.split(";")[0] === "application/json") {
|
|
@@ -53100,7 +53673,9 @@ async function cloudFailure(response, read) {
|
|
|
53100
53673
|
});
|
|
53101
53674
|
return new CloudRequestError(
|
|
53102
53675
|
response.status === 401 || response.status === 403 ? "FORBIDDEN" : "REFUSED",
|
|
53103
|
-
response.status >= 500 ? "UNKNOWN" : "REFUSED"
|
|
53676
|
+
response.status >= 500 ? "UNKNOWN" : "REFUSED",
|
|
53677
|
+
void 0,
|
|
53678
|
+
response.status
|
|
53104
53679
|
);
|
|
53105
53680
|
}
|
|
53106
53681
|
|
|
@@ -53216,8 +53791,8 @@ var LocalCloudClient = class {
|
|
|
53216
53791
|
throw new CloudRequestError("RESPONSE_INVALID", "UNKNOWN");
|
|
53217
53792
|
}
|
|
53218
53793
|
}
|
|
53219
|
-
async limited(r,
|
|
53220
|
-
if (Number(r.headers.get("content-length")) >
|
|
53794
|
+
async limited(r, maximum4) {
|
|
53795
|
+
if (Number(r.headers.get("content-length")) > maximum4) {
|
|
53221
53796
|
await r.body?.cancel();
|
|
53222
53797
|
throw new CloudRequestError("RESPONSE_LIMIT", "UNKNOWN");
|
|
53223
53798
|
}
|
|
@@ -53226,7 +53801,7 @@ var LocalCloudClient = class {
|
|
|
53226
53801
|
try {
|
|
53227
53802
|
for await (const b of r.body ?? []) {
|
|
53228
53803
|
size += b.byteLength;
|
|
53229
|
-
if (size >
|
|
53804
|
+
if (size > maximum4) throw Error("LIMIT");
|
|
53230
53805
|
chunks.push(b);
|
|
53231
53806
|
}
|
|
53232
53807
|
return Buffer.concat(chunks);
|
|
@@ -53439,7 +54014,7 @@ init_zod();
|
|
|
53439
54014
|
init_local_execution();
|
|
53440
54015
|
init_src3();
|
|
53441
54016
|
import { unlink as unlink7 } from "node:fs/promises";
|
|
53442
|
-
import { join as
|
|
54017
|
+
import { join as join52 } from "node:path";
|
|
53443
54018
|
|
|
53444
54019
|
// packages/media-execution/src/speech/openai-realtime.ts
|
|
53445
54020
|
init_src2();
|
|
@@ -53626,7 +54201,7 @@ async function synthesizeOpenAiRealtimeDevice(input3) {
|
|
|
53626
54201
|
// apps/local-runtime/src/preview/openai-speech.ts
|
|
53627
54202
|
init_src();
|
|
53628
54203
|
init_error();
|
|
53629
|
-
|
|
54204
|
+
init_identity4();
|
|
53630
54205
|
init_private_state();
|
|
53631
54206
|
|
|
53632
54207
|
// apps/local-runtime/src/preview/managed-provider-key.ts
|
|
@@ -53700,7 +54275,7 @@ var savedReceipt = external_exports.union([
|
|
|
53700
54275
|
external_exports.strictObject({ status: external_exports.literal("REJECTED") })
|
|
53701
54276
|
]);
|
|
53702
54277
|
function openAiSpeechResultPath(journal, runtimeJobId) {
|
|
53703
|
-
return
|
|
54278
|
+
return join52(journal.root, "staging", LocalIdSchema.parse(runtimeJobId) + ".openai-speech");
|
|
53704
54279
|
}
|
|
53705
54280
|
async function saveOriginal(work, { receipt: receipt2, bytes }) {
|
|
53706
54281
|
const path = openAiSpeechResultPath(work.journal, work.binding.runtimeJobId);
|
|
@@ -53880,11 +54455,11 @@ async function inspectDeviceOpenAiSpeech(evidence2, source5, normalized, tools,
|
|
|
53880
54455
|
init_local_execution();
|
|
53881
54456
|
init_zod();
|
|
53882
54457
|
init_executions();
|
|
53883
|
-
|
|
54458
|
+
init_identity4();
|
|
53884
54459
|
init_error();
|
|
53885
54460
|
init_private_state();
|
|
53886
54461
|
import { unlink as unlink8 } from "node:fs/promises";
|
|
53887
|
-
import { join as
|
|
54462
|
+
import { join as join53 } from "node:path";
|
|
53888
54463
|
init_processor_checkpoint();
|
|
53889
54464
|
var historySchema = external_exports.strictObject({
|
|
53890
54465
|
assignment: TenantProcessorAssignmentSchema,
|
|
@@ -53894,12 +54469,22 @@ var historySchema = external_exports.strictObject({
|
|
|
53894
54469
|
});
|
|
53895
54470
|
function processorLocalTerminal(journal, assignment, current, laneKind = "PROCESSOR") {
|
|
53896
54471
|
const binding = bindingFor(assignment.lease);
|
|
53897
|
-
const pathFor = (index) =>
|
|
54472
|
+
const pathFor = (index) => join53(journal.root, "staging", binding.attemptId + ".processor-" + index);
|
|
53898
54473
|
const verifyReceipt = (receipt2) => {
|
|
53899
54474
|
const report = current().entry.report;
|
|
53900
54475
|
if (!report || fingerprint2(bindingFor(report)) !== fingerprint2(binding) || fingerprint2(report.work) !== binding.workFingerprint || receipt2.requestId !== report.requestId || receipt2.operationId !== assignment.work.operationId || receipt2.reportFingerprint !== report.reportFingerprint || fingerprint2(bindingFor(receipt2)) !== fingerprint2(binding))
|
|
53901
54476
|
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
53902
54477
|
};
|
|
54478
|
+
const finishReportRejection = (raw) => {
|
|
54479
|
+
const rejection = TenantProcessorReportRejectionSchema.parse(raw);
|
|
54480
|
+
verifyReceipt(rejection);
|
|
54481
|
+
if (assignment.recipe.processor !== "IMPORT_ORIGINAL" || assignment.recipe.command.input.expectedProductionRevision !== rejection.expectedProductionRevision)
|
|
54482
|
+
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
54483
|
+
const record6 = () => recordTaskFailure(journal, binding, { code: rejection.reason });
|
|
54484
|
+
if (laneKind === "PROCESSOR") archiveFence(record6);
|
|
54485
|
+
else journal.transaction(record6);
|
|
54486
|
+
return "PROCESSOR_REPORT_REJECTION_RECORDED";
|
|
54487
|
+
};
|
|
53903
54488
|
const finish = async (raw) => {
|
|
53904
54489
|
const receipt2 = TenantProcessorReceiptSchema.parse(raw);
|
|
53905
54490
|
verifyReceipt(receipt2);
|
|
@@ -53967,7 +54552,10 @@ function processorLocalTerminal(journal, assignment, current, laneKind = "PROCES
|
|
|
53967
54552
|
"KEYFRAME_GENERATE",
|
|
53968
54553
|
"VIDEO_GENERATE",
|
|
53969
54554
|
"TRANSCRIBE_EXTERNAL_QWEN",
|
|
53970
|
-
"SPEECH_EXTERNAL_QWEN"
|
|
54555
|
+
"SPEECH_EXTERNAL_QWEN",
|
|
54556
|
+
// 栅栏恢复与正常终态接受相同的供应商类型。
|
|
54557
|
+
"TRANSCRIBE_EXTERNAL_OPENAI",
|
|
54558
|
+
"SPEECH_EXTERNAL_OPENAI_REALTIME"
|
|
53971
54559
|
].includes(assignment.recipe.processor) || fingerprint2(entry.assignment) !== fingerprint2(assignment) || entry.rendered || entry.report || entry.invalidSource)
|
|
53972
54560
|
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
53973
54561
|
journal.transaction(() => {
|
|
@@ -53976,17 +54564,18 @@ function processorLocalTerminal(journal, assignment, current, laneKind = "PROCES
|
|
|
53976
54564
|
});
|
|
53977
54565
|
return "PROCESSOR_PROVIDER_TERMINAL_RECORDED";
|
|
53978
54566
|
};
|
|
53979
|
-
|
|
54567
|
+
function archiveFence(record6) {
|
|
53980
54568
|
const { row, entry } = current();
|
|
53981
54569
|
journal.transaction(() => {
|
|
53982
54570
|
const saved = journal.get("PROCESSOR_FENCED", binding.attemptId);
|
|
53983
54571
|
if (saved && fingerprint2(saved.payload) !== fingerprint2(entry))
|
|
53984
54572
|
runtimeError("PROCESSOR_RECEIPT_INVALID");
|
|
53985
54573
|
if (!saved) journal.put("PROCESSOR_FENCED", binding.attemptId, entry, 0);
|
|
54574
|
+
record6?.();
|
|
53986
54575
|
journal.remove("PROCESSOR", row.id, row.revision);
|
|
53987
54576
|
});
|
|
53988
54577
|
return "PROCESSOR_FENCED";
|
|
53989
|
-
}
|
|
54578
|
+
}
|
|
53990
54579
|
async function recoverArchived() {
|
|
53991
54580
|
const row = journal.get("PROCESSOR_HISTORY", fingerprint2(binding));
|
|
53992
54581
|
if (row) {
|
|
@@ -54004,6 +54593,7 @@ function processorLocalTerminal(journal, assignment, current, laneKind = "PROCES
|
|
|
54004
54593
|
return {
|
|
54005
54594
|
pathFor,
|
|
54006
54595
|
finish,
|
|
54596
|
+
finishReportRejection,
|
|
54007
54597
|
finishConfirmedFailure,
|
|
54008
54598
|
finishProviderOutcome,
|
|
54009
54599
|
finishFencedProviderOutcome,
|
|
@@ -54027,6 +54617,7 @@ function processorTerminal(journal, assignment, cloud, signal, current, laneKind
|
|
|
54027
54617
|
const {
|
|
54028
54618
|
pathFor,
|
|
54029
54619
|
finish,
|
|
54620
|
+
finishReportRejection,
|
|
54030
54621
|
finishConfirmedFailure,
|
|
54031
54622
|
finishProviderOutcome,
|
|
54032
54623
|
finishFencedProviderOutcome,
|
|
@@ -54044,6 +54635,28 @@ function processorTerminal(journal, assignment, cloud, signal, current, laneKind
|
|
|
54044
54635
|
signal
|
|
54045
54636
|
) : null;
|
|
54046
54637
|
}
|
|
54638
|
+
async function readReportRejection() {
|
|
54639
|
+
const report = current().entry.report;
|
|
54640
|
+
if (!report || assignment.recipe.processor !== "IMPORT_ORIGINAL") return null;
|
|
54641
|
+
const query = { ...binding, requestId: report.requestId };
|
|
54642
|
+
const read = (input3) => cloud.processor(
|
|
54643
|
+
"reportRejection",
|
|
54644
|
+
input3,
|
|
54645
|
+
TenantProcessorReportRejectionSchema.nullable(),
|
|
54646
|
+
signal
|
|
54647
|
+
);
|
|
54648
|
+
try {
|
|
54649
|
+
return await read({ ...query, version: 2 });
|
|
54650
|
+
} catch (error62) {
|
|
54651
|
+
if (!(error62 instanceof CloudRequestError) || error62.status !== 400) throw error62;
|
|
54652
|
+
}
|
|
54653
|
+
try {
|
|
54654
|
+
return await read(query);
|
|
54655
|
+
} catch (error62) {
|
|
54656
|
+
if (error62 instanceof CloudRequestError && error62.status === 400) return null;
|
|
54657
|
+
throw error62;
|
|
54658
|
+
}
|
|
54659
|
+
}
|
|
54047
54660
|
async function fencedOrWaiting() {
|
|
54048
54661
|
const receipt2 = await readReceipt3();
|
|
54049
54662
|
if (receipt2) return finish(receipt2);
|
|
@@ -54063,7 +54676,9 @@ function processorTerminal(journal, assignment, cloud, signal, current, laneKind
|
|
|
54063
54676
|
}
|
|
54064
54677
|
return finishProviderOutcome(outcome);
|
|
54065
54678
|
}
|
|
54066
|
-
|
|
54679
|
+
if (status.state !== "FENCED") return "PROCESSOR_WAITING_FOR_AUTHORITY";
|
|
54680
|
+
const rejection = await readReportRejection();
|
|
54681
|
+
return rejection ? finishReportRejection(rejection) : archiveFence();
|
|
54067
54682
|
}
|
|
54068
54683
|
async function recoverFenced() {
|
|
54069
54684
|
const fenced = journal.get("PROCESSOR_FENCED", binding.attemptId);
|
|
@@ -54079,6 +54694,8 @@ function processorTerminal(journal, assignment, cloud, signal, current, laneKind
|
|
|
54079
54694
|
if (laneKind === "PROCESSOR_FENCED" && entry.report) {
|
|
54080
54695
|
const receipt2 = await readReceipt3();
|
|
54081
54696
|
if (receipt2) return finish(receipt2);
|
|
54697
|
+
const rejection = await readReportRejection();
|
|
54698
|
+
if (rejection) return finishReportRejection(rejection);
|
|
54082
54699
|
}
|
|
54083
54700
|
if (!external3) return "PROCESSOR_FENCED";
|
|
54084
54701
|
const status = await cloud.processor("state", binding, TenantProcessorStateSchema, signal);
|
|
@@ -54127,6 +54744,7 @@ function processorTerminal(journal, assignment, cloud, signal, current, laneKind
|
|
|
54127
54744
|
finishFailure,
|
|
54128
54745
|
finishProviderOutcome,
|
|
54129
54746
|
readReceipt: readReceipt3,
|
|
54747
|
+
archiveFence,
|
|
54130
54748
|
fencedOrWaiting,
|
|
54131
54749
|
recoverArchived,
|
|
54132
54750
|
recoverFenced
|
|
@@ -54134,6 +54752,7 @@ function processorTerminal(journal, assignment, cloud, signal, current, laneKind
|
|
|
54134
54752
|
}
|
|
54135
54753
|
|
|
54136
54754
|
// apps/local-runtime/src/preview/fenced-processor-recovery.ts
|
|
54755
|
+
init_local_execution();
|
|
54137
54756
|
var external2 = /* @__PURE__ */ new Set([
|
|
54138
54757
|
"KEYFRAME_GENERATE",
|
|
54139
54758
|
"VIDEO_GENERATE",
|
|
@@ -54152,6 +54771,10 @@ function firstFencedProcessor(journal, device, after = "") {
|
|
|
54152
54771
|
const assignment = assertProcessorAssignment(entry, device.deviceId);
|
|
54153
54772
|
const binding = bindingFor(assignment.lease);
|
|
54154
54773
|
if (row.id !== binding.attemptId) runtimeError("PROCESSOR_ASSIGNMENT_INVALID");
|
|
54774
|
+
if (assignment.recipe.processor === "IMPORT_ORIGINAL" && TenantProcessorReportRejectionSchema.shape.reason.safeParse(
|
|
54775
|
+
readTaskFailure(journal, binding)?.code
|
|
54776
|
+
).success)
|
|
54777
|
+
continue;
|
|
54155
54778
|
const active = [0, 1].some((lane) => {
|
|
54156
54779
|
const current = journal.get(
|
|
54157
54780
|
"PROCESSOR",
|
|
@@ -54613,7 +55236,7 @@ init_src2();
|
|
|
54613
55236
|
init_local_execution();
|
|
54614
55237
|
init_src3();
|
|
54615
55238
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
54616
|
-
|
|
55239
|
+
init_identity4();
|
|
54617
55240
|
init_executions();
|
|
54618
55241
|
init_requests();
|
|
54619
55242
|
init_error();
|
|
@@ -54623,7 +55246,7 @@ init_src2();
|
|
|
54623
55246
|
init_src3();
|
|
54624
55247
|
init_error();
|
|
54625
55248
|
init_local_execution();
|
|
54626
|
-
|
|
55249
|
+
init_identity4();
|
|
54627
55250
|
init_executions();
|
|
54628
55251
|
async function inspectTenantOutput(runtime, cloud, assignment, input3, tools, signal) {
|
|
54629
55252
|
if (assignment.work.protocol !== "NVS_LOCAL_WORK_V2") runtimeError("WORK_INVALID");
|
|
@@ -54996,7 +55619,7 @@ var LocalPreviewPipeline = class {
|
|
|
54996
55619
|
|
|
54997
55620
|
// apps/local-runtime/src/preview/worker.ts
|
|
54998
55621
|
init_executions();
|
|
54999
|
-
|
|
55622
|
+
init_identity4();
|
|
55000
55623
|
init_error();
|
|
55001
55624
|
|
|
55002
55625
|
// apps/local-runtime/src/preview/openai-asr.ts
|
|
@@ -55004,13 +55627,13 @@ init_zod();
|
|
|
55004
55627
|
init_src2();
|
|
55005
55628
|
init_local_execution();
|
|
55006
55629
|
init_src3();
|
|
55007
|
-
|
|
55630
|
+
init_identity4();
|
|
55008
55631
|
init_provider_submission();
|
|
55009
55632
|
var Receipt2 = external_exports.discriminatedUnion("status", [
|
|
55010
55633
|
external_exports.strictObject({
|
|
55011
55634
|
status: external_exports.literal("SUCCEEDED"),
|
|
55012
55635
|
provider: OpenAiAsrProviderSchema,
|
|
55013
|
-
transcript: TranscriptSchema
|
|
55636
|
+
transcript: TranscriptSchema
|
|
55014
55637
|
}),
|
|
55015
55638
|
external_exports.strictObject({ status: external_exports.literal("REJECTED") })
|
|
55016
55639
|
]);
|
|
@@ -55068,7 +55691,7 @@ async function renderDeviceOpenAiTranscript({
|
|
|
55068
55691
|
status: "SUCCEEDED",
|
|
55069
55692
|
transcript,
|
|
55070
55693
|
provider: OpenAiAsrProviderSchema.parse({
|
|
55071
|
-
protocol: "OPENAI_TRANSCRIPTION_V1",
|
|
55694
|
+
protocol: model3 === openAiWhisperModelId ? "OPENAI_WHISPER_TRANSCRIPTION_V1" : "OPENAI_TRANSCRIPTION_V1",
|
|
55072
55695
|
requestId: providerRequestId,
|
|
55073
55696
|
model: model3,
|
|
55074
55697
|
usage,
|
|
@@ -55086,6 +55709,7 @@ async function renderDeviceOpenAiTranscript({
|
|
|
55086
55709
|
prepared2 = prepareOpenAiTranscription({
|
|
55087
55710
|
source: source5,
|
|
55088
55711
|
parameters,
|
|
55712
|
+
...recipe.model && { model: recipe.model },
|
|
55089
55713
|
bytes: await readSource(source5.representationId)
|
|
55090
55714
|
});
|
|
55091
55715
|
},
|
|
@@ -55121,8 +55745,8 @@ async function renderDeviceOpenAiTranscript({
|
|
|
55121
55745
|
async function inspectDeviceOpenAiTranscript(evidence2, read) {
|
|
55122
55746
|
const bytes = await read(0);
|
|
55123
55747
|
const text5 = Buffer.from(bytes).toString("utf8");
|
|
55124
|
-
const transcript = TranscriptSchema.
|
|
55125
|
-
if (bytes.length !== evidence2.transcriptDigest.byteSize || digest13(bytes) !== evidence2.transcriptDigest.checksumSha256 || canonicalLocalJson(transcript) !== text5)
|
|
55748
|
+
const transcript = TranscriptSchema.parse(JSON.parse(text5));
|
|
55749
|
+
if (bytes.length !== evidence2.transcriptDigest.byteSize || digest13(bytes) !== evidence2.transcriptDigest.checksumSha256 || canonicalLocalJson(transcript) !== text5 || evidence2.provider.model === openAiWhisperModelId !== (transcript.timing === "PROVIDER_REPORTED"))
|
|
55126
55750
|
throw new OpenAiTranscriptionError("PROVIDER_OUTCOME_UNKNOWN");
|
|
55127
55751
|
return evidence2;
|
|
55128
55752
|
}
|
|
@@ -55142,13 +55766,14 @@ function invalidProcessorSource(error62) {
|
|
|
55142
55766
|
}
|
|
55143
55767
|
|
|
55144
55768
|
// apps/local-runtime/src/preview/processor.ts
|
|
55145
|
-
|
|
55769
|
+
init_identity4();
|
|
55146
55770
|
|
|
55147
55771
|
// apps/local-runtime/src/preview/processor-media.ts
|
|
55148
55772
|
init_local_execution();
|
|
55149
55773
|
init_src3();
|
|
55150
55774
|
init_error();
|
|
55151
|
-
|
|
55775
|
+
init_imported_visual();
|
|
55776
|
+
init_identity4();
|
|
55152
55777
|
init_generation();
|
|
55153
55778
|
|
|
55154
55779
|
// apps/local-runtime/src/preview/qwen-speech.ts
|
|
@@ -55156,7 +55781,7 @@ init_local_execution();
|
|
|
55156
55781
|
init_src3();
|
|
55157
55782
|
init_zod();
|
|
55158
55783
|
init_error();
|
|
55159
|
-
|
|
55784
|
+
init_identity4();
|
|
55160
55785
|
async function renderDeviceSpeech({
|
|
55161
55786
|
cloud,
|
|
55162
55787
|
binding,
|
|
@@ -55220,7 +55845,7 @@ function speechEvidence(ids, { source: source5, bytes }) {
|
|
|
55220
55845
|
// apps/local-runtime/src/preview/processor-composition.ts
|
|
55221
55846
|
init_src2();
|
|
55222
55847
|
init_local_execution();
|
|
55223
|
-
|
|
55848
|
+
init_identity4();
|
|
55224
55849
|
init_error();
|
|
55225
55850
|
async function renderProcessorComposition(recipe, read, tools, signal) {
|
|
55226
55851
|
const inputs = [];
|
|
@@ -55325,12 +55950,8 @@ async function renderProcessorMedia(recipe, read, tools, signal, compositionTool
|
|
|
55325
55950
|
case "SPEECH_EXTERNAL_OPENAI_REALTIME":
|
|
55326
55951
|
return runtimeError("PROVIDER_AUTHORITY_REQUIRED");
|
|
55327
55952
|
case "IMPORTED_VISUAL_NORMALIZE": {
|
|
55328
|
-
const
|
|
55329
|
-
|
|
55330
|
-
await read(recipe.source.representationId),
|
|
55331
|
-
signal,
|
|
55332
|
-
tools
|
|
55333
|
-
);
|
|
55953
|
+
const source5 = await read(recipe.source.representationId);
|
|
55954
|
+
const { bytes, poster: poster2, receipt: receipt2 } = recipe.request.schemaVersion === 2 ? await normalizePreserveImportedVisual(recipe.request, source5, signal, tools) : await normalizeImportedVisual(recipe.request, source5, signal, tools);
|
|
55334
55955
|
return {
|
|
55335
55956
|
outputs: [bytes, poster2.bytes],
|
|
55336
55957
|
evidence: {
|
|
@@ -55351,7 +55972,8 @@ async function renderProcessorMedia(recipe, read, tools, signal, compositionTool
|
|
|
55351
55972
|
recipe.input,
|
|
55352
55973
|
await read(recipe.source.representationId),
|
|
55353
55974
|
signal,
|
|
55354
|
-
tools
|
|
55975
|
+
tools,
|
|
55976
|
+
recipe.sourceGeometryProfile
|
|
55355
55977
|
);
|
|
55356
55978
|
return { outputs: [bytes], evidence: { processor, provenance } };
|
|
55357
55979
|
}
|
|
@@ -55419,13 +56041,27 @@ async function inspectProcessorMedia(recipe, evidence2, read, tools, signal, com
|
|
|
55419
56041
|
if (processor === "REFERENCE_PREVIEW" && evidence2.processor === processor)
|
|
55420
56042
|
return { processor, image: await inspectReferenceThumbnail(await read(0), signal, tools) };
|
|
55421
56043
|
if (processor === "KEYFRAME_GENERATE" && evidence2.processor === processor) {
|
|
56044
|
+
const original2 = recipe.geometryPolicy === "PAD_TO_ASPECT" ? await normalizeQwenKeyframe(await read(1), recipe.aspectRatio, signal, tools) : void 0;
|
|
56045
|
+
if (original2 && !Buffer.from(original2.image.bytes).equals(await read(0)))
|
|
56046
|
+
runtimeError("PROCESSOR_READBACK_INVALID");
|
|
55422
56047
|
const { width, height, checksumSha256, byteSize } = await inspectQwenKeyframe(
|
|
55423
56048
|
await read(0),
|
|
55424
56049
|
recipe.aspectRatio,
|
|
55425
56050
|
signal,
|
|
55426
56051
|
tools
|
|
55427
56052
|
);
|
|
55428
|
-
return {
|
|
56053
|
+
return {
|
|
56054
|
+
...evidence2,
|
|
56055
|
+
image: { width, height, checksumSha256, byteSize },
|
|
56056
|
+
...original2 ? {
|
|
56057
|
+
original: {
|
|
56058
|
+
width: original2.original.width,
|
|
56059
|
+
height: original2.original.height,
|
|
56060
|
+
checksumSha256: original2.original.checksumSha256,
|
|
56061
|
+
byteSize: original2.original.byteSize
|
|
56062
|
+
}
|
|
56063
|
+
} : {}
|
|
56064
|
+
};
|
|
55429
56065
|
}
|
|
55430
56066
|
if (processor === "TRANSCRIBE_EXTERNAL_OPENAI" && evidence2.processor === processor)
|
|
55431
56067
|
return inspectDeviceOpenAiTranscript(evidence2, read);
|
|
@@ -55450,18 +56086,34 @@ async function inspectProcessorMedia(recipe, evidence2, read, tools, signal, com
|
|
|
55450
56086
|
...sound ? { sound: { checksumSha256: digest13(sound), byteSize: sound.byteLength } } : {}
|
|
55451
56087
|
};
|
|
55452
56088
|
}
|
|
55453
|
-
if (processor === "IMPORTED_VISUAL_NORMALIZE" && evidence2.processor === processor)
|
|
55454
|
-
|
|
55455
|
-
|
|
55456
|
-
|
|
55457
|
-
|
|
55458
|
-
|
|
55459
|
-
|
|
55460
|
-
|
|
55461
|
-
|
|
55462
|
-
|
|
55463
|
-
|
|
55464
|
-
|
|
56089
|
+
if (processor === "IMPORTED_VISUAL_NORMALIZE" && evidence2.processor === processor) {
|
|
56090
|
+
const video = await read(0), poster2 = await read(1);
|
|
56091
|
+
if (recipe.request.schemaVersion === 2 && evidence2.receipt.schemaVersion === 2)
|
|
56092
|
+
return {
|
|
56093
|
+
processor,
|
|
56094
|
+
...await inspectPreserveImportedVisualReadback(
|
|
56095
|
+
recipe.request,
|
|
56096
|
+
evidence2.receipt,
|
|
56097
|
+
video,
|
|
56098
|
+
poster2,
|
|
56099
|
+
tools,
|
|
56100
|
+
signal
|
|
56101
|
+
)
|
|
56102
|
+
};
|
|
56103
|
+
if (recipe.request.schemaVersion === 1 && evidence2.receipt.schemaVersion === 1)
|
|
56104
|
+
return {
|
|
56105
|
+
processor,
|
|
56106
|
+
...await inspectImportedVisualReadback(
|
|
56107
|
+
recipe.request,
|
|
56108
|
+
evidence2.receipt,
|
|
56109
|
+
video,
|
|
56110
|
+
poster2,
|
|
56111
|
+
tools,
|
|
56112
|
+
signal
|
|
56113
|
+
)
|
|
56114
|
+
};
|
|
56115
|
+
return runtimeError("PROCESSOR_EVIDENCE_INVALID");
|
|
56116
|
+
}
|
|
55465
56117
|
if (processor === "SOURCE_SYNC_AUDIO" && evidence2.processor === processor)
|
|
55466
56118
|
return { processor, provenance: inspectSourceSyncReadback(await read(0), evidence2.provenance) };
|
|
55467
56119
|
if ((processor === "SPEECH_SYNTHESIZE" || processor === "SPEECH_SYNTHESIZE_CPU") && evidence2.processor === processor) {
|
|
@@ -55529,21 +56181,23 @@ async function inspectReadOnlyProcessor(recipe, read, tools, signal, whisper) {
|
|
|
55529
56181
|
if (processor === "IMPORT_ORIGINAL")
|
|
55530
56182
|
return {
|
|
55531
56183
|
processor,
|
|
55532
|
-
metadata: (
|
|
56184
|
+
metadata: (recipe.command.input.geometryProfile === PRESERVE_VISUAL_PROFILE_ID ? await inspectImportedVisualSource(
|
|
56185
|
+
recipe.command.input.source,
|
|
56186
|
+
bytes,
|
|
56187
|
+
signal,
|
|
56188
|
+
tools,
|
|
56189
|
+
PRESERVE_VISUAL_PROFILE_ID
|
|
56190
|
+
) : await inspectImportedVisualSource(recipe.command.input.source, bytes, signal, tools)).source
|
|
55533
56191
|
};
|
|
55534
56192
|
const { contentType } = recipe.metadata;
|
|
55535
56193
|
if (contentType === "video/mp4") {
|
|
55536
|
-
const
|
|
55537
|
-
|
|
55538
|
-
|
|
55539
|
-
|
|
55540
|
-
|
|
55541
|
-
|
|
55542
|
-
|
|
55543
|
-
bytes,
|
|
55544
|
-
signal,
|
|
55545
|
-
tools
|
|
55546
|
-
);
|
|
56194
|
+
const input3 = {
|
|
56195
|
+
contentType,
|
|
56196
|
+
checksumSha256,
|
|
56197
|
+
byteSize,
|
|
56198
|
+
executionClass: "LIVE"
|
|
56199
|
+
};
|
|
56200
|
+
const { source: video } = recipe.metadata.videoGeometryProfile === PRESERVE_VISUAL_PROFILE_ID ? await inspectImportedVisualSource(input3, bytes, signal, tools, PRESERVE_VISUAL_PROFILE_ID) : await inspectImportedVisualSource(input3, bytes, signal, tools);
|
|
55547
56201
|
return { processor, validated: { checksumSha256, byteSize, ...video.geometry, video } };
|
|
55548
56202
|
}
|
|
55549
56203
|
if (contentType === "image/png" || contentType === "image/jpeg" || contentType === "image/webp")
|
|
@@ -55565,7 +56219,7 @@ init_private_state();
|
|
|
55565
56219
|
|
|
55566
56220
|
// apps/local-runtime/src/preview/processor-tools.ts
|
|
55567
56221
|
init_src3();
|
|
55568
|
-
|
|
56222
|
+
init_identity4();
|
|
55569
56223
|
init_error();
|
|
55570
56224
|
import { isAbsolute as isAbsolute17 } from "node:path";
|
|
55571
56225
|
async function verifyProcessorTools(assignment, tools, cpuSpeechTools, signal = AbortSignal.timeout(12e3)) {
|
|
@@ -55581,9 +56235,10 @@ async function verifyProcessorTools(assignment, tools, cpuSpeechTools, signal =
|
|
|
55581
56235
|
init_zod();
|
|
55582
56236
|
init_local_execution();
|
|
55583
56237
|
init_src3();
|
|
55584
|
-
|
|
56238
|
+
init_identity4();
|
|
55585
56239
|
init_error();
|
|
55586
56240
|
init_executions();
|
|
56241
|
+
init_imported_visual();
|
|
55587
56242
|
var prepared = external_exports.strictObject({
|
|
55588
56243
|
request: TenantProcessorReportRequestSchema,
|
|
55589
56244
|
tickets: external_exports.array(MediaObjectTicketSchema).max(362)
|
|
@@ -55634,17 +56289,19 @@ async function inspectLibraryProcessor(runtime, cloud, recipe, binding, tools, r
|
|
|
55634
56289
|
let inspection;
|
|
55635
56290
|
if (ref5.contentType === "video/mp4") {
|
|
55636
56291
|
const executionClass = recipe.processor === "LOCAL_MEDIA_PUBLISH" && recipe.destination.kind === "ORIGINAL" ? recipe.destination.command.input.source.executionClass : "LIVE";
|
|
55637
|
-
const
|
|
55638
|
-
|
|
55639
|
-
|
|
55640
|
-
|
|
55641
|
-
|
|
55642
|
-
|
|
55643
|
-
|
|
56292
|
+
const source5 = {
|
|
56293
|
+
contentType: "video/mp4",
|
|
56294
|
+
checksumSha256: ref5.checksumSha256,
|
|
56295
|
+
byteSize: ref5.byteSize,
|
|
56296
|
+
executionClass
|
|
56297
|
+
};
|
|
56298
|
+
const result2 = localLibraryVideoGeometry(recipe) === PRESERVE_VISUAL_PROFILE_ID ? await inspectImportedVisualSource(
|
|
56299
|
+
source5,
|
|
55644
56300
|
bytes,
|
|
55645
56301
|
signal,
|
|
55646
|
-
tools
|
|
55647
|
-
|
|
56302
|
+
tools,
|
|
56303
|
+
PRESERVE_VISUAL_PROFILE_ID
|
|
56304
|
+
) : await inspectImportedVisualSource(source5, bytes, signal, tools);
|
|
55648
56305
|
inspection = { kind: "VIDEO", metadata: result2.source };
|
|
55649
56306
|
} else if (ref5.contentType === "audio/wav") {
|
|
55650
56307
|
inspection = {
|
|
@@ -55822,7 +56479,7 @@ async function resolveProcessorClaim(cloud, scope8, requestId3, signal) {
|
|
|
55822
56479
|
|
|
55823
56480
|
// apps/local-runtime/src/preview/processor.ts
|
|
55824
56481
|
var stage = external_exports.strictObject({ ticket: MediaObjectTicketSchema, uploaded: external_exports.boolean() });
|
|
55825
|
-
var
|
|
56482
|
+
var readback2 = external_exports.strictObject({
|
|
55826
56483
|
request: TenantProcessorReportRequestSchema,
|
|
55827
56484
|
tickets: external_exports.array(MediaObjectTicketSchema).max(362)
|
|
55828
56485
|
});
|
|
@@ -55880,8 +56537,14 @@ async function stepTenantProcessor(runtime, cloud, tools, scope8, lane, signal,
|
|
|
55880
56537
|
const { pathFor, finish, finishFailure, finishProviderOutcome, fencedOrWaiting } = terminal;
|
|
55881
56538
|
if (entry.invalidSource) return finishFailure();
|
|
55882
56539
|
if (entry.report) {
|
|
55883
|
-
|
|
55884
|
-
|
|
56540
|
+
try {
|
|
56541
|
+
const prior = await terminal.readReceipt();
|
|
56542
|
+
if (prior) return finish(prior);
|
|
56543
|
+
} catch (error62) {
|
|
56544
|
+
if (assignment.recipe.processor === "IMPORT_ORIGINAL" && error62 instanceof CloudRequestError && error62.status === 403 && error62.code === "FORBIDDEN" && error62.outcome === "REFUSED")
|
|
56545
|
+
return terminal.archiveFence(() => recordTaskFailure(journal, binding, error62));
|
|
56546
|
+
throw error62;
|
|
56547
|
+
}
|
|
55885
56548
|
}
|
|
55886
56549
|
const abort = new AbortController();
|
|
55887
56550
|
const owned = AbortSignal.any([signal, abort.signal, AbortSignal.timeout(6e5)]);
|
|
@@ -55968,7 +56631,7 @@ async function stepTenantProcessor(runtime, cloud, tools, scope8, lane, signal,
|
|
|
55968
56631
|
const { request: request2, tickets: tickets2 } = await cloud.processor(
|
|
55969
56632
|
"prepare",
|
|
55970
56633
|
{ ...binding, requestId: entry.reportRequestId, outputVersionIds: [] },
|
|
55971
|
-
|
|
56634
|
+
readback2,
|
|
55972
56635
|
owned
|
|
55973
56636
|
);
|
|
55974
56637
|
if (fingerprint2(bindingFor(request2)) !== fingerprint2(binding) || request2.requestId !== entry.reportRequestId || request2.outputs.length || tickets2.length || fingerprint2(request2.work) !== binding.workFingerprint)
|
|
@@ -56060,7 +56723,7 @@ async function stepTenantProcessor(runtime, cloud, tools, scope8, lane, signal,
|
|
|
56060
56723
|
requestId: entry.reportRequestId,
|
|
56061
56724
|
outputVersionIds: versions.map((v) => v.versionId)
|
|
56062
56725
|
},
|
|
56063
|
-
|
|
56726
|
+
readback2,
|
|
56064
56727
|
owned
|
|
56065
56728
|
);
|
|
56066
56729
|
if (fingerprint2(bindingFor(request)) !== fingerprint2(binding) || request.requestId !== entry.reportRequestId || fingerprint2(request.outputs) !== fingerprint2(versions) || fingerprint2(tickets.map((ticket) => ticket.object)) !== fingerprint2(versions) || fingerprint2(request.work) !== binding.workFingerprint)
|
|
@@ -56117,7 +56780,7 @@ init_processor_checkpoint();
|
|
|
56117
56780
|
|
|
56118
56781
|
// apps/local-runtime/src/preview/storage-capacity.ts
|
|
56119
56782
|
import { lstat as lstat7, opendir as opendir6, statfs as statfs3 } from "node:fs/promises";
|
|
56120
|
-
import { join as
|
|
56783
|
+
import { join as join54 } from "node:path";
|
|
56121
56784
|
async function fileSize(path) {
|
|
56122
56785
|
try {
|
|
56123
56786
|
const info = await lstat7(path);
|
|
@@ -56146,10 +56809,10 @@ async function previewDiskUsage(root, quota, signal) {
|
|
|
56146
56809
|
};
|
|
56147
56810
|
for (const name2 of ["cache", "staging"]) {
|
|
56148
56811
|
signal.throwIfAborted();
|
|
56149
|
-
const directory =
|
|
56812
|
+
const directory = join54(root, name2);
|
|
56150
56813
|
for await (const entry of await opendir6(directory)) {
|
|
56151
56814
|
signal.throwIfAborted();
|
|
56152
|
-
batch.push(
|
|
56815
|
+
batch.push(join54(directory, entry.name));
|
|
56153
56816
|
if (batch.length === 8 && !await measureBatch()) return null;
|
|
56154
56817
|
}
|
|
56155
56818
|
}
|
|
@@ -56157,7 +56820,7 @@ async function previewDiskUsage(root, quota, signal) {
|
|
|
56157
56820
|
}
|
|
56158
56821
|
|
|
56159
56822
|
// apps/local-runtime/src/preview/local-terminal-recovery.ts
|
|
56160
|
-
|
|
56823
|
+
init_identity4();
|
|
56161
56824
|
init_error();
|
|
56162
56825
|
init_executions();
|
|
56163
56826
|
init_requests();
|
|
@@ -56736,7 +57399,7 @@ import { resolve as resolve8 } from "node:path";
|
|
|
56736
57399
|
// apps/local-runtime/src/lifecycle/serve.ts
|
|
56737
57400
|
init_src();
|
|
56738
57401
|
import { homedir as homedir2 } from "node:os";
|
|
56739
|
-
import { join as
|
|
57402
|
+
import { join as join59, resolve as resolve4 } from "node:path";
|
|
56740
57403
|
init_error();
|
|
56741
57404
|
init_private_state();
|
|
56742
57405
|
|
|
@@ -56922,14 +57585,14 @@ init_error();
|
|
|
56922
57585
|
import { createServer } from "node:http";
|
|
56923
57586
|
import { createConnection } from "node:net";
|
|
56924
57587
|
import { chmod, lstat as lstat8, unlink as unlink9 } from "node:fs/promises";
|
|
56925
|
-
import { join as
|
|
57588
|
+
import { join as join57 } from "node:path";
|
|
56926
57589
|
|
|
56927
57590
|
// apps/local-runtime/src/review/discovery.ts
|
|
56928
57591
|
init_local_execution();
|
|
56929
57592
|
import { homedir } from "node:os";
|
|
56930
|
-
import { join as
|
|
57593
|
+
import { join as join56 } from "node:path";
|
|
56931
57594
|
import { readdir as readdir2, open as open16, realpath as realpath11 } from "node:fs/promises";
|
|
56932
|
-
import { createHash as
|
|
57595
|
+
import { createHash as createHash47 } from "node:crypto";
|
|
56933
57596
|
import { constants as constants11 } from "node:fs";
|
|
56934
57597
|
async function discoverInstalledAgent(db, selected) {
|
|
56935
57598
|
const target2 = {
|
|
@@ -56941,21 +57604,21 @@ async function discoverInstalledAgent(db, selected) {
|
|
|
56941
57604
|
}[process.platform + "-" + process.arch];
|
|
56942
57605
|
const owner = homedir(), executable3 = process.platform === "win32" ? "codex.exe" : "codex";
|
|
56943
57606
|
const roots = [
|
|
56944
|
-
|
|
57607
|
+
join56(owner, ".local/lib/node_modules"),
|
|
56945
57608
|
"/usr/local/lib/node_modules",
|
|
56946
57609
|
"/opt/homebrew/lib/node_modules"
|
|
56947
57610
|
];
|
|
56948
57611
|
try {
|
|
56949
|
-
for (const version4 of (await readdir2(
|
|
56950
|
-
roots.push(
|
|
57612
|
+
for (const version4 of (await readdir2(join56(owner, ".nvm/versions/node"))).filter((n) => /^v\d+\.\d+\.\d+$/.test(n)).sort().reverse().slice(0, 8))
|
|
57613
|
+
roots.push(join56(owner, ".nvm/versions/node", version4, "lib/node_modules"));
|
|
56951
57614
|
} catch {
|
|
56952
57615
|
}
|
|
56953
57616
|
const paths = selected ? [selected] : [
|
|
56954
|
-
|
|
57617
|
+
join56(owner, ".local/bin", executable3),
|
|
56955
57618
|
"/Applications/Codex.app/Contents/Resources/codex",
|
|
56956
57619
|
...roots.flatMap((root) => [
|
|
56957
|
-
|
|
56958
|
-
|
|
57620
|
+
join56(root, "@openai/codex/vendor", target2 ?? "unavailable", "codex", executable3),
|
|
57621
|
+
join56(
|
|
56959
57622
|
root,
|
|
56960
57623
|
"@openai/codex/node_modules/@openai",
|
|
56961
57624
|
"codex-" + process.platform + "-" + process.arch,
|
|
@@ -56978,7 +57641,7 @@ async function discoverInstalledAgent(db, selected) {
|
|
|
56978
57641
|
header.toString("hex")
|
|
56979
57642
|
) && header.subarray(0, 2).toString("hex") !== "4d5a")
|
|
56980
57643
|
continue;
|
|
56981
|
-
const hash10 =
|
|
57644
|
+
const hash10 = createHash47("sha256");
|
|
56982
57645
|
for await (const bytes of f.createReadStream({ autoClose: false, start: 0, end: s.size - 1 }))
|
|
56983
57646
|
hash10.update(bytes);
|
|
56984
57647
|
const binaryDigest2 = hash10.digest("hex"), output3 = (await inspectAgentCommand(binary, ["--version"], {
|
|
@@ -57218,7 +57881,15 @@ async function serveRuntime(runtime) {
|
|
|
57218
57881
|
break;
|
|
57219
57882
|
case "runtime.inventory":
|
|
57220
57883
|
if (!session.owner) runtimeError("FORBIDDEN");
|
|
57221
|
-
|
|
57884
|
+
try {
|
|
57885
|
+
data = await runtime.inventory(input3.call.includeProviderWork);
|
|
57886
|
+
} catch (error62) {
|
|
57887
|
+
if (input3.call.includeProviderWork && (error62 instanceof external_exports.ZodError || error62 instanceof LocalRuntimeError && ["PROCESSOR_RECEIPT_INVALID", "PROCESSOR_ASSIGNMENT_INVALID"].includes(
|
|
57888
|
+
error62.code
|
|
57889
|
+
)))
|
|
57890
|
+
runtimeError("PROVIDER_INVENTORY_INVALID");
|
|
57891
|
+
throw error62;
|
|
57892
|
+
}
|
|
57222
57893
|
break;
|
|
57223
57894
|
case "session.issue": {
|
|
57224
57895
|
if (!session.owner) runtimeError("FORBIDDEN");
|
|
@@ -57314,7 +57985,7 @@ async function serveRuntime(runtime) {
|
|
|
57314
57985
|
server.requestTimeout = 5e3;
|
|
57315
57986
|
server.headersTimeout = 2e3;
|
|
57316
57987
|
server.keepAliveTimeout = 500;
|
|
57317
|
-
const cookiePath =
|
|
57988
|
+
const cookiePath = join57(runtime.journal.root, "control-token");
|
|
57318
57989
|
let pipe2;
|
|
57319
57990
|
let closing;
|
|
57320
57991
|
function close() {
|
|
@@ -57359,13 +58030,13 @@ async function serveRuntime(runtime) {
|
|
|
57359
58030
|
// apps/local-runtime/src/lifecycle/login.ts
|
|
57360
58031
|
init_src();
|
|
57361
58032
|
init_private_state();
|
|
57362
|
-
|
|
58033
|
+
init_identity4();
|
|
57363
58034
|
init_error();
|
|
57364
58035
|
import { createConnection as createConnection2 } from "node:net";
|
|
57365
|
-
import { join as
|
|
58036
|
+
import { join as join58 } from "node:path";
|
|
57366
58037
|
import { realpath as realpath12 } from "node:fs/promises";
|
|
57367
58038
|
async function readApproval(home, approved) {
|
|
57368
|
-
const bytes = await readPrivate(
|
|
58039
|
+
const bytes = await readPrivate(join58(home, runtimeLoginApprovalFile), 32768);
|
|
57369
58040
|
return digest13(bytes) === approved ? parseRuntimeLoginApproval(bytes) : null;
|
|
57370
58041
|
}
|
|
57371
58042
|
async function hasListener(stateDirectory) {
|
|
@@ -57434,7 +58105,7 @@ async function serve(args) {
|
|
|
57434
58105
|
flags.set(flag, value2);
|
|
57435
58106
|
}
|
|
57436
58107
|
}
|
|
57437
|
-
const stateDirectory = flags.has("--state-dir") ? resolve4(flags.get("--state-dir")) :
|
|
58108
|
+
const stateDirectory = flags.has("--state-dir") ? resolve4(flags.get("--state-dir")) : join59(homedir2(), ".nativestudio", "runtime");
|
|
57438
58109
|
const tools = flags.has("--tools-config") ? DeviceRuntimeConfigurationSchema.shape.tools.parse(
|
|
57439
58110
|
JSON.parse((await readPrivate(resolve4(flags.get("--tools-config")), 32768)).toString())
|
|
57440
58111
|
) : void 0;
|
|
@@ -57467,7 +58138,7 @@ async function serve(args) {
|
|
|
57467
58138
|
|
|
57468
58139
|
// apps/local-runtime/src/entry.ts
|
|
57469
58140
|
init_local_execution();
|
|
57470
|
-
|
|
58141
|
+
init_identity4();
|
|
57471
58142
|
init_error();
|
|
57472
58143
|
init_src3();
|
|
57473
58144
|
try {
|