@transloadit/zod 7.0.0 → 7.1.1
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/README.md +12 -2
- package/dist/v3/builtinTemplates.d.ts +40 -0
- package/dist/v3/builtinTemplates.d.ts.map +1 -1
- package/dist/v3/builtinTemplates.js +29 -0
- package/dist/v3/responseErrors/DocumentConvertRobot.d.ts +17 -0
- package/dist/v3/responseErrors/DocumentConvertRobot.d.ts.map +1 -0
- package/dist/v3/responseErrors/DocumentConvertRobot.js +16 -0
- package/dist/v3/robots/document-convert.d.ts.map +1 -1
- package/dist/v3/robots/document-convert.js +19 -0
- package/dist/v3/robots/document-extract.d.ts +32 -20
- package/dist/v3/robots/document-extract.d.ts.map +1 -1
- package/dist/v3/robots/document-extract.js +51 -1
- package/dist/v3/robots/html-convert.d.ts.map +1 -1
- package/dist/v3/robots/html-convert.js +1 -0
- package/dist/v3/robots/speech-transcribe.d.ts +14 -0
- package/dist/v3/robots/speech-transcribe.d.ts.map +1 -1
- package/dist/v3/robots/speech-transcribe.js +42 -2
- package/dist/v3/robots/video-split.d.ts +11 -0
- package/dist/v3/robots/video-split.d.ts.map +1 -1
- package/dist/v3/robots/video-split.js +2 -1
- package/dist/v3/robots/video-subtitle.d.ts +24 -24
- package/dist/v3/robots/video-subtitle.d.ts.map +1 -1
- package/dist/v3/robots/video-subtitle.js +12 -11
- package/dist/v3/robots/video-thumbs.d.ts +36 -36
- package/dist/v3/robots/video-thumbs.d.ts.map +1 -1
- package/dist/v3/robots/video-thumbs.js +8 -3
- package/dist/v3/template.d.ts.map +1 -1
- package/dist/v3/template.js +5 -2
- package/dist/v4/assemblyStatus.d.ts +2 -2
- package/dist/v4/builtinTemplates.d.ts +22 -0
- package/dist/v4/builtinTemplates.d.ts.map +1 -1
- package/dist/v4/builtinTemplates.js +29 -0
- package/dist/v4/responseErrors/DocumentConvertRobot.d.ts +17 -0
- package/dist/v4/responseErrors/DocumentConvertRobot.d.ts.map +1 -0
- package/dist/v4/responseErrors/DocumentConvertRobot.js +16 -0
- package/dist/v4/robots/_instructions-primitives.d.ts.map +1 -1
- package/dist/v4/robots/_instructions-primitives.js +5 -0
- package/dist/v4/robots/document-convert.d.ts.map +1 -1
- package/dist/v4/robots/document-convert.js +19 -0
- package/dist/v4/robots/document-extract.d.ts +12 -0
- package/dist/v4/robots/document-extract.d.ts.map +1 -1
- package/dist/v4/robots/document-extract.js +51 -1
- package/dist/v4/robots/html-convert.d.ts.map +1 -1
- package/dist/v4/robots/html-convert.js +1 -0
- package/dist/v4/robots/speech-transcribe.d.ts +6 -0
- package/dist/v4/robots/speech-transcribe.d.ts.map +1 -1
- package/dist/v4/robots/speech-transcribe.js +42 -2
- package/dist/v4/robots/video-split.d.ts +5 -0
- package/dist/v4/robots/video-split.d.ts.map +1 -1
- package/dist/v4/robots/video-split.js +2 -1
- package/dist/v4/robots/video-subtitle.d.ts +12 -12
- package/dist/v4/robots/video-subtitle.d.ts.map +1 -1
- package/dist/v4/robots/video-subtitle.js +15 -17
- package/dist/v4/robots/video-thumbs.d.ts +12 -12
- package/dist/v4/robots/video-thumbs.d.ts.map +1 -1
- package/dist/v4/robots/video-thumbs.js +10 -5
- package/dist/v4/template.d.ts.map +1 -1
- package/dist/v4/template.js +5 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
# @transloadit/zod
|
|
2
2
|
|
|
3
|
-
**Stability:**
|
|
3
|
+
**Stability:** Exported names, helper functions and supported Zod versions follow strict SemVer.
|
|
4
|
+
API contract types and schemas follow API2 and can change in minor releases, including
|
|
5
|
+
type-breaking updates. See the
|
|
6
|
+
[versioning policy](https://github.com/transloadit/node-sdk/blob/main/CONTRIBUTING.md#versioning-policy).
|
|
7
|
+
|
|
8
|
+
- Commit your lockfile and type-check dependency update PRs.
|
|
9
|
+
- Use `~` ranges for stable contract types within a minor; patch releases do not change contract
|
|
10
|
+
types. Use `^` to follow the API as it evolves.
|
|
11
|
+
- Use input types for instructions you write, such as `AssemblyInstructionsInput`; narrow fields
|
|
12
|
+
from responses and parsed output before use (`null`, `undefined`, unknown strings).
|
|
13
|
+
- Do not depend on Zod internals such as wrapper classes, `.shape` or parse-time defaults.
|
|
4
14
|
|
|
5
15
|
Exports Zod schemas derived from Transloadit types.
|
|
6
16
|
|
|
7
|
-
For the
|
|
17
|
+
For the SDK client, use `@transloadit/node` or the unscoped `transloadit` package.
|
|
8
18
|
|
|
9
19
|
## Migrating schema consumers
|
|
10
20
|
|
|
@@ -80,4 +80,44 @@ export declare const builtinTemplateDocsSchema: z.ZodArray<z.ZodObject<{
|
|
|
80
80
|
}[];
|
|
81
81
|
}>, "many">;
|
|
82
82
|
export type BuiltinTemplateDoc = z.infer<typeof builtinTemplateDocSchema>;
|
|
83
|
+
/** Standalone catalog JSON Schema, or null when a Builtin has no declared fields contract. */
|
|
84
|
+
export declare const builtinTemplateFieldsSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
85
|
+
/**
|
|
86
|
+
* Runtime catalog projection used by Builtin clients. API2 supplies descriptions, field schemas
|
|
87
|
+
* and defaults; absent and null schemas remain distinct, and neither declares a usable contract.
|
|
88
|
+
*/
|
|
89
|
+
export declare const builtinTemplateCatalogItemSchema: z.ZodObject<{
|
|
90
|
+
id: z.ZodString;
|
|
91
|
+
description: z.ZodOptional<z.ZodString>;
|
|
92
|
+
fields_schema: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
93
|
+
content: z.ZodObject<{
|
|
94
|
+
fields: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
fields: Record<string, unknown>;
|
|
97
|
+
}, {
|
|
98
|
+
fields?: Record<string, unknown> | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
content: {
|
|
102
|
+
fields: Record<string, unknown>;
|
|
103
|
+
};
|
|
104
|
+
id: string;
|
|
105
|
+
description?: string | undefined;
|
|
106
|
+
fields_schema?: Record<string, unknown> | null | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
content: {
|
|
109
|
+
fields?: Record<string, unknown> | undefined;
|
|
110
|
+
};
|
|
111
|
+
id: string;
|
|
112
|
+
description?: string | undefined;
|
|
113
|
+
fields_schema?: Record<string, unknown> | null | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
/** Runtime catalog item after missing fields have been normalized to an empty object. */
|
|
116
|
+
export type BuiltinTemplateCatalogItem = z.infer<typeof builtinTemplateCatalogItemSchema>;
|
|
117
|
+
/**
|
|
118
|
+
* MCP channel approvals: exact reviewed versions and temporarily excluded field values.
|
|
119
|
+
* Membership is explicit; a catalog schema, a new Builtin version, or Storage eligibility does
|
|
120
|
+
* not grant MCP approval. Keep runtime descriptions, schemas and defaults in API2's catalog.
|
|
121
|
+
*/
|
|
122
|
+
export declare const mcpBuiltinTemplateManifest: Readonly<Record<string, Readonly<Record<string, readonly string[]>>>>;
|
|
83
123
|
//# sourceMappingURL=builtinTemplates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinTemplates.d.ts","sourceRoot":"","sources":["../../src/v3/builtinTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiB1B,CAAA;AAEX,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAoC,CAAA;AAE1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"builtinTemplates.d.ts","sourceRoot":"","sources":["../../src/v3/builtinTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiB1B,CAAA;AAEX,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAoC,CAAA;AAE1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,8FAA8F;AAC9F,eAAO,MAAM,2BAA2B,uDAA+C,CAAA;AAEvF;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAA;AAEF,yFAAyF;AACzF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAEzF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAC/C,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,CAY5D,CAAA"}
|
|
@@ -16,3 +16,32 @@ export const builtinTemplateDocSchema = z
|
|
|
16
16
|
})
|
|
17
17
|
.strict();
|
|
18
18
|
export const builtinTemplateDocsSchema = z.array(builtinTemplateDocSchema);
|
|
19
|
+
/** Standalone catalog JSON Schema, or null when a Builtin has no declared fields contract. */
|
|
20
|
+
export const builtinTemplateFieldsSchema = z.record(z.string(), z.unknown()).nullable();
|
|
21
|
+
/**
|
|
22
|
+
* Runtime catalog projection used by Builtin clients. API2 supplies descriptions, field schemas
|
|
23
|
+
* and defaults; absent and null schemas remain distinct, and neither declares a usable contract.
|
|
24
|
+
*/
|
|
25
|
+
export const builtinTemplateCatalogItemSchema = z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
description: z.string().optional(),
|
|
28
|
+
fields_schema: builtinTemplateFieldsSchema.optional(),
|
|
29
|
+
content: z.object({ fields: z.record(z.string(), z.unknown()).default({}) }),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* MCP channel approvals: exact reviewed versions and temporarily excluded field values.
|
|
33
|
+
* Membership is explicit; a catalog schema, a new Builtin version, or Storage eligibility does
|
|
34
|
+
* not grant MCP approval. Keep runtime descriptions, schemas and defaults in API2's catalog.
|
|
35
|
+
*/
|
|
36
|
+
export const mcpBuiltinTemplateManifest = {
|
|
37
|
+
'builtin/caption-video@0.0.1': {},
|
|
38
|
+
'builtin/capture-webpage@0.0.1': {},
|
|
39
|
+
'builtin/convert-to-pdf@0.0.1': {},
|
|
40
|
+
// Remove only after api2#9960 is deployed and its VP8/turbo output is verified.
|
|
41
|
+
'builtin/encode-video@0.0.1': { preset: ['webm'] },
|
|
42
|
+
'builtin/extract-text@0.0.1': {},
|
|
43
|
+
'builtin/prepare-image@0.0.1': {},
|
|
44
|
+
'builtin/remove-background@0.0.1': {},
|
|
45
|
+
'builtin/transcribe@0.0.1': {},
|
|
46
|
+
'builtin/video-covers@0.0.1': {},
|
|
47
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Public reason when diagnostics identify a service-side document-loading failure. */
|
|
2
|
+
export declare const documentConvertLoadInternalErrorReason = "LibreOffice could not load the document. Please contact support.";
|
|
3
|
+
/** Public reason for a load refusal without evidence of a service-side failure. */
|
|
4
|
+
export declare const documentConvertLoadUserErrorReason = "LibreOffice could not load the document. It may be damaged, password-protected, or in an unsupported format. If it opens elsewhere, please contact support.";
|
|
5
|
+
/** DocumentConvertRobot error payloads shared by runtime and the Assembly Status contract. */
|
|
6
|
+
export declare const documentConvertRobotErrors: {
|
|
7
|
+
readonly DOCUMENT_CONVERT_VALIDATION: {
|
|
8
|
+
readonly error: "DOCUMENT_CONVERT_VALIDATION";
|
|
9
|
+
readonly http_code: 400;
|
|
10
|
+
};
|
|
11
|
+
readonly DOCUMENT_CONVERT_UNSUPPORTED_CONVERSION: {
|
|
12
|
+
readonly error: "DOCUMENT_CONVERT_UNSUPPORTED_CONVERSION";
|
|
13
|
+
readonly http_code: 400;
|
|
14
|
+
readonly message: "The conversion from the input file's format to the desired output format is not supported.";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=DocumentConvertRobot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentConvertRobot.d.ts","sourceRoot":"","sources":["../../../src/v3/responseErrors/DocumentConvertRobot.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,sCAAsC,qEACiB,CAAA;AAEpE,mFAAmF;AACnF,eAAO,MAAM,kCAAkC,gKACgH,CAAA;AAE/J,8FAA8F;AAC9F,eAAO,MAAM,0BAA0B;;;;;;;;;;CAW7B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Public reason when diagnostics identify a service-side document-loading failure. */
|
|
2
|
+
export const documentConvertLoadInternalErrorReason = 'LibreOffice could not load the document. Please contact support.';
|
|
3
|
+
/** Public reason for a load refusal without evidence of a service-side failure. */
|
|
4
|
+
export const documentConvertLoadUserErrorReason = 'LibreOffice could not load the document. It may be damaged, password-protected, or in an unsupported format. If it opens elsewhere, please contact support.';
|
|
5
|
+
/** DocumentConvertRobot error payloads shared by runtime and the Assembly Status contract. */
|
|
6
|
+
export const documentConvertRobotErrors = {
|
|
7
|
+
DOCUMENT_CONVERT_VALIDATION: {
|
|
8
|
+
error: 'DOCUMENT_CONVERT_VALIDATION',
|
|
9
|
+
http_code: 400,
|
|
10
|
+
},
|
|
11
|
+
DOCUMENT_CONVERT_UNSUPPORTED_CONVERSION: {
|
|
12
|
+
error: 'DOCUMENT_CONVERT_UNSUPPORTED_CONVERSION',
|
|
13
|
+
http_code: 400,
|
|
14
|
+
message: "The conversion from the input file's format to the desired output format is not supported.",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-convert.d.ts","sourceRoot":"","sources":["../../../src/v3/robots/document-convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"document-convert.d.ts","sourceRoot":"","sources":["../../../src/v3/robots/document-convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAsB1B,4FAA4F;AAC5F,eAAO,MAAM,8BAA8B,iNAE1C,CAAA;AAQD,eAAO,MAAM,IAAI,EAAE,cA4ElB,CAAA;AAED,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgLxC,CAAA;AAEX,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,OAAO,sCAAsC,CAAC,KAAK,CACtC,CAAA;AAE3D,eAAO,MACa,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACxD,oDAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAElE,oEAAoE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EACrD,CAAA;AAEnB,KAAK,YAAY,GAAG,uBAAuB,CAAC,OAAO,eAAe,CAAC,CAAA;AAEnE,MAAM,MAAM,gCAAgC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AACrE,MAAM,MAAM,gDAAgD,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AAC3F,MAAM,MAAM,8CAA8C,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAA;AAChG,MAAM,MAAM,mDAAmD,GAC7D,YAAY,CAAC,qBAAqB,CAAC,CAAA;AACrC,MAAM,MAAM,8DAA8D,GACxE,YAAY,CAAC,4BAA4B,CAAC,CAAA;AAC5C,MAAM,MAAM,mEAAmE,GAC7E,YAAY,CAAC,2BAA2B,CAAC,CAAA"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
2
|
import { zodCaseInsensitiveEnum } from "../lib/zodInputSemantics.js";
|
|
3
|
+
import { documentConvertLoadInternalErrorReason, documentConvertLoadUserErrorReason, } from "../responseErrors/DocumentConvertRobot.js";
|
|
3
4
|
import { createProcessingExample, defineRobot, robotBase, robotDocumentProcessingMeta, robotUse, } from "./_instructions-primitives.js";
|
|
5
|
+
const transcriptSrtDocumentation = 'Timestamped JSON from `/speech/transcribe` with `"format": "json"` can be converted to SRT. ' +
|
|
6
|
+
'Set `"format": "srt"` here. JSON words are grouped into cues of up to three words, breaking ' +
|
|
7
|
+
'at sentence endings and pauses longer than 0.4 seconds. Casing and punctuation are preserved. ' +
|
|
8
|
+
'JSON input is limited to 32 MiB and is only supported for SRT output. ' +
|
|
9
|
+
'SRT-to-SRT copies the original cues unchanged.';
|
|
4
10
|
/** Accepts Playwright's paper-format case variants while publishing canonical spellings. */
|
|
5
11
|
export const documentConvertPdfFormatSchema = zodCaseInsensitiveEnum(z.enum(['A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'Ledger', 'Legal', 'Letter', 'Tabloid']));
|
|
12
|
+
const documentLoadErrorDocumentation = `
|
|
13
|
+
A generic LibreOffice load refusal returns \`USER_COMMAND_ERROR\` with the reason “${documentConvertLoadUserErrorReason}” This preserves the user error code for integrations without assuming the document is corrupt.
|
|
14
|
+
|
|
15
|
+
When diagnostics identify a problem in the conversion service, the load failure returns \`INTERNAL_COMMAND_ERROR\` with the reason “${documentConvertLoadInternalErrorReason}” Private diagnostics are not included in either response.
|
|
16
|
+
`;
|
|
6
17
|
export const meta = {
|
|
7
18
|
...robotDocumentProcessingMeta,
|
|
8
19
|
example_code: createProcessingExample('converted', '/document/convert', {
|
|
@@ -20,6 +31,10 @@ Using this <dfn>Robot</dfn>, you can bypass the issues that certain file types m
|
|
|
20
31
|
> ![Warning]
|
|
21
32
|
> A general rule of this <dfn>Robot</dfn> is that converting files into an alien format category will result in an error. For example, SRT files can be converted into the VTT format, but not to an image.
|
|
22
33
|
|
|
34
|
+
${documentLoadErrorDocumentation}
|
|
35
|
+
|
|
36
|
+
${transcriptSrtDocumentation}
|
|
37
|
+
|
|
23
38
|
The following file formats can be converted from:
|
|
24
39
|
|
|
25
40
|
- \`ai\`
|
|
@@ -89,6 +104,10 @@ Using this Robot, you can bypass the issues that certain file types may bring, b
|
|
|
89
104
|
> [!Warning]
|
|
90
105
|
> A general rule of this Robot is that converting files into an alien format category will result in an error. For example, SRT files can be converted into the VTT format (and vice versa), but not to an image.
|
|
91
106
|
|
|
107
|
+
${documentLoadErrorDocumentation}
|
|
108
|
+
|
|
109
|
+
${transcriptSrtDocumentation}
|
|
110
|
+
|
|
92
111
|
The following file formats can be converted from:
|
|
93
112
|
|
|
94
113
|
- \`ai\`
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { RobotDefinition, RobotMetaInput, RobotSchemaVariantTypes } from './_instructions-primitives.ts';
|
|
2
2
|
import { z } from 'zod/v3';
|
|
3
|
+
/** Validate OCR dependencies after interpolation-aware parsing at the Assembly Step boundary. */
|
|
4
|
+
export declare function refineDocumentExtractOcr(step: {
|
|
5
|
+
robot: string;
|
|
6
|
+
extract?: unknown;
|
|
7
|
+
text_method?: unknown;
|
|
8
|
+
ocr_provider?: unknown;
|
|
9
|
+
password?: unknown;
|
|
10
|
+
page_range?: unknown;
|
|
11
|
+
text_granularity?: unknown;
|
|
12
|
+
}, context: z.RefinementCtx, options?: {
|
|
13
|
+
allowInterpolation?: boolean;
|
|
14
|
+
}): void;
|
|
3
15
|
export declare const meta: RobotMetaInput;
|
|
4
16
|
export declare const robotDocumentExtractInstructionsSchema: z.ZodObject<{
|
|
5
17
|
interpolate: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodEnum<["true", "false"]>]>, boolean, boolean | "true" | "false">, z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodEnum<["true", "false"]>]>, boolean, boolean | "true" | "false">>]>>;
|
|
@@ -80,9 +92,9 @@ export declare const robotDocumentExtractInstructionsSchema: z.ZodObject<{
|
|
|
80
92
|
user_meta: Record<string, unknown>;
|
|
81
93
|
force_accept: boolean;
|
|
82
94
|
ignore_errors: string[];
|
|
95
|
+
text_granularity: "document" | "page";
|
|
83
96
|
text_method: "auto" | "native" | "ocr";
|
|
84
97
|
text_format: "json" | "txt";
|
|
85
|
-
text_granularity: "document" | "page";
|
|
86
98
|
image_format: "auto" | "jpg" | "png" | "original";
|
|
87
99
|
min_image_width: number;
|
|
88
100
|
min_image_height: number;
|
|
@@ -107,8 +119,8 @@ export declare const robotDocumentExtractInstructionsSchema: z.ZodObject<{
|
|
|
107
119
|
output_meta?: boolean | string[] | Record<string, boolean> | undefined;
|
|
108
120
|
queue?: "batch" | undefined;
|
|
109
121
|
password?: string | undefined;
|
|
110
|
-
page_range?: string | undefined;
|
|
111
122
|
ocr_provider?: "aws" | "gcp" | undefined;
|
|
123
|
+
page_range?: string | undefined;
|
|
112
124
|
}, {
|
|
113
125
|
robot: "/document/extract";
|
|
114
126
|
extract?: "text" | "images" | ("text" | "images")[] | undefined;
|
|
@@ -134,11 +146,11 @@ export declare const robotDocumentExtractInstructionsSchema: z.ZodObject<{
|
|
|
134
146
|
force_accept?: boolean | undefined;
|
|
135
147
|
ignore_errors?: boolean | ("meta" | "execute")[] | undefined;
|
|
136
148
|
password?: string | undefined;
|
|
137
|
-
text_method?: "auto" | "native" | "ocr" | undefined;
|
|
138
|
-
page_range?: string | undefined;
|
|
139
149
|
ocr_provider?: "aws" | "gcp" | undefined;
|
|
140
|
-
|
|
150
|
+
page_range?: string | undefined;
|
|
141
151
|
text_granularity?: "document" | "page" | undefined;
|
|
152
|
+
text_method?: "auto" | "native" | "ocr" | undefined;
|
|
153
|
+
text_format?: "json" | "txt" | undefined;
|
|
142
154
|
image_format?: "auto" | "jpg" | "png" | "original" | undefined;
|
|
143
155
|
min_image_width?: number | undefined;
|
|
144
156
|
min_image_height?: number | undefined;
|
|
@@ -224,9 +236,9 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
224
236
|
user_meta: Record<string, unknown>;
|
|
225
237
|
force_accept: boolean;
|
|
226
238
|
ignore_errors: string[];
|
|
239
|
+
text_granularity: "document" | "page";
|
|
227
240
|
text_method: "auto" | "native" | "ocr";
|
|
228
241
|
text_format: "json" | "txt";
|
|
229
|
-
text_granularity: "document" | "page";
|
|
230
242
|
image_format: "auto" | "jpg" | "png" | "original";
|
|
231
243
|
min_image_width: number;
|
|
232
244
|
min_image_height: number;
|
|
@@ -252,8 +264,8 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
252
264
|
output_meta?: boolean | string[] | Record<string, boolean> | undefined;
|
|
253
265
|
queue?: "batch" | undefined;
|
|
254
266
|
password?: string | undefined;
|
|
255
|
-
page_range?: string | undefined;
|
|
256
267
|
ocr_provider?: "aws" | "gcp" | undefined;
|
|
268
|
+
page_range?: string | undefined;
|
|
257
269
|
}, {
|
|
258
270
|
robot: "/document/extract";
|
|
259
271
|
extract?: "text" | "images" | ("text" | "images")[] | undefined;
|
|
@@ -279,11 +291,11 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
279
291
|
force_accept?: boolean | undefined;
|
|
280
292
|
ignore_errors?: boolean | ("meta" | "execute")[] | undefined;
|
|
281
293
|
password?: string | undefined;
|
|
282
|
-
text_method?: "auto" | "native" | "ocr" | undefined;
|
|
283
|
-
page_range?: string | undefined;
|
|
284
294
|
ocr_provider?: "aws" | "gcp" | undefined;
|
|
285
|
-
|
|
295
|
+
page_range?: string | undefined;
|
|
286
296
|
text_granularity?: "document" | "page" | undefined;
|
|
297
|
+
text_method?: "auto" | "native" | "ocr" | undefined;
|
|
298
|
+
text_format?: "json" | "txt" | undefined;
|
|
287
299
|
image_format?: "auto" | "jpg" | "png" | "original" | undefined;
|
|
288
300
|
min_image_width?: number | undefined;
|
|
289
301
|
min_image_height?: number | undefined;
|
|
@@ -367,9 +379,9 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
367
379
|
user_meta: Record<string, unknown>;
|
|
368
380
|
force_accept: string | boolean;
|
|
369
381
|
ignore_errors: string | string[];
|
|
382
|
+
text_granularity: string;
|
|
370
383
|
text_method: string;
|
|
371
384
|
text_format: string;
|
|
372
|
-
text_granularity: string;
|
|
373
385
|
image_format: string;
|
|
374
386
|
min_image_width: string | number;
|
|
375
387
|
min_image_height: string | number;
|
|
@@ -394,8 +406,8 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
394
406
|
output_meta?: string | boolean | string[] | Record<string, string | boolean> | undefined;
|
|
395
407
|
queue?: string | undefined;
|
|
396
408
|
password?: string | undefined;
|
|
397
|
-
page_range?: string | undefined;
|
|
398
409
|
ocr_provider?: string | undefined;
|
|
410
|
+
page_range?: string | undefined;
|
|
399
411
|
}, {
|
|
400
412
|
robot: "/document/extract";
|
|
401
413
|
extract?: string | string[] | undefined;
|
|
@@ -421,11 +433,11 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
421
433
|
force_accept?: string | boolean | undefined;
|
|
422
434
|
ignore_errors?: string | boolean | ("meta" | "execute")[] | undefined;
|
|
423
435
|
password?: string | undefined;
|
|
424
|
-
text_method?: string | undefined;
|
|
425
|
-
page_range?: string | undefined;
|
|
426
436
|
ocr_provider?: string | undefined;
|
|
427
|
-
|
|
437
|
+
page_range?: string | undefined;
|
|
428
438
|
text_granularity?: string | undefined;
|
|
439
|
+
text_method?: string | undefined;
|
|
440
|
+
text_format?: string | undefined;
|
|
429
441
|
image_format?: string | undefined;
|
|
430
442
|
min_image_width?: string | number | undefined;
|
|
431
443
|
min_image_height?: string | number | undefined;
|
|
@@ -508,9 +520,9 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
508
520
|
user_meta: Record<string, unknown>;
|
|
509
521
|
force_accept: string | boolean;
|
|
510
522
|
ignore_errors: string | string[];
|
|
523
|
+
text_granularity: string;
|
|
511
524
|
text_method: string;
|
|
512
525
|
text_format: string;
|
|
513
|
-
text_granularity: string;
|
|
514
526
|
image_format: string;
|
|
515
527
|
min_image_width: string | number;
|
|
516
528
|
min_image_height: string | number;
|
|
@@ -536,8 +548,8 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
536
548
|
output_meta?: string | boolean | string[] | Record<string, string | boolean> | undefined;
|
|
537
549
|
queue?: string | undefined;
|
|
538
550
|
password?: string | undefined;
|
|
539
|
-
page_range?: string | undefined;
|
|
540
551
|
ocr_provider?: string | undefined;
|
|
552
|
+
page_range?: string | undefined;
|
|
541
553
|
}, {
|
|
542
554
|
robot: "/document/extract";
|
|
543
555
|
extract?: string | string[] | undefined;
|
|
@@ -563,11 +575,11 @@ export declare const robotDocumentExtractInstructionsWithHiddenFieldsSchema: z.Z
|
|
|
563
575
|
force_accept?: string | boolean | undefined;
|
|
564
576
|
ignore_errors?: string | boolean | ("meta" | "execute")[] | undefined;
|
|
565
577
|
password?: string | undefined;
|
|
566
|
-
text_method?: string | undefined;
|
|
567
|
-
page_range?: string | undefined;
|
|
568
578
|
ocr_provider?: string | undefined;
|
|
569
|
-
|
|
579
|
+
page_range?: string | undefined;
|
|
570
580
|
text_granularity?: string | undefined;
|
|
581
|
+
text_method?: string | undefined;
|
|
582
|
+
text_format?: string | undefined;
|
|
571
583
|
image_format?: string | undefined;
|
|
572
584
|
min_image_width?: string | number | undefined;
|
|
573
585
|
min_image_height?: string | number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-extract.d.ts","sourceRoot":"","sources":["../../../src/v3/robots/document-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"document-extract.d.ts","sourceRoot":"","sources":["../../../src/v3/robots/document-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAmB1B,iGAAiG;AACjG,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IACJ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,EACD,OAAO,EAAE,CAAC,CAAC,aAA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,qBAAqB,CAAC,CAAA;AAChG,MAAM,MAAM,mDAAmD,GAC7D,YAAY,CAAC,qBAAqB,CAAC,CAAA;AACrC,MAAM,MAAM,8DAA8D,GACxE,YAAY,CAAC,4BAA4B,CAAC,CAAA;AAC5C,MAAM,MAAM,mEAAmE,GAC7E,YAAY,CAAC,2BAA2B,CAAC,CAAA"}
|
|
@@ -1,12 +1,62 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
2
|
import { ecmaWhitespaceCharacterClass } from "../lib/zodInputSemantics.js";
|
|
3
|
-
import { createProcessingExample, defineRobot, robotBase, robotDocumentProcessingMeta, robotUse, } from "./_instructions-primitives.js";
|
|
3
|
+
import { createProcessingExample, defineRobot, interpolationSchemaFull, robotBase, robotDocumentProcessingMeta, robotUse, } from "./_instructions-primitives.js";
|
|
4
4
|
const extractTargets = z.enum(['text', 'images']);
|
|
5
5
|
const imageFormats = z.enum(['auto', 'original', 'png', 'jpg']);
|
|
6
6
|
const ocrProviders = z.enum(['aws', 'gcp']);
|
|
7
7
|
const textFormats = z.enum(['txt', 'json']);
|
|
8
8
|
const textGranularities = z.enum(['document', 'page']);
|
|
9
9
|
const textMethods = z.enum(['native', 'ocr', 'auto']);
|
|
10
|
+
/** Validate OCR dependencies after interpolation-aware parsing at the Assembly Step boundary. */
|
|
11
|
+
export function refineDocumentExtractOcr(step, context, options = {}) {
|
|
12
|
+
if (step.robot !== '/document/extract')
|
|
13
|
+
return;
|
|
14
|
+
if (step.text_method !== 'ocr' && step.text_method !== 'auto')
|
|
15
|
+
return;
|
|
16
|
+
// Image-only extraction never invokes OCR; unresolved targets are checked at runtime.
|
|
17
|
+
const extractsText = step.extract === undefined ||
|
|
18
|
+
step.extract === 'text' ||
|
|
19
|
+
(Array.isArray(step.extract) && step.extract.includes('text'));
|
|
20
|
+
if (!extractsText)
|
|
21
|
+
return;
|
|
22
|
+
if (step.ocr_provider === undefined) {
|
|
23
|
+
context.addIssue({
|
|
24
|
+
code: z.ZodIssueCode.custom,
|
|
25
|
+
path: ['ocr_provider'],
|
|
26
|
+
message: 'The ocr_provider parameter is required when text_method is ocr or auto.',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Assembly Steps preserve opaque interpolation until the Robot checks the resolved values.
|
|
30
|
+
// Builtin fields can opt out because those values are already resolved at their boundary.
|
|
31
|
+
// Keep these constraints aligned with the matching stepJsonInputSchema branch in template.ts.
|
|
32
|
+
if (step.password !== undefined &&
|
|
33
|
+
step.password !== '' &&
|
|
34
|
+
!(options.allowInterpolation !== false &&
|
|
35
|
+
interpolationSchemaFull.safeParse(step.password).success)) {
|
|
36
|
+
context.addIssue({
|
|
37
|
+
code: z.ZodIssueCode.custom,
|
|
38
|
+
path: ['password'],
|
|
39
|
+
message: 'The password parameter is only supported for native text extraction and embedded image extraction.',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Defer full page-range interpolation to runtime, consistently with the other unresolved fields.
|
|
43
|
+
if (step.page_range !== undefined &&
|
|
44
|
+
!(options.allowInterpolation !== false &&
|
|
45
|
+
interpolationSchemaFull.safeParse(step.page_range).success)) {
|
|
46
|
+
context.addIssue({
|
|
47
|
+
code: z.ZodIssueCode.custom,
|
|
48
|
+
path: ['page_range'],
|
|
49
|
+
message: 'The page_range parameter is only supported for native text extraction.',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (step.text_granularity === 'page') {
|
|
53
|
+
context.addIssue({
|
|
54
|
+
code: z.ZodIssueCode.custom,
|
|
55
|
+
path: ['text_granularity'],
|
|
56
|
+
message: 'The page text_granularity is only supported for native text extraction.',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
10
60
|
export const meta = {
|
|
11
61
|
...robotDocumentProcessingMeta,
|
|
12
62
|
example_code: createProcessingExample('extracted', '/document/extract', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-convert.d.ts","sourceRoot":"","sources":["../../../src/v3/robots/html-convert.ts"],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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAChC,gEAAgE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAC/E,CAAA;AAEnB,KAAK,YAAY,GAAG,uBAAuB,CAAC,OAAO,eAAe,CAAC,CAAA;AAEnE,MAAM,MAAM,4BAA4B,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AACjE,MAAM,MAAM,4CAA4C,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AACvF,MAAM,MAAM,0CAA0C,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAA;AAC5F,MAAM,MAAM,+CAA+C,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAA;AACjG,MAAM,MAAM,0DAA0D,GACpE,YAAY,CAAC,4BAA4B,CAAC,CAAA;AAC5C,MAAM,MAAM,+DAA+D,GACzE,YAAY,CAAC,2BAA2B,CAAC,CAAA"}
|
|
@@ -43,6 +43,7 @@ Use [🤖/image/resize](/docs/robots/image-resize/) to resize or crop the screen
|
|
|
43
43
|
.default(null)
|
|
44
44
|
.describe(`
|
|
45
45
|
The URL of the web page to be converted. Optional, as you can also upload/import HTML files and pass it to this <dfn>Robot</dfn>.
|
|
46
|
+
Omit it, or use \`null\` or an empty string, to convert uploaded HTML instead.
|
|
46
47
|
`),
|
|
47
48
|
format: z
|
|
48
49
|
.enum(['jpeg', 'jpg', 'pdf', 'png'])
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { RobotDefinitionWithHiddenFields, RobotMetaInput, RobotSchemaVariantTypes } from './_instructions-primitives.ts';
|
|
2
2
|
import { z } from 'zod/v3';
|
|
3
|
+
/** Shared vocabulary limits keep inline hints within GCP and Whisper prompt budgets. */
|
|
4
|
+
export declare const speechTranscribeVocabularySchema: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>, string[], string[]>;
|
|
3
5
|
export declare const meta: RobotMetaInput;
|
|
4
6
|
export declare const robotSpeechTranscribeInstructionsSchema: z.ZodObject<{
|
|
5
7
|
interpolate: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodEnum<["true", "false"]>]>, boolean, boolean | "true" | "false">, z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodUnion<[z.ZodBoolean, z.ZodEnum<["true", "false"]>]>, boolean, boolean | "true" | "false">>]>>;
|
|
@@ -61,6 +63,7 @@ export declare const robotSpeechTranscribeInstructionsSchema: z.ZodObject<{
|
|
|
61
63
|
} & {
|
|
62
64
|
robot: z.ZodLiteral<"/speech/transcribe">;
|
|
63
65
|
provider: z.ZodDefault<z.ZodEnum<["auto", "aws", "gcp", "replicate"]>>;
|
|
66
|
+
vocabulary: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>, string[], string[]>>;
|
|
64
67
|
granularity: z.ZodDefault<z.ZodEnum<["full", "list"]>>;
|
|
65
68
|
format: z.ZodDefault<z.ZodEnum<["json", "meta", "srt", "text", "webvtt"]>>;
|
|
66
69
|
speaker_labels: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -97,6 +100,7 @@ export declare const robotSpeechTranscribeInstructionsSchema: z.ZodObject<{
|
|
|
97
100
|
output_meta?: boolean | string[] | Record<string, boolean> | undefined;
|
|
98
101
|
queue?: "batch" | undefined;
|
|
99
102
|
target_language?: string | undefined;
|
|
103
|
+
vocabulary?: string[] | undefined;
|
|
100
104
|
}, {
|
|
101
105
|
robot: "/speech/transcribe";
|
|
102
106
|
result?: boolean | undefined;
|
|
@@ -124,6 +128,7 @@ export declare const robotSpeechTranscribeInstructionsSchema: z.ZodObject<{
|
|
|
124
128
|
format?: "json" | "text" | "meta" | "srt" | "webvtt" | undefined;
|
|
125
129
|
granularity?: "full" | "list" | undefined;
|
|
126
130
|
target_language?: string | undefined;
|
|
131
|
+
vocabulary?: string[] | undefined;
|
|
127
132
|
speaker_labels?: boolean | undefined;
|
|
128
133
|
max_speakers?: number | undefined;
|
|
129
134
|
source_language?: string | undefined;
|
|
@@ -189,6 +194,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
189
194
|
group_by_original?: boolean | undefined;
|
|
190
195
|
}>]>>;
|
|
191
196
|
robot: z.ZodLiteral<"/speech/transcribe">;
|
|
197
|
+
vocabulary: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>, string[], string[]>>;
|
|
192
198
|
granularity: z.ZodDefault<z.ZodEnum<["full", "list"]>>;
|
|
193
199
|
format: z.ZodDefault<z.ZodEnum<["json", "meta", "srt", "text", "webvtt"]>>;
|
|
194
200
|
speaker_labels: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -230,6 +236,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
230
236
|
output_meta?: boolean | string[] | Record<string, boolean> | undefined;
|
|
231
237
|
queue?: "batch" | undefined;
|
|
232
238
|
target_language?: string | undefined;
|
|
239
|
+
vocabulary?: string[] | undefined;
|
|
233
240
|
}, {
|
|
234
241
|
robot: "/speech/transcribe";
|
|
235
242
|
result?: boolean | "debug" | undefined;
|
|
@@ -258,6 +265,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
258
265
|
format?: "json" | "text" | "meta" | "srt" | "webvtt" | undefined;
|
|
259
266
|
granularity?: "full" | "list" | undefined;
|
|
260
267
|
target_language?: string | undefined;
|
|
268
|
+
vocabulary?: string[] | undefined;
|
|
261
269
|
speaker_labels?: boolean | undefined;
|
|
262
270
|
max_speakers?: number | undefined;
|
|
263
271
|
source_language?: string | undefined;
|
|
@@ -319,6 +327,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
319
327
|
}>]>>;
|
|
320
328
|
robot: z.ZodLiteral<"/speech/transcribe">;
|
|
321
329
|
provider: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodEnum<["auto", "aws", "gcp", "replicate"]>]>>;
|
|
330
|
+
vocabulary: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>, string[], string[]>]>>;
|
|
322
331
|
granularity: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodEnum<["full", "list"]>]>>;
|
|
323
332
|
format: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodEnum<["json", "meta", "srt", "text", "webvtt"]>]>>;
|
|
324
333
|
speaker_labels: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
@@ -355,6 +364,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
355
364
|
output_meta?: string | boolean | string[] | Record<string, string | boolean> | undefined;
|
|
356
365
|
queue?: string | undefined;
|
|
357
366
|
target_language?: string | undefined;
|
|
367
|
+
vocabulary?: string | string[] | undefined;
|
|
358
368
|
}, {
|
|
359
369
|
robot: "/speech/transcribe";
|
|
360
370
|
result?: string | boolean | undefined;
|
|
@@ -382,6 +392,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
382
392
|
format?: string | undefined;
|
|
383
393
|
granularity?: string | undefined;
|
|
384
394
|
target_language?: string | undefined;
|
|
395
|
+
vocabulary?: string | string[] | undefined;
|
|
385
396
|
speaker_labels?: string | boolean | undefined;
|
|
386
397
|
max_speakers?: string | number | undefined;
|
|
387
398
|
source_language?: string | undefined;
|
|
@@ -441,6 +452,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
441
452
|
group_by_original?: boolean | undefined;
|
|
442
453
|
}>]>>;
|
|
443
454
|
robot: z.ZodLiteral<"/speech/transcribe">;
|
|
455
|
+
vocabulary: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>, string[], string[]>]>>;
|
|
444
456
|
granularity: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodEnum<["full", "list"]>]>>;
|
|
445
457
|
format: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodEnum<["json", "meta", "srt", "text", "webvtt"]>]>>;
|
|
446
458
|
speaker_labels: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
@@ -481,6 +493,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
481
493
|
output_meta?: string | boolean | string[] | Record<string, string | boolean> | undefined;
|
|
482
494
|
queue?: string | undefined;
|
|
483
495
|
target_language?: string | undefined;
|
|
496
|
+
vocabulary?: string | string[] | undefined;
|
|
484
497
|
}, {
|
|
485
498
|
robot: "/speech/transcribe";
|
|
486
499
|
result?: string | boolean | undefined;
|
|
@@ -509,6 +522,7 @@ export declare const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema: z.
|
|
|
509
522
|
format?: string | undefined;
|
|
510
523
|
granularity?: string | undefined;
|
|
511
524
|
target_language?: string | undefined;
|
|
525
|
+
vocabulary?: string | string[] | undefined;
|
|
512
526
|
speaker_labels?: string | boolean | undefined;
|
|
513
527
|
max_speakers?: string | number | undefined;
|
|
514
528
|
source_language?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech-transcribe.d.ts","sourceRoot":"","sources":["../../../src/v3/robots/speech-transcribe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,cAAc,EACd,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CA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AAuB,CAAC,OAAO,eAAe,CAAC,CAAA;AAEnE,MAAM,MAAM,iCAAiC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AACtE,MAAM,MAAM,iDAAiD,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AAC5F,MAAM,MAAM,+CAA+C,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAA;AACjG,MAAM,MAAM,oDAAoD,GAC9D,YAAY,CAAC,qBAAqB,CAAC,CAAA;AACrC,MAAM,MAAM,+DAA+D,GACzE,YAAY,CAAC,4BAA4B,CAAC,CAAA;AAC5C,MAAM,MAAM,oEAAoE,GAC9E,YAAY,CAAC,2BAA2B,CAAC,CAAA"}
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
|
+
import { zodWithConservativeJsonInputSchema } from "../lib/zodInputSemantics.js";
|
|
2
3
|
import { autoProviderDescription, createProcessingExample, defineRobotWithHiddenFields, granularitySchema, robotArtificialIntelligenceMeta, robotBase, robotUse, } from "./_instructions-primitives.js";
|
|
3
4
|
const speechTranscribeProviderSchema = z.enum(['auto', 'aws', 'gcp', 'replicate']).default('auto');
|
|
4
5
|
const speechTranscribeProviderWithHiddenFieldsSchema = z
|
|
5
6
|
.enum(['auto', 'aws', 'gcp', 'replicate', 'transloadit'])
|
|
6
7
|
.default('auto');
|
|
8
|
+
/** Shared vocabulary limits keep inline hints within GCP and Whisper prompt budgets. */
|
|
9
|
+
export const speechTranscribeVocabularySchema = zodWithConservativeJsonInputSchema(z
|
|
10
|
+
.array(z
|
|
11
|
+
.string()
|
|
12
|
+
.trim()
|
|
13
|
+
.min(1)
|
|
14
|
+
.max(100)
|
|
15
|
+
.regex(/^[^\p{Cc}]+$/u))
|
|
16
|
+
.max(50)
|
|
17
|
+
.refine((terms) => new Set(terms.map((term) => term.toLowerCase())).size === terms.length, {
|
|
18
|
+
message: 'Vocabulary terms must be unique, ignoring case.',
|
|
19
|
+
})
|
|
20
|
+
// Byte-level tokenization uses at most one token per byte. Reserve room for sentence styling.
|
|
21
|
+
.refine((terms) => new TextEncoder().encode(terms.join(', ')).byteLength <= 200, {
|
|
22
|
+
message: 'Vocabulary terms joined with comma-space must not exceed 200 UTF-8 bytes.',
|
|
23
|
+
}),
|
|
24
|
+
// Trimming, Unicode case uniqueness and a joined UTF-8 budget have no portable JSON Schema form.
|
|
25
|
+
z.array(z.string().min(1)).max(50));
|
|
7
26
|
export const meta = {
|
|
8
27
|
...robotArtificialIntelligenceMeta,
|
|
9
28
|
example_code: createProcessingExample('transcribed', '/speech/transcribe', {
|
|
@@ -58,7 +77,8 @@ recurring speakers:
|
|
|
58
77
|
\`\`\`
|
|
59
78
|
|
|
60
79
|
Speaker labels are currently supported by the \`aws\` and \`gcp\` providers. If you enable
|
|
61
|
-
\`speaker_labels\` without setting \`provider\`, Transloadit uses \`aws\` for that <dfn>Step</dfn
|
|
80
|
+
\`speaker_labels\` without setting \`provider\`, Transloadit uses \`aws\` for that <dfn>Step</dfn>, or
|
|
81
|
+
\`gcp\` when \`vocabulary\` is also supplied. Labels
|
|
62
82
|
are normalized as \`speaker_1\`, \`speaker_2\`, and so on:
|
|
63
83
|
|
|
64
84
|
\`\`\`json
|
|
@@ -81,7 +101,27 @@ ${autoProviderDescription}
|
|
|
81
101
|
|
|
82
102
|
Set this to \`"aws"\`, \`"gcp"\`, or \`"replicate"\` to force a specific provider.
|
|
83
103
|
When set to \`"auto"\`, Transloadit uses \`"replicate"\` by default and uses \`"aws"\` when
|
|
84
|
-
\`speaker_labels\` is enabled.
|
|
104
|
+
\`speaker_labels\` is enabled. If both \`speaker_labels\` and a nonempty \`vocabulary\` are set,
|
|
105
|
+
\`"auto"\` uses \`"gcp"\`.
|
|
106
|
+
`),
|
|
107
|
+
vocabulary: speechTranscribeVocabularySchema.optional().describe(`
|
|
108
|
+
Words or phrases to favor during speech recognition, using the spelling you want in the output.
|
|
109
|
+
For example, \`["Transloadit", "Uppy", "tus"]\` helps the provider recognize brand and product names.
|
|
110
|
+
|
|
111
|
+
Supply up to 50 distinct terms, each between 1 and 100 characters after trimming surrounding
|
|
112
|
+
whitespace. Terms must not contain control characters or case-insensitive duplicates. The terms
|
|
113
|
+
joined with \`", "\` must fit within 200 UTF-8 bytes, keeping all terms within Whisper’s prompt
|
|
114
|
+
budget. Omitting this parameter or supplying an empty array leaves recognition unchanged.
|
|
115
|
+
|
|
116
|
+
Supported by \`"replicate"\` and \`"gcp"\`. Replicate uses a prompt-capable WhisperX large-v3 model
|
|
117
|
+
with aligned word timestamps when vocabulary is supplied. GCP uses inline boosted phrase hints.
|
|
118
|
+
Explicit \`"aws"\` requests with vocabulary return a validation error because AWS requires a
|
|
119
|
+
pre-created Custom Vocabulary. Use \`"auto"\`, \`"replicate"\`, or \`"gcp"\` instead.
|
|
120
|
+
|
|
121
|
+
Hints improve recognition but do not guarantee that a term is recognized. Afterwards, complete
|
|
122
|
+
case-insensitive matches use your supplied spelling in every output format, including JSON words
|
|
123
|
+
and speaker segments, without changing timestamps. Similar-sounding words are never replaced:
|
|
124
|
+
\`"transloadit"\` becomes \`"Transloadit"\`, but \`"Transloaded"\` stays unchanged.
|
|
85
125
|
`),
|
|
86
126
|
granularity: granularitySchema.describe(`
|
|
87
127
|
Both \`"full"\` and \`"list"\` currently return the same complete transcription response. \`"list"\` remains accepted for backward compatibility.
|