@mettlelabs/mettle 0.0.0-beta.2-linux-arm64 → 0.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/bin/mettle.js +53 -0
  2. package/bin/postinstall.js +28 -0
  3. package/package.json +19 -13
  4. package/THIRD_PARTY_NOTICES.md +0 -11974
  5. package/bin/mettle +0 -4
  6. package/harness/audit-investigation.mjs +0 -203
  7. package/harness/chunk-1sygmp11.mjs +0 -18142
  8. package/harness/chunk-1ykxpmaz.mjs +0 -7887
  9. package/harness/chunk-2pm2sayw.mjs +0 -248
  10. package/harness/chunk-3m7jn5ac.mjs +0 -16242
  11. package/harness/chunk-3wt8a8fq.mjs +0 -1716
  12. package/harness/chunk-3wvjs93w.mjs +0 -538
  13. package/harness/chunk-49ytr8d5.mjs +0 -33761
  14. package/harness/chunk-4bepyxmq.mjs +0 -113
  15. package/harness/chunk-4vx34w5h.mjs +0 -2357
  16. package/harness/chunk-50sbrf09.mjs +0 -18972
  17. package/harness/chunk-56csr8sw.mjs +0 -322
  18. package/harness/chunk-5wgmv4np.mjs +0 -585
  19. package/harness/chunk-65eyq32y.mjs +0 -225
  20. package/harness/chunk-6fnh6qhk.mjs +0 -195
  21. package/harness/chunk-6kgqw9ny.mjs +0 -32303
  22. package/harness/chunk-7b242j0n.mjs +0 -14
  23. package/harness/chunk-9dg1btk1.mjs +0 -2818
  24. package/harness/chunk-ageqxj9v.mjs +0 -63008
  25. package/harness/chunk-b0qbt5jd.mjs +0 -14
  26. package/harness/chunk-b5g1r3fz.mjs +0 -4785
  27. package/harness/chunk-b71gpkxg.mjs +0 -1514
  28. package/harness/chunk-bdv1rx4a.mjs +0 -20364
  29. package/harness/chunk-c1631s2x.mjs +0 -12241
  30. package/harness/chunk-c7dx5mdd.mjs +0 -10807
  31. package/harness/chunk-d5xgxsnp.mjs +0 -74
  32. package/harness/chunk-erg1fbh0.mjs +0 -0
  33. package/harness/chunk-fh78v9vn.mjs +0 -19366
  34. package/harness/chunk-fjx29qvp.mjs +0 -50
  35. package/harness/chunk-gryka6kg.mjs +0 -39
  36. package/harness/chunk-h1td5kq9.mjs +0 -422
  37. package/harness/chunk-jb0r19et.mjs +0 -180
  38. package/harness/chunk-jp69h6sj.mjs +0 -95
  39. package/harness/chunk-mfn574ss.mjs +0 -179
  40. package/harness/chunk-nz5sv9as.mjs +0 -1642
  41. package/harness/chunk-p9d3cgvq.mjs +0 -452
  42. package/harness/chunk-pq6wvwxr.mjs +0 -12
  43. package/harness/chunk-qcm9arf8.mjs +0 -7736
  44. package/harness/chunk-qr8zfqjd.mjs +0 -24
  45. package/harness/chunk-rd80vvc5.mjs +0 -22047
  46. package/harness/chunk-rz2tz6jp.mjs +0 -26
  47. package/harness/chunk-sbkgc3kn.mjs +0 -8
  48. package/harness/chunk-v66qvpnb.mjs +0 -169
  49. package/harness/chunk-vjaxzab3.mjs +0 -136
  50. package/harness/chunk-vr1n5nza.mjs +0 -1045
  51. package/harness/chunk-vsf2zajv.mjs +0 -3867
  52. package/harness/chunk-w0qwc5z2.mjs +0 -41
  53. package/harness/chunk-wq253fj4.mjs +0 -19041
  54. package/harness/chunk-wyv7ceq4.mjs +0 -0
  55. package/harness/chunk-xnqknk2r.mjs +0 -198
  56. package/harness/chunk-z6n9thea.mjs +0 -45146
  57. package/harness/chunk-zty0d3bw.mjs +0 -0
  58. package/harness/chunk-zvkxtj82.mjs +0 -42
  59. package/harness/issue-api-token.mjs +0 -35
  60. package/harness/launcher.mjs +0 -459
  61. package/harness/sandbox.mjs +0 -133
  62. package/harness/server.mjs +0 -87314
