@scalemule/sdk 0.0.1 → 0.0.2
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/index.d.mts +788 -4
- package/dist/index.d.ts +788 -4
- package/dist/index.js +747 -189
- package/dist/index.mjs +740 -177
- package/dist/{upload-compression-CWKEDQYS.mjs → upload-compression-VOUJRAIM.mjs} +2 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -278,19 +278,8 @@ var init_upload_compression = __esm({
|
|
|
278
278
|
"src/services/upload-compression.ts"() {
|
|
279
279
|
"use strict";
|
|
280
280
|
MIN_COMPRESS_SIZE = 100 * 1024;
|
|
281
|
-
COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set([
|
|
282
|
-
|
|
283
|
-
"image/jpg",
|
|
284
|
-
"image/png",
|
|
285
|
-
"image/bmp",
|
|
286
|
-
"image/tiff"
|
|
287
|
-
]);
|
|
288
|
-
SKIP_TYPES = /* @__PURE__ */ new Set([
|
|
289
|
-
"image/gif",
|
|
290
|
-
"image/svg+xml",
|
|
291
|
-
"image/webp",
|
|
292
|
-
"image/avif"
|
|
293
|
-
]);
|
|
281
|
+
COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/jpg", "image/png", "image/bmp", "image/tiff"]);
|
|
282
|
+
SKIP_TYPES = /* @__PURE__ */ new Set(["image/gif", "image/svg+xml", "image/webp", "image/avif"]);
|
|
294
283
|
NETWORK_PROFILES = {
|
|
295
284
|
"slow-2g": { maxWidth: 1280, maxHeight: 1280, quality: 0.6, maxSizeMB: 0.5 },
|
|
296
285
|
"2g": { maxWidth: 1600, maxHeight: 1600, quality: 0.65, maxSizeMB: 1 },
|
|
@@ -305,6 +294,12 @@ var init_upload_compression = __esm({
|
|
|
305
294
|
var index_exports = {};
|
|
306
295
|
__export(index_exports, {
|
|
307
296
|
AccountsService: () => AccountsService,
|
|
297
|
+
AgentAuthService: () => AgentAuthService,
|
|
298
|
+
AgentModelsService: () => AgentModelsService,
|
|
299
|
+
AgentProjectsService: () => AgentProjectsService,
|
|
300
|
+
AgentSessionsService: () => AgentSessionsService,
|
|
301
|
+
AgentToolsService: () => AgentToolsService,
|
|
302
|
+
AgentsService: () => AgentsService,
|
|
308
303
|
AnalyticsService: () => AnalyticsService,
|
|
309
304
|
AuthService: () => AuthService,
|
|
310
305
|
BillingService: () => BillingService,
|
|
@@ -941,81 +936,76 @@ var ScaleMuleClient = class {
|
|
|
941
936
|
* Single upload with XMLHttpRequest for progress tracking.
|
|
942
937
|
* Supports abort via AbortSignal.
|
|
943
938
|
*/
|
|
944
|
-
uploadWithXHR(url, buildFormData, onProgress, signal, maxRetries = this.maxRetries) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
if (signal) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
signal.addEventListener("abort", () => xhr.abort(), { once: true });
|
|
939
|
+
async uploadWithXHR(url, buildFormData, onProgress, signal, maxRetries = this.maxRetries) {
|
|
940
|
+
let lastError = null;
|
|
941
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
942
|
+
const result = await new Promise((res) => {
|
|
943
|
+
const xhr = new XMLHttpRequest();
|
|
944
|
+
if (signal) {
|
|
945
|
+
if (signal.aborted) {
|
|
946
|
+
res({ data: null, error: { code: "aborted", message: "Upload aborted", status: 0 } });
|
|
947
|
+
return;
|
|
956
948
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
res({ data: null, error: { code: "internal_error", message: "Failed to parse response", status: 0 } });
|
|
949
|
+
signal.addEventListener("abort", () => xhr.abort(), { once: true });
|
|
950
|
+
}
|
|
951
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
952
|
+
if (event.lengthComputable) {
|
|
953
|
+
onProgress(Math.round(event.loaded / event.total * 100));
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
xhr.addEventListener("load", () => {
|
|
957
|
+
try {
|
|
958
|
+
const data = JSON.parse(xhr.responseText);
|
|
959
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
960
|
+
const result2 = data?.data !== void 0 ? data.data : data;
|
|
961
|
+
res({ data: result2, error: null });
|
|
962
|
+
} else {
|
|
963
|
+
res({
|
|
964
|
+
data: null,
|
|
965
|
+
error: {
|
|
966
|
+
code: data?.error?.code || statusToErrorCode(xhr.status),
|
|
967
|
+
message: data?.error?.message || data?.message || "Upload failed",
|
|
968
|
+
status: xhr.status,
|
|
969
|
+
details: data?.error?.details
|
|
970
|
+
}
|
|
971
|
+
});
|
|
981
972
|
}
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
res({ data: null, error: { code: "upload_error", message: "Upload failed", status: 0 } });
|
|
985
|
-
});
|
|
986
|
-
xhr.addEventListener("abort", () => {
|
|
987
|
-
res({ data: null, error: { code: "aborted", message: "Upload aborted", status: 0 } });
|
|
988
|
-
});
|
|
989
|
-
xhr.open("POST", url);
|
|
990
|
-
xhr.setRequestHeader("x-api-key", this.apiKey);
|
|
991
|
-
if (this.sessionToken) {
|
|
992
|
-
xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
|
|
973
|
+
} catch {
|
|
974
|
+
res({ data: null, error: { code: "internal_error", message: "Failed to parse response", status: 0 } });
|
|
993
975
|
}
|
|
994
|
-
xhr.send(buildFormData());
|
|
995
976
|
});
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
lastError = result.error;
|
|
1007
|
-
onProgress(0);
|
|
1008
|
-
await sleep(getBackoffDelay(attempt, this.backoffMs));
|
|
1009
|
-
continue;
|
|
977
|
+
xhr.addEventListener("error", () => {
|
|
978
|
+
res({ data: null, error: { code: "upload_error", message: "Upload failed", status: 0 } });
|
|
979
|
+
});
|
|
980
|
+
xhr.addEventListener("abort", () => {
|
|
981
|
+
res({ data: null, error: { code: "aborted", message: "Upload aborted", status: 0 } });
|
|
982
|
+
});
|
|
983
|
+
xhr.open("POST", url);
|
|
984
|
+
xhr.setRequestHeader("x-api-key", this.apiKey);
|
|
985
|
+
if (this.sessionToken) {
|
|
986
|
+
xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
|
|
1010
987
|
}
|
|
1011
|
-
|
|
1012
|
-
return;
|
|
1013
|
-
}
|
|
1014
|
-
resolve({
|
|
1015
|
-
data: null,
|
|
1016
|
-
error: lastError || { code: "upload_error", message: "Upload failed", status: 0 }
|
|
988
|
+
xhr.send(buildFormData());
|
|
1017
989
|
});
|
|
1018
|
-
|
|
990
|
+
if (result.error === null) {
|
|
991
|
+
return result;
|
|
992
|
+
}
|
|
993
|
+
const isRetryable = result.error.code === "upload_error" || result.error.code === "network_error" || RETRYABLE_STATUS_CODES.has(result.error.status);
|
|
994
|
+
if (result.error.code === "aborted") {
|
|
995
|
+
return result;
|
|
996
|
+
}
|
|
997
|
+
if (attempt < maxRetries && isRetryable) {
|
|
998
|
+
lastError = result.error;
|
|
999
|
+
onProgress(0);
|
|
1000
|
+
await sleep(getBackoffDelay(attempt, this.backoffMs));
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
return result;
|
|
1004
|
+
}
|
|
1005
|
+
return {
|
|
1006
|
+
data: null,
|
|
1007
|
+
error: lastError || { code: "upload_error", message: "Upload failed", status: 0 }
|
|
1008
|
+
};
|
|
1019
1009
|
}
|
|
1020
1010
|
// --------------------------------------------------------------------------
|
|
1021
1011
|
// Offline Queue Sync
|
|
@@ -1108,7 +1098,12 @@ var ServiceModule = class {
|
|
|
1108
1098
|
// File upload (delegates to client.upload)
|
|
1109
1099
|
// --------------------------------------------------------------------------
|
|
1110
1100
|
_upload(path, file, additionalFields, options) {
|
|
1111
|
-
return this.client.upload(
|
|
1101
|
+
return this.client.upload(
|
|
1102
|
+
`${this.basePath}${path}`,
|
|
1103
|
+
file,
|
|
1104
|
+
additionalFields,
|
|
1105
|
+
this.resolveOptions(options)
|
|
1106
|
+
);
|
|
1112
1107
|
}
|
|
1113
1108
|
// --------------------------------------------------------------------------
|
|
1114
1109
|
// Query string helper (available to subclasses)
|
|
@@ -1793,13 +1788,17 @@ var StorageService = class extends ServiceModule {
|
|
|
1793
1788
|
const directStart = Date.now();
|
|
1794
1789
|
const requestOpts = this.withSessionHeader(sessionId, options);
|
|
1795
1790
|
const filename = options?.filename || file.name || "file";
|
|
1796
|
-
const initResult = await this.post(
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1791
|
+
const initResult = await this.post(
|
|
1792
|
+
"/signed-url/upload",
|
|
1793
|
+
{
|
|
1794
|
+
filename,
|
|
1795
|
+
content_type: file.type || "application/octet-stream",
|
|
1796
|
+
size_bytes: file.size,
|
|
1797
|
+
is_public: options?.isPublic ?? true,
|
|
1798
|
+
metadata: options?.metadata
|
|
1799
|
+
},
|
|
1800
|
+
requestOpts
|
|
1801
|
+
);
|
|
1803
1802
|
if (initResult.error) {
|
|
1804
1803
|
telemetry?.emit(sessionId, "upload.failed", { step: "presign", error: initResult.error.message });
|
|
1805
1804
|
return { data: null, error: initResult.error };
|
|
@@ -1825,14 +1824,27 @@ var StorageService = class extends ServiceModule {
|
|
|
1825
1824
|
});
|
|
1826
1825
|
return { data: null, error: uploadResult.error };
|
|
1827
1826
|
}
|
|
1828
|
-
const completeResult = await this.post(
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1827
|
+
const completeResult = await this.post(
|
|
1828
|
+
"/signed-url/complete",
|
|
1829
|
+
{
|
|
1830
|
+
file_id,
|
|
1831
|
+
completion_token
|
|
1832
|
+
},
|
|
1833
|
+
requestOpts
|
|
1834
|
+
);
|
|
1832
1835
|
if (completeResult.error) {
|
|
1833
|
-
telemetry?.emit(sessionId, "upload.failed", {
|
|
1836
|
+
telemetry?.emit(sessionId, "upload.failed", {
|
|
1837
|
+
step: "complete",
|
|
1838
|
+
error: completeResult.error.message,
|
|
1839
|
+
file_id,
|
|
1840
|
+
duration_ms: Date.now() - directStart
|
|
1841
|
+
});
|
|
1834
1842
|
} else {
|
|
1835
|
-
telemetry?.emit(sessionId, "upload.completed", {
|
|
1843
|
+
telemetry?.emit(sessionId, "upload.completed", {
|
|
1844
|
+
file_id,
|
|
1845
|
+
size_bytes: file.size,
|
|
1846
|
+
duration_ms: Date.now() - directStart
|
|
1847
|
+
});
|
|
1836
1848
|
}
|
|
1837
1849
|
return completeResult;
|
|
1838
1850
|
}
|
|
@@ -1867,14 +1879,17 @@ var StorageService = class extends ServiceModule {
|
|
|
1867
1879
|
});
|
|
1868
1880
|
}
|
|
1869
1881
|
} catch (err) {
|
|
1870
|
-
telemetry?.emit(sessionId, "upload.retried", {
|
|
1882
|
+
telemetry?.emit(sessionId, "upload.retried", {
|
|
1883
|
+
step: "resume_load",
|
|
1884
|
+
error: err instanceof Error ? err.message : "Resume store unavailable"
|
|
1885
|
+
});
|
|
1871
1886
|
resumeStore = null;
|
|
1872
1887
|
resumeData = null;
|
|
1873
1888
|
}
|
|
1874
1889
|
}
|
|
1875
1890
|
let startData;
|
|
1876
1891
|
let completionToken;
|
|
1877
|
-
|
|
1892
|
+
const completedParts = /* @__PURE__ */ new Map();
|
|
1878
1893
|
if (resumeData) {
|
|
1879
1894
|
startData = {
|
|
1880
1895
|
upload_session_id: resumeData.upload_session_id,
|
|
@@ -1903,15 +1918,19 @@ var StorageService = class extends ServiceModule {
|
|
|
1903
1918
|
);
|
|
1904
1919
|
} catch {
|
|
1905
1920
|
}
|
|
1906
|
-
const startResult = await this.post(
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1921
|
+
const startResult = await this.post(
|
|
1922
|
+
"/signed-url/multipart/start",
|
|
1923
|
+
{
|
|
1924
|
+
filename,
|
|
1925
|
+
content_type: file.type || "application/octet-stream",
|
|
1926
|
+
size_bytes: file.size,
|
|
1927
|
+
is_public: options?.isPublic ?? true,
|
|
1928
|
+
metadata: options?.metadata,
|
|
1929
|
+
chunk_size: options?.chunkSize,
|
|
1930
|
+
...clientUploadKey ? { client_upload_key: clientUploadKey } : {}
|
|
1931
|
+
},
|
|
1932
|
+
requestOpts
|
|
1933
|
+
);
|
|
1915
1934
|
if (startResult.error) {
|
|
1916
1935
|
telemetry?.emit(sessionId, "upload.multipart.aborted", { error: startResult.error.message });
|
|
1917
1936
|
return { data: null, error: startResult.error };
|
|
@@ -1940,11 +1959,14 @@ var StorageService = class extends ServiceModule {
|
|
|
1940
1959
|
created_at: Date.now()
|
|
1941
1960
|
});
|
|
1942
1961
|
} catch (err) {
|
|
1943
|
-
telemetry?.emit(sessionId, "upload.retried", {
|
|
1962
|
+
telemetry?.emit(sessionId, "upload.retried", {
|
|
1963
|
+
step: "resume_save",
|
|
1964
|
+
error: err instanceof Error ? err.message : "Resume save failed"
|
|
1965
|
+
});
|
|
1944
1966
|
}
|
|
1945
1967
|
}
|
|
1946
1968
|
const maxConcurrency = options?.maxConcurrency || this.defaultConcurrency();
|
|
1947
|
-
|
|
1969
|
+
const availableUrls = /* @__PURE__ */ new Map();
|
|
1948
1970
|
if (startData.part_urls.length > 0) {
|
|
1949
1971
|
for (const pu of startData.part_urls) {
|
|
1950
1972
|
availableUrls.set(pu.part_number, pu);
|
|
@@ -1965,7 +1987,11 @@ var StorageService = class extends ServiceModule {
|
|
|
1965
1987
|
}
|
|
1966
1988
|
const milestone = Math.floor(percent / 25) * 25;
|
|
1967
1989
|
if (milestone > lastProgressMilestone && milestone < 100) {
|
|
1968
|
-
telemetry?.emit(sessionId, "upload.progress", {
|
|
1990
|
+
telemetry?.emit(sessionId, "upload.progress", {
|
|
1991
|
+
percent: milestone,
|
|
1992
|
+
uploaded_parts: uploadedCount,
|
|
1993
|
+
total_parts
|
|
1994
|
+
});
|
|
1969
1995
|
lastProgressMilestone = milestone;
|
|
1970
1996
|
}
|
|
1971
1997
|
};
|
|
@@ -2065,7 +2091,11 @@ var StorageService = class extends ServiceModule {
|
|
|
2065
2091
|
);
|
|
2066
2092
|
await resumeStore.updatePart(resumeKey, result.partNum, result.etag);
|
|
2067
2093
|
} catch (err) {
|
|
2068
|
-
telemetry?.emit(sessionId, "upload.retried", {
|
|
2094
|
+
telemetry?.emit(sessionId, "upload.retried", {
|
|
2095
|
+
step: "resume_update",
|
|
2096
|
+
part_number: result.partNum,
|
|
2097
|
+
error: err instanceof Error ? err.message : "Resume update failed"
|
|
2098
|
+
});
|
|
2069
2099
|
}
|
|
2070
2100
|
}
|
|
2071
2101
|
} else {
|
|
@@ -2099,15 +2129,30 @@ var StorageService = class extends ServiceModule {
|
|
|
2099
2129
|
);
|
|
2100
2130
|
await resumeStore.remove(resumeKey);
|
|
2101
2131
|
} catch (err) {
|
|
2102
|
-
telemetry?.emit(sessionId, "upload.retried", {
|
|
2132
|
+
telemetry?.emit(sessionId, "upload.retried", {
|
|
2133
|
+
step: "resume_cleanup",
|
|
2134
|
+
error: err instanceof Error ? err.message : "Resume cleanup failed"
|
|
2135
|
+
});
|
|
2103
2136
|
}
|
|
2104
2137
|
}
|
|
2105
2138
|
if (completeResult.error) {
|
|
2106
|
-
telemetry?.emit(sessionId, "upload.multipart.aborted", {
|
|
2139
|
+
telemetry?.emit(sessionId, "upload.multipart.aborted", {
|
|
2140
|
+
file_id,
|
|
2141
|
+
error: completeResult.error.message,
|
|
2142
|
+
duration_ms: Date.now() - multipartStart
|
|
2143
|
+
});
|
|
2107
2144
|
return { data: null, error: completeResult.error };
|
|
2108
2145
|
}
|
|
2109
|
-
telemetry?.emit(sessionId, "upload.multipart.completed", {
|
|
2110
|
-
|
|
2146
|
+
telemetry?.emit(sessionId, "upload.multipart.completed", {
|
|
2147
|
+
file_id,
|
|
2148
|
+
size_bytes: file.size,
|
|
2149
|
+
duration_ms: Date.now() - multipartStart
|
|
2150
|
+
});
|
|
2151
|
+
telemetry?.emit(sessionId, "upload.completed", {
|
|
2152
|
+
file_id,
|
|
2153
|
+
size_bytes: file.size,
|
|
2154
|
+
duration_ms: Date.now() - multipartStart
|
|
2155
|
+
});
|
|
2111
2156
|
options?.onProgress?.(100);
|
|
2112
2157
|
const d = completeResult.data;
|
|
2113
2158
|
return {
|
|
@@ -2127,10 +2172,14 @@ var StorageService = class extends ServiceModule {
|
|
|
2127
2172
|
// --------------------------------------------------------------------------
|
|
2128
2173
|
async abortMultipart(uploadSessionId, completionToken, requestOpts) {
|
|
2129
2174
|
try {
|
|
2130
|
-
await this.post(
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2175
|
+
await this.post(
|
|
2176
|
+
"/signed-url/multipart/abort",
|
|
2177
|
+
{
|
|
2178
|
+
upload_session_id: uploadSessionId,
|
|
2179
|
+
...completionToken ? { completion_token: completionToken } : {}
|
|
2180
|
+
},
|
|
2181
|
+
requestOpts
|
|
2182
|
+
);
|
|
2134
2183
|
} catch {
|
|
2135
2184
|
}
|
|
2136
2185
|
}
|
|
@@ -2145,25 +2194,33 @@ var StorageService = class extends ServiceModule {
|
|
|
2145
2194
|
* Flow: server calls getUploadUrl() → returns URL to client → client PUTs to S3 → server calls completeUpload()
|
|
2146
2195
|
*/
|
|
2147
2196
|
async getUploadUrl(filename, contentType, options, requestOptions) {
|
|
2148
|
-
return this.post(
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2197
|
+
return this.post(
|
|
2198
|
+
"/signed-url/upload",
|
|
2199
|
+
{
|
|
2200
|
+
filename,
|
|
2201
|
+
content_type: contentType,
|
|
2202
|
+
is_public: options?.isPublic ?? true,
|
|
2203
|
+
expires_in: options?.expiresIn ?? 3600,
|
|
2204
|
+
metadata: options?.metadata
|
|
2205
|
+
},
|
|
2206
|
+
requestOptions
|
|
2207
|
+
);
|
|
2155
2208
|
}
|
|
2156
2209
|
/**
|
|
2157
2210
|
* Complete a presigned upload after the file has been uploaded to S3.
|
|
2158
2211
|
* Triggers scan and makes the file available.
|
|
2159
2212
|
*/
|
|
2160
2213
|
async completeUpload(fileId, completionToken, options, requestOptions) {
|
|
2161
|
-
return this.post(
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2214
|
+
return this.post(
|
|
2215
|
+
"/signed-url/complete",
|
|
2216
|
+
{
|
|
2217
|
+
file_id: fileId,
|
|
2218
|
+
completion_token: completionToken,
|
|
2219
|
+
size_bytes: options?.sizeBytes,
|
|
2220
|
+
checksum: options?.checksum
|
|
2221
|
+
},
|
|
2222
|
+
requestOptions
|
|
2223
|
+
);
|
|
2167
2224
|
}
|
|
2168
2225
|
// --------------------------------------------------------------------------
|
|
2169
2226
|
// Multipart Public API (for advanced/server-side usage)
|
|
@@ -2174,11 +2231,15 @@ var StorageService = class extends ServiceModule {
|
|
|
2174
2231
|
}
|
|
2175
2232
|
/** Get presigned URLs for specific part numbers. */
|
|
2176
2233
|
async getMultipartPartUrls(uploadSessionId, partNumbers, completionToken, requestOptions) {
|
|
2177
|
-
return this.post(
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2234
|
+
return this.post(
|
|
2235
|
+
"/signed-url/multipart/part-urls",
|
|
2236
|
+
{
|
|
2237
|
+
upload_session_id: uploadSessionId,
|
|
2238
|
+
part_numbers: partNumbers,
|
|
2239
|
+
...completionToken ? { completion_token: completionToken } : {}
|
|
2240
|
+
},
|
|
2241
|
+
requestOptions
|
|
2242
|
+
);
|
|
2182
2243
|
}
|
|
2183
2244
|
/** Complete a multipart upload. */
|
|
2184
2245
|
async completeMultipartUpload(params, requestOptions) {
|
|
@@ -2186,10 +2247,14 @@ var StorageService = class extends ServiceModule {
|
|
|
2186
2247
|
}
|
|
2187
2248
|
/** Abort a multipart upload. */
|
|
2188
2249
|
async abortMultipartUpload(uploadSessionId, completionToken, requestOptions) {
|
|
2189
|
-
return this.post(
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2250
|
+
return this.post(
|
|
2251
|
+
"/signed-url/multipart/abort",
|
|
2252
|
+
{
|
|
2253
|
+
upload_session_id: uploadSessionId,
|
|
2254
|
+
...completionToken ? { completion_token: completionToken } : {}
|
|
2255
|
+
},
|
|
2256
|
+
requestOptions
|
|
2257
|
+
);
|
|
2193
2258
|
}
|
|
2194
2259
|
// --------------------------------------------------------------------------
|
|
2195
2260
|
// File Operations
|
|
@@ -2238,7 +2303,11 @@ var StorageService = class extends ServiceModule {
|
|
|
2238
2303
|
* Public files get 7-day signed URLs; private files get 1-hour signed URLs.
|
|
2239
2304
|
*/
|
|
2240
2305
|
async updateVisibility(fileId, isPublic, options) {
|
|
2241
|
-
return this.patch(
|
|
2306
|
+
return this.patch(
|
|
2307
|
+
`/files/${fileId}/visibility`,
|
|
2308
|
+
{ is_public: isPublic },
|
|
2309
|
+
options
|
|
2310
|
+
);
|
|
2242
2311
|
}
|
|
2243
2312
|
// --------------------------------------------------------------------------
|
|
2244
2313
|
// Legacy methods (backward compat)
|
|
@@ -2382,10 +2451,14 @@ var StorageService = class extends ServiceModule {
|
|
|
2382
2451
|
resolve({ data: null, error: { code: "aborted", message: "Upload aborted", status: 0 } });
|
|
2383
2452
|
return;
|
|
2384
2453
|
}
|
|
2385
|
-
signal.addEventListener(
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2454
|
+
signal.addEventListener(
|
|
2455
|
+
"abort",
|
|
2456
|
+
() => {
|
|
2457
|
+
clearStallTimer();
|
|
2458
|
+
xhr.abort();
|
|
2459
|
+
},
|
|
2460
|
+
{ once: true }
|
|
2461
|
+
);
|
|
2389
2462
|
}
|
|
2390
2463
|
xhr.upload.addEventListener("progress", (event) => {
|
|
2391
2464
|
resetStallTimer();
|
|
@@ -2472,7 +2545,11 @@ var StorageService = class extends ServiceModule {
|
|
|
2472
2545
|
return { error: `Part upload failed: ${response.status}`, status: response.status, code: "s3_error" };
|
|
2473
2546
|
}
|
|
2474
2547
|
if (attempt === RETRY_DELAYS.length - 1) {
|
|
2475
|
-
return {
|
|
2548
|
+
return {
|
|
2549
|
+
error: `Part upload failed after retries: ${response.status}`,
|
|
2550
|
+
status: response.status,
|
|
2551
|
+
code: "s3_error"
|
|
2552
|
+
};
|
|
2476
2553
|
}
|
|
2477
2554
|
} catch (err) {
|
|
2478
2555
|
clearTimeout(timer);
|
|
@@ -2981,14 +3058,18 @@ var VideoService = class extends ServiceModule {
|
|
|
2981
3058
|
const chunkSize = Math.max(options?.chunkSize ?? DEFAULT_CHUNK_SIZE, MIN_CHUNK_SIZE);
|
|
2982
3059
|
const totalChunks = Math.ceil(file.size / chunkSize);
|
|
2983
3060
|
const filename = options?.filename || file.name || "video";
|
|
2984
|
-
const startResult = await this.post(
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
3061
|
+
const startResult = await this.post(
|
|
3062
|
+
"/upload-start",
|
|
3063
|
+
{
|
|
3064
|
+
filename,
|
|
3065
|
+
content_type: file.type || "video/mp4",
|
|
3066
|
+
size_bytes: file.size,
|
|
3067
|
+
title: options?.title,
|
|
3068
|
+
description: options?.description,
|
|
3069
|
+
metadata: options?.metadata
|
|
3070
|
+
},
|
|
3071
|
+
requestOptions
|
|
3072
|
+
);
|
|
2992
3073
|
if (startResult.error) return { data: null, error: startResult.error };
|
|
2993
3074
|
const { video_id, upload_id } = startResult.data;
|
|
2994
3075
|
const parts = [];
|
|
@@ -3000,13 +3081,7 @@ var VideoService = class extends ServiceModule {
|
|
|
3000
3081
|
const end = Math.min(start + chunkSize, file.size);
|
|
3001
3082
|
const chunk = file.slice(start, end);
|
|
3002
3083
|
const partNumber = i + 1;
|
|
3003
|
-
const partResult = await this.uploadPart(
|
|
3004
|
-
video_id,
|
|
3005
|
-
upload_id,
|
|
3006
|
-
partNumber,
|
|
3007
|
-
chunk,
|
|
3008
|
-
options?.signal
|
|
3009
|
-
);
|
|
3084
|
+
const partResult = await this.uploadPart(video_id, upload_id, partNumber, chunk, options?.signal);
|
|
3010
3085
|
if (partResult.error) return { data: null, error: partResult.error };
|
|
3011
3086
|
parts.push({
|
|
3012
3087
|
part_number: partNumber,
|
|
@@ -3017,10 +3092,14 @@ var VideoService = class extends ServiceModule {
|
|
|
3017
3092
|
options.onProgress(progress);
|
|
3018
3093
|
}
|
|
3019
3094
|
}
|
|
3020
|
-
const completeResult = await this.post(
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3095
|
+
const completeResult = await this.post(
|
|
3096
|
+
`/${video_id}/upload-complete`,
|
|
3097
|
+
{
|
|
3098
|
+
upload_id,
|
|
3099
|
+
parts
|
|
3100
|
+
},
|
|
3101
|
+
requestOptions
|
|
3102
|
+
);
|
|
3024
3103
|
return completeResult;
|
|
3025
3104
|
}
|
|
3026
3105
|
// --------------------------------------------------------------------------
|
|
@@ -3049,7 +3128,10 @@ var VideoService = class extends ServiceModule {
|
|
|
3049
3128
|
}
|
|
3050
3129
|
/** Get video analytics (views, watch time, etc.). */
|
|
3051
3130
|
async getAnalytics(videoId, options) {
|
|
3052
|
-
return super._get(
|
|
3131
|
+
return super._get(
|
|
3132
|
+
`/${videoId}/analytics`,
|
|
3133
|
+
options
|
|
3134
|
+
);
|
|
3053
3135
|
}
|
|
3054
3136
|
/**
|
|
3055
3137
|
* Update a video's access mode (public/private).
|
|
@@ -3249,7 +3331,10 @@ var ChatService = class extends ServiceModule {
|
|
|
3249
3331
|
return this.post(`/conversations/${conversationId}/messages`, data, options);
|
|
3250
3332
|
}
|
|
3251
3333
|
async getMessages(conversationId, options, requestOptions) {
|
|
3252
|
-
return this._get(
|
|
3334
|
+
return this._get(
|
|
3335
|
+
this.withQuery(`/conversations/${conversationId}/messages`, options),
|
|
3336
|
+
requestOptions
|
|
3337
|
+
);
|
|
3253
3338
|
}
|
|
3254
3339
|
async editMessage(messageId, data, options) {
|
|
3255
3340
|
return this.patch(`/messages/${messageId}`, data, options);
|
|
@@ -3486,7 +3571,10 @@ var BillingService = class extends ServiceModule {
|
|
|
3486
3571
|
return this._list("/transactions", params, options);
|
|
3487
3572
|
}
|
|
3488
3573
|
async getTransactionSummary(params, options) {
|
|
3489
|
-
return this._get(
|
|
3574
|
+
return this._get(
|
|
3575
|
+
this.withQuery("/transactions/summary", params),
|
|
3576
|
+
options
|
|
3577
|
+
);
|
|
3490
3578
|
}
|
|
3491
3579
|
// --------------------------------------------------------------------------
|
|
3492
3580
|
// Setup Sessions
|
|
@@ -3513,7 +3601,11 @@ var BillingService = class extends ServiceModule {
|
|
|
3513
3601
|
return this.post(`/connected-subscriptions/${id}/cancel`, data, options);
|
|
3514
3602
|
}
|
|
3515
3603
|
async listConnectedSubscriptions(params, options) {
|
|
3516
|
-
return this._list(
|
|
3604
|
+
return this._list(
|
|
3605
|
+
"/connected-subscriptions",
|
|
3606
|
+
params,
|
|
3607
|
+
options
|
|
3608
|
+
);
|
|
3517
3609
|
}
|
|
3518
3610
|
async createConnectedSetupIntent(data, options) {
|
|
3519
3611
|
return this.post("/connected-setup-intents", data, options);
|
|
@@ -3559,7 +3651,11 @@ var AnalyticsService = class extends ServiceModule {
|
|
|
3559
3651
|
// Identity
|
|
3560
3652
|
// --------------------------------------------------------------------------
|
|
3561
3653
|
async identify(userId, traits, anonymousId, options) {
|
|
3562
|
-
return this.post(
|
|
3654
|
+
return this.post(
|
|
3655
|
+
"/identify",
|
|
3656
|
+
{ user_id: userId, traits, anonymous_id: anonymousId },
|
|
3657
|
+
options
|
|
3658
|
+
);
|
|
3563
3659
|
}
|
|
3564
3660
|
async alias(userId, anonymousId, options) {
|
|
3565
3661
|
return this.post("/alias", { user_id: userId, anonymous_id: anonymousId }, options);
|
|
@@ -3749,22 +3845,30 @@ var PermissionsService = class extends ServiceModule {
|
|
|
3749
3845
|
/** Check a single permission. Supports identity_type for unified model. */
|
|
3750
3846
|
async check(identityId, permission, options) {
|
|
3751
3847
|
const { identityType, resourceType, resourceId, ...reqOptions } = options || {};
|
|
3752
|
-
return this.post(
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3848
|
+
return this.post(
|
|
3849
|
+
"/check",
|
|
3850
|
+
{
|
|
3851
|
+
identity_id: identityId,
|
|
3852
|
+
identity_type: identityType || "user",
|
|
3853
|
+
permission,
|
|
3854
|
+
resource_type: resourceType,
|
|
3855
|
+
resource_id: resourceId
|
|
3856
|
+
},
|
|
3857
|
+
reqOptions
|
|
3858
|
+
);
|
|
3759
3859
|
}
|
|
3760
3860
|
/** Batch check multiple permissions for an identity. */
|
|
3761
3861
|
async batchCheck(identityId, permissions, options) {
|
|
3762
3862
|
const { identityType, ...reqOptions } = options || {};
|
|
3763
|
-
return this.post(
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3863
|
+
return this.post(
|
|
3864
|
+
"/batch-check",
|
|
3865
|
+
{
|
|
3866
|
+
identity_id: identityId,
|
|
3867
|
+
identity_type: identityType || "user",
|
|
3868
|
+
permissions
|
|
3869
|
+
},
|
|
3870
|
+
reqOptions
|
|
3871
|
+
);
|
|
3768
3872
|
}
|
|
3769
3873
|
/** Fetch the full permission matrix for an identity (single request, no N+1). */
|
|
3770
3874
|
async getMatrix(identityId, identityType = "user", options) {
|
|
@@ -4208,7 +4312,7 @@ var PhotoService = class extends ServiceModule {
|
|
|
4208
4312
|
* // Profile avatar at 48px -> snaps to 150px
|
|
4209
4313
|
* const url = sm.photo.getOptimalUrl(photoId, 48)
|
|
4210
4314
|
* ```
|
|
4211
|
-
|
|
4315
|
+
*/
|
|
4212
4316
|
getOptimalUrl(photoId, displayWidth, options) {
|
|
4213
4317
|
const requestedDpr = options?.dpr ?? 1;
|
|
4214
4318
|
const dpr = Number.isFinite(requestedDpr) && requestedDpr > 0 ? requestedDpr : 1;
|
|
@@ -4237,7 +4341,9 @@ var PhotoService = class extends ServiceModule {
|
|
|
4237
4341
|
* ```
|
|
4238
4342
|
*/
|
|
4239
4343
|
getSrcSet(photoId) {
|
|
4240
|
-
return PHOTO_BREAKPOINTS.map(
|
|
4344
|
+
return PHOTO_BREAKPOINTS.map(
|
|
4345
|
+
(size) => `${this.getTransformUrl(photoId, { width: size, height: size, fit: "cover" })} ${size}w`
|
|
4346
|
+
).join(", ");
|
|
4241
4347
|
}
|
|
4242
4348
|
/**
|
|
4243
4349
|
* Register a photo from an already-uploaded storage file.
|
|
@@ -4249,10 +4355,14 @@ var PhotoService = class extends ServiceModule {
|
|
|
4249
4355
|
* Returns the photo record with `id` that can be used with `getTransformUrl()`.
|
|
4250
4356
|
*/
|
|
4251
4357
|
async register(registerOptions, requestOptions) {
|
|
4252
|
-
return this.post(
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4358
|
+
return this.post(
|
|
4359
|
+
"/register",
|
|
4360
|
+
{
|
|
4361
|
+
file_id: registerOptions.fileId,
|
|
4362
|
+
sm_user_id: registerOptions.userId
|
|
4363
|
+
},
|
|
4364
|
+
requestOptions
|
|
4365
|
+
);
|
|
4256
4366
|
}
|
|
4257
4367
|
/** @deprecated Use upload() instead */
|
|
4258
4368
|
async uploadPhoto(file, options) {
|
|
@@ -4520,6 +4630,442 @@ var FlagContentService = class extends ServiceModule {
|
|
|
4520
4630
|
}
|
|
4521
4631
|
};
|
|
4522
4632
|
|
|
4633
|
+
// src/services/agent-auth.ts
|
|
4634
|
+
var AgentAuthService = class extends ServiceModule {
|
|
4635
|
+
constructor() {
|
|
4636
|
+
super(...arguments);
|
|
4637
|
+
this.basePath = "/v1/auth";
|
|
4638
|
+
}
|
|
4639
|
+
async registerAgent(data, options) {
|
|
4640
|
+
return this.post("/register/agent", data, options);
|
|
4641
|
+
}
|
|
4642
|
+
async listTokens(options) {
|
|
4643
|
+
return this._get("/agent-tokens", options);
|
|
4644
|
+
}
|
|
4645
|
+
async createToken(data, options) {
|
|
4646
|
+
return this.post("/agent-tokens", data, options);
|
|
4647
|
+
}
|
|
4648
|
+
async revokeToken(id, options) {
|
|
4649
|
+
return this.del(`/agent-tokens/${id}`, options);
|
|
4650
|
+
}
|
|
4651
|
+
async rotateToken(id, options) {
|
|
4652
|
+
return this.post(`/agent-tokens/${id}/rotate`, void 0, options);
|
|
4653
|
+
}
|
|
4654
|
+
async exchangeToken(data, options) {
|
|
4655
|
+
return this.post("/agent-tokens/exchange", data, options);
|
|
4656
|
+
}
|
|
4657
|
+
async listSigningKeys(options) {
|
|
4658
|
+
return this._get("/agent-signing-keys", options);
|
|
4659
|
+
}
|
|
4660
|
+
async addSigningKey(data, options) {
|
|
4661
|
+
return this.post("/agent-signing-keys", data, options);
|
|
4662
|
+
}
|
|
4663
|
+
async revokeSigningKey(id, options) {
|
|
4664
|
+
return this.del(`/agent-signing-keys/${id}`, options);
|
|
4665
|
+
}
|
|
4666
|
+
async getProfile(options) {
|
|
4667
|
+
return this._get("/agent-profile", options);
|
|
4668
|
+
}
|
|
4669
|
+
async updateProfile(data, options) {
|
|
4670
|
+
return this.patch("/agent-profile", data, options);
|
|
4671
|
+
}
|
|
4672
|
+
async getSecurityPolicy(appId, options) {
|
|
4673
|
+
return this._get(`/applications/${appId}/agent-security`, options);
|
|
4674
|
+
}
|
|
4675
|
+
async updateSecurityPolicy(appId, data, options) {
|
|
4676
|
+
return this.put(`/applications/${appId}/agent-security`, data, options);
|
|
4677
|
+
}
|
|
4678
|
+
};
|
|
4679
|
+
|
|
4680
|
+
// src/services/agents.ts
|
|
4681
|
+
var AgentsService = class extends ServiceModule {
|
|
4682
|
+
constructor() {
|
|
4683
|
+
super(...arguments);
|
|
4684
|
+
this.basePath = "/v1/agents";
|
|
4685
|
+
}
|
|
4686
|
+
// Orchestrated registration
|
|
4687
|
+
async registerAgent(data, options) {
|
|
4688
|
+
return this.post("/register-agent", data, options);
|
|
4689
|
+
}
|
|
4690
|
+
async deactivateAgent(id, options) {
|
|
4691
|
+
return this.post(`/agents/${id}/deactivate`, void 0, options);
|
|
4692
|
+
}
|
|
4693
|
+
// Agent CRUD
|
|
4694
|
+
async create(data, options) {
|
|
4695
|
+
return this.post("/agents", data, options);
|
|
4696
|
+
}
|
|
4697
|
+
async list(params, options) {
|
|
4698
|
+
return this._list("/agents", params, options);
|
|
4699
|
+
}
|
|
4700
|
+
async get(id, options) {
|
|
4701
|
+
return this._get(`/agents/${id}`, options);
|
|
4702
|
+
}
|
|
4703
|
+
async update(id, data, options) {
|
|
4704
|
+
return this.patch(`/agents/${id}`, data, options);
|
|
4705
|
+
}
|
|
4706
|
+
async remove(id, options) {
|
|
4707
|
+
return this.del(`/agents/${id}`, options);
|
|
4708
|
+
}
|
|
4709
|
+
async setDefaultWorkspace(id, data, options) {
|
|
4710
|
+
return this.post(`/agents/${id}/set-default-workspace`, data, options);
|
|
4711
|
+
}
|
|
4712
|
+
// Runtime Templates
|
|
4713
|
+
async createTemplate(data, options) {
|
|
4714
|
+
return this.post("/runtime-templates", data, options);
|
|
4715
|
+
}
|
|
4716
|
+
async listTemplates(params, options) {
|
|
4717
|
+
return this._list("/runtime-templates", params, options);
|
|
4718
|
+
}
|
|
4719
|
+
async getTemplate(id, options) {
|
|
4720
|
+
return this._get(
|
|
4721
|
+
`/runtime-templates/${id}`,
|
|
4722
|
+
options
|
|
4723
|
+
);
|
|
4724
|
+
}
|
|
4725
|
+
async createTemplateVersion(id, data, options) {
|
|
4726
|
+
return this.post(`/runtime-templates/${id}/versions`, data, options);
|
|
4727
|
+
}
|
|
4728
|
+
async listTemplateVersions(id, options) {
|
|
4729
|
+
return this._get(`/runtime-templates/${id}/versions`, options);
|
|
4730
|
+
}
|
|
4731
|
+
// Workspaces
|
|
4732
|
+
async createWorkspace(data, options) {
|
|
4733
|
+
return this.post("/workspaces", data, options);
|
|
4734
|
+
}
|
|
4735
|
+
async listWorkspaces(params, options) {
|
|
4736
|
+
return this._list("/workspaces", params, options);
|
|
4737
|
+
}
|
|
4738
|
+
async getWorkspace(id, options) {
|
|
4739
|
+
return this._get(`/workspaces/${id}`, options);
|
|
4740
|
+
}
|
|
4741
|
+
async updateWorkspace(id, data, options) {
|
|
4742
|
+
return this.patch(`/workspaces/${id}`, data, options);
|
|
4743
|
+
}
|
|
4744
|
+
async addOsAccount(workspaceId, data, options) {
|
|
4745
|
+
return this.post(`/workspaces/${workspaceId}/os-accounts`, data, options);
|
|
4746
|
+
}
|
|
4747
|
+
};
|
|
4748
|
+
|
|
4749
|
+
// src/services/agent-projects.ts
|
|
4750
|
+
var AgentProjectsService = class extends ServiceModule {
|
|
4751
|
+
constructor() {
|
|
4752
|
+
super(...arguments);
|
|
4753
|
+
this.basePath = "/v1/agent-projects";
|
|
4754
|
+
}
|
|
4755
|
+
withAppId(path, applicationId) {
|
|
4756
|
+
return applicationId ? this.withQuery(path, { application_id: applicationId }) : path;
|
|
4757
|
+
}
|
|
4758
|
+
// Projects
|
|
4759
|
+
async createProject(data, applicationId, options) {
|
|
4760
|
+
return this.post(this.withAppId("/projects", applicationId), data, options);
|
|
4761
|
+
}
|
|
4762
|
+
async listProjects(params, options) {
|
|
4763
|
+
return this._list("/projects", params, options);
|
|
4764
|
+
}
|
|
4765
|
+
async getProject(id, applicationId, options) {
|
|
4766
|
+
return this._get(this.withAppId(`/projects/${id}`, applicationId), options);
|
|
4767
|
+
}
|
|
4768
|
+
async updateProject(id, data, applicationId, options) {
|
|
4769
|
+
return this.patch(this.withAppId(`/projects/${id}`, applicationId), data, options);
|
|
4770
|
+
}
|
|
4771
|
+
// Members (use auth user_id)
|
|
4772
|
+
async addMember(projectId, data, applicationId, options) {
|
|
4773
|
+
return this.post(this.withAppId(`/projects/${projectId}/members`, applicationId), data, options);
|
|
4774
|
+
}
|
|
4775
|
+
async listMembers(projectId, applicationId, options) {
|
|
4776
|
+
const result = await this._get(
|
|
4777
|
+
this.withAppId(`/projects/${projectId}/members`, applicationId),
|
|
4778
|
+
options
|
|
4779
|
+
);
|
|
4780
|
+
return { data: result.data?.members ?? [], error: result.error };
|
|
4781
|
+
}
|
|
4782
|
+
async updateMember(projectId, userId, data, applicationId, options) {
|
|
4783
|
+
return this.patch(
|
|
4784
|
+
this.withAppId(`/projects/${projectId}/members/${userId}`, applicationId),
|
|
4785
|
+
data,
|
|
4786
|
+
options
|
|
4787
|
+
);
|
|
4788
|
+
}
|
|
4789
|
+
async removeMember(projectId, userId, applicationId, options) {
|
|
4790
|
+
return this.del(this.withAppId(`/projects/${projectId}/members/${userId}`, applicationId), options);
|
|
4791
|
+
}
|
|
4792
|
+
// Tasks
|
|
4793
|
+
async createTask(projectId, data, applicationId, options) {
|
|
4794
|
+
return this.post(this.withAppId(`/projects/${projectId}/tasks`, applicationId), data, options);
|
|
4795
|
+
}
|
|
4796
|
+
async listTasks(projectId, params, options) {
|
|
4797
|
+
return this._list(`/projects/${projectId}/tasks`, params, options);
|
|
4798
|
+
}
|
|
4799
|
+
async getTask(id, applicationId, options) {
|
|
4800
|
+
return this._get(this.withAppId(`/tasks/${id}`, applicationId), options);
|
|
4801
|
+
}
|
|
4802
|
+
async updateTask(id, data, applicationId, options) {
|
|
4803
|
+
return this.patch(this.withAppId(`/tasks/${id}`, applicationId), data, options);
|
|
4804
|
+
}
|
|
4805
|
+
// Lifecycle (use registry agent_id)
|
|
4806
|
+
async claimNext(agentId, applicationId, options) {
|
|
4807
|
+
const result = await this.post(
|
|
4808
|
+
this.withAppId("/tasks/next-available", applicationId),
|
|
4809
|
+
{ agent_id: agentId },
|
|
4810
|
+
options
|
|
4811
|
+
);
|
|
4812
|
+
if (!result.data || typeof result.data !== "object" || !("task_id" in result.data)) {
|
|
4813
|
+
return { data: null, error: result.error };
|
|
4814
|
+
}
|
|
4815
|
+
return result;
|
|
4816
|
+
}
|
|
4817
|
+
async claim(taskId, agentId, applicationId, options) {
|
|
4818
|
+
return this.post(
|
|
4819
|
+
this.withAppId(`/tasks/${taskId}/claim`, applicationId),
|
|
4820
|
+
{ agent_id: agentId },
|
|
4821
|
+
options
|
|
4822
|
+
);
|
|
4823
|
+
}
|
|
4824
|
+
async heartbeat(taskId, agentId, applicationId, options) {
|
|
4825
|
+
return this.post(
|
|
4826
|
+
this.withAppId(`/tasks/${taskId}/heartbeat`, applicationId),
|
|
4827
|
+
{ agent_id: agentId },
|
|
4828
|
+
options
|
|
4829
|
+
);
|
|
4830
|
+
}
|
|
4831
|
+
async submit(taskId, data, applicationId, options) {
|
|
4832
|
+
return this.post(this.withAppId(`/tasks/${taskId}/submit`, applicationId), data, options);
|
|
4833
|
+
}
|
|
4834
|
+
async block(taskId, data, applicationId, options) {
|
|
4835
|
+
return this.post(this.withAppId(`/tasks/${taskId}/block`, applicationId), data, options);
|
|
4836
|
+
}
|
|
4837
|
+
// Assignment
|
|
4838
|
+
async assignAgent(taskId, data, applicationId, options) {
|
|
4839
|
+
return this.post(this.withAppId(`/tasks/${taskId}/assign`, applicationId), data, options);
|
|
4840
|
+
}
|
|
4841
|
+
async unassignAgent(taskId, agentId, applicationId, options) {
|
|
4842
|
+
return this.del(this.withAppId(`/tasks/${taskId}/assign/${agentId}`, applicationId), options);
|
|
4843
|
+
}
|
|
4844
|
+
// History
|
|
4845
|
+
async listAttempts(taskId, applicationId, options) {
|
|
4846
|
+
const result = await this._get(
|
|
4847
|
+
this.withAppId(`/tasks/${taskId}/attempts`, applicationId),
|
|
4848
|
+
options
|
|
4849
|
+
);
|
|
4850
|
+
return { data: result.data?.attempts ?? [], error: result.error };
|
|
4851
|
+
}
|
|
4852
|
+
async listTransitions(taskId, applicationId, options) {
|
|
4853
|
+
const result = await this._get(
|
|
4854
|
+
this.withAppId(`/tasks/${taskId}/transitions`, applicationId),
|
|
4855
|
+
options
|
|
4856
|
+
);
|
|
4857
|
+
return { data: result.data?.transitions ?? [], error: result.error };
|
|
4858
|
+
}
|
|
4859
|
+
// Documents
|
|
4860
|
+
async createDocument(projectId, data, applicationId, options) {
|
|
4861
|
+
return this.post(this.withAppId(`/projects/${projectId}/documents`, applicationId), data, options);
|
|
4862
|
+
}
|
|
4863
|
+
async listDocuments(projectId, applicationId, options) {
|
|
4864
|
+
const result = await this._get(
|
|
4865
|
+
this.withAppId(`/projects/${projectId}/documents`, applicationId),
|
|
4866
|
+
options
|
|
4867
|
+
);
|
|
4868
|
+
return { data: result.data?.documents ?? [], error: result.error };
|
|
4869
|
+
}
|
|
4870
|
+
async deleteDocument(documentId, applicationId, options) {
|
|
4871
|
+
return this.del(this.withAppId(`/documents/${documentId}`, applicationId), options);
|
|
4872
|
+
}
|
|
4873
|
+
// Pipelines
|
|
4874
|
+
async createPipeline(projectId, data, applicationId, options) {
|
|
4875
|
+
return this.post(this.withAppId(`/projects/${projectId}/pipelines`, applicationId), data, options);
|
|
4876
|
+
}
|
|
4877
|
+
async listPipelines(projectId, applicationId, options) {
|
|
4878
|
+
const result = await this._get(
|
|
4879
|
+
this.withAppId(`/projects/${projectId}/pipelines`, applicationId),
|
|
4880
|
+
options
|
|
4881
|
+
);
|
|
4882
|
+
return { data: result.data?.pipelines ?? [], error: result.error };
|
|
4883
|
+
}
|
|
4884
|
+
async createPipelineVersion(pipelineId, data, applicationId, options) {
|
|
4885
|
+
return this.post(
|
|
4886
|
+
this.withAppId(`/pipelines/${pipelineId}/versions`, applicationId),
|
|
4887
|
+
data,
|
|
4888
|
+
options
|
|
4889
|
+
);
|
|
4890
|
+
}
|
|
4891
|
+
async listPipelineVersions(pipelineId, applicationId, options) {
|
|
4892
|
+
const result = await this._get(
|
|
4893
|
+
this.withAppId(`/pipelines/${pipelineId}/versions`, applicationId),
|
|
4894
|
+
options
|
|
4895
|
+
);
|
|
4896
|
+
return { data: result.data?.versions ?? [], error: result.error };
|
|
4897
|
+
}
|
|
4898
|
+
};
|
|
4899
|
+
|
|
4900
|
+
// src/services/agent-tools.ts
|
|
4901
|
+
var AgentToolsService = class extends ServiceModule {
|
|
4902
|
+
constructor() {
|
|
4903
|
+
super(...arguments);
|
|
4904
|
+
this.basePath = "/v1/agent-tools";
|
|
4905
|
+
}
|
|
4906
|
+
// Tools
|
|
4907
|
+
async createTool(data, options) {
|
|
4908
|
+
return this.post("/tools", data, options);
|
|
4909
|
+
}
|
|
4910
|
+
async listTools(params, options) {
|
|
4911
|
+
return this._list("/tools", params, options);
|
|
4912
|
+
}
|
|
4913
|
+
async getTool(id, options) {
|
|
4914
|
+
return this._get(`/tools/${id}`, options);
|
|
4915
|
+
}
|
|
4916
|
+
async createCapability(toolId, data, options) {
|
|
4917
|
+
return this.post(`/tools/${toolId}/capabilities`, data, options);
|
|
4918
|
+
}
|
|
4919
|
+
async listCapabilities(toolId, options) {
|
|
4920
|
+
return this._get(`/tools/${toolId}/capabilities`, options);
|
|
4921
|
+
}
|
|
4922
|
+
// Tool Integrations
|
|
4923
|
+
async createIntegration(data, options) {
|
|
4924
|
+
return this.post("/tool-integrations", data, options);
|
|
4925
|
+
}
|
|
4926
|
+
async listIntegrations(params, options) {
|
|
4927
|
+
return this._list("/tool-integrations", params, options);
|
|
4928
|
+
}
|
|
4929
|
+
async updateIntegration(id, data, options) {
|
|
4930
|
+
return this.patch(`/tool-integrations/${id}`, data, options);
|
|
4931
|
+
}
|
|
4932
|
+
// Credentials
|
|
4933
|
+
async createCredential(data, options) {
|
|
4934
|
+
return this.post("/credentials", data, options);
|
|
4935
|
+
}
|
|
4936
|
+
async listCredentials(params, options) {
|
|
4937
|
+
return this._list("/credentials", params, options);
|
|
4938
|
+
}
|
|
4939
|
+
async updateCredential(id, data, options) {
|
|
4940
|
+
return this.patch(`/credentials/${id}`, data, options);
|
|
4941
|
+
}
|
|
4942
|
+
async createScope(credentialId, data, options) {
|
|
4943
|
+
return this.post(`/credentials/${credentialId}/scopes`, data, options);
|
|
4944
|
+
}
|
|
4945
|
+
async listScopes(credentialId, options) {
|
|
4946
|
+
return this._get(`/credentials/${credentialId}/scopes`, options);
|
|
4947
|
+
}
|
|
4948
|
+
// Entitlements
|
|
4949
|
+
async grantEntitlement(data, options) {
|
|
4950
|
+
return this.post("/agent-tool-entitlements", data, options);
|
|
4951
|
+
}
|
|
4952
|
+
async listEntitlements(params, options) {
|
|
4953
|
+
return this._list("/agent-tool-entitlements", params, options);
|
|
4954
|
+
}
|
|
4955
|
+
async revokeEntitlement(id, options) {
|
|
4956
|
+
return this.del(`/agent-tool-entitlements/${id}`, options);
|
|
4957
|
+
}
|
|
4958
|
+
async authorizeAction(data, options) {
|
|
4959
|
+
return this.post("/authorize-action", data, options);
|
|
4960
|
+
}
|
|
4961
|
+
// Data Sources
|
|
4962
|
+
async createDataSource(data, options) {
|
|
4963
|
+
return this.post("/data-sources", data, options);
|
|
4964
|
+
}
|
|
4965
|
+
async listDataSources(params, options) {
|
|
4966
|
+
return this._list("/data-sources", params, options);
|
|
4967
|
+
}
|
|
4968
|
+
// Data Access Policies
|
|
4969
|
+
async createDataAccessPolicy(data, options) {
|
|
4970
|
+
return this.post("/data-access-policies", data, options);
|
|
4971
|
+
}
|
|
4972
|
+
async listDataAccessPolicies(params, options) {
|
|
4973
|
+
return this._list("/data-access-policies", params, options);
|
|
4974
|
+
}
|
|
4975
|
+
};
|
|
4976
|
+
|
|
4977
|
+
// src/services/agent-models.ts
|
|
4978
|
+
var AgentModelsService = class extends ServiceModule {
|
|
4979
|
+
constructor() {
|
|
4980
|
+
super(...arguments);
|
|
4981
|
+
this.basePath = "/v1/agent-models";
|
|
4982
|
+
}
|
|
4983
|
+
// Providers
|
|
4984
|
+
async createProvider(data, options) {
|
|
4985
|
+
return this.post("/model-providers", data, options);
|
|
4986
|
+
}
|
|
4987
|
+
async listProviders(params, options) {
|
|
4988
|
+
return this._list("/model-providers", params, options);
|
|
4989
|
+
}
|
|
4990
|
+
// Models
|
|
4991
|
+
async createModel(data, options) {
|
|
4992
|
+
return this.post("/models", data, options);
|
|
4993
|
+
}
|
|
4994
|
+
async listModels(params, options) {
|
|
4995
|
+
return this._list("/models", params, options);
|
|
4996
|
+
}
|
|
4997
|
+
async getModel(id, options) {
|
|
4998
|
+
return this._get(`/models/${id}`, options);
|
|
4999
|
+
}
|
|
5000
|
+
async createPricing(modelId, data, options) {
|
|
5001
|
+
return this.post(`/models/${modelId}/pricing`, data, options);
|
|
5002
|
+
}
|
|
5003
|
+
async listPricing(modelId, options) {
|
|
5004
|
+
return this._get(`/models/${modelId}/pricing`, options);
|
|
5005
|
+
}
|
|
5006
|
+
// Entitlements
|
|
5007
|
+
async createEntitlement(data, options) {
|
|
5008
|
+
return this.post("/model-entitlements", data, options);
|
|
5009
|
+
}
|
|
5010
|
+
async listEntitlements(params, options) {
|
|
5011
|
+
return this._list("/model-entitlements", params, options);
|
|
5012
|
+
}
|
|
5013
|
+
async deleteEntitlement(id, options) {
|
|
5014
|
+
return this.del(`/model-entitlements/${id}`, options);
|
|
5015
|
+
}
|
|
5016
|
+
// Usage & Reporting
|
|
5017
|
+
async recordUsage(data, options) {
|
|
5018
|
+
return this.post("/usage-records", data, options);
|
|
5019
|
+
}
|
|
5020
|
+
async listUsage(params, options) {
|
|
5021
|
+
return this._list("/usage-records", params, options);
|
|
5022
|
+
}
|
|
5023
|
+
async getUsageSummary(params, options) {
|
|
5024
|
+
return this._get(this.withQuery("/usage-records/summary", params), options);
|
|
5025
|
+
}
|
|
5026
|
+
async getCostReport(params, options) {
|
|
5027
|
+
return this._get(this.withQuery("/cost-report", params), options);
|
|
5028
|
+
}
|
|
5029
|
+
};
|
|
5030
|
+
|
|
5031
|
+
// src/services/agent-sessions.ts
|
|
5032
|
+
var AgentSessionsService = class extends ServiceModule {
|
|
5033
|
+
constructor() {
|
|
5034
|
+
super(...arguments);
|
|
5035
|
+
this.basePath = "/v1/agent-sessions";
|
|
5036
|
+
}
|
|
5037
|
+
// Sessions
|
|
5038
|
+
async createSession(data, options) {
|
|
5039
|
+
return this.post("/sessions", data, options);
|
|
5040
|
+
}
|
|
5041
|
+
async listSessions(params, options) {
|
|
5042
|
+
return this._list("/sessions", params, options);
|
|
5043
|
+
}
|
|
5044
|
+
async getSession(id, options) {
|
|
5045
|
+
return this._get(`/sessions/${id}`, options);
|
|
5046
|
+
}
|
|
5047
|
+
async startSession(id, options) {
|
|
5048
|
+
return this.post(`/sessions/${id}/start`, void 0, options);
|
|
5049
|
+
}
|
|
5050
|
+
async endSession(id, data, options) {
|
|
5051
|
+
return this.post(`/sessions/${id}/end`, data, options);
|
|
5052
|
+
}
|
|
5053
|
+
// Logs
|
|
5054
|
+
async appendLog(sessionId, data, options) {
|
|
5055
|
+
return this.post(`/sessions/${sessionId}/logs`, data, options);
|
|
5056
|
+
}
|
|
5057
|
+
async listLogs(sessionId, options) {
|
|
5058
|
+
return this._get(`/sessions/${sessionId}/logs`, options);
|
|
5059
|
+
}
|
|
5060
|
+
// Artifacts
|
|
5061
|
+
async addArtifact(sessionId, data, options) {
|
|
5062
|
+
return this.post(`/sessions/${sessionId}/artifacts`, data, options);
|
|
5063
|
+
}
|
|
5064
|
+
async listArtifacts(sessionId, options) {
|
|
5065
|
+
return this._get(`/sessions/${sessionId}/artifacts`, options);
|
|
5066
|
+
}
|
|
5067
|
+
};
|
|
5068
|
+
|
|
4523
5069
|
// src/index.ts
|
|
4524
5070
|
var ScaleMule = class {
|
|
4525
5071
|
constructor(config) {
|
|
@@ -4554,6 +5100,12 @@ var ScaleMule = class {
|
|
|
4554
5100
|
this.flagContent = new FlagContentService(this._client);
|
|
4555
5101
|
this.compliance = new ComplianceService(this._client);
|
|
4556
5102
|
this.orchestrator = new OrchestratorService(this._client);
|
|
5103
|
+
this.agentAuth = new AgentAuthService(this._client);
|
|
5104
|
+
this.agents = new AgentsService(this._client);
|
|
5105
|
+
this.agentProjects = new AgentProjectsService(this._client);
|
|
5106
|
+
this.agentTools = new AgentToolsService(this._client);
|
|
5107
|
+
this.agentModels = new AgentModelsService(this._client);
|
|
5108
|
+
this.agentSessions = new AgentSessionsService(this._client);
|
|
4557
5109
|
}
|
|
4558
5110
|
/**
|
|
4559
5111
|
* Initialize the client — loads persisted session from storage.
|
|
@@ -4606,6 +5158,12 @@ var index_default = ScaleMule;
|
|
|
4606
5158
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4607
5159
|
0 && (module.exports = {
|
|
4608
5160
|
AccountsService,
|
|
5161
|
+
AgentAuthService,
|
|
5162
|
+
AgentModelsService,
|
|
5163
|
+
AgentProjectsService,
|
|
5164
|
+
AgentSessionsService,
|
|
5165
|
+
AgentToolsService,
|
|
5166
|
+
AgentsService,
|
|
4609
5167
|
AnalyticsService,
|
|
4610
5168
|
AuthService,
|
|
4611
5169
|
BillingService,
|