@zocomputer/agent-sdk 0.5.0
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/LICENSE +21 -0
- package/README.md +673 -0
- package/dist/attachments.js +52 -0
- package/dist/gateway-fetch.js +67 -0
- package/dist/index.js +4169 -0
- package/dist/initiator-auth.js +49 -0
- package/dist/platform/agent-sandbox/index.js +691 -0
- package/dist/platform/cloud-tools/image.js +498 -0
- package/dist/platform/cloud-tools/index.js +507 -0
- package/dist/platform/cloud-tools/web-search.js +87 -0
- package/dist/platform/runtime-ai/gateway.js +87 -0
- package/dist/platform/runtime-ai/index.js +91 -0
- package/dist/platform/runtime-ai/register.js +88 -0
- package/dist/platform/runtime-ai/session-fetch.js +54 -0
- package/dist/platform/runtime-auth/index.js +141 -0
- package/dist/state-files.js +287 -0
- package/dist/state-sandbox.js +383 -0
- package/dist/state.js +29 -0
- package/dist/steer-inbox.js +84 -0
- package/dist/steer.js +83 -0
- package/package.json +143 -0
- package/platform/agent-sandbox/api-client.ts +196 -0
- package/platform/agent-sandbox/index.ts +27 -0
- package/platform/agent-sandbox/pure.ts +83 -0
- package/platform/agent-sandbox/sftp.ts +141 -0
- package/platform/agent-sandbox/ssh-connection.ts +165 -0
- package/platform/agent-sandbox/ssh-exec.ts +98 -0
- package/platform/agent-sandbox/ssh-session.ts +487 -0
- package/platform/agent-sandbox/zo-backend.ts +88 -0
- package/platform/agent-sandbox/zo-sandbox.ts +39 -0
- package/platform/cloud-tools/image-path.ts +44 -0
- package/platform/cloud-tools/image.ts +225 -0
- package/platform/cloud-tools/index.ts +22 -0
- package/platform/cloud-tools/state-files.ts +368 -0
- package/platform/cloud-tools/tool-meta.ts +32 -0
- package/platform/cloud-tools/web-search.ts +15 -0
- package/platform/runtime-ai/gateway.ts +76 -0
- package/platform/runtime-ai/index.ts +20 -0
- package/platform/runtime-ai/register.ts +26 -0
- package/platform/runtime-ai/session-fetch.ts +124 -0
- package/platform/runtime-auth/index.ts +331 -0
- package/src/async-tasks.ts +273 -0
- package/src/attachments.ts +109 -0
- package/src/backgroundable.ts +88 -0
- package/src/bounded-output.ts +159 -0
- package/src/dir-conventions.ts +238 -0
- package/src/extract/cache.ts +40 -0
- package/src/extract/docx.ts +18 -0
- package/src/extract/pdf.ts +54 -0
- package/src/extract/sheet.ts +56 -0
- package/src/file-kind.ts +258 -0
- package/src/file-view.ts +80 -0
- package/src/gateway-fetch.ts +115 -0
- package/src/glob-match.ts +13 -0
- package/src/hooks.ts +213 -0
- package/src/index.ts +419 -0
- package/src/initiator-auth.ts +81 -0
- package/src/instructions.ts +224 -0
- package/src/list-files.ts +41 -0
- package/src/mock-model.ts +572 -0
- package/src/park-delivery.ts +247 -0
- package/src/path-locks.ts +52 -0
- package/src/read-file-content.ts +142 -0
- package/src/read-text.ts +40 -0
- package/src/redeliver.ts +155 -0
- package/src/run.ts +159 -0
- package/src/sandbox-io.ts +414 -0
- package/src/state-files.ts +460 -0
- package/src/state-sandbox.ts +710 -0
- package/src/state.ts +96 -0
- package/src/steer-inbox.ts +105 -0
- package/src/steer-tool.ts +83 -0
- package/src/steer.ts +146 -0
- package/src/task.ts +320 -0
- package/src/tools/bash.ts +143 -0
- package/src/tools/edit.ts +58 -0
- package/src/tools/glob.ts +56 -0
- package/src/tools/grep.ts +188 -0
- package/src/tools/read.ts +319 -0
- package/src/tools/tasks.ts +241 -0
- package/src/tools/webfetch.ts +368 -0
- package/src/tools/write.ts +42 -0
- package/src/walk.ts +112 -0
- package/src/watch-output.ts +104 -0
- package/src/web-fetch.ts +324 -0
- package/src/web-page.ts +179 -0
- package/src/workspace-io.ts +225 -0
- package/src/workspace.ts +41 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/image.ts
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { generateImage } from "ai";
|
|
4
|
+
import { defineTool } from "eve/tools";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/gateway.ts
|
|
8
|
+
import { createGateway } from "ai";
|
|
9
|
+
|
|
10
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/session-fetch.ts
|
|
11
|
+
var EVE_SESSION_HEADER = "x-zo-eve-session";
|
|
12
|
+
var EVE_TURN_HEADER = "x-zo-eve-turn";
|
|
13
|
+
var EVE_CONTEXT_STORAGE_KEY = Symbol.for("eve.context-storage");
|
|
14
|
+
var SESSION_ID_KEY_NAME = "eve.sessionId";
|
|
15
|
+
var SESSION_KEY_NAME = "eve.session";
|
|
16
|
+
function hasMethod(value, name) {
|
|
17
|
+
return typeof value === "object" && value !== null && typeof value[name] === "function";
|
|
18
|
+
}
|
|
19
|
+
function ambientEveSessionId() {
|
|
20
|
+
const value = ambientContextValue(SESSION_ID_KEY_NAME);
|
|
21
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
22
|
+
}
|
|
23
|
+
function ambientEveTurnId() {
|
|
24
|
+
const session = ambientContextValue(SESSION_KEY_NAME);
|
|
25
|
+
if (typeof session !== "object" || session === null)
|
|
26
|
+
return;
|
|
27
|
+
const turn = session["turn"];
|
|
28
|
+
if (typeof turn !== "object" || turn === null)
|
|
29
|
+
return;
|
|
30
|
+
const id = turn["id"];
|
|
31
|
+
return typeof id === "string" && id.trim().length > 0 ? id : undefined;
|
|
32
|
+
}
|
|
33
|
+
function ambientContextValue(keyName) {
|
|
34
|
+
const storage = Reflect.get(globalThis, EVE_CONTEXT_STORAGE_KEY);
|
|
35
|
+
if (!hasMethod(storage, "getStore"))
|
|
36
|
+
return;
|
|
37
|
+
const store = storage.getStore();
|
|
38
|
+
if (!hasMethod(store, "get"))
|
|
39
|
+
return;
|
|
40
|
+
return store.get({ name: keyName });
|
|
41
|
+
}
|
|
42
|
+
function eveSessionFetch(getSessionId = ambientEveSessionId, baseFetch = globalThis.fetch, getTurnId = ambientEveTurnId) {
|
|
43
|
+
return Object.assign((input, init) => {
|
|
44
|
+
const sessionId = getSessionId()?.trim();
|
|
45
|
+
if (!sessionId)
|
|
46
|
+
return baseFetch(input, init);
|
|
47
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
48
|
+
headers.set(EVE_SESSION_HEADER, sessionId);
|
|
49
|
+
const turnId = getTurnId()?.trim();
|
|
50
|
+
if (turnId)
|
|
51
|
+
headers.set(EVE_TURN_HEADER, turnId);
|
|
52
|
+
else
|
|
53
|
+
headers.delete(EVE_TURN_HEADER);
|
|
54
|
+
return baseFetch(input, { ...init, headers });
|
|
55
|
+
}, baseFetch);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/gateway.ts
|
|
59
|
+
var ZO_TOOL_HEADER = "x-zo-tool";
|
|
60
|
+
var DEFAULT_ZO_AI_BASE_URL = "http://localhost:4000/runtime/ai/v4/ai";
|
|
61
|
+
var DEFAULT_ZO_AI_KEY = "dev-proxy";
|
|
62
|
+
var AGENT_TOKEN_HEADER = "x-zo-agent-token";
|
|
63
|
+
var AGENT_TOKEN_ENV = "ZO_AGENT_TOKEN";
|
|
64
|
+
function agentAuthHeaders(token = process.env[AGENT_TOKEN_ENV]) {
|
|
65
|
+
const trimmed = token?.trim();
|
|
66
|
+
return trimmed ? { [AGENT_TOKEN_HEADER]: trimmed } : {};
|
|
67
|
+
}
|
|
68
|
+
function resolveZoGatewayBaseUrl(baseURL = process.env.ZO_AI_BASE_URL) {
|
|
69
|
+
const trimmed = baseURL?.trim();
|
|
70
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_ZO_AI_BASE_URL;
|
|
71
|
+
}
|
|
72
|
+
function resolveZoGatewayApiKey(apiKey = process.env.ZO_AI_KEY) {
|
|
73
|
+
const trimmed = apiKey?.trim();
|
|
74
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_ZO_AI_KEY;
|
|
75
|
+
}
|
|
76
|
+
function zoGateway(options = {}) {
|
|
77
|
+
return createGateway({
|
|
78
|
+
...options,
|
|
79
|
+
headers: { ...agentAuthHeaders(), ...options.headers },
|
|
80
|
+
apiKey: resolveZoGatewayApiKey(options.apiKey),
|
|
81
|
+
baseURL: resolveZoGatewayBaseUrl(options.baseURL),
|
|
82
|
+
fetch: eveSessionFetch(undefined, options.fetch)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/image-path.ts
|
|
86
|
+
var DEFAULT_IMAGE_OUTPUT_DIR = "generated";
|
|
87
|
+
var MEDIA_TYPE_EXTENSIONS = {
|
|
88
|
+
"image/jpeg": "jpg",
|
|
89
|
+
"image/png": "png",
|
|
90
|
+
"image/webp": "webp"
|
|
91
|
+
};
|
|
92
|
+
function extensionForMediaType(mediaType) {
|
|
93
|
+
return MEDIA_TYPE_EXTENSIONS[mediaType] ?? "bin";
|
|
94
|
+
}
|
|
95
|
+
function slugForPrompt(prompt) {
|
|
96
|
+
const slug = prompt.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
|
|
97
|
+
return slug.length > 0 ? slug : "image";
|
|
98
|
+
}
|
|
99
|
+
function normalizedOutputDir(outputDir) {
|
|
100
|
+
const trimmed = outputDir?.trim();
|
|
101
|
+
const dir = trimmed && trimmed.length > 0 ? trimmed : DEFAULT_IMAGE_OUTPUT_DIR;
|
|
102
|
+
const withoutTrailingSlash = dir.replace(/\/+$/g, "");
|
|
103
|
+
return withoutTrailingSlash.length > 0 ? withoutTrailingSlash : DEFAULT_IMAGE_OUTPUT_DIR;
|
|
104
|
+
}
|
|
105
|
+
function imageOutputPath(input) {
|
|
106
|
+
return `${normalizedOutputDir(input.outputDir)}/${slugForPrompt(input.prompt)}-${input.id}.${extensionForMediaType(input.mediaType)}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/tool-meta.ts
|
|
110
|
+
var CLOUD_TOOL_META = {
|
|
111
|
+
image: {
|
|
112
|
+
description: "Generate an image from a text prompt and save it as an external state asset."
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/state-files.ts
|
|
117
|
+
var DEFAULT_STATE_ASSET_DECLARATION_NAME = "files";
|
|
118
|
+
var STATE_FILES_HANDLE_PATH = "/state/handles";
|
|
119
|
+
var ZO_AGENT_TOKEN_HEADER = "x-zo-agent-token";
|
|
120
|
+
var ZO_EVE_SESSION_HEADER = "x-zo-eve-session";
|
|
121
|
+
var DEFAULT_STATE_FILES_SUGGESTED_DEFAULTS = Object.freeze({
|
|
122
|
+
engine: "zo-blob-r2",
|
|
123
|
+
partition: "session"
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
class StateFilesRuntimeError extends Error {
|
|
127
|
+
constructor(message) {
|
|
128
|
+
super(message);
|
|
129
|
+
this.name = "StateFilesRuntimeError";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function createRuntimeStateFilesClient(options = {}) {
|
|
133
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
134
|
+
const declarationName = options.declarationName ?? DEFAULT_STATE_ASSET_DECLARATION_NAME;
|
|
135
|
+
const getSessionId = options.getSessionId ?? ambientEveSessionId;
|
|
136
|
+
const now = options.now ?? (() => new Date);
|
|
137
|
+
return {
|
|
138
|
+
async write(path, body, writeOptions) {
|
|
139
|
+
const key = normalizeStateFilePath(path);
|
|
140
|
+
const eveSessionKey = getSessionId();
|
|
141
|
+
const handle = await requestRuntimeStateFilesHandle({
|
|
142
|
+
apiBaseUrl: resolveApiBaseUrl(options.apiBaseUrl),
|
|
143
|
+
agentToken: resolveAgentToken(options.agentToken),
|
|
144
|
+
declarationName,
|
|
145
|
+
fetch: fetchImpl,
|
|
146
|
+
suggestedDefaults: options.suggestedDefaults ?? DEFAULT_STATE_FILES_SUGGESTED_DEFAULTS,
|
|
147
|
+
...eveSessionKey === undefined ? {} : { eveSessionKey }
|
|
148
|
+
});
|
|
149
|
+
if (handle.access !== "rw") {
|
|
150
|
+
throw new StateFilesRuntimeError(`state files handle "${handle.handleId}" is read-only`);
|
|
151
|
+
}
|
|
152
|
+
await putStateFileObject({
|
|
153
|
+
body,
|
|
154
|
+
bucketName: handle.bucketName,
|
|
155
|
+
credentials: handle.credentials,
|
|
156
|
+
endpoint: handle.endpoint,
|
|
157
|
+
fetch: fetchImpl,
|
|
158
|
+
key,
|
|
159
|
+
now,
|
|
160
|
+
...writeOptions?.contentType === undefined ? {} : { contentType: writeOptions.contentType }
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function stateAssetReference(input) {
|
|
166
|
+
return Object.freeze({
|
|
167
|
+
type: "state_asset",
|
|
168
|
+
declarationName: input.declarationName,
|
|
169
|
+
path: normalizeStateFilePath(input.path),
|
|
170
|
+
...input.contentType === undefined ? {} : { contentType: input.contentType },
|
|
171
|
+
...input.bytes === undefined ? {} : { bytes: input.bytes }
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function normalizeStateFilePath(path) {
|
|
175
|
+
if (path.length === 0)
|
|
176
|
+
throw new Error("state file path must not be empty");
|
|
177
|
+
if (path.startsWith("/"))
|
|
178
|
+
throw new Error(`state file path "${path}" must be relative`);
|
|
179
|
+
const segments = path.split("/");
|
|
180
|
+
if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
181
|
+
throw new Error(`state file path "${path}" must not contain empty, . or .. segments`);
|
|
182
|
+
}
|
|
183
|
+
return path;
|
|
184
|
+
}
|
|
185
|
+
async function requestRuntimeStateFilesHandle(options) {
|
|
186
|
+
const headers = new Headers({ "content-type": "application/json" });
|
|
187
|
+
headers.set(ZO_AGENT_TOKEN_HEADER, options.agentToken);
|
|
188
|
+
if (options.eveSessionKey !== undefined && options.eveSessionKey.trim().length > 0) {
|
|
189
|
+
headers.set(ZO_EVE_SESSION_HEADER, options.eveSessionKey.trim());
|
|
190
|
+
}
|
|
191
|
+
const response = await options.fetch(buildStateFilesHandleUrl(options.apiBaseUrl), {
|
|
192
|
+
method: "POST",
|
|
193
|
+
headers,
|
|
194
|
+
body: JSON.stringify({
|
|
195
|
+
declarationName: options.declarationName,
|
|
196
|
+
interface: "files",
|
|
197
|
+
access: "rw",
|
|
198
|
+
suggestedDefaults: options.suggestedDefaults
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
const json = await response.json().catch(() => null);
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
throw new StateFilesRuntimeError(readBrokerErrorMessage(json));
|
|
204
|
+
}
|
|
205
|
+
const handle = parseStateFilesHandle(json);
|
|
206
|
+
if (handle === null) {
|
|
207
|
+
throw new StateFilesRuntimeError("state files broker returned a malformed handle");
|
|
208
|
+
}
|
|
209
|
+
return handle;
|
|
210
|
+
}
|
|
211
|
+
function resolveApiBaseUrl(apiBaseUrl) {
|
|
212
|
+
const value = String(apiBaseUrl ?? process.env.ZO_API_URL ?? "").trim();
|
|
213
|
+
if (value.length === 0) {
|
|
214
|
+
throw new StateFilesRuntimeError("ZO_API_URL is required to write generated state assets");
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
function resolveAgentToken(agentToken) {
|
|
219
|
+
const value = (agentToken ?? process.env.ZO_AGENT_TOKEN ?? "").trim();
|
|
220
|
+
if (value.length === 0) {
|
|
221
|
+
throw new StateFilesRuntimeError("ZO_AGENT_TOKEN is required to write generated state assets");
|
|
222
|
+
}
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
function buildStateFilesHandleUrl(apiBaseUrl) {
|
|
226
|
+
const url = new URL(apiBaseUrl);
|
|
227
|
+
url.pathname = `${url.pathname.replace(/\/+$/u, "")}/${STATE_FILES_HANDLE_PATH.replace(/^\/+/, "")}`;
|
|
228
|
+
url.search = "";
|
|
229
|
+
url.hash = "";
|
|
230
|
+
return url.toString();
|
|
231
|
+
}
|
|
232
|
+
function parseStateFilesHandle(value) {
|
|
233
|
+
if (!isRecord(value))
|
|
234
|
+
return null;
|
|
235
|
+
if (value.interface !== "files" || value.engine !== "zo-blob-r2")
|
|
236
|
+
return null;
|
|
237
|
+
const access = value.access === "r" || value.access === "rw" ? value.access : null;
|
|
238
|
+
const handleId = readString(value, "handleId");
|
|
239
|
+
const declarationName = readString(value, "declarationName");
|
|
240
|
+
const bucketName = readString(value, "bucketName");
|
|
241
|
+
const endpoint = readString(value, "endpoint");
|
|
242
|
+
const credentials = parseStateFilesCredentials(value.credentials);
|
|
243
|
+
if (access === null || handleId === null || declarationName === null || bucketName === null || endpoint === null || credentials === null) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
return { handleId, declarationName, interface: "files", access, engine: "zo-blob-r2", bucketName, endpoint, credentials };
|
|
247
|
+
}
|
|
248
|
+
function parseStateFilesCredentials(value) {
|
|
249
|
+
if (!isRecord(value))
|
|
250
|
+
return null;
|
|
251
|
+
const accessKeyId = readString(value, "accessKeyId");
|
|
252
|
+
const secretAccessKey = readString(value, "secretAccessKey");
|
|
253
|
+
const sessionToken = readString(value, "sessionToken");
|
|
254
|
+
const expiresAt = readString(value, "expiresAt");
|
|
255
|
+
if (accessKeyId === null || secretAccessKey === null || sessionToken === null || expiresAt === null || !Number.isFinite(Date.parse(expiresAt))) {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
return { accessKeyId, secretAccessKey, sessionToken, expiresAt };
|
|
259
|
+
}
|
|
260
|
+
function readBrokerErrorMessage(value) {
|
|
261
|
+
if (!isRecord(value))
|
|
262
|
+
return "state files broker request failed";
|
|
263
|
+
const error = isRecord(value.error) ? value.error : value;
|
|
264
|
+
return readString(error, "message") ?? "state files broker request failed";
|
|
265
|
+
}
|
|
266
|
+
async function putStateFileObject(options) {
|
|
267
|
+
const url = stateFileObjectUrl(options.endpoint, options.bucketName, options.key);
|
|
268
|
+
const payloadHash = await sha256Hex(options.body);
|
|
269
|
+
const headers = await signedS3Headers({
|
|
270
|
+
credentials: options.credentials,
|
|
271
|
+
date: options.now(),
|
|
272
|
+
host: url.host,
|
|
273
|
+
method: "PUT",
|
|
274
|
+
path: url.pathname,
|
|
275
|
+
payloadHash,
|
|
276
|
+
...options.contentType === undefined ? {} : { contentType: options.contentType }
|
|
277
|
+
});
|
|
278
|
+
const response = await options.fetch(url, {
|
|
279
|
+
method: "PUT",
|
|
280
|
+
headers,
|
|
281
|
+
body: options.body
|
|
282
|
+
});
|
|
283
|
+
if (!response.ok) {
|
|
284
|
+
throw new StateFilesRuntimeError(`state asset write failed with ${response.status}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function stateFileObjectUrl(endpoint, bucketName, key) {
|
|
288
|
+
const base = endpoint.replace(/\/+$/u, "");
|
|
289
|
+
return new URL(`${base}/${encodeS3PathSegment(bucketName)}/${encodeS3Key(key)}`);
|
|
290
|
+
}
|
|
291
|
+
async function signedS3Headers(input) {
|
|
292
|
+
const amzDate = awsAmzDate(input.date);
|
|
293
|
+
const dateStamp = amzDate.slice(0, 8);
|
|
294
|
+
const headerEntries = [
|
|
295
|
+
["host", input.host],
|
|
296
|
+
["x-amz-content-sha256", input.payloadHash],
|
|
297
|
+
["x-amz-date", amzDate],
|
|
298
|
+
["x-amz-security-token", input.credentials.sessionToken]
|
|
299
|
+
];
|
|
300
|
+
if (input.contentType !== undefined) {
|
|
301
|
+
headerEntries.push(["content-type", input.contentType]);
|
|
302
|
+
}
|
|
303
|
+
headerEntries.sort(([left], [right]) => left.localeCompare(right));
|
|
304
|
+
const canonicalHeaders = headerEntries.map(([name, value]) => `${name}:${value.trim()}
|
|
305
|
+
`).join("");
|
|
306
|
+
const signedHeaders = headerEntries.map(([name]) => name).join(";");
|
|
307
|
+
const canonicalRequest = [
|
|
308
|
+
input.method,
|
|
309
|
+
input.path,
|
|
310
|
+
"",
|
|
311
|
+
canonicalHeaders,
|
|
312
|
+
signedHeaders,
|
|
313
|
+
input.payloadHash
|
|
314
|
+
].join(`
|
|
315
|
+
`);
|
|
316
|
+
const scope = `${dateStamp}/auto/s3/aws4_request`;
|
|
317
|
+
const stringToSign = [
|
|
318
|
+
"AWS4-HMAC-SHA256",
|
|
319
|
+
amzDate,
|
|
320
|
+
scope,
|
|
321
|
+
await sha256Hex(new TextEncoder().encode(canonicalRequest))
|
|
322
|
+
].join(`
|
|
323
|
+
`);
|
|
324
|
+
const signingKey = await awsSigningKey(input.credentials.secretAccessKey, dateStamp);
|
|
325
|
+
const signature = await hmacHex(signingKey, stringToSign);
|
|
326
|
+
const headers = new Headers;
|
|
327
|
+
for (const [name, value] of headerEntries)
|
|
328
|
+
headers.set(name, value);
|
|
329
|
+
headers.set("authorization", `AWS4-HMAC-SHA256 Credential=${input.credentials.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`);
|
|
330
|
+
return headers;
|
|
331
|
+
}
|
|
332
|
+
async function awsSigningKey(secretAccessKey, dateStamp) {
|
|
333
|
+
const dateKey = await hmacBytes(new TextEncoder().encode(`AWS4${secretAccessKey}`), dateStamp);
|
|
334
|
+
const regionKey = await hmacBytes(dateKey, "auto");
|
|
335
|
+
const serviceKey = await hmacBytes(regionKey, "s3");
|
|
336
|
+
return hmacBytes(serviceKey, "aws4_request");
|
|
337
|
+
}
|
|
338
|
+
async function hmacBytes(key, data) {
|
|
339
|
+
const cryptoKey = await crypto.subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
340
|
+
return new Uint8Array(await crypto.subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(data)));
|
|
341
|
+
}
|
|
342
|
+
async function hmacHex(key, data) {
|
|
343
|
+
return bytesToHex(await hmacBytes(key, data));
|
|
344
|
+
}
|
|
345
|
+
async function sha256Hex(bytes) {
|
|
346
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
347
|
+
return bytesToHex(new Uint8Array(digest));
|
|
348
|
+
}
|
|
349
|
+
function bytesToHex(bytes) {
|
|
350
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
351
|
+
}
|
|
352
|
+
function awsAmzDate(date) {
|
|
353
|
+
return date.toISOString().replace(/[:-]|\.\d{3}/gu, "");
|
|
354
|
+
}
|
|
355
|
+
function encodeS3Key(key) {
|
|
356
|
+
return key.split("/").map(encodeS3PathSegment).join("/");
|
|
357
|
+
}
|
|
358
|
+
function encodeS3PathSegment(segment) {
|
|
359
|
+
return encodeURIComponent(segment).replace(/[!'()*]/gu, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
360
|
+
}
|
|
361
|
+
function isRecord(value) {
|
|
362
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
363
|
+
}
|
|
364
|
+
function readString(record, key) {
|
|
365
|
+
const value = record[key];
|
|
366
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/image.ts
|
|
370
|
+
var DEFAULT_IMAGE_MODEL = "bfl/flux-2-pro";
|
|
371
|
+
function isImageSize(value) {
|
|
372
|
+
return typeof value === "string" && /^[1-9]\d{1,4}x[1-9]\d{1,4}$/u.test(value);
|
|
373
|
+
}
|
|
374
|
+
function isImageAspectRatio(value) {
|
|
375
|
+
return typeof value === "string" && /^[1-9]\d{0,2}:[1-9]\d{0,2}$/u.test(value);
|
|
376
|
+
}
|
|
377
|
+
var SizeSchema = z.templateLiteral([z.number().int().positive(), "x", z.number().int().positive()]).refine(isImageSize, { message: "Use WIDTHxHEIGHT, for example 1024x1024." });
|
|
378
|
+
var AspectRatioSchema = z.templateLiteral([z.number().int().positive(), ":", z.number().int().positive()]).refine(isImageAspectRatio, { message: "Use WIDTH:HEIGHT, for example 1:1 or 16:9." });
|
|
379
|
+
var ImageDimensionsSchema = z.discriminatedUnion("kind", [
|
|
380
|
+
z.object({ kind: z.literal("auto") }).strict(),
|
|
381
|
+
z.object({ kind: z.literal("size"), size: SizeSchema }).strict(),
|
|
382
|
+
z.object({
|
|
383
|
+
aspectRatio: AspectRatioSchema,
|
|
384
|
+
kind: z.literal("aspectRatio")
|
|
385
|
+
}).strict()
|
|
386
|
+
]);
|
|
387
|
+
var OutputDirSchema = z.string().trim().min(1).max(200).regex(/^(?!\/)(?!.*\/$)(?!.*\/\/)(?!.*(?:^|\/)(?:\.|\.\.)(?:\/|$))[A-Za-z0-9._/-]+$/u, "Use a relative state file path without empty, . or .. segments.");
|
|
388
|
+
var GenerateImageInputSchema = z.object({
|
|
389
|
+
dimensions: ImageDimensionsSchema.optional(),
|
|
390
|
+
model: z.string().trim().min(1).optional(),
|
|
391
|
+
outputDir: OutputDirSchema.optional(),
|
|
392
|
+
prompt: z.string().trim().min(1).max(4000),
|
|
393
|
+
seed: z.number().int().nonnegative().optional()
|
|
394
|
+
}).strict();
|
|
395
|
+
var StateAssetReferenceSchema = z.object({
|
|
396
|
+
bytes: z.number().int().nonnegative().optional(),
|
|
397
|
+
contentType: z.string().optional(),
|
|
398
|
+
declarationName: z.string(),
|
|
399
|
+
path: z.string(),
|
|
400
|
+
type: z.literal("state_asset")
|
|
401
|
+
}).strict();
|
|
402
|
+
var GenerateImageOutputSchema = z.object({
|
|
403
|
+
asset: StateAssetReferenceSchema,
|
|
404
|
+
bytes: z.number().int().nonnegative(),
|
|
405
|
+
mediaType: z.string(),
|
|
406
|
+
model: z.string(),
|
|
407
|
+
path: z.string(),
|
|
408
|
+
prompt: z.string(),
|
|
409
|
+
warnings: z.array(z.string())
|
|
410
|
+
}).strict();
|
|
411
|
+
function assertNever(value) {
|
|
412
|
+
throw new Error(`Unhandled generate_image dimensions: ${JSON.stringify(value)}`);
|
|
413
|
+
}
|
|
414
|
+
function imageDimensionSettings(dimensions) {
|
|
415
|
+
if (dimensions === undefined || dimensions.kind === "auto") {
|
|
416
|
+
return {};
|
|
417
|
+
}
|
|
418
|
+
switch (dimensions.kind) {
|
|
419
|
+
case "aspectRatio":
|
|
420
|
+
return { aspectRatio: dimensions.aspectRatio };
|
|
421
|
+
case "size":
|
|
422
|
+
return { size: dimensions.size };
|
|
423
|
+
default:
|
|
424
|
+
return assertNever(dimensions);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function warningText(warning) {
|
|
428
|
+
if (warning instanceof Error) {
|
|
429
|
+
return warning.message;
|
|
430
|
+
}
|
|
431
|
+
if (typeof warning === "string") {
|
|
432
|
+
return warning;
|
|
433
|
+
}
|
|
434
|
+
const json = JSON.stringify(warning);
|
|
435
|
+
return json ?? String(warning);
|
|
436
|
+
}
|
|
437
|
+
function randomImageId() {
|
|
438
|
+
return randomUUID().slice(0, 8);
|
|
439
|
+
}
|
|
440
|
+
function generateImageTool(options = {}) {
|
|
441
|
+
const declarationName = options.declarationName ?? DEFAULT_STATE_ASSET_DECLARATION_NAME;
|
|
442
|
+
const assetWriter = options.assetWriter ?? createRuntimeStateFilesClient({ declarationName });
|
|
443
|
+
const generate = options.generate ?? generateImage;
|
|
444
|
+
const randomId = options.randomId ?? randomImageId;
|
|
445
|
+
return defineTool({
|
|
446
|
+
description: CLOUD_TOOL_META.image.description,
|
|
447
|
+
inputSchema: GenerateImageInputSchema,
|
|
448
|
+
outputSchema: GenerateImageOutputSchema,
|
|
449
|
+
async execute(input) {
|
|
450
|
+
const model = input.model ?? DEFAULT_IMAGE_MODEL;
|
|
451
|
+
const result = await generate({
|
|
452
|
+
headers: { [ZO_TOOL_HEADER]: "generate_image" },
|
|
453
|
+
model: zoGateway().imageModel(model),
|
|
454
|
+
prompt: input.prompt,
|
|
455
|
+
...imageDimensionSettings(input.dimensions),
|
|
456
|
+
...input.seed === undefined ? {} : { seed: input.seed }
|
|
457
|
+
});
|
|
458
|
+
const image = result.image;
|
|
459
|
+
const path = imageOutputPath({
|
|
460
|
+
id: randomId(),
|
|
461
|
+
mediaType: image.mediaType,
|
|
462
|
+
outputDir: input.outputDir,
|
|
463
|
+
prompt: input.prompt
|
|
464
|
+
});
|
|
465
|
+
await assetWriter.write(path, image.uint8Array, { contentType: image.mediaType });
|
|
466
|
+
const asset = stateAssetReference({
|
|
467
|
+
type: "state_asset",
|
|
468
|
+
declarationName,
|
|
469
|
+
path,
|
|
470
|
+
contentType: image.mediaType,
|
|
471
|
+
bytes: image.uint8Array.byteLength
|
|
472
|
+
});
|
|
473
|
+
return {
|
|
474
|
+
asset,
|
|
475
|
+
bytes: image.uint8Array.byteLength,
|
|
476
|
+
mediaType: image.mediaType,
|
|
477
|
+
model,
|
|
478
|
+
path,
|
|
479
|
+
prompt: input.prompt,
|
|
480
|
+
warnings: result.warnings.map(warningText)
|
|
481
|
+
};
|
|
482
|
+
},
|
|
483
|
+
toModelOutput(output) {
|
|
484
|
+
return {
|
|
485
|
+
type: "text",
|
|
486
|
+
value: `Generated image saved as state asset ${output.asset.declarationName}:${output.asset.path}. ` + `The asset is available to the chat UI through the state_asset reference; ` + `do not invent or expose a temporary URL.`
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
var image_default = generateImageTool();
|
|
492
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/web-search.ts
|
|
493
|
+
function webSearch(config) {
|
|
494
|
+
const gateway = zoGateway();
|
|
495
|
+
return config === undefined ? gateway.tools.exaSearch() : gateway.tools.exaSearch(config);
|
|
496
|
+
}
|
|
497
|
+
export {
|
|
498
|
+
webSearch,
|
|
499
|
+
stateAssetReference,
|
|
500
|
+
generateImageTool,
|
|
501
|
+
image_default as generateImage,
|
|
502
|
+
createRuntimeStateFilesClient,
|
|
503
|
+
GenerateImageOutputSchema,
|
|
504
|
+
GenerateImageInputSchema,
|
|
505
|
+
DEFAULT_STATE_ASSET_DECLARATION_NAME,
|
|
506
|
+
DEFAULT_IMAGE_MODEL
|
|
507
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/gateway.ts
|
|
2
|
+
import { createGateway } from "ai";
|
|
3
|
+
|
|
4
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/session-fetch.ts
|
|
5
|
+
var EVE_SESSION_HEADER = "x-zo-eve-session";
|
|
6
|
+
var EVE_TURN_HEADER = "x-zo-eve-turn";
|
|
7
|
+
var EVE_CONTEXT_STORAGE_KEY = Symbol.for("eve.context-storage");
|
|
8
|
+
var SESSION_ID_KEY_NAME = "eve.sessionId";
|
|
9
|
+
var SESSION_KEY_NAME = "eve.session";
|
|
10
|
+
function hasMethod(value, name) {
|
|
11
|
+
return typeof value === "object" && value !== null && typeof value[name] === "function";
|
|
12
|
+
}
|
|
13
|
+
function ambientEveSessionId() {
|
|
14
|
+
const value = ambientContextValue(SESSION_ID_KEY_NAME);
|
|
15
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
16
|
+
}
|
|
17
|
+
function ambientEveTurnId() {
|
|
18
|
+
const session = ambientContextValue(SESSION_KEY_NAME);
|
|
19
|
+
if (typeof session !== "object" || session === null)
|
|
20
|
+
return;
|
|
21
|
+
const turn = session["turn"];
|
|
22
|
+
if (typeof turn !== "object" || turn === null)
|
|
23
|
+
return;
|
|
24
|
+
const id = turn["id"];
|
|
25
|
+
return typeof id === "string" && id.trim().length > 0 ? id : undefined;
|
|
26
|
+
}
|
|
27
|
+
function ambientContextValue(keyName) {
|
|
28
|
+
const storage = Reflect.get(globalThis, EVE_CONTEXT_STORAGE_KEY);
|
|
29
|
+
if (!hasMethod(storage, "getStore"))
|
|
30
|
+
return;
|
|
31
|
+
const store = storage.getStore();
|
|
32
|
+
if (!hasMethod(store, "get"))
|
|
33
|
+
return;
|
|
34
|
+
return store.get({ name: keyName });
|
|
35
|
+
}
|
|
36
|
+
function eveSessionFetch(getSessionId = ambientEveSessionId, baseFetch = globalThis.fetch, getTurnId = ambientEveTurnId) {
|
|
37
|
+
return Object.assign((input, init) => {
|
|
38
|
+
const sessionId = getSessionId()?.trim();
|
|
39
|
+
if (!sessionId)
|
|
40
|
+
return baseFetch(input, init);
|
|
41
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
42
|
+
headers.set(EVE_SESSION_HEADER, sessionId);
|
|
43
|
+
const turnId = getTurnId()?.trim();
|
|
44
|
+
if (turnId)
|
|
45
|
+
headers.set(EVE_TURN_HEADER, turnId);
|
|
46
|
+
else
|
|
47
|
+
headers.delete(EVE_TURN_HEADER);
|
|
48
|
+
return baseFetch(input, { ...init, headers });
|
|
49
|
+
}, baseFetch);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/gateway.ts
|
|
53
|
+
var DEFAULT_ZO_AI_BASE_URL = "http://localhost:4000/runtime/ai/v4/ai";
|
|
54
|
+
var DEFAULT_ZO_AI_KEY = "dev-proxy";
|
|
55
|
+
var AGENT_TOKEN_HEADER = "x-zo-agent-token";
|
|
56
|
+
var AGENT_TOKEN_ENV = "ZO_AGENT_TOKEN";
|
|
57
|
+
function agentAuthHeaders(token = process.env[AGENT_TOKEN_ENV]) {
|
|
58
|
+
const trimmed = token?.trim();
|
|
59
|
+
return trimmed ? { [AGENT_TOKEN_HEADER]: trimmed } : {};
|
|
60
|
+
}
|
|
61
|
+
function resolveZoGatewayBaseUrl(baseURL = process.env.ZO_AI_BASE_URL) {
|
|
62
|
+
const trimmed = baseURL?.trim();
|
|
63
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_ZO_AI_BASE_URL;
|
|
64
|
+
}
|
|
65
|
+
function resolveZoGatewayApiKey(apiKey = process.env.ZO_AI_KEY) {
|
|
66
|
+
const trimmed = apiKey?.trim();
|
|
67
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_ZO_AI_KEY;
|
|
68
|
+
}
|
|
69
|
+
function zoGateway(options = {}) {
|
|
70
|
+
return createGateway({
|
|
71
|
+
...options,
|
|
72
|
+
headers: { ...agentAuthHeaders(), ...options.headers },
|
|
73
|
+
apiKey: resolveZoGatewayApiKey(options.apiKey),
|
|
74
|
+
baseURL: resolveZoGatewayBaseUrl(options.baseURL),
|
|
75
|
+
fetch: eveSessionFetch(undefined, options.fetch)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/cloud-tools/web-search.ts
|
|
79
|
+
function webSearch(config) {
|
|
80
|
+
const gateway = zoGateway();
|
|
81
|
+
return config === undefined ? gateway.tools.exaSearch() : gateway.tools.exaSearch(config);
|
|
82
|
+
}
|
|
83
|
+
var web_search_default = webSearch;
|
|
84
|
+
export {
|
|
85
|
+
webSearch,
|
|
86
|
+
web_search_default as default
|
|
87
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/gateway.ts
|
|
2
|
+
import { createGateway } from "ai";
|
|
3
|
+
|
|
4
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/session-fetch.ts
|
|
5
|
+
var EVE_SESSION_HEADER = "x-zo-eve-session";
|
|
6
|
+
var EVE_TURN_HEADER = "x-zo-eve-turn";
|
|
7
|
+
var EVE_CONTEXT_STORAGE_KEY = Symbol.for("eve.context-storage");
|
|
8
|
+
var SESSION_ID_KEY_NAME = "eve.sessionId";
|
|
9
|
+
var SESSION_KEY_NAME = "eve.session";
|
|
10
|
+
function hasMethod(value, name) {
|
|
11
|
+
return typeof value === "object" && value !== null && typeof value[name] === "function";
|
|
12
|
+
}
|
|
13
|
+
function ambientEveSessionId() {
|
|
14
|
+
const value = ambientContextValue(SESSION_ID_KEY_NAME);
|
|
15
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
16
|
+
}
|
|
17
|
+
function ambientEveTurnId() {
|
|
18
|
+
const session = ambientContextValue(SESSION_KEY_NAME);
|
|
19
|
+
if (typeof session !== "object" || session === null)
|
|
20
|
+
return;
|
|
21
|
+
const turn = session["turn"];
|
|
22
|
+
if (typeof turn !== "object" || turn === null)
|
|
23
|
+
return;
|
|
24
|
+
const id = turn["id"];
|
|
25
|
+
return typeof id === "string" && id.trim().length > 0 ? id : undefined;
|
|
26
|
+
}
|
|
27
|
+
function ambientContextValue(keyName) {
|
|
28
|
+
const storage = Reflect.get(globalThis, EVE_CONTEXT_STORAGE_KEY);
|
|
29
|
+
if (!hasMethod(storage, "getStore"))
|
|
30
|
+
return;
|
|
31
|
+
const store = storage.getStore();
|
|
32
|
+
if (!hasMethod(store, "get"))
|
|
33
|
+
return;
|
|
34
|
+
return store.get({ name: keyName });
|
|
35
|
+
}
|
|
36
|
+
function eveSessionFetch(getSessionId = ambientEveSessionId, baseFetch = globalThis.fetch, getTurnId = ambientEveTurnId) {
|
|
37
|
+
return Object.assign((input, init) => {
|
|
38
|
+
const sessionId = getSessionId()?.trim();
|
|
39
|
+
if (!sessionId)
|
|
40
|
+
return baseFetch(input, init);
|
|
41
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
42
|
+
headers.set(EVE_SESSION_HEADER, sessionId);
|
|
43
|
+
const turnId = getTurnId()?.trim();
|
|
44
|
+
if (turnId)
|
|
45
|
+
headers.set(EVE_TURN_HEADER, turnId);
|
|
46
|
+
else
|
|
47
|
+
headers.delete(EVE_TURN_HEADER);
|
|
48
|
+
return baseFetch(input, { ...init, headers });
|
|
49
|
+
}, baseFetch);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ../../var/folders/vh/qdfcqc514qj47bbvzslcwjsc0000gn/T/agent-sdk-publish-eDWqsZ/platform/runtime-ai/gateway.ts
|
|
53
|
+
var ZO_TOOL_HEADER = "x-zo-tool";
|
|
54
|
+
var DEFAULT_ZO_AI_BASE_URL = "http://localhost:4000/runtime/ai/v4/ai";
|
|
55
|
+
var DEFAULT_ZO_AI_KEY = "dev-proxy";
|
|
56
|
+
var AGENT_TOKEN_HEADER = "x-zo-agent-token";
|
|
57
|
+
var AGENT_TOKEN_ENV = "ZO_AGENT_TOKEN";
|
|
58
|
+
function agentAuthHeaders(token = process.env[AGENT_TOKEN_ENV]) {
|
|
59
|
+
const trimmed = token?.trim();
|
|
60
|
+
return trimmed ? { [AGENT_TOKEN_HEADER]: trimmed } : {};
|
|
61
|
+
}
|
|
62
|
+
function resolveZoGatewayBaseUrl(baseURL = process.env.ZO_AI_BASE_URL) {
|
|
63
|
+
const trimmed = baseURL?.trim();
|
|
64
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_ZO_AI_BASE_URL;
|
|
65
|
+
}
|
|
66
|
+
function resolveZoGatewayApiKey(apiKey = process.env.ZO_AI_KEY) {
|
|
67
|
+
const trimmed = apiKey?.trim();
|
|
68
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_ZO_AI_KEY;
|
|
69
|
+
}
|
|
70
|
+
function zoGateway(options = {}) {
|
|
71
|
+
return createGateway({
|
|
72
|
+
...options,
|
|
73
|
+
headers: { ...agentAuthHeaders(), ...options.headers },
|
|
74
|
+
apiKey: resolveZoGatewayApiKey(options.apiKey),
|
|
75
|
+
baseURL: resolveZoGatewayBaseUrl(options.baseURL),
|
|
76
|
+
fetch: eveSessionFetch(undefined, options.fetch)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
zoGateway,
|
|
81
|
+
resolveZoGatewayBaseUrl,
|
|
82
|
+
resolveZoGatewayApiKey,
|
|
83
|
+
agentAuthHeaders,
|
|
84
|
+
ZO_TOOL_HEADER,
|
|
85
|
+
DEFAULT_ZO_AI_KEY,
|
|
86
|
+
DEFAULT_ZO_AI_BASE_URL
|
|
87
|
+
};
|