@@ -1,538 +0,0 @@
1
- import {
2
- MastraBase
3
- } from "./chunk-2pm2sayw.mjs";
4
- import {
5
- MastraError
6
- } from "./chunk-v66qvpnb.mjs";
7
- import {
8
- createOpenAICompatible,
9
- createOpenAI,
10
- MastraModelGateway,
11
- createAnthropic,
12
- MASTRA_USER_AGENT,
13
- createGoogleGenerativeAI
14
- } from "./chunk-bdv1rx4a.mjs";
15
- import {
16
- __exportAll
17
- } from "./chunk-vsf2zajv.mjs";
18
-
19
- // node_modules/.bun/@isaacs+ttlcache@2.1.5/node_modules/@isaacs/ttlcache/dist/esm/index.js
20
- var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
21
- var now = () => perf.now();
22
- var isPosInt = (n) => !!n && n === Math.floor(n) && n > 0 && isFinite(n);
23
- var isPosIntOrInf = (n) => n === Infinity || isPosInt(n);
24
- var TIMER_MAX = 2 ** 31 - 1;
25
-
26
- class TTLCache {
27
- expirations = Object.create(null);
28
- data = new Map;
29
- expirationMap = new Map;
30
- ttl;
31
- max;
32
- updateAgeOnGet;
33
- updateAgeOnHas;
34
- noUpdateTTL;
35
- noDisposeOnSet;
36
- checkAgeOnGet;
37
- checkAgeOnHas;
38
- dispose;
39
- timer;
40
- timerExpiration;
41
- immortalKeys = new Set;
42
- constructor({ max = Infinity, ttl, updateAgeOnGet = false, checkAgeOnGet = false, updateAgeOnHas = false, checkAgeOnHas = false, noUpdateTTL = false, dispose, noDisposeOnSet = false } = {}) {
43
- if (ttl !== undefined && !isPosIntOrInf(ttl)) {
44
- throw new TypeError("ttl must be positive integer or Infinity if set");
45
- }
46
- if (!isPosIntOrInf(max)) {
47
- throw new TypeError("max must be positive integer or Infinity");
48
- }
49
- this.ttl = ttl;
50
- this.max = max;
51
- this.updateAgeOnGet = !!updateAgeOnGet;
52
- this.checkAgeOnGet = !!checkAgeOnGet;
53
- this.updateAgeOnHas = !!updateAgeOnHas;
54
- this.checkAgeOnHas = !!checkAgeOnHas;
55
- this.noUpdateTTL = !!noUpdateTTL;
56
- this.noDisposeOnSet = !!noDisposeOnSet;
57
- if (dispose !== undefined) {
58
- if (typeof dispose !== "function") {
59
- throw new TypeError("dispose must be function if set");
60
- }
61
- this.dispose = dispose;
62
- } else {
63
- this.dispose = (_, __, ___) => {};
64
- }
65
- this.timer = undefined;
66
- this.timerExpiration = undefined;
67
- }
68
- setTimer(expiration, ttl) {
69
- if (this.timerExpiration && this.timerExpiration < expiration) {
70
- return;
71
- }
72
- if (this.timer) {
73
- clearTimeout(this.timer);
74
- }
75
- const t = setTimeout(() => {
76
- this.timer = undefined;
77
- this.timerExpiration = undefined;
78
- this.purgeStale();
79
- for (const exp in this.expirations) {
80
- const e = Number(exp);
81
- this.setTimer(e, e - now());
82
- break;
83
- }
84
- }, Math.min(TIMER_MAX, Math.max(0, ttl)));
85
- if (t.unref)
86
- t.unref();
87
- this.timerExpiration = expiration;
88
- this.timer = t;
89
- }
90
- cancelTimer() {
91
- if (this.timer) {
92
- clearTimeout(this.timer);
93
- this.timerExpiration = undefined;
94
- this.timer = undefined;
95
- }
96
- }
97
- cancelTimers() {
98
- process.emitWarning("TTLCache.cancelTimers has been renamed to " + 'TTLCache.cancelTimer (no "s"), and will be removed in the next ' + "major version update");
99
- return this.cancelTimer();
100
- }
101
- clear() {
102
- const entries = this.dispose !== TTLCache.prototype.dispose ? [...this] : [];
103
- this.data.clear();
104
- this.expirationMap.clear();
105
- this.cancelTimer();
106
- this.expirations = Object.create(null);
107
- for (const [key, val] of entries) {
108
- this.dispose(val, key, "delete");
109
- }
110
- }
111
- setTTL(key, ttl = this.ttl) {
112
- const current = this.expirationMap.get(key);
113
- if (current !== undefined) {
114
- const exp = this.expirations[current];
115
- if (!exp || exp.length <= 1) {
116
- delete this.expirations[current];
117
- } else {
118
- this.expirations[current] = exp.filter((k) => k !== key);
119
- }
120
- }
121
- if (ttl && ttl !== Infinity) {
122
- this.immortalKeys.delete(key);
123
- const expiration = Math.floor(now() + ttl);
124
- this.expirationMap.set(key, expiration);
125
- if (!this.expirations[expiration]) {
126
- this.expirations[expiration] = [];
127
- this.setTimer(expiration, ttl);
128
- }
129
- this.expirations[expiration].push(key);
130
- } else {
131
- this.immortalKeys.add(key);
132
- this.expirationMap.set(key, Infinity);
133
- }
134
- }
135
- set(key, val, { ttl = this.ttl, noUpdateTTL = this.noUpdateTTL, noDisposeOnSet = this.noDisposeOnSet } = {}) {
136
- if (!isPosIntOrInf(ttl)) {
137
- throw new TypeError("ttl must be positive integer or Infinity");
138
- }
139
- if (this.expirationMap.has(key)) {
140
- if (!noUpdateTTL) {
141
- this.setTTL(key, ttl);
142
- }
143
- const oldValue = this.data.get(key);
144
- const disp = !noDisposeOnSet && this.data.has(key);
145
- if (oldValue !== val) {
146
- this.data.set(key, val);
147
- if (disp) {
148
- this.dispose(oldValue, key, "set");
149
- }
150
- }
151
- } else {
152
- this.setTTL(key, ttl);
153
- this.data.set(key, val);
154
- }
155
- while (this.size > this.max) {
156
- this.purgeToCapacity();
157
- }
158
- return this;
159
- }
160
- has(key, { checkAgeOnHas = this.checkAgeOnHas, ttl = this.ttl, updateAgeOnHas = this.updateAgeOnHas } = {}) {
161
- if (this.data.has(key)) {
162
- if (checkAgeOnHas && this.getRemainingTTL(key) === 0) {
163
- this.delete(key);
164
- return false;
165
- }
166
- if (updateAgeOnHas) {
167
- this.setTTL(key, ttl);
168
- }
169
- return true;
170
- }
171
- return false;
172
- }
173
- getRemainingTTL(key) {
174
- const expiration = this.expirationMap.get(key);
175
- return expiration === Infinity ? expiration : expiration !== undefined ? Math.max(0, Math.ceil(expiration - now())) : 0;
176
- }
177
- get(key, { updateAgeOnGet = this.updateAgeOnGet, ttl = this.ttl, checkAgeOnGet = this.checkAgeOnGet } = {}) {
178
- if (!this.data.has(key))
179
- return;
180
- const val = this.data.get(key);
181
- if (checkAgeOnGet && this.getRemainingTTL(key) === 0) {
182
- this.delete(key);
183
- return;
184
- }
185
- if (updateAgeOnGet) {
186
- this.setTTL(key, ttl);
187
- }
188
- return val;
189
- }
190
- delete(key) {
191
- const current = this.expirationMap.get(key);
192
- if (current !== undefined) {
193
- const value = this.data.get(key);
194
- this.data.delete(key);
195
- this.expirationMap.delete(key);
196
- this.immortalKeys.delete(key);
197
- const exp = this.expirations[current];
198
- if (exp) {
199
- if (exp.length <= 1) {
200
- delete this.expirations[current];
201
- } else {
202
- this.expirations[current] = exp.filter((k) => k !== key);
203
- }
204
- }
205
- this.dispose(value, key, "delete");
206
- if (this.size === 0) {
207
- this.cancelTimer();
208
- }
209
- return true;
210
- }
211
- return false;
212
- }
213
- purgeToCapacity() {
214
- for (const exp in this.expirations) {
215
- const keys = this.expirations[exp];
216
- if (this.size - keys.length >= this.max) {
217
- delete this.expirations[exp];
218
- const entries = [];
219
- for (const key of keys) {
220
- entries.push([key, this.data.get(key)]);
221
- this.data.delete(key);
222
- this.expirationMap.delete(key);
223
- }
224
- for (const [key, val] of entries) {
225
- this.dispose(val, key, "evict");
226
- }
227
- } else {
228
- const s = this.size - this.max;
229
- const entries = [];
230
- for (const key of keys.splice(0, s)) {
231
- entries.push([key, this.data.get(key)]);
232
- this.data.delete(key);
233
- this.expirationMap.delete(key);
234
- }
235
- for (const [key, val] of entries) {
236
- this.dispose(val, key, "evict");
237
- }
238
- return;
239
- }
240
- }
241
- }
242
- get size() {
243
- return this.data.size;
244
- }
245
- purgeStale() {
246
- const n = Math.ceil(now());
247
- for (const exp in this.expirations) {
248
- if (exp === "Infinity" || Number(exp) > n) {
249
- return;
250
- }
251
- const keys = [...this.expirations[exp] || []];
252
- const entries = [];
253
- delete this.expirations[exp];
254
- for (const key of keys) {
255
- entries.push([key, this.data.get(key)]);
256
- this.data.delete(key);
257
- this.expirationMap.delete(key);
258
- }
259
- for (const [key, val] of entries) {
260
- this.dispose(val, key, "stale");
261
- }
262
- }
263
- if (this.size === 0) {
264
- this.cancelTimer();
265
- }
266
- }
267
- *entries() {
268
- for (const exp in this.expirations) {
269
- for (const key of this.expirations[exp]) {
270
- yield [key, this.data.get(key)];
271
- }
272
- }
273
- for (const key of this.immortalKeys) {
274
- yield [key, this.data.get(key)];
275
- }
276
- }
277
- *keys() {
278
- for (const exp in this.expirations) {
279
- for (const key of this.expirations[exp]) {
280
- yield key;
281
- }
282
- }
283
- for (const key of this.immortalKeys) {
284
- yield key;
285
- }
286
- }
287
- *values() {
288
- for (const exp in this.expirations) {
289
- for (const key of this.expirations[exp]) {
290
- yield this.data.get(key);
291
- }
292
- }
293
- for (const key of this.immortalKeys) {
294
- yield this.data.get(key);
295
- }
296
- }
297
- [Symbol.iterator]() {
298
- return this.entries();
299
- }
300
- }
301
-
302
- // node_modules/.bun/@mastra+core@1.71.0+95d98e20cbc6e6e1/node_modules/@mastra/core/dist/inmemory-D_cTX1px.js
303
- var MastraServerCache = class extends MastraBase {
304
- constructor({ name }) {
305
- super({
306
- component: "SERVER_CACHE",
307
- name
308
- });
309
- }
310
- async listPushIndexed(listKey, counterKey, value) {
311
- const index = await this.increment(counterKey) - 1;
312
- await this.listPush(listKey, {
313
- ...value,
314
- index
315
- });
316
- return index;
317
- }
318
- };
319
- var InMemoryServerCache = class extends MastraServerCache {
320
- cache;
321
- ttlMs;
322
- constructor(options = {}) {
323
- super({ name: "InMemoryServerCache" });
324
- this.ttlMs = options.ttlMs ?? 1000 * 60 * 5;
325
- const ttl = this.ttlMs > 0 ? this.ttlMs : Infinity;
326
- this.cache = new TTLCache({
327
- max: options.maxSize ?? 1000,
328
- ttl
329
- });
330
- }
331
- async get(key) {
332
- return this.cache.get(key);
333
- }
334
- async set(key, value, ttlMs) {
335
- if (ttlMs === undefined) {
336
- this.cache.set(key, value);
337
- return;
338
- }
339
- this.cache.set(key, value, { ttl: ttlMs > 0 ? ttlMs : Infinity });
340
- }
341
- async listLength(key) {
342
- const value = this.cache.get(key);
343
- if (value === undefined)
344
- return 0;
345
- if (!Array.isArray(value))
346
- throw new Error(`${key} exists but is not an array`);
347
- return value.length;
348
- }
349
- async listPush(key, value) {
350
- const existing = this.cache.get(key);
351
- if (Array.isArray(existing)) {
352
- existing.push(value);
353
- if (this.ttlMs > 0)
354
- this.cache.set(key, existing, { ttl: this.ttlMs });
355
- } else if (existing !== undefined)
356
- throw new Error(`${key} exists but is not an array`);
357
- else
358
- this.cache.set(key, [value]);
359
- }
360
- async listFromTo(key, from, to = -1) {
361
- const list = this.cache.get(key);
362
- if (Array.isArray(list)) {
363
- const endIndex = to === -1 ? undefined : to + 1;
364
- return list.slice(from, endIndex);
365
- }
366
- return [];
367
- }
368
- async delete(key) {
369
- this.cache.delete(key);
370
- }
371
- async clear() {
372
- this.cache.clear();
373
- }
374
- async increment(key) {
375
- const value = this.cache.get(key);
376
- let counter;
377
- if (value === undefined)
378
- counter = 1;
379
- else if (typeof value === "number")
380
- counter = value + 1;
381
- else
382
- throw new Error(`${key} exists but is not a number`);
383
- this.cache.set(key, counter);
384
- return counter;
385
- }
386
- };
387
-
388
- // node_modules/.bun/@mastra+core@1.71.0+95d98e20cbc6e6e1/node_modules/@mastra/core/dist/netlify-B_pyJk7y.js
389
- var netlify_exports = /* @__PURE__ */ __exportAll({ NetlifyGateway: () => NetlifyGateway });
390
- var NetlifyGateway = class extends MastraModelGateway {
391
- id = "netlify";
392
- name = "Netlify AI Gateway";
393
- tokenCache = new InMemoryServerCache;
394
- async fetchProviders() {
395
- const response = await fetch("https://api.netlify.com/api/v1/ai-gateway/providers");
396
- if (!response.ok)
397
- throw new Error(`Failed to fetch from Netlify: ${response.statusText}`);
398
- const data = await response.json();
399
- const config = {
400
- apiKeyEnvVar: ["NETLIFY_TOKEN", "NETLIFY_SITE_ID"],
401
- apiKeyHeader: "Authorization",
402
- name: `Netlify`,
403
- gateway: `netlify`,
404
- models: [],
405
- docUrl: "https://docs.netlify.com/build/ai-gateway/overview/"
406
- };
407
- for (const [providerId, provider] of Object.entries(data.providers))
408
- for (const model of provider.models)
409
- config.models.push(`${providerId}/${model}`);
410
- return { netlify: config };
411
- }
412
- async buildUrl(routerId, envVars) {
413
- const siteId = envVars?.["NETLIFY_SITE_ID"] || process.env["NETLIFY_SITE_ID"];
414
- const netlifyToken = envVars?.["NETLIFY_TOKEN"] || process.env["NETLIFY_TOKEN"];
415
- if (!netlifyToken)
416
- throw new MastraError({
417
- id: "NETLIFY_GATEWAY_NO_TOKEN",
418
- domain: "LLM",
419
- category: "UNKNOWN",
420
- text: `Missing NETLIFY_TOKEN environment variable required for model: ${routerId}`
421
- });
422
- if (!siteId)
423
- throw new MastraError({
424
- id: "NETLIFY_GATEWAY_NO_SITE_ID",
425
- domain: "LLM",
426
- category: "UNKNOWN",
427
- text: `Missing NETLIFY_SITE_ID environment variable required for model: ${routerId}`
428
- });
429
- try {
430
- const tokenData = await this.getOrFetchToken(siteId, netlifyToken);
431
- return tokenData.url.endsWith(`/`) ? tokenData.url.substring(0, tokenData.url.length - 1) : tokenData.url;
432
- } catch (error) {
433
- throw new MastraError({
434
- id: "NETLIFY_GATEWAY_TOKEN_ERROR",
435
- domain: "LLM",
436
- category: "UNKNOWN",
437
- text: `Failed to get Netlify AI Gateway token for model ${routerId}: ${error instanceof Error ? error.message : String(error)}`
438
- });
439
- }
440
- }
441
- async getOrFetchToken(siteId, netlifyToken) {
442
- const cacheKey = `netlify-token:${siteId}:${netlifyToken}`;
443
- const cached = await this.tokenCache.get(cacheKey);
444
- if (cached && cached.expiresAt > Date.now() / 1000 + 60)
445
- return {
446
- token: cached.token,
447
- url: cached.url
448
- };
449
- const response = await fetch(`https://api.netlify.com/api/v1/sites/${siteId}/ai-gateway/token`, {
450
- method: "GET",
451
- headers: { Authorization: `Bearer ${netlifyToken}` }
452
- });
453
- if (!response.ok) {
454
- const error = await response.text();
455
- throw new Error(`Failed to get Netlify AI Gateway token: ${response.status} ${error}`);
456
- }
457
- const tokenResponse = await response.json();
458
- await this.tokenCache.set(cacheKey, {
459
- token: tokenResponse.token,
460
- url: tokenResponse.url,
461
- expiresAt: tokenResponse.expires_at
462
- });
463
- return {
464
- token: tokenResponse.token,
465
- url: tokenResponse.url
466
- };
467
- }
468
- async getApiKey(modelId) {
469
- const siteId = process.env["NETLIFY_SITE_ID"];
470
- const netlifyToken = process.env["NETLIFY_TOKEN"];
471
- if (!netlifyToken)
472
- throw new MastraError({
473
- id: "NETLIFY_GATEWAY_NO_TOKEN",
474
- domain: "LLM",
475
- category: "UNKNOWN",
476
- text: `Missing NETLIFY_TOKEN environment variable required for model: ${modelId}`
477
- });
478
- if (!siteId)
479
- throw new MastraError({
480
- id: "NETLIFY_GATEWAY_NO_SITE_ID",
481
- domain: "LLM",
482
- category: "UNKNOWN",
483
- text: `Missing NETLIFY_SITE_ID environment variable required for model: ${modelId}`
484
- });
485
- try {
486
- return (await this.getOrFetchToken(siteId, netlifyToken)).token;
487
- } catch (error) {
488
- throw new MastraError({
489
- id: "NETLIFY_GATEWAY_TOKEN_ERROR",
490
- domain: "LLM",
491
- category: "UNKNOWN",
492
- text: `Failed to get Netlify AI Gateway token for model ${modelId}: ${error instanceof Error ? error.message : String(error)}`
493
- });
494
- }
495
- }
496
- async resolveLanguageModel({ modelId, providerId, apiKey, headers }) {
497
- const baseURL = await this.buildUrl(`${providerId}/${modelId}`);
498
- const mastraHeaders = {
499
- "User-Agent": MASTRA_USER_AGENT,
500
- ...headers
501
- };
502
- switch (providerId) {
503
- case "openai":
504
- return createOpenAI({
505
- apiKey,
506
- baseURL,
507
- headers: mastraHeaders
508
- }).responses(modelId);
509
- case "gemini":
510
- return createGoogleGenerativeAI({
511
- baseURL: `${baseURL}/v1beta/`,
512
- apiKey,
513
- headers: {
514
- "user-agent": "google-genai-sdk/",
515
- ...mastraHeaders
516
- }
517
- }).chat(modelId);
518
- case "anthropic":
519
- return createAnthropic({
520
- apiKey,
521
- baseURL: `${baseURL}/v1/`,
522
- headers: {
523
- "anthropic-version": "2023-06-01",
524
- ...mastraHeaders
525
- }
526
- })(modelId);
527
- default:
528
- return createOpenAICompatible({
529
- name: providerId,
530
- apiKey,
531
- baseURL,
532
- headers: mastraHeaders,
533
- supportsStructuredOutputs: true
534
- }).chatModel(modelId);
535
- }
536
- }
537
- };
538
- export { TTLCache, InMemoryServerCache, netlify_exports, NetlifyGateway };