@semiont/cli 0.2.4-build.17 → 0.2.4-build.18
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/cli.mjs +82 -1806
- package/package.json +2 -1
package/dist/cli.mjs
CHANGED
|
@@ -2757,13 +2757,13 @@ var init_schemas = __esm({
|
|
|
2757
2757
|
}
|
|
2758
2758
|
return propValues;
|
|
2759
2759
|
});
|
|
2760
|
-
const
|
|
2760
|
+
const isObject3 = isObject;
|
|
2761
2761
|
const catchall = def.catchall;
|
|
2762
2762
|
let value;
|
|
2763
2763
|
inst._zod.parse = (payload, ctx) => {
|
|
2764
2764
|
value ?? (value = _normalized.value);
|
|
2765
2765
|
const input = payload.value;
|
|
2766
|
-
if (!
|
|
2766
|
+
if (!isObject3(input)) {
|
|
2767
2767
|
payload.issues.push({
|
|
2768
2768
|
expected: "object",
|
|
2769
2769
|
code: "invalid_type",
|
|
@@ -2837,7 +2837,7 @@ var init_schemas = __esm({
|
|
|
2837
2837
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2838
2838
|
};
|
|
2839
2839
|
let fastpass;
|
|
2840
|
-
const
|
|
2840
|
+
const isObject3 = isObject;
|
|
2841
2841
|
const jit = !globalConfig.jitless;
|
|
2842
2842
|
const allowsEval2 = allowsEval;
|
|
2843
2843
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -2846,7 +2846,7 @@ var init_schemas = __esm({
|
|
|
2846
2846
|
inst._zod.parse = (payload, ctx) => {
|
|
2847
2847
|
value ?? (value = _normalized.value);
|
|
2848
2848
|
const input = payload.value;
|
|
2849
|
-
if (!
|
|
2849
|
+
if (!isObject3(input)) {
|
|
2850
2850
|
payload.issues.push({
|
|
2851
2851
|
expected: "object",
|
|
2852
2852
|
code: "invalid_type",
|
|
@@ -15765,1730 +15765,9 @@ var init_backend_paths = __esm({
|
|
|
15765
15765
|
}
|
|
15766
15766
|
});
|
|
15767
15767
|
|
|
15768
|
-
// ../../node_modules/ky/distribution/errors/HTTPError.js
|
|
15769
|
-
var HTTPError;
|
|
15770
|
-
var init_HTTPError = __esm({
|
|
15771
|
-
"../../node_modules/ky/distribution/errors/HTTPError.js"() {
|
|
15772
|
-
HTTPError = class extends Error {
|
|
15773
|
-
response;
|
|
15774
|
-
request;
|
|
15775
|
-
options;
|
|
15776
|
-
constructor(response, request, options) {
|
|
15777
|
-
const code = response.status || response.status === 0 ? response.status : "";
|
|
15778
|
-
const title = response.statusText ?? "";
|
|
15779
|
-
const status = `${code} ${title}`.trim();
|
|
15780
|
-
const reason = status ? `status code ${status}` : "an unknown error";
|
|
15781
|
-
super(`Request failed with ${reason}: ${request.method} ${request.url}`);
|
|
15782
|
-
this.name = "HTTPError";
|
|
15783
|
-
this.response = response;
|
|
15784
|
-
this.request = request;
|
|
15785
|
-
this.options = options;
|
|
15786
|
-
}
|
|
15787
|
-
};
|
|
15788
|
-
}
|
|
15789
|
-
});
|
|
15790
|
-
|
|
15791
|
-
// ../../node_modules/ky/distribution/core/constants.js
|
|
15792
|
-
var supportsRequestStreams, supportsAbortController, supportsAbortSignal, supportsResponseStreams, supportsFormData, requestMethods, validate, responseTypes, maxSafeTimeout, usualFormBoundarySize, stop, kyOptionKeys, requestOptionsRegistry;
|
|
15793
|
-
var init_constants = __esm({
|
|
15794
|
-
"../../node_modules/ky/distribution/core/constants.js"() {
|
|
15795
|
-
supportsRequestStreams = (() => {
|
|
15796
|
-
let duplexAccessed = false;
|
|
15797
|
-
let hasContentType = false;
|
|
15798
|
-
const supportsReadableStream = typeof globalThis.ReadableStream === "function";
|
|
15799
|
-
const supportsRequest = typeof globalThis.Request === "function";
|
|
15800
|
-
if (supportsReadableStream && supportsRequest) {
|
|
15801
|
-
try {
|
|
15802
|
-
hasContentType = new globalThis.Request("https://empty.invalid", {
|
|
15803
|
-
body: new globalThis.ReadableStream(),
|
|
15804
|
-
method: "POST",
|
|
15805
|
-
// @ts-expect-error - Types are outdated.
|
|
15806
|
-
get duplex() {
|
|
15807
|
-
duplexAccessed = true;
|
|
15808
|
-
return "half";
|
|
15809
|
-
}
|
|
15810
|
-
}).headers.has("Content-Type");
|
|
15811
|
-
} catch (error46) {
|
|
15812
|
-
if (error46 instanceof Error && error46.message === "unsupported BodyInit type") {
|
|
15813
|
-
return false;
|
|
15814
|
-
}
|
|
15815
|
-
throw error46;
|
|
15816
|
-
}
|
|
15817
|
-
}
|
|
15818
|
-
return duplexAccessed && !hasContentType;
|
|
15819
|
-
})();
|
|
15820
|
-
supportsAbortController = typeof globalThis.AbortController === "function";
|
|
15821
|
-
supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
|
|
15822
|
-
supportsResponseStreams = typeof globalThis.ReadableStream === "function";
|
|
15823
|
-
supportsFormData = typeof globalThis.FormData === "function";
|
|
15824
|
-
requestMethods = ["get", "post", "put", "patch", "head", "delete"];
|
|
15825
|
-
validate = () => void 0;
|
|
15826
|
-
validate();
|
|
15827
|
-
responseTypes = {
|
|
15828
|
-
json: "application/json",
|
|
15829
|
-
text: "text/*",
|
|
15830
|
-
formData: "multipart/form-data",
|
|
15831
|
-
arrayBuffer: "*/*",
|
|
15832
|
-
blob: "*/*",
|
|
15833
|
-
// Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
|
|
15834
|
-
// We still feature-check at runtime before exposing the shortcut.
|
|
15835
|
-
bytes: "*/*"
|
|
15836
|
-
};
|
|
15837
|
-
maxSafeTimeout = 2147483647;
|
|
15838
|
-
usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
|
|
15839
|
-
stop = Symbol("stop");
|
|
15840
|
-
kyOptionKeys = {
|
|
15841
|
-
json: true,
|
|
15842
|
-
parseJson: true,
|
|
15843
|
-
stringifyJson: true,
|
|
15844
|
-
searchParams: true,
|
|
15845
|
-
prefixUrl: true,
|
|
15846
|
-
retry: true,
|
|
15847
|
-
timeout: true,
|
|
15848
|
-
hooks: true,
|
|
15849
|
-
throwHttpErrors: true,
|
|
15850
|
-
onDownloadProgress: true,
|
|
15851
|
-
onUploadProgress: true,
|
|
15852
|
-
fetch: true
|
|
15853
|
-
};
|
|
15854
|
-
requestOptionsRegistry = {
|
|
15855
|
-
method: true,
|
|
15856
|
-
headers: true,
|
|
15857
|
-
body: true,
|
|
15858
|
-
mode: true,
|
|
15859
|
-
credentials: true,
|
|
15860
|
-
cache: true,
|
|
15861
|
-
redirect: true,
|
|
15862
|
-
referrer: true,
|
|
15863
|
-
referrerPolicy: true,
|
|
15864
|
-
integrity: true,
|
|
15865
|
-
keepalive: true,
|
|
15866
|
-
signal: true,
|
|
15867
|
-
window: true,
|
|
15868
|
-
duplex: true
|
|
15869
|
-
};
|
|
15870
|
-
}
|
|
15871
|
-
});
|
|
15872
|
-
|
|
15873
|
-
// ../../node_modules/ky/distribution/utils/body.js
|
|
15874
|
-
var getBodySize, withProgress, streamResponse, streamRequest;
|
|
15875
|
-
var init_body = __esm({
|
|
15876
|
-
"../../node_modules/ky/distribution/utils/body.js"() {
|
|
15877
|
-
init_constants();
|
|
15878
|
-
getBodySize = (body) => {
|
|
15879
|
-
if (!body) {
|
|
15880
|
-
return 0;
|
|
15881
|
-
}
|
|
15882
|
-
if (body instanceof FormData) {
|
|
15883
|
-
let size = 0;
|
|
15884
|
-
for (const [key, value] of body) {
|
|
15885
|
-
size += usualFormBoundarySize;
|
|
15886
|
-
size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
|
|
15887
|
-
size += typeof value === "string" ? new TextEncoder().encode(value).length : value.size;
|
|
15888
|
-
}
|
|
15889
|
-
return size;
|
|
15890
|
-
}
|
|
15891
|
-
if (body instanceof Blob) {
|
|
15892
|
-
return body.size;
|
|
15893
|
-
}
|
|
15894
|
-
if (body instanceof ArrayBuffer) {
|
|
15895
|
-
return body.byteLength;
|
|
15896
|
-
}
|
|
15897
|
-
if (typeof body === "string") {
|
|
15898
|
-
return new TextEncoder().encode(body).length;
|
|
15899
|
-
}
|
|
15900
|
-
if (body instanceof URLSearchParams) {
|
|
15901
|
-
return new TextEncoder().encode(body.toString()).length;
|
|
15902
|
-
}
|
|
15903
|
-
if ("byteLength" in body) {
|
|
15904
|
-
return body.byteLength;
|
|
15905
|
-
}
|
|
15906
|
-
if (typeof body === "object" && body !== null) {
|
|
15907
|
-
try {
|
|
15908
|
-
const jsonString = JSON.stringify(body);
|
|
15909
|
-
return new TextEncoder().encode(jsonString).length;
|
|
15910
|
-
} catch {
|
|
15911
|
-
return 0;
|
|
15912
|
-
}
|
|
15913
|
-
}
|
|
15914
|
-
return 0;
|
|
15915
|
-
};
|
|
15916
|
-
withProgress = (stream, totalBytes, onProgress) => {
|
|
15917
|
-
let previousChunk;
|
|
15918
|
-
let transferredBytes = 0;
|
|
15919
|
-
return stream.pipeThrough(new TransformStream({
|
|
15920
|
-
transform(currentChunk, controller) {
|
|
15921
|
-
controller.enqueue(currentChunk);
|
|
15922
|
-
if (previousChunk) {
|
|
15923
|
-
transferredBytes += previousChunk.byteLength;
|
|
15924
|
-
let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
|
|
15925
|
-
if (percent >= 1) {
|
|
15926
|
-
percent = 1 - Number.EPSILON;
|
|
15927
|
-
}
|
|
15928
|
-
onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
|
|
15929
|
-
}
|
|
15930
|
-
previousChunk = currentChunk;
|
|
15931
|
-
},
|
|
15932
|
-
flush() {
|
|
15933
|
-
if (previousChunk) {
|
|
15934
|
-
transferredBytes += previousChunk.byteLength;
|
|
15935
|
-
onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
|
|
15936
|
-
}
|
|
15937
|
-
}
|
|
15938
|
-
}));
|
|
15939
|
-
};
|
|
15940
|
-
streamResponse = (response, onDownloadProgress) => {
|
|
15941
|
-
if (!response.body) {
|
|
15942
|
-
return response;
|
|
15943
|
-
}
|
|
15944
|
-
if (response.status === 204) {
|
|
15945
|
-
return new Response(null, {
|
|
15946
|
-
status: response.status,
|
|
15947
|
-
statusText: response.statusText,
|
|
15948
|
-
headers: response.headers
|
|
15949
|
-
});
|
|
15950
|
-
}
|
|
15951
|
-
const totalBytes = Number(response.headers.get("content-length")) || 0;
|
|
15952
|
-
return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
|
|
15953
|
-
status: response.status,
|
|
15954
|
-
statusText: response.statusText,
|
|
15955
|
-
headers: response.headers
|
|
15956
|
-
});
|
|
15957
|
-
};
|
|
15958
|
-
streamRequest = (request, onUploadProgress, originalBody) => {
|
|
15959
|
-
if (!request.body) {
|
|
15960
|
-
return request;
|
|
15961
|
-
}
|
|
15962
|
-
const totalBytes = getBodySize(originalBody ?? request.body);
|
|
15963
|
-
return new Request(request, {
|
|
15964
|
-
// @ts-expect-error - Types are outdated.
|
|
15965
|
-
duplex: "half",
|
|
15966
|
-
body: withProgress(request.body, totalBytes, onUploadProgress)
|
|
15967
|
-
});
|
|
15968
|
-
};
|
|
15969
|
-
}
|
|
15970
|
-
});
|
|
15971
|
-
|
|
15972
|
-
// ../../node_modules/ky/distribution/utils/is.js
|
|
15973
|
-
var isObject2;
|
|
15974
|
-
var init_is2 = __esm({
|
|
15975
|
-
"../../node_modules/ky/distribution/utils/is.js"() {
|
|
15976
|
-
isObject2 = (value) => value !== null && typeof value === "object";
|
|
15977
|
-
}
|
|
15978
|
-
});
|
|
15979
|
-
|
|
15980
|
-
// ../../node_modules/ky/distribution/utils/merge.js
|
|
15981
|
-
function newHookValue(original, incoming, property) {
|
|
15982
|
-
return Object.hasOwn(incoming, property) && incoming[property] === void 0 ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
|
|
15983
|
-
}
|
|
15984
|
-
var validateAndMerge, mergeHeaders, mergeHooks, appendSearchParameters, deepMerge;
|
|
15985
|
-
var init_merge = __esm({
|
|
15986
|
-
"../../node_modules/ky/distribution/utils/merge.js"() {
|
|
15987
|
-
init_constants();
|
|
15988
|
-
init_is2();
|
|
15989
|
-
validateAndMerge = (...sources) => {
|
|
15990
|
-
for (const source of sources) {
|
|
15991
|
-
if ((!isObject2(source) || Array.isArray(source)) && source !== void 0) {
|
|
15992
|
-
throw new TypeError("The `options` argument must be an object");
|
|
15993
|
-
}
|
|
15994
|
-
}
|
|
15995
|
-
return deepMerge({}, ...sources);
|
|
15996
|
-
};
|
|
15997
|
-
mergeHeaders = (source1 = {}, source2 = {}) => {
|
|
15998
|
-
const result = new globalThis.Headers(source1);
|
|
15999
|
-
const isHeadersInstance = source2 instanceof globalThis.Headers;
|
|
16000
|
-
const source = new globalThis.Headers(source2);
|
|
16001
|
-
for (const [key, value] of source.entries()) {
|
|
16002
|
-
if (isHeadersInstance && value === "undefined" || value === void 0) {
|
|
16003
|
-
result.delete(key);
|
|
16004
|
-
} else {
|
|
16005
|
-
result.set(key, value);
|
|
16006
|
-
}
|
|
16007
|
-
}
|
|
16008
|
-
return result;
|
|
16009
|
-
};
|
|
16010
|
-
mergeHooks = (original = {}, incoming = {}) => ({
|
|
16011
|
-
beforeRequest: newHookValue(original, incoming, "beforeRequest"),
|
|
16012
|
-
beforeRetry: newHookValue(original, incoming, "beforeRetry"),
|
|
16013
|
-
afterResponse: newHookValue(original, incoming, "afterResponse"),
|
|
16014
|
-
beforeError: newHookValue(original, incoming, "beforeError")
|
|
16015
|
-
});
|
|
16016
|
-
appendSearchParameters = (target, source) => {
|
|
16017
|
-
const result = new URLSearchParams();
|
|
16018
|
-
for (const input of [target, source]) {
|
|
16019
|
-
if (input === void 0) {
|
|
16020
|
-
continue;
|
|
16021
|
-
}
|
|
16022
|
-
if (input instanceof URLSearchParams) {
|
|
16023
|
-
for (const [key, value] of input.entries()) {
|
|
16024
|
-
result.append(key, value);
|
|
16025
|
-
}
|
|
16026
|
-
} else if (Array.isArray(input)) {
|
|
16027
|
-
for (const pair of input) {
|
|
16028
|
-
if (!Array.isArray(pair) || pair.length !== 2) {
|
|
16029
|
-
throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
|
|
16030
|
-
}
|
|
16031
|
-
result.append(String(pair[0]), String(pair[1]));
|
|
16032
|
-
}
|
|
16033
|
-
} else if (isObject2(input)) {
|
|
16034
|
-
for (const [key, value] of Object.entries(input)) {
|
|
16035
|
-
if (value !== void 0) {
|
|
16036
|
-
result.append(key, String(value));
|
|
16037
|
-
}
|
|
16038
|
-
}
|
|
16039
|
-
} else {
|
|
16040
|
-
const parameters = new URLSearchParams(input);
|
|
16041
|
-
for (const [key, value] of parameters.entries()) {
|
|
16042
|
-
result.append(key, value);
|
|
16043
|
-
}
|
|
16044
|
-
}
|
|
16045
|
-
}
|
|
16046
|
-
return result;
|
|
16047
|
-
};
|
|
16048
|
-
deepMerge = (...sources) => {
|
|
16049
|
-
let returnValue = {};
|
|
16050
|
-
let headers = {};
|
|
16051
|
-
let hooks = {};
|
|
16052
|
-
let searchParameters;
|
|
16053
|
-
const signals = [];
|
|
16054
|
-
for (const source of sources) {
|
|
16055
|
-
if (Array.isArray(source)) {
|
|
16056
|
-
if (!Array.isArray(returnValue)) {
|
|
16057
|
-
returnValue = [];
|
|
16058
|
-
}
|
|
16059
|
-
returnValue = [...returnValue, ...source];
|
|
16060
|
-
} else if (isObject2(source)) {
|
|
16061
|
-
for (let [key, value] of Object.entries(source)) {
|
|
16062
|
-
if (key === "signal" && value instanceof globalThis.AbortSignal) {
|
|
16063
|
-
signals.push(value);
|
|
16064
|
-
continue;
|
|
16065
|
-
}
|
|
16066
|
-
if (key === "searchParams") {
|
|
16067
|
-
if (value === void 0 || value === null) {
|
|
16068
|
-
searchParameters = void 0;
|
|
16069
|
-
} else {
|
|
16070
|
-
searchParameters = searchParameters === void 0 ? value : appendSearchParameters(searchParameters, value);
|
|
16071
|
-
}
|
|
16072
|
-
continue;
|
|
16073
|
-
}
|
|
16074
|
-
if (isObject2(value) && key in returnValue) {
|
|
16075
|
-
value = deepMerge(returnValue[key], value);
|
|
16076
|
-
}
|
|
16077
|
-
returnValue = { ...returnValue, [key]: value };
|
|
16078
|
-
}
|
|
16079
|
-
if (isObject2(source.hooks)) {
|
|
16080
|
-
hooks = mergeHooks(hooks, source.hooks);
|
|
16081
|
-
returnValue.hooks = hooks;
|
|
16082
|
-
}
|
|
16083
|
-
if (isObject2(source.headers)) {
|
|
16084
|
-
headers = mergeHeaders(headers, source.headers);
|
|
16085
|
-
returnValue.headers = headers;
|
|
16086
|
-
}
|
|
16087
|
-
}
|
|
16088
|
-
}
|
|
16089
|
-
if (searchParameters !== void 0) {
|
|
16090
|
-
returnValue.searchParams = searchParameters;
|
|
16091
|
-
}
|
|
16092
|
-
if (signals.length > 0) {
|
|
16093
|
-
if (signals.length === 1) {
|
|
16094
|
-
returnValue.signal = signals[0];
|
|
16095
|
-
} else if (supportsAbortSignal) {
|
|
16096
|
-
returnValue.signal = AbortSignal.any(signals);
|
|
16097
|
-
} else {
|
|
16098
|
-
returnValue.signal = signals.at(-1);
|
|
16099
|
-
}
|
|
16100
|
-
}
|
|
16101
|
-
return returnValue;
|
|
16102
|
-
};
|
|
16103
|
-
}
|
|
16104
|
-
});
|
|
16105
|
-
|
|
16106
|
-
// ../../node_modules/ky/distribution/utils/normalize.js
|
|
16107
|
-
var normalizeRequestMethod, retryMethods, retryStatusCodes, retryAfterStatusCodes, defaultRetryOptions, normalizeRetryOptions;
|
|
16108
|
-
var init_normalize = __esm({
|
|
16109
|
-
"../../node_modules/ky/distribution/utils/normalize.js"() {
|
|
16110
|
-
init_constants();
|
|
16111
|
-
normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
|
|
16112
|
-
retryMethods = ["get", "put", "head", "delete", "options", "trace"];
|
|
16113
|
-
retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
|
|
16114
|
-
retryAfterStatusCodes = [413, 429, 503];
|
|
16115
|
-
defaultRetryOptions = {
|
|
16116
|
-
limit: 2,
|
|
16117
|
-
methods: retryMethods,
|
|
16118
|
-
statusCodes: retryStatusCodes,
|
|
16119
|
-
afterStatusCodes: retryAfterStatusCodes,
|
|
16120
|
-
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
16121
|
-
backoffLimit: Number.POSITIVE_INFINITY,
|
|
16122
|
-
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1e3
|
|
16123
|
-
};
|
|
16124
|
-
normalizeRetryOptions = (retry = {}) => {
|
|
16125
|
-
if (typeof retry === "number") {
|
|
16126
|
-
return {
|
|
16127
|
-
...defaultRetryOptions,
|
|
16128
|
-
limit: retry
|
|
16129
|
-
};
|
|
16130
|
-
}
|
|
16131
|
-
if (retry.methods && !Array.isArray(retry.methods)) {
|
|
16132
|
-
throw new Error("retry.methods must be an array");
|
|
16133
|
-
}
|
|
16134
|
-
if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {
|
|
16135
|
-
throw new Error("retry.statusCodes must be an array");
|
|
16136
|
-
}
|
|
16137
|
-
return {
|
|
16138
|
-
...defaultRetryOptions,
|
|
16139
|
-
...retry
|
|
16140
|
-
};
|
|
16141
|
-
};
|
|
16142
|
-
}
|
|
16143
|
-
});
|
|
16144
|
-
|
|
16145
|
-
// ../../node_modules/ky/distribution/errors/TimeoutError.js
|
|
16146
|
-
var TimeoutError;
|
|
16147
|
-
var init_TimeoutError = __esm({
|
|
16148
|
-
"../../node_modules/ky/distribution/errors/TimeoutError.js"() {
|
|
16149
|
-
TimeoutError = class extends Error {
|
|
16150
|
-
request;
|
|
16151
|
-
constructor(request) {
|
|
16152
|
-
super(`Request timed out: ${request.method} ${request.url}`);
|
|
16153
|
-
this.name = "TimeoutError";
|
|
16154
|
-
this.request = request;
|
|
16155
|
-
}
|
|
16156
|
-
};
|
|
16157
|
-
}
|
|
16158
|
-
});
|
|
16159
|
-
|
|
16160
|
-
// ../../node_modules/ky/distribution/utils/timeout.js
|
|
16161
|
-
async function timeout(request, init2, abortController, options) {
|
|
16162
|
-
return new Promise((resolve2, reject) => {
|
|
16163
|
-
const timeoutId = setTimeout(() => {
|
|
16164
|
-
if (abortController) {
|
|
16165
|
-
abortController.abort();
|
|
16166
|
-
}
|
|
16167
|
-
reject(new TimeoutError(request));
|
|
16168
|
-
}, options.timeout);
|
|
16169
|
-
void options.fetch(request, init2).then(resolve2).catch(reject).then(() => {
|
|
16170
|
-
clearTimeout(timeoutId);
|
|
16171
|
-
});
|
|
16172
|
-
});
|
|
16173
|
-
}
|
|
16174
|
-
var init_timeout = __esm({
|
|
16175
|
-
"../../node_modules/ky/distribution/utils/timeout.js"() {
|
|
16176
|
-
init_TimeoutError();
|
|
16177
|
-
}
|
|
16178
|
-
});
|
|
16179
|
-
|
|
16180
|
-
// ../../node_modules/ky/distribution/utils/delay.js
|
|
16181
|
-
async function delay(ms, { signal }) {
|
|
16182
|
-
return new Promise((resolve2, reject) => {
|
|
16183
|
-
if (signal) {
|
|
16184
|
-
signal.throwIfAborted();
|
|
16185
|
-
signal.addEventListener("abort", abortHandler, { once: true });
|
|
16186
|
-
}
|
|
16187
|
-
function abortHandler() {
|
|
16188
|
-
clearTimeout(timeoutId);
|
|
16189
|
-
reject(signal.reason);
|
|
16190
|
-
}
|
|
16191
|
-
const timeoutId = setTimeout(() => {
|
|
16192
|
-
signal?.removeEventListener("abort", abortHandler);
|
|
16193
|
-
resolve2();
|
|
16194
|
-
}, ms);
|
|
16195
|
-
});
|
|
16196
|
-
}
|
|
16197
|
-
var init_delay = __esm({
|
|
16198
|
-
"../../node_modules/ky/distribution/utils/delay.js"() {
|
|
16199
|
-
}
|
|
16200
|
-
});
|
|
16201
|
-
|
|
16202
|
-
// ../../node_modules/ky/distribution/utils/options.js
|
|
16203
|
-
var findUnknownOptions, hasSearchParameters;
|
|
16204
|
-
var init_options = __esm({
|
|
16205
|
-
"../../node_modules/ky/distribution/utils/options.js"() {
|
|
16206
|
-
init_constants();
|
|
16207
|
-
findUnknownOptions = (request, options) => {
|
|
16208
|
-
const unknownOptions = {};
|
|
16209
|
-
for (const key in options) {
|
|
16210
|
-
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {
|
|
16211
|
-
unknownOptions[key] = options[key];
|
|
16212
|
-
}
|
|
16213
|
-
}
|
|
16214
|
-
return unknownOptions;
|
|
16215
|
-
};
|
|
16216
|
-
hasSearchParameters = (search) => {
|
|
16217
|
-
if (search === void 0) {
|
|
16218
|
-
return false;
|
|
16219
|
-
}
|
|
16220
|
-
if (Array.isArray(search)) {
|
|
16221
|
-
return search.length > 0;
|
|
16222
|
-
}
|
|
16223
|
-
if (search instanceof URLSearchParams) {
|
|
16224
|
-
return search.size > 0;
|
|
16225
|
-
}
|
|
16226
|
-
if (typeof search === "object") {
|
|
16227
|
-
return Object.keys(search).length > 0;
|
|
16228
|
-
}
|
|
16229
|
-
if (typeof search === "string") {
|
|
16230
|
-
return search.trim().length > 0;
|
|
16231
|
-
}
|
|
16232
|
-
return Boolean(search);
|
|
16233
|
-
};
|
|
16234
|
-
}
|
|
16235
|
-
});
|
|
16236
|
-
|
|
16237
|
-
// ../../node_modules/ky/distribution/utils/type-guards.js
|
|
16238
|
-
function isHTTPError(error46) {
|
|
16239
|
-
return error46 instanceof HTTPError || error46?.name === HTTPError.name;
|
|
16240
|
-
}
|
|
16241
|
-
function isTimeoutError(error46) {
|
|
16242
|
-
return error46 instanceof TimeoutError || error46?.name === TimeoutError.name;
|
|
16243
|
-
}
|
|
16244
|
-
var init_type_guards = __esm({
|
|
16245
|
-
"../../node_modules/ky/distribution/utils/type-guards.js"() {
|
|
16246
|
-
init_HTTPError();
|
|
16247
|
-
init_TimeoutError();
|
|
16248
|
-
}
|
|
16249
|
-
});
|
|
16250
|
-
|
|
16251
|
-
// ../../node_modules/ky/distribution/core/Ky.js
|
|
16252
|
-
var Ky;
|
|
16253
|
-
var init_Ky = __esm({
|
|
16254
|
-
"../../node_modules/ky/distribution/core/Ky.js"() {
|
|
16255
|
-
init_HTTPError();
|
|
16256
|
-
init_body();
|
|
16257
|
-
init_merge();
|
|
16258
|
-
init_normalize();
|
|
16259
|
-
init_timeout();
|
|
16260
|
-
init_delay();
|
|
16261
|
-
init_options();
|
|
16262
|
-
init_type_guards();
|
|
16263
|
-
init_constants();
|
|
16264
|
-
Ky = class _Ky {
|
|
16265
|
-
static create(input, options) {
|
|
16266
|
-
const ky2 = new _Ky(input, options);
|
|
16267
|
-
const function_ = async () => {
|
|
16268
|
-
if (typeof ky2._options.timeout === "number" && ky2._options.timeout > maxSafeTimeout) {
|
|
16269
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
|
|
16270
|
-
}
|
|
16271
|
-
await Promise.resolve();
|
|
16272
|
-
let response = await ky2._fetch();
|
|
16273
|
-
for (const hook of ky2._options.hooks.afterResponse) {
|
|
16274
|
-
const modifiedResponse = await hook(ky2.request, ky2.#getNormalizedOptions(), ky2._decorateResponse(response.clone()), { retryCount: ky2._retryCount });
|
|
16275
|
-
if (modifiedResponse instanceof globalThis.Response) {
|
|
16276
|
-
response = modifiedResponse;
|
|
16277
|
-
}
|
|
16278
|
-
}
|
|
16279
|
-
ky2._decorateResponse(response);
|
|
16280
|
-
if (!response.ok && ky2._options.throwHttpErrors) {
|
|
16281
|
-
let error46 = new HTTPError(response, ky2.request, ky2.#getNormalizedOptions());
|
|
16282
|
-
for (const hook of ky2._options.hooks.beforeError) {
|
|
16283
|
-
error46 = await hook(error46, { retryCount: ky2._retryCount });
|
|
16284
|
-
}
|
|
16285
|
-
throw error46;
|
|
16286
|
-
}
|
|
16287
|
-
if (ky2._options.onDownloadProgress) {
|
|
16288
|
-
if (typeof ky2._options.onDownloadProgress !== "function") {
|
|
16289
|
-
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
16290
|
-
}
|
|
16291
|
-
if (!supportsResponseStreams) {
|
|
16292
|
-
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
16293
|
-
}
|
|
16294
|
-
return streamResponse(response.clone(), ky2._options.onDownloadProgress);
|
|
16295
|
-
}
|
|
16296
|
-
return response;
|
|
16297
|
-
};
|
|
16298
|
-
const isRetriableMethod = ky2._options.retry.methods.includes(ky2.request.method.toLowerCase());
|
|
16299
|
-
const result = (isRetriableMethod ? ky2._retry(function_) : function_()).finally(async () => {
|
|
16300
|
-
const originalRequest = ky2._originalRequest;
|
|
16301
|
-
const cleanupPromises = [];
|
|
16302
|
-
if (originalRequest && !originalRequest.bodyUsed) {
|
|
16303
|
-
cleanupPromises.push(originalRequest.body?.cancel());
|
|
16304
|
-
}
|
|
16305
|
-
if (!ky2.request.bodyUsed) {
|
|
16306
|
-
cleanupPromises.push(ky2.request.body?.cancel());
|
|
16307
|
-
}
|
|
16308
|
-
await Promise.all(cleanupPromises);
|
|
16309
|
-
});
|
|
16310
|
-
for (const [type2, mimeType] of Object.entries(responseTypes)) {
|
|
16311
|
-
if (type2 === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
|
|
16312
|
-
continue;
|
|
16313
|
-
}
|
|
16314
|
-
result[type2] = async () => {
|
|
16315
|
-
ky2.request.headers.set("accept", ky2.request.headers.get("accept") || mimeType);
|
|
16316
|
-
const response = await result;
|
|
16317
|
-
if (type2 === "json") {
|
|
16318
|
-
if (response.status === 204) {
|
|
16319
|
-
return "";
|
|
16320
|
-
}
|
|
16321
|
-
const text = await response.text();
|
|
16322
|
-
if (text === "") {
|
|
16323
|
-
return "";
|
|
16324
|
-
}
|
|
16325
|
-
if (options.parseJson) {
|
|
16326
|
-
return options.parseJson(text);
|
|
16327
|
-
}
|
|
16328
|
-
return JSON.parse(text);
|
|
16329
|
-
}
|
|
16330
|
-
return response[type2]();
|
|
16331
|
-
};
|
|
16332
|
-
}
|
|
16333
|
-
return result;
|
|
16334
|
-
}
|
|
16335
|
-
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
16336
|
-
static #normalizeSearchParams(searchParams) {
|
|
16337
|
-
if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
|
|
16338
|
-
return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== void 0));
|
|
16339
|
-
}
|
|
16340
|
-
return searchParams;
|
|
16341
|
-
}
|
|
16342
|
-
request;
|
|
16343
|
-
abortController;
|
|
16344
|
-
_retryCount = 0;
|
|
16345
|
-
_input;
|
|
16346
|
-
_options;
|
|
16347
|
-
_originalRequest;
|
|
16348
|
-
#cachedNormalizedOptions;
|
|
16349
|
-
// eslint-disable-next-line complexity
|
|
16350
|
-
constructor(input, options = {}) {
|
|
16351
|
-
this._input = input;
|
|
16352
|
-
this._options = {
|
|
16353
|
-
...options,
|
|
16354
|
-
headers: mergeHeaders(this._input.headers, options.headers),
|
|
16355
|
-
hooks: mergeHooks({
|
|
16356
|
-
beforeRequest: [],
|
|
16357
|
-
beforeRetry: [],
|
|
16358
|
-
beforeError: [],
|
|
16359
|
-
afterResponse: []
|
|
16360
|
-
}, options.hooks),
|
|
16361
|
-
method: normalizeRequestMethod(options.method ?? this._input.method ?? "GET"),
|
|
16362
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
16363
|
-
prefixUrl: String(options.prefixUrl || ""),
|
|
16364
|
-
retry: normalizeRetryOptions(options.retry),
|
|
16365
|
-
throwHttpErrors: options.throwHttpErrors !== false,
|
|
16366
|
-
timeout: options.timeout ?? 1e4,
|
|
16367
|
-
fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
|
|
16368
|
-
};
|
|
16369
|
-
if (typeof this._input !== "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
|
|
16370
|
-
throw new TypeError("`input` must be a string, URL, or Request");
|
|
16371
|
-
}
|
|
16372
|
-
if (this._options.prefixUrl && typeof this._input === "string") {
|
|
16373
|
-
if (this._input.startsWith("/")) {
|
|
16374
|
-
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
16375
|
-
}
|
|
16376
|
-
if (!this._options.prefixUrl.endsWith("/")) {
|
|
16377
|
-
this._options.prefixUrl += "/";
|
|
16378
|
-
}
|
|
16379
|
-
this._input = this._options.prefixUrl + this._input;
|
|
16380
|
-
}
|
|
16381
|
-
if (supportsAbortController && supportsAbortSignal) {
|
|
16382
|
-
const originalSignal = this._options.signal ?? this._input.signal;
|
|
16383
|
-
this.abortController = new globalThis.AbortController();
|
|
16384
|
-
this._options.signal = originalSignal ? AbortSignal.any([originalSignal, this.abortController.signal]) : this.abortController.signal;
|
|
16385
|
-
}
|
|
16386
|
-
if (supportsRequestStreams) {
|
|
16387
|
-
this._options.duplex = "half";
|
|
16388
|
-
}
|
|
16389
|
-
if (this._options.json !== void 0) {
|
|
16390
|
-
this._options.body = this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json);
|
|
16391
|
-
this._options.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json");
|
|
16392
|
-
}
|
|
16393
|
-
const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
|
|
16394
|
-
if (this._input instanceof globalThis.Request && (supportsFormData && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !userProvidedContentType) {
|
|
16395
|
-
this._options.headers.delete("content-type");
|
|
16396
|
-
}
|
|
16397
|
-
this.request = new globalThis.Request(this._input, this._options);
|
|
16398
|
-
if (hasSearchParameters(this._options.searchParams)) {
|
|
16399
|
-
const textSearchParams = typeof this._options.searchParams === "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(_Ky.#normalizeSearchParams(this._options.searchParams)).toString();
|
|
16400
|
-
const searchParams = "?" + textSearchParams;
|
|
16401
|
-
const url2 = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
|
|
16402
|
-
this.request = new globalThis.Request(new globalThis.Request(url2, { ...this.request }), this._options);
|
|
16403
|
-
}
|
|
16404
|
-
if (this._options.onUploadProgress) {
|
|
16405
|
-
if (typeof this._options.onUploadProgress !== "function") {
|
|
16406
|
-
throw new TypeError("The `onUploadProgress` option must be a function");
|
|
16407
|
-
}
|
|
16408
|
-
if (!supportsRequestStreams) {
|
|
16409
|
-
throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
16410
|
-
}
|
|
16411
|
-
const originalBody = this.request.body;
|
|
16412
|
-
if (originalBody) {
|
|
16413
|
-
this.request = streamRequest(this.request, this._options.onUploadProgress, this._options.body);
|
|
16414
|
-
}
|
|
16415
|
-
}
|
|
16416
|
-
}
|
|
16417
|
-
_calculateRetryDelay(error46) {
|
|
16418
|
-
this._retryCount++;
|
|
16419
|
-
if (this._retryCount > this._options.retry.limit || isTimeoutError(error46)) {
|
|
16420
|
-
throw error46;
|
|
16421
|
-
}
|
|
16422
|
-
if (isHTTPError(error46)) {
|
|
16423
|
-
if (!this._options.retry.statusCodes.includes(error46.response.status)) {
|
|
16424
|
-
throw error46;
|
|
16425
|
-
}
|
|
16426
|
-
const retryAfter = error46.response.headers.get("Retry-After") ?? error46.response.headers.get("RateLimit-Reset") ?? error46.response.headers.get("X-RateLimit-Reset") ?? error46.response.headers.get("X-Rate-Limit-Reset");
|
|
16427
|
-
if (retryAfter && this._options.retry.afterStatusCodes.includes(error46.response.status)) {
|
|
16428
|
-
let after = Number(retryAfter) * 1e3;
|
|
16429
|
-
if (Number.isNaN(after)) {
|
|
16430
|
-
after = Date.parse(retryAfter) - Date.now();
|
|
16431
|
-
} else if (after >= Date.parse("2024-01-01")) {
|
|
16432
|
-
after -= Date.now();
|
|
16433
|
-
}
|
|
16434
|
-
const max = this._options.retry.maxRetryAfter ?? after;
|
|
16435
|
-
return after < max ? after : max;
|
|
16436
|
-
}
|
|
16437
|
-
if (error46.response.status === 413) {
|
|
16438
|
-
throw error46;
|
|
16439
|
-
}
|
|
16440
|
-
}
|
|
16441
|
-
const retryDelay = this._options.retry.delay(this._retryCount);
|
|
16442
|
-
return Math.min(this._options.retry.backoffLimit, retryDelay);
|
|
16443
|
-
}
|
|
16444
|
-
_decorateResponse(response) {
|
|
16445
|
-
if (this._options.parseJson) {
|
|
16446
|
-
response.json = async () => this._options.parseJson(await response.text());
|
|
16447
|
-
}
|
|
16448
|
-
return response;
|
|
16449
|
-
}
|
|
16450
|
-
async _retry(function_) {
|
|
16451
|
-
try {
|
|
16452
|
-
return await function_();
|
|
16453
|
-
} catch (error46) {
|
|
16454
|
-
const ms = Math.min(this._calculateRetryDelay(error46), maxSafeTimeout);
|
|
16455
|
-
if (this._retryCount < 1) {
|
|
16456
|
-
throw error46;
|
|
16457
|
-
}
|
|
16458
|
-
await delay(ms, { signal: this._options.signal });
|
|
16459
|
-
for (const hook of this._options.hooks.beforeRetry) {
|
|
16460
|
-
const hookResult = await hook({
|
|
16461
|
-
request: this.request,
|
|
16462
|
-
options: this.#getNormalizedOptions(),
|
|
16463
|
-
error: error46,
|
|
16464
|
-
retryCount: this._retryCount
|
|
16465
|
-
});
|
|
16466
|
-
if (hookResult === stop) {
|
|
16467
|
-
return;
|
|
16468
|
-
}
|
|
16469
|
-
}
|
|
16470
|
-
return this._retry(function_);
|
|
16471
|
-
}
|
|
16472
|
-
}
|
|
16473
|
-
async _fetch() {
|
|
16474
|
-
for (const hook of this._options.hooks.beforeRequest) {
|
|
16475
|
-
const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this._retryCount });
|
|
16476
|
-
if (result instanceof Request) {
|
|
16477
|
-
this.request = result;
|
|
16478
|
-
break;
|
|
16479
|
-
}
|
|
16480
|
-
if (result instanceof Response) {
|
|
16481
|
-
return result;
|
|
16482
|
-
}
|
|
16483
|
-
}
|
|
16484
|
-
const nonRequestOptions = findUnknownOptions(this.request, this._options);
|
|
16485
|
-
this._originalRequest = this.request;
|
|
16486
|
-
this.request = this._originalRequest.clone();
|
|
16487
|
-
if (this._options.timeout === false) {
|
|
16488
|
-
return this._options.fetch(this._originalRequest, nonRequestOptions);
|
|
16489
|
-
}
|
|
16490
|
-
return timeout(this._originalRequest, nonRequestOptions, this.abortController, this._options);
|
|
16491
|
-
}
|
|
16492
|
-
#getNormalizedOptions() {
|
|
16493
|
-
if (!this.#cachedNormalizedOptions) {
|
|
16494
|
-
const { hooks, ...normalizedOptions } = this._options;
|
|
16495
|
-
this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
|
|
16496
|
-
}
|
|
16497
|
-
return this.#cachedNormalizedOptions;
|
|
16498
|
-
}
|
|
16499
|
-
};
|
|
16500
|
-
}
|
|
16501
|
-
});
|
|
16502
|
-
|
|
16503
|
-
// ../../node_modules/ky/distribution/index.js
|
|
16504
|
-
var createInstance, ky, distribution_default;
|
|
16505
|
-
var init_distribution = __esm({
|
|
16506
|
-
"../../node_modules/ky/distribution/index.js"() {
|
|
16507
|
-
init_Ky();
|
|
16508
|
-
init_constants();
|
|
16509
|
-
init_merge();
|
|
16510
|
-
createInstance = (defaults2) => {
|
|
16511
|
-
const ky2 = (input, options) => Ky.create(input, validateAndMerge(defaults2, options));
|
|
16512
|
-
for (const method of requestMethods) {
|
|
16513
|
-
ky2[method] = (input, options) => Ky.create(input, validateAndMerge(defaults2, options, { method }));
|
|
16514
|
-
}
|
|
16515
|
-
ky2.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
|
|
16516
|
-
ky2.extend = (newDefaults) => {
|
|
16517
|
-
if (typeof newDefaults === "function") {
|
|
16518
|
-
newDefaults = newDefaults(defaults2 ?? {});
|
|
16519
|
-
}
|
|
16520
|
-
return createInstance(validateAndMerge(defaults2, newDefaults));
|
|
16521
|
-
};
|
|
16522
|
-
ky2.stop = stop;
|
|
16523
|
-
return ky2;
|
|
16524
|
-
};
|
|
16525
|
-
ky = createInstance();
|
|
16526
|
-
distribution_default = ky;
|
|
16527
|
-
}
|
|
16528
|
-
});
|
|
16529
|
-
|
|
16530
|
-
// ../../packages/api-client/dist/index.js
|
|
16531
|
-
function createSSEStream(url2, fetchOptions, config2) {
|
|
16532
|
-
const abortController = new AbortController();
|
|
16533
|
-
let progressCallback = null;
|
|
16534
|
-
let completeCallback = null;
|
|
16535
|
-
let errorCallback = null;
|
|
16536
|
-
const customHandlers = /* @__PURE__ */ new Map();
|
|
16537
|
-
let closed = false;
|
|
16538
|
-
const connect = async () => {
|
|
16539
|
-
try {
|
|
16540
|
-
const response = await fetch(url2, {
|
|
16541
|
-
...fetchOptions,
|
|
16542
|
-
signal: abortController.signal,
|
|
16543
|
-
headers: {
|
|
16544
|
-
...fetchOptions.headers,
|
|
16545
|
-
"Accept": "text/event-stream"
|
|
16546
|
-
}
|
|
16547
|
-
});
|
|
16548
|
-
if (!response.ok) {
|
|
16549
|
-
const errorData = await response.json().catch(() => ({}));
|
|
16550
|
-
throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`);
|
|
16551
|
-
}
|
|
16552
|
-
if (!response.body) {
|
|
16553
|
-
throw new Error("Response body is null - server did not return a stream");
|
|
16554
|
-
}
|
|
16555
|
-
const reader = response.body.getReader();
|
|
16556
|
-
const decoder = new TextDecoder();
|
|
16557
|
-
let buffer = "";
|
|
16558
|
-
let eventType = "";
|
|
16559
|
-
let eventData = "";
|
|
16560
|
-
let eventId = "";
|
|
16561
|
-
while (true) {
|
|
16562
|
-
const { done, value } = await reader.read();
|
|
16563
|
-
if (done || closed) break;
|
|
16564
|
-
buffer += decoder.decode(value, { stream: true });
|
|
16565
|
-
const lines = buffer.split("\n");
|
|
16566
|
-
buffer = lines.pop() || "";
|
|
16567
|
-
for (const line of lines) {
|
|
16568
|
-
if (line.startsWith("event:")) {
|
|
16569
|
-
eventType = line.slice(6).trim();
|
|
16570
|
-
} else if (line.startsWith("data:")) {
|
|
16571
|
-
eventData = line.slice(5).trim();
|
|
16572
|
-
} else if (line.startsWith("id:")) {
|
|
16573
|
-
eventId = line.slice(3).trim();
|
|
16574
|
-
} else if (line === "") {
|
|
16575
|
-
if (eventData && !closed) {
|
|
16576
|
-
handleEvent(eventType, eventData, eventId);
|
|
16577
|
-
if (closed) break;
|
|
16578
|
-
eventType = "";
|
|
16579
|
-
eventData = "";
|
|
16580
|
-
eventId = "";
|
|
16581
|
-
}
|
|
16582
|
-
}
|
|
16583
|
-
}
|
|
16584
|
-
if (closed) break;
|
|
16585
|
-
}
|
|
16586
|
-
} catch (error46) {
|
|
16587
|
-
if (error46 instanceof Error && error46.name !== "AbortError") {
|
|
16588
|
-
errorCallback?.(error46);
|
|
16589
|
-
}
|
|
16590
|
-
}
|
|
16591
|
-
};
|
|
16592
|
-
const handleEvent = (eventType, data, _id) => {
|
|
16593
|
-
if (data.startsWith(":")) {
|
|
16594
|
-
return;
|
|
16595
|
-
}
|
|
16596
|
-
try {
|
|
16597
|
-
const parsed = JSON.parse(data);
|
|
16598
|
-
if (config2.customEventHandler) {
|
|
16599
|
-
const handler = customHandlers.get(eventType);
|
|
16600
|
-
if (handler) {
|
|
16601
|
-
handler(parsed);
|
|
16602
|
-
return;
|
|
16603
|
-
}
|
|
16604
|
-
progressCallback?.(parsed);
|
|
16605
|
-
return;
|
|
16606
|
-
}
|
|
16607
|
-
if (config2.progressEvents.includes(eventType)) {
|
|
16608
|
-
progressCallback?.(parsed);
|
|
16609
|
-
}
|
|
16610
|
-
if (config2.completeEvent && eventType === config2.completeEvent) {
|
|
16611
|
-
completeCallback?.(parsed);
|
|
16612
|
-
closed = true;
|
|
16613
|
-
abortController.abort();
|
|
16614
|
-
}
|
|
16615
|
-
if (config2.errorEvent && eventType === config2.errorEvent) {
|
|
16616
|
-
errorCallback?.(new Error(parsed.message || "Stream error"));
|
|
16617
|
-
closed = true;
|
|
16618
|
-
abortController.abort();
|
|
16619
|
-
}
|
|
16620
|
-
} catch (error46) {
|
|
16621
|
-
console.error("[SSE] Failed to parse event data:", error46);
|
|
16622
|
-
console.error("[SSE] Event type:", eventType);
|
|
16623
|
-
console.error("[SSE] Data:", data);
|
|
16624
|
-
}
|
|
16625
|
-
};
|
|
16626
|
-
connect();
|
|
16627
|
-
return {
|
|
16628
|
-
onProgress(callback) {
|
|
16629
|
-
progressCallback = callback;
|
|
16630
|
-
},
|
|
16631
|
-
onComplete(callback) {
|
|
16632
|
-
completeCallback = callback;
|
|
16633
|
-
},
|
|
16634
|
-
onError(callback) {
|
|
16635
|
-
errorCallback = callback;
|
|
16636
|
-
},
|
|
16637
|
-
close() {
|
|
16638
|
-
abortController.abort();
|
|
16639
|
-
},
|
|
16640
|
-
// Internal method for custom event handlers (used by resourceEvents)
|
|
16641
|
-
on(event, callback) {
|
|
16642
|
-
customHandlers.set(event, callback);
|
|
16643
|
-
}
|
|
16644
|
-
};
|
|
16645
|
-
}
|
|
16646
|
-
function baseUrl(value) {
|
|
16647
|
-
return value;
|
|
16648
|
-
}
|
|
16649
|
-
var SSEClient, APIError, SemiontApiClient, LOCALES, localeByCode;
|
|
16650
|
-
var init_dist = __esm({
|
|
16651
|
-
"../../packages/api-client/dist/index.js"() {
|
|
16652
|
-
"use strict";
|
|
16653
|
-
init_distribution();
|
|
16654
|
-
SSEClient = class {
|
|
16655
|
-
baseUrl;
|
|
16656
|
-
accessToken = null;
|
|
16657
|
-
constructor(config2) {
|
|
16658
|
-
this.baseUrl = config2.baseUrl.endsWith("/") ? config2.baseUrl.slice(0, -1) : config2.baseUrl;
|
|
16659
|
-
this.accessToken = config2.accessToken || null;
|
|
16660
|
-
}
|
|
16661
|
-
/**
|
|
16662
|
-
* Set the access token for authenticated requests
|
|
16663
|
-
*/
|
|
16664
|
-
setAccessToken(token) {
|
|
16665
|
-
this.accessToken = token;
|
|
16666
|
-
}
|
|
16667
|
-
/**
|
|
16668
|
-
* Clear the access token
|
|
16669
|
-
*/
|
|
16670
|
-
clearAccessToken() {
|
|
16671
|
-
this.accessToken = null;
|
|
16672
|
-
}
|
|
16673
|
-
/**
|
|
16674
|
-
* Get common headers for SSE requests
|
|
16675
|
-
*/
|
|
16676
|
-
getHeaders() {
|
|
16677
|
-
const headers = {
|
|
16678
|
-
"Content-Type": "application/json"
|
|
16679
|
-
};
|
|
16680
|
-
if (this.accessToken) {
|
|
16681
|
-
headers["Authorization"] = `Bearer ${this.accessToken}`;
|
|
16682
|
-
}
|
|
16683
|
-
return headers;
|
|
16684
|
-
}
|
|
16685
|
-
/**
|
|
16686
|
-
* Extract resource ID from URI
|
|
16687
|
-
*
|
|
16688
|
-
* Handles both full URIs and plain IDs:
|
|
16689
|
-
* - 'http://localhost:4000/resources/doc-123' -> 'doc-123'
|
|
16690
|
-
* - 'doc-123' -> 'doc-123'
|
|
16691
|
-
*/
|
|
16692
|
-
extractId(uri) {
|
|
16693
|
-
const parts = uri.split("/");
|
|
16694
|
-
return parts[parts.length - 1];
|
|
16695
|
-
}
|
|
16696
|
-
/**
|
|
16697
|
-
* Detect annotations in a resource (streaming)
|
|
16698
|
-
*
|
|
16699
|
-
* Streams entity detection progress via Server-Sent Events.
|
|
16700
|
-
*
|
|
16701
|
-
* @param resourceId - Resource URI or ID
|
|
16702
|
-
* @param request - Detection configuration (entity types to detect)
|
|
16703
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
16704
|
-
*
|
|
16705
|
-
* @example
|
|
16706
|
-
* ```typescript
|
|
16707
|
-
* const stream = sseClient.detectAnnotations(
|
|
16708
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
16709
|
-
* { entityTypes: ['Person', 'Organization'] }
|
|
16710
|
-
* );
|
|
16711
|
-
*
|
|
16712
|
-
* stream.onProgress((progress) => {
|
|
16713
|
-
* console.log(`Scanning: ${progress.currentEntityType}`);
|
|
16714
|
-
* console.log(`Progress: ${progress.processedEntityTypes}/${progress.totalEntityTypes}`);
|
|
16715
|
-
* });
|
|
16716
|
-
*
|
|
16717
|
-
* stream.onComplete((result) => {
|
|
16718
|
-
* console.log(`Detection complete! Found ${result.foundCount} entities`);
|
|
16719
|
-
* });
|
|
16720
|
-
*
|
|
16721
|
-
* stream.onError((error) => {
|
|
16722
|
-
* console.error('Detection failed:', error.message);
|
|
16723
|
-
* });
|
|
16724
|
-
*
|
|
16725
|
-
* // Cleanup when done
|
|
16726
|
-
* stream.close();
|
|
16727
|
-
* ```
|
|
16728
|
-
*/
|
|
16729
|
-
detectAnnotations(resourceId, request) {
|
|
16730
|
-
const id = this.extractId(resourceId);
|
|
16731
|
-
const url2 = `${this.baseUrl}/resources/${id}/detect-annotations-stream`;
|
|
16732
|
-
return createSSEStream(
|
|
16733
|
-
url2,
|
|
16734
|
-
{
|
|
16735
|
-
method: "POST",
|
|
16736
|
-
headers: this.getHeaders(),
|
|
16737
|
-
body: JSON.stringify(request)
|
|
16738
|
-
},
|
|
16739
|
-
{
|
|
16740
|
-
progressEvents: ["detection-started", "detection-progress"],
|
|
16741
|
-
completeEvent: "detection-complete",
|
|
16742
|
-
errorEvent: "detection-error"
|
|
16743
|
-
}
|
|
16744
|
-
);
|
|
16745
|
-
}
|
|
16746
|
-
/**
|
|
16747
|
-
* Generate resource from annotation (streaming)
|
|
16748
|
-
*
|
|
16749
|
-
* Streams resource generation progress via Server-Sent Events.
|
|
16750
|
-
*
|
|
16751
|
-
* @param resourceId - Source resource URI or ID
|
|
16752
|
-
* @param annotationId - Annotation URI or ID to use as generation source
|
|
16753
|
-
* @param request - Generation options (title, prompt, language)
|
|
16754
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
16755
|
-
*
|
|
16756
|
-
* @example
|
|
16757
|
-
* ```typescript
|
|
16758
|
-
* const stream = sseClient.generateResourceFromAnnotation(
|
|
16759
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
16760
|
-
* 'http://localhost:4000/annotations/ann-456',
|
|
16761
|
-
* { language: 'es', title: 'Spanish Summary' }
|
|
16762
|
-
* );
|
|
16763
|
-
*
|
|
16764
|
-
* stream.onProgress((progress) => {
|
|
16765
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
16766
|
-
* console.log(progress.message);
|
|
16767
|
-
* });
|
|
16768
|
-
*
|
|
16769
|
-
* stream.onComplete((result) => {
|
|
16770
|
-
* console.log(`Generated resource: ${result.resourceId}`);
|
|
16771
|
-
* });
|
|
16772
|
-
*
|
|
16773
|
-
* stream.onError((error) => {
|
|
16774
|
-
* console.error('Generation failed:', error.message);
|
|
16775
|
-
* });
|
|
16776
|
-
*
|
|
16777
|
-
* // Cleanup when done
|
|
16778
|
-
* stream.close();
|
|
16779
|
-
* ```
|
|
16780
|
-
*/
|
|
16781
|
-
generateResourceFromAnnotation(resourceId, annotationId, request) {
|
|
16782
|
-
const resId = this.extractId(resourceId);
|
|
16783
|
-
const annId = this.extractId(annotationId);
|
|
16784
|
-
const url2 = `${this.baseUrl}/resources/${resId}/annotations/${annId}/generate-resource-stream`;
|
|
16785
|
-
return createSSEStream(
|
|
16786
|
-
url2,
|
|
16787
|
-
{
|
|
16788
|
-
method: "POST",
|
|
16789
|
-
headers: this.getHeaders(),
|
|
16790
|
-
body: JSON.stringify(request)
|
|
16791
|
-
},
|
|
16792
|
-
{
|
|
16793
|
-
progressEvents: ["generation-started", "generation-progress"],
|
|
16794
|
-
completeEvent: "generation-complete",
|
|
16795
|
-
errorEvent: "generation-error"
|
|
16796
|
-
}
|
|
16797
|
-
);
|
|
16798
|
-
}
|
|
16799
|
-
/**
|
|
16800
|
-
* Detect highlights in a resource (streaming)
|
|
16801
|
-
*
|
|
16802
|
-
* Streams highlight detection progress via Server-Sent Events.
|
|
16803
|
-
*
|
|
16804
|
-
* @param resourceId - Resource URI or ID
|
|
16805
|
-
* @param request - Detection configuration (optional instructions)
|
|
16806
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
16807
|
-
*
|
|
16808
|
-
* @example
|
|
16809
|
-
* ```typescript
|
|
16810
|
-
* const stream = sseClient.detectHighlights(
|
|
16811
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
16812
|
-
* { instructions: 'Focus on key technical points' }
|
|
16813
|
-
* );
|
|
16814
|
-
*
|
|
16815
|
-
* stream.onProgress((progress) => {
|
|
16816
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
16817
|
-
* console.log(progress.message);
|
|
16818
|
-
* });
|
|
16819
|
-
*
|
|
16820
|
-
* stream.onComplete((result) => {
|
|
16821
|
-
* console.log(`Detection complete! Created ${result.createdCount} highlights`);
|
|
16822
|
-
* });
|
|
16823
|
-
*
|
|
16824
|
-
* stream.onError((error) => {
|
|
16825
|
-
* console.error('Detection failed:', error.message);
|
|
16826
|
-
* });
|
|
16827
|
-
*
|
|
16828
|
-
* // Cleanup when done
|
|
16829
|
-
* stream.close();
|
|
16830
|
-
* ```
|
|
16831
|
-
*/
|
|
16832
|
-
detectHighlights(resourceId, request = {}) {
|
|
16833
|
-
const id = this.extractId(resourceId);
|
|
16834
|
-
const url2 = `${this.baseUrl}/resources/${id}/detect-highlights-stream`;
|
|
16835
|
-
return createSSEStream(
|
|
16836
|
-
url2,
|
|
16837
|
-
{
|
|
16838
|
-
method: "POST",
|
|
16839
|
-
headers: this.getHeaders(),
|
|
16840
|
-
body: JSON.stringify(request)
|
|
16841
|
-
},
|
|
16842
|
-
{
|
|
16843
|
-
progressEvents: ["highlight-detection-started", "highlight-detection-progress"],
|
|
16844
|
-
completeEvent: "highlight-detection-complete",
|
|
16845
|
-
errorEvent: "highlight-detection-error"
|
|
16846
|
-
}
|
|
16847
|
-
);
|
|
16848
|
-
}
|
|
16849
|
-
/**
|
|
16850
|
-
* Detect assessments in a resource (streaming)
|
|
16851
|
-
*
|
|
16852
|
-
* Streams assessment detection progress via Server-Sent Events.
|
|
16853
|
-
*
|
|
16854
|
-
* @param resourceId - Resource URI or ID
|
|
16855
|
-
* @param request - Detection configuration (optional instructions)
|
|
16856
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
16857
|
-
*
|
|
16858
|
-
* @example
|
|
16859
|
-
* ```typescript
|
|
16860
|
-
* const stream = sseClient.detectAssessments(
|
|
16861
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
16862
|
-
* { instructions: 'Evaluate claims for accuracy' }
|
|
16863
|
-
* );
|
|
16864
|
-
*
|
|
16865
|
-
* stream.onProgress((progress) => {
|
|
16866
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
16867
|
-
* console.log(progress.message);
|
|
16868
|
-
* });
|
|
16869
|
-
*
|
|
16870
|
-
* stream.onComplete((result) => {
|
|
16871
|
-
* console.log(`Detection complete! Created ${result.createdCount} assessments`);
|
|
16872
|
-
* });
|
|
16873
|
-
*
|
|
16874
|
-
* stream.onError((error) => {
|
|
16875
|
-
* console.error('Detection failed:', error.message);
|
|
16876
|
-
* });
|
|
16877
|
-
*
|
|
16878
|
-
* // Cleanup when done
|
|
16879
|
-
* stream.close();
|
|
16880
|
-
* ```
|
|
16881
|
-
*/
|
|
16882
|
-
detectAssessments(resourceId, request = {}) {
|
|
16883
|
-
const id = this.extractId(resourceId);
|
|
16884
|
-
const url2 = `${this.baseUrl}/resources/${id}/detect-assessments-stream`;
|
|
16885
|
-
return createSSEStream(
|
|
16886
|
-
url2,
|
|
16887
|
-
{
|
|
16888
|
-
method: "POST",
|
|
16889
|
-
headers: this.getHeaders(),
|
|
16890
|
-
body: JSON.stringify(request)
|
|
16891
|
-
},
|
|
16892
|
-
{
|
|
16893
|
-
progressEvents: ["assessment-detection-started", "assessment-detection-progress"],
|
|
16894
|
-
completeEvent: "assessment-detection-complete",
|
|
16895
|
-
errorEvent: "assessment-detection-error"
|
|
16896
|
-
}
|
|
16897
|
-
);
|
|
16898
|
-
}
|
|
16899
|
-
/**
|
|
16900
|
-
* Detect comments in a resource (streaming)
|
|
16901
|
-
*
|
|
16902
|
-
* Streams comment detection progress via Server-Sent Events.
|
|
16903
|
-
* Uses AI to identify passages that would benefit from explanatory comments
|
|
16904
|
-
* and creates comment annotations with contextual information.
|
|
16905
|
-
*
|
|
16906
|
-
* @param resourceId - Resource URI or ID
|
|
16907
|
-
* @param request - Detection configuration (optional instructions and tone)
|
|
16908
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
16909
|
-
*
|
|
16910
|
-
* @example
|
|
16911
|
-
* ```typescript
|
|
16912
|
-
* const stream = sseClient.detectComments('http://localhost:4000/resources/doc-123', {
|
|
16913
|
-
* instructions: 'Focus on technical terminology',
|
|
16914
|
-
* tone: 'scholarly'
|
|
16915
|
-
* });
|
|
16916
|
-
*
|
|
16917
|
-
* stream.onProgress((progress) => {
|
|
16918
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
16919
|
-
* });
|
|
16920
|
-
*
|
|
16921
|
-
* stream.onComplete((result) => {
|
|
16922
|
-
* console.log(`Detection complete! Created ${result.createdCount} comments`);
|
|
16923
|
-
* });
|
|
16924
|
-
*
|
|
16925
|
-
* stream.onError((error) => {
|
|
16926
|
-
* console.error('Detection failed:', error.message);
|
|
16927
|
-
* });
|
|
16928
|
-
*
|
|
16929
|
-
* // Cleanup when done
|
|
16930
|
-
* stream.close();
|
|
16931
|
-
* ```
|
|
16932
|
-
*/
|
|
16933
|
-
detectComments(resourceId, request = {}) {
|
|
16934
|
-
const id = this.extractId(resourceId);
|
|
16935
|
-
const url2 = `${this.baseUrl}/resources/${id}/detect-comments-stream`;
|
|
16936
|
-
return createSSEStream(
|
|
16937
|
-
url2,
|
|
16938
|
-
{
|
|
16939
|
-
method: "POST",
|
|
16940
|
-
headers: this.getHeaders(),
|
|
16941
|
-
body: JSON.stringify(request)
|
|
16942
|
-
},
|
|
16943
|
-
{
|
|
16944
|
-
progressEvents: ["comment-detection-started", "comment-detection-progress"],
|
|
16945
|
-
completeEvent: "comment-detection-complete",
|
|
16946
|
-
errorEvent: "comment-detection-error"
|
|
16947
|
-
}
|
|
16948
|
-
);
|
|
16949
|
-
}
|
|
16950
|
-
/**
|
|
16951
|
-
* Detect tags in a resource (streaming)
|
|
16952
|
-
*
|
|
16953
|
-
* Streams tag detection progress via Server-Sent Events.
|
|
16954
|
-
* Uses AI to identify passages serving specific structural roles
|
|
16955
|
-
* (e.g., IRAC, IMRAD, Toulmin) and creates tag annotations with dual-body structure.
|
|
16956
|
-
*
|
|
16957
|
-
* @param resourceId - Resource URI or ID
|
|
16958
|
-
* @param request - Detection configuration (schema and categories to detect)
|
|
16959
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
16960
|
-
*
|
|
16961
|
-
* @example
|
|
16962
|
-
* ```typescript
|
|
16963
|
-
* const stream = sseClient.detectTags('http://localhost:4000/resources/doc-123', {
|
|
16964
|
-
* schemaId: 'legal-irac',
|
|
16965
|
-
* categories: ['Issue', 'Rule', 'Application', 'Conclusion']
|
|
16966
|
-
* });
|
|
16967
|
-
*
|
|
16968
|
-
* stream.onProgress((progress) => {
|
|
16969
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
16970
|
-
* console.log(`Processing ${progress.currentCategory}...`);
|
|
16971
|
-
* });
|
|
16972
|
-
*
|
|
16973
|
-
* stream.onComplete((result) => {
|
|
16974
|
-
* console.log(`Detection complete! Created ${result.tagsCreated} tags`);
|
|
16975
|
-
* });
|
|
16976
|
-
*
|
|
16977
|
-
* stream.onError((error) => {
|
|
16978
|
-
* console.error('Detection failed:', error.message);
|
|
16979
|
-
* });
|
|
16980
|
-
*
|
|
16981
|
-
* // Cleanup when done
|
|
16982
|
-
* stream.close();
|
|
16983
|
-
* ```
|
|
16984
|
-
*/
|
|
16985
|
-
detectTags(resourceId, request) {
|
|
16986
|
-
const id = this.extractId(resourceId);
|
|
16987
|
-
const url2 = `${this.baseUrl}/resources/${id}/detect-tags-stream`;
|
|
16988
|
-
return createSSEStream(
|
|
16989
|
-
url2,
|
|
16990
|
-
{
|
|
16991
|
-
method: "POST",
|
|
16992
|
-
headers: this.getHeaders(),
|
|
16993
|
-
body: JSON.stringify(request)
|
|
16994
|
-
},
|
|
16995
|
-
{
|
|
16996
|
-
progressEvents: ["tag-detection-started", "tag-detection-progress"],
|
|
16997
|
-
completeEvent: "tag-detection-complete",
|
|
16998
|
-
errorEvent: "tag-detection-error"
|
|
16999
|
-
}
|
|
17000
|
-
);
|
|
17001
|
-
}
|
|
17002
|
-
/**
|
|
17003
|
-
* Subscribe to resource events (long-lived stream)
|
|
17004
|
-
*
|
|
17005
|
-
* Opens a long-lived SSE connection to receive real-time events for a resource.
|
|
17006
|
-
* Used for collaborative editing - see events from other users as they happen.
|
|
17007
|
-
*
|
|
17008
|
-
* This stream does NOT have a complete event - it stays open until explicitly closed.
|
|
17009
|
-
*
|
|
17010
|
-
* @param resourceId - Resource URI or ID to subscribe to
|
|
17011
|
-
* @returns SSE stream controller with event callback
|
|
17012
|
-
*
|
|
17013
|
-
* @example
|
|
17014
|
-
* ```typescript
|
|
17015
|
-
* const stream = sseClient.resourceEvents('http://localhost:4000/resources/doc-123');
|
|
17016
|
-
*
|
|
17017
|
-
* stream.onProgress((event) => {
|
|
17018
|
-
* console.log(`Event: ${event.type}`);
|
|
17019
|
-
* console.log(`User: ${event.userId}`);
|
|
17020
|
-
* console.log(`Sequence: ${event.metadata.sequenceNumber}`);
|
|
17021
|
-
* console.log(`Payload:`, event.payload);
|
|
17022
|
-
* });
|
|
17023
|
-
*
|
|
17024
|
-
* stream.onError((error) => {
|
|
17025
|
-
* console.error('Stream error:', error.message);
|
|
17026
|
-
* });
|
|
17027
|
-
*
|
|
17028
|
-
* // Close when no longer needed (e.g., component unmount)
|
|
17029
|
-
* stream.close();
|
|
17030
|
-
* ```
|
|
17031
|
-
*/
|
|
17032
|
-
resourceEvents(resourceId) {
|
|
17033
|
-
const id = this.extractId(resourceId);
|
|
17034
|
-
const url2 = `${this.baseUrl}/resources/${id}/events/stream`;
|
|
17035
|
-
return createSSEStream(
|
|
17036
|
-
url2,
|
|
17037
|
-
{
|
|
17038
|
-
method: "GET",
|
|
17039
|
-
headers: this.getHeaders()
|
|
17040
|
-
},
|
|
17041
|
-
{
|
|
17042
|
-
progressEvents: ["*"],
|
|
17043
|
-
// Accept all event types
|
|
17044
|
-
completeEvent: null,
|
|
17045
|
-
// Long-lived stream - no completion
|
|
17046
|
-
errorEvent: "error",
|
|
17047
|
-
// Generic error event
|
|
17048
|
-
customEventHandler: true
|
|
17049
|
-
// Use custom event handling
|
|
17050
|
-
}
|
|
17051
|
-
);
|
|
17052
|
-
}
|
|
17053
|
-
};
|
|
17054
|
-
APIError = class extends Error {
|
|
17055
|
-
constructor(message, status, statusText, details) {
|
|
17056
|
-
super(message);
|
|
17057
|
-
this.status = status;
|
|
17058
|
-
this.statusText = statusText;
|
|
17059
|
-
this.details = details;
|
|
17060
|
-
this.name = "APIError";
|
|
17061
|
-
}
|
|
17062
|
-
};
|
|
17063
|
-
SemiontApiClient = class {
|
|
17064
|
-
http;
|
|
17065
|
-
baseUrl;
|
|
17066
|
-
accessToken = null;
|
|
17067
|
-
/**
|
|
17068
|
-
* SSE streaming client for real-time operations
|
|
17069
|
-
*
|
|
17070
|
-
* Separate from the main HTTP client to clearly mark streaming endpoints.
|
|
17071
|
-
* Uses native fetch() instead of ky for SSE support.
|
|
17072
|
-
*
|
|
17073
|
-
* @example
|
|
17074
|
-
* ```typescript
|
|
17075
|
-
* const stream = client.sse.detectAnnotations(
|
|
17076
|
-
* resourceId,
|
|
17077
|
-
* { entityTypes: ['Person', 'Organization'] }
|
|
17078
|
-
* );
|
|
17079
|
-
*
|
|
17080
|
-
* stream.onProgress((p) => console.log(p.message));
|
|
17081
|
-
* stream.onComplete((r) => console.log(`Found ${r.foundCount} entities`));
|
|
17082
|
-
* stream.close();
|
|
17083
|
-
* ```
|
|
17084
|
-
*/
|
|
17085
|
-
sse;
|
|
17086
|
-
constructor(config2) {
|
|
17087
|
-
const { baseUrl: baseUrl2, accessToken: accessToken2, timeout: timeout2 = 3e4, retry = 2 } = config2;
|
|
17088
|
-
this.baseUrl = baseUrl2.endsWith("/") ? baseUrl2.slice(0, -1) : baseUrl2;
|
|
17089
|
-
this.http = distribution_default.create({
|
|
17090
|
-
timeout: timeout2,
|
|
17091
|
-
retry,
|
|
17092
|
-
hooks: {
|
|
17093
|
-
beforeRequest: [
|
|
17094
|
-
(request) => {
|
|
17095
|
-
if (this.accessToken) {
|
|
17096
|
-
request.headers.set("Authorization", `Bearer ${this.accessToken}`);
|
|
17097
|
-
}
|
|
17098
|
-
}
|
|
17099
|
-
],
|
|
17100
|
-
beforeError: [
|
|
17101
|
-
async (error46) => {
|
|
17102
|
-
const { response } = error46;
|
|
17103
|
-
if (response) {
|
|
17104
|
-
const body = await response.json().catch(() => ({}));
|
|
17105
|
-
throw new APIError(
|
|
17106
|
-
body.message || `HTTP ${response.status}: ${response.statusText}`,
|
|
17107
|
-
response.status,
|
|
17108
|
-
response.statusText,
|
|
17109
|
-
body
|
|
17110
|
-
);
|
|
17111
|
-
}
|
|
17112
|
-
return error46;
|
|
17113
|
-
}
|
|
17114
|
-
]
|
|
17115
|
-
}
|
|
17116
|
-
});
|
|
17117
|
-
if (accessToken2) {
|
|
17118
|
-
this.accessToken = accessToken2;
|
|
17119
|
-
}
|
|
17120
|
-
this.sse = new SSEClient({
|
|
17121
|
-
baseUrl: this.baseUrl,
|
|
17122
|
-
accessToken: this.accessToken || void 0
|
|
17123
|
-
});
|
|
17124
|
-
}
|
|
17125
|
-
/**
|
|
17126
|
-
* Set the access token for authenticated requests
|
|
17127
|
-
*/
|
|
17128
|
-
setAccessToken(token) {
|
|
17129
|
-
this.accessToken = token;
|
|
17130
|
-
this.sse.setAccessToken(token);
|
|
17131
|
-
}
|
|
17132
|
-
/**
|
|
17133
|
-
* Clear the access token
|
|
17134
|
-
*/
|
|
17135
|
-
clearAccessToken() {
|
|
17136
|
-
this.accessToken = null;
|
|
17137
|
-
this.sse.clearAccessToken();
|
|
17138
|
-
}
|
|
17139
|
-
// ============================================================================
|
|
17140
|
-
// AUTHENTICATION
|
|
17141
|
-
// ============================================================================
|
|
17142
|
-
async authenticatePassword(email22, password) {
|
|
17143
|
-
const response = await this.http.post(`${this.baseUrl}/api/tokens/password`, { json: { email: email22, password } }).json();
|
|
17144
|
-
if (response.token) {
|
|
17145
|
-
this.setAccessToken(response.token);
|
|
17146
|
-
}
|
|
17147
|
-
return response;
|
|
17148
|
-
}
|
|
17149
|
-
async refreshToken(token) {
|
|
17150
|
-
const response = await this.http.post(`${this.baseUrl}/api/tokens/refresh`, { json: { refreshToken: token } }).json();
|
|
17151
|
-
if (response.access_token) {
|
|
17152
|
-
this.setAccessToken(response.access_token);
|
|
17153
|
-
}
|
|
17154
|
-
return response;
|
|
17155
|
-
}
|
|
17156
|
-
async authenticateGoogle(credential) {
|
|
17157
|
-
const response = await this.http.post(`${this.baseUrl}/api/tokens/google`, { json: { credential } }).json();
|
|
17158
|
-
if (response.token) {
|
|
17159
|
-
this.setAccessToken(response.token);
|
|
17160
|
-
}
|
|
17161
|
-
return response;
|
|
17162
|
-
}
|
|
17163
|
-
async generateMCPToken() {
|
|
17164
|
-
return this.http.post(`${this.baseUrl}/api/tokens/mcp-generate`).json();
|
|
17165
|
-
}
|
|
17166
|
-
// ============================================================================
|
|
17167
|
-
// USERS
|
|
17168
|
-
// ============================================================================
|
|
17169
|
-
async getMe() {
|
|
17170
|
-
return this.http.get(`${this.baseUrl}/api/users/me`).json();
|
|
17171
|
-
}
|
|
17172
|
-
async acceptTerms() {
|
|
17173
|
-
return this.http.post(`${this.baseUrl}/api/users/accept-terms`).json();
|
|
17174
|
-
}
|
|
17175
|
-
async logout() {
|
|
17176
|
-
return this.http.post(`${this.baseUrl}/api/users/logout`).json();
|
|
17177
|
-
}
|
|
17178
|
-
// ============================================================================
|
|
17179
|
-
// RESOURCES
|
|
17180
|
-
// ============================================================================
|
|
17181
|
-
/**
|
|
17182
|
-
* Create a new resource with binary content support
|
|
17183
|
-
*
|
|
17184
|
-
* @param data - Resource creation data
|
|
17185
|
-
* @param data.name - Resource name
|
|
17186
|
-
* @param data.file - File object or Buffer with binary content
|
|
17187
|
-
* @param data.format - MIME type (e.g., 'text/markdown', 'image/png')
|
|
17188
|
-
* @param data.entityTypes - Optional array of entity types
|
|
17189
|
-
* @param data.language - Optional ISO 639-1 language code
|
|
17190
|
-
* @param data.creationMethod - Optional creation method
|
|
17191
|
-
* @param data.sourceAnnotationId - Optional source annotation ID
|
|
17192
|
-
* @param data.sourceResourceId - Optional source resource ID
|
|
17193
|
-
*/
|
|
17194
|
-
async createResource(data) {
|
|
17195
|
-
const formData = new FormData();
|
|
17196
|
-
formData.append("name", data.name);
|
|
17197
|
-
formData.append("format", data.format);
|
|
17198
|
-
if (data.file instanceof File) {
|
|
17199
|
-
formData.append("file", data.file);
|
|
17200
|
-
} else if (Buffer.isBuffer(data.file)) {
|
|
17201
|
-
const blob = new Blob([data.file], { type: data.format });
|
|
17202
|
-
formData.append("file", blob, data.name);
|
|
17203
|
-
} else {
|
|
17204
|
-
throw new Error("file must be a File or Buffer");
|
|
17205
|
-
}
|
|
17206
|
-
if (data.entityTypes && data.entityTypes.length > 0) {
|
|
17207
|
-
formData.append("entityTypes", JSON.stringify(data.entityTypes));
|
|
17208
|
-
}
|
|
17209
|
-
if (data.language) {
|
|
17210
|
-
formData.append("language", data.language);
|
|
17211
|
-
}
|
|
17212
|
-
if (data.creationMethod) {
|
|
17213
|
-
formData.append("creationMethod", data.creationMethod);
|
|
17214
|
-
}
|
|
17215
|
-
if (data.sourceAnnotationId) {
|
|
17216
|
-
formData.append("sourceAnnotationId", data.sourceAnnotationId);
|
|
17217
|
-
}
|
|
17218
|
-
if (data.sourceResourceId) {
|
|
17219
|
-
formData.append("sourceResourceId", data.sourceResourceId);
|
|
17220
|
-
}
|
|
17221
|
-
return this.http.post(`${this.baseUrl}/resources`, { body: formData }).json();
|
|
17222
|
-
}
|
|
17223
|
-
async getResource(resourceUri2) {
|
|
17224
|
-
return this.http.get(resourceUri2).json();
|
|
17225
|
-
}
|
|
17226
|
-
/**
|
|
17227
|
-
* Get resource representation using W3C content negotiation
|
|
17228
|
-
* Returns raw binary content (images, PDFs, text, etc.) with content type
|
|
17229
|
-
*
|
|
17230
|
-
* @param resourceUri - Full resource URI
|
|
17231
|
-
* @param options - Options including Accept header for content negotiation
|
|
17232
|
-
* @returns Object with data (ArrayBuffer) and contentType (string)
|
|
17233
|
-
*
|
|
17234
|
-
* @example
|
|
17235
|
-
* ```typescript
|
|
17236
|
-
* // Get markdown representation
|
|
17237
|
-
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown' });
|
|
17238
|
-
* const markdown = new TextDecoder().decode(data);
|
|
17239
|
-
*
|
|
17240
|
-
* // Get image representation
|
|
17241
|
-
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png' });
|
|
17242
|
-
* const blob = new Blob([data], { type: contentType });
|
|
17243
|
-
*
|
|
17244
|
-
* // Get PDF representation
|
|
17245
|
-
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf' });
|
|
17246
|
-
* ```
|
|
17247
|
-
*/
|
|
17248
|
-
async getResourceRepresentation(resourceUri2, options) {
|
|
17249
|
-
const response = await this.http.get(resourceUri2, {
|
|
17250
|
-
headers: {
|
|
17251
|
-
Accept: options?.accept || "text/plain"
|
|
17252
|
-
}
|
|
17253
|
-
});
|
|
17254
|
-
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
17255
|
-
const data = await response.arrayBuffer();
|
|
17256
|
-
return { data, contentType };
|
|
17257
|
-
}
|
|
17258
|
-
/**
|
|
17259
|
-
* Get resource representation as a stream using W3C content negotiation
|
|
17260
|
-
* Returns streaming binary content (for large files: videos, large PDFs, etc.)
|
|
17261
|
-
*
|
|
17262
|
-
* Use this for large files to avoid loading entire content into memory.
|
|
17263
|
-
* The stream is consumed incrementally and the backend connection stays open
|
|
17264
|
-
* until the stream is fully consumed or closed.
|
|
17265
|
-
*
|
|
17266
|
-
* @param resourceUri - Full resource URI
|
|
17267
|
-
* @param options - Options including Accept header for content negotiation
|
|
17268
|
-
* @returns Object with stream (ReadableStream) and contentType (string)
|
|
17269
|
-
*
|
|
17270
|
-
* @example
|
|
17271
|
-
* ```typescript
|
|
17272
|
-
* // Stream large file
|
|
17273
|
-
* const { stream, contentType } = await client.getResourceRepresentationStream(rUri, {
|
|
17274
|
-
* accept: 'video/mp4'
|
|
17275
|
-
* });
|
|
17276
|
-
*
|
|
17277
|
-
* // Consume stream chunk by chunk (never loads entire file into memory)
|
|
17278
|
-
* for await (const chunk of stream) {
|
|
17279
|
-
* // Process chunk
|
|
17280
|
-
* console.log(`Received ${chunk.length} bytes`);
|
|
17281
|
-
* }
|
|
17282
|
-
*
|
|
17283
|
-
* // Or pipe to a file in Node.js
|
|
17284
|
-
* const fileStream = fs.createWriteStream('output.mp4');
|
|
17285
|
-
* const reader = stream.getReader();
|
|
17286
|
-
* while (true) {
|
|
17287
|
-
* const { done, value } = await reader.read();
|
|
17288
|
-
* if (done) break;
|
|
17289
|
-
* fileStream.write(value);
|
|
17290
|
-
* }
|
|
17291
|
-
* ```
|
|
17292
|
-
*/
|
|
17293
|
-
async getResourceRepresentationStream(resourceUri2, options) {
|
|
17294
|
-
const response = await this.http.get(resourceUri2, {
|
|
17295
|
-
headers: {
|
|
17296
|
-
Accept: options?.accept || "text/plain"
|
|
17297
|
-
}
|
|
17298
|
-
});
|
|
17299
|
-
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
17300
|
-
if (!response.body) {
|
|
17301
|
-
throw new Error("Response body is null - cannot create stream");
|
|
17302
|
-
}
|
|
17303
|
-
return { stream: response.body, contentType };
|
|
17304
|
-
}
|
|
17305
|
-
async listResources(limit2, archived, query) {
|
|
17306
|
-
const searchParams = new URLSearchParams();
|
|
17307
|
-
if (limit2) searchParams.append("limit", limit2.toString());
|
|
17308
|
-
if (archived !== void 0) searchParams.append("archived", archived.toString());
|
|
17309
|
-
if (query) searchParams.append("q", query);
|
|
17310
|
-
return this.http.get(`${this.baseUrl}/resources`, { searchParams }).json();
|
|
17311
|
-
}
|
|
17312
|
-
async updateResource(resourceUri2, data) {
|
|
17313
|
-
return this.http.patch(resourceUri2, { json: data }).json();
|
|
17314
|
-
}
|
|
17315
|
-
async getResourceEvents(resourceUri2) {
|
|
17316
|
-
return this.http.get(`${resourceUri2}/events`).json();
|
|
17317
|
-
}
|
|
17318
|
-
async getResourceAnnotations(resourceUri2) {
|
|
17319
|
-
return this.http.get(`${resourceUri2}/annotations`).json();
|
|
17320
|
-
}
|
|
17321
|
-
async getAnnotationLLMContext(resourceUri2, annotationId, options) {
|
|
17322
|
-
const searchParams = new URLSearchParams();
|
|
17323
|
-
if (options?.contextWindow) {
|
|
17324
|
-
searchParams.append("contextWindow", options.contextWindow.toString());
|
|
17325
|
-
}
|
|
17326
|
-
return this.http.get(
|
|
17327
|
-
`${resourceUri2}/annotations/${annotationId}/llm-context`,
|
|
17328
|
-
{ searchParams }
|
|
17329
|
-
).json();
|
|
17330
|
-
}
|
|
17331
|
-
async getResourceReferencedBy(resourceUri2) {
|
|
17332
|
-
return this.http.get(`${resourceUri2}/referenced-by`).json();
|
|
17333
|
-
}
|
|
17334
|
-
async generateCloneToken(resourceUri2) {
|
|
17335
|
-
return this.http.post(`${resourceUri2}/clone-with-token`).json();
|
|
17336
|
-
}
|
|
17337
|
-
async getResourceByToken(token) {
|
|
17338
|
-
return this.http.get(`${this.baseUrl}/api/resources/token/${token}`).json();
|
|
17339
|
-
}
|
|
17340
|
-
async createResourceFromToken(data) {
|
|
17341
|
-
return this.http.post(`${this.baseUrl}/api/resources/create-from-token`, { json: data }).json();
|
|
17342
|
-
}
|
|
17343
|
-
// ============================================================================
|
|
17344
|
-
// ANNOTATIONS
|
|
17345
|
-
// ============================================================================
|
|
17346
|
-
async createAnnotation(resourceUri2, data) {
|
|
17347
|
-
return this.http.post(`${resourceUri2}/annotations`, { json: data }).json();
|
|
17348
|
-
}
|
|
17349
|
-
async getAnnotation(annotationUri2) {
|
|
17350
|
-
return this.http.get(annotationUri2).json();
|
|
17351
|
-
}
|
|
17352
|
-
async getResourceAnnotation(annotationUri2) {
|
|
17353
|
-
return this.http.get(annotationUri2).json();
|
|
17354
|
-
}
|
|
17355
|
-
async listAnnotations(resourceUri2, motivation) {
|
|
17356
|
-
const searchParams = new URLSearchParams();
|
|
17357
|
-
if (motivation) searchParams.append("motivation", motivation);
|
|
17358
|
-
return this.http.get(`${resourceUri2}/annotations`, { searchParams }).json();
|
|
17359
|
-
}
|
|
17360
|
-
async deleteAnnotation(annotationUri2) {
|
|
17361
|
-
await this.http.delete(annotationUri2);
|
|
17362
|
-
}
|
|
17363
|
-
async updateAnnotationBody(annotationUri2, data) {
|
|
17364
|
-
return this.http.put(`${annotationUri2}/body`, {
|
|
17365
|
-
json: data
|
|
17366
|
-
}).json();
|
|
17367
|
-
}
|
|
17368
|
-
async getAnnotationHistory(annotationUri2) {
|
|
17369
|
-
return this.http.get(`${annotationUri2}/history`).json();
|
|
17370
|
-
}
|
|
17371
|
-
// ============================================================================
|
|
17372
|
-
// ENTITY TYPES
|
|
17373
|
-
// ============================================================================
|
|
17374
|
-
async addEntityType(type2) {
|
|
17375
|
-
return this.http.post(`${this.baseUrl}/api/entity-types`, { json: { type: type2 } }).json();
|
|
17376
|
-
}
|
|
17377
|
-
async addEntityTypesBulk(types) {
|
|
17378
|
-
return this.http.post(`${this.baseUrl}/api/entity-types/bulk`, { json: { tags: types } }).json();
|
|
17379
|
-
}
|
|
17380
|
-
async listEntityTypes() {
|
|
17381
|
-
return this.http.get(`${this.baseUrl}/api/entity-types`).json();
|
|
17382
|
-
}
|
|
17383
|
-
// ============================================================================
|
|
17384
|
-
// ADMIN
|
|
17385
|
-
// ============================================================================
|
|
17386
|
-
async listUsers() {
|
|
17387
|
-
return this.http.get(`${this.baseUrl}/api/admin/users`).json();
|
|
17388
|
-
}
|
|
17389
|
-
async getUserStats() {
|
|
17390
|
-
return this.http.get(`${this.baseUrl}/api/admin/users/stats`).json();
|
|
17391
|
-
}
|
|
17392
|
-
/**
|
|
17393
|
-
* Update a user by ID
|
|
17394
|
-
* Note: Users use DID identifiers (did:web:domain:users:id), not HTTP URIs.
|
|
17395
|
-
*/
|
|
17396
|
-
async updateUser(id, data) {
|
|
17397
|
-
return this.http.patch(`${this.baseUrl}/api/admin/users/${id}`, { json: data }).json();
|
|
17398
|
-
}
|
|
17399
|
-
async getOAuthConfig() {
|
|
17400
|
-
return this.http.get(`${this.baseUrl}/api/admin/oauth/config`).json();
|
|
17401
|
-
}
|
|
17402
|
-
// ============================================================================
|
|
17403
|
-
// JOB STATUS
|
|
17404
|
-
// ============================================================================
|
|
17405
|
-
async getJobStatus(id) {
|
|
17406
|
-
return this.http.get(`${this.baseUrl}/api/jobs/${id}`).json();
|
|
17407
|
-
}
|
|
17408
|
-
/**
|
|
17409
|
-
* Poll a job until it completes or fails
|
|
17410
|
-
* @param id - The job ID to poll
|
|
17411
|
-
* @param options - Polling options
|
|
17412
|
-
* @returns The final job status
|
|
17413
|
-
*/
|
|
17414
|
-
async pollJobUntilComplete(id, options) {
|
|
17415
|
-
const interval = options?.interval ?? 1e3;
|
|
17416
|
-
const timeout2 = options?.timeout ?? 6e4;
|
|
17417
|
-
const startTime = Date.now();
|
|
17418
|
-
while (true) {
|
|
17419
|
-
const status = await this.getJobStatus(id);
|
|
17420
|
-
if (options?.onProgress) {
|
|
17421
|
-
options.onProgress(status);
|
|
17422
|
-
}
|
|
17423
|
-
if (status.status === "complete" || status.status === "failed" || status.status === "cancelled") {
|
|
17424
|
-
return status;
|
|
17425
|
-
}
|
|
17426
|
-
if (Date.now() - startTime > timeout2) {
|
|
17427
|
-
throw new Error(`Job polling timeout after ${timeout2}ms`);
|
|
17428
|
-
}
|
|
17429
|
-
await new Promise((resolve2) => setTimeout(resolve2, interval));
|
|
17430
|
-
}
|
|
17431
|
-
}
|
|
17432
|
-
// ============================================================================
|
|
17433
|
-
// LLM CONTEXT
|
|
17434
|
-
// ============================================================================
|
|
17435
|
-
async getResourceLLMContext(resourceUri2, options) {
|
|
17436
|
-
const searchParams = new URLSearchParams();
|
|
17437
|
-
if (options?.depth !== void 0) searchParams.append("depth", options.depth.toString());
|
|
17438
|
-
if (options?.maxResources !== void 0) searchParams.append("maxResources", options.maxResources.toString());
|
|
17439
|
-
if (options?.includeContent !== void 0) searchParams.append("includeContent", options.includeContent.toString());
|
|
17440
|
-
if (options?.includeSummary !== void 0) searchParams.append("includeSummary", options.includeSummary.toString());
|
|
17441
|
-
return this.http.get(`${resourceUri2}/llm-context`, { searchParams }).json();
|
|
17442
|
-
}
|
|
17443
|
-
// ============================================================================
|
|
17444
|
-
// SYSTEM STATUS
|
|
17445
|
-
// ============================================================================
|
|
17446
|
-
async healthCheck() {
|
|
17447
|
-
return this.http.get(`${this.baseUrl}/api/health`).json();
|
|
17448
|
-
}
|
|
17449
|
-
async getStatus() {
|
|
17450
|
-
return this.http.get(`${this.baseUrl}/api/status`).json();
|
|
17451
|
-
}
|
|
17452
|
-
};
|
|
17453
|
-
LOCALES = [
|
|
17454
|
-
{ code: "ar", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629", englishName: "Arabic" },
|
|
17455
|
-
{ code: "bn", nativeName: "\u09AC\u09BE\u0982\u09B2\u09BE", englishName: "Bengali" },
|
|
17456
|
-
{ code: "cs", nativeName: "\u010Ce\u0161tina", englishName: "Czech" },
|
|
17457
|
-
{ code: "da", nativeName: "Dansk", englishName: "Danish" },
|
|
17458
|
-
{ code: "de", nativeName: "Deutsch", englishName: "German" },
|
|
17459
|
-
{ code: "el", nativeName: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC", englishName: "Greek" },
|
|
17460
|
-
{ code: "en", nativeName: "English", englishName: "English" },
|
|
17461
|
-
{ code: "es", nativeName: "Espa\xF1ol", englishName: "Spanish" },
|
|
17462
|
-
{ code: "fa", nativeName: "\u0641\u0627\u0631\u0633\u06CC", englishName: "Persian" },
|
|
17463
|
-
{ code: "fi", nativeName: "Suomi", englishName: "Finnish" },
|
|
17464
|
-
{ code: "fr", nativeName: "Fran\xE7ais", englishName: "French" },
|
|
17465
|
-
{ code: "he", nativeName: "\u05E2\u05D1\u05E8\u05D9\u05EA", englishName: "Hebrew" },
|
|
17466
|
-
{ code: "hi", nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940", englishName: "Hindi" },
|
|
17467
|
-
{ code: "id", nativeName: "Bahasa Indonesia", englishName: "Indonesian" },
|
|
17468
|
-
{ code: "it", nativeName: "Italiano", englishName: "Italian" },
|
|
17469
|
-
{ code: "ja", nativeName: "\u65E5\u672C\u8A9E", englishName: "Japanese" },
|
|
17470
|
-
{ code: "ko", nativeName: "\uD55C\uAD6D\uC5B4", englishName: "Korean" },
|
|
17471
|
-
{ code: "ms", nativeName: "Bahasa Melayu", englishName: "Malay" },
|
|
17472
|
-
{ code: "nl", nativeName: "Nederlands", englishName: "Dutch" },
|
|
17473
|
-
{ code: "no", nativeName: "Norsk", englishName: "Norwegian" },
|
|
17474
|
-
{ code: "pl", nativeName: "Polski", englishName: "Polish" },
|
|
17475
|
-
{ code: "pt", nativeName: "Portugu\xEAs", englishName: "Portuguese" },
|
|
17476
|
-
{ code: "ro", nativeName: "Rom\xE2n\u0103", englishName: "Romanian" },
|
|
17477
|
-
{ code: "sv", nativeName: "Svenska", englishName: "Swedish" },
|
|
17478
|
-
{ code: "th", nativeName: "\u0E44\u0E17\u0E22", englishName: "Thai" },
|
|
17479
|
-
{ code: "tr", nativeName: "T\xFCrk\xE7e", englishName: "Turkish" },
|
|
17480
|
-
{ code: "uk", nativeName: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430", englishName: "Ukrainian" },
|
|
17481
|
-
{ code: "vi", nativeName: "Ti\u1EBFng Vi\u1EC7t", englishName: "Vietnamese" },
|
|
17482
|
-
{ code: "zh", nativeName: "\u4E2D\u6587", englishName: "Chinese" }
|
|
17483
|
-
];
|
|
17484
|
-
localeByCode = new Map(
|
|
17485
|
-
LOCALES.map((locale) => [locale.code.toLowerCase(), locale])
|
|
17486
|
-
);
|
|
17487
|
-
}
|
|
17488
|
-
});
|
|
17489
|
-
|
|
17490
15768
|
// src/platforms/posix/handlers/backend-check.ts
|
|
17491
15769
|
import * as fs9 from "fs";
|
|
15770
|
+
import { SemiontApiClient, baseUrl } from "@semiont/api-client";
|
|
17492
15771
|
var checkBackendService, backendCheckDescriptor;
|
|
17493
15772
|
var init_backend_check = __esm({
|
|
17494
15773
|
"src/platforms/posix/handlers/backend-check.ts"() {
|
|
@@ -17496,7 +15775,6 @@ var init_backend_check = __esm({
|
|
|
17496
15775
|
init_network_utils();
|
|
17497
15776
|
init_state_manager();
|
|
17498
15777
|
init_backend_paths();
|
|
17499
|
-
init_dist();
|
|
17500
15778
|
checkBackendService = async (context) => {
|
|
17501
15779
|
const { service, savedState } = context;
|
|
17502
15780
|
const config2 = service.config;
|
|
@@ -19962,10 +18240,10 @@ async function stopJanusGraph(context) {
|
|
|
19962
18240
|
printInfo(`Stopping JanusGraph gracefully (PID: ${pid})...`);
|
|
19963
18241
|
}
|
|
19964
18242
|
process.kill(pid, "SIGTERM");
|
|
19965
|
-
const
|
|
18243
|
+
const timeout = options.timeout * 1e3;
|
|
19966
18244
|
const startTime = Date.now();
|
|
19967
18245
|
let processRunning = true;
|
|
19968
|
-
while (processRunning && Date.now() - startTime <
|
|
18246
|
+
while (processRunning && Date.now() - startTime < timeout) {
|
|
19969
18247
|
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
19970
18248
|
try {
|
|
19971
18249
|
process.kill(pid, 0);
|
|
@@ -20978,11 +19256,11 @@ var init_platform2 = __esm({
|
|
|
20978
19256
|
|
|
20979
19257
|
// src/platforms/container/handlers/web-check.ts
|
|
20980
19258
|
import { execSync as execSync16 } from "child_process";
|
|
19259
|
+
import { SemiontApiClient as SemiontApiClient2, baseUrl as baseUrl2 } from "@semiont/api-client";
|
|
20981
19260
|
var checkWebContainer, webCheckDescriptor;
|
|
20982
19261
|
var init_web_check = __esm({
|
|
20983
19262
|
"src/platforms/container/handlers/web-check.ts"() {
|
|
20984
19263
|
"use strict";
|
|
20985
|
-
init_dist();
|
|
20986
19264
|
checkWebContainer = async (context) => {
|
|
20987
19265
|
const { platform, service, runtime, containerName } = context;
|
|
20988
19266
|
const config2 = service.config;
|
|
@@ -21029,7 +19307,7 @@ var init_web_check = __esm({
|
|
|
21029
19307
|
try {
|
|
21030
19308
|
if (isBackend) {
|
|
21031
19309
|
const backendConfig = config2;
|
|
21032
|
-
const client = new
|
|
19310
|
+
const client = new SemiontApiClient2({ baseUrl: baseUrl2(backendConfig.publicURL) });
|
|
21033
19311
|
try {
|
|
21034
19312
|
const healthData = await client.healthCheck();
|
|
21035
19313
|
health = {
|
|
@@ -22138,7 +20416,7 @@ var init_database_provision = __esm({
|
|
|
22138
20416
|
function isNothing(subject) {
|
|
22139
20417
|
return typeof subject === "undefined" || subject === null;
|
|
22140
20418
|
}
|
|
22141
|
-
function
|
|
20419
|
+
function isObject2(subject) {
|
|
22142
20420
|
return typeof subject === "object" && subject !== null;
|
|
22143
20421
|
}
|
|
22144
20422
|
function toArray(sequence) {
|
|
@@ -24320,7 +22598,7 @@ var isNothing_1, isObject_1, toArray_1, repeat_1, isNegativeZero_1, extend_1, co
|
|
|
24320
22598
|
var init_js_yaml = __esm({
|
|
24321
22599
|
"node_modules/js-yaml/dist/js-yaml.mjs"() {
|
|
24322
22600
|
isNothing_1 = isNothing;
|
|
24323
|
-
isObject_1 =
|
|
22601
|
+
isObject_1 = isObject2;
|
|
24324
22602
|
toArray_1 = toArray;
|
|
24325
22603
|
repeat_1 = repeat;
|
|
24326
22604
|
isNegativeZero_1 = isNegativeZero;
|
|
@@ -25081,7 +23359,7 @@ var init_database_stop = __esm({
|
|
|
25081
23359
|
init_cli_logger();
|
|
25082
23360
|
stopDatabaseContainer = async (context) => {
|
|
25083
23361
|
const { service, runtime, containerName } = context;
|
|
25084
|
-
const { force, timeout
|
|
23362
|
+
const { force, timeout = 30 } = context.options;
|
|
25085
23363
|
if (!service.quiet) {
|
|
25086
23364
|
printInfo(`Stopping database container: ${containerName}`);
|
|
25087
23365
|
}
|
|
@@ -25118,29 +23396,29 @@ var init_database_stop = __esm({
|
|
|
25118
23396
|
execSync25(`${runtime} kill ${containerName}`, { stdio: "pipe" });
|
|
25119
23397
|
} else {
|
|
25120
23398
|
if (!service.quiet) {
|
|
25121
|
-
printInfo(`Gracefully stopping database (timeout: ${
|
|
23399
|
+
printInfo(`Gracefully stopping database (timeout: ${timeout}s)...`);
|
|
25122
23400
|
}
|
|
25123
23401
|
const image = service.getImage();
|
|
25124
23402
|
if (image.includes("postgres")) {
|
|
25125
23403
|
try {
|
|
25126
23404
|
execSync25(
|
|
25127
|
-
`${runtime} exec ${containerName} su -c "pg_ctl stop -D /var/lib/postgresql/data -m smart -t ${
|
|
25128
|
-
{ stdio: "pipe", timeout: (
|
|
23405
|
+
`${runtime} exec ${containerName} su -c "pg_ctl stop -D /var/lib/postgresql/data -m smart -t ${timeout}" postgres`,
|
|
23406
|
+
{ stdio: "pipe", timeout: (timeout + 5) * 1e3 }
|
|
25129
23407
|
);
|
|
25130
23408
|
} catch {
|
|
25131
|
-
execSync25(`${runtime} stop -t ${
|
|
23409
|
+
execSync25(`${runtime} stop -t ${timeout} ${containerName}`, { stdio: "pipe" });
|
|
25132
23410
|
}
|
|
25133
23411
|
} else if (image.includes("mysql")) {
|
|
25134
23412
|
try {
|
|
25135
23413
|
execSync25(
|
|
25136
23414
|
`${runtime} exec ${containerName} mysqladmin shutdown`,
|
|
25137
|
-
{ stdio: "pipe", timeout:
|
|
23415
|
+
{ stdio: "pipe", timeout: timeout * 1e3 }
|
|
25138
23416
|
);
|
|
25139
23417
|
} catch {
|
|
25140
|
-
execSync25(`${runtime} stop -t ${
|
|
23418
|
+
execSync25(`${runtime} stop -t ${timeout} ${containerName}`, { stdio: "pipe" });
|
|
25141
23419
|
}
|
|
25142
23420
|
} else {
|
|
25143
|
-
execSync25(`${runtime} stop -t ${
|
|
23421
|
+
execSync25(`${runtime} stop -t ${timeout} ${containerName}`, { stdio: "pipe" });
|
|
25144
23422
|
}
|
|
25145
23423
|
}
|
|
25146
23424
|
let stopped = false;
|
|
@@ -26861,12 +25139,12 @@ async function fetchTaskLogs(clusterName, taskArn, region, verbose = false) {
|
|
|
26861
25139
|
return [];
|
|
26862
25140
|
}
|
|
26863
25141
|
}
|
|
26864
|
-
async function waitForECSDeployment(clusterName, serviceName, deploymentId, region,
|
|
25142
|
+
async function waitForECSDeployment(clusterName, serviceName, deploymentId, region, timeout, verbose = false) {
|
|
26865
25143
|
const startTime = Date.now();
|
|
26866
25144
|
const checkInterval = 5e3;
|
|
26867
25145
|
let imagePullDetected = false;
|
|
26868
25146
|
let lastEventCount = 0;
|
|
26869
|
-
let effectiveTimeout =
|
|
25147
|
+
let effectiveTimeout = timeout;
|
|
26870
25148
|
let recentStoppedTasks = /* @__PURE__ */ new Set();
|
|
26871
25149
|
let consecutiveFailures = 0;
|
|
26872
25150
|
let taskDetails = { new: { total: 0, running: 0, healthy: 0, pending: 0 }, old: { total: 0, running: 0, healthy: 0, pending: 0 } };
|
|
@@ -26894,7 +25172,7 @@ async function waitForECSDeployment(clusterName, serviceName, deploymentId, regi
|
|
|
26894
25172
|
);
|
|
26895
25173
|
if (pullEvents.length > 0 && !imagePullDetected) {
|
|
26896
25174
|
imagePullDetected = true;
|
|
26897
|
-
effectiveTimeout =
|
|
25175
|
+
effectiveTimeout = timeout + 300;
|
|
26898
25176
|
if (!verbose) {
|
|
26899
25177
|
process.stdout.write("\n");
|
|
26900
25178
|
}
|
|
@@ -27247,11 +25525,11 @@ var init_ecs_update = __esm({
|
|
|
27247
25525
|
const newDeployment = deployments.find((d) => d.status === "PRIMARY");
|
|
27248
25526
|
const deploymentId = newDeployment?.id;
|
|
27249
25527
|
if (service.config?.wait && deploymentId) {
|
|
27250
|
-
const
|
|
25528
|
+
const timeout = service.config.timeout || 300;
|
|
27251
25529
|
if (!service.quiet) {
|
|
27252
|
-
printInfo(`Waiting for deployment to complete (timeout: ${
|
|
25530
|
+
printInfo(`Waiting for deployment to complete (timeout: ${timeout}s)...`);
|
|
27253
25531
|
}
|
|
27254
|
-
await waitForECSDeployment(clusterName, serviceName, deploymentId, region,
|
|
25532
|
+
await waitForECSDeployment(clusterName, serviceName, deploymentId, region, timeout, service.verbose);
|
|
27255
25533
|
}
|
|
27256
25534
|
return {
|
|
27257
25535
|
success: true,
|
|
@@ -28297,13 +26575,13 @@ var init_errors3 = __esm({
|
|
|
28297
26575
|
});
|
|
28298
26576
|
|
|
28299
26577
|
// ../../node_modules/@anthropic-ai/sdk/core/error.mjs
|
|
28300
|
-
var AnthropicError,
|
|
26578
|
+
var AnthropicError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError;
|
|
28301
26579
|
var init_error = __esm({
|
|
28302
26580
|
"../../node_modules/@anthropic-ai/sdk/core/error.mjs"() {
|
|
28303
26581
|
init_errors3();
|
|
28304
26582
|
AnthropicError = class extends Error {
|
|
28305
26583
|
};
|
|
28306
|
-
|
|
26584
|
+
APIError = class _APIError extends AnthropicError {
|
|
28307
26585
|
constructor(status, error46, message, headers) {
|
|
28308
26586
|
super(`${_APIError.makeMessage(status, error46, message)}`);
|
|
28309
26587
|
this.status = status;
|
|
@@ -28356,12 +26634,12 @@ var init_error = __esm({
|
|
|
28356
26634
|
return new _APIError(status, error46, message, headers);
|
|
28357
26635
|
}
|
|
28358
26636
|
};
|
|
28359
|
-
APIUserAbortError = class extends
|
|
26637
|
+
APIUserAbortError = class extends APIError {
|
|
28360
26638
|
constructor({ message } = {}) {
|
|
28361
26639
|
super(void 0, void 0, message || "Request was aborted.", void 0);
|
|
28362
26640
|
}
|
|
28363
26641
|
};
|
|
28364
|
-
APIConnectionError = class extends
|
|
26642
|
+
APIConnectionError = class extends APIError {
|
|
28365
26643
|
constructor({ message, cause }) {
|
|
28366
26644
|
super(void 0, void 0, message || "Connection error.", void 0);
|
|
28367
26645
|
if (cause)
|
|
@@ -28373,21 +26651,21 @@ var init_error = __esm({
|
|
|
28373
26651
|
super({ message: message ?? "Request timed out." });
|
|
28374
26652
|
}
|
|
28375
26653
|
};
|
|
28376
|
-
BadRequestError = class extends
|
|
26654
|
+
BadRequestError = class extends APIError {
|
|
28377
26655
|
};
|
|
28378
|
-
AuthenticationError = class extends
|
|
26656
|
+
AuthenticationError = class extends APIError {
|
|
28379
26657
|
};
|
|
28380
|
-
PermissionDeniedError = class extends
|
|
26658
|
+
PermissionDeniedError = class extends APIError {
|
|
28381
26659
|
};
|
|
28382
|
-
NotFoundError = class extends
|
|
26660
|
+
NotFoundError = class extends APIError {
|
|
28383
26661
|
};
|
|
28384
|
-
ConflictError = class extends
|
|
26662
|
+
ConflictError = class extends APIError {
|
|
28385
26663
|
};
|
|
28386
|
-
UnprocessableEntityError = class extends
|
|
26664
|
+
UnprocessableEntityError = class extends APIError {
|
|
28387
26665
|
};
|
|
28388
|
-
RateLimitError = class extends
|
|
26666
|
+
RateLimitError = class extends APIError {
|
|
28389
26667
|
};
|
|
28390
|
-
InternalServerError = class extends
|
|
26668
|
+
InternalServerError = class extends APIError {
|
|
28391
26669
|
};
|
|
28392
26670
|
}
|
|
28393
26671
|
});
|
|
@@ -28979,7 +27257,7 @@ var init_streaming = __esm({
|
|
|
28979
27257
|
continue;
|
|
28980
27258
|
}
|
|
28981
27259
|
if (sse.event === "error") {
|
|
28982
|
-
throw new
|
|
27260
|
+
throw new APIError(void 0, safeJSON(sse.data) ?? sse.data, void 0, response.headers);
|
|
28983
27261
|
}
|
|
28984
27262
|
}
|
|
28985
27263
|
done = true;
|
|
@@ -29376,7 +27654,7 @@ function makeFile(fileBits, fileName, options) {
|
|
|
29376
27654
|
function getName(value) {
|
|
29377
27655
|
return (typeof value === "object" && value !== null && ("name" in value && value.name && String(value.name) || "url" in value && value.url && String(value.url) || "filename" in value && value.filename && String(value.filename) || "path" in value && value.path && String(value.path)) || "").split(/[\\/]/).pop() || void 0;
|
|
29378
27656
|
}
|
|
29379
|
-
function
|
|
27657
|
+
function supportsFormData(fetchObject) {
|
|
29380
27658
|
const fetch2 = typeof fetchObject === "function" ? fetchObject : fetchObject.fetch;
|
|
29381
27659
|
const cached2 = supportsFormDataMap.get(fetch2);
|
|
29382
27660
|
if (cached2)
|
|
@@ -29413,7 +27691,7 @@ var init_uploads = __esm({
|
|
|
29413
27691
|
};
|
|
29414
27692
|
supportsFormDataMap = /* @__PURE__ */ new WeakMap();
|
|
29415
27693
|
createForm = async (body, fetch2) => {
|
|
29416
|
-
if (!await
|
|
27694
|
+
if (!await supportsFormData(fetch2)) {
|
|
29417
27695
|
throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
|
|
29418
27696
|
}
|
|
29419
27697
|
const form = new FormData();
|
|
@@ -30912,7 +29190,7 @@ var init_BetaMessageStream = __esm({
|
|
|
30912
29190
|
|
|
30913
29191
|
// ../../node_modules/@anthropic-ai/sdk/internal/constants.mjs
|
|
30914
29192
|
var MODEL_NONSTREAMING_TOKENS;
|
|
30915
|
-
var
|
|
29193
|
+
var init_constants = __esm({
|
|
30916
29194
|
"../../node_modules/@anthropic-ai/sdk/internal/constants.mjs"() {
|
|
30917
29195
|
MODEL_NONSTREAMING_TOKENS = {
|
|
30918
29196
|
"claude-opus-4-20250514": 8192,
|
|
@@ -31195,7 +29473,7 @@ var init_messages = __esm({
|
|
|
31195
29473
|
init_batches();
|
|
31196
29474
|
init_headers();
|
|
31197
29475
|
init_BetaMessageStream();
|
|
31198
|
-
|
|
29476
|
+
init_constants();
|
|
31199
29477
|
init_BetaToolRunner();
|
|
31200
29478
|
init_BetaToolRunner();
|
|
31201
29479
|
DEPRECATED_MODELS = {
|
|
@@ -31222,14 +29500,14 @@ var init_messages = __esm({
|
|
|
31222
29500
|
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}
|
|
31223
29501
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
31224
29502
|
}
|
|
31225
|
-
let
|
|
31226
|
-
if (!body.stream &&
|
|
29503
|
+
let timeout = this._client._options.timeout;
|
|
29504
|
+
if (!body.stream && timeout == null) {
|
|
31227
29505
|
const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? void 0;
|
|
31228
|
-
|
|
29506
|
+
timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
|
|
31229
29507
|
}
|
|
31230
29508
|
return this._client.post("/v1/messages?beta=true", {
|
|
31231
29509
|
body,
|
|
31232
|
-
timeout:
|
|
29510
|
+
timeout: timeout ?? 6e5,
|
|
31233
29511
|
...options,
|
|
31234
29512
|
headers: buildHeaders([
|
|
31235
29513
|
{ ...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : void 0 },
|
|
@@ -32060,7 +30338,7 @@ var init_messages2 = __esm({
|
|
|
32060
30338
|
init_MessageStream();
|
|
32061
30339
|
init_batches2();
|
|
32062
30340
|
init_batches2();
|
|
32063
|
-
|
|
30341
|
+
init_constants();
|
|
32064
30342
|
Messages2 = class extends APIResource {
|
|
32065
30343
|
constructor() {
|
|
32066
30344
|
super(...arguments);
|
|
@@ -32071,14 +30349,14 @@ var init_messages2 = __esm({
|
|
|
32071
30349
|
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS2[body.model]}
|
|
32072
30350
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
32073
30351
|
}
|
|
32074
|
-
let
|
|
32075
|
-
if (!body.stream &&
|
|
30352
|
+
let timeout = this._client._options.timeout;
|
|
30353
|
+
if (!body.stream && timeout == null) {
|
|
32076
30354
|
const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? void 0;
|
|
32077
|
-
|
|
30355
|
+
timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
|
|
32078
30356
|
}
|
|
32079
30357
|
return this._client.post("/v1/messages", {
|
|
32080
30358
|
body,
|
|
32081
|
-
timeout:
|
|
30359
|
+
timeout: timeout ?? 6e5,
|
|
32082
30360
|
...options,
|
|
32083
30361
|
stream: body.stream ?? false
|
|
32084
30362
|
});
|
|
@@ -32344,7 +30622,7 @@ var init_client = __esm({
|
|
|
32344
30622
|
return `stainless-node-retry-${uuid42()}`;
|
|
32345
30623
|
}
|
|
32346
30624
|
makeStatusError(status, error46, message, headers) {
|
|
32347
|
-
return
|
|
30625
|
+
return APIError.generate(status, error46, message, headers);
|
|
32348
30626
|
}
|
|
32349
30627
|
buildURL(path34, query, defaultBaseURL) {
|
|
32350
30628
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
@@ -32409,7 +30687,7 @@ var init_client = __esm({
|
|
|
32409
30687
|
retriesRemaining = maxRetries;
|
|
32410
30688
|
}
|
|
32411
30689
|
await this.prepareOptions(options);
|
|
32412
|
-
const { req, url: url2, timeout
|
|
30690
|
+
const { req, url: url2, timeout } = await this.buildRequest(options, {
|
|
32413
30691
|
retryCount: maxRetries - retriesRemaining
|
|
32414
30692
|
});
|
|
32415
30693
|
await this.prepareRequest(req, { url: url2, options });
|
|
@@ -32427,7 +30705,7 @@ var init_client = __esm({
|
|
|
32427
30705
|
throw new APIUserAbortError();
|
|
32428
30706
|
}
|
|
32429
30707
|
const controller = new AbortController();
|
|
32430
|
-
const response = await this.fetchWithTimeout(url2, req,
|
|
30708
|
+
const response = await this.fetchWithTimeout(url2, req, timeout, controller).catch(castToError);
|
|
32431
30709
|
const headersTime = Date.now();
|
|
32432
30710
|
if (response instanceof globalThis.Error) {
|
|
32433
30711
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
@@ -32511,7 +30789,7 @@ var init_client = __esm({
|
|
|
32511
30789
|
const { signal, method, ...options } = init2 || {};
|
|
32512
30790
|
if (signal)
|
|
32513
30791
|
signal.addEventListener("abort", () => controller.abort());
|
|
32514
|
-
const
|
|
30792
|
+
const timeout = setTimeout(() => controller.abort(), ms);
|
|
32515
30793
|
const isReadableBody = globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream || typeof options.body === "object" && options.body !== null && Symbol.asyncIterator in options.body;
|
|
32516
30794
|
const fetchOptions = {
|
|
32517
30795
|
signal: controller.signal,
|
|
@@ -32525,7 +30803,7 @@ var init_client = __esm({
|
|
|
32525
30803
|
try {
|
|
32526
30804
|
return await this.fetch.call(void 0, url2, fetchOptions);
|
|
32527
30805
|
} finally {
|
|
32528
|
-
clearTimeout(
|
|
30806
|
+
clearTimeout(timeout);
|
|
32529
30807
|
}
|
|
32530
30808
|
}
|
|
32531
30809
|
async shouldRetry(response) {
|
|
@@ -32662,7 +30940,7 @@ var init_client = __esm({
|
|
|
32662
30940
|
BaseAnthropic.AI_PROMPT = AI_PROMPT;
|
|
32663
30941
|
BaseAnthropic.DEFAULT_TIMEOUT = 6e5;
|
|
32664
30942
|
BaseAnthropic.AnthropicError = AnthropicError;
|
|
32665
|
-
BaseAnthropic.APIError =
|
|
30943
|
+
BaseAnthropic.APIError = APIError;
|
|
32666
30944
|
BaseAnthropic.APIConnectionError = APIConnectionError;
|
|
32667
30945
|
BaseAnthropic.APIConnectionTimeoutError = APIConnectionTimeoutError;
|
|
32668
30946
|
BaseAnthropic.APIUserAbortError = APIUserAbortError;
|
|
@@ -32779,13 +31057,13 @@ var init_errors4 = __esm({
|
|
|
32779
31057
|
});
|
|
32780
31058
|
|
|
32781
31059
|
// ../../node_modules/openai/core/error.mjs
|
|
32782
|
-
var OpenAIError,
|
|
31060
|
+
var OpenAIError, APIError2, APIUserAbortError2, APIConnectionError2, APIConnectionTimeoutError2, BadRequestError2, AuthenticationError2, PermissionDeniedError2, NotFoundError2, ConflictError2, UnprocessableEntityError2, RateLimitError2, InternalServerError2, LengthFinishReasonError, ContentFilterFinishReasonError, InvalidWebhookSignatureError;
|
|
32783
31061
|
var init_error3 = __esm({
|
|
32784
31062
|
"../../node_modules/openai/core/error.mjs"() {
|
|
32785
31063
|
init_errors4();
|
|
32786
31064
|
OpenAIError = class extends Error {
|
|
32787
31065
|
};
|
|
32788
|
-
|
|
31066
|
+
APIError2 = class _APIError extends OpenAIError {
|
|
32789
31067
|
constructor(status, error46, message, headers) {
|
|
32790
31068
|
super(`${_APIError.makeMessage(status, error46, message)}`);
|
|
32791
31069
|
this.status = status;
|
|
@@ -32842,12 +31120,12 @@ var init_error3 = __esm({
|
|
|
32842
31120
|
return new _APIError(status, error46, message, headers);
|
|
32843
31121
|
}
|
|
32844
31122
|
};
|
|
32845
|
-
APIUserAbortError2 = class extends
|
|
31123
|
+
APIUserAbortError2 = class extends APIError2 {
|
|
32846
31124
|
constructor({ message } = {}) {
|
|
32847
31125
|
super(void 0, void 0, message || "Request was aborted.", void 0);
|
|
32848
31126
|
}
|
|
32849
31127
|
};
|
|
32850
|
-
APIConnectionError2 = class extends
|
|
31128
|
+
APIConnectionError2 = class extends APIError2 {
|
|
32851
31129
|
constructor({ message, cause }) {
|
|
32852
31130
|
super(void 0, void 0, message || "Connection error.", void 0);
|
|
32853
31131
|
if (cause)
|
|
@@ -32859,21 +31137,21 @@ var init_error3 = __esm({
|
|
|
32859
31137
|
super({ message: message ?? "Request timed out." });
|
|
32860
31138
|
}
|
|
32861
31139
|
};
|
|
32862
|
-
BadRequestError2 = class extends
|
|
31140
|
+
BadRequestError2 = class extends APIError2 {
|
|
32863
31141
|
};
|
|
32864
|
-
AuthenticationError2 = class extends
|
|
31142
|
+
AuthenticationError2 = class extends APIError2 {
|
|
32865
31143
|
};
|
|
32866
|
-
PermissionDeniedError2 = class extends
|
|
31144
|
+
PermissionDeniedError2 = class extends APIError2 {
|
|
32867
31145
|
};
|
|
32868
|
-
NotFoundError2 = class extends
|
|
31146
|
+
NotFoundError2 = class extends APIError2 {
|
|
32869
31147
|
};
|
|
32870
|
-
ConflictError2 = class extends
|
|
31148
|
+
ConflictError2 = class extends APIError2 {
|
|
32871
31149
|
};
|
|
32872
|
-
UnprocessableEntityError2 = class extends
|
|
31150
|
+
UnprocessableEntityError2 = class extends APIError2 {
|
|
32873
31151
|
};
|
|
32874
|
-
RateLimitError2 = class extends
|
|
31152
|
+
RateLimitError2 = class extends APIError2 {
|
|
32875
31153
|
};
|
|
32876
|
-
InternalServerError2 = class extends
|
|
31154
|
+
InternalServerError2 = class extends APIError2 {
|
|
32877
31155
|
};
|
|
32878
31156
|
LengthFinishReasonError = class extends OpenAIError {
|
|
32879
31157
|
constructor() {
|
|
@@ -33869,7 +32147,7 @@ var init_streaming3 = __esm({
|
|
|
33869
32147
|
throw e;
|
|
33870
32148
|
}
|
|
33871
32149
|
if (data && data.error) {
|
|
33872
|
-
throw new
|
|
32150
|
+
throw new APIError2(void 0, data.error, void 0, response.headers);
|
|
33873
32151
|
}
|
|
33874
32152
|
yield data;
|
|
33875
32153
|
} else {
|
|
@@ -33882,7 +32160,7 @@ var init_streaming3 = __esm({
|
|
|
33882
32160
|
throw e;
|
|
33883
32161
|
}
|
|
33884
32162
|
if (sse.event == "error") {
|
|
33885
|
-
throw new
|
|
32163
|
+
throw new APIError2(void 0, data.error, data.message, void 0);
|
|
33886
32164
|
}
|
|
33887
32165
|
yield { event: sse.event, data };
|
|
33888
32166
|
}
|
|
@@ -34310,7 +32588,7 @@ function makeFile2(fileBits, fileName, options) {
|
|
|
34310
32588
|
function getName2(value) {
|
|
34311
32589
|
return (typeof value === "object" && value !== null && ("name" in value && value.name && String(value.name) || "url" in value && value.url && String(value.url) || "filename" in value && value.filename && String(value.filename) || "path" in value && value.path && String(value.path)) || "").split(/[\\/]/).pop() || void 0;
|
|
34312
32590
|
}
|
|
34313
|
-
function
|
|
32591
|
+
function supportsFormData2(fetchObject) {
|
|
34314
32592
|
const fetch2 = typeof fetchObject === "function" ? fetchObject : fetchObject.fetch;
|
|
34315
32593
|
const cached2 = supportsFormDataMap2.get(fetch2);
|
|
34316
32594
|
if (cached2)
|
|
@@ -34347,7 +32625,7 @@ var init_uploads3 = __esm({
|
|
|
34347
32625
|
};
|
|
34348
32626
|
supportsFormDataMap2 = /* @__PURE__ */ new WeakMap();
|
|
34349
32627
|
createForm2 = async (body, fetch2) => {
|
|
34350
|
-
if (!await
|
|
32628
|
+
if (!await supportsFormData2(fetch2)) {
|
|
34351
32629
|
throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
|
|
34352
32630
|
}
|
|
34353
32631
|
const form = new FormData();
|
|
@@ -39642,7 +37920,7 @@ var init_client2 = __esm({
|
|
|
39642
37920
|
return `stainless-node-retry-${uuid43()}`;
|
|
39643
37921
|
}
|
|
39644
37922
|
makeStatusError(status, error46, message, headers) {
|
|
39645
|
-
return
|
|
37923
|
+
return APIError2.generate(status, error46, message, headers);
|
|
39646
37924
|
}
|
|
39647
37925
|
async _callApiKey() {
|
|
39648
37926
|
const apiKey = this._options.apiKey;
|
|
@@ -39722,7 +38000,7 @@ var init_client2 = __esm({
|
|
|
39722
38000
|
retriesRemaining = maxRetries;
|
|
39723
38001
|
}
|
|
39724
38002
|
await this.prepareOptions(options);
|
|
39725
|
-
const { req, url: url2, timeout
|
|
38003
|
+
const { req, url: url2, timeout } = await this.buildRequest(options, {
|
|
39726
38004
|
retryCount: maxRetries - retriesRemaining
|
|
39727
38005
|
});
|
|
39728
38006
|
await this.prepareRequest(req, { url: url2, options });
|
|
@@ -39740,7 +38018,7 @@ var init_client2 = __esm({
|
|
|
39740
38018
|
throw new APIUserAbortError2();
|
|
39741
38019
|
}
|
|
39742
38020
|
const controller = new AbortController();
|
|
39743
|
-
const response = await this.fetchWithTimeout(url2, req,
|
|
38021
|
+
const response = await this.fetchWithTimeout(url2, req, timeout, controller).catch(castToError2);
|
|
39744
38022
|
const headersTime = Date.now();
|
|
39745
38023
|
if (response instanceof globalThis.Error) {
|
|
39746
38024
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
@@ -39824,7 +38102,7 @@ var init_client2 = __esm({
|
|
|
39824
38102
|
const { signal, method, ...options } = init2 || {};
|
|
39825
38103
|
if (signal)
|
|
39826
38104
|
signal.addEventListener("abort", () => controller.abort());
|
|
39827
|
-
const
|
|
38105
|
+
const timeout = setTimeout(() => controller.abort(), ms);
|
|
39828
38106
|
const isReadableBody = globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream || typeof options.body === "object" && options.body !== null && Symbol.asyncIterator in options.body;
|
|
39829
38107
|
const fetchOptions = {
|
|
39830
38108
|
signal: controller.signal,
|
|
@@ -39838,7 +38116,7 @@ var init_client2 = __esm({
|
|
|
39838
38116
|
try {
|
|
39839
38117
|
return await this.fetch.call(void 0, url2, fetchOptions);
|
|
39840
38118
|
} finally {
|
|
39841
|
-
clearTimeout(
|
|
38119
|
+
clearTimeout(timeout);
|
|
39842
38120
|
}
|
|
39843
38121
|
}
|
|
39844
38122
|
async shouldRetry(response) {
|
|
@@ -39964,7 +38242,7 @@ var init_client2 = __esm({
|
|
|
39964
38242
|
OpenAI.OpenAI = _a3;
|
|
39965
38243
|
OpenAI.DEFAULT_TIMEOUT = 6e5;
|
|
39966
38244
|
OpenAI.OpenAIError = OpenAIError;
|
|
39967
|
-
OpenAI.APIError =
|
|
38245
|
+
OpenAI.APIError = APIError2;
|
|
39968
38246
|
OpenAI.APIConnectionError = APIConnectionError2;
|
|
39969
38247
|
OpenAI.APIConnectionTimeoutError = APIConnectionTimeoutError2;
|
|
39970
38248
|
OpenAI.APIUserAbortError = APIUserAbortError2;
|
|
@@ -42091,6 +40369,7 @@ var require_package = __commonJS({
|
|
|
42091
40369
|
"@aws-sdk/client-sts": "^3.859.0",
|
|
42092
40370
|
"@aws-sdk/client-wafv2": "^3.859.0",
|
|
42093
40371
|
"@prisma/client": "^6.13.0",
|
|
40372
|
+
"@semiont/api-client": "*",
|
|
42094
40373
|
"@semiont/core": "*",
|
|
42095
40374
|
"@testcontainers/postgresql": "^11.5.1",
|
|
42096
40375
|
"@vitest/coverage-v8": "^3.2.4",
|
|
@@ -42443,7 +40722,7 @@ var stopDescriptor = createCommandDescriptor({
|
|
|
42443
40722
|
supportsAll: true
|
|
42444
40723
|
});
|
|
42445
40724
|
var stopExecutor = new MultiServiceExecutor(stopDescriptor);
|
|
42446
|
-
async function
|
|
40725
|
+
async function stop(serviceDeployments, options, envConfig) {
|
|
42447
40726
|
return stopExecutor.execute(serviceDeployments, options, envConfig);
|
|
42448
40727
|
}
|
|
42449
40728
|
var stopCommand = new CommandBuilder().name("stop").description("Stop services on their configured platforms").examples(
|
|
@@ -42477,7 +40756,7 @@ var stopCommand = new CommandBuilder().name("stop").description("Stop services o
|
|
|
42477
40756
|
"-f": "--force",
|
|
42478
40757
|
"-t": "--timeout"
|
|
42479
40758
|
}
|
|
42480
|
-
}).schema(StopOptionsSchema).handler(
|
|
40759
|
+
}).schema(StopOptionsSchema).handler(stop).build();
|
|
42481
40760
|
|
|
42482
40761
|
// src/core/command-discovery.ts
|
|
42483
40762
|
init_check();
|
|
@@ -44509,9 +42788,6 @@ main().catch((error46) => {
|
|
|
44509
42788
|
});
|
|
44510
42789
|
/*! Bundled license information:
|
|
44511
42790
|
|
|
44512
|
-
ky/distribution/index.js:
|
|
44513
|
-
(*! MIT License © Sindre Sorhus *)
|
|
44514
|
-
|
|
44515
42791
|
js-yaml/dist/js-yaml.mjs:
|
|
44516
42792
|
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
44517
42793
|
*/
|