@byteplus-iga-pages/agent 0.0.0-stage → 1.0.4

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.
Files changed (105) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +84 -2
  3. package/dist/cjs/261.js +77 -0
  4. package/dist/cjs/341.js +43 -0
  5. package/dist/cjs/401.js +3632 -0
  6. package/dist/cjs/419.js +854 -0
  7. package/dist/cjs/504.js +760 -0
  8. package/dist/cjs/521.js +242 -0
  9. package/dist/cjs/594.js +79 -0
  10. package/dist/cjs/647.js +1367 -0
  11. package/dist/cjs/808.js +322 -0
  12. package/dist/cjs/82.js +10089 -0
  13. package/dist/cjs/893.js +17720 -0
  14. package/dist/cjs/893.js.LICENSE.txt +13 -0
  15. package/dist/cjs/951.js +59 -0
  16. package/dist/cjs/package.json +3 -0
  17. package/dist/cjs/runtime.js +79 -0
  18. package/dist/cjs/sandbox/host.js +125 -0
  19. package/dist/cjs/sandbox/index.js +286 -0
  20. package/dist/cjs/store/claude.js +209 -0
  21. package/dist/cjs/store/host.js +92 -0
  22. package/dist/cjs/store/index.js +43 -0
  23. package/dist/cjs/store/langgraph.js +581 -0
  24. package/dist/cjs/store/openai.js +118 -0
  25. package/dist/cjs/tools/claude.js +59 -0
  26. package/dist/cjs/tools/index.js +37 -0
  27. package/dist/cjs/tools/langchain.js +52 -0
  28. package/dist/cjs/tools/openai-agents.js +43 -0
  29. package/dist/cjs/tools/openai.js +43 -0
  30. package/dist/esm/128.js +10381 -0
  31. package/dist/esm/261.js +67 -0
  32. package/dist/esm/341.js +30 -0
  33. package/dist/esm/392.js +4453 -0
  34. package/dist/esm/417.js +704 -0
  35. package/dist/esm/521.js +230 -0
  36. package/dist/esm/594.js +67 -0
  37. package/dist/esm/613.js +19042 -0
  38. package/dist/esm/613.js.LICENSE.txt +13 -0
  39. package/dist/esm/951.js +44 -0
  40. package/dist/esm/package.json +3 -0
  41. package/dist/esm/runtime.js +39 -0
  42. package/dist/esm/sandbox/host.js +1 -0
  43. package/dist/esm/sandbox/index.js +183 -0
  44. package/dist/esm/store/claude.js +172 -0
  45. package/dist/esm/store/host.js +46 -0
  46. package/dist/esm/store/index.js +2 -0
  47. package/dist/esm/store/langgraph.js +542 -0
  48. package/dist/esm/store/openai.js +81 -0
  49. package/dist/esm/tools/claude.js +22 -0
  50. package/dist/esm/tools/index.js +1 -0
  51. package/dist/esm/tools/langchain.js +16 -0
  52. package/dist/esm/tools/openai-agents.js +6 -0
  53. package/dist/esm/tools/openai.js +6 -0
  54. package/dist/types/_internal/data-plane/control-plane-request.d.ts +12 -0
  55. package/dist/types/_internal/data-plane/control-plane.d.ts +3 -0
  56. package/dist/types/_internal/data-plane/credential-provider.d.ts +25 -0
  57. package/dist/types/_internal/data-plane/errors.d.ts +19 -0
  58. package/dist/types/_internal/data-plane/index.d.ts +11 -0
  59. package/dist/types/_internal/data-plane/supabase-client.d.ts +12 -0
  60. package/dist/types/_internal/data-plane/token-client.d.ts +23 -0
  61. package/dist/types/sandbox/api-client.d.ts +37 -0
  62. package/dist/types/sandbox/api-types.d.ts +81 -0
  63. package/dist/types/sandbox/binding-repository.d.ts +62 -0
  64. package/dist/types/sandbox/error.d.ts +22 -0
  65. package/dist/types/sandbox/expiry.d.ts +11 -0
  66. package/dist/types/sandbox/host.d.ts +6 -0
  67. package/dist/types/sandbox/iga-sandbox.d.ts +208 -0
  68. package/dist/types/sandbox/index.d.ts +8 -0
  69. package/dist/types/sandbox/public-surface.d.ts +19 -0
  70. package/dist/types/sandbox/runtime-sandbox.d.ts +32 -0
  71. package/dist/types/sandbox/types.d.ts +238 -0
  72. package/dist/types/store/append.d.ts +41 -0
  73. package/dist/types/store/claude-repository.d.ts +36 -0
  74. package/dist/types/store/claude.d.ts +3 -0
  75. package/dist/types/store/control-plane-request.d.ts +2 -0
  76. package/dist/types/store/credential-error.d.ts +2 -0
  77. package/dist/types/store/credential-provider.d.ts +29 -0
  78. package/dist/types/store/errors.d.ts +29 -0
  79. package/dist/types/store/factory.d.ts +31 -0
  80. package/dist/types/store/host.d.ts +5 -0
  81. package/dist/types/store/index.d.ts +6 -0
  82. package/dist/types/store/json.d.ts +7 -0
  83. package/dist/types/store/langgraph-repository.d.ts +98 -0
  84. package/dist/types/store/langgraph.d.ts +43 -0
  85. package/dist/types/store/openai.d.ts +12 -0
  86. package/dist/types/store/pagination.d.ts +27 -0
  87. package/dist/types/store/runtime-data-plane.d.ts +8 -0
  88. package/dist/types/store/runtime-provider.d.ts +1 -0
  89. package/dist/types/store/runtime-store.d.ts +20 -0
  90. package/dist/types/store/store.d.ts +240 -0
  91. package/dist/types/store/supabase-transport.d.ts +43 -0
  92. package/dist/types/store/token-client.d.ts +7 -0
  93. package/dist/types/tools/adapters.d.ts +5 -0
  94. package/dist/types/tools/claude.d.ts +4 -0
  95. package/dist/types/tools/index.d.ts +2 -0
  96. package/dist/types/tools/langchain.d.ts +16 -0
  97. package/dist/types/tools/model-output.d.ts +8 -0
  98. package/dist/types/tools/openai-agents.d.ts +4 -0
  99. package/dist/types/tools/openai.d.ts +5 -0
  100. package/dist/types/tools/registry.d.ts +16 -0
  101. package/dist/types/tools/result.d.ts +17 -0
  102. package/dist/types/tools/sandbox-result-mappers.d.ts +10 -0
  103. package/dist/types/tools/sandbox-tools.d.ts +17 -0
  104. package/dist/types/tools/types.d.ts +307 -0
  105. package/package.json +136 -4
