@mettlelabs/mettle 0.0.0-beta.1-linux-arm64 → 0.0.0-beta.11

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 (61) hide show
  1. package/LICENSE +22 -0
  2. package/bin/mettle.cjs +152 -0
  3. package/package.json +28 -16
  4. package/THIRD_PARTY_NOTICES.md +0 -11479
  5. package/bin/mettle +0 -4
  6. package/harness/audit-investigation.mjs +0 -203
  7. package/harness/chunk-13tgmdey.mjs +0 -33761
  8. package/harness/chunk-1sygmp11.mjs +0 -18142
  9. package/harness/chunk-1ykxpmaz.mjs +0 -7887
  10. package/harness/chunk-2gt4cy7x.mjs +0 -2290
  11. package/harness/chunk-2pm2sayw.mjs +0 -248
  12. package/harness/chunk-32y07kkp.mjs +0 -3747
  13. package/harness/chunk-3m7jn5ac.mjs +0 -16242
  14. package/harness/chunk-3wvjs93w.mjs +0 -538
  15. package/harness/chunk-4bepyxmq.mjs +0 -113
  16. package/harness/chunk-4jtnt9k5.mjs +0 -95
  17. package/harness/chunk-50sbrf09.mjs +0 -18972
  18. package/harness/chunk-56csr8sw.mjs +0 -322
  19. package/harness/chunk-5cvb1jnb.mjs +0 -41
  20. package/harness/chunk-5wgmv4np.mjs +0 -585
  21. package/harness/chunk-65eyq32y.mjs +0 -225
  22. package/harness/chunk-6fnh6qhk.mjs +0 -195
  23. package/harness/chunk-6kgqw9ny.mjs +0 -32303
  24. package/harness/chunk-7b242j0n.mjs +0 -14
  25. package/harness/chunk-7bg2gnv2.mjs +0 -7540
  26. package/harness/chunk-ageqxj9v.mjs +0 -63008
  27. package/harness/chunk-b0qbt5jd.mjs +0 -14
  28. package/harness/chunk-b5g1r3fz.mjs +0 -4785
  29. package/harness/chunk-b71gpkxg.mjs +0 -1514
  30. package/harness/chunk-bdv1rx4a.mjs +0 -20364
  31. package/harness/chunk-c1631s2x.mjs +0 -12241
  32. package/harness/chunk-d5xgxsnp.mjs +0 -74
  33. package/harness/chunk-erg1fbh0.mjs +0 -0
  34. package/harness/chunk-fh78v9vn.mjs +0 -19366
  35. package/harness/chunk-fjx29qvp.mjs +0 -50
  36. package/harness/chunk-gryka6kg.mjs +0 -39
  37. package/harness/chunk-jb0r19et.mjs +0 -180
  38. package/harness/chunk-mfn574ss.mjs +0 -179
  39. package/harness/chunk-msg872ea.mjs +0 -334
  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-rz2tz6jp.mjs +0 -26
  46. package/harness/chunk-sbkgc3kn.mjs +0 -8
  47. package/harness/chunk-v66qvpnb.mjs +0 -169
  48. package/harness/chunk-vjaxzab3.mjs +0 -136
  49. package/harness/chunk-vr1n5nza.mjs +0 -1045
  50. package/harness/chunk-vsf2zajv.mjs +0 -3867
  51. package/harness/chunk-wq253fj4.mjs +0 -19041
  52. package/harness/chunk-wyv7ceq4.mjs +0 -0
  53. package/harness/chunk-xnqknk2r.mjs +0 -198
  54. package/harness/chunk-xqyc4ca2.mjs +0 -1890
  55. package/harness/chunk-z6n9thea.mjs +0 -45146
  56. package/harness/chunk-zty0d3bw.mjs +0 -0
  57. package/harness/chunk-zvkxtj82.mjs +0 -42
  58. package/harness/issue-api-token.mjs +0 -35
  59. package/harness/launcher.mjs +0 -159
  60. package/harness/sandbox.mjs +0 -132
  61. package/harness/server.mjs +0 -66322
