stitchkit 0.123.6 → 0.124.0
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/CHANGELOG.md +80 -0
- package/dist/entrypoints/application/diagnostic-journal.js +1 -1
- package/dist/entrypoints/application/directory-inbox.js +3 -3
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/cli.js +2 -1
- package/dist/entrypoints/files.js +2 -2
- package/dist/entrypoints/node.js +2 -2
- package/dist/entrypoints/server.js +5 -5
- package/dist/entrypoints/telegram.js +1 -1
- package/dist/entrypoints/tools/contract.d.ts +1 -1
- package/dist/entrypoints/tools/contract.d.ts.map +1 -1
- package/dist/entrypoints/tools/contract.js +6 -2
- package/dist/entrypoints/tools/toolkit.js +2 -1
- package/dist/entrypoints/tools.d.ts +1 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +53 -52
- package/dist/{index-yfpt7sxr.js → index-6qrspvxp.js} +5 -3
- package/dist/index-81t0bf0f.js +18 -0
- package/dist/{index-d9cg0gen.js → index-8yky60kq.js} +1 -1
- package/dist/{index-bph35vpy.js → index-9cxxfkhb.js} +21 -1
- package/dist/{index-73dappvg.js → index-ezwvsqx9.js} +1 -1
- package/dist/index-gy9x38a2.js +40 -0
- package/dist/{index-chz7c830.js → index-mqttte96.js} +39 -6
- package/dist/{index-xjb131sc.js → index-q89kd1xc.js} +194 -51
- package/dist/{index-eabx6qjh.js → index-tnnmekgb.js} +1 -6
- package/dist/index-zs8cze4j.js +6 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/media-extension.d.ts +3 -0
- package/dist/internal/media-extension.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +7 -1
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +5 -2
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/download.d.ts +25 -4
- package/dist/tools/cli/download.d.ts.map +1 -1
- package/dist/tools/cli/inline-files.d.ts +70 -0
- package/dist/tools/cli/inline-files.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/transfer/download-core.d.ts +2 -0
- package/dist/tools/transfer/download-core.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts +45 -4
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
- package/dist/tools/transfer/view-file.d.ts +1 -1
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/llms/cli.txt +64 -3
- package/llms/stitchkit.txt +3 -3
- package/llms/tools.2.txt +11 -0
- package/llms/tools.3.txt +2 -1
- package/llms/{upgrading-0.106.0-0.123.0.txt → upgrading-0.106.0-0.124.0.txt} +39 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +116 -7
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/dist/index-sba3e6m4.js +0 -52
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
|
|
19
19
|
// src/internal/exclusive-lock.ts
|
|
20
20
|
import { randomUUID } from "node:crypto";
|
|
21
|
+
import { constants as constants2 } from "node:fs";
|
|
21
22
|
import { lstat, open as open2, readdir as readdir2, unlink } from "node:fs/promises";
|
|
22
23
|
import { hostname as hostname2 } from "node:os";
|
|
23
24
|
import { dirname, join } from "node:path";
|
|
@@ -179,6 +180,7 @@ async function readLockFile(path, onFailure, signal) {
|
|
|
179
180
|
}
|
|
180
181
|
return {
|
|
181
182
|
path,
|
|
183
|
+
record: record.text,
|
|
182
184
|
...readOwner(record.text),
|
|
183
185
|
ino: record.info.ino,
|
|
184
186
|
dev: record.info.dev,
|
|
@@ -288,6 +290,38 @@ async function createOwned(path, options, reclaimed) {
|
|
|
288
290
|
}
|
|
289
291
|
};
|
|
290
292
|
}
|
|
293
|
+
async function removeJudgedLock(state) {
|
|
294
|
+
const pin = await open2(state.path, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK).catch((error) => {
|
|
295
|
+
if (isCode(error, "ENOENT"))
|
|
296
|
+
return null;
|
|
297
|
+
throw error;
|
|
298
|
+
});
|
|
299
|
+
if (!pin)
|
|
300
|
+
return "absent";
|
|
301
|
+
try {
|
|
302
|
+
const pinned = await pin.stat();
|
|
303
|
+
if (pinned.ino !== state.ino || pinned.dev !== state.dev)
|
|
304
|
+
return "changed";
|
|
305
|
+
const current = await readLockRecord(state.path, {
|
|
306
|
+
singleLink: state.stagedName === undefined
|
|
307
|
+
}).catch((error) => {
|
|
308
|
+
if (error instanceof LockRecordError || isCode(error, "ENOENT"))
|
|
309
|
+
return null;
|
|
310
|
+
throw error;
|
|
311
|
+
});
|
|
312
|
+
if (current?.info.ino !== state.ino || current.info.dev !== state.dev || current.text !== state.record)
|
|
313
|
+
return "changed";
|
|
314
|
+
if (state.stagedName !== undefined)
|
|
315
|
+
await unlink(state.stagedName).catch((error) => {
|
|
316
|
+
if (!isCode(error, "ENOENT"))
|
|
317
|
+
throw error;
|
|
318
|
+
});
|
|
319
|
+
await unlinkIfSame(state.path, state.ino, state.dev);
|
|
320
|
+
return "removed";
|
|
321
|
+
} finally {
|
|
322
|
+
await pin.close();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
291
325
|
function reclaimable(state, diagnosis, graceMs) {
|
|
292
326
|
if (state.owner)
|
|
293
327
|
return diagnosis.liveness === "gone";
|
|
@@ -327,12 +361,11 @@ async function reclaimUnderGuard(path, options, depth) {
|
|
|
327
361
|
return { refused: true };
|
|
328
362
|
if (!reclaimable(state, diagnosis, options.ownerlessGraceMs))
|
|
329
363
|
return { refused: true, cause: diagnosis.cause };
|
|
330
|
-
if (state
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
await unlinkIfSame(path, state.ino, state.dev);
|
|
364
|
+
if (await removeJudgedLock(state) === "changed")
|
|
365
|
+
return {
|
|
366
|
+
refused: true,
|
|
367
|
+
cause: new LockRecordError("LOCK_RECORD_CHANGED", "The judged lock was replaced before it could be reclaimed")
|
|
368
|
+
};
|
|
336
369
|
}
|
|
337
370
|
await sweepStagedLocks(dirname(path), options.machineIdentity, options.signal);
|
|
338
371
|
return await createOwned(path, options, state !== undefined).catch((error) => {
|
|
@@ -30,6 +30,11 @@ import {
|
|
|
30
30
|
import {
|
|
31
31
|
isRepeatableRead
|
|
32
32
|
} from "./index-332d0m9g.js";
|
|
33
|
+
import {
|
|
34
|
+
MCP_FILE_NAME_META_KEY2,
|
|
35
|
+
McpImageContentSchema,
|
|
36
|
+
McpAudioContentSchema
|
|
37
|
+
} from "./index-gy9x38a2.js";
|
|
33
38
|
import {
|
|
34
39
|
readContractStreamItems,
|
|
35
40
|
contractStreamLifetimeExceeded
|
|
@@ -43,8 +48,9 @@ import {
|
|
|
43
48
|
containedEntryMetadata
|
|
44
49
|
} from "./index-ww3gss55.js";
|
|
45
50
|
import {
|
|
46
|
-
pollUntil
|
|
47
|
-
|
|
51
|
+
pollUntil,
|
|
52
|
+
mediaExtension
|
|
53
|
+
} from "./index-9cxxfkhb.js";
|
|
48
54
|
import {
|
|
49
55
|
collectToolSurface
|
|
50
56
|
} from "./index-993vtv1w.js";
|
|
@@ -59,6 +65,9 @@ import {
|
|
|
59
65
|
isUnsafeKey,
|
|
60
66
|
safeJsonParse
|
|
61
67
|
} from "./index-zsarb5xp.js";
|
|
68
|
+
import {
|
|
69
|
+
assertPositiveSafeInteger
|
|
70
|
+
} from "./index-0s4xebbg.js";
|
|
62
71
|
import {
|
|
63
72
|
formatZodError2
|
|
64
73
|
} from "./index-1eeqpadm.js";
|
|
@@ -189,17 +198,20 @@ function prepareCliCommandEmission(policy, result, options) {
|
|
|
189
198
|
};
|
|
190
199
|
}
|
|
191
200
|
}
|
|
192
|
-
function emitCliCommandResult(policy, result, options, writers, emit) {
|
|
201
|
+
function emitCliCommandResult(policy, result, options, writers, emit, shown) {
|
|
193
202
|
const emission = prepareCliCommandEmission(policy, result, options);
|
|
194
|
-
if (emission.result.ok
|
|
195
|
-
return
|
|
196
|
-
|
|
197
|
-
if (emission.result.ok && emission.presentation !== undefined) {
|
|
203
|
+
if (!emission.result.ok)
|
|
204
|
+
return emitResult2(emission.result, writers, emit);
|
|
205
|
+
if (emission.presentation !== undefined) {
|
|
198
206
|
writers.stdout(emission.presentation);
|
|
199
207
|
return emission.successExitCode;
|
|
200
208
|
}
|
|
201
|
-
const
|
|
202
|
-
|
|
209
|
+
const printed = shown ?? emission.result;
|
|
210
|
+
if (emission.presentationFailure !== undefined) {
|
|
211
|
+
return emitPresentationFailure(printed, emission.presentationFailure, writers, emit);
|
|
212
|
+
}
|
|
213
|
+
emitResult2(printed, writers, emit);
|
|
214
|
+
return emission.successExitCode;
|
|
203
215
|
}
|
|
204
216
|
function cliCommandPresentationSchema(definition) {
|
|
205
217
|
return buildToolPresentationSchema({
|
|
@@ -931,7 +943,8 @@ function createCliIo(config) {
|
|
|
931
943
|
}
|
|
932
944
|
|
|
933
945
|
// src/tools/cli/download.ts
|
|
934
|
-
import {
|
|
946
|
+
import { createHash } from "node:crypto";
|
|
947
|
+
import { basename as basename2, resolve } from "node:path";
|
|
935
948
|
|
|
936
949
|
// src/internal/write-download.ts
|
|
937
950
|
import path from "node:path";
|
|
@@ -949,39 +962,150 @@ async function writeDownload(root, name, data) {
|
|
|
949
962
|
});
|
|
950
963
|
}
|
|
951
964
|
|
|
965
|
+
// src/tools/cli/inline-files.ts
|
|
966
|
+
import { basename } from "node:path";
|
|
967
|
+
import { pathToFileURL } from "node:url";
|
|
968
|
+
import { z as z2 } from "zod";
|
|
969
|
+
var EmbeddedResourceSchema = z2.object({
|
|
970
|
+
type: z2.literal("resource"),
|
|
971
|
+
resource: z2.union([
|
|
972
|
+
z2.object({ uri: z2.string(), mimeType: z2.string().optional(), blob: z2.string() }),
|
|
973
|
+
z2.object({ uri: z2.string(), mimeType: z2.string().optional(), text: z2.string() })
|
|
974
|
+
])
|
|
975
|
+
});
|
|
976
|
+
var InlineFileSchema = z2.discriminatedUnion("type", [
|
|
977
|
+
McpImageContentSchema,
|
|
978
|
+
McpAudioContentSchema,
|
|
979
|
+
EmbeddedResourceSchema
|
|
980
|
+
]);
|
|
981
|
+
function inlineFileBlocks(data) {
|
|
982
|
+
if (!isRecord(data) || !Array.isArray(data.content))
|
|
983
|
+
return [];
|
|
984
|
+
return data.content.flatMap((part, index) => {
|
|
985
|
+
const parsed = InlineFileSchema.safeParse(part);
|
|
986
|
+
return parsed.success ? [{ index, file: parsed.data }] : [];
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function decodeBase64(data, maxBytes) {
|
|
990
|
+
const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
|
|
991
|
+
const decodedLength = Math.floor((data.length - padding) * 3 / 4);
|
|
992
|
+
if (data.length > Math.ceil(maxBytes / 3) * 4 || decodedLength > maxBytes) {
|
|
993
|
+
throw new Error(`file exceeds the ${maxBytes}-byte cap`);
|
|
994
|
+
}
|
|
995
|
+
if (data.length % 4 === 1 || padding > 0 && data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(data)) {
|
|
996
|
+
throw new Error("invalid base64");
|
|
997
|
+
}
|
|
998
|
+
const bytes = Buffer.from(data, "base64");
|
|
999
|
+
if (!bytes.toString("base64").startsWith(data))
|
|
1000
|
+
throw new Error("invalid base64");
|
|
1001
|
+
return bytes;
|
|
1002
|
+
}
|
|
1003
|
+
function encodeText(text, maxBytes) {
|
|
1004
|
+
const bytes = text.length > maxBytes ? undefined : Buffer.from(text, "utf8");
|
|
1005
|
+
if (!bytes || bytes.length > maxBytes) {
|
|
1006
|
+
throw new Error(`file exceeds the ${maxBytes}-byte cap`);
|
|
1007
|
+
}
|
|
1008
|
+
return bytes;
|
|
1009
|
+
}
|
|
1010
|
+
function inlineFileBytes(file, maxBytes) {
|
|
1011
|
+
if (file.type !== "resource")
|
|
1012
|
+
return decodeBase64(file.data, maxBytes);
|
|
1013
|
+
return "blob" in file.resource ? decodeBase64(file.resource.blob, maxBytes) : encodeText(file.resource.text, maxBytes);
|
|
1014
|
+
}
|
|
1015
|
+
function uriFileName(uri) {
|
|
1016
|
+
try {
|
|
1017
|
+
return basename(new URL(uri).pathname);
|
|
1018
|
+
} catch {
|
|
1019
|
+
return "";
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
function inlineFileMimeType(file) {
|
|
1023
|
+
return file.type === "resource" ? file.resource.mimeType : file.mimeType;
|
|
1024
|
+
}
|
|
1025
|
+
function ownFileName(file) {
|
|
1026
|
+
if (file.type === "resource")
|
|
1027
|
+
return uriFileName(file.resource.uri) || undefined;
|
|
1028
|
+
const name = file._meta?.[MCP_FILE_NAME_META_KEY2];
|
|
1029
|
+
return typeof name === "string" ? name : undefined;
|
|
1030
|
+
}
|
|
1031
|
+
function inlineFileName(file, digest) {
|
|
1032
|
+
return ownFileName(file) ?? `${file.type}-${digest}${mediaExtension(inlineFileMimeType(file) ?? "") ?? ".bin"}`;
|
|
1033
|
+
}
|
|
1034
|
+
function linkSavedFiles(data, blocks, saved) {
|
|
1035
|
+
if (!isRecord(data) || !Array.isArray(data.content))
|
|
1036
|
+
return data;
|
|
1037
|
+
const links = new Map;
|
|
1038
|
+
for (const block of blocks) {
|
|
1039
|
+
const file = saved(block);
|
|
1040
|
+
if (!file)
|
|
1041
|
+
continue;
|
|
1042
|
+
const mimeType = inlineFileMimeType(block.file);
|
|
1043
|
+
links.set(block.index, {
|
|
1044
|
+
type: "resource_link",
|
|
1045
|
+
uri: pathToFileURL(file.path).href,
|
|
1046
|
+
name: file.name,
|
|
1047
|
+
...mimeType !== undefined && { mimeType },
|
|
1048
|
+
size: file.size
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
if (links.size === 0)
|
|
1052
|
+
return data;
|
|
1053
|
+
return { ...data, content: data.content.map((part, index) => links.get(index) ?? part) };
|
|
1054
|
+
}
|
|
1055
|
+
|
|
952
1056
|
// src/tools/cli/download.ts
|
|
953
1057
|
var DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
|
|
954
|
-
async function
|
|
1058
|
+
async function saveResultMedia(data, options) {
|
|
1059
|
+
const blocks = inlineFileBlocks(data);
|
|
1060
|
+
const sources = [...options.download?.(data) ?? [], ...blocks];
|
|
1061
|
+
if (sources.length === 0) {
|
|
1062
|
+
if (!options.quiet)
|
|
1063
|
+
options.stderr(`--output-dir: the result carries no files to save
|
|
1064
|
+
`);
|
|
1065
|
+
return { ok: true, data };
|
|
1066
|
+
}
|
|
1067
|
+
const batch = await saveBatch(sources, options);
|
|
1068
|
+
return {
|
|
1069
|
+
ok: batch.ok,
|
|
1070
|
+
data: linkSavedFiles(data, blocks, (block) => batch.files.get(block))
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
async function saveBatch(sources, { dir, allowPrivateHosts, maxBytes, timeoutMs, quiet, stderr }) {
|
|
955
1074
|
const root = resolve(dir);
|
|
956
|
-
|
|
957
|
-
return true;
|
|
1075
|
+
const files = new Map;
|
|
958
1076
|
let directory;
|
|
959
1077
|
try {
|
|
960
1078
|
directory = await openPinnedDirectory(root, { create: true, readable: false });
|
|
961
1079
|
} catch (error) {
|
|
962
1080
|
stderr(`failed to prepare download directory: ${error instanceof Error ? error.message : String(error)}
|
|
963
1081
|
`);
|
|
964
|
-
return false;
|
|
1082
|
+
return { ok: false, files };
|
|
965
1083
|
}
|
|
966
|
-
let
|
|
1084
|
+
let ok = true;
|
|
1085
|
+
const digests = new Map;
|
|
967
1086
|
try {
|
|
968
|
-
for (const
|
|
1087
|
+
for (const source of sources) {
|
|
969
1088
|
try {
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1089
|
+
const bytes = "url" in source ? await fetchDownload(source.url, allowPrivateHosts, maxBytes, timeoutMs) : inlineFileBytes(source.file, maxBytes);
|
|
1090
|
+
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
1091
|
+
const name = basename2("url" in source ? source.name : inlineFileName(source.file, digest));
|
|
1092
|
+
const path = resolve(root, name);
|
|
1093
|
+
const written = digests.get(name);
|
|
1094
|
+
if (written === undefined) {
|
|
1095
|
+
await writeDownload(directory, name, bytes);
|
|
1096
|
+
digests.set(name, digest);
|
|
1097
|
+
if (!quiet)
|
|
1098
|
+
stderr(`saved ${path} (${(bytes.length / 1024).toFixed(0)}KB)
|
|
980
1099
|
`);
|
|
1100
|
+
} else if (written !== digest) {
|
|
1101
|
+
throw new Error(`another file of this batch is already saved as ${JSON.stringify(name)}`);
|
|
1102
|
+
}
|
|
1103
|
+
files.set(source, { path, name, size: bytes.length });
|
|
981
1104
|
} catch (err) {
|
|
982
|
-
|
|
1105
|
+
ok = false;
|
|
983
1106
|
const reason = errnoOf(err) ?? (err instanceof Error ? err.message : String(err));
|
|
984
|
-
|
|
1107
|
+
const subject = "url" in source ? `failed to download ${source.url}` : `failed to save content[${source.index}]`;
|
|
1108
|
+
stderr(`${subject}: ${reason}
|
|
985
1109
|
`);
|
|
986
1110
|
}
|
|
987
1111
|
}
|
|
@@ -989,12 +1113,21 @@ async function downloadResults(files, dir, stderr, quiet, allowPrivate, maxBytes
|
|
|
989
1113
|
try {
|
|
990
1114
|
await directory.close();
|
|
991
1115
|
} catch (error) {
|
|
992
|
-
|
|
1116
|
+
ok = false;
|
|
993
1117
|
stderr(`failed to close download directory: ${error instanceof Error ? error.message : String(error)}
|
|
994
1118
|
`);
|
|
995
1119
|
}
|
|
996
1120
|
}
|
|
997
|
-
return
|
|
1121
|
+
return { ok, files };
|
|
1122
|
+
}
|
|
1123
|
+
async function fetchDownload(url, allowPrivateHosts, maxBytes, timeoutMs) {
|
|
1124
|
+
const res = await fetchGuarded(new URL(url), allowPrivateHosts, { timeoutMs });
|
|
1125
|
+
if (!res.ok)
|
|
1126
|
+
throw new Error(`HTTP ${res.status}`);
|
|
1127
|
+
const bytes = await readCapped(res, maxBytes);
|
|
1128
|
+
if (!bytes)
|
|
1129
|
+
throw new Error(`file exceeds the ${maxBytes}-byte cap`);
|
|
1130
|
+
return bytes;
|
|
998
1131
|
}
|
|
999
1132
|
|
|
1000
1133
|
// src/tools/cli/help.ts
|
|
@@ -1002,7 +1135,7 @@ var GLOBAL_OPTIONS = [
|
|
|
1002
1135
|
["--json", "Emit compact success/error JSON records (for scripts)"],
|
|
1003
1136
|
["--wait", "Block-poll an async result to a terminal state"],
|
|
1004
1137
|
["--wait-timeout <s>", "Override the --wait timeout in seconds"],
|
|
1005
|
-
["--output-dir <dir>", "
|
|
1138
|
+
["--output-dir <dir>", "Save the files a result names or carries into a directory"],
|
|
1006
1139
|
["--quiet", "Suppress non-essential stderr output"],
|
|
1007
1140
|
["--dry-run", "Print the resolved call without executing it"],
|
|
1008
1141
|
["--schema", "Print the JSON Schema of a command input and output"],
|
|
@@ -1410,7 +1543,7 @@ async function buildManagedSurface(session, typedGlobals, forExecution) {
|
|
|
1410
1543
|
}
|
|
1411
1544
|
|
|
1412
1545
|
// src/tools/cli/args.ts
|
|
1413
|
-
import { z as
|
|
1546
|
+
import { z as z3 } from "zod";
|
|
1414
1547
|
|
|
1415
1548
|
// src/tools/cli/args-json.ts
|
|
1416
1549
|
function cliFieldOption(option, fields) {
|
|
@@ -1818,7 +1951,7 @@ function extractCliGlobalOptions2(argv, schema) {
|
|
|
1818
1951
|
try {
|
|
1819
1952
|
coerced = coerceJsonArgs2(args, schema);
|
|
1820
1953
|
} catch (error) {
|
|
1821
|
-
if (error instanceof
|
|
1954
|
+
if (error instanceof z3.ZodError)
|
|
1822
1955
|
refuseGlobalOption(error.issues[0]);
|
|
1823
1956
|
throw error;
|
|
1824
1957
|
}
|
|
@@ -1914,6 +2047,7 @@ function createCliSession(config, io) {
|
|
|
1914
2047
|
if (config.auth !== undefined && config.resolveAuth !== undefined) {
|
|
1915
2048
|
throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
|
|
1916
2049
|
}
|
|
2050
|
+
assertPositiveSafeInteger("createCli maxDownloadBytes", config.maxDownloadBytes);
|
|
1917
2051
|
const applicationOptions = config.globalOptions ? jsonSchemaFields(buildToolPresentationSchema({
|
|
1918
2052
|
inputSchema: config.globalOptions,
|
|
1919
2053
|
unrepresentable: "any"
|
|
@@ -2451,11 +2585,6 @@ async function runManagedCommand(session, route, command, managed) {
|
|
|
2451
2585
|
}
|
|
2452
2586
|
if (options.waitTimeout !== undefined && !options.wait) {
|
|
2453
2587
|
stderr(`--wait-timeout requires --wait
|
|
2454
|
-
`);
|
|
2455
|
-
return exit(2);
|
|
2456
|
-
}
|
|
2457
|
-
if (options.outputDir !== undefined && !config.download) {
|
|
2458
|
-
stderr(`--output-dir is not configured for this CLI
|
|
2459
2588
|
`);
|
|
2460
2589
|
return exit(2);
|
|
2461
2590
|
}
|
|
@@ -2525,40 +2654,54 @@ async function executeManagedTool(session, route, command, managed, tool, { tool
|
|
|
2525
2654
|
}
|
|
2526
2655
|
return result;
|
|
2527
2656
|
}
|
|
2528
|
-
async function emitManagedResult(session, command,
|
|
2657
|
+
async function emitManagedResult(session, command, result, options, repeatable) {
|
|
2529
2658
|
const { config } = session;
|
|
2530
2659
|
const { stdout, stderr, exit } = session.io;
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2660
|
+
const emit = { ...emitOptionsFor(config, options.json, command), repeatable };
|
|
2661
|
+
if (!result.ok)
|
|
2662
|
+
return exit(emitResult2(result, { stdout, stderr }, emit));
|
|
2663
|
+
let shown = result;
|
|
2664
|
+
let mediaExitCode = 0;
|
|
2665
|
+
if (options.outputDir !== undefined) {
|
|
2666
|
+
const saved = await saveResultMedia(result.data, {
|
|
2667
|
+
dir: options.outputDir,
|
|
2668
|
+
download: config.download,
|
|
2669
|
+
allowPrivateHosts: config.allowPrivateDownloadHosts ?? false,
|
|
2670
|
+
maxBytes: config.maxDownloadBytes ?? DEFAULT_DOWNLOAD_MAX_BYTES,
|
|
2671
|
+
timeoutMs: config.downloadTimeoutMs,
|
|
2672
|
+
quiet: options.quiet,
|
|
2673
|
+
stderr
|
|
2674
|
+
});
|
|
2675
|
+
shown = { ...result, data: saved.data };
|
|
2676
|
+
if (!saved.ok)
|
|
2677
|
+
mediaExitCode = 1;
|
|
2535
2678
|
}
|
|
2536
|
-
if (options.view
|
|
2679
|
+
if (options.view) {
|
|
2537
2680
|
let viewed;
|
|
2538
2681
|
try {
|
|
2539
|
-
viewed = renderCliView2(
|
|
2682
|
+
viewed = renderCliView2(shown.data, options.view);
|
|
2540
2683
|
} catch (error) {
|
|
2541
2684
|
const failure = error instanceof CliArgumentError2 ? {
|
|
2542
2685
|
ok: false,
|
|
2543
2686
|
code: "BAD_REQUEST",
|
|
2544
2687
|
details: { message: error.message }
|
|
2545
2688
|
} : toolResultFromError(error);
|
|
2546
|
-
return exit(emitPresentationFailure(
|
|
2689
|
+
return exit(emitPresentationFailure(shown, failure, { stdout, stderr }, emit));
|
|
2547
2690
|
}
|
|
2548
2691
|
if (viewed.kind === "text") {
|
|
2549
2692
|
stdout(viewed.text);
|
|
2550
|
-
return exit(
|
|
2693
|
+
return exit(mediaExitCode);
|
|
2551
2694
|
}
|
|
2552
2695
|
if (viewed.order) {
|
|
2553
2696
|
stdout(`${stringifyGroups(viewed.data, viewed.order, options.json === true)}
|
|
2554
2697
|
`);
|
|
2555
|
-
return exit(
|
|
2698
|
+
return exit(mediaExitCode);
|
|
2556
2699
|
}
|
|
2557
|
-
|
|
2700
|
+
shown = { ...shown, data: viewed.data };
|
|
2558
2701
|
}
|
|
2559
2702
|
const policy = options.view === undefined && !options.wait ? cliResultPolicy(config, command) : undefined;
|
|
2560
|
-
const exitCode = emitCliCommandResult(policy, result, options, { stdout, stderr },
|
|
2561
|
-
return exit(
|
|
2703
|
+
const exitCode = emitCliCommandResult(policy, result, options, { stdout, stderr }, emit, shown);
|
|
2704
|
+
return exit(mediaExitCode || exitCode);
|
|
2562
2705
|
}
|
|
2563
2706
|
|
|
2564
2707
|
// src/tools/cli/run-native.ts
|
|
@@ -129,9 +129,4 @@ function createScopedImplement2() {
|
|
|
129
129
|
return Object.assign(implementScoped, { stream, declare });
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
function mediaTypeEssence(contentType) {
|
|
134
|
-
return (contentType ?? "").split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export { defineMultipartStream2, createMultipartStream2, contractOnlyService, bindContract, implement2, createImplement2, createScopedImplement2, mediaTypeEssence };
|
|
132
|
+
export { defineMultipartStream2, createMultipartStream2, contractOnlyService, bindContract, implement2, createImplement2, createScopedImplement2 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"AA8BA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAGxB,MAAM,wBAAwB,CAAC;AAMhC,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,uFAAuF;IACvF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IACE,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AAoWN;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,EACpC,KAAK,SAAI,GACR,OAAO,CAAC,oBAAoB,CAAC,CAkC/B;AAED,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-extension.d.ts","sourceRoot":"","sources":["../../src/internal/media-extension.ts"],"names":[],"mappings":"AAeA,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEtE"}
|
package/dist/tools/cli/args.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface CliRunOptions {
|
|
|
27
27
|
wait: boolean;
|
|
28
28
|
/** `--wait-timeout <seconds>` — override the poll timeout. */
|
|
29
29
|
waitTimeout?: number;
|
|
30
|
-
/** `--output-dir <dir>` —
|
|
30
|
+
/** `--output-dir <dir>` — save the files a result names or carries into this directory. */
|
|
31
31
|
outputDir?: string;
|
|
32
32
|
/** `--quiet` — suppress non-essential stderr chatter. */
|
|
33
33
|
quiet: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,aAAa,CAAC;AAMjE,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,aAAa,CAAC;AAMjE,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,IAAI,EAAE,OAAO,CAAC;IACd,0FAA0F;IAC1F,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,+BAA+B;IAC/B,OAAO,EAAE,aAAa,CAAC;CACxB;AAwHD;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,EAC7B,MAAM,GAAE;IACN,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,GACL,aAAa,CAsBf;AAED,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AASD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,SAAS,GAC9B,qBAAqB,CAyDvB"}
|
|
@@ -82,10 +82,16 @@ export declare function cliCommandResultPolicy(definition: CliCommandDefinition)
|
|
|
82
82
|
* The single place a policy meets the terminal: a native command and a managed
|
|
83
83
|
* one answer through it, so `present`, `exitCode` and a failed presentation
|
|
84
84
|
* behave identically on both.
|
|
85
|
+
*
|
|
86
|
+
* The policy judges `result`, the operation's own answer. `shown` is what stdout
|
|
87
|
+
* prints when the policy brings no presenter: the same answer, unless the caller
|
|
88
|
+
* has already moved part of it elsewhere (a view, media saved to files).
|
|
85
89
|
*/
|
|
86
90
|
export declare function emitCliCommandResult(policy: CliResultPolicy<unknown> | undefined, result: ToolResult, options: Readonly<CliRunOptions>, writers: CliWriters, emit: EmitOptions & {
|
|
87
91
|
repeatable: boolean;
|
|
88
|
-
}
|
|
92
|
+
}, shown?: Extract<ToolResult, {
|
|
93
|
+
ok: true;
|
|
94
|
+
}>): number;
|
|
89
95
|
export declare function cliCommandPresentationSchema(definition: CliCommandDefinition): Record<string, unknown>;
|
|
90
96
|
/** Execute a CLI-only definition without inventing a tool operation identity. */
|
|
91
97
|
export declare function executeCliCommand(definition: CliCommandDefinition, rawArgs: Record<string, unknown>, options: CliRunOptions, writers: CliWriters, coerceJson: boolean, globals?: Readonly<Record<string, unknown>>): Promise<ToolResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGjD,OAAO,EAAoB,KAAK,UAAU,EAAuB,MAAM,mBAAmB,CAAC;AAG3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAGjB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,SAAS,CAAE,SAAQ,UAAU;IAC7E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC;;;;;OAKG;IACH,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,wBAAwB,CAAC,MAAM,SAAS,SAAS;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,OAAO;IAItC,0FAA0F;IAC1F,OAAO,CAAC,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;KAAE,GAAG,MAAM,CAAC;IACjF,6DAA6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AO,EAAE,QAAQ,CAAC,aAAa,CAAC,EAChC,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,WAAW,GAAG;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,EAC3C,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,GACxC,MAAM,CAaR;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAED,iFAAiF;AACjF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,OAAO,EACnB,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAC9C,OAAO,CAAC,UAAU,CAAC,CAoCrB"}
|
|
@@ -59,7 +59,7 @@ export interface CliConfig<TAuth = unknown, TContext extends Record<string, unkn
|
|
|
59
59
|
passthrough?: Record<string, string>;
|
|
60
60
|
/** Per-command `--wait` polling behaviour, keyed by command name. */
|
|
61
61
|
wait?: Record<string, CliWaitConfig>;
|
|
62
|
-
/**
|
|
62
|
+
/** Name a result's URL files for `--output-dir`; files inline in `content` need no callback. */
|
|
63
63
|
download?: (result: unknown) => Array<{
|
|
64
64
|
url: string;
|
|
65
65
|
name: string;
|
|
@@ -69,7 +69,10 @@ export interface CliConfig<TAuth = unknown, TContext extends Record<string, unkn
|
|
|
69
69
|
* Default `false` — the SSRF guard, since the URLs come from handler output.
|
|
70
70
|
*/
|
|
71
71
|
allowPrivateDownloadHosts?: boolean;
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Byte cap per URL or inline file of `--output-dir`. A positive safe
|
|
74
|
+
* integer, checked when the CLI is created. Default 100 MB.
|
|
75
|
+
*/
|
|
73
76
|
maxDownloadBytes?: number;
|
|
74
77
|
/**
|
|
75
78
|
* Deadline for producing response headers per `--output-dir` download (DNS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,WAAW,SAAS,CACxB,KAAK,GAAG,OAAO,EACf,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,QAAQ,SAAS,SAAS,GAAG,SAAS,CACtC,SAAQ,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC;IACnD,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACtE;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,C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,MAAM,EAAE,CAAC;IAChB,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,gEAAgE;IAChE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACtC"}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
/** Default
|
|
1
|
+
/** Default decoded byte cap per file — overridable via `maxDownloadBytes`. */
|
|
2
2
|
export declare const DEFAULT_DOWNLOAD_MAX_BYTES: number;
|
|
3
|
-
|
|
4
|
-
export declare function downloadResults(files: Array<{
|
|
3
|
+
interface UrlMedia {
|
|
5
4
|
url: string;
|
|
6
5
|
name: string;
|
|
7
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export interface SaveResultMediaOptions {
|
|
8
|
+
/** `--output-dir` as typed; resolved and pinned once for the whole batch. */
|
|
9
|
+
dir: string;
|
|
10
|
+
/** The application's `download` callback: the URL media a result names. */
|
|
11
|
+
download: ((result: unknown) => UrlMedia[]) | undefined;
|
|
12
|
+
allowPrivateHosts: boolean;
|
|
13
|
+
maxBytes: number;
|
|
14
|
+
timeoutMs: number | undefined;
|
|
15
|
+
quiet: boolean;
|
|
16
|
+
stderr: (text: string) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `--output-dir`: save the URL files a successful result names and the files its `content`
|
|
20
|
+
* carries inline as one batch, reporting each outcome to stderr. `ok` is false when any file
|
|
21
|
+
* failed. `data` is the result as stdout prints it: a saved inline block is a link to its
|
|
22
|
+
* file, everything else is as it was.
|
|
23
|
+
*/
|
|
24
|
+
export declare function saveResultMedia(data: unknown, options: SaveResultMediaOptions): Promise<{
|
|
25
|
+
ok: boolean;
|
|
26
|
+
data: unknown;
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
|
8
29
|
//# sourceMappingURL=download.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/download.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/download.ts"],"names":[],"mappings":"AAeA,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,QAAoB,CAAC;AAE5D,UAAU,QAAQ;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAWD,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC;IACxD,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAYzC"}
|