@@ -0,0 +1,322 @@
1
+ "use strict";
2
+ exports.ids = [
3
+ "808"
4
+ ];
5
+ exports.modules = {
6
+ "../data-plane/dist/esm/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
7
+ __webpack_require__.d(__webpack_exports__, {
8
+ Ju: ()=>createAuthenticatedSupabaseClient,
9
+ FM: ()=>fetchRuntimeDataPlaneCredentials,
10
+ uQ: ()=>getControlPlaneHeaders,
11
+ R5: ()=>fetchDataPlaneCredentials,
12
+ ZQ: ()=>DataPlaneCredentialProvider,
13
+ I7: ()=>ALLOWED_STORE_HOST_SUFFIX,
14
+ KK: ()=>STORE_TOKEN_ENDPOINT,
15
+ $Y: ()=>CONTROL_PLANE_BASE_URL,
16
+ uk: ()=>validateDataPlaneRootUrl,
17
+ d: ()=>DataPlaneError
18
+ });
19
+ const CONTROL_PLANE_BASE_URL = "https://dsa-pages-api-bd.byteintlapi.com";
20
+ const ALLOWED_STORE_HOST_SUFFIX = ".supabase.aidap-global.ap-southeast-1.bytepluses.com";
21
+ const CONTROL_PLANE_HEADERS = {};
22
+ function getControlPlaneHeaders() {
23
+ return CONTROL_PLANE_HEADERS;
24
+ }
25
+ async function postStoreToken(options) {
26
+ const fetch = options.fetch ?? globalThis.fetch;
27
+ return fetch(options.endpoint, {
28
+ method: "POST",
29
+ headers: {
30
+ "content-type": "application/json",
31
+ ...getControlPlaneHeaders()
32
+ },
33
+ body: options.body
34
+ });
35
+ }
36
+ class DataPlaneError extends Error {
37
+ constructor(code, message, options){
38
+ super(message);
39
+ this.name = "DataPlaneError";
40
+ this.code = code;
41
+ this.operation = options.operation;
42
+ this.retryable = options.retryable ?? false;
43
+ this.requestId = options.requestId;
44
+ this.status = options.status;
45
+ this.failureKind = options.failureKind;
46
+ }
47
+ }
48
+ const STORE_TOKEN_ENDPOINT = `${CONTROL_PLANE_BASE_URL}/pages/v1/api/store-token`;
49
+ const SAFE_REQUEST_ID = /^[A-Za-z0-9._:/-]{1,256}$/;
50
+ function safeRequestId(value) {
51
+ const normalized = value.trim();
52
+ return SAFE_REQUEST_ID.test(normalized) ? normalized : void 0;
53
+ }
54
+ function requestIdFrom(envelope) {
55
+ return "string" == typeof envelope?.log_id ? safeRequestId(envelope.log_id) : void 0;
56
+ }
57
+ function credentialErrorForStatus(status, requestId, authenticationFailed = false) {
58
+ if (401 === status) return new DataPlaneError("unauthenticated", "Data plane authorization failed", {
59
+ operation: "data-plane.authenticate",
60
+ requestId,
61
+ status
62
+ });
63
+ if (403 === status) return new DataPlaneError("permission_denied", "Data plane access was denied", {
64
+ operation: "data-plane.authenticate",
65
+ requestId,
66
+ status
67
+ });
68
+ if (429 === status) return new DataPlaneError("rate_limited", "Data plane authentication is rate limited", {
69
+ operation: "data-plane.authenticate",
70
+ requestId,
71
+ status,
72
+ retryable: true
73
+ });
74
+ return new DataPlaneError(status >= 500 ? "unavailable" : "internal", status >= 500 ? "Data plane authentication is temporarily unavailable" : "Data plane authentication failed", {
75
+ operation: "data-plane.authenticate",
76
+ requestId,
77
+ status,
78
+ retryable: status >= 500,
79
+ ...authenticationFailed ? {
80
+ failureKind: "authentication_failed"
81
+ } : 408 === status || 504 === status ? {
82
+ failureKind: "timeout"
83
+ } : {}
84
+ });
85
+ }
86
+ function validateDataPlaneRootUrl(value, isAllowedHostname) {
87
+ let url;
88
+ try {
89
+ url = new URL(value);
90
+ } catch {
91
+ throw invalidCredentials();
92
+ }
93
+ if ("https:" !== url.protocol || "" !== url.username || "" !== url.password || "" !== url.pathname && "/" !== url.pathname || "" !== url.search || "" !== url.hash || !isAllowedHostname(url.hostname)) throw invalidCredentials();
94
+ return url.origin;
95
+ }
96
+ function invalidCredentials(requestId, status) {
97
+ return new DataPlaneError("internal", "Data plane returned invalid credentials", {
98
+ operation: "data-plane.authenticate",
99
+ requestId,
100
+ status
101
+ });
102
+ }
103
+ async function fetchDataPlaneCredentials(options) {
104
+ if (!options.token) throw new DataPlaneError("unavailable", "Data plane credentials are unavailable", {
105
+ operation: "data-plane.authenticate"
106
+ });
107
+ const timestamp = (options.now ?? Date.now)();
108
+ let endpoint;
109
+ try {
110
+ endpoint = new URL(options.endpoint);
111
+ } catch {
112
+ throw new DataPlaneError("internal", "Data plane authentication is misconfigured", {
113
+ operation: "data-plane.authenticate"
114
+ });
115
+ }
116
+ if ("https:" !== endpoint.protocol || "" !== endpoint.username || "" !== endpoint.password || !options.isAllowedTokenEndpoint(endpoint)) throw new DataPlaneError("internal", "Data plane authentication is misconfigured", {
117
+ operation: "data-plane.authenticate"
118
+ });
119
+ endpoint.searchParams.set("timestamp", String(timestamp));
120
+ endpoint.searchParams.set("token", options.token);
121
+ let response;
122
+ try {
123
+ response = await postStoreToken({
124
+ endpoint,
125
+ body: JSON.stringify({}),
126
+ fetch: options.fetch
127
+ });
128
+ } catch (error) {
129
+ throw new DataPlaneError("unavailable", "Data plane authentication is temporarily unavailable", {
130
+ operation: "data-plane.authenticate",
131
+ retryable: true,
132
+ ...error?.name === "TimeoutError" ? {
133
+ failureKind: "timeout"
134
+ } : {}
135
+ });
136
+ }
137
+ let envelope;
138
+ try {
139
+ envelope = await response.json();
140
+ } catch {
141
+ if (!response.ok) throw credentialErrorForStatus(response.status);
142
+ throw new DataPlaneError("internal", "Data plane returned an invalid response", {
143
+ operation: "data-plane.authenticate",
144
+ status: response.status
145
+ });
146
+ }
147
+ const requestId = requestIdFrom(envelope);
148
+ if (!response.ok) throw credentialErrorForStatus(response.status, requestId, 400 === response.status && envelope?.error === "鉴权不通过");
149
+ if ("number" == typeof envelope?.code && 0 !== envelope.code) throw new DataPlaneError("internal", "Data plane returned invalid credentials", {
150
+ operation: "data-plane.authenticate",
151
+ requestId,
152
+ status: response.status,
153
+ failureKind: "authentication_failed"
154
+ });
155
+ const data = envelope?.data;
156
+ if (envelope?.code !== 0 || "string" != typeof data?.Url || "string" != typeof data.AnonKey || "" === data.AnonKey || "string" != typeof data.Jwt || "" === data.Jwt) throw invalidCredentials(requestId, response.status);
157
+ let url;
158
+ try {
159
+ url = validateDataPlaneRootUrl(data.Url, options.isAllowedHostname);
160
+ } catch {
161
+ throw invalidCredentials(void 0, response.status);
162
+ }
163
+ return {
164
+ url,
165
+ anonKey: data.AnonKey,
166
+ jwt: data.Jwt
167
+ };
168
+ }
169
+ function fetchRuntimeDataPlaneCredentials(options) {
170
+ return fetchDataPlaneCredentials({
171
+ ...options,
172
+ endpoint: STORE_TOKEN_ENDPOINT,
173
+ isAllowedTokenEndpoint: (url)=>{
174
+ const allowed = new URL(STORE_TOKEN_ENDPOINT);
175
+ return url.origin === allowed.origin && url.pathname === allowed.pathname;
176
+ },
177
+ isAllowedHostname: (hostname)=>hostname.endsWith(ALLOWED_STORE_HOST_SUFFIX)
178
+ });
179
+ }
180
+ function credential_provider_invalidCredentials() {
181
+ return new DataPlaneError("internal", "Data plane returned invalid credentials", {
182
+ operation: "data-plane.authenticate"
183
+ });
184
+ }
185
+ function readJwtClaims(jwt) {
186
+ const segments = jwt.split(".");
187
+ if (3 !== segments.length) throw credential_provider_invalidCredentials();
188
+ let claims;
189
+ try {
190
+ const normalized = segments[1].replace(/-/g, "+").replace(/_/g, "/");
191
+ const padding = "=".repeat((4 - normalized.length % 4) % 4);
192
+ claims = JSON.parse(Buffer.from(normalized + padding, "base64").toString());
193
+ } catch {
194
+ throw credential_provider_invalidCredentials();
195
+ }
196
+ if (null === claims || "object" != typeof claims || Array.isArray(claims)) throw credential_provider_invalidCredentials();
197
+ return claims;
198
+ }
199
+ function readJwtProjectId(jwt) {
200
+ const { sub } = readJwtClaims(jwt);
201
+ if ("string" != typeof sub || !sub.trim() || sub !== sub.trim()) throw credential_provider_invalidCredentials();
202
+ return sub;
203
+ }
204
+ function readJwtTiming(jwt) {
205
+ const { iat, exp } = readJwtClaims(jwt);
206
+ if ("number" != typeof iat || !Number.isFinite(iat) || "number" != typeof exp || !Number.isFinite(exp) || exp <= iat) throw credential_provider_invalidCredentials();
207
+ return {
208
+ issuedAtMs: 1000 * iat,
209
+ expiresAtMs: 1000 * exp
210
+ };
211
+ }
212
+ function waitWithSignal(promise, signal) {
213
+ if (!signal) return promise;
214
+ if (signal.aborted) return Promise.reject(new DataPlaneError("aborted", "Data plane request was cancelled", {
215
+ operation: "data-plane.authenticate"
216
+ }));
217
+ return new Promise((resolve, reject)=>{
218
+ const abort = ()=>reject(new DataPlaneError("aborted", "Data plane request was cancelled", {
219
+ operation: "data-plane.authenticate"
220
+ }));
221
+ signal.addEventListener("abort", abort, {
222
+ once: true
223
+ });
224
+ promise.then(resolve, reject).finally(()=>signal.removeEventListener("abort", abort));
225
+ });
226
+ }
227
+ class DataPlaneCredentialProvider {
228
+ async getValidCredentials(signal) {
229
+ if (signal?.aborted) throw new DataPlaneError("aborted", "Data plane request was cancelled", {
230
+ operation: "data-plane.authenticate"
231
+ });
232
+ const current = this.current;
233
+ if (current && this.now() < current.timing.expiresAtMs) return this.toPublic(current);
234
+ return this.toPublic(await waitWithSignal(this.refresh(), signal));
235
+ }
236
+ async getProjectId(signal) {
237
+ const credentials = await this.getValidCredentials(signal);
238
+ return readJwtProjectId(credentials.jwt);
239
+ }
240
+ invalidate(jwt) {
241
+ if (void 0 === jwt || this.current?.jwt === jwt) this.current = void 0;
242
+ }
243
+ refresh() {
244
+ if (this.refreshPromise) return this.refreshPromise;
245
+ this.refreshPromise = this.fetchCredentials().then((credentials)=>{
246
+ const timing = readJwtTiming(credentials.jwt);
247
+ if (timing.expiresAtMs <= this.now()) throw credential_provider_invalidCredentials();
248
+ const projectId = readJwtProjectId(credentials.jwt);
249
+ if (void 0 !== this.projectId && this.projectId !== projectId) throw credential_provider_invalidCredentials();
250
+ const next = {
251
+ ...credentials,
252
+ timing
253
+ };
254
+ this.projectId = projectId;
255
+ this.current = next;
256
+ return next;
257
+ }).catch((error)=>{
258
+ if (error instanceof DataPlaneError) throw error;
259
+ throw new DataPlaneError("unavailable", "Data plane authentication is temporarily unavailable", {
260
+ operation: "data-plane.authenticate",
261
+ retryable: true
262
+ });
263
+ }).finally(()=>{
264
+ this.refreshPromise = void 0;
265
+ });
266
+ return this.refreshPromise;
267
+ }
268
+ toPublic(credentials) {
269
+ return {
270
+ url: credentials.url,
271
+ anonKey: credentials.anonKey,
272
+ jwt: credentials.jwt
273
+ };
274
+ }
275
+ constructor(options){
276
+ this.fetchCredentials = options.fetchCredentials;
277
+ this.now = options.now ?? Date.now;
278
+ }
279
+ }
280
+ var dist = __webpack_require__("../../node_modules/.pnpm/@supabase+supabase-js@2.106.2/node_modules/@supabase/supabase-js/dist/index.mjs");
281
+ function mergeSignals(first, second) {
282
+ if (!first) return second;
283
+ if (!second || first === second) return first;
284
+ return AbortSignal.any([
285
+ first,
286
+ second
287
+ ]);
288
+ }
289
+ function createAuthenticatedSupabaseClient(options) {
290
+ const fetch = options.fetch ?? globalThis.fetch;
291
+ const scopedFetch = (input, init = {})=>{
292
+ const headers = new Headers(init.headers);
293
+ if (void 0 !== options.requestId) headers.set("x-dsa-trace-id", options.requestId);
294
+ return fetch(input, {
295
+ ...init,
296
+ headers,
297
+ signal: mergeSignals(init.signal, options.signal)
298
+ });
299
+ };
300
+ const realtimeError = options.realtimeError;
301
+ class DisabledRealtimeTransport {
302
+ constructor(){
303
+ throw realtimeError();
304
+ }
305
+ }
306
+ return (options.createClient ?? dist.U)(options.credentials.url, options.credentials.anonKey, {
307
+ accessToken: async ()=>options.credentials.jwt,
308
+ auth: {
309
+ autoRefreshToken: false,
310
+ persistSession: false,
311
+ detectSessionInUrl: false
312
+ },
313
+ realtime: {
314
+ transport: DisabledRealtimeTransport
315
+ },
316
+ global: {
317
+ fetch: scopedFetch
318
+ }
319
+ });
320
+ }
321
+ }
322
+ };