@aexhq/sdk 0.39.0 → 0.40.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 +22 -16
- package/dist/_contracts/api-key.d.ts +49 -0
- package/dist/_contracts/api-key.js +87 -0
- package/dist/_contracts/bundle-manifest.d.ts +86 -0
- package/dist/_contracts/bundle-manifest.js +157 -0
- package/dist/_contracts/error-codes.d.ts +26 -0
- package/dist/_contracts/error-codes.js +79 -0
- package/dist/_contracts/error-factory.d.ts +32 -0
- package/dist/_contracts/error-factory.js +142 -0
- package/dist/_contracts/event-envelope.d.ts +33 -10
- package/dist/_contracts/event-envelope.js +46 -10
- package/dist/_contracts/event-view.d.ts +123 -0
- package/dist/_contracts/event-view.js +120 -0
- package/dist/_contracts/http.js +12 -3
- package/dist/_contracts/index.d.ts +8 -4
- package/dist/_contracts/index.js +11 -7
- package/dist/_contracts/models.d.ts +15 -0
- package/dist/_contracts/models.js +33 -0
- package/dist/_contracts/operations.d.ts +53 -2
- package/dist/_contracts/operations.js +119 -7
- package/dist/_contracts/run-record.d.ts +3 -2
- package/dist/_contracts/runtime-types.d.ts +126 -36
- package/dist/_contracts/runtime-types.js +33 -1
- package/dist/_contracts/sdk-errors.d.ts +61 -2
- package/dist/_contracts/sdk-errors.js +83 -3
- package/dist/_contracts/sdk-secrets.js +31 -6
- package/dist/_contracts/stable.d.ts +14 -0
- package/dist/_contracts/stable.js +14 -0
- package/dist/_contracts/status.d.ts +28 -1
- package/dist/_contracts/status.js +48 -3
- package/dist/_contracts/submission.d.ts +79 -2
- package/dist/_contracts/submission.js +148 -5
- package/dist/_contracts/suggest.d.ts +15 -0
- package/dist/_contracts/suggest.js +54 -0
- package/dist/asset-upload.d.ts +26 -0
- package/dist/asset-upload.js +218 -3
- package/dist/asset-upload.js.map +1 -1
- package/dist/bundle.d.ts +14 -3
- package/dist/bundle.js +34 -14
- package/dist/bundle.js.map +1 -1
- package/dist/canonical-zip.d.ts +68 -0
- package/dist/canonical-zip.js +307 -0
- package/dist/canonical-zip.js.map +1 -0
- package/dist/cli.mjs +1923 -338
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +217 -58
- package/dist/client.js +749 -261
- package/dist/client.js.map +1 -1
- package/dist/file.d.ts +33 -6
- package/dist/file.js +120 -54
- package/dist/file.js.map +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/dist/node-fs.d.ts +26 -9
- package/dist/node-fs.js +13 -38
- package/dist/node-fs.js.map +1 -1
- package/dist/node-walk.d.ts +69 -0
- package/dist/node-walk.js +146 -0
- package/dist/node-walk.js.map +1 -0
- package/dist/retry.d.ts +9 -13
- package/dist/retry.js +18 -17
- package/dist/retry.js.map +1 -1
- package/dist/skill.d.ts +16 -4
- package/dist/skill.js +18 -9
- package/dist/skill.js.map +1 -1
- package/dist/tool.d.ts +14 -2
- package/dist/tool.js +33 -7
- package/dist/tool.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/authentication.md +29 -5
- package/docs/billing.md +6 -0
- package/docs/concepts/agent-tools.md +11 -0
- package/docs/defaults.md +1 -0
- package/docs/errors.md +64 -4
- package/docs/events.md +84 -49
- package/docs/limits-and-quotas.md +24 -0
- package/docs/networking.md +7 -1
- package/docs/outputs.md +36 -7
- package/docs/quickstart.md +17 -7
- package/docs/run-config.md +3 -3
- package/docs/secrets.md +14 -0
- package/examples/feature-tour.ts +4 -6
- package/examples/spike-settle-latency.ts +125 -0
- package/package.json +4 -3
- package/dist/_contracts/event-guards.d.ts +0 -67
- package/dist/_contracts/event-guards.js +0 -36
|
@@ -565,6 +565,9 @@ export function parseRunSubmissionRequest(input, options = {}) {
|
|
|
565
565
|
trustedReparse: options.trustedReparse === true
|
|
566
566
|
});
|
|
567
567
|
assertRunModelMatchesProvider(provider, submission.model);
|
|
568
|
+
// Fail-closed streaming: `outputMode:'stream'` on a non-streamable provider is
|
|
569
|
+
// a hard reject at parse time (no silent downgrade).
|
|
570
|
+
assertStreamableOutputMode(submission.outputMode, provider);
|
|
568
571
|
crossValidateSecretEnvAndValues(submission.secretEnv, secrets.envSecrets);
|
|
569
572
|
// mcpServers names must agree across the submission half and the
|
|
570
573
|
// secrets half — every secrets.mcpServers[i].name MUST resolve to a
|
|
@@ -648,7 +651,7 @@ export function parseRunLimits(input) {
|
|
|
648
651
|
return undefined;
|
|
649
652
|
}
|
|
650
653
|
const value = requireRecord(input, "limits");
|
|
651
|
-
const allowed = new Set(["maxConcurrentChildRuns", "maxSubagentDepth", "maxSpendUsd"]);
|
|
654
|
+
const allowed = new Set(["maxConcurrentChildRuns", "maxSubagentDepth", "maxSpendUsd", "maxTurns"]);
|
|
652
655
|
for (const key of Object.keys(value)) {
|
|
653
656
|
if (!allowed.has(key)) {
|
|
654
657
|
throw new Error(`limits.${key} is not an allowed field; permitted: ${[...allowed].join(", ")}`);
|
|
@@ -660,16 +663,23 @@ export function parseRunLimits(input) {
|
|
|
660
663
|
// NUMBER, not a positive int. Clamping to the workspace/platform ceiling is the
|
|
661
664
|
// resolver's job; here we only enforce shape + positivity.
|
|
662
665
|
const maxSpendUsd = optionalPositiveNumber(value.maxSpendUsd, "limits.maxSpendUsd");
|
|
666
|
+
// maxTurns is an ITERATION count — a positive safe integer. Clamp to the ceiling
|
|
667
|
+
// is the resolver's job; here we enforce shape + positivity only.
|
|
668
|
+
const maxTurns = optionalPositiveInt(value.maxTurns, "limits.maxTurns");
|
|
663
669
|
// Collapse an all-absent override (e.g. `limits: {}`) to `undefined` so it never
|
|
664
670
|
// lands an empty object on the request — matches sibling parsers (parseRunWebhook,
|
|
665
671
|
// parseEnvironment). The resolver supplies platform defaults for absent fields.
|
|
666
|
-
if (maxConcurrentChildRuns === undefined &&
|
|
672
|
+
if (maxConcurrentChildRuns === undefined &&
|
|
673
|
+
maxSubagentDepth === undefined &&
|
|
674
|
+
maxSpendUsd === undefined &&
|
|
675
|
+
maxTurns === undefined) {
|
|
667
676
|
return undefined;
|
|
668
677
|
}
|
|
669
678
|
return {
|
|
670
679
|
...(maxConcurrentChildRuns !== undefined ? { maxConcurrentChildRuns } : {}),
|
|
671
680
|
...(maxSubagentDepth !== undefined ? { maxSubagentDepth } : {}),
|
|
672
|
-
...(maxSpendUsd !== undefined ? { maxSpendUsd } : {})
|
|
681
|
+
...(maxSpendUsd !== undefined ? { maxSpendUsd } : {}),
|
|
682
|
+
...(maxTurns !== undefined ? { maxTurns } : {})
|
|
673
683
|
};
|
|
674
684
|
}
|
|
675
685
|
/**
|
|
@@ -766,6 +776,8 @@ export function parseSubmission(input, options = {}) {
|
|
|
766
776
|
"outputs",
|
|
767
777
|
"includeBuiltinTools",
|
|
768
778
|
"outputMode",
|
|
779
|
+
"responseFormat",
|
|
780
|
+
"approvalGate",
|
|
769
781
|
"platform"
|
|
770
782
|
]);
|
|
771
783
|
for (const key of Object.keys(value)) {
|
|
@@ -789,6 +801,8 @@ export function parseSubmission(input, options = {}) {
|
|
|
789
801
|
const outputs = parseOutputs(value.outputs);
|
|
790
802
|
const includeBuiltinTools = parseIncludeBuiltinTools(value.includeBuiltinTools);
|
|
791
803
|
const outputMode = parseOutputMode(value.outputMode);
|
|
804
|
+
const responseFormat = parseResponseFormat(value.responseFormat);
|
|
805
|
+
const approvalGate = parseApprovalGate(value.approvalGate);
|
|
792
806
|
const platform = parsePlatformConfig(value.platform);
|
|
793
807
|
return {
|
|
794
808
|
model,
|
|
@@ -808,6 +822,8 @@ export function parseSubmission(input, options = {}) {
|
|
|
808
822
|
...(includeBuiltinTools !== undefined ? { includeBuiltinTools } : {}),
|
|
809
823
|
...(builtinTools.length > 0 ? { builtinTools } : {}),
|
|
810
824
|
...(outputMode !== undefined ? { outputMode } : {}),
|
|
825
|
+
...(responseFormat !== undefined ? { responseFormat } : {}),
|
|
826
|
+
...(approvalGate !== undefined ? { approvalGate } : {}),
|
|
811
827
|
...(platform ? { platform } : {})
|
|
812
828
|
};
|
|
813
829
|
}
|
|
@@ -869,6 +885,127 @@ function parseOutputMode(input) {
|
|
|
869
885
|
}
|
|
870
886
|
return input;
|
|
871
887
|
}
|
|
888
|
+
// ---------------------------------------------------------------------------
|
|
889
|
+
// Streaming capability model — WS9. `outputMode:'stream'` is capability-gated.
|
|
890
|
+
// ---------------------------------------------------------------------------
|
|
891
|
+
/**
|
|
892
|
+
* The provider wire-SHAPES that have a real per-token streaming producer. This
|
|
893
|
+
* const is the contracts-side SSoT, pinned EQUAL to the platform's shape SSoT by
|
|
894
|
+
* a cross-repo parity test so streaming can never be promised for a shape
|
|
895
|
+
* nothing feeds.
|
|
896
|
+
*/
|
|
897
|
+
export const STREAMABLE_SHAPES = ["anthropic", "openai_chat"];
|
|
898
|
+
/**
|
|
899
|
+
* Each provider's wire shape, or `null` when it has no streaming producer wired
|
|
900
|
+
* yet. `stream` output is only honored for a provider whose shape is streamable.
|
|
901
|
+
*/
|
|
902
|
+
const PROVIDER_STREAM_SHAPE = {
|
|
903
|
+
anthropic: "anthropic",
|
|
904
|
+
deepseek: "openai_chat",
|
|
905
|
+
openai: "openai_chat",
|
|
906
|
+
gemini: null,
|
|
907
|
+
mistral: "openai_chat",
|
|
908
|
+
openrouter: "openai_chat",
|
|
909
|
+
doubao: "openai_chat",
|
|
910
|
+
"doubao-cn": "openai_chat"
|
|
911
|
+
};
|
|
912
|
+
/** True when a provider has a streaming producer wired (a {@link STREAMABLE_SHAPES} shape). */
|
|
913
|
+
export function isStreamableProvider(provider) {
|
|
914
|
+
return PROVIDER_STREAM_SHAPE[provider] !== null;
|
|
915
|
+
}
|
|
916
|
+
function streamableProviders() {
|
|
917
|
+
return Object.keys(PROVIDER_STREAM_SHAPE).filter(isStreamableProvider);
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Fail-closed streaming gate: `outputMode:'stream'` on a NON-streamable provider
|
|
921
|
+
* throws (a HARD reject — no silent downgrade to buffered). Called by
|
|
922
|
+
* {@link parseRunSubmissionRequest} once mode + provider are both known.
|
|
923
|
+
*/
|
|
924
|
+
export function assertStreamableOutputMode(outputMode, provider) {
|
|
925
|
+
if (outputMode === "stream" && !isStreamableProvider(provider)) {
|
|
926
|
+
throw new Error(`submission.outputMode 'stream' is not supported for provider ${provider}; ` +
|
|
927
|
+
`streaming is available for: ${streamableProviders().join(", ")}`);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
// ---------------------------------------------------------------------------
|
|
931
|
+
// Structured-output (schema-decode) policy — WS10.
|
|
932
|
+
// ---------------------------------------------------------------------------
|
|
933
|
+
/** Response-format kinds: free-form `text` (default) or provider-native `json_schema`. */
|
|
934
|
+
export const RESPONSE_FORMAT_KINDS = ["text", "json_schema"];
|
|
935
|
+
/**
|
|
936
|
+
* Parse the optional `submission.responseFormat`. Mirrors {@link parseOutputMode}
|
|
937
|
+
* / {@link OUTPUT_MODES}: absent ⇒ undefined; a bad `kind` or unknown subfield is
|
|
938
|
+
* rejected (fail-fast). `json_schema` requires a JSON-object `schema`.
|
|
939
|
+
*/
|
|
940
|
+
export function parseResponseFormat(input) {
|
|
941
|
+
if (input === undefined || input === null)
|
|
942
|
+
return undefined;
|
|
943
|
+
const value = requireRecord(input, "submission.responseFormat");
|
|
944
|
+
const kind = value.kind;
|
|
945
|
+
if (typeof kind !== "string" || !RESPONSE_FORMAT_KINDS.includes(kind)) {
|
|
946
|
+
throw new Error(`submission.responseFormat.kind must be one of ${RESPONSE_FORMAT_KINDS.join(", ")}`);
|
|
947
|
+
}
|
|
948
|
+
if (kind === "text") {
|
|
949
|
+
for (const key of Object.keys(value)) {
|
|
950
|
+
if (key !== "kind") {
|
|
951
|
+
throw new Error(`submission.responseFormat.${key} is not allowed when kind is 'text'`);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return { kind: "text" };
|
|
955
|
+
}
|
|
956
|
+
const allowed = new Set(["kind", "schema", "strict", "name"]);
|
|
957
|
+
for (const key of Object.keys(value)) {
|
|
958
|
+
if (!allowed.has(key)) {
|
|
959
|
+
throw new Error(`submission.responseFormat.${key} is not an allowed field; permitted: ${[...allowed].join(", ")}`);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
if (!isRecord(value.schema) || !isJsonValue(value.schema)) {
|
|
963
|
+
throw new Error("submission.responseFormat.schema must be a JSON-serializable object");
|
|
964
|
+
}
|
|
965
|
+
const schema = value.schema;
|
|
966
|
+
if (value.strict !== undefined && typeof value.strict !== "boolean") {
|
|
967
|
+
throw new Error("submission.responseFormat.strict must be a boolean");
|
|
968
|
+
}
|
|
969
|
+
const name = optionalString(value.name, "submission.responseFormat.name");
|
|
970
|
+
return {
|
|
971
|
+
kind: "json_schema",
|
|
972
|
+
schema,
|
|
973
|
+
...(value.strict !== undefined ? { strict: value.strict } : {}),
|
|
974
|
+
...(name !== undefined ? { name } : {})
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Parse the optional `submission.approvalGate`. Absent / empty tool list ⇒
|
|
979
|
+
* undefined (no gate). Tool names are deduped; the strict allow-list mirrors the
|
|
980
|
+
* sibling parsers.
|
|
981
|
+
*/
|
|
982
|
+
export function parseApprovalGate(input) {
|
|
983
|
+
if (input === undefined || input === null)
|
|
984
|
+
return undefined;
|
|
985
|
+
const value = requireRecord(input, "submission.approvalGate");
|
|
986
|
+
for (const key of Object.keys(value)) {
|
|
987
|
+
if (key !== "tools") {
|
|
988
|
+
throw new Error(`submission.approvalGate.${key} is not an allowed field; permitted: tools`);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (!Array.isArray(value.tools)) {
|
|
992
|
+
throw new Error("submission.approvalGate.tools must be an array of tool names");
|
|
993
|
+
}
|
|
994
|
+
const seen = new Set();
|
|
995
|
+
const tools = [];
|
|
996
|
+
value.tools.forEach((entry, index) => {
|
|
997
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
998
|
+
throw new Error(`submission.approvalGate.tools[${index}] must be a non-empty string`);
|
|
999
|
+
}
|
|
1000
|
+
if (!seen.has(entry)) {
|
|
1001
|
+
seen.add(entry);
|
|
1002
|
+
tools.push(entry);
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
if (tools.length === 0)
|
|
1006
|
+
return undefined;
|
|
1007
|
+
return { tools };
|
|
1008
|
+
}
|
|
872
1009
|
/**
|
|
873
1010
|
* The CLOSED set of builtin tool NAMES the managed runtime can inject — one per
|
|
874
1011
|
* machine tool the hands implement. This list is the single source of truth for
|
|
@@ -898,7 +1035,10 @@ export const BUILTIN_TOOL_NAMES = [
|
|
|
898
1035
|
"bash_kill",
|
|
899
1036
|
"code_execution",
|
|
900
1037
|
"wait",
|
|
901
|
-
"git"
|
|
1038
|
+
"git",
|
|
1039
|
+
"ls",
|
|
1040
|
+
"stat",
|
|
1041
|
+
"wc"
|
|
902
1042
|
];
|
|
903
1043
|
/**
|
|
904
1044
|
* Typo-safe accessors for the closed builtin tool set: each key maps to the
|
|
@@ -927,7 +1067,10 @@ export const BuiltinTools = {
|
|
|
927
1067
|
bash_kill: "bash_kill",
|
|
928
1068
|
code_execution: "code_execution",
|
|
929
1069
|
wait: "wait",
|
|
930
|
-
git: "git"
|
|
1070
|
+
git: "git",
|
|
1071
|
+
ls: "ls",
|
|
1072
|
+
stat: "stat",
|
|
1073
|
+
wc: "wc"
|
|
931
1074
|
};
|
|
932
1075
|
/**
|
|
933
1076
|
* The default builtin tool set injected when `includeBuiltinTools !== false`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared "did you mean?" suggester — the SSoT for near-miss enum hints across
|
|
3
|
+
* the SDK and the CLI. Previously this lived only in the CLI, so the SDK could
|
|
4
|
+
* not emit a fuzzy model/provider hint even though the docs promised one.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The closest candidate to `input` by a unique case-insensitive prefix match,
|
|
8
|
+
* else by Levenshtein distance (≤ 2), else `undefined`. Ties break by
|
|
9
|
+
* declaration order. Used on an invalid `--model` / `--provider` /
|
|
10
|
+
* `--runtime-size` (and the SDK's unknown-model throw) to turn a flat rejection
|
|
11
|
+
* into a fix hint.
|
|
12
|
+
*/
|
|
13
|
+
export declare function suggest(input: string, candidates: readonly string[]): string | undefined;
|
|
14
|
+
/** Levenshtein edit distance between two strings (rolling two-row DP). */
|
|
15
|
+
export declare function levenshtein(a: string, b: string): number;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared "did you mean?" suggester — the SSoT for near-miss enum hints across
|
|
3
|
+
* the SDK and the CLI. Previously this lived only in the CLI, so the SDK could
|
|
4
|
+
* not emit a fuzzy model/provider hint even though the docs promised one.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The closest candidate to `input` by a unique case-insensitive prefix match,
|
|
8
|
+
* else by Levenshtein distance (≤ 2), else `undefined`. Ties break by
|
|
9
|
+
* declaration order. Used on an invalid `--model` / `--provider` /
|
|
10
|
+
* `--runtime-size` (and the SDK's unknown-model throw) to turn a flat rejection
|
|
11
|
+
* into a fix hint.
|
|
12
|
+
*/
|
|
13
|
+
export function suggest(input, candidates) {
|
|
14
|
+
const needle = input.trim();
|
|
15
|
+
if (!needle)
|
|
16
|
+
return undefined;
|
|
17
|
+
// Unique case-insensitive prefix match first (cheap + intuitive).
|
|
18
|
+
const lower = needle.toLowerCase();
|
|
19
|
+
const prefixHits = candidates.filter((c) => c.toLowerCase().startsWith(lower));
|
|
20
|
+
if (prefixHits.length === 1)
|
|
21
|
+
return prefixHits[0];
|
|
22
|
+
// Else nearest by edit distance, ties broken by declaration order.
|
|
23
|
+
let best;
|
|
24
|
+
let bestDist = Number.POSITIVE_INFINITY;
|
|
25
|
+
for (const candidate of candidates) {
|
|
26
|
+
const dist = levenshtein(needle, candidate);
|
|
27
|
+
if (dist < bestDist) {
|
|
28
|
+
bestDist = dist;
|
|
29
|
+
best = candidate;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return bestDist <= 2 ? best : undefined;
|
|
33
|
+
}
|
|
34
|
+
/** Levenshtein edit distance between two strings (rolling two-row DP). */
|
|
35
|
+
export function levenshtein(a, b) {
|
|
36
|
+
const m = a.length;
|
|
37
|
+
const n = b.length;
|
|
38
|
+
if (m === 0)
|
|
39
|
+
return n;
|
|
40
|
+
if (n === 0)
|
|
41
|
+
return m;
|
|
42
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
43
|
+
let curr = new Array(n + 1);
|
|
44
|
+
for (let i = 1; i <= m; i++) {
|
|
45
|
+
curr[0] = i;
|
|
46
|
+
for (let j = 1; j <= n; j++) {
|
|
47
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
48
|
+
curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
49
|
+
}
|
|
50
|
+
[prev, curr] = [curr, prev];
|
|
51
|
+
}
|
|
52
|
+
return prev[n];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=suggest.js.map
|
package/dist/asset-upload.d.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* 3. POST /assets/finalize → confirms the object exists (HEAD only).
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
+
import type { ByteSink } from "./canonical-zip.js";
|
|
22
23
|
/**
|
|
23
24
|
* Subset of `HttpClient` needed by the asset uploader. Defined as a
|
|
24
25
|
* structural type so tests can supply a thin stub without dragging in
|
|
@@ -32,6 +33,10 @@ export type AssetFetch = (input: string, init?: RequestInit) => Promise<{
|
|
|
32
33
|
readonly ok: boolean;
|
|
33
34
|
readonly status: number;
|
|
34
35
|
text(): Promise<string>;
|
|
36
|
+
/** Present on real `fetch` Responses; used to read a multipart part's ETag. */
|
|
37
|
+
readonly headers?: {
|
|
38
|
+
get(name: string): string | null;
|
|
39
|
+
};
|
|
35
40
|
}>;
|
|
36
41
|
export interface UploadAssetArgs {
|
|
37
42
|
readonly http: AssetsHttpClient;
|
|
@@ -58,3 +63,24 @@ export interface UploadedAsset {
|
|
|
58
63
|
* and the runner re-checks on download.
|
|
59
64
|
*/
|
|
60
65
|
export declare function uploadAsset(args: UploadAssetArgs): Promise<UploadedAsset>;
|
|
66
|
+
/** Default multipart part size — 16 MiB covers the 100 GiB cap within S3's 10 000-part limit. */
|
|
67
|
+
export declare const DEFAULT_MULTIPART_PART_SIZE: number;
|
|
68
|
+
/** Default in-flight part concurrency. */
|
|
69
|
+
export declare const DEFAULT_MULTIPART_CONCURRENCY = 4;
|
|
70
|
+
/**
|
|
71
|
+
* Drives the canonical-zip framer, pushing every zip byte into `sink` in order.
|
|
72
|
+
* Called TWICE (pass 1 hash, pass 2 upload); the framer is deterministic so both
|
|
73
|
+
* passes emit byte-identical streams.
|
|
74
|
+
*/
|
|
75
|
+
export type ZipStreamDriver = (sink: ByteSink) => Promise<void>;
|
|
76
|
+
export interface UploadAssetStreamArgs {
|
|
77
|
+
readonly http: AssetsHttpClient;
|
|
78
|
+
/** Re-openable, deterministic canonical-zip stream driver (pass-1 hash == pass-2 bytes). */
|
|
79
|
+
readonly drive: ZipStreamDriver;
|
|
80
|
+
readonly contentType?: string;
|
|
81
|
+
readonly fetch?: AssetFetch;
|
|
82
|
+
readonly partSize?: number;
|
|
83
|
+
readonly partConcurrency?: number;
|
|
84
|
+
}
|
|
85
|
+
/** Stream a large asset to the content store via the two-pass multipart flow. */
|
|
86
|
+
export declare function uploadAssetMultipart(args: UploadAssetStreamArgs): Promise<UploadedAsset>;
|
package/dist/asset-upload.js
CHANGED
|
@@ -97,15 +97,230 @@ async function computeSha256Hex(bytes) {
|
|
|
97
97
|
throw new Error("uploadAsset: globalThis.crypto.subtle is not available; " +
|
|
98
98
|
"Bun, Node 18+, or a Web-Crypto-capable runtime is required");
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
copy.
|
|
102
|
-
const digest = await subtle.digest("SHA-256",
|
|
100
|
+
// Pass the view directly — Web Crypto accepts an ArrayBufferView and digests
|
|
101
|
+
// exactly its bytes (respecting byteOffset/length). No redundant full-buffer copy.
|
|
102
|
+
const digest = await subtle.digest("SHA-256", bytes);
|
|
103
103
|
return bufferToHex(digest);
|
|
104
104
|
}
|
|
105
105
|
function assetIdFromContentHash(contentHash) {
|
|
106
106
|
const hex = contentHash.startsWith("sha256:") ? contentHash.slice("sha256:".length) : contentHash;
|
|
107
107
|
return `asset_${hex}`;
|
|
108
108
|
}
|
|
109
|
+
// ===========================================================================
|
|
110
|
+
// Multipart streaming upload (large assets — the "kill the in-memory ceiling"
|
|
111
|
+
// path). Two-pass over a re-openable, DETERMINISTIC canonical-zip byte stream:
|
|
112
|
+
// pass 1 — stream → running SHA-256 → presign BY HASH (dedup still short-
|
|
113
|
+
// circuits `exists:true` with zero bytes uploaded);
|
|
114
|
+
// pass 2 — re-stream → chunk into parts → S3 multipart UploadPart (bounded
|
|
115
|
+
// concurrency + per-part retry, only the failed part re-sent) →
|
|
116
|
+
// CompleteMultipartUpload (server validates the full-object SHA-256).
|
|
117
|
+
// A failure after presign aborts the multipart upload so no orphaned parts bill.
|
|
118
|
+
// ===========================================================================
|
|
119
|
+
/** Default multipart part size — 16 MiB covers the 100 GiB cap within S3's 10 000-part limit. */
|
|
120
|
+
export const DEFAULT_MULTIPART_PART_SIZE = 16 * 1024 * 1024;
|
|
121
|
+
/** Default in-flight part concurrency. */
|
|
122
|
+
export const DEFAULT_MULTIPART_CONCURRENCY = 4;
|
|
123
|
+
/** Stream a large asset to the content store via the two-pass multipart flow. */
|
|
124
|
+
export async function uploadAssetMultipart(args) {
|
|
125
|
+
const partSize = args.partSize ?? DEFAULT_MULTIPART_PART_SIZE;
|
|
126
|
+
const concurrency = Math.max(1, args.partConcurrency ?? DEFAULT_MULTIPART_CONCURRENCY);
|
|
127
|
+
const doFetch = args.fetch ?? globalThis.fetch;
|
|
128
|
+
// ---- Pass 1: stream → running SHA-256 + byte count ----
|
|
129
|
+
const { hashHex, sizeBytes } = await hashAndSizeViaDrive(args.drive);
|
|
130
|
+
const contentHashHeader = `sha256:${hashHex}`;
|
|
131
|
+
// ---- Presign (multipart) — dedup short-circuits before any bytes move ----
|
|
132
|
+
const presign = await args.http.request("/assets/presign", {
|
|
133
|
+
method: "POST",
|
|
134
|
+
headers: { "content-type": "application/json" },
|
|
135
|
+
body: JSON.stringify({ hash: contentHashHeader, sizeBytes, multipart: true, partSize })
|
|
136
|
+
});
|
|
137
|
+
if (presign.exists) {
|
|
138
|
+
const contentHash = presign.contentHash ?? contentHashHeader;
|
|
139
|
+
return {
|
|
140
|
+
assetId: presign.assetId ?? assetIdFromContentHash(contentHash),
|
|
141
|
+
contentHash,
|
|
142
|
+
sizeBytes: presign.sizeBytes ?? sizeBytes,
|
|
143
|
+
exists: true
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const mp = presign.multipart;
|
|
147
|
+
if (!mp || !mp.uploadId || !mp.key || !Array.isArray(mp.partUrls)) {
|
|
148
|
+
throw new Error("uploadAssetMultipart: presign returned no multipart plan and exists:false");
|
|
149
|
+
}
|
|
150
|
+
// ---- Pass 2: re-stream → parts → UploadPart (bounded concurrency + retry) ----
|
|
151
|
+
const urlByPart = new Map();
|
|
152
|
+
for (const p of mp.partUrls)
|
|
153
|
+
urlByPart.set(p.partNumber, p.url);
|
|
154
|
+
const parts = [];
|
|
155
|
+
const inflight = new Set();
|
|
156
|
+
let failed;
|
|
157
|
+
const refreshPartUrl = async (partNumber) => {
|
|
158
|
+
const res = await args.http.request("/assets/mpu/presign-parts", {
|
|
159
|
+
method: "POST",
|
|
160
|
+
headers: { "content-type": "application/json" },
|
|
161
|
+
body: JSON.stringify({ uploadId: mp.uploadId, key: mp.key, partNumbers: [partNumber] })
|
|
162
|
+
});
|
|
163
|
+
const fresh = res.partUrls?.find((p) => p.partNumber === partNumber)?.url;
|
|
164
|
+
if (!fresh)
|
|
165
|
+
throw new Error(`uploadAssetMultipart: could not refresh URL for part ${partNumber}`);
|
|
166
|
+
urlByPart.set(partNumber, fresh);
|
|
167
|
+
return fresh;
|
|
168
|
+
};
|
|
169
|
+
const uploadOnePart = async (partNumber, bytes) => {
|
|
170
|
+
let url = urlByPart.get(partNumber);
|
|
171
|
+
if (!url)
|
|
172
|
+
url = await refreshPartUrl(partNumber);
|
|
173
|
+
const etag = await putPartWithRetry(doFetch, url, bytes, args.contentType, () => refreshPartUrl(partNumber));
|
|
174
|
+
parts.push({ partNumber, etag });
|
|
175
|
+
};
|
|
176
|
+
const submitPart = async (partNumber, bytes) => {
|
|
177
|
+
while (inflight.size >= concurrency)
|
|
178
|
+
await Promise.race(inflight);
|
|
179
|
+
if (failed !== undefined)
|
|
180
|
+
throw failed;
|
|
181
|
+
const tracked = uploadOnePart(partNumber, bytes)
|
|
182
|
+
.catch((err) => {
|
|
183
|
+
failed ??= err;
|
|
184
|
+
})
|
|
185
|
+
.finally(() => {
|
|
186
|
+
inflight.delete(tracked);
|
|
187
|
+
});
|
|
188
|
+
inflight.add(tracked);
|
|
189
|
+
};
|
|
190
|
+
try {
|
|
191
|
+
let partNumber = 0;
|
|
192
|
+
const chunker = makePartChunker(partSize, async (bytes) => {
|
|
193
|
+
partNumber += 1;
|
|
194
|
+
await submitPart(partNumber, bytes);
|
|
195
|
+
});
|
|
196
|
+
await args.drive(async (chunk) => {
|
|
197
|
+
await chunker.push(chunk);
|
|
198
|
+
if (failed !== undefined)
|
|
199
|
+
throw failed;
|
|
200
|
+
});
|
|
201
|
+
await chunker.flush();
|
|
202
|
+
await Promise.all(inflight);
|
|
203
|
+
if (failed !== undefined)
|
|
204
|
+
throw failed;
|
|
205
|
+
if (partNumber === 0) {
|
|
206
|
+
// Zero-length streams cannot happen for a real zip (EOCD is always emitted),
|
|
207
|
+
// but guard so a bug fails loud rather than completing an empty MPU.
|
|
208
|
+
throw new Error("uploadAssetMultipart: no parts produced from the zip stream");
|
|
209
|
+
}
|
|
210
|
+
parts.sort((a, b) => a.partNumber - b.partNumber);
|
|
211
|
+
const fin = await args.http.request("/assets/finalize", {
|
|
212
|
+
method: "POST",
|
|
213
|
+
headers: { "content-type": "application/json" },
|
|
214
|
+
body: JSON.stringify({ hash: contentHashHeader, sizeBytes, uploadId: mp.uploadId, key: mp.key, parts })
|
|
215
|
+
});
|
|
216
|
+
const contentHash = fin.contentHash ?? contentHashHeader;
|
|
217
|
+
return {
|
|
218
|
+
assetId: fin.assetId ?? assetIdFromContentHash(contentHash),
|
|
219
|
+
contentHash,
|
|
220
|
+
sizeBytes: fin.sizeBytes ?? sizeBytes,
|
|
221
|
+
exists: false
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
// Abort so orphaned parts don't bill silently (backed by the S3 lifecycle rule too).
|
|
226
|
+
await args.http
|
|
227
|
+
.request("/assets/mpu/abort", {
|
|
228
|
+
method: "POST",
|
|
229
|
+
headers: { "content-type": "application/json" },
|
|
230
|
+
body: JSON.stringify({ uploadId: mp.uploadId, key: mp.key })
|
|
231
|
+
})
|
|
232
|
+
.catch(() => undefined);
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** Drive the framer through SHA-256, returning the hex digest + total byte count. Node/Bun only. */
|
|
237
|
+
async function hashAndSizeViaDrive(drive) {
|
|
238
|
+
const { createHash } = await import("node:crypto");
|
|
239
|
+
const hash = createHash("sha256");
|
|
240
|
+
let sizeBytes = 0;
|
|
241
|
+
await drive((chunk) => {
|
|
242
|
+
hash.update(chunk);
|
|
243
|
+
sizeBytes += chunk.length;
|
|
244
|
+
});
|
|
245
|
+
return { hashHex: hash.digest("hex"), sizeBytes };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Repackage an arbitrary-boundary byte stream into fixed `partSize` parts (the
|
|
249
|
+
* last may be smaller), invoking `emit` once per full part. Efficient: front-of-
|
|
250
|
+
* queue splitting, no O(n²) buffer growth.
|
|
251
|
+
*/
|
|
252
|
+
function makePartChunker(partSize, emit) {
|
|
253
|
+
const chunks = [];
|
|
254
|
+
let buffered = 0;
|
|
255
|
+
const emitPart = async (size) => {
|
|
256
|
+
const part = new Uint8Array(size);
|
|
257
|
+
let off = 0;
|
|
258
|
+
while (off < size) {
|
|
259
|
+
const head = chunks[0];
|
|
260
|
+
const take = Math.min(head.length, size - off);
|
|
261
|
+
part.set(head.subarray(0, take), off);
|
|
262
|
+
off += take;
|
|
263
|
+
if (take === head.length)
|
|
264
|
+
chunks.shift();
|
|
265
|
+
else
|
|
266
|
+
chunks[0] = head.subarray(take);
|
|
267
|
+
}
|
|
268
|
+
buffered -= size;
|
|
269
|
+
await emit(part);
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
push: async (chunk) => {
|
|
273
|
+
if (chunk.length === 0)
|
|
274
|
+
return;
|
|
275
|
+
chunks.push(chunk);
|
|
276
|
+
buffered += chunk.length;
|
|
277
|
+
while (buffered >= partSize)
|
|
278
|
+
await emitPart(partSize);
|
|
279
|
+
},
|
|
280
|
+
flush: async () => {
|
|
281
|
+
if (buffered > 0)
|
|
282
|
+
await emitPart(buffered);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/** PUT one part with bounded retry; refreshes the URL once on a 403 (expiry). Returns the ETag. */
|
|
287
|
+
async function putPartWithRetry(fetchImpl, url, bytes, contentType, refreshUrl) {
|
|
288
|
+
let currentUrl = url;
|
|
289
|
+
let refreshed = false;
|
|
290
|
+
for (let attempt = 1; attempt <= DIRECT_UPLOAD_MAX_ATTEMPTS; attempt++) {
|
|
291
|
+
let response;
|
|
292
|
+
try {
|
|
293
|
+
response = await fetchImpl(currentUrl, {
|
|
294
|
+
method: "PUT",
|
|
295
|
+
headers: { "content-type": contentType ?? "application/zip" },
|
|
296
|
+
body: bytes
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
if (attempt < DIRECT_UPLOAD_MAX_ATTEMPTS && isRetryableUploadError(err))
|
|
301
|
+
continue;
|
|
302
|
+
throw directUploadNetworkError(currentUrl, err, attempt);
|
|
303
|
+
}
|
|
304
|
+
if (response.ok) {
|
|
305
|
+
const etag = response.headers?.get?.("etag") ?? response.headers?.get?.("ETag") ?? "";
|
|
306
|
+
return etag.replace(/"/g, "");
|
|
307
|
+
}
|
|
308
|
+
// A 403 mid-upload is a presign-expiry; refresh the URL once and retry.
|
|
309
|
+
if (response.status === 403 && !refreshed) {
|
|
310
|
+
refreshed = true;
|
|
311
|
+
await response.text().catch(() => "");
|
|
312
|
+
currentUrl = await refreshUrl();
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (attempt < DIRECT_UPLOAD_MAX_ATTEMPTS && isRetryableUploadStatus(response.status)) {
|
|
316
|
+
await response.text().catch(() => "");
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const detail = await response.text().catch(() => "");
|
|
320
|
+
throw directUploadResponseError(currentUrl, response.status, detail, attempt);
|
|
321
|
+
}
|
|
322
|
+
throw directUploadResponseError(currentUrl, 0, "exhausted retries", DIRECT_UPLOAD_MAX_ATTEMPTS);
|
|
323
|
+
}
|
|
109
324
|
async function putWithRetry(fetchImpl, uploadUrl, init) {
|
|
110
325
|
for (let attempt = 1; attempt <= DIRECT_UPLOAD_MAX_ATTEMPTS; attempt++) {
|
|
111
326
|
let response;
|
package/dist/asset-upload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-upload.js","sourceRoot":"","sources":["../src/asset-upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAoC/D,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAqB;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,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GAAG,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB;IACtC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAW,CAAC;QAC/B,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/bundle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ToolInputSchema } from "./_contracts/index.js";
|
|
1
|
+
import { type BundleSymlink, type ToolInputSchema } from "./_contracts/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* In-memory skill bundle: a flat path -> bytes map and the
|
|
4
4
|
* deterministically-zipped representation.
|
|
@@ -21,7 +21,18 @@ export interface BundledSkill {
|
|
|
21
21
|
}
|
|
22
22
|
/** Inline files map: path -> contents (UTF-8 string or raw bytes). */
|
|
23
23
|
export type SkillFiles = Readonly<Record<string, string | Uint8Array>>;
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Fidelity metadata captured from a local directory walk: `exec` are the
|
|
26
|
+
* bundle-relative paths that restore executable (0o755); `symlinks` are captured
|
|
27
|
+
* links. When non-empty it is serialized into the {@link RESERVED_META_ENTRY}
|
|
28
|
+
* sidecar, appended LAST so a pure-content bundle stays byte-identical to the
|
|
29
|
+
* pre-fidelity output (dedup continuity).
|
|
30
|
+
*/
|
|
31
|
+
export interface BundleMeta {
|
|
32
|
+
readonly exec?: readonly string[];
|
|
33
|
+
readonly symlinks?: readonly BundleSymlink[];
|
|
34
|
+
}
|
|
35
|
+
export declare function bundleSkillFiles(files: SkillFiles, meta?: BundleMeta): BundledSkill;
|
|
25
36
|
export interface BundledTool {
|
|
26
37
|
readonly zip: Uint8Array;
|
|
27
38
|
readonly fileCount: number;
|
|
@@ -33,7 +44,7 @@ export interface ToolBundleManifest {
|
|
|
33
44
|
readonly input_schema: ToolInputSchema;
|
|
34
45
|
readonly entry: string;
|
|
35
46
|
}
|
|
36
|
-
export declare function bundleToolFiles(files: SkillFiles, manifest: ToolBundleManifest): BundledTool;
|
|
47
|
+
export declare function bundleToolFiles(files: SkillFiles, manifest: ToolBundleManifest, meta?: BundleMeta): BundledTool;
|
|
37
48
|
/**
|
|
38
49
|
* Compute `sha256:<hex>` of the given canonicalised zip bytes. Used by the
|
|
39
50
|
* `Skill.from*` / `File` / `AgentsMd` factories to populate the draft's
|