@leitwerk-dev/worker-protocol 0.2.0 → 0.2.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/dist/{chunk-DVN32ANP.js → chunk-VR7BWTD7.js} +5 -1
- package/dist/chunk-VR7BWTD7.js.map +1 -0
- package/dist/docker-config.d.ts +16 -0
- package/dist/docker-config.d.ts.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -24
- package/dist/index.js.map +1 -1
- package/dist/ipc-codec.d.ts +22 -0
- package/dist/ipc-codec.d.ts.map +1 -1
- package/dist/ipc-decode.d.ts +7 -0
- package/dist/ipc-decode.d.ts.map +1 -1
- package/dist/ipc-messages.d.ts +286 -18
- package/dist/ipc-messages.d.ts.map +1 -1
- package/dist/pi-resource-bundle.d.ts +13 -2
- package/dist/pi-resource-bundle.d.ts.map +1 -1
- package/dist/pi-resource-manifest.d.ts +35 -1
- package/dist/pi-resource-manifest.d.ts.map +1 -1
- package/dist/testing.d.ts +2 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/worker-api-version.d.ts +1 -0
- package/dist/worker-api-version.d.ts.map +1 -1
- package/dist/worker-ipc-transport.d.ts +7 -0
- package/dist/worker-ipc-transport.d.ts.map +1 -1
- package/dist/worker-result-image-public.d.ts +2 -0
- package/dist/worker-result-image-public.d.ts.map +1 -0
- package/dist/worker-result-image-public.js +7 -0
- package/dist/worker-result-image-public.js.map +1 -0
- package/dist/worker-result-image.d.ts +22 -0
- package/dist/worker-result-image.d.ts.map +1 -1
- package/dist/worker-result-image.js +1 -1
- package/dist/worker-session-snapshot.d.ts +5 -0
- package/dist/worker-session-snapshot.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/docker-config.ts +12 -0
- package/src/index.ts +62 -5
- package/src/ipc-codec.ts +40 -6
- package/src/ipc-decode.ts +15 -2
- package/src/ipc-messages.ts +314 -25
- package/src/pi-resource-bundle.ts +13 -2
- package/src/pi-resource-manifest.ts +35 -1
- package/src/testing.ts +2 -11
- package/src/worker-api-version.ts +1 -0
- package/src/worker-ipc-transport.ts +7 -0
- package/src/worker-result-image-public.ts +1 -0
- package/src/worker-result-image.ts +25 -1
- package/src/worker-session-snapshot.ts +5 -0
- package/dist/chunk-DVN32ANP.js.map +0 -1
|
@@ -3,18 +3,27 @@ import path from "node:path";
|
|
|
3
3
|
|
|
4
4
|
const BLOCK_SIZE = 512;
|
|
5
5
|
|
|
6
|
+
/** @internal */
|
|
6
7
|
export interface PiResourceFile {
|
|
8
|
+
/** @internal */
|
|
7
9
|
path: string;
|
|
10
|
+
/** @internal */
|
|
8
11
|
content: Uint8Array;
|
|
9
12
|
}
|
|
10
13
|
|
|
14
|
+
/** @internal */
|
|
11
15
|
export interface PiResourceBundle {
|
|
16
|
+
/** @internal */
|
|
12
17
|
digest: string;
|
|
18
|
+
/** @internal */
|
|
13
19
|
bytes: Uint8Array;
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
/** @internal */
|
|
16
23
|
export interface ExtractedPiResourceFile {
|
|
24
|
+
/** @internal */
|
|
17
25
|
path: string;
|
|
26
|
+
/** @internal */
|
|
18
27
|
content: Uint8Array;
|
|
19
28
|
}
|
|
20
29
|
|
|
@@ -22,6 +31,7 @@ function fail(message: string): never {
|
|
|
22
31
|
throw new Error(`Invalid Pi resource bundle: ${message}`);
|
|
23
32
|
}
|
|
24
33
|
|
|
34
|
+
/** @internal */
|
|
25
35
|
export function validateResourceRelativePath(value: string): string {
|
|
26
36
|
if (!value || path.posix.isAbsolute(value) || value.includes("\\")) {
|
|
27
37
|
fail(`unsafe path '${value}'`);
|
|
@@ -69,11 +79,12 @@ function padding(size: number): Buffer {
|
|
|
69
79
|
return Buffer.alloc(length);
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
/** @internal */
|
|
72
83
|
export function sha256Digest(bytes: Uint8Array): string {
|
|
73
84
|
return createHash("sha256").update(bytes).digest("hex");
|
|
74
85
|
}
|
|
75
86
|
|
|
76
|
-
/** Creates a deterministic, uncompressed ustar archive containing regular files only. */
|
|
87
|
+
/** Creates a deterministic, uncompressed ustar archive containing regular files only. @internal */
|
|
77
88
|
export function createCanonicalPiResourceBundle(
|
|
78
89
|
files: readonly PiResourceFile[],
|
|
79
90
|
): PiResourceBundle {
|
|
@@ -120,7 +131,7 @@ function allZero(block: Uint8Array): boolean {
|
|
|
120
131
|
return block.every((byte) => byte === 0);
|
|
121
132
|
}
|
|
122
133
|
|
|
123
|
-
/** Parses only the narrow regular-file ustar subset emitted by this module. */
|
|
134
|
+
/** Parses only the narrow regular-file ustar subset emitted by this module. @internal */
|
|
124
135
|
export function verifyCanonicalPiResourceBundle(
|
|
125
136
|
bytes: Uint8Array,
|
|
126
137
|
expectedDigest?: string,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { validateResourceRelativePath } from "./pi-resource-bundle.js";
|
|
3
3
|
|
|
4
|
+
/** @internal */
|
|
4
5
|
export const PI_RESOURCE_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
5
6
|
|
|
6
7
|
const nonBlankStringSchema = v.pipe(
|
|
@@ -11,59 +12,89 @@ const jsonObjectSchema = v.record(v.string(), v.unknown());
|
|
|
11
12
|
const positiveSafeIntegerSchema = v.pipe(v.number(), v.safeInteger(), v.minValue(1));
|
|
12
13
|
const nonNegativeSafeIntegerSchema = v.pipe(v.number(), v.safeInteger(), v.minValue(0));
|
|
13
14
|
|
|
15
|
+
/** @internal */
|
|
14
16
|
export const piResourceManifestSchema = v.strictObject({
|
|
17
|
+
/** @internal */
|
|
15
18
|
schemaVersion: v.literal(PI_RESOURCE_SNAPSHOT_SCHEMA_VERSION),
|
|
19
|
+
/** @internal */
|
|
16
20
|
model: v.strictObject({
|
|
21
|
+
/** @internal */
|
|
17
22
|
profileId: nonBlankStringSchema,
|
|
23
|
+
/** @internal */
|
|
18
24
|
providerId: nonBlankStringSchema,
|
|
25
|
+
/** @internal */
|
|
19
26
|
modelId: nonBlankStringSchema,
|
|
27
|
+
/** @internal */
|
|
20
28
|
thinkingLevel: nonBlankStringSchema,
|
|
21
29
|
}),
|
|
30
|
+
/** @internal */
|
|
22
31
|
providerOptions: v.record(v.string(), nonBlankStringSchema),
|
|
32
|
+
/** @internal */
|
|
23
33
|
providerWorkerConfig: v.nullable(
|
|
24
34
|
v.strictObject({
|
|
35
|
+
/** @internal */
|
|
25
36
|
version: positiveSafeIntegerSchema,
|
|
37
|
+
/** @internal */
|
|
26
38
|
value: jsonObjectSchema,
|
|
27
39
|
}),
|
|
28
40
|
),
|
|
41
|
+
/** @internal */
|
|
29
42
|
declaredCredentialPaths: v.array(nonBlankStringSchema),
|
|
43
|
+
/** @internal */
|
|
30
44
|
compatibility: v.strictObject({
|
|
45
|
+
/** @internal */
|
|
31
46
|
workerApiVersion: nonBlankStringSchema,
|
|
47
|
+
/** @internal */
|
|
32
48
|
piVersion: nonBlankStringSchema,
|
|
49
|
+
/** @internal */
|
|
33
50
|
protocolVersion: v.optional(nonBlankStringSchema),
|
|
34
51
|
}),
|
|
52
|
+
/** @internal */
|
|
35
53
|
provenance: v.array(
|
|
36
54
|
v.strictObject({
|
|
55
|
+
/** @internal */
|
|
37
56
|
kind: v.picklist(["extension", "skill", "prompt", "generated"]),
|
|
57
|
+
/** @internal */
|
|
38
58
|
ownerExtensionId: v.nullable(nonBlankStringSchema),
|
|
59
|
+
/** @internal */
|
|
39
60
|
packageName: v.nullable(nonBlankStringSchema),
|
|
61
|
+
/** @internal */
|
|
40
62
|
snapshotPath: nonBlankStringSchema,
|
|
63
|
+
/** @internal */
|
|
41
64
|
sha256: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/)),
|
|
65
|
+
/** @internal */
|
|
42
66
|
size: nonNegativeSafeIntegerSchema,
|
|
43
67
|
}),
|
|
44
68
|
),
|
|
45
69
|
});
|
|
46
70
|
|
|
71
|
+
/** @internal */
|
|
47
72
|
type DeepReadonly<T> = T extends readonly unknown[]
|
|
48
73
|
? { readonly [Index in keyof T]: DeepReadonly<T[Index]> }
|
|
49
74
|
: T extends object
|
|
50
75
|
? { readonly [Key in keyof T]: DeepReadonly<T[Key]> }
|
|
51
76
|
: T;
|
|
52
77
|
|
|
78
|
+
/** @internal */
|
|
53
79
|
export type PiResourceManifest = DeepReadonly<v.InferOutput<typeof piResourceManifestSchema>>;
|
|
80
|
+
/** @internal */
|
|
54
81
|
export type PiResourceSnapshotModel = PiResourceManifest["model"];
|
|
82
|
+
/** @internal */
|
|
55
83
|
export type PiResourceSnapshotWorkerConfig = NonNullable<
|
|
56
84
|
PiResourceManifest["providerWorkerConfig"]
|
|
57
85
|
>;
|
|
86
|
+
/** @internal */
|
|
58
87
|
export type PiResourceSnapshotCompatibility = PiResourceManifest["compatibility"];
|
|
88
|
+
/** @internal */
|
|
59
89
|
export type PiResourceFileProvenance = PiResourceManifest["provenance"][number];
|
|
90
|
+
/** @internal */
|
|
60
91
|
export type PiResourceProvenanceKind = PiResourceFileProvenance["kind"];
|
|
61
92
|
|
|
62
93
|
function invalidManifest(message: string, cause?: unknown): never {
|
|
63
94
|
throw new Error(`Invalid managed Pi resource snapshot: ${message}`, { cause });
|
|
64
95
|
}
|
|
65
96
|
|
|
66
|
-
/** Parses and validates the complete generated.json contract. */
|
|
97
|
+
/** Parses and validates the complete generated.json contract. @internal */
|
|
67
98
|
export function parsePiResourceManifest(raw: unknown): PiResourceManifest {
|
|
68
99
|
let manifest: PiResourceManifest;
|
|
69
100
|
try {
|
|
@@ -100,6 +131,7 @@ export function parsePiResourceManifest(raw: unknown): PiResourceManifest {
|
|
|
100
131
|
|
|
101
132
|
type JsonRecord = Record<string, unknown>;
|
|
102
133
|
|
|
134
|
+
/** @internal */
|
|
103
135
|
export function canonicalizeJson(value: unknown, location = "value"): unknown {
|
|
104
136
|
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
105
137
|
if (typeof value === "number") {
|
|
@@ -121,10 +153,12 @@ export function canonicalizeJson(value: unknown, location = "value"): unknown {
|
|
|
121
153
|
);
|
|
122
154
|
}
|
|
123
155
|
|
|
156
|
+
/** @internal */
|
|
124
157
|
export function canonicalJsonStringify(value: unknown, location = "value"): string {
|
|
125
158
|
return JSON.stringify(canonicalizeJson(value, location));
|
|
126
159
|
}
|
|
127
160
|
|
|
161
|
+
/** @internal */
|
|
128
162
|
export function canonicalJsonEqual(left: unknown, right: unknown): boolean {
|
|
129
163
|
return canonicalJsonStringify(left) === canonicalJsonStringify(right);
|
|
130
164
|
}
|
package/src/testing.ts
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import type { ConfigSnapshot } from "@leitwerk-dev/protocol/config-snapshot";
|
|
2
|
-
import { IPC_PROTOCOL_VERSION } from "./ipc-codec.js";
|
|
3
2
|
|
|
3
|
+
/** @internal */
|
|
4
4
|
export async function flushAsyncWork(iterations = 30): Promise<void> {
|
|
5
5
|
for (let i = 0; i < iterations; i++) {
|
|
6
6
|
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
protocol: IPC_PROTOCOL_VERSION as typeof IPC_PROTOCOL_VERSION,
|
|
13
|
-
messageId,
|
|
14
|
-
instanceId,
|
|
15
|
-
workerId,
|
|
16
|
-
sentAt: new Date().toISOString(),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
10
|
+
/** @internal */
|
|
20
11
|
export function createTestConfigSnapshot(): ConfigSnapshot {
|
|
21
12
|
return {
|
|
22
13
|
workers: {
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
export const WORKER_INSTANCE_ID_ENV = "LEITWERK_INSTANCE_ID";
|
|
3
|
+
/** @internal */
|
|
2
4
|
export const WORKER_ID_ENV = "LEITWERK_WORKER_ID";
|
|
5
|
+
/** @internal */
|
|
3
6
|
export const WORKER_IPC_SERVER_URL_ENV = "LEITWERK_SERVER_URL";
|
|
7
|
+
/** @internal */
|
|
4
8
|
export const WORKER_IPC_CONNECT_TOKEN_ENV = "LEITWERK_WORKER_CONNECT_TOKEN";
|
|
9
|
+
/** @internal */
|
|
5
10
|
export const WORKER_IPC_RECONNECT_ENV = "LEITWERK_WORKER_RECONNECT";
|
|
11
|
+
/** @internal */
|
|
6
12
|
export const WORKER_SNAPSHOT_TOKEN_ENV = "LEITWERK_WORKER_SNAPSHOT_TOKEN";
|
|
13
|
+
/** @internal */
|
|
7
14
|
export const WORKER_SERVER_EPOCH_ENV = "LEITWERK_SERVER_EPOCH";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseManagedResultImagePath } from "./worker-result-image.js";
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
|
+
/** @internal */
|
|
3
4
|
export const WORKER_RESULT_IMAGE_WORKER_ID_HEADER = "x-leitwerk-worker-id";
|
|
5
|
+
/** @internal */
|
|
4
6
|
export const RESULT_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp"] as const;
|
|
7
|
+
/** @internal */
|
|
5
8
|
export const RESULT_IMAGE_MAX_SIZE_BYTES = 10 * 1024 * 1024;
|
|
9
|
+
/** @internal */
|
|
6
10
|
export const RESULT_IMAGE_STORAGE_SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
11
|
+
/** @internal */
|
|
7
12
|
export const RESULT_IMAGE_ID_PATTERN = /^img_[A-Za-z0-9]+\.(png|jpg|webp)$/;
|
|
13
|
+
/** @internal */
|
|
8
14
|
export type ResultImageMimeType = (typeof RESULT_IMAGE_MIME_TYPES)[number];
|
|
9
15
|
|
|
16
|
+
/** @internal */
|
|
10
17
|
export function isResultImageStorageSegment(value: string): boolean {
|
|
11
18
|
return RESULT_IMAGE_STORAGE_SEGMENT_PATTERN.test(value);
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
/** @internal */
|
|
22
|
+
export function parseResultImageId(value: string): {
|
|
23
|
+
/** @internal */
|
|
24
|
+
extension: "png" | "jpg" | "webp";
|
|
25
|
+
} | null {
|
|
15
26
|
const extension = RESULT_IMAGE_ID_PATTERN.exec(value)?.[1];
|
|
16
27
|
return extension === "png" || extension === "jpg" || extension === "webp" ? { extension } : null;
|
|
17
28
|
}
|
|
@@ -20,23 +31,31 @@ function assertResultImageStorageSegment(value: string): void {
|
|
|
20
31
|
if (!isResultImageStorageSegment(value)) throw new Error("Invalid result image storage id");
|
|
21
32
|
}
|
|
22
33
|
|
|
34
|
+
/** @internal */
|
|
23
35
|
export const workerResultImageUploadResponseSchema = v.object({
|
|
36
|
+
/** @internal */
|
|
24
37
|
imageId: v.string(),
|
|
38
|
+
/** @internal */
|
|
25
39
|
url: v.string(),
|
|
40
|
+
/** @internal */
|
|
26
41
|
mimeType: v.picklist(RESULT_IMAGE_MIME_TYPES),
|
|
42
|
+
/** @internal */
|
|
27
43
|
byteSize: v.number(),
|
|
28
44
|
});
|
|
29
45
|
|
|
46
|
+
/** @internal */
|
|
30
47
|
export type WorkerResultImageUploadResponse = v.InferOutput<
|
|
31
48
|
typeof workerResultImageUploadResponseSchema
|
|
32
49
|
>;
|
|
33
50
|
|
|
51
|
+
/** @internal */
|
|
34
52
|
export function buildWorkerResultImageUploadPath(instanceId: string, turnRecordId: string): string {
|
|
35
53
|
assertResultImageStorageSegment(instanceId);
|
|
36
54
|
assertResultImageStorageSegment(turnRecordId);
|
|
37
55
|
return `/internal/workers/${instanceId}/turn-records/${turnRecordId}/result-images`;
|
|
38
56
|
}
|
|
39
57
|
|
|
58
|
+
/** @internal */
|
|
40
59
|
export function buildManagedResultImagePath(
|
|
41
60
|
instanceId: string,
|
|
42
61
|
turnRecordId: string,
|
|
@@ -51,9 +70,13 @@ export function buildManagedResultImagePath(
|
|
|
51
70
|
const MANAGED_RESULT_IMAGE_PATH =
|
|
52
71
|
/^\/api\/processes\/([^/]+)\/turn-records\/([^/]+)\/result-images\/([^/]+)$/;
|
|
53
72
|
|
|
73
|
+
/** @internal */
|
|
54
74
|
export function parseManagedResultImagePath(value: string): {
|
|
75
|
+
/** @internal */
|
|
55
76
|
instanceId: string;
|
|
77
|
+
/** @internal */
|
|
56
78
|
turnRecordId: string;
|
|
79
|
+
/** @internal */
|
|
57
80
|
imageId: string;
|
|
58
81
|
} | null {
|
|
59
82
|
const match = MANAGED_RESULT_IMAGE_PATH.exec(value);
|
|
@@ -70,6 +93,7 @@ export function parseManagedResultImagePath(value: string): {
|
|
|
70
93
|
: null;
|
|
71
94
|
}
|
|
72
95
|
|
|
96
|
+
/** @internal */
|
|
73
97
|
export function parseWorkerResultImageUploadResponse(
|
|
74
98
|
value: unknown,
|
|
75
99
|
): WorkerResultImageUploadResponse | null {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
export const WORKER_SESSION_SNAPSHOT_CONTENT_TYPE = "application/x-ndjson";
|
|
3
|
+
/** @internal */
|
|
2
4
|
export const WORKER_SESSION_SNAPSHOT_WORKER_ID_HEADER = "x-leitwerk-worker-id";
|
|
5
|
+
/** @internal */
|
|
3
6
|
export const WORKER_SESSION_SNAPSHOT_REASON_HEADER = "x-leitwerk-session-snapshot-reason";
|
|
7
|
+
/** @internal */
|
|
4
8
|
export const WORKER_SESSION_SNAPSHOT_TURN_RECORD_ID_HEADER = "x-leitwerk-turn-record-id";
|
|
9
|
+
/** @internal */
|
|
5
10
|
export function buildWorkerSessionSnapshotPath(instanceId: string): string {
|
|
6
11
|
return `/internal/workers/${encodeURIComponent(instanceId)}/session-snapshot`;
|
|
7
12
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/worker-result-image.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const WORKER_RESULT_IMAGE_WORKER_ID_HEADER = \"x-leitwerk-worker-id\";\nexport const RESULT_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\"] as const;\nexport const RESULT_IMAGE_MAX_SIZE_BYTES = 10 * 1024 * 1024;\nexport const RESULT_IMAGE_STORAGE_SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nexport const RESULT_IMAGE_ID_PATTERN = /^img_[A-Za-z0-9]+\\.(png|jpg|webp)$/;\nexport type ResultImageMimeType = (typeof RESULT_IMAGE_MIME_TYPES)[number];\n\nexport function isResultImageStorageSegment(value: string): boolean {\n\treturn RESULT_IMAGE_STORAGE_SEGMENT_PATTERN.test(value);\n}\n\nexport function parseResultImageId(value: string): { extension: \"png\" | \"jpg\" | \"webp\" } | null {\n\tconst extension = RESULT_IMAGE_ID_PATTERN.exec(value)?.[1];\n\treturn extension === \"png\" || extension === \"jpg\" || extension === \"webp\" ? { extension } : null;\n}\n\nfunction assertResultImageStorageSegment(value: string): void {\n\tif (!isResultImageStorageSegment(value)) throw new Error(\"Invalid result image storage id\");\n}\n\nexport const workerResultImageUploadResponseSchema = v.object({\n\timageId: v.string(),\n\turl: v.string(),\n\tmimeType: v.picklist(RESULT_IMAGE_MIME_TYPES),\n\tbyteSize: v.number(),\n});\n\nexport type WorkerResultImageUploadResponse = v.InferOutput<\n\ttypeof workerResultImageUploadResponseSchema\n>;\n\nexport function buildWorkerResultImageUploadPath(instanceId: string, turnRecordId: string): string {\n\tassertResultImageStorageSegment(instanceId);\n\tassertResultImageStorageSegment(turnRecordId);\n\treturn `/internal/workers/${instanceId}/turn-records/${turnRecordId}/result-images`;\n}\n\nexport function buildManagedResultImagePath(\n\tinstanceId: string,\n\tturnRecordId: string,\n\timageId: string,\n): string {\n\tassertResultImageStorageSegment(instanceId);\n\tassertResultImageStorageSegment(turnRecordId);\n\tif (!parseResultImageId(imageId)) throw new Error(\"Invalid result image id\");\n\treturn `/api/processes/${instanceId}/turn-records/${turnRecordId}/result-images/${imageId}`;\n}\n\nconst MANAGED_RESULT_IMAGE_PATH =\n\t/^\\/api\\/processes\\/([^/]+)\\/turn-records\\/([^/]+)\\/result-images\\/([^/]+)$/;\n\nexport function parseManagedResultImagePath(value: string): {\n\tinstanceId: string;\n\tturnRecordId: string;\n\timageId: string;\n} | null {\n\tconst match = MANAGED_RESULT_IMAGE_PATH.exec(value);\n\tconst instanceId = match?.[1];\n\tconst turnRecordId = match?.[2];\n\tconst imageId = match?.[3];\n\treturn instanceId &&\n\t\tturnRecordId &&\n\t\timageId &&\n\t\tisResultImageStorageSegment(instanceId) &&\n\t\tisResultImageStorageSegment(turnRecordId) &&\n\t\tparseResultImageId(imageId)\n\t\t? { instanceId, turnRecordId, imageId }\n\t\t: null;\n}\n\nexport function parseWorkerResultImageUploadResponse(\n\tvalue: unknown,\n): WorkerResultImageUploadResponse | null {\n\tconst parsed = v.safeParse(workerResultImageUploadResponseSchema, value);\n\treturn parsed.success ? parsed.output : null;\n}\n"],"mappings":";AAAA,YAAY,OAAO;AAEZ,IAAM,uCAAuC;AAC7C,IAAM,0BAA0B,CAAC,aAAa,cAAc,YAAY;AACxE,IAAM,8BAA8B,KAAK,OAAO;AAChD,IAAM,uCAAuC;AAC7C,IAAM,0BAA0B;AAGhC,SAAS,4BAA4B,OAAwB;AACnE,SAAO,qCAAqC,KAAK,KAAK;AACvD;AAEO,SAAS,mBAAmB,OAA6D;AAC/F,QAAM,YAAY,wBAAwB,KAAK,KAAK,IAAI,CAAC;AACzD,SAAO,cAAc,SAAS,cAAc,SAAS,cAAc,SAAS,EAAE,UAAU,IAAI;AAC7F;AAEA,SAAS,gCAAgC,OAAqB;AAC7D,MAAI,CAAC,4BAA4B,KAAK,EAAG,OAAM,IAAI,MAAM,iCAAiC;AAC3F;AAEO,IAAM,wCAA0C,SAAO;AAAA,EAC7D,SAAW,SAAO;AAAA,EAClB,KAAO,SAAO;AAAA,EACd,UAAY,WAAS,uBAAuB;AAAA,EAC5C,UAAY,SAAO;AACpB,CAAC;AAMM,SAAS,iCAAiC,YAAoB,cAA8B;AAClG,kCAAgC,UAAU;AAC1C,kCAAgC,YAAY;AAC5C,SAAO,qBAAqB,UAAU,iBAAiB,YAAY;AACpE;AAEO,SAAS,4BACf,YACA,cACA,SACS;AACT,kCAAgC,UAAU;AAC1C,kCAAgC,YAAY;AAC5C,MAAI,CAAC,mBAAmB,OAAO,EAAG,OAAM,IAAI,MAAM,yBAAyB;AAC3E,SAAO,kBAAkB,UAAU,iBAAiB,YAAY,kBAAkB,OAAO;AAC1F;AAEA,IAAM,4BACL;AAEM,SAAS,4BAA4B,OAInC;AACR,QAAM,QAAQ,0BAA0B,KAAK,KAAK;AAClD,QAAM,aAAa,QAAQ,CAAC;AAC5B,QAAM,eAAe,QAAQ,CAAC;AAC9B,QAAM,UAAU,QAAQ,CAAC;AACzB,SAAO,cACN,gBACA,WACA,4BAA4B,UAAU,KACtC,4BAA4B,YAAY,KACxC,mBAAmB,OAAO,IACxB,EAAE,YAAY,cAAc,QAAQ,IACpC;AACJ;AAEO,SAAS,qCACf,OACyC;AACzC,QAAM,SAAW,YAAU,uCAAuC,KAAK;AACvE,SAAO,OAAO,UAAU,OAAO,SAAS;AACzC;","names":[]}
|