@tangle-network/agent-app 0.60.77 → 0.60.79
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-KBTY4AAU.js → chunk-TVGL2OAC.js} +1 -1
- package/dist/{chunk-KBTY4AAU.js.map → chunk-TVGL2OAC.js.map} +1 -1
- package/dist/signoff/cli.js +1 -1
- package/dist/signoff/index.js +1 -1
- package/dist/signoff/shell-alignment-cli.d.ts +0 -1
- package/dist/workspace-export/engine.d.ts +2 -0
- package/dist/workspace-export/index.js +48 -22
- package/dist/workspace-export/index.js.map +1 -1
- package/package.json +1 -1
package/dist/signoff/cli.js
CHANGED
package/dist/signoff/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type ShellAlignmentOptions } from './shell-alignment';
|
|
2
|
-
export declare function shellAlignmentUsage(): string;
|
|
3
2
|
export declare class ShellAlignmentUsageError extends Error {
|
|
4
3
|
}
|
|
5
4
|
export declare function parseShellAlignmentArgs(argv: readonly string[]): ShellAlignmentOptions & {
|
|
@@ -24,6 +24,8 @@ export interface ExportEngineOptions {
|
|
|
24
24
|
}): readonly string[] | Promise<readonly string[]>;
|
|
25
25
|
/** Storage key prefix. Default `workspace-exports`. */
|
|
26
26
|
prefix?: string;
|
|
27
|
+
/** Sandbox archives read at once in one request. Default 4. */
|
|
28
|
+
archiveConcurrency?: number;
|
|
27
29
|
now?: () => number;
|
|
28
30
|
}
|
|
29
31
|
export declare function createExportEngine(options: ExportEngineOptions): {
|
|
@@ -722,6 +722,18 @@ function createExportEngine(options) {
|
|
|
722
722
|
const { storage } = options;
|
|
723
723
|
const prefix = options.prefix ?? "workspace-exports";
|
|
724
724
|
const now = options.now ?? (() => Date.now());
|
|
725
|
+
const archiveConcurrency = Math.max(1, Math.floor(options.archiveConcurrency ?? 4));
|
|
726
|
+
function archiveBatch(pending, from) {
|
|
727
|
+
const first = pending[from];
|
|
728
|
+
if (first.unit.kind !== "archive" || first.unit.attempts > 0) return [first];
|
|
729
|
+
const batch = [first];
|
|
730
|
+
for (let i = from + 1; i < pending.length && batch.length < archiveConcurrency; i += 1) {
|
|
731
|
+
const candidate = pending[i];
|
|
732
|
+
if (candidate.unit.kind !== "archive" || candidate.unit.attempts > 0) break;
|
|
733
|
+
batch.push(candidate);
|
|
734
|
+
}
|
|
735
|
+
return batch;
|
|
736
|
+
}
|
|
725
737
|
const base = (workspaceId, id) => `${prefix}/${assertSafeKeySegment(workspaceId)}/${assertSafeKeySegment(id)}`;
|
|
726
738
|
const jobKey = (workspaceId, id) => `${base(workspaceId, id)}/job.json`;
|
|
727
739
|
const archiveKey = (workspaceId, id) => `${base(workspaceId, id)}/archive.zip`;
|
|
@@ -1043,37 +1055,51 @@ function createExportEngine(options) {
|
|
|
1043
1055
|
const plan = await options.plan({ workspaceId });
|
|
1044
1056
|
const scanner = createSecretScanner({ knownSecrets: await options.knownSecrets?.({ workspaceId }) ?? [] });
|
|
1045
1057
|
const sources = new Map(plan.sources.map((s) => [s.name, s]));
|
|
1046
|
-
|
|
1047
|
-
|
|
1058
|
+
const pending = job.units.flatMap((unit, index) => unit.status === "pending" ? [{ unit, index }] : []);
|
|
1059
|
+
let next = 0;
|
|
1060
|
+
while (next < pending.length) {
|
|
1048
1061
|
if (now() > deadline) break;
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1062
|
+
const batch = archiveBatch(pending, next);
|
|
1063
|
+
next += batch.length;
|
|
1064
|
+
const exhausted = batch.find(({ unit: unit2 }) => unit2.attempts >= MAX_ATTEMPTS);
|
|
1065
|
+
if (exhausted) {
|
|
1066
|
+
const { unit: unit2 } = exhausted;
|
|
1067
|
+
unit2.status = "failed";
|
|
1068
|
+
unit2.error ??= "the request exporting this source ended before it finished";
|
|
1053
1069
|
job.status = "failed";
|
|
1054
|
-
job.error = `${
|
|
1070
|
+
job.error = `${unit2.name}: ${unit2.error}`;
|
|
1055
1071
|
etag = await saveJob(job, etag);
|
|
1056
1072
|
break;
|
|
1057
1073
|
}
|
|
1058
|
-
unit.attempts += 1;
|
|
1074
|
+
for (const { unit: unit2 } of batch) unit2.attempts += 1;
|
|
1059
1075
|
etag = await saveJob(job, etag);
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1076
|
+
const failed = await Promise.all(
|
|
1077
|
+
batch.map(async ({ unit: unit2, index }) => {
|
|
1078
|
+
const source = sources.get(unit2.name);
|
|
1079
|
+
try {
|
|
1080
|
+
if (!source || source.kind !== unit2.kind) throw new Error("source is no longer available");
|
|
1081
|
+
await runUnit(job, unit2, index, source, scanner, deadline);
|
|
1082
|
+
unit2.error = void 0;
|
|
1083
|
+
return false;
|
|
1084
|
+
} catch (err) {
|
|
1085
|
+
unit2.error = errorText(scanner, err);
|
|
1086
|
+
if (unit2.cursor === void 0) unit2.entries = [];
|
|
1087
|
+
if (unit2.attempts >= MAX_ATTEMPTS) unit2.status = "failed";
|
|
1088
|
+
return true;
|
|
1089
|
+
}
|
|
1090
|
+
})
|
|
1091
|
+
);
|
|
1092
|
+
const dead = batch.find(({ unit: unit2 }) => unit2.status === "failed");
|
|
1093
|
+
if (dead) {
|
|
1094
|
+
job.status = "failed";
|
|
1095
|
+
job.error = `${dead.unit.name}: ${dead.unit.error}`;
|
|
1096
|
+
}
|
|
1097
|
+
job.lease = { id: job.lease.id, until: now() + LEASE_MS };
|
|
1098
|
+
if (failed.includes(true)) {
|
|
1073
1099
|
etag = await saveJob(job, etag);
|
|
1074
1100
|
break;
|
|
1075
1101
|
}
|
|
1076
|
-
|
|
1102
|
+
const { unit } = batch[0];
|
|
1077
1103
|
if (unit.status === "pending") {
|
|
1078
1104
|
unit.attempts = 0;
|
|
1079
1105
|
etag = await saveJob(job, etag);
|