@standardagents/builder 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-in-routes.js +1650 -502
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/ApiKeysView.js +1 -1
- package/dist/client/CenteredContentView.js +1 -1
- package/dist/client/CompositionView.js +5 -5
- package/dist/client/ConfirmDialog.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/CopyButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/DataTable.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/client/JsonViewer.js +1 -1
- package/dist/client/LoginView.js +1 -1
- package/dist/client/Modal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ModelsView.js +1 -1
- package/dist/client/PromptEditView.js +1 -1
- package/dist/client/PromptModal.js +1 -1
- package/dist/client/PromptsView.js +1 -1
- package/dist/client/ProvidersView.js +2 -2
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang.js +19 -19
- package/dist/client/ToolsView.js +1 -1
- package/dist/client/UsersView.js +1 -1
- package/dist/client/VariablesView.js +1 -0
- package/dist/client/assets/CompositionView.css +1 -1
- package/dist/client/assets/ThreadInspectorPane.css +1 -1
- package/dist/client/assets/VariablesView.css +1 -0
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +6 -6
- package/dist/{index-D6_KjpVv.d.ts → index-BwqQtJ4r.d.ts} +47 -0
- package/dist/index.d.ts +116 -4
- package/dist/index.js +1547 -706
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +548 -372
- package/dist/plugin.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
package/dist/built-in-routes.js
CHANGED
|
@@ -5,7 +5,9 @@ import * as z128 from 'zod/v4';
|
|
|
5
5
|
import { z as z$1 } from 'zod/v4';
|
|
6
6
|
import z179, { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
7
7
|
import * as fs2 from 'fs';
|
|
8
|
+
import fs2__default from 'fs';
|
|
8
9
|
import * as path4 from 'path';
|
|
10
|
+
import path4__default from 'path';
|
|
9
11
|
import MagicString from 'magic-string';
|
|
10
12
|
import { exec } from 'child_process';
|
|
11
13
|
import { promisify } from 'util';
|
|
@@ -880,8 +882,10 @@ var init_ProviderRegistry = __esm({
|
|
|
880
882
|
ProviderRegistryImpl = class {
|
|
881
883
|
providerCache = /* @__PURE__ */ new Map();
|
|
882
884
|
providerOverrideFn = null;
|
|
885
|
+
providerOverrideRevision = 0;
|
|
883
886
|
setProviderOverride(fn) {
|
|
884
887
|
this.providerOverrideFn = fn;
|
|
888
|
+
this.providerOverrideRevision += 1;
|
|
885
889
|
}
|
|
886
890
|
/**
|
|
887
891
|
* Get provider for a model.
|
|
@@ -901,17 +905,6 @@ var init_ProviderRegistry = __esm({
|
|
|
901
905
|
if (!modelDef) {
|
|
902
906
|
throw new Error(`Model not found: ${modelName}`);
|
|
903
907
|
}
|
|
904
|
-
if (this.providerOverrideFn) {
|
|
905
|
-
const overrideFingerprint = this.getProviderFingerprint("override", modelDef);
|
|
906
|
-
const cached2 = this.providerCache.get(modelName);
|
|
907
|
-
if (cached2?.fingerprint === overrideFingerprint) {
|
|
908
|
-
return this.buildResult(cached2.provider, modelDef);
|
|
909
|
-
}
|
|
910
|
-
const overrideProvider = this.providerOverrideFn(modelName, modelDef, env2);
|
|
911
|
-
if (overrideProvider) {
|
|
912
|
-
return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
908
|
if (typeof modelDef.provider !== "function") {
|
|
916
909
|
throw new Error(
|
|
917
910
|
`Model '${modelName}' has invalid provider. Provider must be a ProviderFactory function imported from a provider package (e.g., @standardagents/openai).`
|
|
@@ -919,29 +912,45 @@ var init_ProviderRegistry = __esm({
|
|
|
919
912
|
}
|
|
920
913
|
const providerFactory = modelDef.provider;
|
|
921
914
|
const providerName = providerFactory({ apiKey: "" }).name;
|
|
922
|
-
const fingerprint = this.getProviderFingerprint(providerName, modelDef);
|
|
923
|
-
const cached = this.providerCache.get(modelName);
|
|
924
|
-
if (cached?.fingerprint === fingerprint) {
|
|
925
|
-
return this.buildResult(cached.provider, modelDef);
|
|
926
|
-
}
|
|
927
915
|
if (providerName === "test") {
|
|
916
|
+
const fingerprint = this.getProviderFingerprint(providerName, modelDef);
|
|
917
|
+
const cached = this.providerCache.get(modelName);
|
|
918
|
+
if (cached?.fingerprint === fingerprint) {
|
|
919
|
+
return this.buildResult(cached.provider, modelDef);
|
|
920
|
+
}
|
|
928
921
|
return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint);
|
|
929
922
|
}
|
|
930
923
|
const apiKey = this.getApiKeyForProvider(providerName, env2);
|
|
931
|
-
if (
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
config.baseUrl
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
924
|
+
if (apiKey) {
|
|
925
|
+
const config = { apiKey };
|
|
926
|
+
if (modelDef.providerOptions?.baseUrl) {
|
|
927
|
+
config.baseUrl = modelDef.providerOptions.baseUrl;
|
|
928
|
+
}
|
|
929
|
+
if (providerName === "cloudflare" && !config.baseUrl && env2.CLOUDFLARE_ACCOUNT_ID) {
|
|
930
|
+
config.baseUrl = `https://api.cloudflare.com/client/v4/accounts/${env2.CLOUDFLARE_ACCOUNT_ID}/ai/v1`;
|
|
931
|
+
}
|
|
932
|
+
if (providerName === "cloudflare" && env2.CLOUDFLARE_ACCOUNT_ID) {
|
|
933
|
+
config.accountId = env2.CLOUDFLARE_ACCOUNT_ID;
|
|
934
|
+
}
|
|
935
|
+
const fingerprint = this.getProviderFingerprint(providerName, modelDef, config);
|
|
936
|
+
const cached = this.providerCache.get(modelName);
|
|
937
|
+
if (cached?.fingerprint === fingerprint) {
|
|
938
|
+
return this.buildResult(cached.provider, modelDef);
|
|
939
|
+
}
|
|
940
|
+
return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
|
|
940
941
|
}
|
|
941
|
-
if (
|
|
942
|
-
|
|
942
|
+
if (this.providerOverrideFn) {
|
|
943
|
+
const overrideFingerprint = this.getProviderFingerprint(`override:${this.providerOverrideRevision}`, modelDef);
|
|
944
|
+
const overrideCached = this.providerCache.get(modelName);
|
|
945
|
+
if (overrideCached?.fingerprint === overrideFingerprint) {
|
|
946
|
+
return this.buildResult(overrideCached.provider, modelDef);
|
|
947
|
+
}
|
|
948
|
+
const overrideProvider = this.providerOverrideFn(modelName, modelDef, env2);
|
|
949
|
+
if (overrideProvider) {
|
|
950
|
+
return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
|
|
951
|
+
}
|
|
943
952
|
}
|
|
944
|
-
|
|
953
|
+
throw new Error(`No API key found for provider: ${providerName}. Set the provider key or STANDARD_AGENTS_API_KEY.`);
|
|
945
954
|
}
|
|
946
955
|
buildResult(provider, modelDef) {
|
|
947
956
|
return { provider, modelName: modelDef.model, modelDef };
|
|
@@ -950,10 +959,12 @@ var init_ProviderRegistry = __esm({
|
|
|
950
959
|
this.providerCache.set(modelName, { provider, fingerprint });
|
|
951
960
|
return this.buildResult(provider, modelDef);
|
|
952
961
|
}
|
|
953
|
-
getProviderFingerprint(providerName, modelDef) {
|
|
962
|
+
getProviderFingerprint(providerName, modelDef, config) {
|
|
954
963
|
return JSON.stringify({
|
|
955
964
|
providerName,
|
|
956
|
-
baseUrl: modelDef.providerOptions?.baseUrl ?? null
|
|
965
|
+
baseUrl: modelDef.providerOptions?.baseUrl ?? null,
|
|
966
|
+
apiKey: config?.apiKey ?? null,
|
|
967
|
+
accountId: config?.accountId ?? null
|
|
957
968
|
});
|
|
958
969
|
}
|
|
959
970
|
/**
|
|
@@ -1157,11 +1168,11 @@ function stripBase64FromMessages(messages, imagePathMap) {
|
|
|
1157
1168
|
const data = part.data;
|
|
1158
1169
|
if (typeof data === "string") {
|
|
1159
1170
|
if (data.startsWith("data:") || data.length > 1e3) {
|
|
1160
|
-
const
|
|
1171
|
+
const path9 = imagePathMap?.get(data);
|
|
1161
1172
|
return {
|
|
1162
1173
|
...part,
|
|
1163
1174
|
data: "[base64 omitted]",
|
|
1164
|
-
...
|
|
1175
|
+
...path9 ? { path: path9 } : {}
|
|
1165
1176
|
};
|
|
1166
1177
|
}
|
|
1167
1178
|
}
|
|
@@ -1838,6 +1849,7 @@ var init_LLMRequest = __esm({
|
|
|
1838
1849
|
try {
|
|
1839
1850
|
const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
|
|
1840
1851
|
const providerName = response._provider?.name;
|
|
1852
|
+
const standardAgentsRouterUsed = providerName === "platform";
|
|
1841
1853
|
const resolvedPricing = resolveModelPricing(modelDef, providerName);
|
|
1842
1854
|
const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
|
|
1843
1855
|
const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
|
|
@@ -1911,6 +1923,7 @@ var init_LLMRequest = __esm({
|
|
|
1911
1923
|
cost_total: cost_total ?? void 0,
|
|
1912
1924
|
actual_provider: actualProvider ?? void 0,
|
|
1913
1925
|
// Store actual provider separately (e.g., from OpenRouter)
|
|
1926
|
+
standard_agents_router_used: standardAgentsRouterUsed,
|
|
1914
1927
|
is_complete: true,
|
|
1915
1928
|
// Now complete
|
|
1916
1929
|
reasoning_content: response.reasoning_content ?? void 0,
|
|
@@ -1938,8 +1951,9 @@ var init_LLMRequest = __esm({
|
|
|
1938
1951
|
is_complete = ?13,
|
|
1939
1952
|
reasoning_content = ?14,
|
|
1940
1953
|
provider_tools = ?15,
|
|
1941
|
-
actual_provider = ?16
|
|
1942
|
-
|
|
1954
|
+
actual_provider = ?16,
|
|
1955
|
+
standard_agents_router_used = ?17
|
|
1956
|
+
WHERE id = ?18
|
|
1943
1957
|
`,
|
|
1944
1958
|
logData.response_body,
|
|
1945
1959
|
logData.input_tokens,
|
|
@@ -1957,6 +1971,7 @@ var init_LLMRequest = __esm({
|
|
|
1957
1971
|
logData.reasoning_content,
|
|
1958
1972
|
providerToolsJson,
|
|
1959
1973
|
actualProvider,
|
|
1974
|
+
standardAgentsRouterUsed ? 1 : 0,
|
|
1960
1975
|
logId
|
|
1961
1976
|
);
|
|
1962
1977
|
}
|
|
@@ -2037,11 +2052,11 @@ var init_LLMRequest = __esm({
|
|
|
2037
2052
|
...choice.message,
|
|
2038
2053
|
images: choice.message?.images?.map(
|
|
2039
2054
|
(img) => {
|
|
2040
|
-
const
|
|
2041
|
-
if (
|
|
2055
|
+
const path9 = img._id ? imagePathMap.get(img._id) : void 0;
|
|
2056
|
+
if (path9) {
|
|
2042
2057
|
return {
|
|
2043
2058
|
type: img.type,
|
|
2044
|
-
image_url: { url:
|
|
2059
|
+
image_url: { url: path9 }
|
|
2045
2060
|
};
|
|
2046
2061
|
}
|
|
2047
2062
|
return img;
|
|
@@ -2419,20 +2434,20 @@ function detectStorageBackend(location) {
|
|
|
2419
2434
|
return "url";
|
|
2420
2435
|
return "local";
|
|
2421
2436
|
}
|
|
2422
|
-
function basename(
|
|
2423
|
-
const parts =
|
|
2437
|
+
function basename(path9) {
|
|
2438
|
+
const parts = path9.split("/").filter(Boolean);
|
|
2424
2439
|
return parts[parts.length - 1] || "";
|
|
2425
2440
|
}
|
|
2426
|
-
function normalizePath(
|
|
2427
|
-
let normalized =
|
|
2441
|
+
function normalizePath(path9) {
|
|
2442
|
+
let normalized = path9.replace(/\/+/g, "/");
|
|
2428
2443
|
if (!normalized.startsWith("/")) normalized = "/" + normalized;
|
|
2429
2444
|
if (normalized.length > 1 && normalized.endsWith("/")) {
|
|
2430
2445
|
normalized = normalized.slice(0, -1);
|
|
2431
2446
|
}
|
|
2432
2447
|
return normalized;
|
|
2433
2448
|
}
|
|
2434
|
-
function dirname(
|
|
2435
|
-
const normalized = normalizePath(
|
|
2449
|
+
function dirname(path9) {
|
|
2450
|
+
const normalized = normalizePath(path9);
|
|
2436
2451
|
const lastSlash = normalized.lastIndexOf("/");
|
|
2437
2452
|
if (lastSlash <= 0) return "/";
|
|
2438
2453
|
return normalized.slice(0, lastSlash);
|
|
@@ -2557,8 +2572,8 @@ var init_files = __esm({
|
|
|
2557
2572
|
* Write a file to storage.
|
|
2558
2573
|
* Files > CHUNK_SIZE are automatically chunked into file_chunks table.
|
|
2559
2574
|
*/
|
|
2560
|
-
async writeFile(
|
|
2561
|
-
const normalizedPath = normalizePath(
|
|
2575
|
+
async writeFile(path9, data, mimeType, options) {
|
|
2576
|
+
const normalizedPath = normalizePath(path9);
|
|
2562
2577
|
const name15 = basename(normalizedPath);
|
|
2563
2578
|
const isText = isTextMimeType(mimeType);
|
|
2564
2579
|
const now = Date.now();
|
|
@@ -2670,8 +2685,8 @@ var init_files = __esm({
|
|
|
2670
2685
|
/**
|
|
2671
2686
|
* Link to an external file (URL, S3, R2)
|
|
2672
2687
|
*/
|
|
2673
|
-
async linkFile(
|
|
2674
|
-
const normalizedPath = normalizePath(
|
|
2688
|
+
async linkFile(path9, location, options) {
|
|
2689
|
+
const normalizedPath = normalizePath(path9);
|
|
2675
2690
|
const name15 = basename(normalizedPath);
|
|
2676
2691
|
const storage = detectStorageBackend(location);
|
|
2677
2692
|
const now = Date.now();
|
|
@@ -2710,8 +2725,8 @@ var init_files = __esm({
|
|
|
2710
2725
|
* WARNING: For large chunked files, this loads the entire file into memory.
|
|
2711
2726
|
* Use streamFile() for memory-efficient access to large files.
|
|
2712
2727
|
*/
|
|
2713
|
-
async readFile(
|
|
2714
|
-
const normalizedPath = normalizePath(
|
|
2728
|
+
async readFile(path9) {
|
|
2729
|
+
const normalizedPath = normalizePath(path9);
|
|
2715
2730
|
const cursor = await this.sql.exec(
|
|
2716
2731
|
`SELECT data, content, storage, is_chunked, chunk_count FROM files WHERE path = ? AND is_directory = 0`,
|
|
2717
2732
|
normalizedPath
|
|
@@ -2763,8 +2778,8 @@ var init_files = __esm({
|
|
|
2763
2778
|
* Memory-efficient way to read large chunked files.
|
|
2764
2779
|
* Yields one chunk at a time for streaming HTTP responses.
|
|
2765
2780
|
*/
|
|
2766
|
-
async *streamFile(
|
|
2767
|
-
const normalizedPath = normalizePath(
|
|
2781
|
+
async *streamFile(path9) {
|
|
2782
|
+
const normalizedPath = normalizePath(path9);
|
|
2768
2783
|
const cursor = await this.sql.exec(
|
|
2769
2784
|
`SELECT data, content, storage, is_chunked, chunk_count FROM files WHERE path = ? AND is_directory = 0`,
|
|
2770
2785
|
normalizedPath
|
|
@@ -2798,8 +2813,8 @@ var init_files = __esm({
|
|
|
2798
2813
|
/**
|
|
2799
2814
|
* Read text file content
|
|
2800
2815
|
*/
|
|
2801
|
-
async readTextFile(
|
|
2802
|
-
const normalizedPath = normalizePath(
|
|
2816
|
+
async readTextFile(path9) {
|
|
2817
|
+
const normalizedPath = normalizePath(path9);
|
|
2803
2818
|
const cursor = await this.sql.exec(
|
|
2804
2819
|
`SELECT content, data, storage FROM files WHERE path = ? AND is_directory = 0`,
|
|
2805
2820
|
normalizedPath
|
|
@@ -2817,8 +2832,8 @@ var init_files = __esm({
|
|
|
2817
2832
|
/**
|
|
2818
2833
|
* Get file metadata (stat)
|
|
2819
2834
|
*/
|
|
2820
|
-
async stat(
|
|
2821
|
-
const normalizedPath = normalizePath(
|
|
2835
|
+
async stat(path9) {
|
|
2836
|
+
const normalizedPath = normalizePath(path9);
|
|
2822
2837
|
const cursor = await this.sql.exec(
|
|
2823
2838
|
`SELECT path, name, mime_type, storage, location, size, metadata, is_directory, created_at, width, height, is_chunked, chunk_count
|
|
2824
2839
|
FROM files WHERE path = ?`,
|
|
@@ -2831,8 +2846,8 @@ var init_files = __esm({
|
|
|
2831
2846
|
/**
|
|
2832
2847
|
* Check if file or directory exists
|
|
2833
2848
|
*/
|
|
2834
|
-
async exists(
|
|
2835
|
-
const normalizedPath = normalizePath(
|
|
2849
|
+
async exists(path9) {
|
|
2850
|
+
const normalizedPath = normalizePath(path9);
|
|
2836
2851
|
const cursor = await this.sql.exec(
|
|
2837
2852
|
`SELECT COUNT(*) as count FROM files WHERE path = ?`,
|
|
2838
2853
|
normalizedPath
|
|
@@ -2842,8 +2857,8 @@ var init_files = __esm({
|
|
|
2842
2857
|
/**
|
|
2843
2858
|
* Delete a file
|
|
2844
2859
|
*/
|
|
2845
|
-
async unlink(
|
|
2846
|
-
const normalizedPath = normalizePath(
|
|
2860
|
+
async unlink(path9) {
|
|
2861
|
+
const normalizedPath = normalizePath(path9);
|
|
2847
2862
|
await this.sql.exec(
|
|
2848
2863
|
`DELETE FROM files WHERE path = ? AND is_directory = 0`,
|
|
2849
2864
|
normalizedPath
|
|
@@ -2853,8 +2868,8 @@ var init_files = __esm({
|
|
|
2853
2868
|
/**
|
|
2854
2869
|
* Create a directory marker
|
|
2855
2870
|
*/
|
|
2856
|
-
async mkdir(
|
|
2857
|
-
const normalizedPath = normalizePath(
|
|
2871
|
+
async mkdir(path9) {
|
|
2872
|
+
const normalizedPath = normalizePath(path9);
|
|
2858
2873
|
const name15 = basename(normalizedPath);
|
|
2859
2874
|
const now = Date.now();
|
|
2860
2875
|
await this.sql.exec(
|
|
@@ -2879,8 +2894,8 @@ var init_files = __esm({
|
|
|
2879
2894
|
/**
|
|
2880
2895
|
* List directory contents
|
|
2881
2896
|
*/
|
|
2882
|
-
async readdir(
|
|
2883
|
-
const normalizedPath = normalizePath(
|
|
2897
|
+
async readdir(path9) {
|
|
2898
|
+
const normalizedPath = normalizePath(path9);
|
|
2884
2899
|
const prefix = normalizedPath === "/" ? "/" : normalizedPath + "/";
|
|
2885
2900
|
const cursor = await this.sql.exec(
|
|
2886
2901
|
`SELECT path, name, mime_type, storage, location, size, metadata, is_directory, created_at
|
|
@@ -2898,8 +2913,8 @@ var init_files = __esm({
|
|
|
2898
2913
|
/**
|
|
2899
2914
|
* Remove empty directory
|
|
2900
2915
|
*/
|
|
2901
|
-
async rmdir(
|
|
2902
|
-
const normalizedPath = normalizePath(
|
|
2916
|
+
async rmdir(path9) {
|
|
2917
|
+
const normalizedPath = normalizePath(path9);
|
|
2903
2918
|
const prefix = normalizedPath + "/";
|
|
2904
2919
|
const cursor = await this.sql.exec(
|
|
2905
2920
|
`SELECT COUNT(*) as count FROM files WHERE path LIKE ? || '%'`,
|
|
@@ -2941,8 +2956,8 @@ var init_files = __esm({
|
|
|
2941
2956
|
/**
|
|
2942
2957
|
* Get thumbnail for an image
|
|
2943
2958
|
*/
|
|
2944
|
-
async getThumbnail(
|
|
2945
|
-
const normalizedPath = normalizePath(
|
|
2959
|
+
async getThumbnail(path9) {
|
|
2960
|
+
const normalizedPath = normalizePath(path9);
|
|
2946
2961
|
const cursor = await this.sql.exec(
|
|
2947
2962
|
`SELECT thumbnail FROM files WHERE path = ? AND is_directory = 0`,
|
|
2948
2963
|
normalizedPath
|
|
@@ -3283,8 +3298,8 @@ var init_ToolExecutor = __esm({
|
|
|
3283
3298
|
const validation = argsSchema.safeParse(args);
|
|
3284
3299
|
if (!validation.success) {
|
|
3285
3300
|
const errorMessage = validation.error.issues.map((issue) => {
|
|
3286
|
-
const
|
|
3287
|
-
return `[${
|
|
3301
|
+
const path9 = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
|
|
3302
|
+
return `[${path9}] ${issue.message}`;
|
|
3288
3303
|
}).join("; ");
|
|
3289
3304
|
return {
|
|
3290
3305
|
status: "error",
|
|
@@ -4403,8 +4418,8 @@ Reference: ${referenceId}` : `Reference: ${referenceId}`;
|
|
|
4403
4418
|
}
|
|
4404
4419
|
return [];
|
|
4405
4420
|
}
|
|
4406
|
-
static inferMimeTypeFromPath(
|
|
4407
|
-
const normalized =
|
|
4421
|
+
static inferMimeTypeFromPath(path9) {
|
|
4422
|
+
const normalized = path9.toLowerCase();
|
|
4408
4423
|
if (normalized.endsWith(".png")) return "image/png";
|
|
4409
4424
|
if (normalized.endsWith(".jpg") || normalized.endsWith(".jpeg")) return "image/jpeg";
|
|
4410
4425
|
if (normalized.endsWith(".webp")) return "image/webp";
|
|
@@ -4443,7 +4458,7 @@ Reference: ${referenceId}` : `Reference: ${referenceId}`;
|
|
|
4443
4458
|
ext: value.slice(lastDot + 1).toLowerCase()
|
|
4444
4459
|
};
|
|
4445
4460
|
}
|
|
4446
|
-
static resolveAttachmentMimeType(sourceMimeType, fallbackMimeType,
|
|
4461
|
+
static resolveAttachmentMimeType(sourceMimeType, fallbackMimeType, path9) {
|
|
4447
4462
|
const source = sourceMimeType?.trim();
|
|
4448
4463
|
if (source && source !== "application/octet-stream") {
|
|
4449
4464
|
return source;
|
|
@@ -4452,7 +4467,7 @@ Reference: ${referenceId}` : `Reference: ${referenceId}`;
|
|
|
4452
4467
|
if (fallback && fallback !== "application/octet-stream") {
|
|
4453
4468
|
return fallback;
|
|
4454
4469
|
}
|
|
4455
|
-
return this.inferMimeTypeFromPath(
|
|
4470
|
+
return this.inferMimeTypeFromPath(path9) ?? source ?? fallback ?? "application/octet-stream";
|
|
4456
4471
|
}
|
|
4457
4472
|
static buildAttachmentTargetPath(preferredName, mimeType, sourcePath) {
|
|
4458
4473
|
const safeName = this.sanitizeFilename(preferredName);
|
|
@@ -4548,8 +4563,8 @@ Reference: ${referenceId}` : `Reference: ${referenceId}`;
|
|
|
4548
4563
|
}
|
|
4549
4564
|
return copied;
|
|
4550
4565
|
}
|
|
4551
|
-
static async readAttachmentDataFromSource(sourceThread,
|
|
4552
|
-
const sourceData = await sourceThread.readFile(
|
|
4566
|
+
static async readAttachmentDataFromSource(sourceThread, path9, sourceFile) {
|
|
4567
|
+
const sourceData = await sourceThread.readFile(path9);
|
|
4553
4568
|
if (sourceData.success && sourceData.data) {
|
|
4554
4569
|
return sourceData.data;
|
|
4555
4570
|
}
|
|
@@ -4583,7 +4598,7 @@ Reference: ${referenceId}` : `Reference: ${referenceId}`;
|
|
|
4583
4598
|
if (!attachments || attachments.length === 0) {
|
|
4584
4599
|
return "";
|
|
4585
4600
|
}
|
|
4586
|
-
const paths = attachments.map((attachment) => attachment.path).filter((
|
|
4601
|
+
const paths = attachments.map((attachment) => attachment.path).filter((path9) => typeof path9 === "string" && path9.length > 0);
|
|
4587
4602
|
if (paths.length === 0) {
|
|
4588
4603
|
return "";
|
|
4589
4604
|
}
|
|
@@ -4879,7 +4894,7 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
4879
4894
|
mappedAttachmentValue
|
|
4880
4895
|
);
|
|
4881
4896
|
const resolvedPaths = new Set(mappedRefs.map((ref) => ref.path));
|
|
4882
|
-
const missingPaths = candidatePaths.filter((
|
|
4897
|
+
const missingPaths = candidatePaths.filter((path9) => !resolvedPaths.has(path9));
|
|
4883
4898
|
if (candidatePaths.length === 0 || missingPaths.length > 0) {
|
|
4884
4899
|
processedResult = {
|
|
4885
4900
|
status: "error",
|
|
@@ -5033,8 +5048,8 @@ ${attachmentPaths}`;
|
|
|
5033
5048
|
if (mimeType.startsWith("image/")) {
|
|
5034
5049
|
return true;
|
|
5035
5050
|
}
|
|
5036
|
-
const
|
|
5037
|
-
return
|
|
5051
|
+
const path9 = ref.path.toLowerCase();
|
|
5052
|
+
return path9.endsWith(".png") || path9.endsWith(".jpg") || path9.endsWith(".jpeg") || path9.endsWith(".webp") || path9.endsWith(".gif") || path9.endsWith(".bmp") || path9.endsWith(".svg");
|
|
5038
5053
|
});
|
|
5039
5054
|
if (imageRefs.length === 0) {
|
|
5040
5055
|
return;
|
|
@@ -5100,27 +5115,27 @@ ${attachmentPaths}`;
|
|
|
5100
5115
|
*/
|
|
5101
5116
|
static async processToolAttachments(attachments, state) {
|
|
5102
5117
|
const { FileStorage: FileStorage2 } = await Promise.resolve().then(() => (init_files(), files_exports));
|
|
5103
|
-
const
|
|
5118
|
+
const fs7 = new FileStorage2(state.storage.sql);
|
|
5104
5119
|
const refs = [];
|
|
5105
5120
|
for (const attachment of attachments) {
|
|
5106
5121
|
try {
|
|
5107
5122
|
const attachmentId = crypto.randomUUID();
|
|
5108
5123
|
const timestamp = Date.now();
|
|
5109
5124
|
const ext = attachment.mimeType === "image/png" ? "png" : attachment.mimeType === "image/jpeg" ? "jpg" : attachment.mimeType === "image/gif" ? "gif" : attachment.mimeType === "image/webp" ? "webp" : attachment.name.split(".").pop() || "bin";
|
|
5110
|
-
const
|
|
5125
|
+
const path9 = `/attachments/${timestamp}-${attachmentId}.${ext}`;
|
|
5111
5126
|
const binaryString = atob(attachment.data);
|
|
5112
5127
|
const dataBuffer = new Uint8Array(binaryString.length);
|
|
5113
5128
|
for (let i = 0; i < binaryString.length; i++) {
|
|
5114
5129
|
dataBuffer[i] = binaryString.charCodeAt(i);
|
|
5115
5130
|
}
|
|
5116
|
-
await
|
|
5131
|
+
await fs7.writeFile(path9, dataBuffer.buffer, attachment.mimeType, {
|
|
5117
5132
|
width: attachment.width,
|
|
5118
5133
|
height: attachment.height
|
|
5119
5134
|
});
|
|
5120
5135
|
const ref = {
|
|
5121
5136
|
id: attachmentId,
|
|
5122
5137
|
type: "file",
|
|
5123
|
-
path:
|
|
5138
|
+
path: path9,
|
|
5124
5139
|
name: attachment.name,
|
|
5125
5140
|
mimeType: attachment.mimeType,
|
|
5126
5141
|
size: dataBuffer.byteLength
|
|
@@ -8313,16 +8328,16 @@ ${lines.join("\n\n")}`
|
|
|
8313
8328
|
const base64Data = match2[2];
|
|
8314
8329
|
const ext = mimeType.split("/")[1] || "png";
|
|
8315
8330
|
const attachmentId = crypto.randomUUID();
|
|
8316
|
-
const
|
|
8331
|
+
const path9 = `/attachments/${Date.now()}-${attachmentId}.${ext}`;
|
|
8317
8332
|
try {
|
|
8318
|
-
await state.thread.instance.writeFile(
|
|
8333
|
+
await state.thread.instance.writeFile(path9, base64Data, mimeType);
|
|
8319
8334
|
if (image.id) {
|
|
8320
|
-
imagePathMap.set(image.id,
|
|
8335
|
+
imagePathMap.set(image.id, path9);
|
|
8321
8336
|
}
|
|
8322
8337
|
refs.push({
|
|
8323
8338
|
id: attachmentId,
|
|
8324
8339
|
type: "file",
|
|
8325
|
-
path:
|
|
8340
|
+
path: path9,
|
|
8326
8341
|
name: `generated-${attachmentId}.${ext}`,
|
|
8327
8342
|
mimeType,
|
|
8328
8343
|
size: Math.ceil(base64Data.length * 3 / 4)
|
|
@@ -8383,13 +8398,13 @@ ${lines.join("\n\n")}`
|
|
|
8383
8398
|
const base64Data = imageUrl.slice(base64Index + base64Marker.length);
|
|
8384
8399
|
const ext = mimeType.split("/")[1] || "png";
|
|
8385
8400
|
const attachmentId = crypto.randomUUID();
|
|
8386
|
-
const
|
|
8401
|
+
const path9 = `/attachments/${Date.now()}-${attachmentId}.${ext}`;
|
|
8387
8402
|
try {
|
|
8388
|
-
await state.thread.instance.writeFile(
|
|
8403
|
+
await state.thread.instance.writeFile(path9, base64Data, mimeType);
|
|
8389
8404
|
const attachmentRef = {
|
|
8390
8405
|
id: attachmentId,
|
|
8391
8406
|
type: "file",
|
|
8392
|
-
path:
|
|
8407
|
+
path: path9,
|
|
8393
8408
|
name: `generated-${attachmentId}.${ext}`,
|
|
8394
8409
|
mimeType,
|
|
8395
8410
|
size: Math.ceil(base64Data.length * 3 / 4)
|
|
@@ -8452,7 +8467,7 @@ ${lines.join("\n\n")}`
|
|
|
8452
8467
|
content: "Image generated successfully",
|
|
8453
8468
|
status: "success",
|
|
8454
8469
|
timestamp: Date.now(),
|
|
8455
|
-
attachment_path:
|
|
8470
|
+
attachment_path: path9
|
|
8456
8471
|
});
|
|
8457
8472
|
await state.storage.sql.exec(
|
|
8458
8473
|
`UPDATE logs SET tool_results = ?1 WHERE id = ?2`,
|
|
@@ -8474,7 +8489,7 @@ ${lines.join("\n\n")}`
|
|
|
8474
8489
|
}
|
|
8475
8490
|
}
|
|
8476
8491
|
if (image.id) {
|
|
8477
|
-
imagePathMap.set(image.id,
|
|
8492
|
+
imagePathMap.set(image.id, path9);
|
|
8478
8493
|
}
|
|
8479
8494
|
} catch (error) {
|
|
8480
8495
|
console.error(`[FlowEngine] Failed to store provider tool result for ${toolName}:`, error);
|
|
@@ -9609,32 +9624,32 @@ function prepareBridge(options, reports, logs) {
|
|
|
9609
9624
|
logs
|
|
9610
9625
|
};
|
|
9611
9626
|
}
|
|
9612
|
-
function prepareNamespaceRecord(value,
|
|
9627
|
+
function prepareNamespaceRecord(value, path9, functions) {
|
|
9613
9628
|
const out = {};
|
|
9614
9629
|
for (const [key, namespace] of Object.entries(value)) {
|
|
9615
|
-
out[key] = prepareValueRecord(namespace, `${
|
|
9630
|
+
out[key] = prepareValueRecord(namespace, `${path9}.${key}`, functions);
|
|
9616
9631
|
}
|
|
9617
9632
|
return out;
|
|
9618
9633
|
}
|
|
9619
|
-
function prepareValueRecord(value,
|
|
9634
|
+
function prepareValueRecord(value, path9, functions) {
|
|
9620
9635
|
const out = {};
|
|
9621
9636
|
for (const [key, item] of Object.entries(value)) {
|
|
9622
|
-
out[key] = prepareBridgeValue(item, `${
|
|
9637
|
+
out[key] = prepareBridgeValue(item, `${path9}.${key}`, functions);
|
|
9623
9638
|
}
|
|
9624
9639
|
return out;
|
|
9625
9640
|
}
|
|
9626
|
-
function prepareBridgeValue(value,
|
|
9641
|
+
function prepareBridgeValue(value, path9, functions) {
|
|
9627
9642
|
if (typeof value === "function") {
|
|
9628
|
-
functions.set(
|
|
9629
|
-
return { __agentbuilderType: "function", id:
|
|
9643
|
+
functions.set(path9, value);
|
|
9644
|
+
return { __agentbuilderType: "function", id: path9 };
|
|
9630
9645
|
}
|
|
9631
9646
|
if (isThenable(value)) {
|
|
9632
|
-
const promiseId = `${
|
|
9647
|
+
const promiseId = `${path9}.__promise`;
|
|
9633
9648
|
functions.set(promiseId, async () => value);
|
|
9634
9649
|
return { __agentbuilderType: "promise", id: promiseId };
|
|
9635
9650
|
}
|
|
9636
9651
|
if (Array.isArray(value)) {
|
|
9637
|
-
return value.map((item, index) => prepareBridgeValue(item, `${
|
|
9652
|
+
return value.map((item, index) => prepareBridgeValue(item, `${path9}.${index}`, functions));
|
|
9638
9653
|
}
|
|
9639
9654
|
if (value && typeof value === "object") {
|
|
9640
9655
|
if (value instanceof Date || value instanceof Map || value instanceof Set || ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
|
|
@@ -9645,7 +9660,7 @@ function prepareBridgeValue(value, path8, functions) {
|
|
|
9645
9660
|
}
|
|
9646
9661
|
const out = {};
|
|
9647
9662
|
for (const [key, item] of Object.entries(value)) {
|
|
9648
|
-
out[key] = prepareBridgeValue(item, `${
|
|
9663
|
+
out[key] = prepareBridgeValue(item, `${path9}.${key}`, functions);
|
|
9649
9664
|
}
|
|
9650
9665
|
return out;
|
|
9651
9666
|
}
|
|
@@ -10520,12 +10535,12 @@ function normalizeVirtualModulePath(basePath, specifier) {
|
|
|
10520
10535
|
}
|
|
10521
10536
|
return normalized;
|
|
10522
10537
|
}
|
|
10523
|
-
function dirnameModulePath(
|
|
10524
|
-
const index =
|
|
10525
|
-
return index <= 0 ? "" :
|
|
10538
|
+
function dirnameModulePath(path9) {
|
|
10539
|
+
const index = path9.lastIndexOf("/");
|
|
10540
|
+
return index <= 0 ? "" : path9.slice(0, index);
|
|
10526
10541
|
}
|
|
10527
|
-
function hasModuleExtension(
|
|
10528
|
-
return /\.[A-Za-z0-9]+$/.test(
|
|
10542
|
+
function hasModuleExtension(path9) {
|
|
10543
|
+
return /\.[A-Za-z0-9]+$/.test(path9);
|
|
10529
10544
|
}
|
|
10530
10545
|
function resolveGraphModuleSpecifier(fromPath, specifier, modulePaths) {
|
|
10531
10546
|
const base = normalizeVirtualModulePath(dirnameModulePath(fromPath), specifier);
|
|
@@ -10851,9 +10866,9 @@ function isPlainObject2(value) {
|
|
|
10851
10866
|
const prototype = Object.getPrototypeOf(value);
|
|
10852
10867
|
return prototype === Object.prototype || prototype === null;
|
|
10853
10868
|
}
|
|
10854
|
-
function findUntransferableOption(value,
|
|
10869
|
+
function findUntransferableOption(value, path9, seen = /* @__PURE__ */ new WeakSet()) {
|
|
10855
10870
|
if (typeof value === "function" || typeof value === "symbol") {
|
|
10856
|
-
return
|
|
10871
|
+
return path9;
|
|
10857
10872
|
}
|
|
10858
10873
|
if (!value || typeof value !== "object") {
|
|
10859
10874
|
return null;
|
|
@@ -10867,7 +10882,7 @@ function findUntransferableOption(value, path8, seen = /* @__PURE__ */ new WeakS
|
|
|
10867
10882
|
seen.add(value);
|
|
10868
10883
|
if (Array.isArray(value)) {
|
|
10869
10884
|
for (const [index, item] of value.entries()) {
|
|
10870
|
-
const found = findUntransferableOption(item, `${
|
|
10885
|
+
const found = findUntransferableOption(item, `${path9}.${index}`, seen);
|
|
10871
10886
|
if (found) return found;
|
|
10872
10887
|
}
|
|
10873
10888
|
return null;
|
|
@@ -10875,9 +10890,9 @@ function findUntransferableOption(value, path8, seen = /* @__PURE__ */ new WeakS
|
|
|
10875
10890
|
if (value instanceof Map) {
|
|
10876
10891
|
let index = 0;
|
|
10877
10892
|
for (const [key, item] of value.entries()) {
|
|
10878
|
-
const foundKey = findUntransferableOption(key, `${
|
|
10893
|
+
const foundKey = findUntransferableOption(key, `${path9}.mapKey${index}`, seen);
|
|
10879
10894
|
if (foundKey) return foundKey;
|
|
10880
|
-
const foundValue = findUntransferableOption(item, `${
|
|
10895
|
+
const foundValue = findUntransferableOption(item, `${path9}.mapValue${index}`, seen);
|
|
10881
10896
|
if (foundValue) return foundValue;
|
|
10882
10897
|
index += 1;
|
|
10883
10898
|
}
|
|
@@ -10886,17 +10901,17 @@ function findUntransferableOption(value, path8, seen = /* @__PURE__ */ new WeakS
|
|
|
10886
10901
|
if (value instanceof Set) {
|
|
10887
10902
|
let index = 0;
|
|
10888
10903
|
for (const item of value.values()) {
|
|
10889
|
-
const found = findUntransferableOption(item, `${
|
|
10904
|
+
const found = findUntransferableOption(item, `${path9}.setValue${index}`, seen);
|
|
10890
10905
|
if (found) return found;
|
|
10891
10906
|
index += 1;
|
|
10892
10907
|
}
|
|
10893
10908
|
return null;
|
|
10894
10909
|
}
|
|
10895
10910
|
if (!isPlainObject2(value)) {
|
|
10896
|
-
return
|
|
10911
|
+
return path9;
|
|
10897
10912
|
}
|
|
10898
10913
|
for (const [key, item] of Object.entries(value)) {
|
|
10899
|
-
const found = findUntransferableOption(item, `${
|
|
10914
|
+
const found = findUntransferableOption(item, `${path9}.${key}`, seen);
|
|
10900
10915
|
if (found) return found;
|
|
10901
10916
|
}
|
|
10902
10917
|
return null;
|
|
@@ -11406,7 +11421,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
11406
11421
|
// ─────────────────────────────────────────────────────────────────────────
|
|
11407
11422
|
// File System
|
|
11408
11423
|
// ─────────────────────────────────────────────────────────────────────────
|
|
11409
|
-
async writeFile(
|
|
11424
|
+
async writeFile(path9, data, mimeType, options) {
|
|
11410
11425
|
const isText = this._isTextMimeType(mimeType);
|
|
11411
11426
|
if (isText) {
|
|
11412
11427
|
let textContent;
|
|
@@ -11415,7 +11430,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
11415
11430
|
} else {
|
|
11416
11431
|
textContent = new TextDecoder().decode(data);
|
|
11417
11432
|
}
|
|
11418
|
-
const result = await this._threadInstance.writeTextFile(
|
|
11433
|
+
const result = await this._threadInstance.writeTextFile(path9, textContent, mimeType, options);
|
|
11419
11434
|
return this._mapFileRecord(result.file);
|
|
11420
11435
|
} else {
|
|
11421
11436
|
let base64Data;
|
|
@@ -11435,7 +11450,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
11435
11450
|
}
|
|
11436
11451
|
base64Data = btoa(binary);
|
|
11437
11452
|
}
|
|
11438
|
-
const result = await this._threadInstance.writeFile(
|
|
11453
|
+
const result = await this._threadInstance.writeFile(path9, base64Data, mimeType, options);
|
|
11439
11454
|
return this._mapFileRecord(result.file);
|
|
11440
11455
|
}
|
|
11441
11456
|
}
|
|
@@ -11507,8 +11522,8 @@ var init_ThreadStateImpl = __esm({
|
|
|
11507
11522
|
(type) => mimeType === type || mimeType.startsWith(type + ";")
|
|
11508
11523
|
);
|
|
11509
11524
|
}
|
|
11510
|
-
async readFile(
|
|
11511
|
-
const result = await this._threadInstance.readFile(
|
|
11525
|
+
async readFile(path9) {
|
|
11526
|
+
const result = await this._threadInstance.readFile(path9);
|
|
11512
11527
|
if (!result.success || !result.data) {
|
|
11513
11528
|
return null;
|
|
11514
11529
|
}
|
|
@@ -11519,8 +11534,8 @@ var init_ThreadStateImpl = __esm({
|
|
|
11519
11534
|
}
|
|
11520
11535
|
return bytes.buffer;
|
|
11521
11536
|
}
|
|
11522
|
-
async readFileStream(
|
|
11523
|
-
const fileInfo = await this._threadInstance.statFile(
|
|
11537
|
+
async readFileStream(path9, options) {
|
|
11538
|
+
const fileInfo = await this._threadInstance.statFile(path9);
|
|
11524
11539
|
if (!fileInfo) {
|
|
11525
11540
|
return null;
|
|
11526
11541
|
}
|
|
@@ -11535,7 +11550,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
11535
11550
|
return {
|
|
11536
11551
|
[Symbol.asyncIterator]: async function* () {
|
|
11537
11552
|
if (!isChunked) {
|
|
11538
|
-
const result = await threadInstance.readFile(
|
|
11553
|
+
const result = await threadInstance.readFile(path9);
|
|
11539
11554
|
if (!result.success || !result.data) {
|
|
11540
11555
|
return;
|
|
11541
11556
|
}
|
|
@@ -11556,7 +11571,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
11556
11571
|
if (signal?.aborted) {
|
|
11557
11572
|
return;
|
|
11558
11573
|
}
|
|
11559
|
-
const result = await threadInstance.readFileChunk(
|
|
11574
|
+
const result = await threadInstance.readFileChunk(path9, i);
|
|
11560
11575
|
if (!result.success || !result.data) {
|
|
11561
11576
|
throw new Error(result.error || `Failed to read chunk ${i}`);
|
|
11562
11577
|
}
|
|
@@ -11575,25 +11590,25 @@ var init_ThreadStateImpl = __esm({
|
|
|
11575
11590
|
}
|
|
11576
11591
|
};
|
|
11577
11592
|
}
|
|
11578
|
-
async statFile(
|
|
11579
|
-
const result = await this._threadInstance.statFile(
|
|
11593
|
+
async statFile(path9) {
|
|
11594
|
+
const result = await this._threadInstance.statFile(path9);
|
|
11580
11595
|
return result ? this._mapFileRecord(result) : null;
|
|
11581
11596
|
}
|
|
11582
|
-
async readdirFile(
|
|
11583
|
-
const entries = await this._threadInstance.readdirFile(
|
|
11597
|
+
async readdirFile(path9) {
|
|
11598
|
+
const entries = await this._threadInstance.readdirFile(path9);
|
|
11584
11599
|
return {
|
|
11585
11600
|
entries: entries.map((e) => this._mapFileRecord(e))
|
|
11586
11601
|
};
|
|
11587
11602
|
}
|
|
11588
|
-
async unlinkFile(
|
|
11589
|
-
await this._threadInstance.unlinkFile(
|
|
11603
|
+
async unlinkFile(path9) {
|
|
11604
|
+
await this._threadInstance.unlinkFile(path9);
|
|
11590
11605
|
}
|
|
11591
|
-
async mkdirFile(
|
|
11592
|
-
const result = await this._threadInstance.mkdirFile(
|
|
11606
|
+
async mkdirFile(path9) {
|
|
11607
|
+
const result = await this._threadInstance.mkdirFile(path9);
|
|
11593
11608
|
return this._mapFileRecord(result);
|
|
11594
11609
|
}
|
|
11595
|
-
async rmdirFile(
|
|
11596
|
-
await this._threadInstance.rmdirFile(
|
|
11610
|
+
async rmdirFile(path9) {
|
|
11611
|
+
await this._threadInstance.rmdirFile(path9);
|
|
11597
11612
|
}
|
|
11598
11613
|
async getFileStats() {
|
|
11599
11614
|
const stats = await this._threadInstance.getFileStats();
|
|
@@ -11616,8 +11631,8 @@ var init_ThreadStateImpl = __esm({
|
|
|
11616
11631
|
paths: Array.isArray(results) ? results : results.paths || []
|
|
11617
11632
|
};
|
|
11618
11633
|
}
|
|
11619
|
-
async getFileThumbnail(
|
|
11620
|
-
return this._threadInstance.getFileThumbnail(
|
|
11634
|
+
async getFileThumbnail(path9) {
|
|
11635
|
+
return this._threadInstance.getFileThumbnail(path9);
|
|
11621
11636
|
}
|
|
11622
11637
|
// ─────────────────────────────────────────────────────────────────────────
|
|
11623
11638
|
// Execution State
|
|
@@ -25943,7 +25958,7 @@ var init_web = __esm({
|
|
|
25943
25958
|
params
|
|
25944
25959
|
);
|
|
25945
25960
|
const urlParams = body["_url"];
|
|
25946
|
-
const
|
|
25961
|
+
const path9 = formatMap("{model}:batchGenerateContent", urlParams);
|
|
25947
25962
|
const batch = body["batch"];
|
|
25948
25963
|
const inputConfig = batch["inputConfig"];
|
|
25949
25964
|
const requestsWrapper = inputConfig["requests"];
|
|
@@ -25964,7 +25979,7 @@ var init_web = __esm({
|
|
|
25964
25979
|
delete body["config"];
|
|
25965
25980
|
delete body["_url"];
|
|
25966
25981
|
delete body["_query"];
|
|
25967
|
-
return { path:
|
|
25982
|
+
return { path: path9, body };
|
|
25968
25983
|
}
|
|
25969
25984
|
// Helper function to get the first GCS URI
|
|
25970
25985
|
getGcsUri(src) {
|
|
@@ -26020,16 +26035,16 @@ var init_web = __esm({
|
|
|
26020
26035
|
async createInternal(params) {
|
|
26021
26036
|
var _a16, _b16, _c, _d;
|
|
26022
26037
|
let response;
|
|
26023
|
-
let
|
|
26038
|
+
let path9 = "";
|
|
26024
26039
|
let queryParams = {};
|
|
26025
26040
|
if (this.apiClient.isVertexAI()) {
|
|
26026
26041
|
const body = createBatchJobParametersToVertex(this.apiClient, params);
|
|
26027
|
-
|
|
26042
|
+
path9 = formatMap("batchPredictionJobs", body["_url"]);
|
|
26028
26043
|
queryParams = body["_query"];
|
|
26029
26044
|
delete body["_url"];
|
|
26030
26045
|
delete body["_query"];
|
|
26031
26046
|
response = this.apiClient.request({
|
|
26032
|
-
path:
|
|
26047
|
+
path: path9,
|
|
26033
26048
|
queryParams,
|
|
26034
26049
|
body: JSON.stringify(body),
|
|
26035
26050
|
httpMethod: "POST",
|
|
@@ -26044,12 +26059,12 @@ var init_web = __esm({
|
|
|
26044
26059
|
});
|
|
26045
26060
|
} else {
|
|
26046
26061
|
const body = createBatchJobParametersToMldev(this.apiClient, params);
|
|
26047
|
-
|
|
26062
|
+
path9 = formatMap("{model}:batchGenerateContent", body["_url"]);
|
|
26048
26063
|
queryParams = body["_query"];
|
|
26049
26064
|
delete body["_url"];
|
|
26050
26065
|
delete body["_query"];
|
|
26051
26066
|
response = this.apiClient.request({
|
|
26052
|
-
path:
|
|
26067
|
+
path: path9,
|
|
26053
26068
|
queryParams,
|
|
26054
26069
|
body: JSON.stringify(body),
|
|
26055
26070
|
httpMethod: "POST",
|
|
@@ -26074,18 +26089,18 @@ var init_web = __esm({
|
|
|
26074
26089
|
async createEmbeddingsInternal(params) {
|
|
26075
26090
|
var _a16, _b16;
|
|
26076
26091
|
let response;
|
|
26077
|
-
let
|
|
26092
|
+
let path9 = "";
|
|
26078
26093
|
let queryParams = {};
|
|
26079
26094
|
if (this.apiClient.isVertexAI()) {
|
|
26080
26095
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
26081
26096
|
} else {
|
|
26082
26097
|
const body = createEmbeddingsBatchJobParametersToMldev(this.apiClient, params);
|
|
26083
|
-
|
|
26098
|
+
path9 = formatMap("{model}:asyncBatchEmbedContent", body["_url"]);
|
|
26084
26099
|
queryParams = body["_query"];
|
|
26085
26100
|
delete body["_url"];
|
|
26086
26101
|
delete body["_query"];
|
|
26087
26102
|
response = this.apiClient.request({
|
|
26088
|
-
path:
|
|
26103
|
+
path: path9,
|
|
26089
26104
|
queryParams,
|
|
26090
26105
|
body: JSON.stringify(body),
|
|
26091
26106
|
httpMethod: "POST",
|
|
@@ -26114,16 +26129,16 @@ var init_web = __esm({
|
|
|
26114
26129
|
async get(params) {
|
|
26115
26130
|
var _a16, _b16, _c, _d;
|
|
26116
26131
|
let response;
|
|
26117
|
-
let
|
|
26132
|
+
let path9 = "";
|
|
26118
26133
|
let queryParams = {};
|
|
26119
26134
|
if (this.apiClient.isVertexAI()) {
|
|
26120
26135
|
const body = getBatchJobParametersToVertex(this.apiClient, params);
|
|
26121
|
-
|
|
26136
|
+
path9 = formatMap("batchPredictionJobs/{name}", body["_url"]);
|
|
26122
26137
|
queryParams = body["_query"];
|
|
26123
26138
|
delete body["_url"];
|
|
26124
26139
|
delete body["_query"];
|
|
26125
26140
|
response = this.apiClient.request({
|
|
26126
|
-
path:
|
|
26141
|
+
path: path9,
|
|
26127
26142
|
queryParams,
|
|
26128
26143
|
body: JSON.stringify(body),
|
|
26129
26144
|
httpMethod: "GET",
|
|
@@ -26138,12 +26153,12 @@ var init_web = __esm({
|
|
|
26138
26153
|
});
|
|
26139
26154
|
} else {
|
|
26140
26155
|
const body = getBatchJobParametersToMldev(this.apiClient, params);
|
|
26141
|
-
|
|
26156
|
+
path9 = formatMap("batches/{name}", body["_url"]);
|
|
26142
26157
|
queryParams = body["_query"];
|
|
26143
26158
|
delete body["_url"];
|
|
26144
26159
|
delete body["_query"];
|
|
26145
26160
|
response = this.apiClient.request({
|
|
26146
|
-
path:
|
|
26161
|
+
path: path9,
|
|
26147
26162
|
queryParams,
|
|
26148
26163
|
body: JSON.stringify(body),
|
|
26149
26164
|
httpMethod: "GET",
|
|
@@ -26171,16 +26186,16 @@ var init_web = __esm({
|
|
|
26171
26186
|
*/
|
|
26172
26187
|
async cancel(params) {
|
|
26173
26188
|
var _a16, _b16, _c, _d;
|
|
26174
|
-
let
|
|
26189
|
+
let path9 = "";
|
|
26175
26190
|
let queryParams = {};
|
|
26176
26191
|
if (this.apiClient.isVertexAI()) {
|
|
26177
26192
|
const body = cancelBatchJobParametersToVertex(this.apiClient, params);
|
|
26178
|
-
|
|
26193
|
+
path9 = formatMap("batchPredictionJobs/{name}:cancel", body["_url"]);
|
|
26179
26194
|
queryParams = body["_query"];
|
|
26180
26195
|
delete body["_url"];
|
|
26181
26196
|
delete body["_query"];
|
|
26182
26197
|
await this.apiClient.request({
|
|
26183
|
-
path:
|
|
26198
|
+
path: path9,
|
|
26184
26199
|
queryParams,
|
|
26185
26200
|
body: JSON.stringify(body),
|
|
26186
26201
|
httpMethod: "POST",
|
|
@@ -26189,12 +26204,12 @@ var init_web = __esm({
|
|
|
26189
26204
|
});
|
|
26190
26205
|
} else {
|
|
26191
26206
|
const body = cancelBatchJobParametersToMldev(this.apiClient, params);
|
|
26192
|
-
|
|
26207
|
+
path9 = formatMap("batches/{name}:cancel", body["_url"]);
|
|
26193
26208
|
queryParams = body["_query"];
|
|
26194
26209
|
delete body["_url"];
|
|
26195
26210
|
delete body["_query"];
|
|
26196
26211
|
await this.apiClient.request({
|
|
26197
|
-
path:
|
|
26212
|
+
path: path9,
|
|
26198
26213
|
queryParams,
|
|
26199
26214
|
body: JSON.stringify(body),
|
|
26200
26215
|
httpMethod: "POST",
|
|
@@ -26206,16 +26221,16 @@ var init_web = __esm({
|
|
|
26206
26221
|
async listInternal(params) {
|
|
26207
26222
|
var _a16, _b16, _c, _d;
|
|
26208
26223
|
let response;
|
|
26209
|
-
let
|
|
26224
|
+
let path9 = "";
|
|
26210
26225
|
let queryParams = {};
|
|
26211
26226
|
if (this.apiClient.isVertexAI()) {
|
|
26212
26227
|
const body = listBatchJobsParametersToVertex(params);
|
|
26213
|
-
|
|
26228
|
+
path9 = formatMap("batchPredictionJobs", body["_url"]);
|
|
26214
26229
|
queryParams = body["_query"];
|
|
26215
26230
|
delete body["_url"];
|
|
26216
26231
|
delete body["_query"];
|
|
26217
26232
|
response = this.apiClient.request({
|
|
26218
|
-
path:
|
|
26233
|
+
path: path9,
|
|
26219
26234
|
queryParams,
|
|
26220
26235
|
body: JSON.stringify(body),
|
|
26221
26236
|
httpMethod: "GET",
|
|
@@ -26238,12 +26253,12 @@ var init_web = __esm({
|
|
|
26238
26253
|
});
|
|
26239
26254
|
} else {
|
|
26240
26255
|
const body = listBatchJobsParametersToMldev(params);
|
|
26241
|
-
|
|
26256
|
+
path9 = formatMap("batches", body["_url"]);
|
|
26242
26257
|
queryParams = body["_query"];
|
|
26243
26258
|
delete body["_url"];
|
|
26244
26259
|
delete body["_query"];
|
|
26245
26260
|
response = this.apiClient.request({
|
|
26246
|
-
path:
|
|
26261
|
+
path: path9,
|
|
26247
26262
|
queryParams,
|
|
26248
26263
|
body: JSON.stringify(body),
|
|
26249
26264
|
httpMethod: "GET",
|
|
@@ -26280,16 +26295,16 @@ var init_web = __esm({
|
|
|
26280
26295
|
async delete(params) {
|
|
26281
26296
|
var _a16, _b16, _c, _d;
|
|
26282
26297
|
let response;
|
|
26283
|
-
let
|
|
26298
|
+
let path9 = "";
|
|
26284
26299
|
let queryParams = {};
|
|
26285
26300
|
if (this.apiClient.isVertexAI()) {
|
|
26286
26301
|
const body = deleteBatchJobParametersToVertex(this.apiClient, params);
|
|
26287
|
-
|
|
26302
|
+
path9 = formatMap("batchPredictionJobs/{name}", body["_url"]);
|
|
26288
26303
|
queryParams = body["_query"];
|
|
26289
26304
|
delete body["_url"];
|
|
26290
26305
|
delete body["_query"];
|
|
26291
26306
|
response = this.apiClient.request({
|
|
26292
|
-
path:
|
|
26307
|
+
path: path9,
|
|
26293
26308
|
queryParams,
|
|
26294
26309
|
body: JSON.stringify(body),
|
|
26295
26310
|
httpMethod: "DELETE",
|
|
@@ -26310,12 +26325,12 @@ var init_web = __esm({
|
|
|
26310
26325
|
});
|
|
26311
26326
|
} else {
|
|
26312
26327
|
const body = deleteBatchJobParametersToMldev(this.apiClient, params);
|
|
26313
|
-
|
|
26328
|
+
path9 = formatMap("batches/{name}", body["_url"]);
|
|
26314
26329
|
queryParams = body["_query"];
|
|
26315
26330
|
delete body["_url"];
|
|
26316
26331
|
delete body["_query"];
|
|
26317
26332
|
response = this.apiClient.request({
|
|
26318
|
-
path:
|
|
26333
|
+
path: path9,
|
|
26319
26334
|
queryParams,
|
|
26320
26335
|
body: JSON.stringify(body),
|
|
26321
26336
|
httpMethod: "DELETE",
|
|
@@ -26374,16 +26389,16 @@ var init_web = __esm({
|
|
|
26374
26389
|
async create(params) {
|
|
26375
26390
|
var _a16, _b16, _c, _d;
|
|
26376
26391
|
let response;
|
|
26377
|
-
let
|
|
26392
|
+
let path9 = "";
|
|
26378
26393
|
let queryParams = {};
|
|
26379
26394
|
if (this.apiClient.isVertexAI()) {
|
|
26380
26395
|
const body = createCachedContentParametersToVertex(this.apiClient, params);
|
|
26381
|
-
|
|
26396
|
+
path9 = formatMap("cachedContents", body["_url"]);
|
|
26382
26397
|
queryParams = body["_query"];
|
|
26383
26398
|
delete body["_url"];
|
|
26384
26399
|
delete body["_query"];
|
|
26385
26400
|
response = this.apiClient.request({
|
|
26386
|
-
path:
|
|
26401
|
+
path: path9,
|
|
26387
26402
|
queryParams,
|
|
26388
26403
|
body: JSON.stringify(body),
|
|
26389
26404
|
httpMethod: "POST",
|
|
@@ -26397,12 +26412,12 @@ var init_web = __esm({
|
|
|
26397
26412
|
});
|
|
26398
26413
|
} else {
|
|
26399
26414
|
const body = createCachedContentParametersToMldev(this.apiClient, params);
|
|
26400
|
-
|
|
26415
|
+
path9 = formatMap("cachedContents", body["_url"]);
|
|
26401
26416
|
queryParams = body["_query"];
|
|
26402
26417
|
delete body["_url"];
|
|
26403
26418
|
delete body["_query"];
|
|
26404
26419
|
response = this.apiClient.request({
|
|
26405
|
-
path:
|
|
26420
|
+
path: path9,
|
|
26406
26421
|
queryParams,
|
|
26407
26422
|
body: JSON.stringify(body),
|
|
26408
26423
|
httpMethod: "POST",
|
|
@@ -26430,16 +26445,16 @@ var init_web = __esm({
|
|
|
26430
26445
|
async get(params) {
|
|
26431
26446
|
var _a16, _b16, _c, _d;
|
|
26432
26447
|
let response;
|
|
26433
|
-
let
|
|
26448
|
+
let path9 = "";
|
|
26434
26449
|
let queryParams = {};
|
|
26435
26450
|
if (this.apiClient.isVertexAI()) {
|
|
26436
26451
|
const body = getCachedContentParametersToVertex(this.apiClient, params);
|
|
26437
|
-
|
|
26452
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
26438
26453
|
queryParams = body["_query"];
|
|
26439
26454
|
delete body["_url"];
|
|
26440
26455
|
delete body["_query"];
|
|
26441
26456
|
response = this.apiClient.request({
|
|
26442
|
-
path:
|
|
26457
|
+
path: path9,
|
|
26443
26458
|
queryParams,
|
|
26444
26459
|
body: JSON.stringify(body),
|
|
26445
26460
|
httpMethod: "GET",
|
|
@@ -26453,12 +26468,12 @@ var init_web = __esm({
|
|
|
26453
26468
|
});
|
|
26454
26469
|
} else {
|
|
26455
26470
|
const body = getCachedContentParametersToMldev(this.apiClient, params);
|
|
26456
|
-
|
|
26471
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
26457
26472
|
queryParams = body["_query"];
|
|
26458
26473
|
delete body["_url"];
|
|
26459
26474
|
delete body["_query"];
|
|
26460
26475
|
response = this.apiClient.request({
|
|
26461
|
-
path:
|
|
26476
|
+
path: path9,
|
|
26462
26477
|
queryParams,
|
|
26463
26478
|
body: JSON.stringify(body),
|
|
26464
26479
|
httpMethod: "GET",
|
|
@@ -26486,16 +26501,16 @@ var init_web = __esm({
|
|
|
26486
26501
|
async delete(params) {
|
|
26487
26502
|
var _a16, _b16, _c, _d;
|
|
26488
26503
|
let response;
|
|
26489
|
-
let
|
|
26504
|
+
let path9 = "";
|
|
26490
26505
|
let queryParams = {};
|
|
26491
26506
|
if (this.apiClient.isVertexAI()) {
|
|
26492
26507
|
const body = deleteCachedContentParametersToVertex(this.apiClient, params);
|
|
26493
|
-
|
|
26508
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
26494
26509
|
queryParams = body["_query"];
|
|
26495
26510
|
delete body["_url"];
|
|
26496
26511
|
delete body["_query"];
|
|
26497
26512
|
response = this.apiClient.request({
|
|
26498
|
-
path:
|
|
26513
|
+
path: path9,
|
|
26499
26514
|
queryParams,
|
|
26500
26515
|
body: JSON.stringify(body),
|
|
26501
26516
|
httpMethod: "DELETE",
|
|
@@ -26518,12 +26533,12 @@ var init_web = __esm({
|
|
|
26518
26533
|
});
|
|
26519
26534
|
} else {
|
|
26520
26535
|
const body = deleteCachedContentParametersToMldev(this.apiClient, params);
|
|
26521
|
-
|
|
26536
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
26522
26537
|
queryParams = body["_query"];
|
|
26523
26538
|
delete body["_url"];
|
|
26524
26539
|
delete body["_query"];
|
|
26525
26540
|
response = this.apiClient.request({
|
|
26526
|
-
path:
|
|
26541
|
+
path: path9,
|
|
26527
26542
|
queryParams,
|
|
26528
26543
|
body: JSON.stringify(body),
|
|
26529
26544
|
httpMethod: "DELETE",
|
|
@@ -26563,16 +26578,16 @@ var init_web = __esm({
|
|
|
26563
26578
|
async update(params) {
|
|
26564
26579
|
var _a16, _b16, _c, _d;
|
|
26565
26580
|
let response;
|
|
26566
|
-
let
|
|
26581
|
+
let path9 = "";
|
|
26567
26582
|
let queryParams = {};
|
|
26568
26583
|
if (this.apiClient.isVertexAI()) {
|
|
26569
26584
|
const body = updateCachedContentParametersToVertex(this.apiClient, params);
|
|
26570
|
-
|
|
26585
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
26571
26586
|
queryParams = body["_query"];
|
|
26572
26587
|
delete body["_url"];
|
|
26573
26588
|
delete body["_query"];
|
|
26574
26589
|
response = this.apiClient.request({
|
|
26575
|
-
path:
|
|
26590
|
+
path: path9,
|
|
26576
26591
|
queryParams,
|
|
26577
26592
|
body: JSON.stringify(body),
|
|
26578
26593
|
httpMethod: "PATCH",
|
|
@@ -26586,12 +26601,12 @@ var init_web = __esm({
|
|
|
26586
26601
|
});
|
|
26587
26602
|
} else {
|
|
26588
26603
|
const body = updateCachedContentParametersToMldev(this.apiClient, params);
|
|
26589
|
-
|
|
26604
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
26590
26605
|
queryParams = body["_query"];
|
|
26591
26606
|
delete body["_url"];
|
|
26592
26607
|
delete body["_query"];
|
|
26593
26608
|
response = this.apiClient.request({
|
|
26594
|
-
path:
|
|
26609
|
+
path: path9,
|
|
26595
26610
|
queryParams,
|
|
26596
26611
|
body: JSON.stringify(body),
|
|
26597
26612
|
httpMethod: "PATCH",
|
|
@@ -26608,16 +26623,16 @@ var init_web = __esm({
|
|
|
26608
26623
|
async listInternal(params) {
|
|
26609
26624
|
var _a16, _b16, _c, _d;
|
|
26610
26625
|
let response;
|
|
26611
|
-
let
|
|
26626
|
+
let path9 = "";
|
|
26612
26627
|
let queryParams = {};
|
|
26613
26628
|
if (this.apiClient.isVertexAI()) {
|
|
26614
26629
|
const body = listCachedContentsParametersToVertex(params);
|
|
26615
|
-
|
|
26630
|
+
path9 = formatMap("cachedContents", body["_url"]);
|
|
26616
26631
|
queryParams = body["_query"];
|
|
26617
26632
|
delete body["_url"];
|
|
26618
26633
|
delete body["_query"];
|
|
26619
26634
|
response = this.apiClient.request({
|
|
26620
|
-
path:
|
|
26635
|
+
path: path9,
|
|
26621
26636
|
queryParams,
|
|
26622
26637
|
body: JSON.stringify(body),
|
|
26623
26638
|
httpMethod: "GET",
|
|
@@ -26640,12 +26655,12 @@ var init_web = __esm({
|
|
|
26640
26655
|
});
|
|
26641
26656
|
} else {
|
|
26642
26657
|
const body = listCachedContentsParametersToMldev(params);
|
|
26643
|
-
|
|
26658
|
+
path9 = formatMap("cachedContents", body["_url"]);
|
|
26644
26659
|
queryParams = body["_query"];
|
|
26645
26660
|
delete body["_url"];
|
|
26646
26661
|
delete body["_query"];
|
|
26647
26662
|
response = this.apiClient.request({
|
|
26648
|
-
path:
|
|
26663
|
+
path: path9,
|
|
26649
26664
|
queryParams,
|
|
26650
26665
|
body: JSON.stringify(body),
|
|
26651
26666
|
httpMethod: "GET",
|
|
@@ -26976,18 +26991,18 @@ var init_web = __esm({
|
|
|
26976
26991
|
async listInternal(params) {
|
|
26977
26992
|
var _a16, _b16;
|
|
26978
26993
|
let response;
|
|
26979
|
-
let
|
|
26994
|
+
let path9 = "";
|
|
26980
26995
|
let queryParams = {};
|
|
26981
26996
|
if (this.apiClient.isVertexAI()) {
|
|
26982
26997
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
26983
26998
|
} else {
|
|
26984
26999
|
const body = listFilesParametersToMldev(params);
|
|
26985
|
-
|
|
27000
|
+
path9 = formatMap("files", body["_url"]);
|
|
26986
27001
|
queryParams = body["_query"];
|
|
26987
27002
|
delete body["_url"];
|
|
26988
27003
|
delete body["_query"];
|
|
26989
27004
|
response = this.apiClient.request({
|
|
26990
|
-
path:
|
|
27005
|
+
path: path9,
|
|
26991
27006
|
queryParams,
|
|
26992
27007
|
body: JSON.stringify(body),
|
|
26993
27008
|
httpMethod: "GET",
|
|
@@ -27013,18 +27028,18 @@ var init_web = __esm({
|
|
|
27013
27028
|
async createInternal(params) {
|
|
27014
27029
|
var _a16, _b16;
|
|
27015
27030
|
let response;
|
|
27016
|
-
let
|
|
27031
|
+
let path9 = "";
|
|
27017
27032
|
let queryParams = {};
|
|
27018
27033
|
if (this.apiClient.isVertexAI()) {
|
|
27019
27034
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
27020
27035
|
} else {
|
|
27021
27036
|
const body = createFileParametersToMldev(params);
|
|
27022
|
-
|
|
27037
|
+
path9 = formatMap("upload/v1beta/files", body["_url"]);
|
|
27023
27038
|
queryParams = body["_query"];
|
|
27024
27039
|
delete body["_url"];
|
|
27025
27040
|
delete body["_query"];
|
|
27026
27041
|
response = this.apiClient.request({
|
|
27027
|
-
path:
|
|
27042
|
+
path: path9,
|
|
27028
27043
|
queryParams,
|
|
27029
27044
|
body: JSON.stringify(body),
|
|
27030
27045
|
httpMethod: "POST",
|
|
@@ -27059,18 +27074,18 @@ var init_web = __esm({
|
|
|
27059
27074
|
async get(params) {
|
|
27060
27075
|
var _a16, _b16;
|
|
27061
27076
|
let response;
|
|
27062
|
-
let
|
|
27077
|
+
let path9 = "";
|
|
27063
27078
|
let queryParams = {};
|
|
27064
27079
|
if (this.apiClient.isVertexAI()) {
|
|
27065
27080
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
27066
27081
|
} else {
|
|
27067
27082
|
const body = getFileParametersToMldev(params);
|
|
27068
|
-
|
|
27083
|
+
path9 = formatMap("files/{file}", body["_url"]);
|
|
27069
27084
|
queryParams = body["_query"];
|
|
27070
27085
|
delete body["_url"];
|
|
27071
27086
|
delete body["_query"];
|
|
27072
27087
|
response = this.apiClient.request({
|
|
27073
|
-
path:
|
|
27088
|
+
path: path9,
|
|
27074
27089
|
queryParams,
|
|
27075
27090
|
body: JSON.stringify(body),
|
|
27076
27091
|
httpMethod: "GET",
|
|
@@ -27100,18 +27115,18 @@ var init_web = __esm({
|
|
|
27100
27115
|
async delete(params) {
|
|
27101
27116
|
var _a16, _b16;
|
|
27102
27117
|
let response;
|
|
27103
|
-
let
|
|
27118
|
+
let path9 = "";
|
|
27104
27119
|
let queryParams = {};
|
|
27105
27120
|
if (this.apiClient.isVertexAI()) {
|
|
27106
27121
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
27107
27122
|
} else {
|
|
27108
27123
|
const body = deleteFileParametersToMldev(params);
|
|
27109
|
-
|
|
27124
|
+
path9 = formatMap("files/{file}", body["_url"]);
|
|
27110
27125
|
queryParams = body["_query"];
|
|
27111
27126
|
delete body["_url"];
|
|
27112
27127
|
delete body["_query"];
|
|
27113
27128
|
response = this.apiClient.request({
|
|
27114
|
-
path:
|
|
27129
|
+
path: path9,
|
|
27115
27130
|
queryParams,
|
|
27116
27131
|
body: JSON.stringify(body),
|
|
27117
27132
|
httpMethod: "DELETE",
|
|
@@ -27137,18 +27152,18 @@ var init_web = __esm({
|
|
|
27137
27152
|
async registerFilesInternal(params) {
|
|
27138
27153
|
var _a16, _b16;
|
|
27139
27154
|
let response;
|
|
27140
|
-
let
|
|
27155
|
+
let path9 = "";
|
|
27141
27156
|
let queryParams = {};
|
|
27142
27157
|
if (this.apiClient.isVertexAI()) {
|
|
27143
27158
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
27144
27159
|
} else {
|
|
27145
27160
|
const body = internalRegisterFilesParametersToMldev(params);
|
|
27146
|
-
|
|
27161
|
+
path9 = formatMap("files:register", body["_url"]);
|
|
27147
27162
|
queryParams = body["_query"];
|
|
27148
27163
|
delete body["_url"];
|
|
27149
27164
|
delete body["_query"];
|
|
27150
27165
|
response = this.apiClient.request({
|
|
27151
|
-
path:
|
|
27166
|
+
path: path9,
|
|
27152
27167
|
queryParams,
|
|
27153
27168
|
body: JSON.stringify(body),
|
|
27154
27169
|
httpMethod: "POST",
|
|
@@ -27307,13 +27322,13 @@ var init_web = __esm({
|
|
|
27307
27322
|
throw new Error("HTTP options are not correctly set.");
|
|
27308
27323
|
}
|
|
27309
27324
|
}
|
|
27310
|
-
constructUrl(
|
|
27325
|
+
constructUrl(path9, httpOptions, prependProjectLocation) {
|
|
27311
27326
|
const urlElement = [this.getRequestUrlInternal(httpOptions)];
|
|
27312
27327
|
if (prependProjectLocation) {
|
|
27313
27328
|
urlElement.push(this.getBaseResourcePath());
|
|
27314
27329
|
}
|
|
27315
|
-
if (
|
|
27316
|
-
urlElement.push(
|
|
27330
|
+
if (path9 !== "") {
|
|
27331
|
+
urlElement.push(path9);
|
|
27317
27332
|
}
|
|
27318
27333
|
const url = new URL(`${urlElement.join("/")}`);
|
|
27319
27334
|
return url;
|
|
@@ -27598,8 +27613,8 @@ var init_web = __esm({
|
|
|
27598
27613
|
file: fileToUpload
|
|
27599
27614
|
};
|
|
27600
27615
|
const fileName = this.getFileName(file);
|
|
27601
|
-
const
|
|
27602
|
-
const uploadUrl = await this.fetchUploadUrl(
|
|
27616
|
+
const path9 = formatMap("upload/v1beta/files", body["_url"]);
|
|
27617
|
+
const uploadUrl = await this.fetchUploadUrl(path9, fileToUpload.sizeBytes, fileToUpload.mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
27603
27618
|
return uploader.upload(file, uploadUrl, this);
|
|
27604
27619
|
}
|
|
27605
27620
|
/**
|
|
@@ -27623,13 +27638,13 @@ var init_web = __esm({
|
|
|
27623
27638
|
if (mimeType === void 0 || mimeType === "") {
|
|
27624
27639
|
throw new Error("Can not determine mimeType. Please provide mimeType in the config.");
|
|
27625
27640
|
}
|
|
27626
|
-
const
|
|
27641
|
+
const path9 = `upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`;
|
|
27627
27642
|
const fileName = this.getFileName(file);
|
|
27628
27643
|
const body = {};
|
|
27629
27644
|
if (config != null) {
|
|
27630
27645
|
uploadToFileSearchStoreConfigToMldev(config, body);
|
|
27631
27646
|
}
|
|
27632
|
-
const uploadUrl = await this.fetchUploadUrl(
|
|
27647
|
+
const uploadUrl = await this.fetchUploadUrl(path9, sizeBytes, mimeType, fileName, body, config === null || config === void 0 ? void 0 : config.httpOptions);
|
|
27633
27648
|
return uploader.uploadToFileSearchStore(file, uploadUrl, this);
|
|
27634
27649
|
}
|
|
27635
27650
|
/**
|
|
@@ -27642,7 +27657,7 @@ var init_web = __esm({
|
|
|
27642
27657
|
const downloader = this.clientOptions.downloader;
|
|
27643
27658
|
await downloader.download(params, this);
|
|
27644
27659
|
}
|
|
27645
|
-
async fetchUploadUrl(
|
|
27660
|
+
async fetchUploadUrl(path9, sizeBytes, mimeType, fileName, body, configHttpOptions) {
|
|
27646
27661
|
var _a16;
|
|
27647
27662
|
let httpOptions = {};
|
|
27648
27663
|
if (configHttpOptions) {
|
|
@@ -27655,7 +27670,7 @@ var init_web = __esm({
|
|
|
27655
27670
|
};
|
|
27656
27671
|
}
|
|
27657
27672
|
const httpResponse = await this.request({
|
|
27658
|
-
path:
|
|
27673
|
+
path: path9,
|
|
27659
27674
|
body: JSON.stringify(body),
|
|
27660
27675
|
httpMethod: "POST",
|
|
27661
27676
|
httpOptions
|
|
@@ -28628,16 +28643,16 @@ var init_web = __esm({
|
|
|
28628
28643
|
async generateContentInternal(params) {
|
|
28629
28644
|
var _a16, _b16, _c, _d;
|
|
28630
28645
|
let response;
|
|
28631
|
-
let
|
|
28646
|
+
let path9 = "";
|
|
28632
28647
|
let queryParams = {};
|
|
28633
28648
|
if (this.apiClient.isVertexAI()) {
|
|
28634
28649
|
const body = generateContentParametersToVertex(this.apiClient, params);
|
|
28635
|
-
|
|
28650
|
+
path9 = formatMap("{model}:generateContent", body["_url"]);
|
|
28636
28651
|
queryParams = body["_query"];
|
|
28637
28652
|
delete body["_url"];
|
|
28638
28653
|
delete body["_query"];
|
|
28639
28654
|
response = this.apiClient.request({
|
|
28640
|
-
path:
|
|
28655
|
+
path: path9,
|
|
28641
28656
|
queryParams,
|
|
28642
28657
|
body: JSON.stringify(body),
|
|
28643
28658
|
httpMethod: "POST",
|
|
@@ -28660,12 +28675,12 @@ var init_web = __esm({
|
|
|
28660
28675
|
});
|
|
28661
28676
|
} else {
|
|
28662
28677
|
const body = generateContentParametersToMldev(this.apiClient, params);
|
|
28663
|
-
|
|
28678
|
+
path9 = formatMap("{model}:generateContent", body["_url"]);
|
|
28664
28679
|
queryParams = body["_query"];
|
|
28665
28680
|
delete body["_url"];
|
|
28666
28681
|
delete body["_query"];
|
|
28667
28682
|
response = this.apiClient.request({
|
|
28668
|
-
path:
|
|
28683
|
+
path: path9,
|
|
28669
28684
|
queryParams,
|
|
28670
28685
|
body: JSON.stringify(body),
|
|
28671
28686
|
httpMethod: "POST",
|
|
@@ -28691,17 +28706,17 @@ var init_web = __esm({
|
|
|
28691
28706
|
async generateContentStreamInternal(params) {
|
|
28692
28707
|
var _a16, _b16, _c, _d;
|
|
28693
28708
|
let response;
|
|
28694
|
-
let
|
|
28709
|
+
let path9 = "";
|
|
28695
28710
|
let queryParams = {};
|
|
28696
28711
|
if (this.apiClient.isVertexAI()) {
|
|
28697
28712
|
const body = generateContentParametersToVertex(this.apiClient, params);
|
|
28698
|
-
|
|
28713
|
+
path9 = formatMap("{model}:streamGenerateContent?alt=sse", body["_url"]);
|
|
28699
28714
|
queryParams = body["_query"];
|
|
28700
28715
|
delete body["_url"];
|
|
28701
28716
|
delete body["_query"];
|
|
28702
28717
|
const apiClient = this.apiClient;
|
|
28703
28718
|
response = apiClient.requestStream({
|
|
28704
|
-
path:
|
|
28719
|
+
path: path9,
|
|
28705
28720
|
queryParams,
|
|
28706
28721
|
body: JSON.stringify(body),
|
|
28707
28722
|
httpMethod: "POST",
|
|
@@ -28737,13 +28752,13 @@ var init_web = __esm({
|
|
|
28737
28752
|
});
|
|
28738
28753
|
} else {
|
|
28739
28754
|
const body = generateContentParametersToMldev(this.apiClient, params);
|
|
28740
|
-
|
|
28755
|
+
path9 = formatMap("{model}:streamGenerateContent?alt=sse", body["_url"]);
|
|
28741
28756
|
queryParams = body["_query"];
|
|
28742
28757
|
delete body["_url"];
|
|
28743
28758
|
delete body["_query"];
|
|
28744
28759
|
const apiClient = this.apiClient;
|
|
28745
28760
|
response = apiClient.requestStream({
|
|
28746
|
-
path:
|
|
28761
|
+
path: path9,
|
|
28747
28762
|
queryParams,
|
|
28748
28763
|
body: JSON.stringify(body),
|
|
28749
28764
|
httpMethod: "POST",
|
|
@@ -28803,17 +28818,17 @@ var init_web = __esm({
|
|
|
28803
28818
|
async embedContentInternal(params) {
|
|
28804
28819
|
var _a16, _b16, _c, _d;
|
|
28805
28820
|
let response;
|
|
28806
|
-
let
|
|
28821
|
+
let path9 = "";
|
|
28807
28822
|
let queryParams = {};
|
|
28808
28823
|
if (this.apiClient.isVertexAI()) {
|
|
28809
28824
|
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
28810
28825
|
const endpointUrl = tIsVertexEmbedContentModel(params.model) ? "{model}:embedContent" : "{model}:predict";
|
|
28811
|
-
|
|
28826
|
+
path9 = formatMap(endpointUrl, body["_url"]);
|
|
28812
28827
|
queryParams = body["_query"];
|
|
28813
28828
|
delete body["_url"];
|
|
28814
28829
|
delete body["_query"];
|
|
28815
28830
|
response = this.apiClient.request({
|
|
28816
|
-
path:
|
|
28831
|
+
path: path9,
|
|
28817
28832
|
queryParams,
|
|
28818
28833
|
body: JSON.stringify(body),
|
|
28819
28834
|
httpMethod: "POST",
|
|
@@ -28836,12 +28851,12 @@ var init_web = __esm({
|
|
|
28836
28851
|
});
|
|
28837
28852
|
} else {
|
|
28838
28853
|
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
28839
|
-
|
|
28854
|
+
path9 = formatMap("{model}:batchEmbedContents", body["_url"]);
|
|
28840
28855
|
queryParams = body["_query"];
|
|
28841
28856
|
delete body["_url"];
|
|
28842
28857
|
delete body["_query"];
|
|
28843
28858
|
response = this.apiClient.request({
|
|
28844
|
-
path:
|
|
28859
|
+
path: path9,
|
|
28845
28860
|
queryParams,
|
|
28846
28861
|
body: JSON.stringify(body),
|
|
28847
28862
|
httpMethod: "POST",
|
|
@@ -28870,16 +28885,16 @@ var init_web = __esm({
|
|
|
28870
28885
|
async generateImagesInternal(params) {
|
|
28871
28886
|
var _a16, _b16, _c, _d;
|
|
28872
28887
|
let response;
|
|
28873
|
-
let
|
|
28888
|
+
let path9 = "";
|
|
28874
28889
|
let queryParams = {};
|
|
28875
28890
|
if (this.apiClient.isVertexAI()) {
|
|
28876
28891
|
const body = generateImagesParametersToVertex(this.apiClient, params);
|
|
28877
|
-
|
|
28892
|
+
path9 = formatMap("{model}:predict", body["_url"]);
|
|
28878
28893
|
queryParams = body["_query"];
|
|
28879
28894
|
delete body["_url"];
|
|
28880
28895
|
delete body["_query"];
|
|
28881
28896
|
response = this.apiClient.request({
|
|
28882
|
-
path:
|
|
28897
|
+
path: path9,
|
|
28883
28898
|
queryParams,
|
|
28884
28899
|
body: JSON.stringify(body),
|
|
28885
28900
|
httpMethod: "POST",
|
|
@@ -28902,12 +28917,12 @@ var init_web = __esm({
|
|
|
28902
28917
|
});
|
|
28903
28918
|
} else {
|
|
28904
28919
|
const body = generateImagesParametersToMldev(this.apiClient, params);
|
|
28905
|
-
|
|
28920
|
+
path9 = formatMap("{model}:predict", body["_url"]);
|
|
28906
28921
|
queryParams = body["_query"];
|
|
28907
28922
|
delete body["_url"];
|
|
28908
28923
|
delete body["_query"];
|
|
28909
28924
|
response = this.apiClient.request({
|
|
28910
|
-
path:
|
|
28925
|
+
path: path9,
|
|
28911
28926
|
queryParams,
|
|
28912
28927
|
body: JSON.stringify(body),
|
|
28913
28928
|
httpMethod: "POST",
|
|
@@ -28936,16 +28951,16 @@ var init_web = __esm({
|
|
|
28936
28951
|
async editImageInternal(params) {
|
|
28937
28952
|
var _a16, _b16;
|
|
28938
28953
|
let response;
|
|
28939
|
-
let
|
|
28954
|
+
let path9 = "";
|
|
28940
28955
|
let queryParams = {};
|
|
28941
28956
|
if (this.apiClient.isVertexAI()) {
|
|
28942
28957
|
const body = editImageParametersInternalToVertex(this.apiClient, params);
|
|
28943
|
-
|
|
28958
|
+
path9 = formatMap("{model}:predict", body["_url"]);
|
|
28944
28959
|
queryParams = body["_query"];
|
|
28945
28960
|
delete body["_url"];
|
|
28946
28961
|
delete body["_query"];
|
|
28947
28962
|
response = this.apiClient.request({
|
|
28948
|
-
path:
|
|
28963
|
+
path: path9,
|
|
28949
28964
|
queryParams,
|
|
28950
28965
|
body: JSON.stringify(body),
|
|
28951
28966
|
httpMethod: "POST",
|
|
@@ -28976,16 +28991,16 @@ var init_web = __esm({
|
|
|
28976
28991
|
async upscaleImageInternal(params) {
|
|
28977
28992
|
var _a16, _b16;
|
|
28978
28993
|
let response;
|
|
28979
|
-
let
|
|
28994
|
+
let path9 = "";
|
|
28980
28995
|
let queryParams = {};
|
|
28981
28996
|
if (this.apiClient.isVertexAI()) {
|
|
28982
28997
|
const body = upscaleImageAPIParametersInternalToVertex(this.apiClient, params);
|
|
28983
|
-
|
|
28998
|
+
path9 = formatMap("{model}:predict", body["_url"]);
|
|
28984
28999
|
queryParams = body["_query"];
|
|
28985
29000
|
delete body["_url"];
|
|
28986
29001
|
delete body["_query"];
|
|
28987
29002
|
response = this.apiClient.request({
|
|
28988
|
-
path:
|
|
29003
|
+
path: path9,
|
|
28989
29004
|
queryParams,
|
|
28990
29005
|
body: JSON.stringify(body),
|
|
28991
29006
|
httpMethod: "POST",
|
|
@@ -29051,16 +29066,16 @@ var init_web = __esm({
|
|
|
29051
29066
|
async recontextImage(params) {
|
|
29052
29067
|
var _a16, _b16;
|
|
29053
29068
|
let response;
|
|
29054
|
-
let
|
|
29069
|
+
let path9 = "";
|
|
29055
29070
|
let queryParams = {};
|
|
29056
29071
|
if (this.apiClient.isVertexAI()) {
|
|
29057
29072
|
const body = recontextImageParametersToVertex(this.apiClient, params);
|
|
29058
|
-
|
|
29073
|
+
path9 = formatMap("{model}:predict", body["_url"]);
|
|
29059
29074
|
queryParams = body["_query"];
|
|
29060
29075
|
delete body["_url"];
|
|
29061
29076
|
delete body["_query"];
|
|
29062
29077
|
response = this.apiClient.request({
|
|
29063
|
-
path:
|
|
29078
|
+
path: path9,
|
|
29064
29079
|
queryParams,
|
|
29065
29080
|
body: JSON.stringify(body),
|
|
29066
29081
|
httpMethod: "POST",
|
|
@@ -29102,16 +29117,16 @@ var init_web = __esm({
|
|
|
29102
29117
|
async segmentImage(params) {
|
|
29103
29118
|
var _a16, _b16;
|
|
29104
29119
|
let response;
|
|
29105
|
-
let
|
|
29120
|
+
let path9 = "";
|
|
29106
29121
|
let queryParams = {};
|
|
29107
29122
|
if (this.apiClient.isVertexAI()) {
|
|
29108
29123
|
const body = segmentImageParametersToVertex(this.apiClient, params);
|
|
29109
|
-
|
|
29124
|
+
path9 = formatMap("{model}:predict", body["_url"]);
|
|
29110
29125
|
queryParams = body["_query"];
|
|
29111
29126
|
delete body["_url"];
|
|
29112
29127
|
delete body["_query"];
|
|
29113
29128
|
response = this.apiClient.request({
|
|
29114
|
-
path:
|
|
29129
|
+
path: path9,
|
|
29115
29130
|
queryParams,
|
|
29116
29131
|
body: JSON.stringify(body),
|
|
29117
29132
|
httpMethod: "POST",
|
|
@@ -29141,16 +29156,16 @@ var init_web = __esm({
|
|
|
29141
29156
|
async get(params) {
|
|
29142
29157
|
var _a16, _b16, _c, _d;
|
|
29143
29158
|
let response;
|
|
29144
|
-
let
|
|
29159
|
+
let path9 = "";
|
|
29145
29160
|
let queryParams = {};
|
|
29146
29161
|
if (this.apiClient.isVertexAI()) {
|
|
29147
29162
|
const body = getModelParametersToVertex(this.apiClient, params);
|
|
29148
|
-
|
|
29163
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29149
29164
|
queryParams = body["_query"];
|
|
29150
29165
|
delete body["_url"];
|
|
29151
29166
|
delete body["_query"];
|
|
29152
29167
|
response = this.apiClient.request({
|
|
29153
|
-
path:
|
|
29168
|
+
path: path9,
|
|
29154
29169
|
queryParams,
|
|
29155
29170
|
body: JSON.stringify(body),
|
|
29156
29171
|
httpMethod: "GET",
|
|
@@ -29165,12 +29180,12 @@ var init_web = __esm({
|
|
|
29165
29180
|
});
|
|
29166
29181
|
} else {
|
|
29167
29182
|
const body = getModelParametersToMldev(this.apiClient, params);
|
|
29168
|
-
|
|
29183
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29169
29184
|
queryParams = body["_query"];
|
|
29170
29185
|
delete body["_url"];
|
|
29171
29186
|
delete body["_query"];
|
|
29172
29187
|
response = this.apiClient.request({
|
|
29173
|
-
path:
|
|
29188
|
+
path: path9,
|
|
29174
29189
|
queryParams,
|
|
29175
29190
|
body: JSON.stringify(body),
|
|
29176
29191
|
httpMethod: "GET",
|
|
@@ -29188,16 +29203,16 @@ var init_web = __esm({
|
|
|
29188
29203
|
async listInternal(params) {
|
|
29189
29204
|
var _a16, _b16, _c, _d;
|
|
29190
29205
|
let response;
|
|
29191
|
-
let
|
|
29206
|
+
let path9 = "";
|
|
29192
29207
|
let queryParams = {};
|
|
29193
29208
|
if (this.apiClient.isVertexAI()) {
|
|
29194
29209
|
const body = listModelsParametersToVertex(this.apiClient, params);
|
|
29195
|
-
|
|
29210
|
+
path9 = formatMap("{models_url}", body["_url"]);
|
|
29196
29211
|
queryParams = body["_query"];
|
|
29197
29212
|
delete body["_url"];
|
|
29198
29213
|
delete body["_query"];
|
|
29199
29214
|
response = this.apiClient.request({
|
|
29200
|
-
path:
|
|
29215
|
+
path: path9,
|
|
29201
29216
|
queryParams,
|
|
29202
29217
|
body: JSON.stringify(body),
|
|
29203
29218
|
httpMethod: "GET",
|
|
@@ -29220,12 +29235,12 @@ var init_web = __esm({
|
|
|
29220
29235
|
});
|
|
29221
29236
|
} else {
|
|
29222
29237
|
const body = listModelsParametersToMldev(this.apiClient, params);
|
|
29223
|
-
|
|
29238
|
+
path9 = formatMap("{models_url}", body["_url"]);
|
|
29224
29239
|
queryParams = body["_query"];
|
|
29225
29240
|
delete body["_url"];
|
|
29226
29241
|
delete body["_query"];
|
|
29227
29242
|
response = this.apiClient.request({
|
|
29228
|
-
path:
|
|
29243
|
+
path: path9,
|
|
29229
29244
|
queryParams,
|
|
29230
29245
|
body: JSON.stringify(body),
|
|
29231
29246
|
httpMethod: "GET",
|
|
@@ -29268,16 +29283,16 @@ var init_web = __esm({
|
|
|
29268
29283
|
async update(params) {
|
|
29269
29284
|
var _a16, _b16, _c, _d;
|
|
29270
29285
|
let response;
|
|
29271
|
-
let
|
|
29286
|
+
let path9 = "";
|
|
29272
29287
|
let queryParams = {};
|
|
29273
29288
|
if (this.apiClient.isVertexAI()) {
|
|
29274
29289
|
const body = updateModelParametersToVertex(this.apiClient, params);
|
|
29275
|
-
|
|
29290
|
+
path9 = formatMap("{model}", body["_url"]);
|
|
29276
29291
|
queryParams = body["_query"];
|
|
29277
29292
|
delete body["_url"];
|
|
29278
29293
|
delete body["_query"];
|
|
29279
29294
|
response = this.apiClient.request({
|
|
29280
|
-
path:
|
|
29295
|
+
path: path9,
|
|
29281
29296
|
queryParams,
|
|
29282
29297
|
body: JSON.stringify(body),
|
|
29283
29298
|
httpMethod: "PATCH",
|
|
@@ -29292,12 +29307,12 @@ var init_web = __esm({
|
|
|
29292
29307
|
});
|
|
29293
29308
|
} else {
|
|
29294
29309
|
const body = updateModelParametersToMldev(this.apiClient, params);
|
|
29295
|
-
|
|
29310
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29296
29311
|
queryParams = body["_query"];
|
|
29297
29312
|
delete body["_url"];
|
|
29298
29313
|
delete body["_query"];
|
|
29299
29314
|
response = this.apiClient.request({
|
|
29300
|
-
path:
|
|
29315
|
+
path: path9,
|
|
29301
29316
|
queryParams,
|
|
29302
29317
|
body: JSON.stringify(body),
|
|
29303
29318
|
httpMethod: "PATCH",
|
|
@@ -29326,16 +29341,16 @@ var init_web = __esm({
|
|
|
29326
29341
|
async delete(params) {
|
|
29327
29342
|
var _a16, _b16, _c, _d;
|
|
29328
29343
|
let response;
|
|
29329
|
-
let
|
|
29344
|
+
let path9 = "";
|
|
29330
29345
|
let queryParams = {};
|
|
29331
29346
|
if (this.apiClient.isVertexAI()) {
|
|
29332
29347
|
const body = deleteModelParametersToVertex(this.apiClient, params);
|
|
29333
|
-
|
|
29348
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29334
29349
|
queryParams = body["_query"];
|
|
29335
29350
|
delete body["_url"];
|
|
29336
29351
|
delete body["_query"];
|
|
29337
29352
|
response = this.apiClient.request({
|
|
29338
|
-
path:
|
|
29353
|
+
path: path9,
|
|
29339
29354
|
queryParams,
|
|
29340
29355
|
body: JSON.stringify(body),
|
|
29341
29356
|
httpMethod: "DELETE",
|
|
@@ -29358,12 +29373,12 @@ var init_web = __esm({
|
|
|
29358
29373
|
});
|
|
29359
29374
|
} else {
|
|
29360
29375
|
const body = deleteModelParametersToMldev(this.apiClient, params);
|
|
29361
|
-
|
|
29376
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29362
29377
|
queryParams = body["_query"];
|
|
29363
29378
|
delete body["_url"];
|
|
29364
29379
|
delete body["_query"];
|
|
29365
29380
|
response = this.apiClient.request({
|
|
29366
|
-
path:
|
|
29381
|
+
path: path9,
|
|
29367
29382
|
queryParams,
|
|
29368
29383
|
body: JSON.stringify(body),
|
|
29369
29384
|
httpMethod: "DELETE",
|
|
@@ -29405,16 +29420,16 @@ var init_web = __esm({
|
|
|
29405
29420
|
async countTokens(params) {
|
|
29406
29421
|
var _a16, _b16, _c, _d;
|
|
29407
29422
|
let response;
|
|
29408
|
-
let
|
|
29423
|
+
let path9 = "";
|
|
29409
29424
|
let queryParams = {};
|
|
29410
29425
|
if (this.apiClient.isVertexAI()) {
|
|
29411
29426
|
const body = countTokensParametersToVertex(this.apiClient, params);
|
|
29412
|
-
|
|
29427
|
+
path9 = formatMap("{model}:countTokens", body["_url"]);
|
|
29413
29428
|
queryParams = body["_query"];
|
|
29414
29429
|
delete body["_url"];
|
|
29415
29430
|
delete body["_query"];
|
|
29416
29431
|
response = this.apiClient.request({
|
|
29417
|
-
path:
|
|
29432
|
+
path: path9,
|
|
29418
29433
|
queryParams,
|
|
29419
29434
|
body: JSON.stringify(body),
|
|
29420
29435
|
httpMethod: "POST",
|
|
@@ -29437,12 +29452,12 @@ var init_web = __esm({
|
|
|
29437
29452
|
});
|
|
29438
29453
|
} else {
|
|
29439
29454
|
const body = countTokensParametersToMldev(this.apiClient, params);
|
|
29440
|
-
|
|
29455
|
+
path9 = formatMap("{model}:countTokens", body["_url"]);
|
|
29441
29456
|
queryParams = body["_query"];
|
|
29442
29457
|
delete body["_url"];
|
|
29443
29458
|
delete body["_query"];
|
|
29444
29459
|
response = this.apiClient.request({
|
|
29445
|
-
path:
|
|
29460
|
+
path: path9,
|
|
29446
29461
|
queryParams,
|
|
29447
29462
|
body: JSON.stringify(body),
|
|
29448
29463
|
httpMethod: "POST",
|
|
@@ -29486,16 +29501,16 @@ var init_web = __esm({
|
|
|
29486
29501
|
async computeTokens(params) {
|
|
29487
29502
|
var _a16, _b16;
|
|
29488
29503
|
let response;
|
|
29489
|
-
let
|
|
29504
|
+
let path9 = "";
|
|
29490
29505
|
let queryParams = {};
|
|
29491
29506
|
if (this.apiClient.isVertexAI()) {
|
|
29492
29507
|
const body = computeTokensParametersToVertex(this.apiClient, params);
|
|
29493
|
-
|
|
29508
|
+
path9 = formatMap("{model}:computeTokens", body["_url"]);
|
|
29494
29509
|
queryParams = body["_query"];
|
|
29495
29510
|
delete body["_url"];
|
|
29496
29511
|
delete body["_query"];
|
|
29497
29512
|
response = this.apiClient.request({
|
|
29498
|
-
path:
|
|
29513
|
+
path: path9,
|
|
29499
29514
|
queryParams,
|
|
29500
29515
|
body: JSON.stringify(body),
|
|
29501
29516
|
httpMethod: "POST",
|
|
@@ -29526,16 +29541,16 @@ var init_web = __esm({
|
|
|
29526
29541
|
async generateVideosInternal(params) {
|
|
29527
29542
|
var _a16, _b16, _c, _d;
|
|
29528
29543
|
let response;
|
|
29529
|
-
let
|
|
29544
|
+
let path9 = "";
|
|
29530
29545
|
let queryParams = {};
|
|
29531
29546
|
if (this.apiClient.isVertexAI()) {
|
|
29532
29547
|
const body = generateVideosParametersToVertex(this.apiClient, params);
|
|
29533
|
-
|
|
29548
|
+
path9 = formatMap("{model}:predictLongRunning", body["_url"]);
|
|
29534
29549
|
queryParams = body["_query"];
|
|
29535
29550
|
delete body["_url"];
|
|
29536
29551
|
delete body["_query"];
|
|
29537
29552
|
response = this.apiClient.request({
|
|
29538
|
-
path:
|
|
29553
|
+
path: path9,
|
|
29539
29554
|
queryParams,
|
|
29540
29555
|
body: JSON.stringify(body),
|
|
29541
29556
|
httpMethod: "POST",
|
|
@@ -29552,12 +29567,12 @@ var init_web = __esm({
|
|
|
29552
29567
|
});
|
|
29553
29568
|
} else {
|
|
29554
29569
|
const body = generateVideosParametersToMldev(this.apiClient, params);
|
|
29555
|
-
|
|
29570
|
+
path9 = formatMap("{model}:predictLongRunning", body["_url"]);
|
|
29556
29571
|
queryParams = body["_query"];
|
|
29557
29572
|
delete body["_url"];
|
|
29558
29573
|
delete body["_query"];
|
|
29559
29574
|
response = this.apiClient.request({
|
|
29560
|
-
path:
|
|
29575
|
+
path: path9,
|
|
29561
29576
|
queryParams,
|
|
29562
29577
|
body: JSON.stringify(body),
|
|
29563
29578
|
httpMethod: "POST",
|
|
@@ -29659,16 +29674,16 @@ var init_web = __esm({
|
|
|
29659
29674
|
async getVideosOperationInternal(params) {
|
|
29660
29675
|
var _a16, _b16, _c, _d;
|
|
29661
29676
|
let response;
|
|
29662
|
-
let
|
|
29677
|
+
let path9 = "";
|
|
29663
29678
|
let queryParams = {};
|
|
29664
29679
|
if (this.apiClient.isVertexAI()) {
|
|
29665
29680
|
const body = getOperationParametersToVertex(params);
|
|
29666
|
-
|
|
29681
|
+
path9 = formatMap("{operationName}", body["_url"]);
|
|
29667
29682
|
queryParams = body["_query"];
|
|
29668
29683
|
delete body["_url"];
|
|
29669
29684
|
delete body["_query"];
|
|
29670
29685
|
response = this.apiClient.request({
|
|
29671
|
-
path:
|
|
29686
|
+
path: path9,
|
|
29672
29687
|
queryParams,
|
|
29673
29688
|
body: JSON.stringify(body),
|
|
29674
29689
|
httpMethod: "GET",
|
|
@@ -29680,12 +29695,12 @@ var init_web = __esm({
|
|
|
29680
29695
|
return response;
|
|
29681
29696
|
} else {
|
|
29682
29697
|
const body = getOperationParametersToMldev(params);
|
|
29683
|
-
|
|
29698
|
+
path9 = formatMap("{operationName}", body["_url"]);
|
|
29684
29699
|
queryParams = body["_query"];
|
|
29685
29700
|
delete body["_url"];
|
|
29686
29701
|
delete body["_query"];
|
|
29687
29702
|
response = this.apiClient.request({
|
|
29688
|
-
path:
|
|
29703
|
+
path: path9,
|
|
29689
29704
|
queryParams,
|
|
29690
29705
|
body: JSON.stringify(body),
|
|
29691
29706
|
httpMethod: "GET",
|
|
@@ -29700,16 +29715,16 @@ var init_web = __esm({
|
|
|
29700
29715
|
async fetchPredictVideosOperationInternal(params) {
|
|
29701
29716
|
var _a16, _b16;
|
|
29702
29717
|
let response;
|
|
29703
|
-
let
|
|
29718
|
+
let path9 = "";
|
|
29704
29719
|
let queryParams = {};
|
|
29705
29720
|
if (this.apiClient.isVertexAI()) {
|
|
29706
29721
|
const body = fetchPredictOperationParametersToVertex(params);
|
|
29707
|
-
|
|
29722
|
+
path9 = formatMap("{resourceName}:fetchPredictOperation", body["_url"]);
|
|
29708
29723
|
queryParams = body["_query"];
|
|
29709
29724
|
delete body["_url"];
|
|
29710
29725
|
delete body["_query"];
|
|
29711
29726
|
response = this.apiClient.request({
|
|
29712
|
-
path:
|
|
29727
|
+
path: path9,
|
|
29713
29728
|
queryParams,
|
|
29714
29729
|
body: JSON.stringify(body),
|
|
29715
29730
|
httpMethod: "POST",
|
|
@@ -29815,20 +29830,20 @@ var init_web = __esm({
|
|
|
29815
29830
|
async create(params) {
|
|
29816
29831
|
var _a16, _b16;
|
|
29817
29832
|
let response;
|
|
29818
|
-
let
|
|
29833
|
+
let path9 = "";
|
|
29819
29834
|
let queryParams = {};
|
|
29820
29835
|
if (this.apiClient.isVertexAI()) {
|
|
29821
29836
|
throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");
|
|
29822
29837
|
} else {
|
|
29823
29838
|
const body = createAuthTokenParametersToMldev(this.apiClient, params);
|
|
29824
|
-
|
|
29839
|
+
path9 = formatMap("auth_tokens", body["_url"]);
|
|
29825
29840
|
queryParams = body["_query"];
|
|
29826
29841
|
delete body["config"];
|
|
29827
29842
|
delete body["_url"];
|
|
29828
29843
|
delete body["_query"];
|
|
29829
29844
|
const transformedBody = convertBidiSetupToTokenSetup(body, params.config);
|
|
29830
29845
|
response = this.apiClient.request({
|
|
29831
|
-
path:
|
|
29846
|
+
path: path9,
|
|
29832
29847
|
queryParams,
|
|
29833
29848
|
body: JSON.stringify(transformedBody),
|
|
29834
29849
|
httpMethod: "POST",
|
|
@@ -29860,18 +29875,18 @@ var init_web = __esm({
|
|
|
29860
29875
|
async get(params) {
|
|
29861
29876
|
var _a16, _b16;
|
|
29862
29877
|
let response;
|
|
29863
|
-
let
|
|
29878
|
+
let path9 = "";
|
|
29864
29879
|
let queryParams = {};
|
|
29865
29880
|
if (this.apiClient.isVertexAI()) {
|
|
29866
29881
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
29867
29882
|
} else {
|
|
29868
29883
|
const body = getDocumentParametersToMldev(params);
|
|
29869
|
-
|
|
29884
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29870
29885
|
queryParams = body["_query"];
|
|
29871
29886
|
delete body["_url"];
|
|
29872
29887
|
delete body["_query"];
|
|
29873
29888
|
response = this.apiClient.request({
|
|
29874
|
-
path:
|
|
29889
|
+
path: path9,
|
|
29875
29890
|
queryParams,
|
|
29876
29891
|
body: JSON.stringify(body),
|
|
29877
29892
|
httpMethod: "GET",
|
|
@@ -29892,18 +29907,18 @@ var init_web = __esm({
|
|
|
29892
29907
|
*/
|
|
29893
29908
|
async delete(params) {
|
|
29894
29909
|
var _a16, _b16;
|
|
29895
|
-
let
|
|
29910
|
+
let path9 = "";
|
|
29896
29911
|
let queryParams = {};
|
|
29897
29912
|
if (this.apiClient.isVertexAI()) {
|
|
29898
29913
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
29899
29914
|
} else {
|
|
29900
29915
|
const body = deleteDocumentParametersToMldev(params);
|
|
29901
|
-
|
|
29916
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
29902
29917
|
queryParams = body["_query"];
|
|
29903
29918
|
delete body["_url"];
|
|
29904
29919
|
delete body["_query"];
|
|
29905
29920
|
await this.apiClient.request({
|
|
29906
|
-
path:
|
|
29921
|
+
path: path9,
|
|
29907
29922
|
queryParams,
|
|
29908
29923
|
body: JSON.stringify(body),
|
|
29909
29924
|
httpMethod: "DELETE",
|
|
@@ -29915,18 +29930,18 @@ var init_web = __esm({
|
|
|
29915
29930
|
async listInternal(params) {
|
|
29916
29931
|
var _a16, _b16;
|
|
29917
29932
|
let response;
|
|
29918
|
-
let
|
|
29933
|
+
let path9 = "";
|
|
29919
29934
|
let queryParams = {};
|
|
29920
29935
|
if (this.apiClient.isVertexAI()) {
|
|
29921
29936
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
29922
29937
|
} else {
|
|
29923
29938
|
const body = listDocumentsParametersToMldev(params);
|
|
29924
|
-
|
|
29939
|
+
path9 = formatMap("{parent}/documents", body["_url"]);
|
|
29925
29940
|
queryParams = body["_query"];
|
|
29926
29941
|
delete body["_url"];
|
|
29927
29942
|
delete body["_query"];
|
|
29928
29943
|
response = this.apiClient.request({
|
|
29929
|
-
path:
|
|
29944
|
+
path: path9,
|
|
29930
29945
|
queryParams,
|
|
29931
29946
|
body: JSON.stringify(body),
|
|
29932
29947
|
httpMethod: "GET",
|
|
@@ -30004,18 +30019,18 @@ var init_web = __esm({
|
|
|
30004
30019
|
async create(params) {
|
|
30005
30020
|
var _a16, _b16;
|
|
30006
30021
|
let response;
|
|
30007
|
-
let
|
|
30022
|
+
let path9 = "";
|
|
30008
30023
|
let queryParams = {};
|
|
30009
30024
|
if (this.apiClient.isVertexAI()) {
|
|
30010
30025
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
30011
30026
|
} else {
|
|
30012
30027
|
const body = createFileSearchStoreParametersToMldev(params);
|
|
30013
|
-
|
|
30028
|
+
path9 = formatMap("fileSearchStores", body["_url"]);
|
|
30014
30029
|
queryParams = body["_query"];
|
|
30015
30030
|
delete body["_url"];
|
|
30016
30031
|
delete body["_query"];
|
|
30017
30032
|
response = this.apiClient.request({
|
|
30018
|
-
path:
|
|
30033
|
+
path: path9,
|
|
30019
30034
|
queryParams,
|
|
30020
30035
|
body: JSON.stringify(body),
|
|
30021
30036
|
httpMethod: "POST",
|
|
@@ -30038,18 +30053,18 @@ var init_web = __esm({
|
|
|
30038
30053
|
async get(params) {
|
|
30039
30054
|
var _a16, _b16;
|
|
30040
30055
|
let response;
|
|
30041
|
-
let
|
|
30056
|
+
let path9 = "";
|
|
30042
30057
|
let queryParams = {};
|
|
30043
30058
|
if (this.apiClient.isVertexAI()) {
|
|
30044
30059
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
30045
30060
|
} else {
|
|
30046
30061
|
const body = getFileSearchStoreParametersToMldev(params);
|
|
30047
|
-
|
|
30062
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
30048
30063
|
queryParams = body["_query"];
|
|
30049
30064
|
delete body["_url"];
|
|
30050
30065
|
delete body["_query"];
|
|
30051
30066
|
response = this.apiClient.request({
|
|
30052
|
-
path:
|
|
30067
|
+
path: path9,
|
|
30053
30068
|
queryParams,
|
|
30054
30069
|
body: JSON.stringify(body),
|
|
30055
30070
|
httpMethod: "GET",
|
|
@@ -30070,18 +30085,18 @@ var init_web = __esm({
|
|
|
30070
30085
|
*/
|
|
30071
30086
|
async delete(params) {
|
|
30072
30087
|
var _a16, _b16;
|
|
30073
|
-
let
|
|
30088
|
+
let path9 = "";
|
|
30074
30089
|
let queryParams = {};
|
|
30075
30090
|
if (this.apiClient.isVertexAI()) {
|
|
30076
30091
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
30077
30092
|
} else {
|
|
30078
30093
|
const body = deleteFileSearchStoreParametersToMldev(params);
|
|
30079
|
-
|
|
30094
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
30080
30095
|
queryParams = body["_query"];
|
|
30081
30096
|
delete body["_url"];
|
|
30082
30097
|
delete body["_query"];
|
|
30083
30098
|
await this.apiClient.request({
|
|
30084
|
-
path:
|
|
30099
|
+
path: path9,
|
|
30085
30100
|
queryParams,
|
|
30086
30101
|
body: JSON.stringify(body),
|
|
30087
30102
|
httpMethod: "DELETE",
|
|
@@ -30093,18 +30108,18 @@ var init_web = __esm({
|
|
|
30093
30108
|
async listInternal(params) {
|
|
30094
30109
|
var _a16, _b16;
|
|
30095
30110
|
let response;
|
|
30096
|
-
let
|
|
30111
|
+
let path9 = "";
|
|
30097
30112
|
let queryParams = {};
|
|
30098
30113
|
if (this.apiClient.isVertexAI()) {
|
|
30099
30114
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
30100
30115
|
} else {
|
|
30101
30116
|
const body = listFileSearchStoresParametersToMldev(params);
|
|
30102
|
-
|
|
30117
|
+
path9 = formatMap("fileSearchStores", body["_url"]);
|
|
30103
30118
|
queryParams = body["_query"];
|
|
30104
30119
|
delete body["_url"];
|
|
30105
30120
|
delete body["_query"];
|
|
30106
30121
|
response = this.apiClient.request({
|
|
30107
|
-
path:
|
|
30122
|
+
path: path9,
|
|
30108
30123
|
queryParams,
|
|
30109
30124
|
body: JSON.stringify(body),
|
|
30110
30125
|
httpMethod: "GET",
|
|
@@ -30124,18 +30139,18 @@ var init_web = __esm({
|
|
|
30124
30139
|
async uploadToFileSearchStoreInternal(params) {
|
|
30125
30140
|
var _a16, _b16;
|
|
30126
30141
|
let response;
|
|
30127
|
-
let
|
|
30142
|
+
let path9 = "";
|
|
30128
30143
|
let queryParams = {};
|
|
30129
30144
|
if (this.apiClient.isVertexAI()) {
|
|
30130
30145
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
30131
30146
|
} else {
|
|
30132
30147
|
const body = uploadToFileSearchStoreParametersToMldev(params);
|
|
30133
|
-
|
|
30148
|
+
path9 = formatMap("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore", body["_url"]);
|
|
30134
30149
|
queryParams = body["_query"];
|
|
30135
30150
|
delete body["_url"];
|
|
30136
30151
|
delete body["_query"];
|
|
30137
30152
|
response = this.apiClient.request({
|
|
30138
|
-
path:
|
|
30153
|
+
path: path9,
|
|
30139
30154
|
queryParams,
|
|
30140
30155
|
body: JSON.stringify(body),
|
|
30141
30156
|
httpMethod: "POST",
|
|
@@ -30163,18 +30178,18 @@ var init_web = __esm({
|
|
|
30163
30178
|
async importFile(params) {
|
|
30164
30179
|
var _a16, _b16;
|
|
30165
30180
|
let response;
|
|
30166
|
-
let
|
|
30181
|
+
let path9 = "";
|
|
30167
30182
|
let queryParams = {};
|
|
30168
30183
|
if (this.apiClient.isVertexAI()) {
|
|
30169
30184
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
30170
30185
|
} else {
|
|
30171
30186
|
const body = importFileParametersToMldev(params);
|
|
30172
|
-
|
|
30187
|
+
path9 = formatMap("{file_search_store_name}:importFile", body["_url"]);
|
|
30173
30188
|
queryParams = body["_query"];
|
|
30174
30189
|
delete body["_url"];
|
|
30175
30190
|
delete body["_query"];
|
|
30176
30191
|
response = this.apiClient.request({
|
|
30177
|
-
path:
|
|
30192
|
+
path: path9,
|
|
30178
30193
|
queryParams,
|
|
30179
30194
|
body: JSON.stringify(body),
|
|
30180
30195
|
httpMethod: "POST",
|
|
@@ -30367,12 +30382,12 @@ var init_web = __esm({
|
|
|
30367
30382
|
};
|
|
30368
30383
|
APIResource._key = [];
|
|
30369
30384
|
EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
30370
|
-
createPathTagFunction = (pathEncoder = encodeURIPath) => (function
|
|
30385
|
+
createPathTagFunction = (pathEncoder = encodeURIPath) => (function path9(statics, ...params) {
|
|
30371
30386
|
if (statics.length === 1)
|
|
30372
30387
|
return statics[0];
|
|
30373
30388
|
let postPath = false;
|
|
30374
30389
|
const invalidSegments = [];
|
|
30375
|
-
const
|
|
30390
|
+
const path10 = statics.reduce((previousValue, currentValue, index) => {
|
|
30376
30391
|
var _a16, _b16, _c;
|
|
30377
30392
|
if (/[?#]/.test(currentValue)) {
|
|
30378
30393
|
postPath = true;
|
|
@@ -30390,7 +30405,7 @@ var init_web = __esm({
|
|
|
30390
30405
|
}
|
|
30391
30406
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
30392
30407
|
}, "");
|
|
30393
|
-
const pathOnly =
|
|
30408
|
+
const pathOnly = path10.split(/[?#]/, 1)[0];
|
|
30394
30409
|
const invalidSegmentPattern = /(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
30395
30410
|
let match2;
|
|
30396
30411
|
while ((match2 = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -30414,10 +30429,10 @@ var init_web = __esm({
|
|
|
30414
30429
|
}, "");
|
|
30415
30430
|
throw new GeminiNextGenAPIClientError(`Path parameters result in path with invalid segments:
|
|
30416
30431
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
30417
|
-
${
|
|
30432
|
+
${path10}
|
|
30418
30433
|
${underline}`);
|
|
30419
30434
|
}
|
|
30420
|
-
return
|
|
30435
|
+
return path10;
|
|
30421
30436
|
});
|
|
30422
30437
|
path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
30423
30438
|
BaseInteractions = class extends APIResource {
|
|
@@ -30971,9 +30986,9 @@ ${underline}`);
|
|
|
30971
30986
|
makeStatusError(status, error, message, headers) {
|
|
30972
30987
|
return APIError.generate(status, error, message, headers);
|
|
30973
30988
|
}
|
|
30974
|
-
buildURL(
|
|
30989
|
+
buildURL(path9, query, defaultBaseURL) {
|
|
30975
30990
|
const baseURL = !this.baseURLOverridden() && defaultBaseURL || this.baseURL;
|
|
30976
|
-
const url = isAbsoluteURL(
|
|
30991
|
+
const url = isAbsoluteURL(path9) ? new URL(path9) : new URL(baseURL + (baseURL.endsWith("/") && path9.startsWith("/") ? path9.slice(1) : path9));
|
|
30977
30992
|
const defaultQuery = this.defaultQuery();
|
|
30978
30993
|
const pathQuery = Object.fromEntries(url.searchParams);
|
|
30979
30994
|
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
@@ -31002,24 +31017,24 @@ ${underline}`);
|
|
|
31002
31017
|
*/
|
|
31003
31018
|
async prepareRequest(request, { url, options }) {
|
|
31004
31019
|
}
|
|
31005
|
-
get(
|
|
31006
|
-
return this.methodRequest("get",
|
|
31020
|
+
get(path9, opts) {
|
|
31021
|
+
return this.methodRequest("get", path9, opts);
|
|
31007
31022
|
}
|
|
31008
|
-
post(
|
|
31009
|
-
return this.methodRequest("post",
|
|
31023
|
+
post(path9, opts) {
|
|
31024
|
+
return this.methodRequest("post", path9, opts);
|
|
31010
31025
|
}
|
|
31011
|
-
patch(
|
|
31012
|
-
return this.methodRequest("patch",
|
|
31026
|
+
patch(path9, opts) {
|
|
31027
|
+
return this.methodRequest("patch", path9, opts);
|
|
31013
31028
|
}
|
|
31014
|
-
put(
|
|
31015
|
-
return this.methodRequest("put",
|
|
31029
|
+
put(path9, opts) {
|
|
31030
|
+
return this.methodRequest("put", path9, opts);
|
|
31016
31031
|
}
|
|
31017
|
-
delete(
|
|
31018
|
-
return this.methodRequest("delete",
|
|
31032
|
+
delete(path9, opts) {
|
|
31033
|
+
return this.methodRequest("delete", path9, opts);
|
|
31019
31034
|
}
|
|
31020
|
-
methodRequest(method,
|
|
31035
|
+
methodRequest(method, path9, opts) {
|
|
31021
31036
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
31022
|
-
return Object.assign({ method, path:
|
|
31037
|
+
return Object.assign({ method, path: path9 }, opts2);
|
|
31023
31038
|
}));
|
|
31024
31039
|
}
|
|
31025
31040
|
request(options, remainingRetries = null) {
|
|
@@ -31193,8 +31208,8 @@ ${underline}`);
|
|
|
31193
31208
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
31194
31209
|
var _b16, _c, _d;
|
|
31195
31210
|
const options = Object.assign({}, inputOptions);
|
|
31196
|
-
const { method, path:
|
|
31197
|
-
const url = this.buildURL(
|
|
31211
|
+
const { method, path: path9, query, defaultBaseURL } = options;
|
|
31212
|
+
const url = this.buildURL(path9, query, defaultBaseURL);
|
|
31198
31213
|
if ("timeout" in options)
|
|
31199
31214
|
validatePositiveInteger("timeout", options.timeout);
|
|
31200
31215
|
options.timeout = (_b16 = options.timeout) !== null && _b16 !== void 0 ? _b16 : this.timeout;
|
|
@@ -31323,16 +31338,16 @@ ${underline}`);
|
|
|
31323
31338
|
async getInternal(params) {
|
|
31324
31339
|
var _a16, _b16, _c, _d;
|
|
31325
31340
|
let response;
|
|
31326
|
-
let
|
|
31341
|
+
let path9 = "";
|
|
31327
31342
|
let queryParams = {};
|
|
31328
31343
|
if (this.apiClient.isVertexAI()) {
|
|
31329
31344
|
const body = getTuningJobParametersToVertex(params);
|
|
31330
|
-
|
|
31345
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
31331
31346
|
queryParams = body["_query"];
|
|
31332
31347
|
delete body["_url"];
|
|
31333
31348
|
delete body["_query"];
|
|
31334
31349
|
response = this.apiClient.request({
|
|
31335
|
-
path:
|
|
31350
|
+
path: path9,
|
|
31336
31351
|
queryParams,
|
|
31337
31352
|
body: JSON.stringify(body),
|
|
31338
31353
|
httpMethod: "GET",
|
|
@@ -31353,12 +31368,12 @@ ${underline}`);
|
|
|
31353
31368
|
});
|
|
31354
31369
|
} else {
|
|
31355
31370
|
const body = getTuningJobParametersToMldev(params);
|
|
31356
|
-
|
|
31371
|
+
path9 = formatMap("{name}", body["_url"]);
|
|
31357
31372
|
queryParams = body["_query"];
|
|
31358
31373
|
delete body["_url"];
|
|
31359
31374
|
delete body["_query"];
|
|
31360
31375
|
response = this.apiClient.request({
|
|
31361
|
-
path:
|
|
31376
|
+
path: path9,
|
|
31362
31377
|
queryParams,
|
|
31363
31378
|
body: JSON.stringify(body),
|
|
31364
31379
|
httpMethod: "GET",
|
|
@@ -31382,16 +31397,16 @@ ${underline}`);
|
|
|
31382
31397
|
async listInternal(params) {
|
|
31383
31398
|
var _a16, _b16, _c, _d;
|
|
31384
31399
|
let response;
|
|
31385
|
-
let
|
|
31400
|
+
let path9 = "";
|
|
31386
31401
|
let queryParams = {};
|
|
31387
31402
|
if (this.apiClient.isVertexAI()) {
|
|
31388
31403
|
const body = listTuningJobsParametersToVertex(params);
|
|
31389
|
-
|
|
31404
|
+
path9 = formatMap("tuningJobs", body["_url"]);
|
|
31390
31405
|
queryParams = body["_query"];
|
|
31391
31406
|
delete body["_url"];
|
|
31392
31407
|
delete body["_query"];
|
|
31393
31408
|
response = this.apiClient.request({
|
|
31394
|
-
path:
|
|
31409
|
+
path: path9,
|
|
31395
31410
|
queryParams,
|
|
31396
31411
|
body: JSON.stringify(body),
|
|
31397
31412
|
httpMethod: "GET",
|
|
@@ -31414,12 +31429,12 @@ ${underline}`);
|
|
|
31414
31429
|
});
|
|
31415
31430
|
} else {
|
|
31416
31431
|
const body = listTuningJobsParametersToMldev(params);
|
|
31417
|
-
|
|
31432
|
+
path9 = formatMap("tunedModels", body["_url"]);
|
|
31418
31433
|
queryParams = body["_query"];
|
|
31419
31434
|
delete body["_url"];
|
|
31420
31435
|
delete body["_query"];
|
|
31421
31436
|
response = this.apiClient.request({
|
|
31422
|
-
path:
|
|
31437
|
+
path: path9,
|
|
31423
31438
|
queryParams,
|
|
31424
31439
|
body: JSON.stringify(body),
|
|
31425
31440
|
httpMethod: "GET",
|
|
@@ -31456,16 +31471,16 @@ ${underline}`);
|
|
|
31456
31471
|
async cancel(params) {
|
|
31457
31472
|
var _a16, _b16, _c, _d;
|
|
31458
31473
|
let response;
|
|
31459
|
-
let
|
|
31474
|
+
let path9 = "";
|
|
31460
31475
|
let queryParams = {};
|
|
31461
31476
|
if (this.apiClient.isVertexAI()) {
|
|
31462
31477
|
const body = cancelTuningJobParametersToVertex(params);
|
|
31463
|
-
|
|
31478
|
+
path9 = formatMap("{name}:cancel", body["_url"]);
|
|
31464
31479
|
queryParams = body["_query"];
|
|
31465
31480
|
delete body["_url"];
|
|
31466
31481
|
delete body["_query"];
|
|
31467
31482
|
response = this.apiClient.request({
|
|
31468
|
-
path:
|
|
31483
|
+
path: path9,
|
|
31469
31484
|
queryParams,
|
|
31470
31485
|
body: JSON.stringify(body),
|
|
31471
31486
|
httpMethod: "POST",
|
|
@@ -31488,12 +31503,12 @@ ${underline}`);
|
|
|
31488
31503
|
});
|
|
31489
31504
|
} else {
|
|
31490
31505
|
const body = cancelTuningJobParametersToMldev(params);
|
|
31491
|
-
|
|
31506
|
+
path9 = formatMap("{name}:cancel", body["_url"]);
|
|
31492
31507
|
queryParams = body["_query"];
|
|
31493
31508
|
delete body["_url"];
|
|
31494
31509
|
delete body["_query"];
|
|
31495
31510
|
response = this.apiClient.request({
|
|
31496
|
-
path:
|
|
31511
|
+
path: path9,
|
|
31497
31512
|
queryParams,
|
|
31498
31513
|
body: JSON.stringify(body),
|
|
31499
31514
|
httpMethod: "POST",
|
|
@@ -31519,16 +31534,16 @@ ${underline}`);
|
|
|
31519
31534
|
async tuneInternal(params) {
|
|
31520
31535
|
var _a16, _b16;
|
|
31521
31536
|
let response;
|
|
31522
|
-
let
|
|
31537
|
+
let path9 = "";
|
|
31523
31538
|
let queryParams = {};
|
|
31524
31539
|
if (this.apiClient.isVertexAI()) {
|
|
31525
31540
|
const body = createTuningJobParametersPrivateToVertex(params, params);
|
|
31526
|
-
|
|
31541
|
+
path9 = formatMap("tuningJobs", body["_url"]);
|
|
31527
31542
|
queryParams = body["_query"];
|
|
31528
31543
|
delete body["_url"];
|
|
31529
31544
|
delete body["_query"];
|
|
31530
31545
|
response = this.apiClient.request({
|
|
31531
|
-
path:
|
|
31546
|
+
path: path9,
|
|
31532
31547
|
queryParams,
|
|
31533
31548
|
body: JSON.stringify(body),
|
|
31534
31549
|
httpMethod: "POST",
|
|
@@ -31554,18 +31569,18 @@ ${underline}`);
|
|
|
31554
31569
|
async tuneMldevInternal(params) {
|
|
31555
31570
|
var _a16, _b16;
|
|
31556
31571
|
let response;
|
|
31557
|
-
let
|
|
31572
|
+
let path9 = "";
|
|
31558
31573
|
let queryParams = {};
|
|
31559
31574
|
if (this.apiClient.isVertexAI()) {
|
|
31560
31575
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
31561
31576
|
} else {
|
|
31562
31577
|
const body = createTuningJobParametersPrivateToMldev(params);
|
|
31563
|
-
|
|
31578
|
+
path9 = formatMap("tunedModels", body["_url"]);
|
|
31564
31579
|
queryParams = body["_query"];
|
|
31565
31580
|
delete body["_url"];
|
|
31566
31581
|
delete body["_query"];
|
|
31567
31582
|
response = this.apiClient.request({
|
|
31568
|
-
path:
|
|
31583
|
+
path: path9,
|
|
31569
31584
|
queryParams,
|
|
31570
31585
|
body: JSON.stringify(body),
|
|
31571
31586
|
httpMethod: "POST",
|
|
@@ -33801,12 +33816,12 @@ var init_path = __esm({
|
|
|
33801
33816
|
"../../node_modules/.pnpm/groq-sdk@1.1.2/node_modules/groq-sdk/internal/utils/path.mjs"() {
|
|
33802
33817
|
init_error();
|
|
33803
33818
|
EMPTY2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
33804
|
-
createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function
|
|
33819
|
+
createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path9(statics, ...params) {
|
|
33805
33820
|
if (statics.length === 1)
|
|
33806
33821
|
return statics[0];
|
|
33807
33822
|
let postPath = false;
|
|
33808
33823
|
const invalidSegments = [];
|
|
33809
|
-
const
|
|
33824
|
+
const path10 = statics.reduce((previousValue, currentValue, index) => {
|
|
33810
33825
|
if (/[?#]/.test(currentValue)) {
|
|
33811
33826
|
postPath = true;
|
|
33812
33827
|
}
|
|
@@ -33823,7 +33838,7 @@ var init_path = __esm({
|
|
|
33823
33838
|
}
|
|
33824
33839
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
33825
33840
|
}, "");
|
|
33826
|
-
const pathOnly =
|
|
33841
|
+
const pathOnly = path10.split(/[?#]/, 1)[0];
|
|
33827
33842
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
33828
33843
|
let match2;
|
|
33829
33844
|
while ((match2 = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -33844,10 +33859,10 @@ var init_path = __esm({
|
|
|
33844
33859
|
}, "");
|
|
33845
33860
|
throw new GroqError(`Path parameters result in path with invalid segments:
|
|
33846
33861
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
33847
|
-
${
|
|
33862
|
+
${path10}
|
|
33848
33863
|
${underline}`);
|
|
33849
33864
|
}
|
|
33850
|
-
return
|
|
33865
|
+
return path10;
|
|
33851
33866
|
};
|
|
33852
33867
|
path2 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
|
|
33853
33868
|
}
|
|
@@ -34759,9 +34774,9 @@ var init_client = __esm({
|
|
|
34759
34774
|
makeStatusError(status, error, message, headers) {
|
|
34760
34775
|
return APIError2.generate(status, error, message, headers);
|
|
34761
34776
|
}
|
|
34762
|
-
buildURL(
|
|
34777
|
+
buildURL(path9, query, defaultBaseURL) {
|
|
34763
34778
|
const baseURL = !__classPrivateFieldGet(this, _Groq_instances, "m", _Groq_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
34764
|
-
const url = isAbsoluteURL2(
|
|
34779
|
+
const url = isAbsoluteURL2(path9) ? new URL(path9) : new URL(baseURL + (baseURL.endsWith("/") && path9.startsWith("/") ? path9.slice(1) : path9));
|
|
34765
34780
|
const defaultQuery = this.defaultQuery();
|
|
34766
34781
|
const pathQuery = Object.fromEntries(url.searchParams);
|
|
34767
34782
|
if (!isEmptyObj2(defaultQuery) || !isEmptyObj2(pathQuery)) {
|
|
@@ -34785,24 +34800,24 @@ var init_client = __esm({
|
|
|
34785
34800
|
*/
|
|
34786
34801
|
async prepareRequest(request, { url, options }) {
|
|
34787
34802
|
}
|
|
34788
|
-
get(
|
|
34789
|
-
return this.methodRequest("get",
|
|
34803
|
+
get(path9, opts) {
|
|
34804
|
+
return this.methodRequest("get", path9, opts);
|
|
34790
34805
|
}
|
|
34791
|
-
post(
|
|
34792
|
-
return this.methodRequest("post",
|
|
34806
|
+
post(path9, opts) {
|
|
34807
|
+
return this.methodRequest("post", path9, opts);
|
|
34793
34808
|
}
|
|
34794
|
-
patch(
|
|
34795
|
-
return this.methodRequest("patch",
|
|
34809
|
+
patch(path9, opts) {
|
|
34810
|
+
return this.methodRequest("patch", path9, opts);
|
|
34796
34811
|
}
|
|
34797
|
-
put(
|
|
34798
|
-
return this.methodRequest("put",
|
|
34812
|
+
put(path9, opts) {
|
|
34813
|
+
return this.methodRequest("put", path9, opts);
|
|
34799
34814
|
}
|
|
34800
|
-
delete(
|
|
34801
|
-
return this.methodRequest("delete",
|
|
34815
|
+
delete(path9, opts) {
|
|
34816
|
+
return this.methodRequest("delete", path9, opts);
|
|
34802
34817
|
}
|
|
34803
|
-
methodRequest(method,
|
|
34818
|
+
methodRequest(method, path9, opts) {
|
|
34804
34819
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
34805
|
-
return { method, path:
|
|
34820
|
+
return { method, path: path9, ...opts2 };
|
|
34806
34821
|
}));
|
|
34807
34822
|
}
|
|
34808
34823
|
request(options, remainingRetries = null) {
|
|
@@ -34978,8 +34993,8 @@ var init_client = __esm({
|
|
|
34978
34993
|
}
|
|
34979
34994
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
34980
34995
|
const options = { ...inputOptions };
|
|
34981
|
-
const { method, path:
|
|
34982
|
-
const url = this.buildURL(
|
|
34996
|
+
const { method, path: path9, query, defaultBaseURL } = options;
|
|
34997
|
+
const url = this.buildURL(path9, query, defaultBaseURL);
|
|
34983
34998
|
if ("timeout" in options)
|
|
34984
34999
|
validatePositiveInteger2("timeout", options.timeout);
|
|
34985
35000
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -44277,14 +44292,14 @@ var init_sdks = __esm({
|
|
|
44277
44292
|
}
|
|
44278
44293
|
}
|
|
44279
44294
|
_createRequest(context, conf, options) {
|
|
44280
|
-
const { method, path:
|
|
44295
|
+
const { method, path: path9, query, headers: opHeaders, security } = conf;
|
|
44281
44296
|
const base = conf.baseURL ?? this._baseURL;
|
|
44282
44297
|
if (!base) {
|
|
44283
44298
|
return ERR(new InvalidRequestError("No base URL provided for operation"));
|
|
44284
44299
|
}
|
|
44285
44300
|
const reqURL = new URL(base);
|
|
44286
|
-
const inputURL = new URL(
|
|
44287
|
-
if (
|
|
44301
|
+
const inputURL = new URL(path9, reqURL);
|
|
44302
|
+
if (path9) {
|
|
44288
44303
|
reqURL.pathname += reqURL.pathname.endsWith("/") ? "" : "/";
|
|
44289
44304
|
reqURL.pathname += inputURL.pathname.replace(/^\/+/, "");
|
|
44290
44305
|
}
|
|
@@ -46322,7 +46337,7 @@ async function $do(client, request, options) {
|
|
|
46322
46337
|
}
|
|
46323
46338
|
const payload = parsed.value;
|
|
46324
46339
|
const body = null;
|
|
46325
|
-
const
|
|
46340
|
+
const path9 = pathToFunc("/activity")();
|
|
46326
46341
|
const query = encodeFormQuery({
|
|
46327
46342
|
"date": payload?.date
|
|
46328
46343
|
});
|
|
@@ -46346,7 +46361,7 @@ async function $do(client, request, options) {
|
|
|
46346
46361
|
security: requestSecurity,
|
|
46347
46362
|
method: "GET",
|
|
46348
46363
|
baseURL: options?.serverURL,
|
|
46349
|
-
path:
|
|
46364
|
+
path: path9,
|
|
46350
46365
|
headers,
|
|
46351
46366
|
query,
|
|
46352
46367
|
body,
|
|
@@ -46422,7 +46437,7 @@ async function $do2(client, request, options) {
|
|
|
46422
46437
|
}
|
|
46423
46438
|
const payload = parsed.value;
|
|
46424
46439
|
const body = encodeJSON("body", payload, { explode: true });
|
|
46425
|
-
const
|
|
46440
|
+
const path9 = pathToFunc("/keys")();
|
|
46426
46441
|
const headers = new Headers(compactMap({
|
|
46427
46442
|
"Content-Type": "application/json",
|
|
46428
46443
|
Accept: "application/json"
|
|
@@ -46444,7 +46459,7 @@ async function $do2(client, request, options) {
|
|
|
46444
46459
|
security: requestSecurity,
|
|
46445
46460
|
method: "POST",
|
|
46446
46461
|
baseURL: options?.serverURL,
|
|
46447
|
-
path:
|
|
46462
|
+
path: path9,
|
|
46448
46463
|
headers,
|
|
46449
46464
|
body,
|
|
46450
46465
|
userAgent: client._options.userAgent,
|
|
@@ -46504,7 +46519,7 @@ async function $do3(client, request, options) {
|
|
|
46504
46519
|
charEncoding: "percent"
|
|
46505
46520
|
})
|
|
46506
46521
|
};
|
|
46507
|
-
const
|
|
46522
|
+
const path9 = pathToFunc("/keys/{hash}")(pathParams);
|
|
46508
46523
|
const headers = new Headers(compactMap({
|
|
46509
46524
|
Accept: "application/json"
|
|
46510
46525
|
}));
|
|
@@ -46525,7 +46540,7 @@ async function $do3(client, request, options) {
|
|
|
46525
46540
|
security: requestSecurity,
|
|
46526
46541
|
method: "DELETE",
|
|
46527
46542
|
baseURL: options?.serverURL,
|
|
46528
|
-
path:
|
|
46543
|
+
path: path9,
|
|
46529
46544
|
headers,
|
|
46530
46545
|
body,
|
|
46531
46546
|
userAgent: client._options.userAgent,
|
|
@@ -46585,7 +46600,7 @@ async function $do4(client, request, options) {
|
|
|
46585
46600
|
charEncoding: "percent"
|
|
46586
46601
|
})
|
|
46587
46602
|
};
|
|
46588
|
-
const
|
|
46603
|
+
const path9 = pathToFunc("/keys/{hash}")(pathParams);
|
|
46589
46604
|
const headers = new Headers(compactMap({
|
|
46590
46605
|
Accept: "application/json"
|
|
46591
46606
|
}));
|
|
@@ -46606,7 +46621,7 @@ async function $do4(client, request, options) {
|
|
|
46606
46621
|
security: requestSecurity,
|
|
46607
46622
|
method: "GET",
|
|
46608
46623
|
baseURL: options?.serverURL,
|
|
46609
|
-
path:
|
|
46624
|
+
path: path9,
|
|
46610
46625
|
headers,
|
|
46611
46626
|
body,
|
|
46612
46627
|
userAgent: client._options.userAgent,
|
|
@@ -46654,7 +46669,7 @@ function apiKeysGetCurrentKeyMetadata(client, options) {
|
|
|
46654
46669
|
return new APIPromise3($do5(client, options));
|
|
46655
46670
|
}
|
|
46656
46671
|
async function $do5(client, options) {
|
|
46657
|
-
const
|
|
46672
|
+
const path9 = pathToFunc("/key")();
|
|
46658
46673
|
const headers = new Headers(compactMap({
|
|
46659
46674
|
Accept: "application/json"
|
|
46660
46675
|
}));
|
|
@@ -46675,7 +46690,7 @@ async function $do5(client, options) {
|
|
|
46675
46690
|
security: requestSecurity,
|
|
46676
46691
|
method: "GET",
|
|
46677
46692
|
baseURL: options?.serverURL,
|
|
46678
|
-
path:
|
|
46693
|
+
path: path9,
|
|
46679
46694
|
headers,
|
|
46680
46695
|
userAgent: client._options.userAgent,
|
|
46681
46696
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -46726,7 +46741,7 @@ async function $do6(client, request, options) {
|
|
|
46726
46741
|
}
|
|
46727
46742
|
const payload = parsed.value;
|
|
46728
46743
|
const body = null;
|
|
46729
|
-
const
|
|
46744
|
+
const path9 = pathToFunc("/keys")();
|
|
46730
46745
|
const query = encodeFormQuery({
|
|
46731
46746
|
"include_disabled": payload?.include_disabled,
|
|
46732
46747
|
"offset": payload?.offset
|
|
@@ -46751,7 +46766,7 @@ async function $do6(client, request, options) {
|
|
|
46751
46766
|
security: requestSecurity,
|
|
46752
46767
|
method: "GET",
|
|
46753
46768
|
baseURL: options?.serverURL,
|
|
46754
|
-
path:
|
|
46769
|
+
path: path9,
|
|
46755
46770
|
headers,
|
|
46756
46771
|
query,
|
|
46757
46772
|
body,
|
|
@@ -46812,7 +46827,7 @@ async function $do7(client, request, options) {
|
|
|
46812
46827
|
charEncoding: "percent"
|
|
46813
46828
|
})
|
|
46814
46829
|
};
|
|
46815
|
-
const
|
|
46830
|
+
const path9 = pathToFunc("/keys/{hash}")(pathParams);
|
|
46816
46831
|
const headers = new Headers(compactMap({
|
|
46817
46832
|
"Content-Type": "application/json",
|
|
46818
46833
|
Accept: "application/json"
|
|
@@ -46834,7 +46849,7 @@ async function $do7(client, request, options) {
|
|
|
46834
46849
|
security: requestSecurity,
|
|
46835
46850
|
method: "PATCH",
|
|
46836
46851
|
baseURL: options?.serverURL,
|
|
46837
|
-
path:
|
|
46852
|
+
path: path9,
|
|
46838
46853
|
headers,
|
|
46839
46854
|
body,
|
|
46840
46855
|
userAgent: client._options.userAgent,
|
|
@@ -46944,7 +46959,7 @@ async function $do8(client, request, options) {
|
|
|
46944
46959
|
}
|
|
46945
46960
|
const payload = parsed.value;
|
|
46946
46961
|
const body = encodeJSON("body", payload, { explode: true });
|
|
46947
|
-
const
|
|
46962
|
+
const path9 = pathToFunc("/responses")();
|
|
46948
46963
|
const headers = new Headers(compactMap({
|
|
46949
46964
|
"Content-Type": "application/json",
|
|
46950
46965
|
Accept: request?.stream ? "text/event-stream" : "application/json"
|
|
@@ -46966,7 +46981,7 @@ async function $do8(client, request, options) {
|
|
|
46966
46981
|
security: requestSecurity,
|
|
46967
46982
|
method: "POST",
|
|
46968
46983
|
baseURL: options?.serverURL,
|
|
46969
|
-
path:
|
|
46984
|
+
path: path9,
|
|
46970
46985
|
headers,
|
|
46971
46986
|
body,
|
|
46972
46987
|
userAgent: client._options.userAgent,
|
|
@@ -47066,7 +47081,7 @@ async function $do9(client, request, options) {
|
|
|
47066
47081
|
}
|
|
47067
47082
|
const payload = parsed.value;
|
|
47068
47083
|
const body = encodeJSON("body", payload, { explode: true });
|
|
47069
|
-
const
|
|
47084
|
+
const path9 = pathToFunc("/chat/completions")();
|
|
47070
47085
|
const headers = new Headers(compactMap({
|
|
47071
47086
|
"Content-Type": "application/json",
|
|
47072
47087
|
Accept: request?.stream ? "text/event-stream" : "application/json"
|
|
@@ -47088,7 +47103,7 @@ async function $do9(client, request, options) {
|
|
|
47088
47103
|
security: requestSecurity,
|
|
47089
47104
|
method: "POST",
|
|
47090
47105
|
baseURL: options?.serverURL,
|
|
47091
|
-
path:
|
|
47106
|
+
path: path9,
|
|
47092
47107
|
headers,
|
|
47093
47108
|
body,
|
|
47094
47109
|
userAgent: client._options.userAgent,
|
|
@@ -47158,7 +47173,7 @@ async function $do10(client, request, options) {
|
|
|
47158
47173
|
}
|
|
47159
47174
|
const payload = parsed.value;
|
|
47160
47175
|
const body = encodeJSON("body", payload, { explode: true });
|
|
47161
|
-
const
|
|
47176
|
+
const path9 = pathToFunc("/completions")();
|
|
47162
47177
|
const headers = new Headers(compactMap({
|
|
47163
47178
|
"Content-Type": "application/json",
|
|
47164
47179
|
Accept: "application/json"
|
|
@@ -47180,7 +47195,7 @@ async function $do10(client, request, options) {
|
|
|
47180
47195
|
security: requestSecurity,
|
|
47181
47196
|
method: "POST",
|
|
47182
47197
|
baseURL: options?.serverURL,
|
|
47183
|
-
path:
|
|
47198
|
+
path: path9,
|
|
47184
47199
|
headers,
|
|
47185
47200
|
body,
|
|
47186
47201
|
userAgent: client._options.userAgent,
|
|
@@ -47255,7 +47270,7 @@ async function $do11(client, security, request, options) {
|
|
|
47255
47270
|
}
|
|
47256
47271
|
const payload = parsed.value;
|
|
47257
47272
|
const body = encodeJSON("body", payload, { explode: true });
|
|
47258
|
-
const
|
|
47273
|
+
const path9 = pathToFunc("/credits/coinbase")();
|
|
47259
47274
|
const headers = new Headers(compactMap({
|
|
47260
47275
|
"Content-Type": "application/json",
|
|
47261
47276
|
Accept: "application/json"
|
|
@@ -47281,7 +47296,7 @@ async function $do11(client, security, request, options) {
|
|
|
47281
47296
|
security: requestSecurity,
|
|
47282
47297
|
method: "POST",
|
|
47283
47298
|
baseURL: options?.serverURL,
|
|
47284
|
-
path:
|
|
47299
|
+
path: path9,
|
|
47285
47300
|
headers,
|
|
47286
47301
|
body,
|
|
47287
47302
|
userAgent: client._options.userAgent,
|
|
@@ -47330,7 +47345,7 @@ function creditsGetCredits(client, options) {
|
|
|
47330
47345
|
return new APIPromise3($do12(client, options));
|
|
47331
47346
|
}
|
|
47332
47347
|
async function $do12(client, options) {
|
|
47333
|
-
const
|
|
47348
|
+
const path9 = pathToFunc("/credits")();
|
|
47334
47349
|
const headers = new Headers(compactMap({
|
|
47335
47350
|
Accept: "application/json"
|
|
47336
47351
|
}));
|
|
@@ -47351,7 +47366,7 @@ async function $do12(client, options) {
|
|
|
47351
47366
|
security: requestSecurity,
|
|
47352
47367
|
method: "GET",
|
|
47353
47368
|
baseURL: options?.serverURL,
|
|
47354
|
-
path:
|
|
47369
|
+
path: path9,
|
|
47355
47370
|
headers,
|
|
47356
47371
|
userAgent: client._options.userAgent,
|
|
47357
47372
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -47433,7 +47448,7 @@ async function $do13(client, request, options) {
|
|
|
47433
47448
|
}
|
|
47434
47449
|
const payload = parsed.value;
|
|
47435
47450
|
const body = encodeJSON("body", payload, { explode: true });
|
|
47436
|
-
const
|
|
47451
|
+
const path9 = pathToFunc("/embeddings")();
|
|
47437
47452
|
const headers = new Headers(compactMap({
|
|
47438
47453
|
"Content-Type": "application/json",
|
|
47439
47454
|
Accept: "application/json;q=1, text/event-stream;q=0"
|
|
@@ -47455,7 +47470,7 @@ async function $do13(client, request, options) {
|
|
|
47455
47470
|
security: requestSecurity,
|
|
47456
47471
|
method: "POST",
|
|
47457
47472
|
baseURL: options?.serverURL,
|
|
47458
|
-
path:
|
|
47473
|
+
path: path9,
|
|
47459
47474
|
headers,
|
|
47460
47475
|
body,
|
|
47461
47476
|
userAgent: client._options.userAgent,
|
|
@@ -47518,7 +47533,7 @@ function embeddingsListModels(client, options) {
|
|
|
47518
47533
|
return new APIPromise3($do14(client, options));
|
|
47519
47534
|
}
|
|
47520
47535
|
async function $do14(client, options) {
|
|
47521
|
-
const
|
|
47536
|
+
const path9 = pathToFunc("/embeddings/models")();
|
|
47522
47537
|
const headers = new Headers(compactMap({
|
|
47523
47538
|
Accept: "application/json"
|
|
47524
47539
|
}));
|
|
@@ -47539,7 +47554,7 @@ async function $do14(client, options) {
|
|
|
47539
47554
|
security: requestSecurity,
|
|
47540
47555
|
method: "GET",
|
|
47541
47556
|
baseURL: options?.serverURL,
|
|
47542
|
-
path:
|
|
47557
|
+
path: path9,
|
|
47543
47558
|
headers,
|
|
47544
47559
|
userAgent: client._options.userAgent,
|
|
47545
47560
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -47631,7 +47646,7 @@ async function $do15(client, request, options) {
|
|
|
47631
47646
|
charEncoding: "percent"
|
|
47632
47647
|
})
|
|
47633
47648
|
};
|
|
47634
|
-
const
|
|
47649
|
+
const path9 = pathToFunc("/models/{author}/{slug}/endpoints")(pathParams);
|
|
47635
47650
|
const headers = new Headers(compactMap({
|
|
47636
47651
|
Accept: "application/json"
|
|
47637
47652
|
}));
|
|
@@ -47652,7 +47667,7 @@ async function $do15(client, request, options) {
|
|
|
47652
47667
|
security: requestSecurity,
|
|
47653
47668
|
method: "GET",
|
|
47654
47669
|
baseURL: options?.serverURL,
|
|
47655
|
-
path:
|
|
47670
|
+
path: path9,
|
|
47656
47671
|
headers,
|
|
47657
47672
|
body,
|
|
47658
47673
|
userAgent: client._options.userAgent,
|
|
@@ -47700,7 +47715,7 @@ function endpointsListZdrEndpoints(client, options) {
|
|
|
47700
47715
|
return new APIPromise3($do16(client, options));
|
|
47701
47716
|
}
|
|
47702
47717
|
async function $do16(client, options) {
|
|
47703
|
-
const
|
|
47718
|
+
const path9 = pathToFunc("/endpoints/zdr")();
|
|
47704
47719
|
const headers = new Headers(compactMap({
|
|
47705
47720
|
Accept: "application/json"
|
|
47706
47721
|
}));
|
|
@@ -47721,7 +47736,7 @@ async function $do16(client, options) {
|
|
|
47721
47736
|
security: requestSecurity,
|
|
47722
47737
|
method: "GET",
|
|
47723
47738
|
baseURL: options?.serverURL,
|
|
47724
|
-
path:
|
|
47739
|
+
path: path9,
|
|
47725
47740
|
headers,
|
|
47726
47741
|
userAgent: client._options.userAgent,
|
|
47727
47742
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -47797,7 +47812,7 @@ async function $do17(client, request, options) {
|
|
|
47797
47812
|
}
|
|
47798
47813
|
const payload = parsed.value;
|
|
47799
47814
|
const body = null;
|
|
47800
|
-
const
|
|
47815
|
+
const path9 = pathToFunc("/generation")();
|
|
47801
47816
|
const query = encodeFormQuery({
|
|
47802
47817
|
"id": payload.id
|
|
47803
47818
|
});
|
|
@@ -47821,7 +47836,7 @@ async function $do17(client, request, options) {
|
|
|
47821
47836
|
security: requestSecurity,
|
|
47822
47837
|
method: "GET",
|
|
47823
47838
|
baseURL: options?.serverURL,
|
|
47824
|
-
path:
|
|
47839
|
+
path: path9,
|
|
47825
47840
|
headers,
|
|
47826
47841
|
query,
|
|
47827
47842
|
body,
|
|
@@ -47899,7 +47914,7 @@ function modelsCount(client, options) {
|
|
|
47899
47914
|
return new APIPromise3($do18(client, options));
|
|
47900
47915
|
}
|
|
47901
47916
|
async function $do18(client, options) {
|
|
47902
|
-
const
|
|
47917
|
+
const path9 = pathToFunc("/models/count")();
|
|
47903
47918
|
const headers = new Headers(compactMap({
|
|
47904
47919
|
Accept: "application/json"
|
|
47905
47920
|
}));
|
|
@@ -47920,7 +47935,7 @@ async function $do18(client, options) {
|
|
|
47920
47935
|
security: requestSecurity,
|
|
47921
47936
|
method: "GET",
|
|
47922
47937
|
baseURL: options?.serverURL,
|
|
47923
|
-
path:
|
|
47938
|
+
path: path9,
|
|
47924
47939
|
headers,
|
|
47925
47940
|
userAgent: client._options.userAgent,
|
|
47926
47941
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -47971,7 +47986,7 @@ async function $do19(client, request, options) {
|
|
|
47971
47986
|
}
|
|
47972
47987
|
const payload = parsed.value;
|
|
47973
47988
|
const body = null;
|
|
47974
|
-
const
|
|
47989
|
+
const path9 = pathToFunc("/models")();
|
|
47975
47990
|
const query = encodeFormQuery({
|
|
47976
47991
|
"category": payload?.category,
|
|
47977
47992
|
"supported_parameters": payload?.supported_parameters
|
|
@@ -47996,7 +48011,7 @@ async function $do19(client, request, options) {
|
|
|
47996
48011
|
security: requestSecurity,
|
|
47997
48012
|
method: "GET",
|
|
47998
48013
|
baseURL: options?.serverURL,
|
|
47999
|
-
path:
|
|
48014
|
+
path: path9,
|
|
48000
48015
|
headers,
|
|
48001
48016
|
query,
|
|
48002
48017
|
body,
|
|
@@ -48046,7 +48061,7 @@ function modelsListForUser(client, security, options) {
|
|
|
48046
48061
|
return new APIPromise3($do20(client, security, options));
|
|
48047
48062
|
}
|
|
48048
48063
|
async function $do20(client, security, options) {
|
|
48049
|
-
const
|
|
48064
|
+
const path9 = pathToFunc("/models/user")();
|
|
48050
48065
|
const headers = new Headers(compactMap({
|
|
48051
48066
|
Accept: "application/json"
|
|
48052
48067
|
}));
|
|
@@ -48071,7 +48086,7 @@ async function $do20(client, security, options) {
|
|
|
48071
48086
|
security: requestSecurity,
|
|
48072
48087
|
method: "GET",
|
|
48073
48088
|
baseURL: options?.serverURL,
|
|
48074
|
-
path:
|
|
48089
|
+
path: path9,
|
|
48075
48090
|
headers,
|
|
48076
48091
|
userAgent: client._options.userAgent,
|
|
48077
48092
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -48154,7 +48169,7 @@ async function $do21(client, request, options) {
|
|
|
48154
48169
|
}
|
|
48155
48170
|
const payload = parsed.value;
|
|
48156
48171
|
const body = encodeJSON("body", payload, { explode: true });
|
|
48157
|
-
const
|
|
48172
|
+
const path9 = pathToFunc("/auth/keys/code")();
|
|
48158
48173
|
const headers = new Headers(compactMap({
|
|
48159
48174
|
"Content-Type": "application/json",
|
|
48160
48175
|
Accept: "application/json"
|
|
@@ -48176,7 +48191,7 @@ async function $do21(client, request, options) {
|
|
|
48176
48191
|
security: requestSecurity,
|
|
48177
48192
|
method: "POST",
|
|
48178
48193
|
baseURL: options?.serverURL,
|
|
48179
|
-
path:
|
|
48194
|
+
path: path9,
|
|
48180
48195
|
headers,
|
|
48181
48196
|
body,
|
|
48182
48197
|
userAgent: client._options.userAgent,
|
|
@@ -48230,7 +48245,7 @@ async function $do22(client, request, options) {
|
|
|
48230
48245
|
}
|
|
48231
48246
|
const payload = parsed.value;
|
|
48232
48247
|
const body = encodeJSON("body", payload, { explode: true });
|
|
48233
|
-
const
|
|
48248
|
+
const path9 = pathToFunc("/auth/keys")();
|
|
48234
48249
|
const headers = new Headers(compactMap({
|
|
48235
48250
|
"Content-Type": "application/json",
|
|
48236
48251
|
Accept: "application/json"
|
|
@@ -48252,7 +48267,7 @@ async function $do22(client, request, options) {
|
|
|
48252
48267
|
security: requestSecurity,
|
|
48253
48268
|
method: "POST",
|
|
48254
48269
|
baseURL: options?.serverURL,
|
|
48255
|
-
path:
|
|
48270
|
+
path: path9,
|
|
48256
48271
|
headers,
|
|
48257
48272
|
body,
|
|
48258
48273
|
userAgent: client._options.userAgent,
|
|
@@ -48482,7 +48497,7 @@ async function $do23(client, security, request, options) {
|
|
|
48482
48497
|
charEncoding: "percent"
|
|
48483
48498
|
})
|
|
48484
48499
|
};
|
|
48485
|
-
const
|
|
48500
|
+
const path9 = pathToFunc("/parameters/{author}/{slug}")(pathParams);
|
|
48486
48501
|
const query = encodeFormQuery({
|
|
48487
48502
|
"provider": payload.provider
|
|
48488
48503
|
});
|
|
@@ -48510,7 +48525,7 @@ async function $do23(client, security, request, options) {
|
|
|
48510
48525
|
security: requestSecurity,
|
|
48511
48526
|
method: "GET",
|
|
48512
48527
|
baseURL: options?.serverURL,
|
|
48513
|
-
path:
|
|
48528
|
+
path: path9,
|
|
48514
48529
|
headers,
|
|
48515
48530
|
query,
|
|
48516
48531
|
body,
|
|
@@ -48577,7 +48592,7 @@ function providersList(client, options) {
|
|
|
48577
48592
|
return new APIPromise3($do24(client, options));
|
|
48578
48593
|
}
|
|
48579
48594
|
async function $do24(client, options) {
|
|
48580
|
-
const
|
|
48595
|
+
const path9 = pathToFunc("/providers")();
|
|
48581
48596
|
const headers = new Headers(compactMap({
|
|
48582
48597
|
Accept: "application/json"
|
|
48583
48598
|
}));
|
|
@@ -48598,7 +48613,7 @@ async function $do24(client, options) {
|
|
|
48598
48613
|
security: requestSecurity,
|
|
48599
48614
|
method: "GET",
|
|
48600
48615
|
baseURL: options?.serverURL,
|
|
48601
|
-
path:
|
|
48616
|
+
path: path9,
|
|
48602
48617
|
headers,
|
|
48603
48618
|
userAgent: client._options.userAgent,
|
|
48604
48619
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
|
|
@@ -61042,14 +61057,14 @@ var NullProtoObj = /* @__PURE__ */ (() => {
|
|
|
61042
61057
|
};
|
|
61043
61058
|
return e.prototype = /* @__PURE__ */ Object.create(null), Object.freeze(e.prototype), e;
|
|
61044
61059
|
})();
|
|
61045
|
-
function splitPath(
|
|
61046
|
-
const [_, ...s] =
|
|
61060
|
+
function splitPath(path9) {
|
|
61061
|
+
const [_, ...s] = path9.split("/");
|
|
61047
61062
|
return s[s.length - 1] === "" ? s.slice(0, -1) : s;
|
|
61048
61063
|
}
|
|
61049
|
-
function addRoute(ctx, method = "",
|
|
61064
|
+
function addRoute(ctx, method = "", path9, data) {
|
|
61050
61065
|
method = method.toUpperCase();
|
|
61051
|
-
if (
|
|
61052
|
-
const segments = splitPath(
|
|
61066
|
+
if (path9.charCodeAt(0) !== 47) path9 = `/${path9}`;
|
|
61067
|
+
const segments = splitPath(path9);
|
|
61053
61068
|
let node = ctx.root;
|
|
61054
61069
|
let _unnamedParamIndex = 0;
|
|
61055
61070
|
const paramsMap = [];
|
|
@@ -61107,7 +61122,7 @@ function addRoute(ctx, method = "", path8, data) {
|
|
|
61107
61122
|
paramsRegexp,
|
|
61108
61123
|
paramsMap: hasParams ? paramsMap : void 0
|
|
61109
61124
|
});
|
|
61110
|
-
if (!hasParams) ctx.static[
|
|
61125
|
+
if (!hasParams) ctx.static[path9] = node;
|
|
61111
61126
|
}
|
|
61112
61127
|
function getParamRegexp(segment) {
|
|
61113
61128
|
const regex = segment.replace(/:(\w+)/g, (_, id) => `(?<${id}>[^/]+)`).replace(/\./g, "\\.");
|
|
@@ -61600,9 +61615,202 @@ var index_post_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
|
61600
61615
|
}
|
|
61601
61616
|
});
|
|
61602
61617
|
|
|
61618
|
+
// src/utils/platform-auth.ts
|
|
61619
|
+
var FALLBACK_PLATFORM_ORIGIN = "https://standardagents.ai";
|
|
61620
|
+
var SESSION_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
61621
|
+
function platformApiKey(env2) {
|
|
61622
|
+
const value = env2.STANDARD_AGENTS_API_KEY;
|
|
61623
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
61624
|
+
}
|
|
61625
|
+
function hasPlatformApiKey(env2) {
|
|
61626
|
+
return platformApiKey(env2) !== null;
|
|
61627
|
+
}
|
|
61628
|
+
function platformEndpoint(env2) {
|
|
61629
|
+
const configured = env2.PLATFORM_ENDPOINT || env2.STANDARD_AGENTS_PLATFORM_URL || env2.PLATFORM_URL || env2.STANDARD_AGENTS_PUBLIC_URL;
|
|
61630
|
+
if (typeof configured === "string" && configured.trim()) {
|
|
61631
|
+
return configured.trim().replace(/\/+$/, "");
|
|
61632
|
+
}
|
|
61633
|
+
return FALLBACK_PLATFORM_ORIGIN;
|
|
61634
|
+
}
|
|
61635
|
+
function sanitizeUsername(input) {
|
|
61636
|
+
const normalized = input.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 50);
|
|
61637
|
+
return normalized || "standard-agents";
|
|
61638
|
+
}
|
|
61639
|
+
async function fallbackAccountForToken(token) {
|
|
61640
|
+
const tokenHash = await hashToken(token);
|
|
61641
|
+
const suffix = tokenHash.slice(0, 12);
|
|
61642
|
+
return {
|
|
61643
|
+
id: `platform-token-${suffix}`,
|
|
61644
|
+
name: "Standard Agents",
|
|
61645
|
+
slug: `standard-agents-${suffix}`,
|
|
61646
|
+
tier: void 0,
|
|
61647
|
+
status: "token-present"
|
|
61648
|
+
};
|
|
61649
|
+
}
|
|
61650
|
+
function normalizeAccount(payload) {
|
|
61651
|
+
const account = payload.account;
|
|
61652
|
+
if (!account) return null;
|
|
61653
|
+
const id = typeof account.id === "string" ? account.id : null;
|
|
61654
|
+
const slug = typeof account.slug === "string" ? account.slug : null;
|
|
61655
|
+
const name15 = typeof account.name === "string" ? account.name : slug;
|
|
61656
|
+
if (!id || !slug || !name15) {
|
|
61657
|
+
return null;
|
|
61658
|
+
}
|
|
61659
|
+
return {
|
|
61660
|
+
id,
|
|
61661
|
+
name: name15,
|
|
61662
|
+
slug,
|
|
61663
|
+
tier: typeof account.tier === "string" ? account.tier : void 0,
|
|
61664
|
+
status: typeof account.status === "string" ? account.status : void 0
|
|
61665
|
+
};
|
|
61666
|
+
}
|
|
61667
|
+
async function fetchPlatformAccount(endpoint, token) {
|
|
61668
|
+
try {
|
|
61669
|
+
const response = await fetch(`${endpoint}/account`, {
|
|
61670
|
+
headers: {
|
|
61671
|
+
Authorization: `Bearer ${token}`
|
|
61672
|
+
}
|
|
61673
|
+
});
|
|
61674
|
+
if (!response.ok) {
|
|
61675
|
+
return null;
|
|
61676
|
+
}
|
|
61677
|
+
const data = await response.json().catch(() => null);
|
|
61678
|
+
return data ? normalizeAccount(data) : null;
|
|
61679
|
+
} catch {
|
|
61680
|
+
return null;
|
|
61681
|
+
}
|
|
61682
|
+
}
|
|
61683
|
+
async function getPlatformIdentity(env2) {
|
|
61684
|
+
const token = platformApiKey(env2);
|
|
61685
|
+
if (!token) {
|
|
61686
|
+
return null;
|
|
61687
|
+
}
|
|
61688
|
+
const endpoint = platformEndpoint(env2);
|
|
61689
|
+
const verifiedAccount = await fetchPlatformAccount(endpoint, token);
|
|
61690
|
+
const account = verifiedAccount ?? await fallbackAccountForToken(token);
|
|
61691
|
+
const username = sanitizeUsername(`standard-agents-${account.slug}`);
|
|
61692
|
+
return {
|
|
61693
|
+
connected: true,
|
|
61694
|
+
verified: verifiedAccount !== null,
|
|
61695
|
+
account,
|
|
61696
|
+
user: {
|
|
61697
|
+
id: account.id,
|
|
61698
|
+
username,
|
|
61699
|
+
role: "admin",
|
|
61700
|
+
source: "standard_agents"
|
|
61701
|
+
},
|
|
61702
|
+
platformEndpoint: endpoint
|
|
61703
|
+
};
|
|
61704
|
+
}
|
|
61705
|
+
async function createPlatformLocalSession(env2) {
|
|
61706
|
+
const identity = await getPlatformIdentity(env2);
|
|
61707
|
+
if (!identity) {
|
|
61708
|
+
return null;
|
|
61709
|
+
}
|
|
61710
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
61711
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
61712
|
+
const username = identity.user.username;
|
|
61713
|
+
let user = await agentBuilder.getUserByUsername(username);
|
|
61714
|
+
if (!user) {
|
|
61715
|
+
user = await agentBuilder.createUser({
|
|
61716
|
+
username,
|
|
61717
|
+
password_hash: await hashPassword(crypto.randomUUID()),
|
|
61718
|
+
role: "admin"
|
|
61719
|
+
});
|
|
61720
|
+
}
|
|
61721
|
+
const token = generateUserToken();
|
|
61722
|
+
const tokenHash = await hashToken(token);
|
|
61723
|
+
const expiresAt = Math.floor(Date.now() / 1e3) + SESSION_TTL_SECONDS;
|
|
61724
|
+
await agentBuilder.createSession({
|
|
61725
|
+
user_id: user.id,
|
|
61726
|
+
token_hash: tokenHash,
|
|
61727
|
+
expires_at: expiresAt
|
|
61728
|
+
});
|
|
61729
|
+
return {
|
|
61730
|
+
token,
|
|
61731
|
+
user: {
|
|
61732
|
+
id: user.id,
|
|
61733
|
+
username: user.username,
|
|
61734
|
+
role: user.role
|
|
61735
|
+
},
|
|
61736
|
+
authType: "platform_token",
|
|
61737
|
+
platform: identity
|
|
61738
|
+
};
|
|
61739
|
+
}
|
|
61740
|
+
|
|
61741
|
+
// src/api/platform-endpoint.ts
|
|
61742
|
+
var ORB_CORE_HOST_PATTERN = /^core\.([a-z0-9-]+)\.orb\.local$/i;
|
|
61743
|
+
var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
|
|
61744
|
+
var DEFAULT_DOCKER_PLATFORM_ENDPOINT = "http://platform-admin:8787";
|
|
61745
|
+
function readEnvString(env2, key) {
|
|
61746
|
+
if (!env2 || typeof env2 !== "object") return void 0;
|
|
61747
|
+
const value = env2[key];
|
|
61748
|
+
return typeof value === "string" ? value : void 0;
|
|
61749
|
+
}
|
|
61750
|
+
function normalizeEndpoint(endpoint) {
|
|
61751
|
+
if (!endpoint) return null;
|
|
61752
|
+
const trimmed = endpoint.trim();
|
|
61753
|
+
if (!trimmed) return null;
|
|
61754
|
+
return trimmed.replace(/\/+$/, "");
|
|
61755
|
+
}
|
|
61756
|
+
function getHostname(urlValue) {
|
|
61757
|
+
try {
|
|
61758
|
+
return new URL(urlValue).hostname.toLowerCase();
|
|
61759
|
+
} catch {
|
|
61760
|
+
return null;
|
|
61761
|
+
}
|
|
61762
|
+
}
|
|
61763
|
+
function deriveOrbPlatformEndpoint(requestUrl) {
|
|
61764
|
+
const requestHost = getHostname(requestUrl);
|
|
61765
|
+
if (!requestHost) return null;
|
|
61766
|
+
const match2 = requestHost.match(ORB_CORE_HOST_PATTERN);
|
|
61767
|
+
if (!match2 || !match2[1]) return null;
|
|
61768
|
+
return `https://platform-api.${match2[1]}.orb.local`;
|
|
61769
|
+
}
|
|
61770
|
+
function resolvePlatformEndpoint(req, env2) {
|
|
61771
|
+
const endpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
61772
|
+
return endpoints[0] ?? null;
|
|
61773
|
+
}
|
|
61774
|
+
function resolvePlatformEndpointCandidates(req, env2) {
|
|
61775
|
+
const configuredEndpoint = normalizeEndpoint(readEnvString(env2, "PLATFORM_ENDPOINT"));
|
|
61776
|
+
const orbFallbackEndpoint = deriveOrbPlatformEndpoint(req.url);
|
|
61777
|
+
const configuredHost = configuredEndpoint ? getHostname(configuredEndpoint) : null;
|
|
61778
|
+
const hasLocalConfiguredEndpoint = !!(configuredHost && LOCAL_HOSTS.has(configuredHost));
|
|
61779
|
+
const shouldUseOrbFallbackPath = !!orbFallbackEndpoint && (!configuredEndpoint || hasLocalConfiguredEndpoint);
|
|
61780
|
+
const candidates = [];
|
|
61781
|
+
if (configuredEndpoint && !shouldUseOrbFallbackPath) {
|
|
61782
|
+
candidates.push(configuredEndpoint);
|
|
61783
|
+
}
|
|
61784
|
+
if (shouldUseOrbFallbackPath) {
|
|
61785
|
+
candidates.push(DEFAULT_DOCKER_PLATFORM_ENDPOINT);
|
|
61786
|
+
if (orbFallbackEndpoint) {
|
|
61787
|
+
candidates.push(orbFallbackEndpoint);
|
|
61788
|
+
}
|
|
61789
|
+
if (configuredEndpoint && hasLocalConfiguredEndpoint) {
|
|
61790
|
+
candidates.push(configuredEndpoint);
|
|
61791
|
+
}
|
|
61792
|
+
} else if (configuredEndpoint) {
|
|
61793
|
+
candidates.push(configuredEndpoint);
|
|
61794
|
+
}
|
|
61795
|
+
return Array.from(new Set(candidates));
|
|
61796
|
+
}
|
|
61797
|
+
var platform_endpoint_default = defineController2(async ({ req, env: env2 }) => {
|
|
61798
|
+
const candidates = resolvePlatformEndpointCandidates(req, env2);
|
|
61799
|
+
return Response.json({
|
|
61800
|
+
endpoint: candidates[0] ?? null,
|
|
61801
|
+
candidates
|
|
61802
|
+
});
|
|
61803
|
+
});
|
|
61804
|
+
|
|
61603
61805
|
// src/api/config.get.ts
|
|
61604
|
-
var config_get_default = defineController2(async ({ config }) => {
|
|
61605
|
-
|
|
61806
|
+
var config_get_default = defineController2(async ({ config, env: env2, req }) => {
|
|
61807
|
+
const configuredPlatformEndpoint = resolvePlatformEndpoint(req, env2);
|
|
61808
|
+
const platformConnected = hasPlatformApiKey(env2) || !!configuredPlatformEndpoint;
|
|
61809
|
+
return Response.json({
|
|
61810
|
+
...config,
|
|
61811
|
+
platformConnected,
|
|
61812
|
+
platformEndpoint: hasPlatformApiKey(env2) ? platformEndpoint(env2) : configuredPlatformEndpoint
|
|
61813
|
+
});
|
|
61606
61814
|
});
|
|
61607
61815
|
|
|
61608
61816
|
// src/api/diagnostics.get.ts
|
|
@@ -62072,14 +62280,20 @@ var SUPPORTED_PROVIDERS = buildInstalledProviderCatalog().map((provider) => ({
|
|
|
62072
62280
|
envKeys: provider.envKeys
|
|
62073
62281
|
}));
|
|
62074
62282
|
var providers_get_default = defineController2(async ({ env: env2 }) => {
|
|
62283
|
+
const hasPlatformConnection = Boolean(env2.STANDARD_AGENTS_API_KEY || env2.PLATFORM_API_KEY);
|
|
62075
62284
|
const providers = await Promise.all(
|
|
62076
62285
|
SUPPORTED_PROVIDERS.map(async (provider) => {
|
|
62077
62286
|
const iconId = await getProviderIcon(provider.sdk);
|
|
62287
|
+
const hasDirectApiKey = provider.envKeys.every((envKey) => Boolean(env2[envKey]));
|
|
62288
|
+
const configuredViaPlatform = !hasDirectApiKey && hasPlatformConnection;
|
|
62078
62289
|
return {
|
|
62079
62290
|
name: provider.name,
|
|
62080
62291
|
sdk: provider.sdk,
|
|
62081
62292
|
label: provider.label,
|
|
62082
|
-
hasApiKey:
|
|
62293
|
+
hasApiKey: hasDirectApiKey || configuredViaPlatform,
|
|
62294
|
+
hasDirectApiKey,
|
|
62295
|
+
configuredViaPlatform,
|
|
62296
|
+
configurationSource: hasDirectApiKey ? "direct" : configuredViaPlatform ? "platform" : "missing",
|
|
62083
62297
|
envKeys: provider.envKeys,
|
|
62084
62298
|
iconId
|
|
62085
62299
|
};
|
|
@@ -62815,10 +63029,10 @@ var index_post_default5 = defineController2(async ({ req }) => {
|
|
|
62815
63029
|
}
|
|
62816
63030
|
try {
|
|
62817
63031
|
const { PackingService: PackingService2 } = await Promise.resolve().then(() => (init_packing_service(), packing_service_exports));
|
|
62818
|
-
const
|
|
63032
|
+
const path9 = await import('path');
|
|
62819
63033
|
const packingService = new PackingService2();
|
|
62820
63034
|
const rootDir = process.cwd();
|
|
62821
|
-
const outputDir =
|
|
63035
|
+
const outputDir = path9.join(rootDir, "agents", "packed");
|
|
62822
63036
|
const result = await packingService.pack({
|
|
62823
63037
|
agentName,
|
|
62824
63038
|
rootDir,
|
|
@@ -63526,14 +63740,192 @@ var id_put_default = defineController2(async ({ req, env: env2, params }) => {
|
|
|
63526
63740
|
);
|
|
63527
63741
|
}
|
|
63528
63742
|
});
|
|
63743
|
+
var STATE_RELATIVE_PATH = path4__default.join(".agents", "bootstrap-session.json");
|
|
63744
|
+
var PROJECT_ROOT_ENV_KEYS = ["INIT_CWD", "PWD", "npm_config_local_prefix"];
|
|
63745
|
+
function readEnvString2(env2, key) {
|
|
63746
|
+
if (!env2 || typeof env2 !== "object") return void 0;
|
|
63747
|
+
const value = env2[key];
|
|
63748
|
+
return typeof value === "string" ? value : void 0;
|
|
63749
|
+
}
|
|
63750
|
+
function uniquePaths(paths) {
|
|
63751
|
+
return Array.from(
|
|
63752
|
+
new Set(
|
|
63753
|
+
paths.filter((value) => !!value?.trim()).map((value) => path4__default.resolve(value))
|
|
63754
|
+
)
|
|
63755
|
+
);
|
|
63756
|
+
}
|
|
63757
|
+
function hasSessionCookie(cookieHeader) {
|
|
63758
|
+
const raw = Array.isArray(cookieHeader) ? cookieHeader.join("; ") : cookieHeader || "";
|
|
63759
|
+
return /(?:^|;\s*)session=/.test(raw);
|
|
63760
|
+
}
|
|
63761
|
+
function loadLocalBootstrapSession(projectRoot) {
|
|
63762
|
+
const statePath = path4__default.join(projectRoot, STATE_RELATIVE_PATH);
|
|
63763
|
+
if (!fs2__default.existsSync(statePath)) return null;
|
|
63764
|
+
try {
|
|
63765
|
+
const parsed = JSON.parse(
|
|
63766
|
+
fs2__default.readFileSync(statePath, "utf-8")
|
|
63767
|
+
);
|
|
63768
|
+
if (parsed.version !== 1) return null;
|
|
63769
|
+
if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
|
|
63770
|
+
if (!parsed.session_cookie || typeof parsed.session_cookie !== "string") return null;
|
|
63771
|
+
return parsed;
|
|
63772
|
+
} catch {
|
|
63773
|
+
return null;
|
|
63774
|
+
}
|
|
63775
|
+
}
|
|
63776
|
+
function loadLocalBootstrapSessionFromEnv(env2) {
|
|
63777
|
+
if (!env2) return null;
|
|
63778
|
+
const endpoint = readEnvString2(env2, "PLATFORM_ENDPOINT")?.trim();
|
|
63779
|
+
const sessionCookie = readEnvString2(env2, "STANDARDAGENTS_BOOTSTRAP_SESSION_COOKIE")?.trim();
|
|
63780
|
+
const userId = readEnvString2(env2, "STANDARDAGENTS_ORG_USER_ID")?.trim();
|
|
63781
|
+
const accountId = readEnvString2(env2, "STANDARDAGENTS_ORG_ACCOUNT_ID")?.trim();
|
|
63782
|
+
const accountSlug = readEnvString2(env2, "STANDARDAGENTS_ORG_SLUG")?.trim();
|
|
63783
|
+
if (!endpoint || !sessionCookie || !userId || !accountId) {
|
|
63784
|
+
return null;
|
|
63785
|
+
}
|
|
63786
|
+
return {
|
|
63787
|
+
version: 1,
|
|
63788
|
+
endpoint,
|
|
63789
|
+
authenticated_at: 0,
|
|
63790
|
+
session_cookie: sessionCookie,
|
|
63791
|
+
user: { id: userId },
|
|
63792
|
+
account: {
|
|
63793
|
+
id: accountId,
|
|
63794
|
+
...accountSlug ? { slug: accountSlug } : {}
|
|
63795
|
+
}
|
|
63796
|
+
};
|
|
63797
|
+
}
|
|
63798
|
+
function findLocalBootstrapSession(projectRoot, env2) {
|
|
63799
|
+
const envSession = loadLocalBootstrapSessionFromEnv(env2);
|
|
63800
|
+
if (envSession) {
|
|
63801
|
+
return {
|
|
63802
|
+
projectRoot: process.cwd(),
|
|
63803
|
+
session: envSession
|
|
63804
|
+
};
|
|
63805
|
+
}
|
|
63806
|
+
const candidates = uniquePaths([
|
|
63807
|
+
projectRoot,
|
|
63808
|
+
process.cwd(),
|
|
63809
|
+
...PROJECT_ROOT_ENV_KEYS.map((key) => process.env[key])
|
|
63810
|
+
]);
|
|
63811
|
+
for (const candidate of candidates) {
|
|
63812
|
+
const session = loadLocalBootstrapSession(candidate);
|
|
63813
|
+
if (session) {
|
|
63814
|
+
return {
|
|
63815
|
+
projectRoot: candidate,
|
|
63816
|
+
session
|
|
63817
|
+
};
|
|
63818
|
+
}
|
|
63819
|
+
}
|
|
63820
|
+
return null;
|
|
63821
|
+
}
|
|
63822
|
+
|
|
63823
|
+
// src/api/auth/bootstrap.post.ts
|
|
63824
|
+
function deriveManagedUsername(platformUserId) {
|
|
63825
|
+
return `sa-${platformUserId}`;
|
|
63826
|
+
}
|
|
63827
|
+
function uniqueEndpoints(preferred, candidates) {
|
|
63828
|
+
return Array.from(new Set([preferred, ...candidates].filter(Boolean)));
|
|
63829
|
+
}
|
|
63830
|
+
var bootstrap_post_default = defineController2(async ({ req, env: env2 }) => {
|
|
63831
|
+
try {
|
|
63832
|
+
const platformTokenSession = await createPlatformLocalSession(env2);
|
|
63833
|
+
if (platformTokenSession) {
|
|
63834
|
+
return Response.json(platformTokenSession);
|
|
63835
|
+
}
|
|
63836
|
+
} catch (error) {
|
|
63837
|
+
console.error("Platform auth bootstrap error:", error);
|
|
63838
|
+
return Response.json(
|
|
63839
|
+
{ error: error instanceof Error ? error.message : "Failed to bootstrap platform auth" },
|
|
63840
|
+
{ status: 500 }
|
|
63841
|
+
);
|
|
63842
|
+
}
|
|
63843
|
+
const bootstrap = findLocalBootstrapSession(void 0, env2);
|
|
63844
|
+
const bootstrapState = bootstrap?.session;
|
|
63845
|
+
if (!bootstrapState?.session_cookie) {
|
|
63846
|
+
return new Response(null, { status: 204 });
|
|
63847
|
+
}
|
|
63848
|
+
const endpoints = uniqueEndpoints(
|
|
63849
|
+
bootstrapState.endpoint,
|
|
63850
|
+
resolvePlatformEndpointCandidates(req, env2)
|
|
63851
|
+
);
|
|
63852
|
+
let platformUser = null;
|
|
63853
|
+
for (const endpoint of endpoints) {
|
|
63854
|
+
try {
|
|
63855
|
+
const response = await fetch(`${endpoint}/auth/session`, {
|
|
63856
|
+
method: "GET",
|
|
63857
|
+
headers: {
|
|
63858
|
+
Cookie: bootstrapState.session_cookie
|
|
63859
|
+
}
|
|
63860
|
+
});
|
|
63861
|
+
if (response.status === 401) {
|
|
63862
|
+
return Response.json(
|
|
63863
|
+
{ error: "Stored Standard Agents session is no longer valid. Run `agents login` again." },
|
|
63864
|
+
{ status: 401 }
|
|
63865
|
+
);
|
|
63866
|
+
}
|
|
63867
|
+
if (!response.ok) {
|
|
63868
|
+
continue;
|
|
63869
|
+
}
|
|
63870
|
+
const payload = await response.json().catch(() => ({}));
|
|
63871
|
+
platformUser = payload.user ?? null;
|
|
63872
|
+
break;
|
|
63873
|
+
} catch {
|
|
63874
|
+
continue;
|
|
63875
|
+
}
|
|
63876
|
+
}
|
|
63877
|
+
const fallbackPlatformUserId = bootstrapState.user?.id;
|
|
63878
|
+
const platformUserId = platformUser?.id ?? fallbackPlatformUserId;
|
|
63879
|
+
if (!platformUserId) {
|
|
63880
|
+
return Response.json(
|
|
63881
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
63882
|
+
{ status: 502 }
|
|
63883
|
+
);
|
|
63884
|
+
}
|
|
63885
|
+
const username = deriveManagedUsername(platformUserId);
|
|
63886
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
63887
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
63888
|
+
let user = await agentBuilder.getUserByUsername(username);
|
|
63889
|
+
if (!user) {
|
|
63890
|
+
user = await agentBuilder.createUser({
|
|
63891
|
+
username,
|
|
63892
|
+
password_hash: await hashPassword(crypto.randomUUID()),
|
|
63893
|
+
role: "admin"
|
|
63894
|
+
});
|
|
63895
|
+
}
|
|
63896
|
+
const token = generateUserToken();
|
|
63897
|
+
const tokenHash = await hashToken(token);
|
|
63898
|
+
const expiresAt = Math.floor(Date.now() / 1e3) + 30 * 24 * 60 * 60;
|
|
63899
|
+
await agentBuilder.createSession({
|
|
63900
|
+
user_id: user.id,
|
|
63901
|
+
token_hash: tokenHash,
|
|
63902
|
+
expires_at: expiresAt
|
|
63903
|
+
});
|
|
63904
|
+
return Response.json({
|
|
63905
|
+
token,
|
|
63906
|
+
user: {
|
|
63907
|
+
id: user.id,
|
|
63908
|
+
username: user.username,
|
|
63909
|
+
role: user.role
|
|
63910
|
+
},
|
|
63911
|
+
platform_user: {
|
|
63912
|
+
id: platformUserId,
|
|
63913
|
+
email: platformUser?.email ?? bootstrapState.user?.email
|
|
63914
|
+
}
|
|
63915
|
+
});
|
|
63916
|
+
});
|
|
63529
63917
|
|
|
63530
63918
|
// src/api/auth/config.get.ts
|
|
63531
|
-
var config_get_default2 = defineController2(async ({ env: env2 }) => {
|
|
63919
|
+
var config_get_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
63532
63920
|
const githubConfigured = !!(env2.GITHUB_CLIENT_ID && env2.GITHUB_CLIENT_SECRET);
|
|
63533
63921
|
const googleConfigured = !!(env2.GOOGLE_CLIENT_ID && env2.GOOGLE_CLIENT_SECRET);
|
|
63922
|
+
const configuredPlatformEndpoint = resolvePlatformEndpoint(req, env2);
|
|
63923
|
+
const platformConnected = hasPlatformApiKey(env2) || !!configuredPlatformEndpoint;
|
|
63534
63924
|
return {
|
|
63535
63925
|
github: githubConfigured,
|
|
63536
|
-
google: googleConfigured
|
|
63926
|
+
google: googleConfigured,
|
|
63927
|
+
platformConnected,
|
|
63928
|
+
platformEndpoint: hasPlatformApiKey(env2) ? platformEndpoint(env2) : configuredPlatformEndpoint
|
|
63537
63929
|
};
|
|
63538
63930
|
});
|
|
63539
63931
|
|
|
@@ -63659,6 +64051,94 @@ var me_get_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
63659
64051
|
}
|
|
63660
64052
|
});
|
|
63661
64053
|
|
|
64054
|
+
// src/api/envs/_shared.ts
|
|
64055
|
+
function buildScopedEnvResponse(entries) {
|
|
64056
|
+
const variables = [...entries].sort((a, b) => a.name.localeCompare(b.name)).map((entry) => ({
|
|
64057
|
+
name: entry.name,
|
|
64058
|
+
type: entry.type === "text" ? "text" : "secret",
|
|
64059
|
+
...entry.type === "text" ? { value: entry.value } : {},
|
|
64060
|
+
created_at: entry.created_at,
|
|
64061
|
+
updated_at: entry.updated_at
|
|
64062
|
+
}));
|
|
64063
|
+
return { variables };
|
|
64064
|
+
}
|
|
64065
|
+
function validateScopedEnvPatchBody(body) {
|
|
64066
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
64067
|
+
return { ok: false, error: "Request body must be an object" };
|
|
64068
|
+
}
|
|
64069
|
+
const payload = body;
|
|
64070
|
+
if (payload.env_patch !== void 0 && (!payload.env_patch || typeof payload.env_patch !== "object" || Array.isArray(payload.env_patch))) {
|
|
64071
|
+
return { ok: false, error: "env_patch must be an object" };
|
|
64072
|
+
}
|
|
64073
|
+
if (payload.env_type_patch !== void 0 && (!payload.env_type_patch || typeof payload.env_type_patch !== "object" || Array.isArray(payload.env_type_patch))) {
|
|
64074
|
+
return { ok: false, error: "env_type_patch must be an object" };
|
|
64075
|
+
}
|
|
64076
|
+
if (payload.env_delete !== void 0 && (!Array.isArray(payload.env_delete) || !payload.env_delete.every((entry) => typeof entry === "string"))) {
|
|
64077
|
+
return { ok: false, error: "env_delete must be an array of strings" };
|
|
64078
|
+
}
|
|
64079
|
+
return {
|
|
64080
|
+
ok: true,
|
|
64081
|
+
payload: {
|
|
64082
|
+
env_patch: payload.env_patch,
|
|
64083
|
+
env_type_patch: payload.env_type_patch,
|
|
64084
|
+
env_delete: payload.env_delete
|
|
64085
|
+
}
|
|
64086
|
+
};
|
|
64087
|
+
}
|
|
64088
|
+
function isScopedEnvValidationError(error) {
|
|
64089
|
+
const message = error instanceof Error ? error.message : "";
|
|
64090
|
+
return message.startsWith("env_patch") || message.startsWith("env_type_patch") || message.includes("matching env value") || message.includes("non-empty strings");
|
|
64091
|
+
}
|
|
64092
|
+
|
|
64093
|
+
// src/api/envs/instance.get.ts
|
|
64094
|
+
var instance_get_default = defineController2(async ({ req, env: env2 }) => {
|
|
64095
|
+
try {
|
|
64096
|
+
const authResult = await requireAdmin(req, env2);
|
|
64097
|
+
if (authResult instanceof Response) {
|
|
64098
|
+
return authResult;
|
|
64099
|
+
}
|
|
64100
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
64101
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
64102
|
+
const variables = typeof agentBuilder.getInstanceEnvEntries === "function" ? await agentBuilder.getInstanceEnvEntries() : [];
|
|
64103
|
+
return Response.json(buildScopedEnvResponse(variables));
|
|
64104
|
+
} catch (error) {
|
|
64105
|
+
console.error("Get instance env error:", error);
|
|
64106
|
+
return Response.json(
|
|
64107
|
+
{ error: error.message || "Failed to load instance env" },
|
|
64108
|
+
{ status: 500 }
|
|
64109
|
+
);
|
|
64110
|
+
}
|
|
64111
|
+
});
|
|
64112
|
+
|
|
64113
|
+
// src/api/envs/instance.patch.ts
|
|
64114
|
+
var instance_patch_default = defineController2(async ({ req, env: env2 }) => {
|
|
64115
|
+
try {
|
|
64116
|
+
const authResult = await requireAdmin(req, env2);
|
|
64117
|
+
if (authResult instanceof Response) {
|
|
64118
|
+
return authResult;
|
|
64119
|
+
}
|
|
64120
|
+
const body = await req.json().catch(() => null);
|
|
64121
|
+
const parsed = validateScopedEnvPatchBody(body);
|
|
64122
|
+
if (!parsed.ok) {
|
|
64123
|
+
return Response.json({ error: parsed.error }, { status: 400 });
|
|
64124
|
+
}
|
|
64125
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
64126
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
64127
|
+
if (typeof agentBuilder.patchInstanceEnv !== "function") {
|
|
64128
|
+
throw new Error("patchInstanceEnv is not supported by this runtime");
|
|
64129
|
+
}
|
|
64130
|
+
await agentBuilder.patchInstanceEnv(parsed.payload);
|
|
64131
|
+
return Response.json({ success: true });
|
|
64132
|
+
} catch (error) {
|
|
64133
|
+
console.error("Patch instance env error:", error);
|
|
64134
|
+
const status = isScopedEnvValidationError(error) ? 400 : 500;
|
|
64135
|
+
return Response.json(
|
|
64136
|
+
{ error: error.message || "Failed to update instance env" },
|
|
64137
|
+
{ status }
|
|
64138
|
+
);
|
|
64139
|
+
}
|
|
64140
|
+
});
|
|
64141
|
+
|
|
63662
64142
|
// src/api/models/available.post.ts
|
|
63663
64143
|
var UUID_LIKE_MODEL_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
63664
64144
|
var CLOUDFLARE_PROVIDER_MODEL_ID = /^@cf\//i;
|
|
@@ -63981,6 +64461,402 @@ var npm_token_status_get_default = defineController2(async ({ env: env2 }) => {
|
|
|
63981
64461
|
});
|
|
63982
64462
|
});
|
|
63983
64463
|
|
|
64464
|
+
// src/api/platform/[...path].ts
|
|
64465
|
+
var path_default = defineController2(async ({ req, params, env: env2, url }) => {
|
|
64466
|
+
const endpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
64467
|
+
const apiKey = env2.PLATFORM_API_KEY;
|
|
64468
|
+
if (endpoints.length === 0 || !apiKey) {
|
|
64469
|
+
return Response.json(
|
|
64470
|
+
{ error: "Platform API not configured" },
|
|
64471
|
+
{ status: 503 }
|
|
64472
|
+
);
|
|
64473
|
+
}
|
|
64474
|
+
const pathParam = params._ || params.path || params["*"] || "";
|
|
64475
|
+
const headers = new Headers();
|
|
64476
|
+
const requestBody = req.method === "GET" || req.method === "HEAD" ? void 0 : await req.arrayBuffer();
|
|
64477
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
64478
|
+
const contentType = req.headers.get("Content-Type");
|
|
64479
|
+
if (contentType) {
|
|
64480
|
+
headers.set("Content-Type", contentType);
|
|
64481
|
+
}
|
|
64482
|
+
for (const endpoint of endpoints) {
|
|
64483
|
+
const targetUrl = `${endpoint}/${pathParam}${url.search}`;
|
|
64484
|
+
try {
|
|
64485
|
+
const response = await fetch(targetUrl, {
|
|
64486
|
+
method: req.method,
|
|
64487
|
+
headers,
|
|
64488
|
+
body: requestBody
|
|
64489
|
+
});
|
|
64490
|
+
return new Response(response.body, {
|
|
64491
|
+
status: response.status,
|
|
64492
|
+
headers: response.headers
|
|
64493
|
+
});
|
|
64494
|
+
} catch {
|
|
64495
|
+
continue;
|
|
64496
|
+
}
|
|
64497
|
+
}
|
|
64498
|
+
return Response.json(
|
|
64499
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
64500
|
+
{ status: 502 }
|
|
64501
|
+
);
|
|
64502
|
+
});
|
|
64503
|
+
|
|
64504
|
+
// src/api/platform-auth/bootstrap.post.ts
|
|
64505
|
+
function uniqueEndpoints2(preferred, candidates) {
|
|
64506
|
+
return Array.from(new Set([preferred, ...candidates].filter((value) => Boolean(value))));
|
|
64507
|
+
}
|
|
64508
|
+
function buildSessionCookieHeader(req, sessionCookie) {
|
|
64509
|
+
const attributes = ["Path=/", "HttpOnly", "SameSite=Lax"];
|
|
64510
|
+
try {
|
|
64511
|
+
if (new URL(req.url).protocol === "https:") {
|
|
64512
|
+
attributes.push("Secure");
|
|
64513
|
+
}
|
|
64514
|
+
} catch {
|
|
64515
|
+
}
|
|
64516
|
+
return `${sessionCookie}; ${attributes.join("; ")}`;
|
|
64517
|
+
}
|
|
64518
|
+
var bootstrap_post_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
64519
|
+
const requestCookie = req.headers.get("Cookie")?.trim() || "";
|
|
64520
|
+
const configuredEndpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
64521
|
+
let cookie = requestCookie;
|
|
64522
|
+
let endpoints = configuredEndpoints;
|
|
64523
|
+
let bootstrappedFromProject = false;
|
|
64524
|
+
if (!hasSessionCookie(cookie)) {
|
|
64525
|
+
const bootstrap = findLocalBootstrapSession(void 0, env2)?.session;
|
|
64526
|
+
if (bootstrap?.session_cookie) {
|
|
64527
|
+
cookie = bootstrap.session_cookie;
|
|
64528
|
+
endpoints = uniqueEndpoints2(bootstrap.endpoint, configuredEndpoints);
|
|
64529
|
+
bootstrappedFromProject = true;
|
|
64530
|
+
} else {
|
|
64531
|
+
const localSession = await createPlatformLocalSession(env2);
|
|
64532
|
+
if (!localSession) {
|
|
64533
|
+
return new Response(null, {
|
|
64534
|
+
status: 204,
|
|
64535
|
+
headers: { "Cache-Control": "no-store" }
|
|
64536
|
+
});
|
|
64537
|
+
}
|
|
64538
|
+
return Response.json({
|
|
64539
|
+
user: localSession.platform.user,
|
|
64540
|
+
account: localSession.platform.account,
|
|
64541
|
+
authType: localSession.authType,
|
|
64542
|
+
verified: localSession.platform.verified,
|
|
64543
|
+
token: localSession.token,
|
|
64544
|
+
localUser: localSession.user
|
|
64545
|
+
}, {
|
|
64546
|
+
headers: { "Cache-Control": "no-store" }
|
|
64547
|
+
});
|
|
64548
|
+
}
|
|
64549
|
+
}
|
|
64550
|
+
if (endpoints.length === 0) {
|
|
64551
|
+
return Response.json(
|
|
64552
|
+
{ error: "Platform API not configured" },
|
|
64553
|
+
{ status: 503 }
|
|
64554
|
+
);
|
|
64555
|
+
}
|
|
64556
|
+
const headers = new Headers();
|
|
64557
|
+
headers.set("Cookie", cookie);
|
|
64558
|
+
for (const endpoint of endpoints) {
|
|
64559
|
+
const targetUrl = `${endpoint}/auth/session`;
|
|
64560
|
+
try {
|
|
64561
|
+
const response = await fetch(targetUrl, {
|
|
64562
|
+
method: "GET",
|
|
64563
|
+
headers
|
|
64564
|
+
});
|
|
64565
|
+
const responseHeaders = new Headers(response.headers);
|
|
64566
|
+
responseHeaders.set("Cache-Control", "no-store");
|
|
64567
|
+
if (bootstrappedFromProject && response.ok) {
|
|
64568
|
+
responseHeaders.append(
|
|
64569
|
+
"Set-Cookie",
|
|
64570
|
+
buildSessionCookieHeader(req, cookie)
|
|
64571
|
+
);
|
|
64572
|
+
}
|
|
64573
|
+
return new Response(response.body, {
|
|
64574
|
+
status: response.status,
|
|
64575
|
+
headers: responseHeaders
|
|
64576
|
+
});
|
|
64577
|
+
} catch {
|
|
64578
|
+
continue;
|
|
64579
|
+
}
|
|
64580
|
+
}
|
|
64581
|
+
return Response.json(
|
|
64582
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
64583
|
+
{ status: 502 }
|
|
64584
|
+
);
|
|
64585
|
+
});
|
|
64586
|
+
|
|
64587
|
+
// src/api/platform-auth/login.post.ts
|
|
64588
|
+
var login_post_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
64589
|
+
const endpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
64590
|
+
if (endpoints.length === 0) {
|
|
64591
|
+
const localSession = await createPlatformLocalSession(env2);
|
|
64592
|
+
if (localSession) {
|
|
64593
|
+
return Response.json({
|
|
64594
|
+
user: localSession.platform.user,
|
|
64595
|
+
account: localSession.platform.account,
|
|
64596
|
+
authType: localSession.authType,
|
|
64597
|
+
verified: localSession.platform.verified,
|
|
64598
|
+
token: localSession.token,
|
|
64599
|
+
localUser: localSession.user
|
|
64600
|
+
});
|
|
64601
|
+
}
|
|
64602
|
+
return Response.json(
|
|
64603
|
+
{ error: "Platform API not configured" },
|
|
64604
|
+
{ status: 503 }
|
|
64605
|
+
);
|
|
64606
|
+
}
|
|
64607
|
+
const headers = new Headers();
|
|
64608
|
+
const requestBody = await req.arrayBuffer();
|
|
64609
|
+
const contentType = req.headers.get("Content-Type");
|
|
64610
|
+
if (contentType) {
|
|
64611
|
+
headers.set("Content-Type", contentType);
|
|
64612
|
+
}
|
|
64613
|
+
const cookie = req.headers.get("Cookie");
|
|
64614
|
+
if (cookie) {
|
|
64615
|
+
headers.set("Cookie", cookie);
|
|
64616
|
+
}
|
|
64617
|
+
for (const endpoint of endpoints) {
|
|
64618
|
+
const targetUrl = `${endpoint}/auth/login`;
|
|
64619
|
+
try {
|
|
64620
|
+
const response = await fetch(targetUrl, {
|
|
64621
|
+
method: "POST",
|
|
64622
|
+
headers,
|
|
64623
|
+
body: requestBody
|
|
64624
|
+
});
|
|
64625
|
+
return new Response(response.body, {
|
|
64626
|
+
status: response.status,
|
|
64627
|
+
headers: response.headers
|
|
64628
|
+
});
|
|
64629
|
+
} catch {
|
|
64630
|
+
continue;
|
|
64631
|
+
}
|
|
64632
|
+
}
|
|
64633
|
+
return Response.json(
|
|
64634
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
64635
|
+
{ status: 502 }
|
|
64636
|
+
);
|
|
64637
|
+
});
|
|
64638
|
+
|
|
64639
|
+
// src/api/platform-auth/logout.post.ts
|
|
64640
|
+
var logout_post_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
64641
|
+
const endpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
64642
|
+
if (endpoints.length === 0) {
|
|
64643
|
+
return Response.json({ success: true });
|
|
64644
|
+
}
|
|
64645
|
+
const headers = new Headers();
|
|
64646
|
+
const requestBody = await req.arrayBuffer();
|
|
64647
|
+
const contentType = req.headers.get("Content-Type");
|
|
64648
|
+
if (contentType) {
|
|
64649
|
+
headers.set("Content-Type", contentType);
|
|
64650
|
+
}
|
|
64651
|
+
const cookie = req.headers.get("Cookie");
|
|
64652
|
+
if (cookie) {
|
|
64653
|
+
headers.set("Cookie", cookie);
|
|
64654
|
+
}
|
|
64655
|
+
for (const endpoint of endpoints) {
|
|
64656
|
+
const targetUrl = `${endpoint}/auth/logout`;
|
|
64657
|
+
try {
|
|
64658
|
+
const response = await fetch(targetUrl, {
|
|
64659
|
+
method: "POST",
|
|
64660
|
+
headers,
|
|
64661
|
+
body: requestBody
|
|
64662
|
+
});
|
|
64663
|
+
return new Response(response.body, {
|
|
64664
|
+
status: response.status,
|
|
64665
|
+
headers: response.headers
|
|
64666
|
+
});
|
|
64667
|
+
} catch {
|
|
64668
|
+
continue;
|
|
64669
|
+
}
|
|
64670
|
+
}
|
|
64671
|
+
return Response.json(
|
|
64672
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
64673
|
+
{ status: 502 }
|
|
64674
|
+
);
|
|
64675
|
+
});
|
|
64676
|
+
|
|
64677
|
+
// src/api/platform-auth/me.get.ts
|
|
64678
|
+
function uniqueEndpoints3(preferred, candidates) {
|
|
64679
|
+
return Array.from(new Set([preferred, ...candidates].filter((value) => Boolean(value))));
|
|
64680
|
+
}
|
|
64681
|
+
function buildSessionCookieHeader2(req, sessionCookie) {
|
|
64682
|
+
const attributes = ["Path=/", "HttpOnly", "SameSite=Lax"];
|
|
64683
|
+
try {
|
|
64684
|
+
if (new URL(req.url).protocol === "https:") {
|
|
64685
|
+
attributes.push("Secure");
|
|
64686
|
+
}
|
|
64687
|
+
} catch {
|
|
64688
|
+
}
|
|
64689
|
+
return `${sessionCookie}; ${attributes.join("; ")}`;
|
|
64690
|
+
}
|
|
64691
|
+
var me_get_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
64692
|
+
const requestCookie = req.headers.get("Cookie")?.trim() || "";
|
|
64693
|
+
const configuredEndpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
64694
|
+
let cookie = requestCookie;
|
|
64695
|
+
let endpoints = configuredEndpoints;
|
|
64696
|
+
let bootstrappedFromProject = false;
|
|
64697
|
+
if (!hasSessionCookie(cookie)) {
|
|
64698
|
+
const bootstrap = findLocalBootstrapSession(void 0, env2)?.session;
|
|
64699
|
+
if (bootstrap?.session_cookie) {
|
|
64700
|
+
cookie = bootstrap.session_cookie;
|
|
64701
|
+
endpoints = uniqueEndpoints3(bootstrap.endpoint, configuredEndpoints);
|
|
64702
|
+
bootstrappedFromProject = true;
|
|
64703
|
+
} else {
|
|
64704
|
+
const identity = await getPlatformIdentity(env2);
|
|
64705
|
+
if (identity) {
|
|
64706
|
+
return Response.json({
|
|
64707
|
+
user: identity.user,
|
|
64708
|
+
account: identity.account,
|
|
64709
|
+
authType: "platform_token",
|
|
64710
|
+
verified: identity.verified
|
|
64711
|
+
}, {
|
|
64712
|
+
headers: { "Cache-Control": "no-store" }
|
|
64713
|
+
});
|
|
64714
|
+
}
|
|
64715
|
+
}
|
|
64716
|
+
}
|
|
64717
|
+
if (endpoints.length === 0) {
|
|
64718
|
+
return Response.json(
|
|
64719
|
+
{ error: "Platform API not configured" },
|
|
64720
|
+
{ status: 503 }
|
|
64721
|
+
);
|
|
64722
|
+
}
|
|
64723
|
+
const headers = new Headers();
|
|
64724
|
+
if (cookie) {
|
|
64725
|
+
headers.set("Cookie", cookie);
|
|
64726
|
+
}
|
|
64727
|
+
for (const endpoint of endpoints) {
|
|
64728
|
+
const targetUrl = `${endpoint}/auth/session`;
|
|
64729
|
+
try {
|
|
64730
|
+
const response = await fetch(targetUrl, {
|
|
64731
|
+
method: "GET",
|
|
64732
|
+
headers
|
|
64733
|
+
});
|
|
64734
|
+
const responseHeaders = new Headers(response.headers);
|
|
64735
|
+
responseHeaders.set("Cache-Control", "no-store");
|
|
64736
|
+
if (bootstrappedFromProject && response.ok) {
|
|
64737
|
+
responseHeaders.append(
|
|
64738
|
+
"Set-Cookie",
|
|
64739
|
+
buildSessionCookieHeader2(req, cookie)
|
|
64740
|
+
);
|
|
64741
|
+
}
|
|
64742
|
+
return new Response(response.body, {
|
|
64743
|
+
status: response.status,
|
|
64744
|
+
headers: responseHeaders
|
|
64745
|
+
});
|
|
64746
|
+
} catch {
|
|
64747
|
+
continue;
|
|
64748
|
+
}
|
|
64749
|
+
}
|
|
64750
|
+
return Response.json(
|
|
64751
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
64752
|
+
{ status: 502 }
|
|
64753
|
+
);
|
|
64754
|
+
});
|
|
64755
|
+
|
|
64756
|
+
// src/api/platform-session/_proxy.ts
|
|
64757
|
+
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
64758
|
+
"connection",
|
|
64759
|
+
"keep-alive",
|
|
64760
|
+
"proxy-authenticate",
|
|
64761
|
+
"proxy-authorization",
|
|
64762
|
+
"te",
|
|
64763
|
+
"trailer",
|
|
64764
|
+
"transfer-encoding",
|
|
64765
|
+
"upgrade"
|
|
64766
|
+
]);
|
|
64767
|
+
function platformPath(params, req) {
|
|
64768
|
+
const rawPathParam = params._ || params.path || params["*"] || "";
|
|
64769
|
+
const path9 = rawPathParam.replace(/^\/+/, "");
|
|
64770
|
+
const url = new URL(req.url);
|
|
64771
|
+
const pathname = path9 ? `/${path9}` : "/";
|
|
64772
|
+
return `${pathname}${url.search}`;
|
|
64773
|
+
}
|
|
64774
|
+
function proxyHeaders(req, token) {
|
|
64775
|
+
const headers = new Headers(req.headers);
|
|
64776
|
+
for (const header of HOP_BY_HOP_HEADERS) {
|
|
64777
|
+
headers.delete(header);
|
|
64778
|
+
}
|
|
64779
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
64780
|
+
headers.delete("host");
|
|
64781
|
+
headers.delete("cookie");
|
|
64782
|
+
return headers;
|
|
64783
|
+
}
|
|
64784
|
+
async function proxyPlatformSessionRequest({
|
|
64785
|
+
req,
|
|
64786
|
+
params,
|
|
64787
|
+
env: env2
|
|
64788
|
+
}) {
|
|
64789
|
+
const token = typeof env2.STANDARD_AGENTS_API_KEY === "string" ? env2.STANDARD_AGENTS_API_KEY.trim() : "";
|
|
64790
|
+
if (!hasPlatformApiKey(env2) || !token) {
|
|
64791
|
+
return Response.json(
|
|
64792
|
+
{ error: "STANDARD_AGENTS_API_KEY is not configured" },
|
|
64793
|
+
{ status: 401 }
|
|
64794
|
+
);
|
|
64795
|
+
}
|
|
64796
|
+
const endpoint = platformEndpoint(env2);
|
|
64797
|
+
const target = `${endpoint}${platformPath(params, req)}`;
|
|
64798
|
+
const method = req.method.toUpperCase();
|
|
64799
|
+
const body = method === "GET" || method === "HEAD" ? void 0 : req.body;
|
|
64800
|
+
const response = await fetch(target, {
|
|
64801
|
+
method,
|
|
64802
|
+
headers: proxyHeaders(req, token),
|
|
64803
|
+
body,
|
|
64804
|
+
redirect: "manual"
|
|
64805
|
+
});
|
|
64806
|
+
const responseHeaders = new Headers(response.headers);
|
|
64807
|
+
responseHeaders.delete("set-cookie");
|
|
64808
|
+
return new Response(response.body, {
|
|
64809
|
+
status: response.status,
|
|
64810
|
+
statusText: response.statusText,
|
|
64811
|
+
headers: responseHeaders
|
|
64812
|
+
});
|
|
64813
|
+
}
|
|
64814
|
+
|
|
64815
|
+
// src/api/platform-session/[...path].ts
|
|
64816
|
+
var path_default2 = defineController2(async ({ req, params, env: env2, url }) => {
|
|
64817
|
+
if (!req.headers.get("Cookie") && hasPlatformApiKey(env2)) {
|
|
64818
|
+
return proxyPlatformSessionRequest({ req, params, env: env2 });
|
|
64819
|
+
}
|
|
64820
|
+
const endpoints = resolvePlatformEndpointCandidates(req, env2);
|
|
64821
|
+
if (endpoints.length === 0) {
|
|
64822
|
+
return Response.json(
|
|
64823
|
+
{ error: "Platform API not configured" },
|
|
64824
|
+
{ status: 503 }
|
|
64825
|
+
);
|
|
64826
|
+
}
|
|
64827
|
+
const pathParam = params._ || params.path || params["*"] || "";
|
|
64828
|
+
const headers = new Headers();
|
|
64829
|
+
const requestBody = req.method === "GET" || req.method === "HEAD" ? void 0 : await req.arrayBuffer();
|
|
64830
|
+
const contentType = req.headers.get("Content-Type");
|
|
64831
|
+
if (contentType) {
|
|
64832
|
+
headers.set("Content-Type", contentType);
|
|
64833
|
+
}
|
|
64834
|
+
const cookie = req.headers.get("Cookie");
|
|
64835
|
+
if (cookie) {
|
|
64836
|
+
headers.set("Cookie", cookie);
|
|
64837
|
+
}
|
|
64838
|
+
for (const endpoint of endpoints) {
|
|
64839
|
+
const targetUrl = `${endpoint}/${pathParam}${url.search}`;
|
|
64840
|
+
try {
|
|
64841
|
+
const response = await fetch(targetUrl, {
|
|
64842
|
+
method: req.method,
|
|
64843
|
+
headers,
|
|
64844
|
+
body: requestBody
|
|
64845
|
+
});
|
|
64846
|
+
return new Response(response.body, {
|
|
64847
|
+
status: response.status,
|
|
64848
|
+
headers: response.headers
|
|
64849
|
+
});
|
|
64850
|
+
} catch {
|
|
64851
|
+
continue;
|
|
64852
|
+
}
|
|
64853
|
+
}
|
|
64854
|
+
return Response.json(
|
|
64855
|
+
{ error: "Bad Gateway: platform API unreachable" },
|
|
64856
|
+
{ status: 502 }
|
|
64857
|
+
);
|
|
64858
|
+
});
|
|
64859
|
+
|
|
63984
64860
|
// src/api/variables/_scan.ts
|
|
63985
64861
|
function normalizeEnvRecord(value) {
|
|
63986
64862
|
if (!value || typeof value !== "object") return {};
|
|
@@ -64126,6 +65002,10 @@ function getIncludeOptionalDisabledFromUrl(url) {
|
|
|
64126
65002
|
const raw = (url.searchParams.get("include_optional_disabled") || "").trim().toLowerCase();
|
|
64127
65003
|
return raw === "1" || raw === "true" || raw === "yes";
|
|
64128
65004
|
}
|
|
65005
|
+
function getTargetOnlyFromUrl(url) {
|
|
65006
|
+
const raw = (url.searchParams.get("target_only") || "").trim().toLowerCase();
|
|
65007
|
+
return raw === "1" || raw === "true" || raw === "yes";
|
|
65008
|
+
}
|
|
64129
65009
|
function parsePreviewEnvQuery(raw) {
|
|
64130
65010
|
if (!raw) return {};
|
|
64131
65011
|
try {
|
|
@@ -64146,6 +65026,35 @@ function parsePreviewEnvQuery(raw) {
|
|
|
64146
65026
|
function getPreviewEnvFromUrl(url) {
|
|
64147
65027
|
return parsePreviewEnvQuery(url.searchParams.get("preview_env"));
|
|
64148
65028
|
}
|
|
65029
|
+
function parsePreviewVariablesQuery(raw) {
|
|
65030
|
+
if (!raw) return [];
|
|
65031
|
+
try {
|
|
65032
|
+
const parsed = JSON.parse(raw);
|
|
65033
|
+
if (!Array.isArray(parsed)) return [];
|
|
65034
|
+
const variables = [];
|
|
65035
|
+
for (const item of parsed) {
|
|
65036
|
+
if (!item || typeof item !== "object") continue;
|
|
65037
|
+
const name15 = typeof item.name === "string" ? item.name.trim() : "";
|
|
65038
|
+
if (!name15) continue;
|
|
65039
|
+
variables.push({
|
|
65040
|
+
name: name15,
|
|
65041
|
+
type: item.type === "secret" ? "secret" : "text",
|
|
65042
|
+
required: !!item.required,
|
|
65043
|
+
scoped: !!item.scoped,
|
|
65044
|
+
description: typeof item.description === "string" ? item.description : ""
|
|
65045
|
+
});
|
|
65046
|
+
}
|
|
65047
|
+
return variables;
|
|
65048
|
+
} catch {
|
|
65049
|
+
return [];
|
|
65050
|
+
}
|
|
65051
|
+
}
|
|
65052
|
+
function getPreviewVariablesFromUrl(url) {
|
|
65053
|
+
return parsePreviewVariablesQuery(url.searchParams.get("preview_variables"));
|
|
65054
|
+
}
|
|
65055
|
+
function hasPreviewVariablesInUrl(url) {
|
|
65056
|
+
return url.searchParams.has("preview_variables");
|
|
65057
|
+
}
|
|
64149
65058
|
async function scanVariables(context) {
|
|
64150
65059
|
const queue = [
|
|
64151
65060
|
{ ...context.target, optionalBranches: [] },
|
|
@@ -64165,7 +65074,9 @@ async function scanVariables(context) {
|
|
|
64165
65074
|
let threadEnv = {};
|
|
64166
65075
|
let threadEnvTypes = {};
|
|
64167
65076
|
let accountEnv = {};
|
|
65077
|
+
let accountEnvTypes = {};
|
|
64168
65078
|
let instanceEnv = {};
|
|
65079
|
+
let instanceEnvTypes = {};
|
|
64169
65080
|
const previewEnv = normalizeEnvRecord(context.previewEnv ?? null);
|
|
64170
65081
|
let accountUserId = context.userId ?? null;
|
|
64171
65082
|
if (context.threadId && context.agentBuilder?.getThread) {
|
|
@@ -64181,9 +65092,21 @@ async function scanVariables(context) {
|
|
|
64181
65092
|
if (accountUserId && context.agentBuilder?.getUserEnv) {
|
|
64182
65093
|
accountEnv = normalizeEnvRecord(await context.agentBuilder.getUserEnv(accountUserId));
|
|
64183
65094
|
}
|
|
65095
|
+
if (accountUserId && context.agentBuilder?.getUserEnvTypes) {
|
|
65096
|
+
accountEnvTypes = normalizeEnvTypeRecord3(
|
|
65097
|
+
await context.agentBuilder.getUserEnvTypes(accountUserId),
|
|
65098
|
+
accountEnv
|
|
65099
|
+
);
|
|
65100
|
+
}
|
|
64184
65101
|
if (context.agentBuilder?.getInstanceEnv) {
|
|
64185
65102
|
instanceEnv = normalizeEnvRecord(await context.agentBuilder.getInstanceEnv());
|
|
64186
65103
|
}
|
|
65104
|
+
if (context.agentBuilder?.getInstanceEnvTypes) {
|
|
65105
|
+
instanceEnvTypes = normalizeEnvTypeRecord3(
|
|
65106
|
+
await context.agentBuilder.getInstanceEnvTypes(),
|
|
65107
|
+
instanceEnv
|
|
65108
|
+
);
|
|
65109
|
+
}
|
|
64187
65110
|
async function getModelDefinition(modelName) {
|
|
64188
65111
|
if (modelCache.has(modelName)) {
|
|
64189
65112
|
return modelCache.get(modelName);
|
|
@@ -64281,6 +65204,36 @@ async function scanVariables(context) {
|
|
|
64281
65204
|
dedupeAddDeclared(existing, source);
|
|
64282
65205
|
}
|
|
64283
65206
|
}
|
|
65207
|
+
function addPreviewDeclarations(defs) {
|
|
65208
|
+
for (const def of defs) {
|
|
65209
|
+
if (!def?.name) continue;
|
|
65210
|
+
const property = def.name;
|
|
65211
|
+
const existing = variables.get(property);
|
|
65212
|
+
if (!existing) {
|
|
65213
|
+
variables.set(property, {
|
|
65214
|
+
property,
|
|
65215
|
+
type: def.type === "secret" ? "secret" : "text",
|
|
65216
|
+
required: !!def.required,
|
|
65217
|
+
scoped: !!def.scoped,
|
|
65218
|
+
description: def.description ?? "",
|
|
65219
|
+
declaredSet: /* @__PURE__ */ new Set(),
|
|
65220
|
+
declared: [],
|
|
65221
|
+
optionalOnly: false,
|
|
65222
|
+
optionalBranchSet: /* @__PURE__ */ new Set(),
|
|
65223
|
+
optionalBranches: []
|
|
65224
|
+
});
|
|
65225
|
+
continue;
|
|
65226
|
+
}
|
|
65227
|
+
existing.required = existing.required || !!def.required;
|
|
65228
|
+
existing.scoped = existing.scoped || !!def.scoped;
|
|
65229
|
+
if (def.type === "secret") {
|
|
65230
|
+
existing.type = "secret";
|
|
65231
|
+
}
|
|
65232
|
+
if (!existing.description && def.description) {
|
|
65233
|
+
existing.description = def.description;
|
|
65234
|
+
}
|
|
65235
|
+
}
|
|
65236
|
+
}
|
|
64284
65237
|
while (queue.length > 0) {
|
|
64285
65238
|
const current = queue.shift();
|
|
64286
65239
|
const branchSignature = dedupeOptionalBranches(current.optionalBranches).map(getOptionalBranchKey).sort((a, b) => a.localeCompare(b)).join(";");
|
|
@@ -64302,6 +65255,7 @@ async function scanVariables(context) {
|
|
|
64302
65255
|
extractDeclaredVariables(toolDef),
|
|
64303
65256
|
current.optionalBranches
|
|
64304
65257
|
);
|
|
65258
|
+
if (context.targetOnly) continue;
|
|
64305
65259
|
const uses = Array.isArray(toolDef.uses) ? toolDef.uses : [];
|
|
64306
65260
|
for (const useNameRaw of uses) {
|
|
64307
65261
|
if (typeof useNameRaw !== "string") continue;
|
|
@@ -64337,6 +65291,7 @@ async function scanVariables(context) {
|
|
|
64337
65291
|
agentValueSources.set(property, { name: current.name, value });
|
|
64338
65292
|
}
|
|
64339
65293
|
}
|
|
65294
|
+
if (context.targetOnly) continue;
|
|
64340
65295
|
const sideAPrompt = typeof agentDef.sideA?.prompt === "string" ? agentDef.sideA.prompt : null;
|
|
64341
65296
|
const sideBPrompt = typeof agentDef.sideB?.prompt === "string" ? agentDef.sideB.prompt : null;
|
|
64342
65297
|
if (sideAPrompt) queue.push({ type: "prompt", name: sideAPrompt, optionalBranches: current.optionalBranches });
|
|
@@ -64353,9 +65308,10 @@ async function scanVariables(context) {
|
|
|
64353
65308
|
promptDef = null;
|
|
64354
65309
|
}
|
|
64355
65310
|
if (!promptDef) continue;
|
|
65311
|
+
const declarationDefinitions = context.previewVariables !== void 0 && current.type === context.target.type && current.name === context.target.name ? context.previewVariables : extractDeclaredVariables(promptDef);
|
|
64356
65312
|
addDeclarations(
|
|
64357
65313
|
{ type: "prompt", name: current.name },
|
|
64358
|
-
|
|
65314
|
+
declarationDefinitions,
|
|
64359
65315
|
current.optionalBranches
|
|
64360
65316
|
);
|
|
64361
65317
|
const promptEnv = normalizeEnvRecord(promptDef.env ?? promptDef.tenvs ?? null);
|
|
@@ -64364,6 +65320,7 @@ async function scanVariables(context) {
|
|
|
64364
65320
|
promptValueSources.set(property, { name: current.name, value });
|
|
64365
65321
|
}
|
|
64366
65322
|
}
|
|
65323
|
+
if (context.targetOnly) continue;
|
|
64367
65324
|
const providerTools = await getProviderToolsForModel(promptDef.model);
|
|
64368
65325
|
const tools = Array.isArray(promptDef.tools) ? promptDef.tools : [];
|
|
64369
65326
|
for (const entry of tools) {
|
|
@@ -64382,7 +65339,7 @@ async function scanVariables(context) {
|
|
|
64382
65339
|
branchDescriptor
|
|
64383
65340
|
);
|
|
64384
65341
|
if (optionalGate) {
|
|
64385
|
-
const enabledValue = previewEnv[optionalGate] ?? threadEnv[optionalGate] ??
|
|
65342
|
+
const enabledValue = previewEnv[optionalGate] ?? threadEnv[optionalGate] ?? agentValueSources.get(optionalGate)?.value ?? promptEnv[optionalGate] ?? promptValueSources.get(optionalGate)?.value ?? accountEnv[optionalGate] ?? instanceEnv[optionalGate];
|
|
64386
65343
|
if (!context.includeOptionalDisabled && !isEnabledEnvFlag2(enabledValue)) {
|
|
64387
65344
|
continue;
|
|
64388
65345
|
}
|
|
@@ -64430,6 +65387,7 @@ async function scanVariables(context) {
|
|
|
64430
65387
|
}
|
|
64431
65388
|
}
|
|
64432
65389
|
}
|
|
65390
|
+
addPreviewDeclarations(context.previewVariables || []);
|
|
64433
65391
|
const output = [];
|
|
64434
65392
|
for (const property of Object.keys(threadEnv)) {
|
|
64435
65393
|
if (variables.has(property)) continue;
|
|
@@ -64464,12 +65422,6 @@ async function scanVariables(context) {
|
|
|
64464
65422
|
} else {
|
|
64465
65423
|
type = "secret";
|
|
64466
65424
|
}
|
|
64467
|
-
} else if (accountEnv[property] !== void 0) {
|
|
64468
|
-
defined = { type: "account" };
|
|
64469
|
-
resolvedValue = accountEnv[property];
|
|
64470
|
-
} else if (instanceEnv[property] !== void 0) {
|
|
64471
|
-
defined = { type: "instance" };
|
|
64472
|
-
resolvedValue = instanceEnv[property];
|
|
64473
65425
|
} else if (agentValueSources.has(property)) {
|
|
64474
65426
|
const source = agentValueSources.get(property);
|
|
64475
65427
|
defined = { type: "agent", name: source.name };
|
|
@@ -64478,6 +65430,14 @@ async function scanVariables(context) {
|
|
|
64478
65430
|
const source = promptValueSources.get(property);
|
|
64479
65431
|
defined = { type: "prompt", name: source.name };
|
|
64480
65432
|
resolvedValue = source.value;
|
|
65433
|
+
} else if (accountEnv[property] !== void 0) {
|
|
65434
|
+
defined = { type: "account" };
|
|
65435
|
+
resolvedValue = accountEnv[property];
|
|
65436
|
+
type = accountEnvTypes[property] === "text" ? "text" : "secret";
|
|
65437
|
+
} else if (instanceEnv[property] !== void 0) {
|
|
65438
|
+
defined = { type: "instance" };
|
|
65439
|
+
resolvedValue = instanceEnv[property];
|
|
65440
|
+
type = instanceEnvTypes[property] === "text" ? "text" : "secret";
|
|
64481
65441
|
}
|
|
64482
65442
|
const item = {
|
|
64483
65443
|
property,
|
|
@@ -64753,19 +65713,19 @@ var publish_post_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
64753
65713
|
}
|
|
64754
65714
|
try {
|
|
64755
65715
|
const { NpmPublishService: NpmPublishService2 } = await Promise.resolve().then(() => (init_npm_publish_service(), npm_publish_service_exports));
|
|
64756
|
-
const
|
|
64757
|
-
const
|
|
65716
|
+
const path9 = await import('path');
|
|
65717
|
+
const fs7 = await import('fs');
|
|
64758
65718
|
const rootDir = process.cwd();
|
|
64759
|
-
const packageDir =
|
|
64760
|
-
if (!
|
|
64761
|
-
const packedDir =
|
|
64762
|
-
if (!
|
|
65719
|
+
const packageDir = path9.join(rootDir, "agents", "packed", agentName);
|
|
65720
|
+
if (!fs7.existsSync(packageDir)) {
|
|
65721
|
+
const packedDir = path9.join(rootDir, "agents", "packed");
|
|
65722
|
+
if (!fs7.existsSync(packedDir)) {
|
|
64763
65723
|
return Response.json(
|
|
64764
65724
|
{ error: `No packed packages found. Pack the agent first.` },
|
|
64765
65725
|
{ status: 400 }
|
|
64766
65726
|
);
|
|
64767
65727
|
}
|
|
64768
|
-
const dirs =
|
|
65728
|
+
const dirs = fs7.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
64769
65729
|
const matchingDir = dirs.find(
|
|
64770
65730
|
(d) => d === agentName || d === `standardagent-${agentName}` || d === `standardagent-${agentName.replace(/_/g, "-")}`
|
|
64771
65731
|
);
|
|
@@ -64775,7 +65735,7 @@ var publish_post_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
64775
65735
|
{ status: 400 }
|
|
64776
65736
|
);
|
|
64777
65737
|
}
|
|
64778
|
-
const foundPackageDir =
|
|
65738
|
+
const foundPackageDir = path9.join(packedDir, matchingDir);
|
|
64779
65739
|
const publishService2 = new NpmPublishService2();
|
|
64780
65740
|
const result2 = await publishService2.publish({
|
|
64781
65741
|
packageDir: foundPackageDir,
|
|
@@ -65248,9 +66208,9 @@ var fs_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
65248
66208
|
}
|
|
65249
66209
|
const grepPattern = url.searchParams.get("grep");
|
|
65250
66210
|
if (grepPattern) {
|
|
65251
|
-
const
|
|
66211
|
+
const path9 = url.searchParams.get("path") || void 0;
|
|
65252
66212
|
const limit = parseInt(url.searchParams.get("limit") || "100", 10);
|
|
65253
|
-
const result2 = await stub.grepFiles(grepPattern, { path:
|
|
66213
|
+
const result2 = await stub.grepFiles(grepPattern, { path: path9, limit });
|
|
65254
66214
|
if (!result2.success) {
|
|
65255
66215
|
return Response.json({ error: result2.error }, { status: 500 });
|
|
65256
66216
|
}
|
|
@@ -65456,6 +66416,10 @@ var logs_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
65456
66416
|
const limit = parseInt(url.searchParams.get("limit") || "100", 10);
|
|
65457
66417
|
const offset = parseInt(url.searchParams.get("offset") || "0", 10);
|
|
65458
66418
|
const order = url.searchParams.get("order") === "desc" ? "DESC" : "ASC";
|
|
66419
|
+
const ids = (url.searchParams.get("ids") || "").split(",").map((id) => id.trim()).filter(Boolean);
|
|
66420
|
+
const messageIds = (url.searchParams.get("messageIds") || "").split(",").map((id) => id.trim()).filter(Boolean);
|
|
66421
|
+
const includeWorkblocks = url.searchParams.get("includeWorkblocks") === "true";
|
|
66422
|
+
const includeDescendants = url.searchParams.get("includeDescendants") === "true";
|
|
65459
66423
|
if (req.headers.get("upgrade")?.toLowerCase() === "websocket") {
|
|
65460
66424
|
const durableId2 = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
65461
66425
|
const stub2 = env2.AGENT_BUILDER_THREAD.get(durableId2);
|
|
@@ -65463,7 +66427,12 @@ var logs_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
65463
66427
|
}
|
|
65464
66428
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
65465
66429
|
const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
65466
|
-
const result = await stub.
|
|
66430
|
+
const result = messageIds.length > 0 && typeof stub.getLogsByMessageIds === "function" ? await stub.getLogsByMessageIds(
|
|
66431
|
+
messageIds,
|
|
66432
|
+
includeWorkblocks,
|
|
66433
|
+
includeDescendants,
|
|
66434
|
+
order
|
|
66435
|
+
) : ids.length > 0 && typeof stub.getLogsByIds === "function" ? await stub.getLogsByIds(ids, includeDescendants, order) : await stub.getLogs(limit, offset, order);
|
|
65467
66436
|
return Response.json(result);
|
|
65468
66437
|
} catch (error) {
|
|
65469
66438
|
console.error(`Error fetching logs for thread ${threadId}:`, error);
|
|
@@ -65496,9 +66465,16 @@ var messages_get_default = defineController2(async ({ req, params, env: env2 })
|
|
|
65496
66465
|
const order = url.searchParams.get("order") === "asc" ? "ASC" : "DESC";
|
|
65497
66466
|
const includeSilent = url.searchParams.get("includeSilent") === "true";
|
|
65498
66467
|
const maxDepth = parseInt(url.searchParams.get("depth") || "0", 10);
|
|
66468
|
+
const ids = (url.searchParams.get("ids") || "").split(",").map((id) => id.trim()).filter(Boolean);
|
|
66469
|
+
const includeWorkblocks = url.searchParams.get("includeWorkblocks") === "true";
|
|
65499
66470
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
65500
66471
|
const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
65501
|
-
const result = await stub.
|
|
66472
|
+
const result = ids.length > 0 && typeof stub.getMessagesByIds === "function" ? await stub.getMessagesByIds(
|
|
66473
|
+
ids,
|
|
66474
|
+
includeSilent,
|
|
66475
|
+
maxDepth,
|
|
66476
|
+
includeWorkblocks
|
|
66477
|
+
) : await stub.getMessages(
|
|
65502
66478
|
limit,
|
|
65503
66479
|
offset,
|
|
65504
66480
|
order,
|
|
@@ -65585,12 +66561,12 @@ var messages_post_default = defineController2(async ({ req, params, env: env2 })
|
|
|
65585
66561
|
}
|
|
65586
66562
|
}
|
|
65587
66563
|
const ext = mimeType === "image/png" ? "png" : mimeType === "image/jpeg" ? "jpg" : attachment.name.split(".").pop() || "bin";
|
|
65588
|
-
const
|
|
66564
|
+
const path9 = `/attachments/${timestamp}-${attachmentId}.${ext}`;
|
|
65589
66565
|
const base64Size = fileData.length;
|
|
65590
66566
|
const binarySize = Math.ceil(base64Size * 3 / 4);
|
|
65591
|
-
console.log(`[writeFile] Storing ${attachment.name}: ${(binarySize / 1024 / 1024).toFixed(2)}MB binary (${(base64Size / 1024 / 1024).toFixed(2)}MB base64) to ${
|
|
66567
|
+
console.log(`[writeFile] Storing ${attachment.name}: ${(binarySize / 1024 / 1024).toFixed(2)}MB binary (${(base64Size / 1024 / 1024).toFixed(2)}MB base64) to ${path9}`);
|
|
65592
66568
|
const result = await stub.writeFile(
|
|
65593
|
-
|
|
66569
|
+
path9,
|
|
65594
66570
|
fileData,
|
|
65595
66571
|
mimeType,
|
|
65596
66572
|
{
|
|
@@ -65607,7 +66583,7 @@ var messages_post_default = defineController2(async ({ req, params, env: env2 })
|
|
|
65607
66583
|
const ref = {
|
|
65608
66584
|
id: attachmentId,
|
|
65609
66585
|
type: "file",
|
|
65610
|
-
path:
|
|
66586
|
+
path: path9,
|
|
65611
66587
|
name: attachment.name,
|
|
65612
66588
|
mimeType,
|
|
65613
66589
|
size: binarySize
|
|
@@ -65748,6 +66724,77 @@ var analyze_get_default2 = defineController2(async ({ req }) => {
|
|
|
65748
66724
|
}
|
|
65749
66725
|
});
|
|
65750
66726
|
|
|
66727
|
+
// src/api/users/[id]/env.get.ts
|
|
66728
|
+
var env_get_default = defineController2(async ({ req, env: env2, params }) => {
|
|
66729
|
+
try {
|
|
66730
|
+
const authResult = await requireAdmin(req, env2);
|
|
66731
|
+
if (authResult instanceof Response) {
|
|
66732
|
+
return authResult;
|
|
66733
|
+
}
|
|
66734
|
+
const userId = params.id;
|
|
66735
|
+
if (!userId) {
|
|
66736
|
+
return Response.json({ error: "User ID is required" }, { status: 400 });
|
|
66737
|
+
}
|
|
66738
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
66739
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
66740
|
+
const user = await agentBuilder.getUserById(userId);
|
|
66741
|
+
if (!user) {
|
|
66742
|
+
return Response.json({ error: "User not found" }, { status: 404 });
|
|
66743
|
+
}
|
|
66744
|
+
const variables = typeof agentBuilder.getUserEnvEntries === "function" ? await agentBuilder.getUserEnvEntries(userId) : [];
|
|
66745
|
+
return Response.json({
|
|
66746
|
+
user: {
|
|
66747
|
+
id: user.id,
|
|
66748
|
+
username: user.username
|
|
66749
|
+
},
|
|
66750
|
+
...buildScopedEnvResponse(variables)
|
|
66751
|
+
});
|
|
66752
|
+
} catch (error) {
|
|
66753
|
+
console.error("Get user env error:", error);
|
|
66754
|
+
return Response.json(
|
|
66755
|
+
{ error: error.message || "Failed to load user env" },
|
|
66756
|
+
{ status: 500 }
|
|
66757
|
+
);
|
|
66758
|
+
}
|
|
66759
|
+
});
|
|
66760
|
+
|
|
66761
|
+
// src/api/users/[id]/env.patch.ts
|
|
66762
|
+
var env_patch_default = defineController2(async ({ req, env: env2, params }) => {
|
|
66763
|
+
try {
|
|
66764
|
+
const authResult = await requireAdmin(req, env2);
|
|
66765
|
+
if (authResult instanceof Response) {
|
|
66766
|
+
return authResult;
|
|
66767
|
+
}
|
|
66768
|
+
const userId = params.id;
|
|
66769
|
+
if (!userId) {
|
|
66770
|
+
return Response.json({ error: "User ID is required" }, { status: 400 });
|
|
66771
|
+
}
|
|
66772
|
+
const body = await req.json().catch(() => null);
|
|
66773
|
+
const parsed = validateScopedEnvPatchBody(body);
|
|
66774
|
+
if (!parsed.ok) {
|
|
66775
|
+
return Response.json({ error: parsed.error }, { status: 400 });
|
|
66776
|
+
}
|
|
66777
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
66778
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
66779
|
+
const user = await agentBuilder.getUserById(userId);
|
|
66780
|
+
if (!user) {
|
|
66781
|
+
return Response.json({ error: "User not found" }, { status: 404 });
|
|
66782
|
+
}
|
|
66783
|
+
if (typeof agentBuilder.patchUserEnv !== "function") {
|
|
66784
|
+
throw new Error("patchUserEnv is not supported by this runtime");
|
|
66785
|
+
}
|
|
66786
|
+
await agentBuilder.patchUserEnv(userId, parsed.payload);
|
|
66787
|
+
return Response.json({ success: true });
|
|
66788
|
+
} catch (error) {
|
|
66789
|
+
console.error("Patch user env error:", error);
|
|
66790
|
+
const status = isScopedEnvValidationError(error) ? 400 : 500;
|
|
66791
|
+
return Response.json(
|
|
66792
|
+
{ error: error.message || "Failed to update user env" },
|
|
66793
|
+
{ status }
|
|
66794
|
+
);
|
|
66795
|
+
}
|
|
66796
|
+
});
|
|
66797
|
+
|
|
65751
66798
|
// src/api/variables/agents/[name].get.ts
|
|
65752
66799
|
var name_get_default5 = defineController2(async ({ params, url, prompts, agents, tools, models, env: env2, req }) => {
|
|
65753
66800
|
const agentName = params.name ? decodeURIComponent(params.name) : "";
|
|
@@ -65759,14 +66806,18 @@ var name_get_default5 = defineController2(async ({ params, url, prompts, agents,
|
|
|
65759
66806
|
const threadId = url.searchParams.get("thread_id") || void 0;
|
|
65760
66807
|
const include = getIncludeTargetsFromUrl(url);
|
|
65761
66808
|
const previewEnv = getPreviewEnvFromUrl(url);
|
|
66809
|
+
const previewVariables = hasPreviewVariablesInUrl(url) ? getPreviewVariablesFromUrl(url) : void 0;
|
|
65762
66810
|
const includeOptionalDisabled = getIncludeOptionalDisabledFromUrl(url);
|
|
66811
|
+
const targetOnly = getTargetOnlyFromUrl(url);
|
|
65763
66812
|
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
65764
66813
|
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
65765
66814
|
const variables = await scanVariables({
|
|
65766
66815
|
target: { type: "agent", name: agentName },
|
|
65767
66816
|
include,
|
|
65768
66817
|
previewEnv,
|
|
66818
|
+
previewVariables,
|
|
65769
66819
|
includeOptionalDisabled,
|
|
66820
|
+
targetOnly,
|
|
65770
66821
|
prompts,
|
|
65771
66822
|
agents,
|
|
65772
66823
|
tools,
|
|
@@ -65789,14 +66840,18 @@ var name_get_default6 = defineController2(async ({ params, url, prompts, agents,
|
|
|
65789
66840
|
const threadId = url.searchParams.get("thread_id") || void 0;
|
|
65790
66841
|
const include = getIncludeTargetsFromUrl(url);
|
|
65791
66842
|
const previewEnv = getPreviewEnvFromUrl(url);
|
|
66843
|
+
const previewVariables = hasPreviewVariablesInUrl(url) ? getPreviewVariablesFromUrl(url) : void 0;
|
|
65792
66844
|
const includeOptionalDisabled = getIncludeOptionalDisabledFromUrl(url);
|
|
66845
|
+
const targetOnly = getTargetOnlyFromUrl(url);
|
|
65793
66846
|
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
65794
66847
|
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
65795
66848
|
const variables = await scanVariables({
|
|
65796
66849
|
target: { type: "prompt", name: promptName },
|
|
65797
66850
|
include,
|
|
65798
66851
|
previewEnv,
|
|
66852
|
+
previewVariables,
|
|
65799
66853
|
includeOptionalDisabled,
|
|
66854
|
+
targetOnly,
|
|
65800
66855
|
prompts,
|
|
65801
66856
|
agents,
|
|
65802
66857
|
tools,
|
|
@@ -65819,14 +66874,18 @@ var name_get_default7 = defineController2(async ({ params, url, prompts, agents,
|
|
|
65819
66874
|
const threadId = url.searchParams.get("thread_id") || void 0;
|
|
65820
66875
|
const include = getIncludeTargetsFromUrl(url);
|
|
65821
66876
|
const previewEnv = getPreviewEnvFromUrl(url);
|
|
66877
|
+
const previewVariables = hasPreviewVariablesInUrl(url) ? getPreviewVariablesFromUrl(url) : void 0;
|
|
65822
66878
|
const includeOptionalDisabled = getIncludeOptionalDisabledFromUrl(url);
|
|
66879
|
+
const targetOnly = getTargetOnlyFromUrl(url);
|
|
65823
66880
|
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
65824
66881
|
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
65825
66882
|
const variables = await scanVariables({
|
|
65826
66883
|
target: { type: "tool", name: toolName },
|
|
65827
66884
|
include,
|
|
65828
66885
|
previewEnv,
|
|
66886
|
+
previewVariables,
|
|
65829
66887
|
includeOptionalDisabled,
|
|
66888
|
+
targetOnly,
|
|
65830
66889
|
prompts,
|
|
65831
66890
|
agents,
|
|
65832
66891
|
tools,
|
|
@@ -65838,6 +66897,73 @@ var name_get_default7 = defineController2(async ({ params, url, prompts, agents,
|
|
|
65838
66897
|
return Response.json({ variables });
|
|
65839
66898
|
});
|
|
65840
66899
|
|
|
66900
|
+
// src/api/users/me/env.get.ts
|
|
66901
|
+
var env_get_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
66902
|
+
try {
|
|
66903
|
+
const authResult = await requireAuth(req, env2);
|
|
66904
|
+
if (authResult instanceof Response) {
|
|
66905
|
+
return authResult;
|
|
66906
|
+
}
|
|
66907
|
+
const auth = authResult;
|
|
66908
|
+
if (auth.authType === "super_admin") {
|
|
66909
|
+
return Response.json(
|
|
66910
|
+
{
|
|
66911
|
+
error: "Super admin sessions do not have per-user env storage. Use instance envs or sign in as a user account."
|
|
66912
|
+
},
|
|
66913
|
+
{ status: 400 }
|
|
66914
|
+
);
|
|
66915
|
+
}
|
|
66916
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
66917
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
66918
|
+
const variables = typeof agentBuilder.getUserEnvEntries === "function" ? await agentBuilder.getUserEnvEntries(auth.user.id) : [];
|
|
66919
|
+
return Response.json(buildScopedEnvResponse(variables));
|
|
66920
|
+
} catch (error) {
|
|
66921
|
+
console.error("Get current user env error:", error);
|
|
66922
|
+
return Response.json(
|
|
66923
|
+
{ error: error.message || "Failed to load user env" },
|
|
66924
|
+
{ status: 500 }
|
|
66925
|
+
);
|
|
66926
|
+
}
|
|
66927
|
+
});
|
|
66928
|
+
|
|
66929
|
+
// src/api/users/me/env.patch.ts
|
|
66930
|
+
var env_patch_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
66931
|
+
try {
|
|
66932
|
+
const authResult = await requireAuth(req, env2);
|
|
66933
|
+
if (authResult instanceof Response) {
|
|
66934
|
+
return authResult;
|
|
66935
|
+
}
|
|
66936
|
+
const auth = authResult;
|
|
66937
|
+
if (auth.authType === "super_admin") {
|
|
66938
|
+
return Response.json(
|
|
66939
|
+
{
|
|
66940
|
+
error: "Super admin sessions do not have per-user env storage. Use instance envs or sign in as a user account."
|
|
66941
|
+
},
|
|
66942
|
+
{ status: 400 }
|
|
66943
|
+
);
|
|
66944
|
+
}
|
|
66945
|
+
const body = await req.json().catch(() => null);
|
|
66946
|
+
const parsed = validateScopedEnvPatchBody(body);
|
|
66947
|
+
if (!parsed.ok) {
|
|
66948
|
+
return Response.json({ error: parsed.error }, { status: 400 });
|
|
66949
|
+
}
|
|
66950
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
66951
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
66952
|
+
if (typeof agentBuilder.patchUserEnv !== "function") {
|
|
66953
|
+
throw new Error("patchUserEnv is not supported by this runtime");
|
|
66954
|
+
}
|
|
66955
|
+
await agentBuilder.patchUserEnv(auth.user.id, parsed.payload);
|
|
66956
|
+
return Response.json({ success: true });
|
|
66957
|
+
} catch (error) {
|
|
66958
|
+
console.error("Patch current user env error:", error);
|
|
66959
|
+
const status = isScopedEnvValidationError(error) ? 400 : 500;
|
|
66960
|
+
return Response.json(
|
|
66961
|
+
{ error: error.message || "Failed to update user env" },
|
|
66962
|
+
{ status }
|
|
66963
|
+
);
|
|
66964
|
+
}
|
|
66965
|
+
});
|
|
66966
|
+
|
|
65841
66967
|
// src/api/threads/[id]/fs/[...path].ts
|
|
65842
66968
|
var CHUNK_SIZE2 = 1.75 * 1024 * 1024;
|
|
65843
66969
|
function toAttachmentRef(file) {
|
|
@@ -65856,19 +66982,19 @@ function toAttachmentRef(file) {
|
|
|
65856
66982
|
...height && { height }
|
|
65857
66983
|
};
|
|
65858
66984
|
}
|
|
65859
|
-
var
|
|
66985
|
+
var path_default3 = defineController2(async ({ req, params, env: env2 }) => {
|
|
65860
66986
|
const threadId = params.id;
|
|
65861
66987
|
const rawPathParam = params._ || params.path || params["*"] || "";
|
|
65862
66988
|
const pathParam = rawPathParam === "fs" ? "" : rawPathParam.replace(/^\/?fs\//, "");
|
|
65863
66989
|
if (!threadId) {
|
|
65864
66990
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
65865
66991
|
}
|
|
65866
|
-
const
|
|
66992
|
+
const path9 = pathParam ? `/${pathParam}` : "/";
|
|
65867
66993
|
const url = new URL(req.url);
|
|
65868
66994
|
try {
|
|
65869
66995
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
65870
66996
|
const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
65871
|
-
const uploadMatch =
|
|
66997
|
+
const uploadMatch = path9.match(/^(.+)\/upload\/(start|complete|chunk\/(\d+))$/);
|
|
65872
66998
|
if (uploadMatch) {
|
|
65873
66999
|
const filePath = uploadMatch[1];
|
|
65874
67000
|
const action = uploadMatch[2];
|
|
@@ -65889,11 +67015,11 @@ var path_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
65889
67015
|
}
|
|
65890
67016
|
switch (req.method) {
|
|
65891
67017
|
case "GET":
|
|
65892
|
-
return handleGet2(stub,
|
|
67018
|
+
return handleGet2(stub, path9, url);
|
|
65893
67019
|
case "POST":
|
|
65894
|
-
return handlePost2(stub,
|
|
67020
|
+
return handlePost2(stub, path9, req);
|
|
65895
67021
|
case "DELETE":
|
|
65896
|
-
return handleDelete2(stub,
|
|
67022
|
+
return handleDelete2(stub, path9);
|
|
65897
67023
|
default:
|
|
65898
67024
|
return Response.json(
|
|
65899
67025
|
{ error: `Method ${req.method} not allowed` },
|
|
@@ -65908,7 +67034,7 @@ var path_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
65908
67034
|
);
|
|
65909
67035
|
}
|
|
65910
67036
|
});
|
|
65911
|
-
async function handleGet2(stub,
|
|
67037
|
+
async function handleGet2(stub, path9, url) {
|
|
65912
67038
|
if (url.searchParams.has("stats")) {
|
|
65913
67039
|
const result2 = await stub.getFileStats();
|
|
65914
67040
|
if (!result2.success) {
|
|
@@ -65917,7 +67043,7 @@ async function handleGet2(stub, path8, url) {
|
|
|
65917
67043
|
return Response.json(result2.stats);
|
|
65918
67044
|
}
|
|
65919
67045
|
if (url.searchParams.has("thumbnail")) {
|
|
65920
|
-
const result2 = await stub.getFileThumbnail(
|
|
67046
|
+
const result2 = await stub.getFileThumbnail(path9);
|
|
65921
67047
|
if (!result2.success) {
|
|
65922
67048
|
return Response.json({ error: result2.error }, { status: 404 });
|
|
65923
67049
|
}
|
|
@@ -65935,17 +67061,17 @@ async function handleGet2(stub, path8, url) {
|
|
|
65935
67061
|
}
|
|
65936
67062
|
});
|
|
65937
67063
|
}
|
|
65938
|
-
const statResult = await stub.statFile(
|
|
67064
|
+
const statResult = await stub.statFile(path9);
|
|
65939
67065
|
if (!statResult.success) {
|
|
65940
67066
|
return Response.json({ error: "Not found" }, { status: 404 });
|
|
65941
67067
|
}
|
|
65942
67068
|
const file = statResult.file;
|
|
65943
67069
|
if (file.isDirectory) {
|
|
65944
|
-
const result2 = await stub.readdirFile(
|
|
67070
|
+
const result2 = await stub.readdirFile(path9);
|
|
65945
67071
|
if (!result2.success) {
|
|
65946
67072
|
return Response.json({ error: result2.error }, { status: 500 });
|
|
65947
67073
|
}
|
|
65948
|
-
return Response.json({ files: result2.files, path:
|
|
67074
|
+
return Response.json({ files: result2.files, path: path9 });
|
|
65949
67075
|
}
|
|
65950
67076
|
if (file.storage !== "local") {
|
|
65951
67077
|
return Response.json({
|
|
@@ -65959,9 +67085,9 @@ async function handleGet2(stub, path8, url) {
|
|
|
65959
67085
|
return Response.json({ file });
|
|
65960
67086
|
}
|
|
65961
67087
|
if (file.isChunked && file.chunkCount) {
|
|
65962
|
-
return streamChunkedFile(stub,
|
|
67088
|
+
return streamChunkedFile(stub, path9, file);
|
|
65963
67089
|
}
|
|
65964
|
-
const result = await stub.readFile(
|
|
67090
|
+
const result = await stub.readFile(path9);
|
|
65965
67091
|
if (!result.success) {
|
|
65966
67092
|
return Response.json({ error: result.error }, { status: 404 });
|
|
65967
67093
|
}
|
|
@@ -65978,13 +67104,13 @@ async function handleGet2(stub, path8, url) {
|
|
|
65978
67104
|
}
|
|
65979
67105
|
});
|
|
65980
67106
|
}
|
|
65981
|
-
function streamChunkedFile(stub,
|
|
67107
|
+
function streamChunkedFile(stub, path9, file) {
|
|
65982
67108
|
const { readable, writable } = new TransformStream();
|
|
65983
67109
|
const writer = writable.getWriter();
|
|
65984
67110
|
(async () => {
|
|
65985
67111
|
try {
|
|
65986
67112
|
for (let i = 0; i < file.chunkCount; i++) {
|
|
65987
|
-
const result = await stub.readFileChunk(
|
|
67113
|
+
const result = await stub.readFileChunk(path9, i);
|
|
65988
67114
|
if (!result.success) {
|
|
65989
67115
|
console.error(`Failed to read chunk ${i}:`, result.error);
|
|
65990
67116
|
break;
|
|
@@ -66011,19 +67137,19 @@ function streamChunkedFile(stub, path8, file) {
|
|
|
66011
67137
|
}
|
|
66012
67138
|
});
|
|
66013
67139
|
}
|
|
66014
|
-
async function handlePost2(stub,
|
|
67140
|
+
async function handlePost2(stub, path9, req) {
|
|
66015
67141
|
const contentType = req.headers.get("Content-Type") || "";
|
|
66016
67142
|
if (contentType.includes("application/json")) {
|
|
66017
67143
|
const body = await req.json();
|
|
66018
67144
|
if (body.type === "directory") {
|
|
66019
|
-
const result2 = await stub.mkdirFile(
|
|
67145
|
+
const result2 = await stub.mkdirFile(path9);
|
|
66020
67146
|
if (!result2.success) {
|
|
66021
67147
|
return Response.json({ error: result2.error }, { status: 400 });
|
|
66022
67148
|
}
|
|
66023
67149
|
return Response.json({ directory: result2.directory }, { status: 201 });
|
|
66024
67150
|
}
|
|
66025
67151
|
if (body.location) {
|
|
66026
|
-
const result2 = await stub.linkFile(
|
|
67152
|
+
const result2 = await stub.linkFile(path9, body.location, {
|
|
66027
67153
|
mimeType: body.mimeType,
|
|
66028
67154
|
size: body.size,
|
|
66029
67155
|
metadata: body.metadata
|
|
@@ -66034,7 +67160,7 @@ async function handlePost2(stub, path8, req) {
|
|
|
66034
67160
|
return Response.json(toAttachmentRef(result2.file), { status: 201 });
|
|
66035
67161
|
}
|
|
66036
67162
|
if (body.data) {
|
|
66037
|
-
const result2 = await stub.writeFile(
|
|
67163
|
+
const result2 = await stub.writeFile(path9, body.data, body.mimeType || "application/octet-stream", {
|
|
66038
67164
|
metadata: body.metadata,
|
|
66039
67165
|
thumbnail: body.thumbnail
|
|
66040
67166
|
});
|
|
@@ -66048,7 +67174,7 @@ async function handlePost2(stub, path8, req) {
|
|
|
66048
67174
|
const mimeType = contentType.split(";")[0].trim() || "application/octet-stream";
|
|
66049
67175
|
const contentLength = parseInt(req.headers.get("Content-Length") || "0", 10);
|
|
66050
67176
|
if (contentLength > CHUNK_SIZE2 && req.body) {
|
|
66051
|
-
return handleStreamingUpload(stub,
|
|
67177
|
+
return handleStreamingUpload(stub, path9, mimeType, contentLength, req);
|
|
66052
67178
|
}
|
|
66053
67179
|
const data = await req.arrayBuffer();
|
|
66054
67180
|
const bytes = new Uint8Array(data);
|
|
@@ -66057,14 +67183,14 @@ async function handlePost2(stub, path8, req) {
|
|
|
66057
67183
|
binary += String.fromCharCode(bytes[i]);
|
|
66058
67184
|
}
|
|
66059
67185
|
const base64 = btoa(binary);
|
|
66060
|
-
const result = await stub.writeFile(
|
|
67186
|
+
const result = await stub.writeFile(path9, base64, mimeType, {});
|
|
66061
67187
|
if (!result.success) {
|
|
66062
67188
|
return Response.json({ error: result.error }, { status: 400 });
|
|
66063
67189
|
}
|
|
66064
67190
|
return Response.json(toAttachmentRef(result.file), { status: 201 });
|
|
66065
67191
|
}
|
|
66066
|
-
async function handleStreamingUpload(stub,
|
|
66067
|
-
const startResult = await stub.startChunkedUpload(
|
|
67192
|
+
async function handleStreamingUpload(stub, path9, mimeType, totalSize, req) {
|
|
67193
|
+
const startResult = await stub.startChunkedUpload(path9, totalSize, mimeType, {});
|
|
66068
67194
|
if (!startResult.success) {
|
|
66069
67195
|
return Response.json({ error: startResult.error }, { status: 400 });
|
|
66070
67196
|
}
|
|
@@ -66082,7 +67208,7 @@ async function handleStreamingUpload(stub, path8, mimeType, totalSize, req) {
|
|
|
66082
67208
|
while (buffer.length >= CHUNK_SIZE2) {
|
|
66083
67209
|
const chunk = buffer.slice(0, CHUNK_SIZE2);
|
|
66084
67210
|
const base64 = arrayBufferToBase64(chunk);
|
|
66085
|
-
const chunkResult = await stub.writeFileChunk(
|
|
67211
|
+
const chunkResult = await stub.writeFileChunk(path9, chunkIndex, base64);
|
|
66086
67212
|
if (!chunkResult.success) {
|
|
66087
67213
|
return Response.json({ error: chunkResult.error }, { status: 400 });
|
|
66088
67214
|
}
|
|
@@ -66093,7 +67219,7 @@ async function handleStreamingUpload(stub, path8, mimeType, totalSize, req) {
|
|
|
66093
67219
|
if (done) {
|
|
66094
67220
|
if (buffer.length > 0) {
|
|
66095
67221
|
const base64 = arrayBufferToBase64(buffer);
|
|
66096
|
-
const chunkResult = await stub.writeFileChunk(
|
|
67222
|
+
const chunkResult = await stub.writeFileChunk(path9, chunkIndex, base64);
|
|
66097
67223
|
if (!chunkResult.success) {
|
|
66098
67224
|
return Response.json({ error: chunkResult.error }, { status: 400 });
|
|
66099
67225
|
}
|
|
@@ -66102,7 +67228,7 @@ async function handleStreamingUpload(stub, path8, mimeType, totalSize, req) {
|
|
|
66102
67228
|
break;
|
|
66103
67229
|
}
|
|
66104
67230
|
}
|
|
66105
|
-
const completeResult = await stub.completeChunkedUpload(
|
|
67231
|
+
const completeResult = await stub.completeChunkedUpload(path9, chunkIndex, {});
|
|
66106
67232
|
if (!completeResult.success) {
|
|
66107
67233
|
return Response.json({ error: completeResult.error }, { status: 400 });
|
|
66108
67234
|
}
|
|
@@ -66121,19 +67247,19 @@ function arrayBufferToBase64(bytes) {
|
|
|
66121
67247
|
}
|
|
66122
67248
|
return btoa(binary);
|
|
66123
67249
|
}
|
|
66124
|
-
async function handleDelete2(stub,
|
|
66125
|
-
const statResult = await stub.statFile(
|
|
67250
|
+
async function handleDelete2(stub, path9) {
|
|
67251
|
+
const statResult = await stub.statFile(path9);
|
|
66126
67252
|
if (!statResult.success) {
|
|
66127
67253
|
return Response.json({ error: "Not found" }, { status: 404 });
|
|
66128
67254
|
}
|
|
66129
67255
|
const file = statResult.file;
|
|
66130
67256
|
if (file.isDirectory) {
|
|
66131
|
-
const result = await stub.rmdirFile(
|
|
67257
|
+
const result = await stub.rmdirFile(path9);
|
|
66132
67258
|
if (!result.success) {
|
|
66133
67259
|
return Response.json({ error: result.error }, { status: 400 });
|
|
66134
67260
|
}
|
|
66135
67261
|
} else {
|
|
66136
|
-
const result = await stub.unlinkFile(
|
|
67262
|
+
const result = await stub.unlinkFile(path9);
|
|
66137
67263
|
if (!result.success) {
|
|
66138
67264
|
return Response.json({ error: result.error }, { status: 400 });
|
|
66139
67265
|
}
|
|
@@ -66841,6 +67967,7 @@ var routeHandlers = {
|
|
|
66841
67967
|
"GET:/hooks": hooks_get_default,
|
|
66842
67968
|
"GET:/models": models_get_default,
|
|
66843
67969
|
"GET:/new-test": new_test_get_default,
|
|
67970
|
+
"GET:/platform-endpoint": platform_endpoint_default,
|
|
66844
67971
|
"GET:/prompts": prompts_get_default,
|
|
66845
67972
|
"GET:/providers": providers_get_default,
|
|
66846
67973
|
"POST:/threads": index_post_default3,
|
|
@@ -66860,14 +67987,31 @@ var routeHandlers = {
|
|
|
66860
67987
|
"POST:/unpack/:packageId": index_post_default6,
|
|
66861
67988
|
"DELETE:/users/:id": id_delete_default3,
|
|
66862
67989
|
"PUT:/users/:id": id_put_default,
|
|
67990
|
+
"POST:/auth/bootstrap": bootstrap_post_default,
|
|
66863
67991
|
"GET:/auth/config": config_get_default2,
|
|
66864
67992
|
"POST:/auth/login": login_post_default,
|
|
66865
67993
|
"POST:/auth/logout": logout_post_default,
|
|
66866
67994
|
"GET:/auth/me": me_get_default,
|
|
67995
|
+
"GET:/envs/instance": instance_get_default,
|
|
67996
|
+
"PATCH:/envs/instance": instance_patch_default,
|
|
66867
67997
|
"POST:/models/available": available_post_default,
|
|
66868
67998
|
"POST:/models/capabilities": capabilities_post_default,
|
|
66869
67999
|
"POST:/models/endpoints": endpoints_post_default,
|
|
66870
68000
|
"GET:/pack/npm-token-status": npm_token_status_get_default,
|
|
68001
|
+
"DELETE:/platform/**": path_default,
|
|
68002
|
+
"PATCH:/platform/**": path_default,
|
|
68003
|
+
"POST:/platform/**": path_default,
|
|
68004
|
+
"PUT:/platform/**": path_default,
|
|
68005
|
+
"GET:/platform/**": path_default,
|
|
68006
|
+
"POST:/platform-auth/bootstrap": bootstrap_post_default2,
|
|
68007
|
+
"POST:/platform-auth/login": login_post_default2,
|
|
68008
|
+
"POST:/platform-auth/logout": logout_post_default2,
|
|
68009
|
+
"GET:/platform-auth/me": me_get_default2,
|
|
68010
|
+
"DELETE:/platform-session/**": path_default2,
|
|
68011
|
+
"PATCH:/platform-session/**": path_default2,
|
|
68012
|
+
"POST:/platform-session/**": path_default2,
|
|
68013
|
+
"PUT:/platform-session/**": path_default2,
|
|
68014
|
+
"GET:/platform-session/**": path_default2,
|
|
66871
68015
|
"GET:/agents/:name/tenvs": tenvs_get_default,
|
|
66872
68016
|
"GET:/models/:name/curl-data": curl_data_get_default,
|
|
66873
68017
|
"GET:/pack/:agentName/analyze": analyze_get_default,
|
|
@@ -66891,12 +68035,16 @@ var routeHandlers = {
|
|
|
66891
68035
|
"POST:/threads/:id/stop": stop_post_default,
|
|
66892
68036
|
"GET:/threads/:id/stream": stream_default,
|
|
66893
68037
|
"GET:/unpack/:packageId/analyze": analyze_get_default2,
|
|
68038
|
+
"GET:/users/:id/env": env_get_default,
|
|
68039
|
+
"PATCH:/users/:id/env": env_patch_default,
|
|
66894
68040
|
"GET:/variables/agents/:name": name_get_default5,
|
|
66895
68041
|
"GET:/variables/prompts/:name": name_get_default6,
|
|
66896
68042
|
"GET:/variables/tools/:name": name_get_default7,
|
|
66897
|
-
"
|
|
66898
|
-
"
|
|
66899
|
-
"
|
|
68043
|
+
"GET:/users/me/env": env_get_default2,
|
|
68044
|
+
"PATCH:/users/me/env": env_patch_default2,
|
|
68045
|
+
"DELETE:/threads/:id/fs/**": path_default3,
|
|
68046
|
+
"POST:/threads/:id/fs/**": path_default3,
|
|
68047
|
+
"GET:/threads/:id/fs/**": path_default3,
|
|
66900
68048
|
"GET:/threads/:id/logs/:logId": logId_get_default,
|
|
66901
68049
|
"DELETE:/threads/:id/messages/:messageId": messageId_delete_default,
|
|
66902
68050
|
"PATCH:/threads/:id/messages/:messageId": messageId_patch_default,
|