@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,322 +0,0 @@
|
|
|
1
|
-
import"./chunk-z6n9thea.mjs";
|
|
2
|
-
import"./chunk-3wvjs93w.mjs";
|
|
3
|
-
import"./chunk-c1631s2x.mjs";
|
|
4
|
-
import"./chunk-50sbrf09.mjs";
|
|
5
|
-
import {
|
|
6
|
-
resolveSuspendedToolRunId
|
|
7
|
-
} from "./chunk-3m7jn5ac.mjs";
|
|
8
|
-
import {
|
|
9
|
-
BACKGROUND_TASK_WORKFLOW_ID
|
|
10
|
-
} from "./chunk-6kgqw9ny.mjs";
|
|
11
|
-
import {
|
|
12
|
-
createStep$1,
|
|
13
|
-
createWorkflow
|
|
14
|
-
} from "./chunk-ageqxj9v.mjs";
|
|
15
|
-
import {
|
|
16
|
-
string,
|
|
17
|
-
boolean,
|
|
18
|
-
any,
|
|
19
|
-
unknown,
|
|
20
|
-
object,
|
|
21
|
-
_enum
|
|
22
|
-
} from "./chunk-1sygmp11.mjs";
|
|
23
|
-
|
|
24
|
-
// node_modules/.bun/@mastra+core@1.71.0+95d98e20cbc6e6e1/node_modules/@mastra/core/dist/workflow-DLhRNxEW.js
|
|
25
|
-
var inputSchema = object({ taskId: string() });
|
|
26
|
-
var attemptOutcomeSchema = _enum([
|
|
27
|
-
"success",
|
|
28
|
-
"retry",
|
|
29
|
-
"failed",
|
|
30
|
-
"cancelled",
|
|
31
|
-
"timed_out"
|
|
32
|
-
]);
|
|
33
|
-
var attemptOutputSchema = object({
|
|
34
|
-
taskId: string(),
|
|
35
|
-
outcome: attemptOutcomeSchema,
|
|
36
|
-
result: unknown().optional(),
|
|
37
|
-
error: any().optional()
|
|
38
|
-
});
|
|
39
|
-
var bodyIOSchema = object({
|
|
40
|
-
taskId: string(),
|
|
41
|
-
done: boolean().optional(),
|
|
42
|
-
result: unknown().optional()
|
|
43
|
-
});
|
|
44
|
-
var bodyOutputSchema = object({
|
|
45
|
-
taskId: string(),
|
|
46
|
-
done: boolean(),
|
|
47
|
-
result: unknown().optional()
|
|
48
|
-
});
|
|
49
|
-
var WORKFLOW_STATUS_TO_PERSIST = [
|
|
50
|
-
"suspended",
|
|
51
|
-
"pending",
|
|
52
|
-
"paused",
|
|
53
|
-
"waiting"
|
|
54
|
-
];
|
|
55
|
-
function buildBackgroundTaskWorkflow(manager) {
|
|
56
|
-
const runAttemptStep = createStep$1({
|
|
57
|
-
id: "run-attempt",
|
|
58
|
-
inputSchema: bodyIOSchema,
|
|
59
|
-
outputSchema: attemptOutputSchema,
|
|
60
|
-
execute: async ({ inputData, abortSignal: workflowAbortSignal, suspend, resumeData, suspendData }) => {
|
|
61
|
-
const { taskId } = inputData;
|
|
62
|
-
const storage = await manager.getStorage();
|
|
63
|
-
const task = await storage.getTask(taskId);
|
|
64
|
-
if (!task || task.status === "cancelled") {
|
|
65
|
-
manager.deregisterTaskContext(taskId);
|
|
66
|
-
return {
|
|
67
|
-
taskId,
|
|
68
|
-
outcome: "cancelled"
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const executor = manager.taskContexts.get(taskId)?.executor ?? (task.agentId ? manager.getStaticExecutor(`${task.agentId}:${task.toolName}`) : undefined) ?? manager.getStaticExecutor(task.toolName);
|
|
72
|
-
if (!executor) {
|
|
73
|
-
const errorInfo = { message: `No executor registered for tool "${task.toolName}". Register the tool on Mastra (so workers can resolve it cross-process) or run the task in the same process as the producer.` };
|
|
74
|
-
await storage.updateTask(taskId, {
|
|
75
|
-
status: "failed",
|
|
76
|
-
error: errorInfo,
|
|
77
|
-
completedAt: /* @__PURE__ */ new Date
|
|
78
|
-
});
|
|
79
|
-
const failedTask = await storage.getTask(taskId);
|
|
80
|
-
if (failedTask) {
|
|
81
|
-
await manager.runLocalCompletionHooks(failedTask, "failed", { error: errorInfo });
|
|
82
|
-
await manager.publishLifecycleEvent("task.failed", failedTask);
|
|
83
|
-
}
|
|
84
|
-
manager.deregisterTaskContext(taskId);
|
|
85
|
-
throw new Error(errorInfo.message);
|
|
86
|
-
}
|
|
87
|
-
const progressThrottleMs = manager.config.progressThrottleMs;
|
|
88
|
-
const shouldThrottleProgress = typeof progressThrottleMs === "number" && Number.isFinite(progressThrottleMs) && progressThrottleMs > 0;
|
|
89
|
-
let lastProgressEmitMs;
|
|
90
|
-
const onProgress = async (chunk) => {
|
|
91
|
-
if (shouldThrottleProgress) {
|
|
92
|
-
const now = Date.now();
|
|
93
|
-
if (lastProgressEmitMs !== undefined && now - lastProgressEmitMs < progressThrottleMs)
|
|
94
|
-
return;
|
|
95
|
-
lastProgressEmitMs = now;
|
|
96
|
-
}
|
|
97
|
-
await manager.publishLifecycleEvent("task.output", {
|
|
98
|
-
...task,
|
|
99
|
-
chunk
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const abortController = new AbortController;
|
|
103
|
-
if (!manager.registerActiveAbortController(taskId, abortController)) {
|
|
104
|
-
manager.deregisterTaskContext(taskId);
|
|
105
|
-
return {
|
|
106
|
-
taskId,
|
|
107
|
-
outcome: "cancelled"
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const onWorkflowAbort = () => abortController.abort(/* @__PURE__ */ new Error("Task cancelled"));
|
|
111
|
-
if (workflowAbortSignal.aborted)
|
|
112
|
-
abortController.abort(/* @__PURE__ */ new Error("Task cancelled"));
|
|
113
|
-
else
|
|
114
|
-
workflowAbortSignal.addEventListener("abort", onWorkflowAbort, { once: true });
|
|
115
|
-
const timeoutHandle = setTimeout(() => {
|
|
116
|
-
abortController.abort(/* @__PURE__ */ new Error(`Task timed out after ${task.timeoutMs}ms`));
|
|
117
|
-
}, task.timeoutMs);
|
|
118
|
-
let pendingSuspend;
|
|
119
|
-
const wrappedSuspend = async (data, suspendOptions) => {
|
|
120
|
-
await storage.updateTask(taskId, {
|
|
121
|
-
status: "suspended",
|
|
122
|
-
suspendPayload: data,
|
|
123
|
-
suspendedAt: /* @__PURE__ */ new Date
|
|
124
|
-
});
|
|
125
|
-
const suspendedTask = await storage.getTask(taskId);
|
|
126
|
-
if (suspendedTask) {
|
|
127
|
-
await manager.runLocalSuspendHooks(suspendedTask);
|
|
128
|
-
await manager.publishLifecycleEvent("task.suspended", suspendedTask);
|
|
129
|
-
}
|
|
130
|
-
pendingSuspend = {
|
|
131
|
-
data,
|
|
132
|
-
suspendOptions
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
try {
|
|
136
|
-
const args = { ...task.args };
|
|
137
|
-
delete args.suspendedToolRunId;
|
|
138
|
-
const suspendedToolRunId = resolveSuspendedToolRunId(suspendData?.suspendedToolRunId);
|
|
139
|
-
if (resumeData !== undefined && suspendedToolRunId)
|
|
140
|
-
args.suspendedToolRunId = suspendedToolRunId;
|
|
141
|
-
const result = await executor.execute(args, {
|
|
142
|
-
abortSignal: abortController.signal,
|
|
143
|
-
onProgress,
|
|
144
|
-
suspend: wrappedSuspend,
|
|
145
|
-
resumeData,
|
|
146
|
-
suspendedToolRunId: resumeData !== undefined ? suspendedToolRunId : undefined
|
|
147
|
-
});
|
|
148
|
-
if (pendingSuspend) {
|
|
149
|
-
const opts = pendingSuspend.suspendOptions;
|
|
150
|
-
const agentRunId = opts?.isAgentSuspend && typeof opts.runId === "string" ? opts.runId : undefined;
|
|
151
|
-
return suspend(!agentRunId ? pendingSuspend.data : pendingSuspend.data && typeof pendingSuspend.data === "object" ? {
|
|
152
|
-
...pendingSuspend.data,
|
|
153
|
-
suspendedToolRunId: agentRunId
|
|
154
|
-
} : { suspendedToolRunId: agentRunId }, opts);
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
taskId,
|
|
158
|
-
outcome: "success",
|
|
159
|
-
result
|
|
160
|
-
};
|
|
161
|
-
} catch (error) {
|
|
162
|
-
const currentTask = await storage.getTask(taskId);
|
|
163
|
-
if (!currentTask || currentTask.status === "cancelled") {
|
|
164
|
-
manager.deregisterTaskContext(taskId);
|
|
165
|
-
return {
|
|
166
|
-
taskId,
|
|
167
|
-
outcome: "cancelled"
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if (manager.isShuttingDown()) {
|
|
171
|
-
manager.deregisterTaskContext(taskId);
|
|
172
|
-
return {
|
|
173
|
-
taskId,
|
|
174
|
-
outcome: "cancelled"
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
if (abortController.signal.aborted || error?.name === "AbortError" || error?.message === "Task cancelled" || error?.message?.startsWith("Task timed out after "))
|
|
178
|
-
return {
|
|
179
|
-
taskId,
|
|
180
|
-
outcome: "timed_out"
|
|
181
|
-
};
|
|
182
|
-
if (error?.name === "FGADeniedError")
|
|
183
|
-
return {
|
|
184
|
-
taskId,
|
|
185
|
-
outcome: "failed",
|
|
186
|
-
error: {
|
|
187
|
-
name: error.name,
|
|
188
|
-
message: error?.message ?? "Authorization denied",
|
|
189
|
-
stack: error?.stack
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
return {
|
|
193
|
-
taskId,
|
|
194
|
-
outcome: "retry",
|
|
195
|
-
error: {
|
|
196
|
-
message: error?.message ?? "Unknown error",
|
|
197
|
-
stack: error?.stack
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
} finally {
|
|
201
|
-
clearTimeout(timeoutHandle);
|
|
202
|
-
workflowAbortSignal.removeEventListener("abort", onWorkflowAbort);
|
|
203
|
-
manager.activeAbortControllers.delete(taskId);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
const classifyOutcomeStep = createStep$1({
|
|
208
|
-
id: "classify-outcome",
|
|
209
|
-
inputSchema: attemptOutputSchema,
|
|
210
|
-
outputSchema: bodyOutputSchema,
|
|
211
|
-
execute: async ({ inputData }) => {
|
|
212
|
-
const { taskId, outcome, result, error } = inputData;
|
|
213
|
-
const storage = await manager.getStorage();
|
|
214
|
-
const task = await storage.getTask(taskId);
|
|
215
|
-
if (!task)
|
|
216
|
-
return {
|
|
217
|
-
taskId,
|
|
218
|
-
done: true
|
|
219
|
-
};
|
|
220
|
-
if (outcome === "cancelled") {
|
|
221
|
-
manager.deregisterTaskContext(taskId);
|
|
222
|
-
return {
|
|
223
|
-
taskId,
|
|
224
|
-
done: true
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
if (outcome === "timed_out") {
|
|
228
|
-
const status = task.status;
|
|
229
|
-
if (status !== "timed_out" && status !== "cancelled") {
|
|
230
|
-
await storage.updateTask(taskId, {
|
|
231
|
-
status: "timed_out",
|
|
232
|
-
error: { message: `Task timed out after ${task.timeoutMs}ms` },
|
|
233
|
-
completedAt: /* @__PURE__ */ new Date
|
|
234
|
-
});
|
|
235
|
-
const timedOutTask = await storage.getTask(taskId);
|
|
236
|
-
if (timedOutTask)
|
|
237
|
-
await manager.publishLifecycleEvent("task.failed", timedOutTask);
|
|
238
|
-
}
|
|
239
|
-
return {
|
|
240
|
-
taskId,
|
|
241
|
-
done: true
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
if (outcome === "success") {
|
|
245
|
-
if (task.status === "cancelled") {
|
|
246
|
-
manager.deregisterTaskContext(taskId);
|
|
247
|
-
return {
|
|
248
|
-
taskId,
|
|
249
|
-
done: true
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
await storage.updateTask(taskId, {
|
|
253
|
-
status: "completed",
|
|
254
|
-
result,
|
|
255
|
-
completedAt: /* @__PURE__ */ new Date
|
|
256
|
-
});
|
|
257
|
-
const completedTask = await storage.getTask(taskId);
|
|
258
|
-
if (completedTask) {
|
|
259
|
-
await manager.runLocalCompletionHooks(completedTask, "completed", { result });
|
|
260
|
-
await manager.publishLifecycleEvent("task.completed", completedTask);
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
taskId,
|
|
264
|
-
done: true,
|
|
265
|
-
result
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
if (outcome === "retry" && task.retryCount < task.maxRetries) {
|
|
269
|
-
await storage.updateTask(taskId, {
|
|
270
|
-
retryCount: task.retryCount + 1,
|
|
271
|
-
error: undefined,
|
|
272
|
-
startedAt: /* @__PURE__ */ new Date
|
|
273
|
-
});
|
|
274
|
-
return {
|
|
275
|
-
taskId,
|
|
276
|
-
done: false
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
const errorInfo = error ?? { message: "Unknown error" };
|
|
280
|
-
await storage.updateTask(taskId, {
|
|
281
|
-
status: "failed",
|
|
282
|
-
error: errorInfo,
|
|
283
|
-
completedAt: /* @__PURE__ */ new Date
|
|
284
|
-
});
|
|
285
|
-
const failedTask = await storage.getTask(taskId);
|
|
286
|
-
if (failedTask) {
|
|
287
|
-
await manager.runLocalCompletionHooks(failedTask, "failed", { error: errorInfo });
|
|
288
|
-
await manager.publishLifecycleEvent("task.failed", failedTask);
|
|
289
|
-
}
|
|
290
|
-
const thrown = new Error(errorInfo.message);
|
|
291
|
-
if (errorInfo.name)
|
|
292
|
-
thrown.name = errorInfo.name;
|
|
293
|
-
if (errorInfo.stack)
|
|
294
|
-
thrown.stack = errorInfo.stack;
|
|
295
|
-
throw thrown;
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
const attemptBodyWorkflow = createWorkflow({
|
|
299
|
-
id: `${BACKGROUND_TASK_WORKFLOW_ID}__attempt`,
|
|
300
|
-
inputSchema: bodyIOSchema,
|
|
301
|
-
outputSchema: bodyOutputSchema,
|
|
302
|
-
steps: [runAttemptStep, classifyOutcomeStep],
|
|
303
|
-
options: {
|
|
304
|
-
validateInputs: false,
|
|
305
|
-
shouldPersistSnapshot: ({ workflowStatus }) => WORKFLOW_STATUS_TO_PERSIST.includes(workflowStatus),
|
|
306
|
-
tracingPolicy: { internal: 1 }
|
|
307
|
-
}
|
|
308
|
-
}).then(runAttemptStep).then(classifyOutcomeStep).commit();
|
|
309
|
-
return createWorkflow({
|
|
310
|
-
id: BACKGROUND_TASK_WORKFLOW_ID,
|
|
311
|
-
inputSchema,
|
|
312
|
-
outputSchema: bodyOutputSchema,
|
|
313
|
-
steps: [attemptBodyWorkflow],
|
|
314
|
-
options: {
|
|
315
|
-
shouldPersistSnapshot: ({ workflowStatus }) => WORKFLOW_STATUS_TO_PERSIST.includes(workflowStatus),
|
|
316
|
-
tracingPolicy: { internal: 1 }
|
|
317
|
-
}
|
|
318
|
-
}).dountil(attemptBodyWorkflow, async ({ inputData }) => inputData?.done === true).commit();
|
|
319
|
-
}
|
|
320
|
-
export {
|
|
321
|
-
buildBackgroundTaskWorkflow
|
|
322
|
-
};
|