@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.
- package/bin/mettle.js +53 -0
- package/bin/postinstall.js +28 -0
- package/package.json +19 -13
- package/THIRD_PARTY_NOTICES.md +0 -11974
- package/bin/mettle +0 -4
- package/harness/audit-investigation.mjs +0 -203
- package/harness/chunk-1sygmp11.mjs +0 -18142
- package/harness/chunk-1ykxpmaz.mjs +0 -7887
- package/harness/chunk-2pm2sayw.mjs +0 -248
- package/harness/chunk-3m7jn5ac.mjs +0 -16242
- package/harness/chunk-3wt8a8fq.mjs +0 -1716
- package/harness/chunk-3wvjs93w.mjs +0 -538
- package/harness/chunk-49ytr8d5.mjs +0 -33761
- package/harness/chunk-4bepyxmq.mjs +0 -113
- package/harness/chunk-4vx34w5h.mjs +0 -2357
- package/harness/chunk-50sbrf09.mjs +0 -18972
- package/harness/chunk-56csr8sw.mjs +0 -322
- package/harness/chunk-5wgmv4np.mjs +0 -585
- package/harness/chunk-65eyq32y.mjs +0 -225
- package/harness/chunk-6fnh6qhk.mjs +0 -195
- package/harness/chunk-6kgqw9ny.mjs +0 -32303
- package/harness/chunk-7b242j0n.mjs +0 -14
- package/harness/chunk-9dg1btk1.mjs +0 -2818
- package/harness/chunk-ageqxj9v.mjs +0 -63008
- package/harness/chunk-b0qbt5jd.mjs +0 -14
- package/harness/chunk-b5g1r3fz.mjs +0 -4785
- package/harness/chunk-b71gpkxg.mjs +0 -1514
- package/harness/chunk-bdv1rx4a.mjs +0 -20364
- package/harness/chunk-c1631s2x.mjs +0 -12241
- package/harness/chunk-c7dx5mdd.mjs +0 -10807
- package/harness/chunk-d5xgxsnp.mjs +0 -74
- package/harness/chunk-erg1fbh0.mjs +0 -0
- package/harness/chunk-fh78v9vn.mjs +0 -19366
- package/harness/chunk-fjx29qvp.mjs +0 -50
- package/harness/chunk-gryka6kg.mjs +0 -39
- package/harness/chunk-h1td5kq9.mjs +0 -422
- package/harness/chunk-jb0r19et.mjs +0 -180
- package/harness/chunk-jp69h6sj.mjs +0 -95
- package/harness/chunk-mfn574ss.mjs +0 -179
- package/harness/chunk-nz5sv9as.mjs +0 -1642
- package/harness/chunk-p9d3cgvq.mjs +0 -452
- package/harness/chunk-pq6wvwxr.mjs +0 -12
- package/harness/chunk-qcm9arf8.mjs +0 -7736
- package/harness/chunk-qr8zfqjd.mjs +0 -24
- package/harness/chunk-rd80vvc5.mjs +0 -22047
- package/harness/chunk-rz2tz6jp.mjs +0 -26
- package/harness/chunk-sbkgc3kn.mjs +0 -8
- package/harness/chunk-v66qvpnb.mjs +0 -169
- package/harness/chunk-vjaxzab3.mjs +0 -136
- package/harness/chunk-vr1n5nza.mjs +0 -1045
- package/harness/chunk-vsf2zajv.mjs +0 -3867
- package/harness/chunk-w0qwc5z2.mjs +0 -41
- package/harness/chunk-wq253fj4.mjs +0 -19041
- package/harness/chunk-wyv7ceq4.mjs +0 -0
- package/harness/chunk-xnqknk2r.mjs +0 -198
- package/harness/chunk-z6n9thea.mjs +0 -45146
- package/harness/chunk-zty0d3bw.mjs +0 -0
- package/harness/chunk-zvkxtj82.mjs +0 -42
- package/harness/issue-api-token.mjs +0 -35
- package/harness/launcher.mjs +0 -459
- package/harness/sandbox.mjs +0 -133
- package/harness/server.mjs +0 -87314
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sha256
|
|
3
|
-
} from "./chunk-rd80vvc5.mjs";
|
|
4
|
-
import {
|
|
5
|
-
ApiPrincipalSchema,
|
|
6
|
-
ApiTokenRecordSchema,
|
|
7
|
-
BEARER_TOKEN_PATTERN
|
|
8
|
-
} from "./chunk-zvkxtj82.mjs";
|
|
9
|
-
import {
|
|
10
|
-
number
|
|
11
|
-
} from "./chunk-1sygmp11.mjs";
|
|
12
|
-
|
|
13
|
-
// apps/harness/src/api/auth.ts
|
|
14
|
-
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
15
|
-
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
16
|
-
import { join, resolve } from "node:path";
|
|
17
|
-
var ApiTokenIssueRequestSchema = ApiPrincipalSchema.omit({
|
|
18
|
-
expiresAt: true
|
|
19
|
-
}).extend({
|
|
20
|
-
ttlSeconds: number().int().min(60).max(86400).default(3600)
|
|
21
|
-
});
|
|
22
|
-
function issueApiToken(input, now = Date.now()) {
|
|
23
|
-
const { ttlSeconds, ...authority } = ApiTokenIssueRequestSchema.parse(input);
|
|
24
|
-
const principal = ApiPrincipalSchema.parse({
|
|
25
|
-
...authority,
|
|
26
|
-
expiresAt: now + ttlSeconds * 1000
|
|
27
|
-
});
|
|
28
|
-
const token = randomBytes(32).toString("base64url");
|
|
29
|
-
const record = {
|
|
30
|
-
tokenSha256: sha256(token),
|
|
31
|
-
principal
|
|
32
|
-
};
|
|
33
|
-
return { token, record };
|
|
34
|
-
}
|
|
35
|
-
async function writePrivateFile(path, contents) {
|
|
36
|
-
await writeFile(path, contents, { flag: "wx", mode: 384 });
|
|
37
|
-
}
|
|
38
|
-
async function writeApiTokenFiles(request, outputDirectory) {
|
|
39
|
-
const { token, record } = issueApiToken(request);
|
|
40
|
-
const directory = resolve(outputDirectory);
|
|
41
|
-
const tokenFile = join(directory, "token.key");
|
|
42
|
-
const serverTokensFile = join(directory, "server-tokens.json");
|
|
43
|
-
await mkdir(directory, { mode: 448 });
|
|
44
|
-
try {
|
|
45
|
-
await writePrivateFile(tokenFile, `${token}
|
|
46
|
-
`);
|
|
47
|
-
await writePrivateFile(serverTokensFile, `${JSON.stringify([record], null, 2)}
|
|
48
|
-
`);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
await rm(directory, { recursive: true, force: true });
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
tokenFile,
|
|
55
|
-
serverTokensFile,
|
|
56
|
-
expiresAt: record.principal.expiresAt,
|
|
57
|
-
credentialsPrinted: false
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
class ApiError extends Error {
|
|
62
|
-
status;
|
|
63
|
-
code;
|
|
64
|
-
constructor(status, code) {
|
|
65
|
-
super(code);
|
|
66
|
-
this.status = status;
|
|
67
|
-
this.code = code;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function tokenAuthenticator(entries, now = Date.now) {
|
|
71
|
-
if (!entries.length)
|
|
72
|
-
throw new Error("At least one explicitly configured API token is required.");
|
|
73
|
-
const records = entries.map((entry) => {
|
|
74
|
-
const record = ApiTokenRecordSchema.parse(entry);
|
|
75
|
-
return {
|
|
76
|
-
hash: Buffer.from(record.tokenSha256, "hex"),
|
|
77
|
-
principal: record.principal
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
if (new Set(entries.map((entry) => entry.tokenSha256)).size !== entries.length)
|
|
81
|
-
throw new Error("Duplicate API token.");
|
|
82
|
-
return async (request) => {
|
|
83
|
-
const header = request.headers.get("authorization") ?? "";
|
|
84
|
-
const match = BEARER_TOKEN_PATTERN.exec(header);
|
|
85
|
-
if (!match)
|
|
86
|
-
throw new ApiError(401, "unauthorized");
|
|
87
|
-
const actual = createHash("sha256").update(match[1]).digest();
|
|
88
|
-
const record = records.find((entry) => timingSafeEqual(entry.hash, actual));
|
|
89
|
-
if (!record || record.principal.expiresAt <= now())
|
|
90
|
-
throw new ApiError(401, "unauthorized");
|
|
91
|
-
return structuredClone(record.principal);
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { writeApiTokenFiles, ApiError, tokenAuthenticator };
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// node_modules/.bun/@mastra+core@1.71.0+95d98e20cbc6e6e1/node_modules/@mastra/core/dist/request-context-BGr5xGOr.js
|
|
2
|
-
var MASTRA_RESOURCE_ID_KEY = "mastra__resourceId";
|
|
3
|
-
var MASTRA_THREAD_ID_KEY = "mastra__threadId";
|
|
4
|
-
var MASTRA_VERSIONS_KEY = "mastra__versions";
|
|
5
|
-
var MASTRA_AUTH_TOKEN_KEY = "mastra__authToken";
|
|
6
|
-
var MASTRA_INHERITED_MEMORY_KEY = "mastra__inheritedMemory";
|
|
7
|
-
var MASTRA_MESSAGE_AUTHOR_KEY = "mastra__messageAuthor";
|
|
8
|
-
function mergeVersionOverrides(base, overrides) {
|
|
9
|
-
if (!base && !overrides)
|
|
10
|
-
return;
|
|
11
|
-
return {
|
|
12
|
-
...base,
|
|
13
|
-
...overrides,
|
|
14
|
-
agents: {
|
|
15
|
-
...base?.agents,
|
|
16
|
-
...overrides?.agents
|
|
17
|
-
},
|
|
18
|
-
...overrides?.defaultStatus ? { defaultStatus: overrides.defaultStatus } : base?.defaultStatus ? { defaultStatus: base.defaultStatus } : {}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
var CyclicRequestContextToJSONError = class extends Error {
|
|
22
|
-
constructor(message) {
|
|
23
|
-
super(message);
|
|
24
|
-
this.name = "CyclicRequestContextToJSONError";
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var _toJSONInProgress = /* @__PURE__ */ new WeakSet;
|
|
28
|
-
var _toJSONDepth = 0;
|
|
29
|
-
var SERIALIZATION_PROBE_BUDGET = 1e6;
|
|
30
|
-
var _typedArrayLength = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), "length").get;
|
|
31
|
-
function isPlainObjectOrArray(value) {
|
|
32
|
-
try {
|
|
33
|
-
if (Array.isArray(value))
|
|
34
|
-
return true;
|
|
35
|
-
if (value === null || typeof value !== "object")
|
|
36
|
-
return false;
|
|
37
|
-
const proto = Object.getPrototypeOf(value);
|
|
38
|
-
return proto === Object.prototype || proto === null;
|
|
39
|
-
} catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
var _probeBudgetActive = false;
|
|
44
|
-
var _probeBudgetRemaining = 0;
|
|
45
|
-
var RequestContext = class {
|
|
46
|
-
registry = /* @__PURE__ */ new Map;
|
|
47
|
-
constructor(iterable) {
|
|
48
|
-
if (iterable && typeof iterable === "object" && typeof iterable[Symbol.iterator] !== "function")
|
|
49
|
-
this.registry = new Map(Object.entries(iterable));
|
|
50
|
-
else
|
|
51
|
-
this.registry = new Map(iterable);
|
|
52
|
-
}
|
|
53
|
-
set(key, value) {
|
|
54
|
-
this.registry.set(key, value);
|
|
55
|
-
}
|
|
56
|
-
setRaw(key, value) {
|
|
57
|
-
this.registry.set(key, value);
|
|
58
|
-
}
|
|
59
|
-
get(key) {
|
|
60
|
-
return this.registry.get(key);
|
|
61
|
-
}
|
|
62
|
-
getRaw(key) {
|
|
63
|
-
return this.registry.get(key);
|
|
64
|
-
}
|
|
65
|
-
has(key) {
|
|
66
|
-
return this.registry.has(key);
|
|
67
|
-
}
|
|
68
|
-
hasRaw(key) {
|
|
69
|
-
return this.registry.has(key);
|
|
70
|
-
}
|
|
71
|
-
delete(key) {
|
|
72
|
-
return this.registry.delete(key);
|
|
73
|
-
}
|
|
74
|
-
deleteRaw(key) {
|
|
75
|
-
return this.registry.delete(key);
|
|
76
|
-
}
|
|
77
|
-
clear() {
|
|
78
|
-
this.registry.clear();
|
|
79
|
-
}
|
|
80
|
-
keys() {
|
|
81
|
-
return this.registry.keys();
|
|
82
|
-
}
|
|
83
|
-
values() {
|
|
84
|
-
return this.registry.values();
|
|
85
|
-
}
|
|
86
|
-
entries() {
|
|
87
|
-
return this.registry.entries();
|
|
88
|
-
}
|
|
89
|
-
size() {
|
|
90
|
-
return this.registry.size;
|
|
91
|
-
}
|
|
92
|
-
forEach(callbackfn) {
|
|
93
|
-
this.registry.forEach(callbackfn);
|
|
94
|
-
}
|
|
95
|
-
toJSON() {
|
|
96
|
-
if (_toJSONInProgress.has(this))
|
|
97
|
-
throw new CyclicRequestContextToJSONError("RequestContext.toJSON: detected cyclic re-entry (a stored value transitively references this context)");
|
|
98
|
-
_toJSONInProgress.add(this);
|
|
99
|
-
_toJSONDepth++;
|
|
100
|
-
try {
|
|
101
|
-
const result = {};
|
|
102
|
-
for (const [key, value] of this.registry.entries())
|
|
103
|
-
if (this.isSerializable(value))
|
|
104
|
-
result[key] = value;
|
|
105
|
-
return result;
|
|
106
|
-
} finally {
|
|
107
|
-
_toJSONInProgress.delete(this);
|
|
108
|
-
_toJSONDepth--;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
isSerializable(value) {
|
|
112
|
-
if (value === null || value === undefined)
|
|
113
|
-
return true;
|
|
114
|
-
if (typeof value === "function")
|
|
115
|
-
return false;
|
|
116
|
-
if (typeof value === "symbol")
|
|
117
|
-
return false;
|
|
118
|
-
if (typeof value !== "object" && typeof value !== "bigint")
|
|
119
|
-
return true;
|
|
120
|
-
const outermostProbe = !_probeBudgetActive;
|
|
121
|
-
if (outermostProbe) {
|
|
122
|
-
_probeBudgetActive = true;
|
|
123
|
-
_probeBudgetRemaining = SERIALIZATION_PROBE_BUDGET;
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
JSON.stringify(value, (_key, probed) => {
|
|
127
|
-
if (--_probeBudgetRemaining < 0)
|
|
128
|
-
throw new RangeError("RequestContext.isSerializable: value expands past the serialization probe budget");
|
|
129
|
-
if (ArrayBuffer.isView(probed)) {
|
|
130
|
-
let elementCount;
|
|
131
|
-
try {
|
|
132
|
-
elementCount = _typedArrayLength.call(probed);
|
|
133
|
-
} catch {
|
|
134
|
-
return probed;
|
|
135
|
-
}
|
|
136
|
-
if (typeof probed[0] === "bigint")
|
|
137
|
-
return probed;
|
|
138
|
-
_probeBudgetRemaining -= elementCount;
|
|
139
|
-
if (_probeBudgetRemaining < 0)
|
|
140
|
-
throw new RangeError("RequestContext.isSerializable: value expands past the serialization probe budget");
|
|
141
|
-
const surrogate = Object.create(null);
|
|
142
|
-
for (const key of Object.keys(probed)) {
|
|
143
|
-
const index = Number(key);
|
|
144
|
-
if (!(Number.isInteger(index) && index >= 0 && String(index) === key))
|
|
145
|
-
surrogate[key] = probed[key];
|
|
146
|
-
}
|
|
147
|
-
return surrogate;
|
|
148
|
-
}
|
|
149
|
-
return probed;
|
|
150
|
-
});
|
|
151
|
-
return true;
|
|
152
|
-
} catch (e) {
|
|
153
|
-
if (e instanceof CyclicRequestContextToJSONError && _toJSONDepth > 1)
|
|
154
|
-
throw e;
|
|
155
|
-
return false;
|
|
156
|
-
} finally {
|
|
157
|
-
if (outermostProbe)
|
|
158
|
-
_probeBudgetActive = false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
serializeForSpan() {
|
|
162
|
-
const safe = {};
|
|
163
|
-
for (const [key, value] of this.registry.entries())
|
|
164
|
-
if (key === "mastra__authToken")
|
|
165
|
-
safe[key] = "[REDACTED]";
|
|
166
|
-
else if (value === null || value === undefined || typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
167
|
-
safe[key] = value;
|
|
168
|
-
else if (isPlainObjectOrArray(value))
|
|
169
|
-
safe[key] = value;
|
|
170
|
-
else
|
|
171
|
-
safe[key] = `[${typeof value}]`;
|
|
172
|
-
return safe;
|
|
173
|
-
}
|
|
174
|
-
get all() {
|
|
175
|
-
return Object.fromEntries(this.registry);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, MASTRA_VERSIONS_KEY, MASTRA_AUTH_TOKEN_KEY, MASTRA_INHERITED_MEMORY_KEY, MASTRA_MESSAGE_AUTHOR_KEY, mergeVersionOverrides, RequestContext };
|