File without changes
@@ -1,198 +0,0 @@
1
- import {
2
- getCapabilityFileName,
3
- getGatewayId,
4
- shouldEnableGateway
5
- } from "./chunk-gryka6kg.mjs";
6
-
7
- // node_modules/.bun/@mastra+core@1.71.0+95d98e20cbc6e6e1/node_modules/@mastra/core/dist/registry-generator-DTVbvs_S.js
8
- import path from "path";
9
- import fs from "fs/promises";
10
- var WINDOWS_RENAME_RETRY_DELAYS_MS = [
11
- 25,
12
- 50,
13
- 100,
14
- 200,
15
- 400
16
- ];
17
- function hasAttachmentCapabilities(gateway) {
18
- return "getAttachmentCapabilities" in gateway && typeof gateway.getAttachmentCapabilities === "function";
19
- }
20
- function hasTemperatureCapabilities(gateway) {
21
- return "getTemperatureCapabilities" in gateway && typeof gateway.getTemperatureCapabilities === "function";
22
- }
23
- function hasStructuredOutputCapabilities(gateway) {
24
- return "getStructuredOutputCapabilities" in gateway && typeof gateway.getStructuredOutputCapabilities === "function";
25
- }
26
- async function atomicWriteFile(filePath, content, encoding = "utf-8") {
27
- const randomSuffix = Math.random().toString(36).substring(2, 15);
28
- const tempPath = `${filePath}.${process.pid}.${Date.now()}.${randomSuffix}.tmp`;
29
- try {
30
- await fs.writeFile(tempPath, content, encoding);
31
- for (let attempt = 0;; attempt += 1)
32
- try {
33
- await fs.rename(tempPath, filePath);
34
- break;
35
- } catch (error) {
36
- const delayMs = WINDOWS_RENAME_RETRY_DELAYS_MS[attempt];
37
- if (!(process.platform === "win32" && error instanceof Error && ("code" in error) && (error.code === "EPERM" || error.code === "EBUSY")) || delayMs === undefined)
38
- throw error;
39
- await new Promise((resolve) => setTimeout(resolve, delayMs));
40
- }
41
- } catch (error) {
42
- try {
43
- await fs.unlink(tempPath);
44
- } catch {}
45
- throw error;
46
- }
47
- }
48
- async function fetchProvidersFromGateways(gateways) {
49
- const enabledGateways = [];
50
- for (const gateway of gateways)
51
- if (shouldEnableGateway(gateway))
52
- enabledGateways.push(gateway);
53
- const allProviders = {};
54
- const allModels = {};
55
- const allAttachmentCapabilities = {};
56
- const allTemperatureCapabilities = {};
57
- const allStructuredOutputCapabilities = {};
58
- const failedGateways = [];
59
- const maxRetries = 3;
60
- for (const gateway of enabledGateways) {
61
- let providers = null;
62
- for (let attempt = 1;attempt <= maxRetries; attempt++)
63
- try {
64
- providers = await gateway.fetchProviders();
65
- break;
66
- } catch {
67
- if (attempt < maxRetries) {
68
- const delayMs = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
69
- await new Promise((resolve) => setTimeout(resolve, delayMs));
70
- }
71
- }
72
- if (!providers) {
73
- failedGateways.push(getGatewayId(gateway));
74
- continue;
75
- }
76
- const gatewayId = getGatewayId(gateway);
77
- const isProviderRegistry = gatewayId === "models.dev";
78
- const gatewayAttachmentCaps = hasAttachmentCapabilities(gateway) ? gateway.getAttachmentCapabilities() : undefined;
79
- const gatewayTemperatureCaps = hasTemperatureCapabilities(gateway) ? gateway.getTemperatureCapabilities() : undefined;
80
- const gatewayStructuredOutputCaps = hasStructuredOutputCapabilities(gateway) ? gateway.getStructuredOutputCapabilities() : undefined;
81
- for (const [providerId, config] of Object.entries(providers)) {
82
- const typeProviderId = isProviderRegistry ? providerId : providerId === gatewayId ? gatewayId : `${gatewayId}/${providerId}`;
83
- allProviders[typeProviderId] = config;
84
- allModels[typeProviderId] = config.models.sort();
85
- if (gatewayAttachmentCaps?.[providerId])
86
- allAttachmentCapabilities[typeProviderId] = gatewayAttachmentCaps[providerId];
87
- if (gatewayTemperatureCaps?.[providerId])
88
- allTemperatureCapabilities[typeProviderId] = gatewayTemperatureCaps[providerId];
89
- if (gatewayStructuredOutputCaps?.[providerId])
90
- allStructuredOutputCapabilities[typeProviderId] = gatewayStructuredOutputCaps[providerId];
91
- }
92
- }
93
- return {
94
- providers: allProviders,
95
- models: allModels,
96
- attachmentCapabilities: allAttachmentCapabilities,
97
- temperatureCapabilities: allTemperatureCapabilities,
98
- structuredOutputCapabilities: allStructuredOutputCapabilities,
99
- failedGateways
100
- };
101
- }
102
- function generateTypesContent(models) {
103
- return `/**
104
- * THIS FILE IS AUTO-GENERATED - DO NOT EDIT
105
- * Generated from model gateway providers
106
- */
107
-
108
- /**
109
- * Provider models mapping type
110
- * This is derived from the JSON data and provides type-safe access
111
- */
112
- export type ProviderModelsMap = {
113
- ${Object.entries(models).map(([provider, modelList]) => {
114
- const modelsList = modelList.map((m) => `'${m}'`);
115
- const providerKey = !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(provider) ? `'${provider}'` : provider;
116
- const singleLine = ` readonly ${providerKey}: readonly [${modelsList.join(", ")}];`;
117
- if (singleLine.length > 120)
118
- return ` readonly ${providerKey}: readonly [
119
- ${modelList.map((m) => ` '${m}',`).join(`
120
- `)}
121
- ];`;
122
- return singleLine;
123
- }).join(`
124
- `)}
125
- };
126
-
127
- /**
128
- * Union type of all registered provider IDs
129
- */
130
- export type Provider = keyof ProviderModelsMap;
131
-
132
- /**
133
- * Provider models mapping interface
134
- */
135
- export interface ProviderModels {
136
- [key: string]: string[];
137
- }
138
-
139
- /**
140
- * OpenAI-compatible model ID type
141
- * Dynamically derived from ProviderModelsMap
142
- * Full provider/model paths (e.g., "openai/gpt-4o", "anthropic/claude-3-5-sonnet-20241022")
143
- */
144
- export type ModelRouterModelId =
145
- | {
146
- [P in Provider]: \`\${P}/\${ProviderModelsMap[P][number]}\`;
147
- }[Provider]
148
- | \`mastra/\${ProviderModelsMap['openrouter'][number]}\`
149
- | (string & {});
150
-
151
- /**
152
- * Extract the model part from a ModelRouterModelId for a specific provider
153
- * Dynamically derived from ProviderModelsMap
154
- * Example: ModelForProvider<'openai'> = 'gpt-4o' | 'gpt-4-turbo' | ...
155
- */
156
- export type ModelForProvider<P extends Provider> = ProviderModelsMap[P][number];
157
- `;
158
- }
159
- async function writeRegistryFiles(jsonPath, typesPath, providers, models, attachmentCapabilities, temperatureCapabilities, structuredOutputCapabilities) {
160
- const jsonDir = path.dirname(jsonPath);
161
- const typesDir = path.dirname(typesPath);
162
- await fs.mkdir(jsonDir, { recursive: true });
163
- await fs.mkdir(typesDir, { recursive: true });
164
- await atomicWriteFile(jsonPath, JSON.stringify({
165
- providers,
166
- models,
167
- version: "1.0.0"
168
- }, null, 2), "utf-8");
169
- await atomicWriteFile(typesPath, generateTypesContent(models), "utf-8");
170
- const capDir = path.join(jsonDir, "capabilities");
171
- const hasCapabilities = attachmentCapabilities && Object.keys(attachmentCapabilities).length > 0 || temperatureCapabilities && Object.keys(temperatureCapabilities).length > 0 || structuredOutputCapabilities && Object.keys(structuredOutputCapabilities).length > 0;
172
- await fs.rm(capDir, {
173
- recursive: true,
174
- force: true
175
- });
176
- if (hasCapabilities) {
177
- await fs.mkdir(capDir, { recursive: true });
178
- const allProviderIds = /* @__PURE__ */ new Set([
179
- ...attachmentCapabilities ? Object.keys(attachmentCapabilities) : [],
180
- ...temperatureCapabilities ? Object.keys(temperatureCapabilities) : [],
181
- ...structuredOutputCapabilities ? Object.keys(structuredOutputCapabilities) : []
182
- ]);
183
- for (const provider of allProviderIds) {
184
- const capData = {};
185
- if (attachmentCapabilities?.[provider])
186
- capData.attachment = attachmentCapabilities[provider];
187
- if (temperatureCapabilities?.[provider])
188
- capData.temperature = temperatureCapabilities[provider];
189
- if (structuredOutputCapabilities?.[provider])
190
- capData.structuredOutput = structuredOutputCapabilities[provider];
191
- await atomicWriteFile(path.join(capDir, getCapabilityFileName(provider)), JSON.stringify(capData, null, 2), "utf-8");
192
- }
193
- }
194
- }
195
- export {
196
- fetchProvidersFromGateways,
197
- writeRegistryFiles
198
- };