@hasna/testers 0.0.34 → 0.0.35
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/dist/cli/index.js +1137 -1016
- package/dist/db/workflows.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +944 -190
- package/dist/lib/ai-client.d.ts +2 -0
- package/dist/lib/ai-client.d.ts.map +1 -1
- package/dist/lib/assertions.d.ts +4 -1
- package/dist/lib/assertions.d.ts.map +1 -1
- package/dist/lib/browser-compat.d.ts +14 -0
- package/dist/lib/browser-compat.d.ts.map +1 -0
- package/dist/lib/repo-discovery.d.ts.map +1 -1
- package/dist/lib/repo-executor.d.ts.map +1 -1
- package/dist/lib/runner.d.ts +29 -1
- package/dist/lib/runner.d.ts.map +1 -1
- package/dist/lib/workflow-runner.d.ts +73 -5
- package/dist/lib/workflow-runner.d.ts.map +1 -1
- package/dist/mcp/http.d.ts +1 -1
- package/dist/mcp/index.js +945 -819
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/server/index.js +897 -585
- package/dist/types/index.d.ts +23 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -6
package/dist/server/index.js
CHANGED
|
@@ -4036,6 +4036,56 @@ var init_zod = __esm(() => {
|
|
|
4036
4036
|
});
|
|
4037
4037
|
|
|
4038
4038
|
// src/types/index.ts
|
|
4039
|
+
function isRecord(value) {
|
|
4040
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4041
|
+
}
|
|
4042
|
+
function stringValue(value) {
|
|
4043
|
+
return typeof value === "string" && value.trim() ? value : undefined;
|
|
4044
|
+
}
|
|
4045
|
+
function numberValue(value) {
|
|
4046
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
4047
|
+
}
|
|
4048
|
+
function stringMap(value) {
|
|
4049
|
+
if (!isRecord(value))
|
|
4050
|
+
return;
|
|
4051
|
+
const entries = Object.entries(value).filter((entry) => typeof entry[1] === "string");
|
|
4052
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
4053
|
+
}
|
|
4054
|
+
function cleanupValue(value) {
|
|
4055
|
+
if (value === "delete" || value === "stop" || value === "keep")
|
|
4056
|
+
return value;
|
|
4057
|
+
return;
|
|
4058
|
+
}
|
|
4059
|
+
function workflowExecutionFromValue(value) {
|
|
4060
|
+
const input = isRecord(value) ? value : {};
|
|
4061
|
+
const rawTarget = stringValue(input["target"]) ?? "local";
|
|
4062
|
+
if (rawTarget === "local") {
|
|
4063
|
+
const timeoutMs2 = numberValue(input["timeoutMs"]);
|
|
4064
|
+
return timeoutMs2 === undefined ? { target: "local" } : { target: "local", timeoutMs: timeoutMs2 };
|
|
4065
|
+
}
|
|
4066
|
+
if (rawTarget !== "sandbox" && rawTarget !== "connector:e2b") {
|
|
4067
|
+
throw new Error(`Unsupported workflow execution target: ${rawTarget}`);
|
|
4068
|
+
}
|
|
4069
|
+
const provider = rawTarget === "connector:e2b" ? "e2b" : stringValue(input["provider"]) ?? stringValue(input["connector"]);
|
|
4070
|
+
const sandboxImage = stringValue(input["sandboxImage"]) ?? stringValue(input["sandboxTemplate"]);
|
|
4071
|
+
const sandboxRemoteDir = stringValue(input["sandboxRemoteDir"]);
|
|
4072
|
+
const sandboxCleanup = cleanupValue(input["sandboxCleanup"]);
|
|
4073
|
+
const setupCommand = stringValue(input["setupCommand"]);
|
|
4074
|
+
const packageSpec = stringValue(input["packageSpec"]);
|
|
4075
|
+
const timeoutMs = numberValue(input["timeoutMs"]);
|
|
4076
|
+
const env = stringMap(input["env"]);
|
|
4077
|
+
return {
|
|
4078
|
+
target: "sandbox",
|
|
4079
|
+
...provider ? { provider } : {},
|
|
4080
|
+
...sandboxImage ? { sandboxImage } : {},
|
|
4081
|
+
...sandboxRemoteDir ? { sandboxRemoteDir } : {},
|
|
4082
|
+
...sandboxCleanup ? { sandboxCleanup } : {},
|
|
4083
|
+
...setupCommand ? { setupCommand } : {},
|
|
4084
|
+
...packageSpec ? { packageSpec } : {},
|
|
4085
|
+
...timeoutMs !== undefined ? { timeoutMs } : {},
|
|
4086
|
+
...env ? { env } : {}
|
|
4087
|
+
};
|
|
4088
|
+
}
|
|
4039
4089
|
function workflowFromRow(row) {
|
|
4040
4090
|
return {
|
|
4041
4091
|
id: row.id,
|
|
@@ -4045,7 +4095,7 @@ function workflowFromRow(row) {
|
|
|
4045
4095
|
scenarioFilter: JSON.parse(row.scenario_filter || "{}"),
|
|
4046
4096
|
personaIds: JSON.parse(row.persona_ids || "[]"),
|
|
4047
4097
|
goal: row.goal ? JSON.parse(row.goal) : null,
|
|
4048
|
-
execution: JSON.parse(row.execution || '{"target":"local"}'),
|
|
4098
|
+
execution: workflowExecutionFromValue(JSON.parse(row.execution || '{"target":"local"}')),
|
|
4049
4099
|
settings: JSON.parse(row.settings || "{}"),
|
|
4050
4100
|
enabled: row.enabled === 1,
|
|
4051
4101
|
createdAt: row.created_at,
|
|
@@ -8582,33 +8632,33 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
8582
8632
|
this.ssl = config.ssl || false;
|
|
8583
8633
|
this._ending = false;
|
|
8584
8634
|
this._emitMessage = false;
|
|
8585
|
-
const
|
|
8635
|
+
const self = this;
|
|
8586
8636
|
this.on("newListener", function(eventName) {
|
|
8587
8637
|
if (eventName === "message") {
|
|
8588
|
-
|
|
8638
|
+
self._emitMessage = true;
|
|
8589
8639
|
}
|
|
8590
8640
|
});
|
|
8591
8641
|
}
|
|
8592
8642
|
connect(port, host) {
|
|
8593
|
-
const
|
|
8643
|
+
const self = this;
|
|
8594
8644
|
this._connecting = true;
|
|
8595
8645
|
this.stream.setNoDelay(true);
|
|
8596
8646
|
this.stream.connect(port, host);
|
|
8597
8647
|
this.stream.once("connect", function() {
|
|
8598
|
-
if (
|
|
8599
|
-
|
|
8648
|
+
if (self._keepAlive) {
|
|
8649
|
+
self.stream.setKeepAlive(true, self._keepAliveInitialDelayMillis);
|
|
8600
8650
|
}
|
|
8601
|
-
|
|
8651
|
+
self.emit("connect");
|
|
8602
8652
|
});
|
|
8603
8653
|
const reportStreamError = function(error) {
|
|
8604
|
-
if (
|
|
8654
|
+
if (self._ending && (error.code === "ECONNRESET" || error.code === "EPIPE")) {
|
|
8605
8655
|
return;
|
|
8606
8656
|
}
|
|
8607
|
-
|
|
8657
|
+
self.emit("error", error);
|
|
8608
8658
|
};
|
|
8609
8659
|
this.stream.on("error", reportStreamError);
|
|
8610
8660
|
this.stream.on("close", function() {
|
|
8611
|
-
|
|
8661
|
+
self.emit("end");
|
|
8612
8662
|
});
|
|
8613
8663
|
if (!this.ssl) {
|
|
8614
8664
|
return this.attachListeners(this.stream);
|
|
@@ -8619,19 +8669,19 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
8619
8669
|
case "S":
|
|
8620
8670
|
break;
|
|
8621
8671
|
case "N":
|
|
8622
|
-
|
|
8623
|
-
return
|
|
8672
|
+
self.stream.end();
|
|
8673
|
+
return self.emit("error", new Error("The server does not support SSL connections"));
|
|
8624
8674
|
default:
|
|
8625
|
-
|
|
8626
|
-
return
|
|
8675
|
+
self.stream.end();
|
|
8676
|
+
return self.emit("error", new Error("There was an error establishing an SSL connection"));
|
|
8627
8677
|
}
|
|
8628
8678
|
const options = {
|
|
8629
|
-
socket:
|
|
8679
|
+
socket: self.stream
|
|
8630
8680
|
};
|
|
8631
|
-
if (
|
|
8632
|
-
Object.assign(options,
|
|
8633
|
-
if ("key" in
|
|
8634
|
-
options.key =
|
|
8681
|
+
if (self.ssl !== true) {
|
|
8682
|
+
Object.assign(options, self.ssl);
|
|
8683
|
+
if ("key" in self.ssl) {
|
|
8684
|
+
options.key = self.ssl.key;
|
|
8635
8685
|
}
|
|
8636
8686
|
}
|
|
8637
8687
|
const net = __require2("net");
|
|
@@ -8639,13 +8689,13 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
8639
8689
|
options.servername = host;
|
|
8640
8690
|
}
|
|
8641
8691
|
try {
|
|
8642
|
-
|
|
8692
|
+
self.stream = getSecureStream(options);
|
|
8643
8693
|
} catch (err) {
|
|
8644
|
-
return
|
|
8694
|
+
return self.emit("error", err);
|
|
8645
8695
|
}
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8696
|
+
self.attachListeners(self.stream);
|
|
8697
|
+
self.stream.on("error", reportStreamError);
|
|
8698
|
+
self.emit("sslconnect");
|
|
8649
8699
|
});
|
|
8650
8700
|
}
|
|
8651
8701
|
attachListeners(stream) {
|
|
@@ -8780,9 +8830,9 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
8780
8830
|
}
|
|
8781
8831
|
cb();
|
|
8782
8832
|
}
|
|
8783
|
-
function push(
|
|
8833
|
+
function push(self, val) {
|
|
8784
8834
|
if (val !== undefined) {
|
|
8785
|
-
|
|
8835
|
+
self.push(val);
|
|
8786
8836
|
}
|
|
8787
8837
|
}
|
|
8788
8838
|
function noop(incoming) {
|
|
@@ -9102,7 +9152,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
9102
9152
|
this._queryQueue.length = 0;
|
|
9103
9153
|
}
|
|
9104
9154
|
_connect(callback) {
|
|
9105
|
-
const
|
|
9155
|
+
const self = this;
|
|
9106
9156
|
const con = this.connection;
|
|
9107
9157
|
this._connectionCallback = callback;
|
|
9108
9158
|
if (this._connecting || this._connected) {
|
|
@@ -9128,14 +9178,14 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
9128
9178
|
con.connect(this.port, this.host);
|
|
9129
9179
|
}
|
|
9130
9180
|
con.on("connect", function() {
|
|
9131
|
-
if (
|
|
9181
|
+
if (self.ssl) {
|
|
9132
9182
|
con.requestSsl();
|
|
9133
9183
|
} else {
|
|
9134
|
-
con.startup(
|
|
9184
|
+
con.startup(self.getStartupConf());
|
|
9135
9185
|
}
|
|
9136
9186
|
});
|
|
9137
9187
|
con.on("sslconnect", function() {
|
|
9138
|
-
con.startup(
|
|
9188
|
+
con.startup(self.getStartupConf());
|
|
9139
9189
|
});
|
|
9140
9190
|
this._attachListeners(con);
|
|
9141
9191
|
con.once("end", () => {
|
|
@@ -10067,34 +10117,34 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
10067
10117
|
};
|
|
10068
10118
|
NativeQuery.prototype.submit = function(client) {
|
|
10069
10119
|
this.state = "running";
|
|
10070
|
-
const
|
|
10120
|
+
const self = this;
|
|
10071
10121
|
this.native = client.native;
|
|
10072
10122
|
client.native.arrayMode = this._arrayMode;
|
|
10073
10123
|
let after = function(err, rows, results) {
|
|
10074
10124
|
client.native.arrayMode = false;
|
|
10075
10125
|
setImmediate(function() {
|
|
10076
|
-
|
|
10126
|
+
self.emit("_done");
|
|
10077
10127
|
});
|
|
10078
10128
|
if (err) {
|
|
10079
|
-
return
|
|
10129
|
+
return self.handleError(err);
|
|
10080
10130
|
}
|
|
10081
|
-
if (
|
|
10131
|
+
if (self._emitRowEvents) {
|
|
10082
10132
|
if (results.length > 1) {
|
|
10083
10133
|
rows.forEach((rowOfRows, i) => {
|
|
10084
10134
|
rowOfRows.forEach((row) => {
|
|
10085
|
-
|
|
10135
|
+
self.emit("row", row, results[i]);
|
|
10086
10136
|
});
|
|
10087
10137
|
});
|
|
10088
10138
|
} else {
|
|
10089
10139
|
rows.forEach(function(row) {
|
|
10090
|
-
|
|
10140
|
+
self.emit("row", row, results);
|
|
10091
10141
|
});
|
|
10092
10142
|
}
|
|
10093
10143
|
}
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
if (
|
|
10097
|
-
|
|
10144
|
+
self.state = "end";
|
|
10145
|
+
self.emit("end", results);
|
|
10146
|
+
if (self.callback) {
|
|
10147
|
+
self.callback(null, results);
|
|
10098
10148
|
}
|
|
10099
10149
|
};
|
|
10100
10150
|
if (process.domain) {
|
|
@@ -10117,8 +10167,8 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
10117
10167
|
return client.native.prepare(this.name, this.text, values.length, function(err) {
|
|
10118
10168
|
if (err)
|
|
10119
10169
|
return after(err);
|
|
10120
|
-
client.namedQueries[
|
|
10121
|
-
return
|
|
10170
|
+
client.namedQueries[self.name] = self.text;
|
|
10171
|
+
return self.native.execute(self.name, values, after);
|
|
10122
10172
|
});
|
|
10123
10173
|
} else if (this.values) {
|
|
10124
10174
|
if (!Array.isArray(this.values)) {
|
|
@@ -10195,36 +10245,36 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
10195
10245
|
this._queryQueue.length = 0;
|
|
10196
10246
|
};
|
|
10197
10247
|
Client.prototype._connect = function(cb) {
|
|
10198
|
-
const
|
|
10248
|
+
const self = this;
|
|
10199
10249
|
if (this._connecting) {
|
|
10200
10250
|
process.nextTick(() => cb(new Error("Client has already been connected. You cannot reuse a client.")));
|
|
10201
10251
|
return;
|
|
10202
10252
|
}
|
|
10203
10253
|
this._connecting = true;
|
|
10204
10254
|
this.connectionParameters.getLibpqConnectionString(function(err, conString) {
|
|
10205
|
-
if (
|
|
10206
|
-
conString =
|
|
10255
|
+
if (self.connectionParameters.nativeConnectionString)
|
|
10256
|
+
conString = self.connectionParameters.nativeConnectionString;
|
|
10207
10257
|
if (err)
|
|
10208
10258
|
return cb(err);
|
|
10209
|
-
|
|
10259
|
+
self.native.connect(conString, function(err2) {
|
|
10210
10260
|
if (err2) {
|
|
10211
|
-
|
|
10261
|
+
self.native.end();
|
|
10212
10262
|
return cb(err2);
|
|
10213
10263
|
}
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10264
|
+
self._connected = true;
|
|
10265
|
+
self.native.on("error", function(err3) {
|
|
10266
|
+
self._queryable = false;
|
|
10267
|
+
self._errorAllQueries(err3);
|
|
10268
|
+
self.emit("error", err3);
|
|
10219
10269
|
});
|
|
10220
|
-
|
|
10221
|
-
|
|
10270
|
+
self.native.on("notification", function(msg) {
|
|
10271
|
+
self.emit("notification", {
|
|
10222
10272
|
channel: msg.relname,
|
|
10223
10273
|
payload: msg.extra
|
|
10224
10274
|
});
|
|
10225
10275
|
});
|
|
10226
|
-
|
|
10227
|
-
|
|
10276
|
+
self.emit("connect");
|
|
10277
|
+
self._pulseQueryQueue(true);
|
|
10228
10278
|
cb(null, this);
|
|
10229
10279
|
});
|
|
10230
10280
|
});
|
|
@@ -10315,7 +10365,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
10315
10365
|
return result;
|
|
10316
10366
|
};
|
|
10317
10367
|
Client.prototype.end = function(cb) {
|
|
10318
|
-
const
|
|
10368
|
+
const self = this;
|
|
10319
10369
|
this._ending = true;
|
|
10320
10370
|
if (!this._connected) {
|
|
10321
10371
|
this.once("connect", this.end.bind(this, cb));
|
|
@@ -10327,10 +10377,10 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
10327
10377
|
});
|
|
10328
10378
|
}
|
|
10329
10379
|
this.native.end(function() {
|
|
10330
|
-
|
|
10331
|
-
|
|
10380
|
+
self._connected = false;
|
|
10381
|
+
self._errorAllQueries(new Error("Connection terminated"));
|
|
10332
10382
|
process.nextTick(() => {
|
|
10333
|
-
|
|
10383
|
+
self.emit("end");
|
|
10334
10384
|
if (cb)
|
|
10335
10385
|
cb();
|
|
10336
10386
|
});
|
|
@@ -10356,9 +10406,9 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
10356
10406
|
}
|
|
10357
10407
|
this._activeQuery = query;
|
|
10358
10408
|
query.submit(this);
|
|
10359
|
-
const
|
|
10409
|
+
const self = this;
|
|
10360
10410
|
query.once("_done", function() {
|
|
10361
|
-
|
|
10411
|
+
self._pulseQueryQueue();
|
|
10362
10412
|
});
|
|
10363
10413
|
};
|
|
10364
10414
|
Client.prototype.cancel = function(query) {
|
|
@@ -15811,7 +15861,6 @@ async function executeTool(page, screenshotter, toolName, toolInput, context) {
|
|
|
15811
15861
|
const assertionType = toolInput.assertion_type;
|
|
15812
15862
|
const selector = toolInput.selector;
|
|
15813
15863
|
const expected = toolInput.expected;
|
|
15814
|
-
const sessionId = context.sessionId ?? "default";
|
|
15815
15864
|
switch (assertionType) {
|
|
15816
15865
|
case "element_exists": {
|
|
15817
15866
|
if (!selector)
|
|
@@ -15876,7 +15925,6 @@ async function executeTool(page, screenshotter, toolName, toolInput, context) {
|
|
|
15876
15925
|
case "browser_intercept": {
|
|
15877
15926
|
const action = toolInput.action;
|
|
15878
15927
|
const pattern = toolInput.pattern;
|
|
15879
|
-
const interceptAction = toolInput.intercept_action;
|
|
15880
15928
|
const statusCode = toolInput.status_code;
|
|
15881
15929
|
const body = toolInput.body;
|
|
15882
15930
|
const sessionId = context.sessionId ?? "default";
|
|
@@ -15953,7 +16001,28 @@ ${JSON.stringify(har, null, 2)}` };
|
|
|
15953
16001
|
}
|
|
15954
16002
|
case "browser_a11y": {
|
|
15955
16003
|
const level = toolInput.level ?? "AA";
|
|
15956
|
-
const snapshot = await page.
|
|
16004
|
+
const snapshot = await page.evaluate(() => {
|
|
16005
|
+
function readRole(el) {
|
|
16006
|
+
return el.getAttribute("role") ?? el.tagName.toLowerCase();
|
|
16007
|
+
}
|
|
16008
|
+
function readName(el) {
|
|
16009
|
+
const labelledBy = el.getAttribute("aria-labelledby");
|
|
16010
|
+
if (labelledBy) {
|
|
16011
|
+
const labelledText = labelledBy.split(/\s+/).map((id) => document.getElementById(id)?.textContent?.trim()).filter(Boolean).join(" ");
|
|
16012
|
+
if (labelledText)
|
|
16013
|
+
return labelledText;
|
|
16014
|
+
}
|
|
16015
|
+
return el.getAttribute("aria-label") ?? el.getAttribute("alt") ?? el.textContent?.trim() ?? "";
|
|
16016
|
+
}
|
|
16017
|
+
function walk(el) {
|
|
16018
|
+
return {
|
|
16019
|
+
role: readRole(el),
|
|
16020
|
+
name: readName(el),
|
|
16021
|
+
children: Array.from(el.children).map((child) => walk(child))
|
|
16022
|
+
};
|
|
16023
|
+
}
|
|
16024
|
+
return document.body ? walk(document.body) : null;
|
|
16025
|
+
});
|
|
15957
16026
|
if (!snapshot)
|
|
15958
16027
|
return { result: "Error: could not capture accessibility tree" };
|
|
15959
16028
|
const issues = [];
|
|
@@ -15995,6 +16064,38 @@ ${filtered.join(`
|
|
|
15995
16064
|
return { result: `Error executing ${toolName}: ${message}` };
|
|
15996
16065
|
}
|
|
15997
16066
|
}
|
|
16067
|
+
function resolveStartUrl(baseUrl, targetPath) {
|
|
16068
|
+
try {
|
|
16069
|
+
return new URL(targetPath, baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`).toString();
|
|
16070
|
+
} catch {
|
|
16071
|
+
return `${baseUrl.replace(/\/+$/, "")}/${targetPath.replace(/^\/+/, "")}`;
|
|
16072
|
+
}
|
|
16073
|
+
}
|
|
16074
|
+
function buildScenarioUserMessage(scenario, baseUrl) {
|
|
16075
|
+
const userParts = [
|
|
16076
|
+
`**Scenario:** ${scenario.name}`,
|
|
16077
|
+
`**Description:** ${scenario.description}`
|
|
16078
|
+
];
|
|
16079
|
+
if (baseUrl) {
|
|
16080
|
+
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
|
|
16081
|
+
userParts.push(`**Base URL:** ${normalizedBaseUrl}`);
|
|
16082
|
+
if (scenario.targetPath) {
|
|
16083
|
+
userParts.push(`**Start URL:** ${resolveStartUrl(normalizedBaseUrl, scenario.targetPath)}`);
|
|
16084
|
+
}
|
|
16085
|
+
userParts.push("**Navigation Boundary:** Treat the Base URL as the application under test. Resolve relative paths and in-app navigation against this origin. Do not navigate to another host unless a step explicitly includes an absolute external URL.");
|
|
16086
|
+
}
|
|
16087
|
+
if (scenario.targetPath) {
|
|
16088
|
+
userParts.push(`**Target Path:** ${scenario.targetPath}`);
|
|
16089
|
+
}
|
|
16090
|
+
if (scenario.steps.length > 0) {
|
|
16091
|
+
userParts.push("**Steps:**");
|
|
16092
|
+
for (let i = 0;i < scenario.steps.length; i++) {
|
|
16093
|
+
userParts.push(`${i + 1}. ${scenario.steps[i]}`);
|
|
16094
|
+
}
|
|
16095
|
+
}
|
|
16096
|
+
return userParts.join(`
|
|
16097
|
+
`);
|
|
16098
|
+
}
|
|
15998
16099
|
async function runAgentLoop(options) {
|
|
15999
16100
|
const {
|
|
16000
16101
|
client,
|
|
@@ -16004,6 +16105,7 @@ async function runAgentLoop(options) {
|
|
|
16004
16105
|
model,
|
|
16005
16106
|
runId,
|
|
16006
16107
|
sessionId,
|
|
16108
|
+
baseUrl,
|
|
16007
16109
|
maxTurns = 30,
|
|
16008
16110
|
onStep,
|
|
16009
16111
|
persona,
|
|
@@ -16051,21 +16153,7 @@ Instructions: ${persona.instructions}` : "",
|
|
|
16051
16153
|
"- Verify both positive and negative states"
|
|
16052
16154
|
].join(`
|
|
16053
16155
|
`) + personaSection;
|
|
16054
|
-
const
|
|
16055
|
-
`**Scenario:** ${scenario.name}`,
|
|
16056
|
-
`**Description:** ${scenario.description}`
|
|
16057
|
-
];
|
|
16058
|
-
if (scenario.targetPath) {
|
|
16059
|
-
userParts.push(`**Target Path:** ${scenario.targetPath}`);
|
|
16060
|
-
}
|
|
16061
|
-
if (scenario.steps.length > 0) {
|
|
16062
|
-
userParts.push("**Steps:**");
|
|
16063
|
-
for (let i = 0;i < scenario.steps.length; i++) {
|
|
16064
|
-
userParts.push(`${i + 1}. ${scenario.steps[i]}`);
|
|
16065
|
-
}
|
|
16066
|
-
}
|
|
16067
|
-
const userMessage = userParts.join(`
|
|
16068
|
-
`);
|
|
16156
|
+
const userMessage = buildScenarioUserMessage(scenario, baseUrl);
|
|
16069
16157
|
const screenshots = [];
|
|
16070
16158
|
let tokensUsed = 0;
|
|
16071
16159
|
let stepNumber = 0;
|
|
@@ -16128,7 +16216,7 @@ Instructions: ${persona.instructions}` : "",
|
|
|
16128
16216
|
if (onStep) {
|
|
16129
16217
|
onStep({ type: "tool_call", toolName: toolBlock.name, toolInput, stepNumber });
|
|
16130
16218
|
}
|
|
16131
|
-
const execResult = await executeTool(page, screenshotter, toolBlock.name, toolInput, { runId, scenarioSlug, stepNumber, sessionId, a11y });
|
|
16219
|
+
const execResult = await executeTool(page, screenshotter, toolBlock.name, toolInput, { runId, scenarioSlug, stepNumber, sessionId: sessionId ?? runId, a11y });
|
|
16132
16220
|
if (onStep) {
|
|
16133
16221
|
onStep({ type: "tool_result", toolName: toolBlock.name, toolResult: execResult.result, stepNumber });
|
|
16134
16222
|
}
|
|
@@ -28623,34 +28711,27 @@ var init_v3 = __esm(() => {
|
|
|
28623
28711
|
|
|
28624
28712
|
// node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
|
|
28625
28713
|
function noop(_arg) {}
|
|
28626
|
-
function createParser(
|
|
28627
|
-
if (typeof
|
|
28628
|
-
throw new TypeError("`
|
|
28629
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment
|
|
28630
|
-
let
|
|
28714
|
+
function createParser(callbacks) {
|
|
28715
|
+
if (typeof callbacks == "function")
|
|
28716
|
+
throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
|
|
28717
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
|
|
28718
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
28631
28719
|
function feed(chunk) {
|
|
28632
|
-
if (terminated)
|
|
28633
|
-
throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
|
|
28634
28720
|
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
28635
28721
|
const trailing2 = processLines(chunk);
|
|
28636
|
-
trailing2 !== "" &&
|
|
28722
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
28637
28723
|
return;
|
|
28638
28724
|
}
|
|
28639
28725
|
if (chunk.indexOf(`
|
|
28640
28726
|
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
28641
|
-
pendingFragments.push(chunk)
|
|
28727
|
+
pendingFragments.push(chunk);
|
|
28642
28728
|
return;
|
|
28643
28729
|
}
|
|
28644
28730
|
pendingFragments.push(chunk);
|
|
28645
28731
|
const input = pendingFragments.join("");
|
|
28646
|
-
pendingFragments.length = 0
|
|
28732
|
+
pendingFragments.length = 0;
|
|
28647
28733
|
const trailing = processLines(input);
|
|
28648
|
-
trailing !== "" &&
|
|
28649
|
-
}
|
|
28650
|
-
function checkBufferSize() {
|
|
28651
|
-
maxBufferSize !== undefined && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = undefined, data = "", dataLines = 0, eventType = undefined, onError(new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
28652
|
-
type: "max-buffer-size-exceeded"
|
|
28653
|
-
}))));
|
|
28734
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
28654
28735
|
}
|
|
28655
28736
|
function processLines(chunk) {
|
|
28656
28737
|
let searchIndex = 0;
|
|
@@ -28762,7 +28843,7 @@ ${value}`, dataLines++;
|
|
|
28762
28843
|
const incompleteLine = pendingFragments.join("");
|
|
28763
28844
|
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
28764
28845
|
}
|
|
28765
|
-
isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0
|
|
28846
|
+
isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0;
|
|
28766
28847
|
}
|
|
28767
28848
|
return { feed, reset };
|
|
28768
28849
|
}
|
|
@@ -28786,7 +28867,7 @@ var EventSourceParserStream;
|
|
|
28786
28867
|
var init_stream = __esm(() => {
|
|
28787
28868
|
init_dist3();
|
|
28788
28869
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
28789
|
-
constructor({ onError, onRetry, onComment
|
|
28870
|
+
constructor({ onError, onRetry, onComment } = {}) {
|
|
28790
28871
|
let parser;
|
|
28791
28872
|
super({
|
|
28792
28873
|
start(controller) {
|
|
@@ -28795,11 +28876,10 @@ var init_stream = __esm(() => {
|
|
|
28795
28876
|
controller.enqueue(event);
|
|
28796
28877
|
},
|
|
28797
28878
|
onError(error40) {
|
|
28798
|
-
|
|
28879
|
+
onError === "terminate" ? controller.error(error40) : typeof onError == "function" && onError(error40);
|
|
28799
28880
|
},
|
|
28800
28881
|
onRetry,
|
|
28801
|
-
onComment
|
|
28802
|
-
maxBufferSize
|
|
28882
|
+
onComment
|
|
28803
28883
|
});
|
|
28804
28884
|
},
|
|
28805
28885
|
transform(chunk) {
|
|
@@ -30238,7 +30318,7 @@ var DelayedPromise = class {
|
|
|
30238
30318
|
});
|
|
30239
30319
|
}
|
|
30240
30320
|
return () => `${prefix}${separator}${generator()}`;
|
|
30241
|
-
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
30321
|
+
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.26", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
30242
30322
|
url: url2,
|
|
30243
30323
|
headers = {},
|
|
30244
30324
|
successfulResponseHandler,
|
|
@@ -32377,7 +32457,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
32377
32457
|
"ai-model-id": this.modelId
|
|
32378
32458
|
};
|
|
32379
32459
|
}
|
|
32380
|
-
}, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.
|
|
32460
|
+
}, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.110", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
32381
32461
|
var init_dist5 = __esm(() => {
|
|
32382
32462
|
init_dist4();
|
|
32383
32463
|
init_dist2();
|
|
@@ -32416,15 +32496,13 @@ var init_dist5 = __esm(() => {
|
|
|
32416
32496
|
message,
|
|
32417
32497
|
statusCode = 500,
|
|
32418
32498
|
cause,
|
|
32419
|
-
generationId
|
|
32420
|
-
isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500)
|
|
32499
|
+
generationId
|
|
32421
32500
|
}) {
|
|
32422
32501
|
super(generationId ? `${message} [${generationId}]` : message);
|
|
32423
32502
|
this[_a17] = true;
|
|
32424
32503
|
this.statusCode = statusCode;
|
|
32425
32504
|
this.cause = cause;
|
|
32426
32505
|
this.generationId = generationId;
|
|
32427
|
-
this.isRetryable = isRetryable;
|
|
32428
32506
|
}
|
|
32429
32507
|
static isInstance(error40) {
|
|
32430
32508
|
return _GatewayError.hasMarker(error40);
|
|
@@ -32947,11 +33025,62 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
32947
33025
|
gateway = createGatewayProvider();
|
|
32948
33026
|
});
|
|
32949
33027
|
|
|
33028
|
+
// node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
33029
|
+
var require_globalThis = __commonJS((exports) => {
|
|
33030
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33031
|
+
exports._globalThis = undefined;
|
|
33032
|
+
exports._globalThis = typeof globalThis === "object" ? globalThis : global;
|
|
33033
|
+
});
|
|
33034
|
+
|
|
33035
|
+
// node_modules/@opentelemetry/api/build/src/platform/node/index.js
|
|
33036
|
+
var require_node = __commonJS((exports) => {
|
|
33037
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
33038
|
+
if (k2 === undefined)
|
|
33039
|
+
k2 = k;
|
|
33040
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
33041
|
+
return m[k];
|
|
33042
|
+
} });
|
|
33043
|
+
} : function(o, m, k, k2) {
|
|
33044
|
+
if (k2 === undefined)
|
|
33045
|
+
k2 = k;
|
|
33046
|
+
o[k2] = m[k];
|
|
33047
|
+
});
|
|
33048
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
33049
|
+
for (var p in m)
|
|
33050
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
33051
|
+
__createBinding(exports2, m, p);
|
|
33052
|
+
};
|
|
33053
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33054
|
+
__exportStar(require_globalThis(), exports);
|
|
33055
|
+
});
|
|
33056
|
+
|
|
33057
|
+
// node_modules/@opentelemetry/api/build/src/platform/index.js
|
|
33058
|
+
var require_platform = __commonJS((exports) => {
|
|
33059
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
33060
|
+
if (k2 === undefined)
|
|
33061
|
+
k2 = k;
|
|
33062
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
33063
|
+
return m[k];
|
|
33064
|
+
} });
|
|
33065
|
+
} : function(o, m, k, k2) {
|
|
33066
|
+
if (k2 === undefined)
|
|
33067
|
+
k2 = k;
|
|
33068
|
+
o[k2] = m[k];
|
|
33069
|
+
});
|
|
33070
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
33071
|
+
for (var p in m)
|
|
33072
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
33073
|
+
__createBinding(exports2, m, p);
|
|
33074
|
+
};
|
|
33075
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33076
|
+
__exportStar(require_node(), exports);
|
|
33077
|
+
});
|
|
33078
|
+
|
|
32950
33079
|
// node_modules/@opentelemetry/api/build/src/version.js
|
|
32951
33080
|
var require_version = __commonJS((exports) => {
|
|
32952
33081
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32953
33082
|
exports.VERSION = undefined;
|
|
32954
|
-
exports.VERSION = "1.9.
|
|
33083
|
+
exports.VERSION = "1.9.0";
|
|
32955
33084
|
});
|
|
32956
33085
|
|
|
32957
33086
|
// node_modules/@opentelemetry/api/build/src/internal/semver.js
|
|
@@ -33029,11 +33158,12 @@ var require_semver = __commonJS((exports) => {
|
|
|
33029
33158
|
var require_global_utils = __commonJS((exports) => {
|
|
33030
33159
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33031
33160
|
exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
|
|
33161
|
+
var platform_1 = require_platform();
|
|
33032
33162
|
var version_1 = require_version();
|
|
33033
33163
|
var semver_1 = require_semver();
|
|
33034
33164
|
var major = version_1.VERSION.split(".")[0];
|
|
33035
33165
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
|
|
33036
|
-
var _global =
|
|
33166
|
+
var _global = platform_1._globalThis;
|
|
33037
33167
|
function registerGlobal(type, instance, diag, allowOverride = false) {
|
|
33038
33168
|
var _a16;
|
|
33039
33169
|
const api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a16 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a16 !== undefined ? _a16 : {
|
|
@@ -33105,7 +33235,8 @@ var require_ComponentLogger = __commonJS((exports) => {
|
|
|
33105
33235
|
if (!logger) {
|
|
33106
33236
|
return;
|
|
33107
33237
|
}
|
|
33108
|
-
|
|
33238
|
+
args.unshift(namespace);
|
|
33239
|
+
return logger[funcName](...args);
|
|
33109
33240
|
}
|
|
33110
33241
|
});
|
|
33111
33242
|
|
|
@@ -33166,12 +33297,6 @@ var require_diag = __commonJS((exports) => {
|
|
|
33166
33297
|
var API_NAME = "diag";
|
|
33167
33298
|
|
|
33168
33299
|
class DiagAPI {
|
|
33169
|
-
static instance() {
|
|
33170
|
-
if (!this._instance) {
|
|
33171
|
-
this._instance = new DiagAPI;
|
|
33172
|
-
}
|
|
33173
|
-
return this._instance;
|
|
33174
|
-
}
|
|
33175
33300
|
constructor() {
|
|
33176
33301
|
function _logProxy(funcName) {
|
|
33177
33302
|
return function(...args) {
|
|
@@ -33181,12 +33306,12 @@ var require_diag = __commonJS((exports) => {
|
|
|
33181
33306
|
return logger[funcName](...args);
|
|
33182
33307
|
};
|
|
33183
33308
|
}
|
|
33184
|
-
const
|
|
33309
|
+
const self = this;
|
|
33185
33310
|
const setLogger = (logger, optionsOrLogLevel = { logLevel: types_1.DiagLogLevel.INFO }) => {
|
|
33186
33311
|
var _a16, _b16, _c;
|
|
33187
|
-
if (logger ===
|
|
33312
|
+
if (logger === self) {
|
|
33188
33313
|
const err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
33189
|
-
|
|
33314
|
+
self.error((_a16 = err.stack) !== null && _a16 !== undefined ? _a16 : err.message);
|
|
33190
33315
|
return false;
|
|
33191
33316
|
}
|
|
33192
33317
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -33201,20 +33326,26 @@ var require_diag = __commonJS((exports) => {
|
|
|
33201
33326
|
oldLogger.warn(`Current logger will be overwritten from ${stack}`);
|
|
33202
33327
|
newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
|
|
33203
33328
|
}
|
|
33204
|
-
return (0, global_utils_1.registerGlobal)("diag", newLogger,
|
|
33329
|
+
return (0, global_utils_1.registerGlobal)("diag", newLogger, self, true);
|
|
33205
33330
|
};
|
|
33206
|
-
|
|
33207
|
-
|
|
33208
|
-
(0, global_utils_1.unregisterGlobal)(API_NAME,
|
|
33331
|
+
self.setLogger = setLogger;
|
|
33332
|
+
self.disable = () => {
|
|
33333
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, self);
|
|
33209
33334
|
};
|
|
33210
|
-
|
|
33335
|
+
self.createComponentLogger = (options) => {
|
|
33211
33336
|
return new ComponentLogger_1.DiagComponentLogger(options);
|
|
33212
33337
|
};
|
|
33213
|
-
|
|
33214
|
-
|
|
33215
|
-
|
|
33216
|
-
|
|
33217
|
-
|
|
33338
|
+
self.verbose = _logProxy("verbose");
|
|
33339
|
+
self.debug = _logProxy("debug");
|
|
33340
|
+
self.info = _logProxy("info");
|
|
33341
|
+
self.warn = _logProxy("warn");
|
|
33342
|
+
self.error = _logProxy("error");
|
|
33343
|
+
}
|
|
33344
|
+
static instance() {
|
|
33345
|
+
if (!this._instance) {
|
|
33346
|
+
this._instance = new DiagAPI;
|
|
33347
|
+
}
|
|
33348
|
+
return this._instance;
|
|
33218
33349
|
}
|
|
33219
33350
|
}
|
|
33220
33351
|
exports.DiagAPI = DiagAPI;
|
|
@@ -33237,7 +33368,7 @@ var require_baggage_impl = __commonJS((exports) => {
|
|
|
33237
33368
|
return Object.assign({}, entry);
|
|
33238
33369
|
}
|
|
33239
33370
|
getAllEntries() {
|
|
33240
|
-
return Array.from(this._entries.entries());
|
|
33371
|
+
return Array.from(this._entries.entries()).map(([k, v]) => [k, v]);
|
|
33241
33372
|
}
|
|
33242
33373
|
setEntry(key, entry) {
|
|
33243
33374
|
const newBaggage = new BaggageImpl(this._entries);
|
|
@@ -33308,16 +33439,16 @@ var require_context = __commonJS((exports) => {
|
|
|
33308
33439
|
|
|
33309
33440
|
class BaseContext {
|
|
33310
33441
|
constructor(parentContext) {
|
|
33311
|
-
const
|
|
33312
|
-
|
|
33313
|
-
|
|
33314
|
-
|
|
33315
|
-
const context = new BaseContext(
|
|
33442
|
+
const self = this;
|
|
33443
|
+
self._currentContext = parentContext ? new Map(parentContext) : new Map;
|
|
33444
|
+
self.getValue = (key) => self._currentContext.get(key);
|
|
33445
|
+
self.setValue = (key, value) => {
|
|
33446
|
+
const context = new BaseContext(self._currentContext);
|
|
33316
33447
|
context._currentContext.set(key, value);
|
|
33317
33448
|
return context;
|
|
33318
33449
|
};
|
|
33319
|
-
|
|
33320
|
-
const context = new BaseContext(
|
|
33450
|
+
self.deleteValue = (key) => {
|
|
33451
|
+
const context = new BaseContext(self._currentContext);
|
|
33321
33452
|
context._currentContext.delete(key);
|
|
33322
33453
|
return context;
|
|
33323
33454
|
};
|
|
@@ -33329,7 +33460,7 @@ var require_context = __commonJS((exports) => {
|
|
|
33329
33460
|
// node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
|
|
33330
33461
|
var require_consoleLogger = __commonJS((exports) => {
|
|
33331
33462
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33332
|
-
exports.DiagConsoleLogger =
|
|
33463
|
+
exports.DiagConsoleLogger = undefined;
|
|
33333
33464
|
var consoleMap = [
|
|
33334
33465
|
{ n: "error", c: "error" },
|
|
33335
33466
|
{ n: "warn", c: "warn" },
|
|
@@ -33337,39 +33468,19 @@ var require_consoleLogger = __commonJS((exports) => {
|
|
|
33337
33468
|
{ n: "debug", c: "debug" },
|
|
33338
33469
|
{ n: "verbose", c: "trace" }
|
|
33339
33470
|
];
|
|
33340
|
-
exports._originalConsoleMethods = {};
|
|
33341
|
-
if (typeof console !== "undefined") {
|
|
33342
|
-
const keys = [
|
|
33343
|
-
"error",
|
|
33344
|
-
"warn",
|
|
33345
|
-
"info",
|
|
33346
|
-
"debug",
|
|
33347
|
-
"trace",
|
|
33348
|
-
"log"
|
|
33349
|
-
];
|
|
33350
|
-
for (const key of keys) {
|
|
33351
|
-
if (typeof console[key] === "function") {
|
|
33352
|
-
exports._originalConsoleMethods[key] = console[key];
|
|
33353
|
-
}
|
|
33354
|
-
}
|
|
33355
|
-
}
|
|
33356
33471
|
|
|
33357
33472
|
class DiagConsoleLogger {
|
|
33358
33473
|
constructor() {
|
|
33359
33474
|
function _consoleFunc(funcName) {
|
|
33360
33475
|
return function(...args) {
|
|
33361
|
-
|
|
33362
|
-
|
|
33363
|
-
theFunc = exports._originalConsoleMethods["log"];
|
|
33364
|
-
}
|
|
33365
|
-
if (typeof theFunc !== "function" && console) {
|
|
33366
|
-
theFunc = console[funcName];
|
|
33476
|
+
if (console) {
|
|
33477
|
+
let theFunc = console[funcName];
|
|
33367
33478
|
if (typeof theFunc !== "function") {
|
|
33368
33479
|
theFunc = console.log;
|
|
33369
33480
|
}
|
|
33370
|
-
|
|
33371
|
-
|
|
33372
|
-
|
|
33481
|
+
if (typeof theFunc === "function") {
|
|
33482
|
+
return theFunc.apply(console, args);
|
|
33483
|
+
}
|
|
33373
33484
|
}
|
|
33374
33485
|
};
|
|
33375
33486
|
}
|
|
@@ -33607,8 +33718,8 @@ var require_NonRecordingSpan = __commonJS((exports) => {
|
|
|
33607
33718
|
var invalid_span_constants_1 = require_invalid_span_constants();
|
|
33608
33719
|
|
|
33609
33720
|
class NonRecordingSpan {
|
|
33610
|
-
constructor(
|
|
33611
|
-
this._spanContext =
|
|
33721
|
+
constructor(_spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
|
|
33722
|
+
this._spanContext = _spanContext;
|
|
33612
33723
|
}
|
|
33613
33724
|
spanContext() {
|
|
33614
33725
|
return this._spanContext;
|
|
@@ -33684,126 +33795,14 @@ var require_spancontext_utils = __commonJS((exports) => {
|
|
|
33684
33795
|
exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
|
|
33685
33796
|
var invalid_span_constants_1 = require_invalid_span_constants();
|
|
33686
33797
|
var NonRecordingSpan_1 = require_NonRecordingSpan();
|
|
33687
|
-
var
|
|
33688
|
-
|
|
33689
|
-
0,
|
|
33690
|
-
0,
|
|
33691
|
-
0,
|
|
33692
|
-
0,
|
|
33693
|
-
0,
|
|
33694
|
-
0,
|
|
33695
|
-
0,
|
|
33696
|
-
0,
|
|
33697
|
-
0,
|
|
33698
|
-
0,
|
|
33699
|
-
0,
|
|
33700
|
-
0,
|
|
33701
|
-
0,
|
|
33702
|
-
0,
|
|
33703
|
-
0,
|
|
33704
|
-
0,
|
|
33705
|
-
0,
|
|
33706
|
-
0,
|
|
33707
|
-
0,
|
|
33708
|
-
0,
|
|
33709
|
-
0,
|
|
33710
|
-
0,
|
|
33711
|
-
0,
|
|
33712
|
-
0,
|
|
33713
|
-
0,
|
|
33714
|
-
0,
|
|
33715
|
-
0,
|
|
33716
|
-
0,
|
|
33717
|
-
0,
|
|
33718
|
-
0,
|
|
33719
|
-
0,
|
|
33720
|
-
0,
|
|
33721
|
-
0,
|
|
33722
|
-
0,
|
|
33723
|
-
0,
|
|
33724
|
-
0,
|
|
33725
|
-
0,
|
|
33726
|
-
0,
|
|
33727
|
-
0,
|
|
33728
|
-
0,
|
|
33729
|
-
0,
|
|
33730
|
-
0,
|
|
33731
|
-
0,
|
|
33732
|
-
0,
|
|
33733
|
-
0,
|
|
33734
|
-
0,
|
|
33735
|
-
0,
|
|
33736
|
-
1,
|
|
33737
|
-
1,
|
|
33738
|
-
1,
|
|
33739
|
-
1,
|
|
33740
|
-
1,
|
|
33741
|
-
1,
|
|
33742
|
-
1,
|
|
33743
|
-
1,
|
|
33744
|
-
1,
|
|
33745
|
-
1,
|
|
33746
|
-
0,
|
|
33747
|
-
0,
|
|
33748
|
-
0,
|
|
33749
|
-
0,
|
|
33750
|
-
0,
|
|
33751
|
-
0,
|
|
33752
|
-
0,
|
|
33753
|
-
1,
|
|
33754
|
-
1,
|
|
33755
|
-
1,
|
|
33756
|
-
1,
|
|
33757
|
-
1,
|
|
33758
|
-
1,
|
|
33759
|
-
0,
|
|
33760
|
-
0,
|
|
33761
|
-
0,
|
|
33762
|
-
0,
|
|
33763
|
-
0,
|
|
33764
|
-
0,
|
|
33765
|
-
0,
|
|
33766
|
-
0,
|
|
33767
|
-
0,
|
|
33768
|
-
0,
|
|
33769
|
-
0,
|
|
33770
|
-
0,
|
|
33771
|
-
0,
|
|
33772
|
-
0,
|
|
33773
|
-
0,
|
|
33774
|
-
0,
|
|
33775
|
-
0,
|
|
33776
|
-
0,
|
|
33777
|
-
0,
|
|
33778
|
-
0,
|
|
33779
|
-
0,
|
|
33780
|
-
0,
|
|
33781
|
-
0,
|
|
33782
|
-
0,
|
|
33783
|
-
0,
|
|
33784
|
-
0,
|
|
33785
|
-
1,
|
|
33786
|
-
1,
|
|
33787
|
-
1,
|
|
33788
|
-
1,
|
|
33789
|
-
1,
|
|
33790
|
-
1
|
|
33791
|
-
]);
|
|
33792
|
-
function isValidHex(id, length) {
|
|
33793
|
-
if (typeof id !== "string" || id.length !== length)
|
|
33794
|
-
return false;
|
|
33795
|
-
let r = 0;
|
|
33796
|
-
for (let i = 0;i < id.length; i += 4) {
|
|
33797
|
-
r += (isHex[id.charCodeAt(i)] | 0) + (isHex[id.charCodeAt(i + 1)] | 0) + (isHex[id.charCodeAt(i + 2)] | 0) + (isHex[id.charCodeAt(i + 3)] | 0);
|
|
33798
|
-
}
|
|
33799
|
-
return r === length;
|
|
33800
|
-
}
|
|
33798
|
+
var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
|
|
33799
|
+
var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
|
|
33801
33800
|
function isValidTraceId(traceId) {
|
|
33802
|
-
return
|
|
33801
|
+
return VALID_TRACEID_REGEX.test(traceId) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
|
|
33803
33802
|
}
|
|
33804
33803
|
exports.isValidTraceId = isValidTraceId;
|
|
33805
33804
|
function isValidSpanId(spanId) {
|
|
33806
|
-
return
|
|
33805
|
+
return VALID_SPANID_REGEX.test(spanId) && spanId !== invalid_span_constants_1.INVALID_SPANID;
|
|
33807
33806
|
}
|
|
33808
33807
|
exports.isValidSpanId = isValidSpanId;
|
|
33809
33808
|
function isSpanContextValid(spanContext) {
|
|
@@ -33863,7 +33862,7 @@ var require_NoopTracer = __commonJS((exports) => {
|
|
|
33863
33862
|
}
|
|
33864
33863
|
exports.NoopTracer = NoopTracer;
|
|
33865
33864
|
function isSpanContext(spanContext) {
|
|
33866
|
-
return
|
|
33865
|
+
return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
|
|
33867
33866
|
}
|
|
33868
33867
|
});
|
|
33869
33868
|
|
|
@@ -33875,8 +33874,8 @@ var require_ProxyTracer = __commonJS((exports) => {
|
|
|
33875
33874
|
var NOOP_TRACER = new NoopTracer_1.NoopTracer;
|
|
33876
33875
|
|
|
33877
33876
|
class ProxyTracer {
|
|
33878
|
-
constructor(
|
|
33879
|
-
this._provider =
|
|
33877
|
+
constructor(_provider, name15, version2, options) {
|
|
33878
|
+
this._provider = _provider;
|
|
33880
33879
|
this.name = name15;
|
|
33881
33880
|
this.version = version2;
|
|
33882
33881
|
this.options = options;
|
|
@@ -34036,7 +34035,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
34036
34035
|
return this._internalState.get(key);
|
|
34037
34036
|
}
|
|
34038
34037
|
serialize() {
|
|
34039
|
-
return
|
|
34038
|
+
return this._keys().reduce((agg, key) => {
|
|
34040
34039
|
agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
|
|
34041
34040
|
return agg;
|
|
34042
34041
|
}, []).join(LIST_MEMBERS_SEPARATOR);
|
|
@@ -34044,7 +34043,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
34044
34043
|
_parse(rawTraceState) {
|
|
34045
34044
|
if (rawTraceState.length > MAX_TRACE_STATE_LEN)
|
|
34046
34045
|
return;
|
|
34047
|
-
this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).
|
|
34046
|
+
this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce((agg, part) => {
|
|
34048
34047
|
const listMember = part.trim();
|
|
34049
34048
|
const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
|
|
34050
34049
|
if (i !== -1) {
|
|
@@ -35144,10 +35143,7 @@ function convertToLanguageModelMessage({
|
|
|
35144
35143
|
type: "tool-result",
|
|
35145
35144
|
toolCallId: part.toolCallId,
|
|
35146
35145
|
toolName: part.toolName,
|
|
35147
|
-
output: mapToolResultOutput(
|
|
35148
|
-
output: part.output,
|
|
35149
|
-
downloadedAssets
|
|
35150
|
-
}),
|
|
35146
|
+
output: mapToolResultOutput(part.output),
|
|
35151
35147
|
providerOptions
|
|
35152
35148
|
};
|
|
35153
35149
|
}
|
|
@@ -35166,10 +35162,7 @@ function convertToLanguageModelMessage({
|
|
|
35166
35162
|
type: "tool-result",
|
|
35167
35163
|
toolCallId: part.toolCallId,
|
|
35168
35164
|
toolName: part.toolName,
|
|
35169
|
-
output: mapToolResultOutput(
|
|
35170
|
-
output: part.output,
|
|
35171
|
-
downloadedAssets
|
|
35172
|
-
}),
|
|
35165
|
+
output: mapToolResultOutput(part.output),
|
|
35173
35166
|
providerOptions: part.providerOptions
|
|
35174
35167
|
};
|
|
35175
35168
|
}
|
|
@@ -35193,44 +35186,15 @@ function convertToLanguageModelMessage({
|
|
|
35193
35186
|
}
|
|
35194
35187
|
}
|
|
35195
35188
|
async function downloadAssets(messages, download2, supportedUrls) {
|
|
35196
|
-
|
|
35197
|
-
|
|
35198
|
-
|
|
35199
|
-
|
|
35200
|
-
|
|
35201
|
-
|
|
35202
|
-
|
|
35203
|
-
|
|
35204
|
-
mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
|
|
35205
|
-
});
|
|
35206
|
-
}
|
|
35207
|
-
}
|
|
35208
|
-
}
|
|
35209
|
-
if (message.role === "tool" || message.role === "assistant") {
|
|
35210
|
-
if (!Array.isArray(message.content)) {
|
|
35211
|
-
continue;
|
|
35212
|
-
}
|
|
35213
|
-
for (const part of message.content) {
|
|
35214
|
-
if (part.type !== "tool-result") {
|
|
35215
|
-
continue;
|
|
35216
|
-
}
|
|
35217
|
-
if (part.output.type !== "content") {
|
|
35218
|
-
continue;
|
|
35219
|
-
}
|
|
35220
|
-
for (const contentPart of part.output.value) {
|
|
35221
|
-
if (contentPart.type === "image-url" || contentPart.type === "file-url") {
|
|
35222
|
-
downloadableFiles.push({
|
|
35223
|
-
data: new URL(contentPart.url),
|
|
35224
|
-
mediaType: contentPart.type === "image-url" ? "image/*" : undefined
|
|
35225
|
-
});
|
|
35226
|
-
}
|
|
35227
|
-
}
|
|
35228
|
-
}
|
|
35189
|
+
const plannedDownloads = messages.filter((message) => message.role === "user").map((message) => message.content).filter((content) => Array.isArray(content)).flat().filter((part) => part.type === "image" || part.type === "file").map((part) => {
|
|
35190
|
+
var _a21;
|
|
35191
|
+
const mediaType = (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined;
|
|
35192
|
+
let data = part.type === "image" ? part.image : part.data;
|
|
35193
|
+
if (typeof data === "string") {
|
|
35194
|
+
try {
|
|
35195
|
+
data = new URL(data);
|
|
35196
|
+
} catch (ignored) {}
|
|
35229
35197
|
}
|
|
35230
|
-
}
|
|
35231
|
-
const plannedDownloads = downloadableFiles.map((part) => {
|
|
35232
|
-
const mediaType = part.mediaType;
|
|
35233
|
-
const { data } = convertToLanguageModelV3DataContent(part.data);
|
|
35234
35198
|
return { mediaType, data };
|
|
35235
35199
|
}).filter((part) => part.data instanceof URL).map((part) => ({
|
|
35236
35200
|
url: part.data,
|
|
@@ -35304,41 +35268,13 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
|
35304
35268
|
}
|
|
35305
35269
|
}
|
|
35306
35270
|
}
|
|
35307
|
-
function mapToolResultOutput({
|
|
35308
|
-
output,
|
|
35309
|
-
downloadedAssets
|
|
35310
|
-
}) {
|
|
35271
|
+
function mapToolResultOutput(output) {
|
|
35311
35272
|
if (output.type !== "content") {
|
|
35312
35273
|
return output;
|
|
35313
35274
|
}
|
|
35314
35275
|
return {
|
|
35315
35276
|
type: "content",
|
|
35316
35277
|
value: output.value.map((item) => {
|
|
35317
|
-
var _a21, _b16;
|
|
35318
|
-
if (item.type === "image-url") {
|
|
35319
|
-
const downloadedFile = downloadedAssets[new URL(item.url).toString()];
|
|
35320
|
-
if (downloadedFile) {
|
|
35321
|
-
return {
|
|
35322
|
-
type: "image-data",
|
|
35323
|
-
data: convertDataContentToBase64String(downloadedFile.data),
|
|
35324
|
-
mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
|
|
35325
|
-
providerOptions: item.providerOptions
|
|
35326
|
-
};
|
|
35327
|
-
}
|
|
35328
|
-
return item;
|
|
35329
|
-
}
|
|
35330
|
-
if (item.type === "file-url") {
|
|
35331
|
-
const downloadedFile = downloadedAssets[new URL(item.url).toString()];
|
|
35332
|
-
if (downloadedFile) {
|
|
35333
|
-
return {
|
|
35334
|
-
type: "file-data",
|
|
35335
|
-
data: convertDataContentToBase64String(downloadedFile.data),
|
|
35336
|
-
mediaType: (_b16 = downloadedFile.mediaType) != null ? _b16 : "application/octet-stream",
|
|
35337
|
-
providerOptions: item.providerOptions
|
|
35338
|
-
};
|
|
35339
|
-
}
|
|
35340
|
-
return item;
|
|
35341
|
-
}
|
|
35342
35278
|
if (item.type !== "media") {
|
|
35343
35279
|
return item;
|
|
35344
35280
|
}
|
|
@@ -35891,7 +35827,7 @@ function getRetryDelayInMs({
|
|
|
35891
35827
|
error: error40,
|
|
35892
35828
|
exponentialBackoffDelay
|
|
35893
35829
|
}) {
|
|
35894
|
-
const headers =
|
|
35830
|
+
const headers = error40.responseHeaders;
|
|
35895
35831
|
if (!headers)
|
|
35896
35832
|
return exponentialBackoffDelay;
|
|
35897
35833
|
let ms;
|
|
@@ -35941,7 +35877,7 @@ async function _retryWithExponentialBackoff(f, {
|
|
|
35941
35877
|
errors: newErrors
|
|
35942
35878
|
});
|
|
35943
35879
|
}
|
|
35944
|
-
if (error40 instanceof Error &&
|
|
35880
|
+
if (error40 instanceof Error && APICallError.isInstance(error40) && error40.isRetryable === true && tryNumber <= maxRetries) {
|
|
35945
35881
|
await delay(getRetryDelayInMs({
|
|
35946
35882
|
error: error40,
|
|
35947
35883
|
exponentialBackoffDelay: delayInMs
|
|
@@ -36159,8 +36095,7 @@ async function executeToolCall({
|
|
|
36159
36095
|
input,
|
|
36160
36096
|
error: error40,
|
|
36161
36097
|
dynamic: tool2.type === "dynamic",
|
|
36162
|
-
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
36163
|
-
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
36098
|
+
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
36164
36099
|
};
|
|
36165
36100
|
}
|
|
36166
36101
|
const durationMs = now2() - startTime;
|
|
@@ -36190,8 +36125,7 @@ async function executeToolCall({
|
|
|
36190
36125
|
input,
|
|
36191
36126
|
output,
|
|
36192
36127
|
dynamic: tool2.type === "dynamic",
|
|
36193
|
-
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
36194
|
-
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
36128
|
+
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
36195
36129
|
};
|
|
36196
36130
|
}
|
|
36197
36131
|
});
|
|
@@ -36556,6 +36490,15 @@ async function parsePartialJson(jsonText) {
|
|
|
36556
36490
|
}
|
|
36557
36491
|
return { value: undefined, state: "failed-parse" };
|
|
36558
36492
|
}
|
|
36493
|
+
function mergeToolProviderMetadata(toolMetadata, callMetadata) {
|
|
36494
|
+
if (toolMetadata == null) {
|
|
36495
|
+
return callMetadata;
|
|
36496
|
+
}
|
|
36497
|
+
if (callMetadata == null) {
|
|
36498
|
+
return toolMetadata;
|
|
36499
|
+
}
|
|
36500
|
+
return { ...toolMetadata, ...callMetadata };
|
|
36501
|
+
}
|
|
36559
36502
|
async function parseToolCall({
|
|
36560
36503
|
toolCall,
|
|
36561
36504
|
tools,
|
|
@@ -36563,6 +36506,7 @@ async function parseToolCall({
|
|
|
36563
36506
|
system,
|
|
36564
36507
|
messages
|
|
36565
36508
|
}) {
|
|
36509
|
+
var _a21, _b16;
|
|
36566
36510
|
try {
|
|
36567
36511
|
if (tools == null) {
|
|
36568
36512
|
if (toolCall.providerExecuted && toolCall.dynamic) {
|
|
@@ -36603,7 +36547,6 @@ async function parseToolCall({
|
|
|
36603
36547
|
} catch (error40) {
|
|
36604
36548
|
const parsedInput = await safeParseJSON({ text: toolCall.input });
|
|
36605
36549
|
const input = parsedInput.success ? parsedInput.value : toolCall.input;
|
|
36606
|
-
const tool2 = tools == null ? undefined : tools[toolCall.toolName];
|
|
36607
36550
|
return {
|
|
36608
36551
|
type: "tool-call",
|
|
36609
36552
|
toolCallId: toolCall.toolCallId,
|
|
@@ -36612,10 +36555,9 @@ async function parseToolCall({
|
|
|
36612
36555
|
dynamic: true,
|
|
36613
36556
|
invalid: true,
|
|
36614
36557
|
error: error40,
|
|
36615
|
-
title:
|
|
36558
|
+
title: (_a21 = tools == null ? undefined : tools[toolCall.toolName]) == null ? undefined : _a21.title,
|
|
36616
36559
|
providerExecuted: toolCall.providerExecuted,
|
|
36617
|
-
providerMetadata: toolCall.providerMetadata,
|
|
36618
|
-
...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
|
|
36560
|
+
providerMetadata: mergeToolProviderMetadata((_b16 = tools == null ? undefined : tools[toolCall.toolName]) == null ? undefined : _b16.providerMetadata, toolCall.providerMetadata)
|
|
36619
36561
|
};
|
|
36620
36562
|
}
|
|
36621
36563
|
}
|
|
@@ -36662,14 +36604,14 @@ async function doParseToolCall({
|
|
|
36662
36604
|
cause: parseResult.error
|
|
36663
36605
|
});
|
|
36664
36606
|
}
|
|
36607
|
+
const mergedProviderMetadata = mergeToolProviderMetadata(tool2.providerMetadata, toolCall.providerMetadata);
|
|
36665
36608
|
return tool2.type === "dynamic" ? {
|
|
36666
36609
|
type: "tool-call",
|
|
36667
36610
|
toolCallId: toolCall.toolCallId,
|
|
36668
36611
|
toolName: toolCall.toolName,
|
|
36669
36612
|
input: parseResult.value,
|
|
36670
36613
|
providerExecuted: toolCall.providerExecuted,
|
|
36671
|
-
providerMetadata:
|
|
36672
|
-
...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
|
|
36614
|
+
providerMetadata: mergedProviderMetadata,
|
|
36673
36615
|
dynamic: true,
|
|
36674
36616
|
title: tool2.title
|
|
36675
36617
|
} : {
|
|
@@ -36678,8 +36620,7 @@ async function doParseToolCall({
|
|
|
36678
36620
|
toolName,
|
|
36679
36621
|
input: parseResult.value,
|
|
36680
36622
|
providerExecuted: toolCall.providerExecuted,
|
|
36681
|
-
providerMetadata:
|
|
36682
|
-
...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
|
|
36623
|
+
providerMetadata: mergedProviderMetadata,
|
|
36683
36624
|
title: tool2.title
|
|
36684
36625
|
};
|
|
36685
36626
|
}
|
|
@@ -37511,8 +37452,7 @@ function asContent({
|
|
|
37511
37452
|
error: part.result,
|
|
37512
37453
|
providerExecuted: true,
|
|
37513
37454
|
dynamic: part.dynamic,
|
|
37514
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37515
|
-
...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
|
|
37455
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37516
37456
|
});
|
|
37517
37457
|
} else {
|
|
37518
37458
|
contentParts.push({
|
|
@@ -37523,8 +37463,7 @@ function asContent({
|
|
|
37523
37463
|
output: part.result,
|
|
37524
37464
|
providerExecuted: true,
|
|
37525
37465
|
dynamic: part.dynamic,
|
|
37526
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37527
|
-
...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
|
|
37466
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37528
37467
|
});
|
|
37529
37468
|
}
|
|
37530
37469
|
break;
|
|
@@ -37538,8 +37477,7 @@ function asContent({
|
|
|
37538
37477
|
error: part.result,
|
|
37539
37478
|
providerExecuted: true,
|
|
37540
37479
|
dynamic: toolCall.dynamic,
|
|
37541
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37542
|
-
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
37480
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37543
37481
|
});
|
|
37544
37482
|
} else {
|
|
37545
37483
|
contentParts.push({
|
|
@@ -37550,8 +37488,7 @@ function asContent({
|
|
|
37550
37488
|
output: part.result,
|
|
37551
37489
|
providerExecuted: true,
|
|
37552
37490
|
dynamic: toolCall.dynamic,
|
|
37553
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37554
|
-
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
37491
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
37555
37492
|
});
|
|
37556
37493
|
}
|
|
37557
37494
|
break;
|
|
@@ -37765,9 +37702,6 @@ function processUIMessageStream({
|
|
|
37765
37702
|
if (options.title !== undefined) {
|
|
37766
37703
|
anyPart.title = options.title;
|
|
37767
37704
|
}
|
|
37768
|
-
if (options.toolMetadata !== undefined) {
|
|
37769
|
-
anyPart.toolMetadata = options.toolMetadata;
|
|
37770
|
-
}
|
|
37771
37705
|
anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
|
|
37772
37706
|
const providerMetadata = anyOptions.providerMetadata;
|
|
37773
37707
|
if (providerMetadata != null) {
|
|
@@ -37784,7 +37718,6 @@ function processUIMessageStream({
|
|
|
37784
37718
|
toolCallId: options.toolCallId,
|
|
37785
37719
|
state: options.state,
|
|
37786
37720
|
title: options.title,
|
|
37787
|
-
...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
|
|
37788
37721
|
input: anyOptions.input,
|
|
37789
37722
|
output: anyOptions.output,
|
|
37790
37723
|
rawInput: anyOptions.rawInput,
|
|
@@ -37812,9 +37745,6 @@ function processUIMessageStream({
|
|
|
37812
37745
|
if (options.title !== undefined) {
|
|
37813
37746
|
anyPart.title = options.title;
|
|
37814
37747
|
}
|
|
37815
|
-
if (options.toolMetadata !== undefined) {
|
|
37816
|
-
anyPart.toolMetadata = options.toolMetadata;
|
|
37817
|
-
}
|
|
37818
37748
|
anyPart.providerExecuted = (_b23 = anyOptions.providerExecuted) != null ? _b23 : part.providerExecuted;
|
|
37819
37749
|
const providerMetadata = anyOptions.providerMetadata;
|
|
37820
37750
|
if (providerMetadata != null) {
|
|
@@ -37837,7 +37767,6 @@ function processUIMessageStream({
|
|
|
37837
37767
|
preliminary: anyOptions.preliminary,
|
|
37838
37768
|
providerExecuted: anyOptions.providerExecuted,
|
|
37839
37769
|
title: options.title,
|
|
37840
|
-
...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
|
|
37841
37770
|
...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
|
|
37842
37771
|
...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
37843
37772
|
});
|
|
@@ -37982,8 +37911,7 @@ function processUIMessageStream({
|
|
|
37982
37911
|
toolName: chunk.toolName,
|
|
37983
37912
|
index: toolInvocations.length,
|
|
37984
37913
|
dynamic: chunk.dynamic,
|
|
37985
|
-
title: chunk.title
|
|
37986
|
-
toolMetadata: chunk.toolMetadata
|
|
37914
|
+
title: chunk.title
|
|
37987
37915
|
};
|
|
37988
37916
|
if (chunk.dynamic) {
|
|
37989
37917
|
updateDynamicToolPart({
|
|
@@ -37993,7 +37921,6 @@ function processUIMessageStream({
|
|
|
37993
37921
|
input: undefined,
|
|
37994
37922
|
providerExecuted: chunk.providerExecuted,
|
|
37995
37923
|
title: chunk.title,
|
|
37996
|
-
toolMetadata: chunk.toolMetadata,
|
|
37997
37924
|
providerMetadata: chunk.providerMetadata
|
|
37998
37925
|
});
|
|
37999
37926
|
} else {
|
|
@@ -38004,7 +37931,6 @@ function processUIMessageStream({
|
|
|
38004
37931
|
input: undefined,
|
|
38005
37932
|
providerExecuted: chunk.providerExecuted,
|
|
38006
37933
|
title: chunk.title,
|
|
38007
|
-
toolMetadata: chunk.toolMetadata,
|
|
38008
37934
|
providerMetadata: chunk.providerMetadata
|
|
38009
37935
|
});
|
|
38010
37936
|
}
|
|
@@ -38028,8 +37954,7 @@ function processUIMessageStream({
|
|
|
38028
37954
|
toolName: partialToolCall.toolName,
|
|
38029
37955
|
state: "input-streaming",
|
|
38030
37956
|
input: partialArgs,
|
|
38031
|
-
title: partialToolCall.title
|
|
38032
|
-
toolMetadata: partialToolCall.toolMetadata
|
|
37957
|
+
title: partialToolCall.title
|
|
38033
37958
|
});
|
|
38034
37959
|
} else {
|
|
38035
37960
|
updateToolPart({
|
|
@@ -38037,8 +37962,7 @@ function processUIMessageStream({
|
|
|
38037
37962
|
toolName: partialToolCall.toolName,
|
|
38038
37963
|
state: "input-streaming",
|
|
38039
37964
|
input: partialArgs,
|
|
38040
|
-
title: partialToolCall.title
|
|
38041
|
-
toolMetadata: partialToolCall.toolMetadata
|
|
37965
|
+
title: partialToolCall.title
|
|
38042
37966
|
});
|
|
38043
37967
|
}
|
|
38044
37968
|
write();
|
|
@@ -38053,8 +37977,7 @@ function processUIMessageStream({
|
|
|
38053
37977
|
input: chunk.input,
|
|
38054
37978
|
providerExecuted: chunk.providerExecuted,
|
|
38055
37979
|
providerMetadata: chunk.providerMetadata,
|
|
38056
|
-
title: chunk.title
|
|
38057
|
-
toolMetadata: chunk.toolMetadata
|
|
37980
|
+
title: chunk.title
|
|
38058
37981
|
});
|
|
38059
37982
|
} else {
|
|
38060
37983
|
updateToolPart({
|
|
@@ -38064,8 +37987,7 @@ function processUIMessageStream({
|
|
|
38064
37987
|
input: chunk.input,
|
|
38065
37988
|
providerExecuted: chunk.providerExecuted,
|
|
38066
37989
|
providerMetadata: chunk.providerMetadata,
|
|
38067
|
-
title: chunk.title
|
|
38068
|
-
toolMetadata: chunk.toolMetadata
|
|
37990
|
+
title: chunk.title
|
|
38069
37991
|
});
|
|
38070
37992
|
}
|
|
38071
37993
|
write();
|
|
@@ -38087,8 +38009,7 @@ function processUIMessageStream({
|
|
|
38087
38009
|
input: chunk.input,
|
|
38088
38010
|
errorText: chunk.errorText,
|
|
38089
38011
|
providerExecuted: chunk.providerExecuted,
|
|
38090
|
-
providerMetadata: chunk.providerMetadata
|
|
38091
|
-
toolMetadata: chunk.toolMetadata
|
|
38012
|
+
providerMetadata: chunk.providerMetadata
|
|
38092
38013
|
});
|
|
38093
38014
|
} else {
|
|
38094
38015
|
updateToolPart({
|
|
@@ -38099,8 +38020,7 @@ function processUIMessageStream({
|
|
|
38099
38020
|
rawInput: chunk.input,
|
|
38100
38021
|
errorText: chunk.errorText,
|
|
38101
38022
|
providerExecuted: chunk.providerExecuted,
|
|
38102
|
-
providerMetadata: chunk.providerMetadata
|
|
38103
|
-
toolMetadata: chunk.toolMetadata
|
|
38023
|
+
providerMetadata: chunk.providerMetadata
|
|
38104
38024
|
});
|
|
38105
38025
|
}
|
|
38106
38026
|
write();
|
|
@@ -38131,8 +38051,7 @@ function processUIMessageStream({
|
|
|
38131
38051
|
preliminary: chunk.preliminary,
|
|
38132
38052
|
providerExecuted: chunk.providerExecuted,
|
|
38133
38053
|
providerMetadata: chunk.providerMetadata,
|
|
38134
|
-
title: toolInvocation.title
|
|
38135
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
38054
|
+
title: toolInvocation.title
|
|
38136
38055
|
});
|
|
38137
38056
|
} else {
|
|
38138
38057
|
updateToolPart({
|
|
@@ -38144,8 +38063,7 @@ function processUIMessageStream({
|
|
|
38144
38063
|
providerExecuted: chunk.providerExecuted,
|
|
38145
38064
|
preliminary: chunk.preliminary,
|
|
38146
38065
|
providerMetadata: chunk.providerMetadata,
|
|
38147
|
-
title: toolInvocation.title
|
|
38148
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
38066
|
+
title: toolInvocation.title
|
|
38149
38067
|
});
|
|
38150
38068
|
}
|
|
38151
38069
|
write();
|
|
@@ -38162,8 +38080,7 @@ function processUIMessageStream({
|
|
|
38162
38080
|
errorText: chunk.errorText,
|
|
38163
38081
|
providerExecuted: chunk.providerExecuted,
|
|
38164
38082
|
providerMetadata: chunk.providerMetadata,
|
|
38165
|
-
title: toolInvocation.title
|
|
38166
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
38083
|
+
title: toolInvocation.title
|
|
38167
38084
|
});
|
|
38168
38085
|
} else {
|
|
38169
38086
|
updateToolPart({
|
|
@@ -38175,8 +38092,7 @@ function processUIMessageStream({
|
|
|
38175
38092
|
errorText: chunk.errorText,
|
|
38176
38093
|
providerExecuted: chunk.providerExecuted,
|
|
38177
38094
|
providerMetadata: chunk.providerMetadata,
|
|
38178
|
-
title: toolInvocation.title
|
|
38179
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
38095
|
+
title: toolInvocation.title
|
|
38180
38096
|
});
|
|
38181
38097
|
}
|
|
38182
38098
|
write();
|
|
@@ -38634,8 +38550,7 @@ function runToolsTransformation({
|
|
|
38634
38550
|
input: toolCall.input,
|
|
38635
38551
|
error: getErrorMessage2(toolCall.error),
|
|
38636
38552
|
dynamic: true,
|
|
38637
|
-
title: toolCall.title
|
|
38638
|
-
...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
38553
|
+
title: toolCall.title
|
|
38639
38554
|
});
|
|
38640
38555
|
break;
|
|
38641
38556
|
}
|
|
@@ -38703,7 +38618,6 @@ function runToolsTransformation({
|
|
|
38703
38618
|
}
|
|
38704
38619
|
case "tool-result": {
|
|
38705
38620
|
const toolName = chunk.toolName;
|
|
38706
|
-
const toolCall = toolCallsByToolCallId.get(chunk.toolCallId);
|
|
38707
38621
|
if (chunk.isError) {
|
|
38708
38622
|
toolResultsStreamController.enqueue({
|
|
38709
38623
|
type: "tool-error",
|
|
@@ -38713,8 +38627,7 @@ function runToolsTransformation({
|
|
|
38713
38627
|
providerExecuted: true,
|
|
38714
38628
|
error: chunk.result,
|
|
38715
38629
|
dynamic: chunk.dynamic,
|
|
38716
|
-
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
38717
|
-
...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
38630
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
38718
38631
|
});
|
|
38719
38632
|
} else {
|
|
38720
38633
|
controller.enqueue({
|
|
@@ -38725,8 +38638,7 @@ function runToolsTransformation({
|
|
|
38725
38638
|
output: chunk.result,
|
|
38726
38639
|
providerExecuted: true,
|
|
38727
38640
|
dynamic: chunk.dynamic,
|
|
38728
|
-
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
38729
|
-
...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
|
|
38641
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
38730
38642
|
});
|
|
38731
38643
|
}
|
|
38732
38644
|
break;
|
|
@@ -39509,7 +39421,7 @@ async function embed({
|
|
|
39509
39421
|
}),
|
|
39510
39422
|
tracer,
|
|
39511
39423
|
fn: async (doEmbedSpan) => {
|
|
39512
|
-
var _a21
|
|
39424
|
+
var _a21;
|
|
39513
39425
|
const modelResponse = await model.doEmbed({
|
|
39514
39426
|
values: [value],
|
|
39515
39427
|
abortSignal,
|
|
@@ -39530,7 +39442,7 @@ async function embed({
|
|
|
39530
39442
|
return {
|
|
39531
39443
|
embedding: embedding2,
|
|
39532
39444
|
usage: usage2,
|
|
39533
|
-
warnings:
|
|
39445
|
+
warnings: modelResponse.warnings,
|
|
39534
39446
|
providerMetadata: modelResponse.providerMetadata,
|
|
39535
39447
|
response: modelResponse.response
|
|
39536
39448
|
};
|
|
@@ -39626,7 +39538,7 @@ async function embedMany({
|
|
|
39626
39538
|
}),
|
|
39627
39539
|
tracer,
|
|
39628
39540
|
fn: async (doEmbedSpan) => {
|
|
39629
|
-
var _a222
|
|
39541
|
+
var _a222;
|
|
39630
39542
|
const modelResponse = await model.doEmbed({
|
|
39631
39543
|
values,
|
|
39632
39544
|
abortSignal,
|
|
@@ -39647,7 +39559,7 @@ async function embedMany({
|
|
|
39647
39559
|
return {
|
|
39648
39560
|
embeddings: embeddings3,
|
|
39649
39561
|
usage: usage2,
|
|
39650
|
-
warnings:
|
|
39562
|
+
warnings: modelResponse.warnings,
|
|
39651
39563
|
providerMetadata: modelResponse.providerMetadata,
|
|
39652
39564
|
response: modelResponse.response
|
|
39653
39565
|
};
|
|
@@ -39704,7 +39616,7 @@ async function embedMany({
|
|
|
39704
39616
|
}),
|
|
39705
39617
|
tracer,
|
|
39706
39618
|
fn: async (doEmbedSpan) => {
|
|
39707
|
-
var _a222
|
|
39619
|
+
var _a222;
|
|
39708
39620
|
const modelResponse = await model.doEmbed({
|
|
39709
39621
|
values: chunk,
|
|
39710
39622
|
abortSignal,
|
|
@@ -39725,7 +39637,7 @@ async function embedMany({
|
|
|
39725
39637
|
return {
|
|
39726
39638
|
embeddings: embeddings2,
|
|
39727
39639
|
usage,
|
|
39728
|
-
warnings:
|
|
39640
|
+
warnings: modelResponse.warnings,
|
|
39729
39641
|
providerMetadata: modelResponse.providerMetadata,
|
|
39730
39642
|
response: modelResponse.response
|
|
39731
39643
|
};
|
|
@@ -41839,7 +41751,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
41839
41751
|
const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
|
|
41840
41752
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
41841
41753
|
return bytes.slice(id3Size + 10);
|
|
41842
|
-
}, VERSION3 = "6.0.
|
|
41754
|
+
}, VERSION3 = "6.0.175", download = async ({
|
|
41843
41755
|
url: url2,
|
|
41844
41756
|
maxBytes,
|
|
41845
41757
|
abortSignal
|
|
@@ -42347,7 +42259,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
42347
42259
|
}
|
|
42348
42260
|
return this._output;
|
|
42349
42261
|
}
|
|
42350
|
-
}, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS,
|
|
42262
|
+
}, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
|
|
42351
42263
|
constructor({
|
|
42352
42264
|
model,
|
|
42353
42265
|
telemetry,
|
|
@@ -42577,18 +42489,18 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
42577
42489
|
const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
|
|
42578
42490
|
message: "No output generated. Check the stream for errors."
|
|
42579
42491
|
});
|
|
42580
|
-
|
|
42581
|
-
|
|
42582
|
-
|
|
42583
|
-
|
|
42492
|
+
self._finishReason.reject(error40);
|
|
42493
|
+
self._rawFinishReason.reject(error40);
|
|
42494
|
+
self._totalUsage.reject(error40);
|
|
42495
|
+
self._steps.reject(error40);
|
|
42584
42496
|
return;
|
|
42585
42497
|
}
|
|
42586
42498
|
const finishReason = recordedFinishReason != null ? recordedFinishReason : "other";
|
|
42587
42499
|
const totalUsage = recordedTotalUsage != null ? recordedTotalUsage : createNullLanguageModelUsage();
|
|
42588
|
-
|
|
42589
|
-
|
|
42590
|
-
|
|
42591
|
-
|
|
42500
|
+
self._finishReason.resolve(finishReason);
|
|
42501
|
+
self._rawFinishReason.resolve(recordedRawFinishReason);
|
|
42502
|
+
self._totalUsage.resolve(totalUsage);
|
|
42503
|
+
self._steps.resolve(recordedSteps);
|
|
42592
42504
|
const finalStep = recordedSteps[recordedSteps.length - 1];
|
|
42593
42505
|
await notify({
|
|
42594
42506
|
event: {
|
|
@@ -42719,7 +42631,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
42719
42631
|
headers,
|
|
42720
42632
|
settings: { ...callSettings, maxRetries }
|
|
42721
42633
|
});
|
|
42722
|
-
const
|
|
42634
|
+
const self = this;
|
|
42723
42635
|
const modelInfo = { provider: model.provider, modelId: model.modelId };
|
|
42724
42636
|
const callbackTelemetryProps = {
|
|
42725
42637
|
functionId: telemetry == null ? undefined : telemetry.functionId,
|
|
@@ -42793,7 +42705,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
42793
42705
|
toolExecutionStepStreamController = controller;
|
|
42794
42706
|
}
|
|
42795
42707
|
});
|
|
42796
|
-
|
|
42708
|
+
self.addStream(toolExecutionStepStream);
|
|
42797
42709
|
try {
|
|
42798
42710
|
for (const toolApproval of [
|
|
42799
42711
|
...localDeniedToolApprovals,
|
|
@@ -42877,7 +42789,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
42877
42789
|
usage
|
|
42878
42790
|
}) {
|
|
42879
42791
|
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i;
|
|
42880
|
-
const includeRawChunks2 =
|
|
42792
|
+
const includeRawChunks2 = self.includeRawChunks;
|
|
42881
42793
|
const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : undefined;
|
|
42882
42794
|
let chunkTimeoutId = undefined;
|
|
42883
42795
|
function resetChunkTimeout() {
|
|
@@ -43049,7 +42961,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43049
42961
|
modelId: modelInfo.modelId
|
|
43050
42962
|
};
|
|
43051
42963
|
let activeText = "";
|
|
43052
|
-
|
|
42964
|
+
self.addStream(streamWithToolResults.pipeThrough(new TransformStream({
|
|
43053
42965
|
async transform(chunk, controller) {
|
|
43054
42966
|
var _a222, _b23, _c2, _d2, _e2;
|
|
43055
42967
|
resetChunkTimeout();
|
|
@@ -43312,7 +43224,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43312
43224
|
type: "error",
|
|
43313
43225
|
error: error40
|
|
43314
43226
|
});
|
|
43315
|
-
|
|
43227
|
+
self.closeStream();
|
|
43316
43228
|
}
|
|
43317
43229
|
} else {
|
|
43318
43230
|
controller.enqueue({
|
|
@@ -43321,7 +43233,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43321
43233
|
rawFinishReason: stepRawFinishReason,
|
|
43322
43234
|
totalUsage: combinedUsage
|
|
43323
43235
|
});
|
|
43324
|
-
|
|
43236
|
+
self.closeStream();
|
|
43325
43237
|
}
|
|
43326
43238
|
}
|
|
43327
43239
|
})));
|
|
@@ -43337,13 +43249,13 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43337
43249
|
});
|
|
43338
43250
|
}
|
|
43339
43251
|
}).catch((error40) => {
|
|
43340
|
-
|
|
43252
|
+
self.addStream(new ReadableStream({
|
|
43341
43253
|
start(controller) {
|
|
43342
43254
|
controller.enqueue({ type: "error", error: error40 });
|
|
43343
43255
|
controller.close();
|
|
43344
43256
|
}
|
|
43345
43257
|
}));
|
|
43346
|
-
|
|
43258
|
+
self.closeStream();
|
|
43347
43259
|
});
|
|
43348
43260
|
}
|
|
43349
43261
|
get steps() {
|
|
@@ -43595,7 +43507,6 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43595
43507
|
toolName: part.toolName,
|
|
43596
43508
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
43597
43509
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43598
|
-
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
43599
43510
|
...dynamic != null ? { dynamic } : {},
|
|
43600
43511
|
...part.title != null ? { title: part.title } : {}
|
|
43601
43512
|
});
|
|
@@ -43619,7 +43530,6 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43619
43530
|
input: part.input,
|
|
43620
43531
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
43621
43532
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43622
|
-
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
43623
43533
|
...dynamic != null ? { dynamic } : {},
|
|
43624
43534
|
errorText: onError(part.error),
|
|
43625
43535
|
...part.title != null ? { title: part.title } : {}
|
|
@@ -43632,7 +43542,6 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43632
43542
|
input: part.input,
|
|
43633
43543
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
43634
43544
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43635
|
-
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
43636
43545
|
...dynamic != null ? { dynamic } : {},
|
|
43637
43546
|
...part.title != null ? { title: part.title } : {}
|
|
43638
43547
|
});
|
|
@@ -43655,7 +43564,6 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43655
43564
|
output: part.output,
|
|
43656
43565
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
43657
43566
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43658
|
-
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
43659
43567
|
...part.preliminary != null ? { preliminary: part.preliminary } : {},
|
|
43660
43568
|
...dynamic != null ? { dynamic } : {}
|
|
43661
43569
|
});
|
|
@@ -43669,7 +43577,6 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43669
43577
|
errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) : onError(part.error),
|
|
43670
43578
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
43671
43579
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
43672
|
-
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
43673
43580
|
...dynamic != null ? { dynamic } : {}
|
|
43674
43581
|
});
|
|
43675
43582
|
break;
|
|
@@ -43843,21 +43750,10 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43843
43750
|
...options
|
|
43844
43751
|
};
|
|
43845
43752
|
const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
|
|
43846
|
-
const {
|
|
43847
|
-
instructions,
|
|
43848
|
-
allowSystemInMessages,
|
|
43849
|
-
messages,
|
|
43850
|
-
prompt,
|
|
43851
|
-
...callArgs
|
|
43852
|
-
} = preparedCallArgs;
|
|
43753
|
+
const { instructions, messages, prompt, ...callArgs } = preparedCallArgs;
|
|
43853
43754
|
return {
|
|
43854
43755
|
...callArgs,
|
|
43855
|
-
...{
|
|
43856
|
-
system: instructions,
|
|
43857
|
-
allowSystemInMessages,
|
|
43858
|
-
messages,
|
|
43859
|
-
prompt
|
|
43860
|
-
}
|
|
43756
|
+
...{ system: instructions, messages, prompt }
|
|
43861
43757
|
};
|
|
43862
43758
|
}
|
|
43863
43759
|
mergeOnStepFinishCallbacks(methodCallback) {
|
|
@@ -43898,7 +43794,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
43898
43794
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
43899
43795
|
});
|
|
43900
43796
|
}
|
|
43901
|
-
},
|
|
43797
|
+
}, uiMessagesSchema, DefaultEmbedResult = class {
|
|
43902
43798
|
constructor(options) {
|
|
43903
43799
|
this.value = options.value;
|
|
43904
43800
|
this.embedding = options.embedding;
|
|
@@ -44214,7 +44110,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
44214
44110
|
settings: { ...callSettings, maxRetries }
|
|
44215
44111
|
});
|
|
44216
44112
|
const tracer = getTracer(telemetry);
|
|
44217
|
-
const
|
|
44113
|
+
const self = this;
|
|
44218
44114
|
const stitchableStream = createStitchableStream();
|
|
44219
44115
|
const eventProcessor = new TransformStream({
|
|
44220
44116
|
transform(chunk, controller) {
|
|
@@ -44323,7 +44219,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
44323
44219
|
result: await model.doStream(callOptions)
|
|
44324
44220
|
})
|
|
44325
44221
|
}));
|
|
44326
|
-
|
|
44222
|
+
self._request.resolve(request != null ? request : {});
|
|
44327
44223
|
let warnings;
|
|
44328
44224
|
let usage = createNullLanguageModelUsage();
|
|
44329
44225
|
let finishReason;
|
|
@@ -44414,24 +44310,24 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
|
|
|
44414
44310
|
provider: model.provider,
|
|
44415
44311
|
model: model.modelId
|
|
44416
44312
|
});
|
|
44417
|
-
|
|
44418
|
-
|
|
44419
|
-
|
|
44420
|
-
|
|
44313
|
+
self._usage.resolve(usage);
|
|
44314
|
+
self._providerMetadata.resolve(providerMetadata);
|
|
44315
|
+
self._warnings.resolve(warnings);
|
|
44316
|
+
self._response.resolve({
|
|
44421
44317
|
...fullResponse,
|
|
44422
44318
|
headers: response == null ? undefined : response.headers
|
|
44423
44319
|
});
|
|
44424
|
-
|
|
44320
|
+
self._finishReason.resolve(finishReason != null ? finishReason : "other");
|
|
44425
44321
|
try {
|
|
44426
44322
|
object22 = await parseAndValidateObjectResultWithRepair(accumulatedText, outputStrategy, repairText, {
|
|
44427
44323
|
response: fullResponse,
|
|
44428
44324
|
usage,
|
|
44429
44325
|
finishReason
|
|
44430
44326
|
});
|
|
44431
|
-
|
|
44327
|
+
self._object.resolve(object22);
|
|
44432
44328
|
} catch (e) {
|
|
44433
44329
|
error40 = e;
|
|
44434
|
-
|
|
44330
|
+
self._object.reject(e);
|
|
44435
44331
|
}
|
|
44436
44332
|
break;
|
|
44437
44333
|
}
|
|
@@ -45406,7 +45302,6 @@ var init_dist6 = __esm(() => {
|
|
|
45406
45302
|
init_dist5();
|
|
45407
45303
|
init_dist2();
|
|
45408
45304
|
init_dist2();
|
|
45409
|
-
init_dist5();
|
|
45410
45305
|
init_dist4();
|
|
45411
45306
|
init_dist4();
|
|
45412
45307
|
init_dist4();
|
|
@@ -46266,7 +46161,6 @@ var init_dist6 = __esm(() => {
|
|
|
46266
46161
|
"x-vercel-ai-ui-message-stream": "v1",
|
|
46267
46162
|
"x-accel-buffering": "no"
|
|
46268
46163
|
};
|
|
46269
|
-
toolMetadataSchema = exports_external3.record(exports_external3.string(), jsonValueSchema.optional());
|
|
46270
46164
|
uiMessageChunkSchema = lazySchema(() => zodSchema(exports_external3.union([
|
|
46271
46165
|
exports_external3.strictObject({
|
|
46272
46166
|
type: exports_external3.literal("text-start"),
|
|
@@ -46294,7 +46188,6 @@ var init_dist6 = __esm(() => {
|
|
|
46294
46188
|
toolName: exports_external3.string(),
|
|
46295
46189
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46296
46190
|
providerMetadata: providerMetadataSchema.optional(),
|
|
46297
|
-
toolMetadata: toolMetadataSchema.optional(),
|
|
46298
46191
|
dynamic: exports_external3.boolean().optional(),
|
|
46299
46192
|
title: exports_external3.string().optional()
|
|
46300
46193
|
}),
|
|
@@ -46310,7 +46203,6 @@ var init_dist6 = __esm(() => {
|
|
|
46310
46203
|
input: exports_external3.unknown(),
|
|
46311
46204
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46312
46205
|
providerMetadata: providerMetadataSchema.optional(),
|
|
46313
|
-
toolMetadata: toolMetadataSchema.optional(),
|
|
46314
46206
|
dynamic: exports_external3.boolean().optional(),
|
|
46315
46207
|
title: exports_external3.string().optional()
|
|
46316
46208
|
}),
|
|
@@ -46321,7 +46213,6 @@ var init_dist6 = __esm(() => {
|
|
|
46321
46213
|
input: exports_external3.unknown(),
|
|
46322
46214
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46323
46215
|
providerMetadata: providerMetadataSchema.optional(),
|
|
46324
|
-
toolMetadata: toolMetadataSchema.optional(),
|
|
46325
46216
|
dynamic: exports_external3.boolean().optional(),
|
|
46326
46217
|
errorText: exports_external3.string(),
|
|
46327
46218
|
title: exports_external3.string().optional()
|
|
@@ -46337,7 +46228,6 @@ var init_dist6 = __esm(() => {
|
|
|
46337
46228
|
output: exports_external3.unknown(),
|
|
46338
46229
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46339
46230
|
providerMetadata: providerMetadataSchema.optional(),
|
|
46340
|
-
toolMetadata: toolMetadataSchema.optional(),
|
|
46341
46231
|
dynamic: exports_external3.boolean().optional(),
|
|
46342
46232
|
preliminary: exports_external3.boolean().optional()
|
|
46343
46233
|
}),
|
|
@@ -46347,7 +46237,6 @@ var init_dist6 = __esm(() => {
|
|
|
46347
46237
|
errorText: exports_external3.string(),
|
|
46348
46238
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46349
46239
|
providerMetadata: providerMetadataSchema.optional(),
|
|
46350
|
-
toolMetadata: toolMetadataSchema.optional(),
|
|
46351
46240
|
dynamic: exports_external3.boolean().optional()
|
|
46352
46241
|
}),
|
|
46353
46242
|
exports_external3.strictObject({
|
|
@@ -46435,7 +46324,6 @@ var init_dist6 = __esm(() => {
|
|
|
46435
46324
|
prefix: "aitxt",
|
|
46436
46325
|
size: 24
|
|
46437
46326
|
});
|
|
46438
|
-
toolMetadataSchema2 = exports_external3.record(exports_external3.string(), jsonValueSchema.optional());
|
|
46439
46327
|
uiMessagesSchema = lazySchema(() => zodSchema(exports_external3.array(exports_external3.object({
|
|
46440
46328
|
id: exports_external3.string(),
|
|
46441
46329
|
role: exports_external3.enum(["system", "user", "assistant"]),
|
|
@@ -46487,7 +46375,6 @@ var init_dist6 = __esm(() => {
|
|
|
46487
46375
|
type: exports_external3.literal("dynamic-tool"),
|
|
46488
46376
|
toolName: exports_external3.string(),
|
|
46489
46377
|
toolCallId: exports_external3.string(),
|
|
46490
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46491
46378
|
state: exports_external3.literal("input-streaming"),
|
|
46492
46379
|
input: exports_external3.unknown().optional(),
|
|
46493
46380
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46500,7 +46387,6 @@ var init_dist6 = __esm(() => {
|
|
|
46500
46387
|
type: exports_external3.literal("dynamic-tool"),
|
|
46501
46388
|
toolName: exports_external3.string(),
|
|
46502
46389
|
toolCallId: exports_external3.string(),
|
|
46503
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46504
46390
|
state: exports_external3.literal("input-available"),
|
|
46505
46391
|
input: exports_external3.unknown(),
|
|
46506
46392
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46513,7 +46399,6 @@ var init_dist6 = __esm(() => {
|
|
|
46513
46399
|
type: exports_external3.literal("dynamic-tool"),
|
|
46514
46400
|
toolName: exports_external3.string(),
|
|
46515
46401
|
toolCallId: exports_external3.string(),
|
|
46516
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46517
46402
|
state: exports_external3.literal("approval-requested"),
|
|
46518
46403
|
input: exports_external3.unknown(),
|
|
46519
46404
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46530,7 +46415,6 @@ var init_dist6 = __esm(() => {
|
|
|
46530
46415
|
type: exports_external3.literal("dynamic-tool"),
|
|
46531
46416
|
toolName: exports_external3.string(),
|
|
46532
46417
|
toolCallId: exports_external3.string(),
|
|
46533
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46534
46418
|
state: exports_external3.literal("approval-responded"),
|
|
46535
46419
|
input: exports_external3.unknown(),
|
|
46536
46420
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46547,7 +46431,6 @@ var init_dist6 = __esm(() => {
|
|
|
46547
46431
|
type: exports_external3.literal("dynamic-tool"),
|
|
46548
46432
|
toolName: exports_external3.string(),
|
|
46549
46433
|
toolCallId: exports_external3.string(),
|
|
46550
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46551
46434
|
state: exports_external3.literal("output-available"),
|
|
46552
46435
|
input: exports_external3.unknown(),
|
|
46553
46436
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46566,9 +46449,8 @@ var init_dist6 = __esm(() => {
|
|
|
46566
46449
|
type: exports_external3.literal("dynamic-tool"),
|
|
46567
46450
|
toolName: exports_external3.string(),
|
|
46568
46451
|
toolCallId: exports_external3.string(),
|
|
46569
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46570
46452
|
state: exports_external3.literal("output-error"),
|
|
46571
|
-
input: exports_external3.unknown()
|
|
46453
|
+
input: exports_external3.unknown(),
|
|
46572
46454
|
rawInput: exports_external3.unknown().optional(),
|
|
46573
46455
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46574
46456
|
output: exports_external3.never().optional(),
|
|
@@ -46585,7 +46467,6 @@ var init_dist6 = __esm(() => {
|
|
|
46585
46467
|
type: exports_external3.literal("dynamic-tool"),
|
|
46586
46468
|
toolName: exports_external3.string(),
|
|
46587
46469
|
toolCallId: exports_external3.string(),
|
|
46588
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46589
46470
|
state: exports_external3.literal("output-denied"),
|
|
46590
46471
|
input: exports_external3.unknown(),
|
|
46591
46472
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46601,7 +46482,6 @@ var init_dist6 = __esm(() => {
|
|
|
46601
46482
|
exports_external3.object({
|
|
46602
46483
|
type: exports_external3.string().startsWith("tool-"),
|
|
46603
46484
|
toolCallId: exports_external3.string(),
|
|
46604
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46605
46485
|
state: exports_external3.literal("input-streaming"),
|
|
46606
46486
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46607
46487
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
@@ -46613,7 +46493,6 @@ var init_dist6 = __esm(() => {
|
|
|
46613
46493
|
exports_external3.object({
|
|
46614
46494
|
type: exports_external3.string().startsWith("tool-"),
|
|
46615
46495
|
toolCallId: exports_external3.string(),
|
|
46616
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46617
46496
|
state: exports_external3.literal("input-available"),
|
|
46618
46497
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46619
46498
|
input: exports_external3.unknown(),
|
|
@@ -46625,7 +46504,6 @@ var init_dist6 = __esm(() => {
|
|
|
46625
46504
|
exports_external3.object({
|
|
46626
46505
|
type: exports_external3.string().startsWith("tool-"),
|
|
46627
46506
|
toolCallId: exports_external3.string(),
|
|
46628
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46629
46507
|
state: exports_external3.literal("approval-requested"),
|
|
46630
46508
|
input: exports_external3.unknown(),
|
|
46631
46509
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46641,7 +46519,6 @@ var init_dist6 = __esm(() => {
|
|
|
46641
46519
|
exports_external3.object({
|
|
46642
46520
|
type: exports_external3.string().startsWith("tool-"),
|
|
46643
46521
|
toolCallId: exports_external3.string(),
|
|
46644
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46645
46522
|
state: exports_external3.literal("approval-responded"),
|
|
46646
46523
|
input: exports_external3.unknown(),
|
|
46647
46524
|
providerExecuted: exports_external3.boolean().optional(),
|
|
@@ -46657,7 +46534,6 @@ var init_dist6 = __esm(() => {
|
|
|
46657
46534
|
exports_external3.object({
|
|
46658
46535
|
type: exports_external3.string().startsWith("tool-"),
|
|
46659
46536
|
toolCallId: exports_external3.string(),
|
|
46660
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46661
46537
|
state: exports_external3.literal("output-available"),
|
|
46662
46538
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46663
46539
|
input: exports_external3.unknown(),
|
|
@@ -46675,10 +46551,9 @@ var init_dist6 = __esm(() => {
|
|
|
46675
46551
|
exports_external3.object({
|
|
46676
46552
|
type: exports_external3.string().startsWith("tool-"),
|
|
46677
46553
|
toolCallId: exports_external3.string(),
|
|
46678
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46679
46554
|
state: exports_external3.literal("output-error"),
|
|
46680
46555
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46681
|
-
input: exports_external3.unknown()
|
|
46556
|
+
input: exports_external3.unknown(),
|
|
46682
46557
|
rawInput: exports_external3.unknown().optional(),
|
|
46683
46558
|
output: exports_external3.never().optional(),
|
|
46684
46559
|
errorText: exports_external3.string(),
|
|
@@ -46693,7 +46568,6 @@ var init_dist6 = __esm(() => {
|
|
|
46693
46568
|
exports_external3.object({
|
|
46694
46569
|
type: exports_external3.string().startsWith("tool-"),
|
|
46695
46570
|
toolCallId: exports_external3.string(),
|
|
46696
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
46697
46571
|
state: exports_external3.literal("output-denied"),
|
|
46698
46572
|
providerExecuted: exports_external3.boolean().optional(),
|
|
46699
46573
|
input: exports_external3.unknown(),
|
|
@@ -47014,11 +46888,11 @@ var init_scan_issues = __esm(() => {
|
|
|
47014
46888
|
|
|
47015
46889
|
// src/server/index.ts
|
|
47016
46890
|
import { existsSync as existsSync10 } from "fs";
|
|
47017
|
-
import { join as
|
|
46891
|
+
import { join as join14 } from "path";
|
|
47018
46892
|
// package.json
|
|
47019
46893
|
var package_default = {
|
|
47020
46894
|
name: "@hasna/testers",
|
|
47021
|
-
version: "0.0.
|
|
46895
|
+
version: "0.0.35",
|
|
47022
46896
|
description: "AI-powered QA testing CLI \u2014 spawns cheap AI agents to test web apps with headless browsers",
|
|
47023
46897
|
type: "module",
|
|
47024
46898
|
main: "dist/index.js",
|
|
@@ -47042,10 +46916,10 @@ var package_default = {
|
|
|
47042
46916
|
],
|
|
47043
46917
|
scripts: {
|
|
47044
46918
|
build: "bun run build:dashboard && bun run build:cli && bun run build:mcp && bun run build:server && bun run build:lib && bun run build:types",
|
|
47045
|
-
"build:cli": "bun build src/cli/index.tsx --outdir dist/cli --target bun --external ink --external react --external chalk --external @modelcontextprotocol/sdk --external @anthropic-ai/sdk --external playwright --external @hasna/browser",
|
|
47046
|
-
"build:mcp": "bun build src/mcp/index.ts --outdir dist/mcp --target bun --external @modelcontextprotocol/sdk --external @anthropic-ai/sdk --external playwright --external @hasna/browser",
|
|
47047
|
-
"build:server": "bun build src/server/index.ts --outdir dist/server --target bun --external @anthropic-ai/sdk --external playwright --external @hasna/browser",
|
|
47048
|
-
"build:lib": "bun build src/index.ts --outdir dist --target bun --external playwright --external @anthropic-ai/sdk --external @modelcontextprotocol/sdk --external @hasna/browser",
|
|
46919
|
+
"build:cli": "bun build src/cli/index.tsx --outdir dist/cli --target bun --external ink --external react --external chalk --external @modelcontextprotocol/sdk --external @anthropic-ai/sdk --external playwright --external @hasna/browser --external @hasna/sandboxes",
|
|
46920
|
+
"build:mcp": "bun build src/mcp/index.ts --outdir dist/mcp --target bun --external @modelcontextprotocol/sdk --external @anthropic-ai/sdk --external playwright --external @hasna/browser --external @hasna/sandboxes",
|
|
46921
|
+
"build:server": "bun build src/server/index.ts --outdir dist/server --target bun --external @anthropic-ai/sdk --external playwright --external @hasna/browser --external @hasna/sandboxes",
|
|
46922
|
+
"build:lib": "bun build src/index.ts --outdir dist --target bun --external playwright --external @anthropic-ai/sdk --external @modelcontextprotocol/sdk --external @hasna/browser --external @hasna/sandboxes",
|
|
47049
46923
|
"build:types": "NODE_OPTIONS='--max-old-space-size=8192' tsc --emitDeclarationOnly --outDir dist --skipLibCheck || true",
|
|
47050
46924
|
"build:dashboard": "cd dashboard && bun run build",
|
|
47051
46925
|
"build:ext": "cd extension && bun run build",
|
|
@@ -47059,10 +46933,11 @@ var package_default = {
|
|
|
47059
46933
|
},
|
|
47060
46934
|
dependencies: {
|
|
47061
46935
|
"@anthropic-ai/sdk": "^0.52.0",
|
|
47062
|
-
"@hasna/browser": "^0.4.
|
|
46936
|
+
"@hasna/browser": "^0.4.12",
|
|
47063
46937
|
"@hasna/cloud": "^0.1.24",
|
|
47064
46938
|
"@hasna/contacts": "^0.6.8",
|
|
47065
46939
|
"@hasna/projects": "^0.1.42",
|
|
46940
|
+
"@hasna/sandboxes": "^0.1.27",
|
|
47066
46941
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
47067
46942
|
ai: "^6.0.175",
|
|
47068
46943
|
chalk: "^5.4.1",
|
|
@@ -49216,12 +49091,345 @@ async function notifyRunToConversations(run, results, options) {
|
|
|
49216
49091
|
} catch {}
|
|
49217
49092
|
}
|
|
49218
49093
|
|
|
49094
|
+
// src/lib/a11y-audit.ts
|
|
49095
|
+
async function runA11yAudit(page, options = {}) {
|
|
49096
|
+
const { level = "AA", rules, exclude = [] } = options;
|
|
49097
|
+
await page.addScriptTag({ url: "https://cdnjs.cloudflare.com/ajax/libs/axe-core/4.9.1/axe.min.js" });
|
|
49098
|
+
const config = {
|
|
49099
|
+
runOnly: {
|
|
49100
|
+
type: level === "AAA" ? "standard" : "tag",
|
|
49101
|
+
values: level === "AAA" ? undefined : [level, "best-practice"]
|
|
49102
|
+
}
|
|
49103
|
+
};
|
|
49104
|
+
if (rules && rules.length > 0) {
|
|
49105
|
+
config.rules = Object.fromEntries(rules.map((r) => [r, { enabled: true }]));
|
|
49106
|
+
}
|
|
49107
|
+
if (exclude.length > 0) {
|
|
49108
|
+
config.exclude = exclude;
|
|
49109
|
+
}
|
|
49110
|
+
const result = await page.evaluate(async (auditConfig) => {
|
|
49111
|
+
const axeResult = await window.axe.run(auditConfig);
|
|
49112
|
+
return axeResult;
|
|
49113
|
+
}, config);
|
|
49114
|
+
const violations = (result.violations ?? []).map((v) => ({
|
|
49115
|
+
id: v.id,
|
|
49116
|
+
impact: v.impact,
|
|
49117
|
+
description: v.description,
|
|
49118
|
+
help: v.help,
|
|
49119
|
+
helpUrl: v.helpUrl,
|
|
49120
|
+
nodes: (v.nodes ?? []).map((n) => ({
|
|
49121
|
+
html: n.html,
|
|
49122
|
+
target: n.target,
|
|
49123
|
+
failureSummary: n.failureSummary
|
|
49124
|
+
}))
|
|
49125
|
+
}));
|
|
49126
|
+
const passes = (result.passes ?? []).map((p) => ({
|
|
49127
|
+
id: p.id,
|
|
49128
|
+
description: p.description
|
|
49129
|
+
}));
|
|
49130
|
+
const incomplete = (result.incomplete ?? []).map((i) => ({
|
|
49131
|
+
id: i.id,
|
|
49132
|
+
description: i.description,
|
|
49133
|
+
impact: i.impact
|
|
49134
|
+
}));
|
|
49135
|
+
const criticalCount = violations.filter((v) => v.impact === "critical").length;
|
|
49136
|
+
const seriousCount = violations.filter((v) => v.impact === "serious").length;
|
|
49137
|
+
const moderateCount = violations.filter((v) => v.impact === "moderate").length;
|
|
49138
|
+
const minorCount = violations.filter((v) => v.impact === "minor").length;
|
|
49139
|
+
return {
|
|
49140
|
+
violations,
|
|
49141
|
+
passes,
|
|
49142
|
+
incomplete,
|
|
49143
|
+
url: page.url(),
|
|
49144
|
+
timestamp: new Date().toISOString(),
|
|
49145
|
+
totalViolations: violations.length,
|
|
49146
|
+
criticalCount,
|
|
49147
|
+
seriousCount,
|
|
49148
|
+
moderateCount,
|
|
49149
|
+
minorCount
|
|
49150
|
+
};
|
|
49151
|
+
}
|
|
49152
|
+
|
|
49153
|
+
// src/lib/assertions.ts
|
|
49154
|
+
async function evaluateAssertions(page, assertions, context = {}) {
|
|
49155
|
+
const results = [];
|
|
49156
|
+
for (const assertion of assertions) {
|
|
49157
|
+
try {
|
|
49158
|
+
const result = await evaluateOne(page, assertion, context);
|
|
49159
|
+
results.push(result);
|
|
49160
|
+
} catch (err) {
|
|
49161
|
+
results.push({
|
|
49162
|
+
assertion,
|
|
49163
|
+
passed: false,
|
|
49164
|
+
actual: "",
|
|
49165
|
+
error: err instanceof Error ? err.message : String(err)
|
|
49166
|
+
});
|
|
49167
|
+
}
|
|
49168
|
+
}
|
|
49169
|
+
return results;
|
|
49170
|
+
}
|
|
49171
|
+
async function evaluateOne(page, assertion, context) {
|
|
49172
|
+
switch (assertion.type) {
|
|
49173
|
+
case "visible": {
|
|
49174
|
+
const visible = await page.locator(assertion.selector).isVisible();
|
|
49175
|
+
return {
|
|
49176
|
+
assertion,
|
|
49177
|
+
passed: visible,
|
|
49178
|
+
actual: String(visible)
|
|
49179
|
+
};
|
|
49180
|
+
}
|
|
49181
|
+
case "not_visible": {
|
|
49182
|
+
const visible = await page.locator(assertion.selector).isVisible();
|
|
49183
|
+
return {
|
|
49184
|
+
assertion,
|
|
49185
|
+
passed: !visible,
|
|
49186
|
+
actual: String(visible)
|
|
49187
|
+
};
|
|
49188
|
+
}
|
|
49189
|
+
case "text_contains": {
|
|
49190
|
+
const text = await page.locator(assertion.selector).textContent() ?? "";
|
|
49191
|
+
const expected = String(assertion.expected ?? "");
|
|
49192
|
+
return {
|
|
49193
|
+
assertion,
|
|
49194
|
+
passed: text.includes(expected),
|
|
49195
|
+
actual: text
|
|
49196
|
+
};
|
|
49197
|
+
}
|
|
49198
|
+
case "text_equals": {
|
|
49199
|
+
const text = await page.locator(assertion.selector).textContent() ?? "";
|
|
49200
|
+
const expected = String(assertion.expected ?? "");
|
|
49201
|
+
return {
|
|
49202
|
+
assertion,
|
|
49203
|
+
passed: text.trim() === expected.trim(),
|
|
49204
|
+
actual: text
|
|
49205
|
+
};
|
|
49206
|
+
}
|
|
49207
|
+
case "element_count": {
|
|
49208
|
+
const count = await page.locator(assertion.selector).count();
|
|
49209
|
+
const expected = Number(assertion.expected ?? 0);
|
|
49210
|
+
return {
|
|
49211
|
+
assertion,
|
|
49212
|
+
passed: count === expected,
|
|
49213
|
+
actual: String(count)
|
|
49214
|
+
};
|
|
49215
|
+
}
|
|
49216
|
+
case "no_console_errors": {
|
|
49217
|
+
if (context.consoleErrors !== undefined) {
|
|
49218
|
+
const errors2 = context.consoleErrors.filter(Boolean);
|
|
49219
|
+
return {
|
|
49220
|
+
assertion,
|
|
49221
|
+
passed: errors2.length === 0,
|
|
49222
|
+
actual: errors2.length === 0 ? "No console errors captured" : errors2.slice(0, 3).join(" | ")
|
|
49223
|
+
};
|
|
49224
|
+
}
|
|
49225
|
+
const errorElements = await page.locator('[role="alert"], .error, .error-message, [data-testid="error"]').count();
|
|
49226
|
+
return {
|
|
49227
|
+
assertion,
|
|
49228
|
+
passed: errorElements === 0,
|
|
49229
|
+
actual: `${errorElements} error element(s) found`
|
|
49230
|
+
};
|
|
49231
|
+
}
|
|
49232
|
+
case "no_a11y_violations": {
|
|
49233
|
+
try {
|
|
49234
|
+
const auditResult = await runA11yAudit(page);
|
|
49235
|
+
const hasIssues = auditResult.violations.length > 0;
|
|
49236
|
+
return {
|
|
49237
|
+
assertion,
|
|
49238
|
+
passed: !hasIssues,
|
|
49239
|
+
actual: hasIssues ? `${auditResult.totalViolations} violation(s): ${auditResult.violations.map((v) => v.id).join(", ")}` : "No accessibility violations found"
|
|
49240
|
+
};
|
|
49241
|
+
} catch (err) {
|
|
49242
|
+
return {
|
|
49243
|
+
assertion,
|
|
49244
|
+
passed: false,
|
|
49245
|
+
actual: "",
|
|
49246
|
+
error: err instanceof Error ? err.message : String(err)
|
|
49247
|
+
};
|
|
49248
|
+
}
|
|
49249
|
+
}
|
|
49250
|
+
case "url_contains": {
|
|
49251
|
+
const url = page.url();
|
|
49252
|
+
const expected = String(assertion.expected ?? "");
|
|
49253
|
+
return {
|
|
49254
|
+
assertion,
|
|
49255
|
+
passed: url.includes(expected),
|
|
49256
|
+
actual: url
|
|
49257
|
+
};
|
|
49258
|
+
}
|
|
49259
|
+
case "title_contains": {
|
|
49260
|
+
const title = await page.title();
|
|
49261
|
+
const expected = String(assertion.expected ?? "");
|
|
49262
|
+
return {
|
|
49263
|
+
assertion,
|
|
49264
|
+
passed: title.includes(expected),
|
|
49265
|
+
actual: title
|
|
49266
|
+
};
|
|
49267
|
+
}
|
|
49268
|
+
case "cookie_exists": {
|
|
49269
|
+
const cookieName = assertion.expected;
|
|
49270
|
+
const cookies = await page.context().cookies();
|
|
49271
|
+
const found = cookies.some((c) => c.name === cookieName);
|
|
49272
|
+
return {
|
|
49273
|
+
assertion,
|
|
49274
|
+
passed: found,
|
|
49275
|
+
actual: found ? `Cookie "${cookieName}" exists` : `Cookie "${cookieName}" not found`
|
|
49276
|
+
};
|
|
49277
|
+
}
|
|
49278
|
+
case "cookie_not_exists": {
|
|
49279
|
+
const cookieName = assertion.expected;
|
|
49280
|
+
const cookies = await page.context().cookies();
|
|
49281
|
+
const found = cookies.some((c) => c.name === cookieName);
|
|
49282
|
+
return {
|
|
49283
|
+
assertion,
|
|
49284
|
+
passed: !found,
|
|
49285
|
+
actual: found ? `Cookie "${cookieName}" found (unexpected)` : `Cookie "${cookieName}" does not exist`
|
|
49286
|
+
};
|
|
49287
|
+
}
|
|
49288
|
+
case "cookie_value": {
|
|
49289
|
+
const [cookieName, expectedValue] = assertion.expected.split("=", 2);
|
|
49290
|
+
const cookies = await page.context().cookies();
|
|
49291
|
+
const cookie = cookies.find((c) => c.name === cookieName);
|
|
49292
|
+
const actualValue = cookie?.value ?? "";
|
|
49293
|
+
return {
|
|
49294
|
+
assertion,
|
|
49295
|
+
passed: actualValue === expectedValue,
|
|
49296
|
+
actual: cookie ? `${cookieName}=${actualValue}` : `Cookie "${cookieName}" not found`
|
|
49297
|
+
};
|
|
49298
|
+
}
|
|
49299
|
+
case "local_storage_exists": {
|
|
49300
|
+
const key = assertion.expected;
|
|
49301
|
+
const value = await page.evaluate((k) => localStorage.getItem(k), key);
|
|
49302
|
+
return {
|
|
49303
|
+
assertion,
|
|
49304
|
+
passed: value !== null,
|
|
49305
|
+
actual: value !== null ? `Key "${key}" exists with value "${value}"` : `Key "${key}" not found in localStorage`
|
|
49306
|
+
};
|
|
49307
|
+
}
|
|
49308
|
+
case "local_storage_not_exists": {
|
|
49309
|
+
const key = assertion.expected;
|
|
49310
|
+
const value = await page.evaluate((k) => localStorage.getItem(k), key);
|
|
49311
|
+
return {
|
|
49312
|
+
assertion,
|
|
49313
|
+
passed: value === null,
|
|
49314
|
+
actual: value !== null ? `Key "${key}" exists (unexpected)` : `Key "${key}" does not exist in localStorage`
|
|
49315
|
+
};
|
|
49316
|
+
}
|
|
49317
|
+
case "local_storage_value": {
|
|
49318
|
+
const [lsKey, expectedValue] = assertion.expected.split("=", 2);
|
|
49319
|
+
const value = await page.evaluate((k) => localStorage.getItem(k), lsKey ?? "");
|
|
49320
|
+
return {
|
|
49321
|
+
assertion,
|
|
49322
|
+
passed: value === expectedValue,
|
|
49323
|
+
actual: value !== null ? `${lsKey}=${value}` : `Key "${lsKey}" not found in localStorage`
|
|
49324
|
+
};
|
|
49325
|
+
}
|
|
49326
|
+
case "session_storage_value": {
|
|
49327
|
+
const [ssKey, expectedValue] = assertion.expected.split("=", 2);
|
|
49328
|
+
const value = await page.evaluate((k) => sessionStorage.getItem(k), ssKey ?? "");
|
|
49329
|
+
return {
|
|
49330
|
+
assertion,
|
|
49331
|
+
passed: value === expectedValue,
|
|
49332
|
+
actual: value !== null ? `${ssKey}=${value}` : `Key "${ssKey}" not found in sessionStorage`
|
|
49333
|
+
};
|
|
49334
|
+
}
|
|
49335
|
+
case "session_storage_not_exists": {
|
|
49336
|
+
const key = assertion.expected;
|
|
49337
|
+
const value = await page.evaluate((k) => sessionStorage.getItem(k), key);
|
|
49338
|
+
return {
|
|
49339
|
+
assertion,
|
|
49340
|
+
passed: value === null,
|
|
49341
|
+
actual: value !== null ? `Key "${key}" exists (unexpected)` : `Key "${key}" does not exist in sessionStorage`
|
|
49342
|
+
};
|
|
49343
|
+
}
|
|
49344
|
+
default: {
|
|
49345
|
+
return {
|
|
49346
|
+
assertion,
|
|
49347
|
+
passed: false,
|
|
49348
|
+
actual: "",
|
|
49349
|
+
error: `Unknown assertion type: ${assertion.type}`
|
|
49350
|
+
};
|
|
49351
|
+
}
|
|
49352
|
+
}
|
|
49353
|
+
}
|
|
49354
|
+
function allAssertionsPassed(results) {
|
|
49355
|
+
return results.every((r) => r.passed);
|
|
49356
|
+
}
|
|
49357
|
+
function formatAssertionResults(results) {
|
|
49358
|
+
if (results.length === 0)
|
|
49359
|
+
return "No assertions.";
|
|
49360
|
+
const lines = [];
|
|
49361
|
+
for (const r of results) {
|
|
49362
|
+
const icon = r.passed ? "PASS" : "FAIL";
|
|
49363
|
+
const desc = r.assertion.description || `${r.assertion.type}${r.assertion.selector ? ` ${r.assertion.selector}` : ""}`;
|
|
49364
|
+
let line = ` [${icon}] ${desc}`;
|
|
49365
|
+
if (!r.passed) {
|
|
49366
|
+
line += ` (actual: ${r.actual})`;
|
|
49367
|
+
if (r.error)
|
|
49368
|
+
line += ` \u2014 ${r.error}`;
|
|
49369
|
+
}
|
|
49370
|
+
lines.push(line);
|
|
49371
|
+
}
|
|
49372
|
+
const passed = results.filter((r) => r.passed).length;
|
|
49373
|
+
lines.push(`
|
|
49374
|
+
${passed}/${results.length} assertions passed.`);
|
|
49375
|
+
return lines.join(`
|
|
49376
|
+
`);
|
|
49377
|
+
}
|
|
49378
|
+
|
|
49219
49379
|
// src/lib/runner.ts
|
|
49220
49380
|
var eventHandler = null;
|
|
49221
49381
|
function emit(event) {
|
|
49222
49382
|
if (eventHandler)
|
|
49223
49383
|
eventHandler(event);
|
|
49224
49384
|
}
|
|
49385
|
+
function assertionDescription(result) {
|
|
49386
|
+
return result.assertion.description || `${result.assertion.type}${result.assertion.selector ? ` ${result.assertion.selector}` : ""}`;
|
|
49387
|
+
}
|
|
49388
|
+
function summarizeAssertionResult(result) {
|
|
49389
|
+
const description = assertionDescription(result);
|
|
49390
|
+
if (result.passed)
|
|
49391
|
+
return description;
|
|
49392
|
+
const suffix = result.error ? `; ${result.error}` : "";
|
|
49393
|
+
return `${description} (actual: ${result.actual}${suffix})`;
|
|
49394
|
+
}
|
|
49395
|
+
async function applyStructuredAssertionsToResult(input) {
|
|
49396
|
+
const assertions = input.scenario.assertions ?? [];
|
|
49397
|
+
if (assertions.length === 0) {
|
|
49398
|
+
return {
|
|
49399
|
+
status: input.status,
|
|
49400
|
+
reasoning: input.reasoning,
|
|
49401
|
+
assertionsPassed: [],
|
|
49402
|
+
assertionsFailed: [],
|
|
49403
|
+
assertionResults: []
|
|
49404
|
+
};
|
|
49405
|
+
}
|
|
49406
|
+
const results = await evaluateAssertions(input.page, assertions, {
|
|
49407
|
+
consoleErrors: input.consoleErrors
|
|
49408
|
+
});
|
|
49409
|
+
const assertionsPassed = results.filter((r) => r.passed).map(summarizeAssertionResult);
|
|
49410
|
+
const assertionsFailed = results.filter((r) => !r.passed).map(summarizeAssertionResult);
|
|
49411
|
+
const assertionResults = results.map((result) => ({
|
|
49412
|
+
type: result.assertion.type,
|
|
49413
|
+
description: assertionDescription(result),
|
|
49414
|
+
passed: result.passed,
|
|
49415
|
+
actual: result.actual,
|
|
49416
|
+
...result.error ? { error: result.error } : {}
|
|
49417
|
+
}));
|
|
49418
|
+
const assertionsOk = allAssertionsPassed(results);
|
|
49419
|
+
const status = assertionsOk || input.status !== "passed" ? input.status : "failed";
|
|
49420
|
+
const assertionHeading = assertionsOk ? "Structured assertions passed:" : "Structured assertions failed:";
|
|
49421
|
+
const reasoningParts = [input.reasoning, `${assertionHeading}
|
|
49422
|
+
${formatAssertionResults(results)}`].map((part) => part.trim()).filter(Boolean);
|
|
49423
|
+
return {
|
|
49424
|
+
status,
|
|
49425
|
+
reasoning: reasoningParts.join(`
|
|
49426
|
+
|
|
49427
|
+
`),
|
|
49428
|
+
assertionsPassed,
|
|
49429
|
+
assertionsFailed,
|
|
49430
|
+
assertionResults
|
|
49431
|
+
};
|
|
49432
|
+
}
|
|
49225
49433
|
function withTimeout(promise, ms, label) {
|
|
49226
49434
|
return new Promise((resolve, reject) => {
|
|
49227
49435
|
const warningAt = Math.floor(ms * 0.8);
|
|
@@ -49392,6 +49600,7 @@ async function runSingleScenario(scenario, runId, options) {
|
|
|
49392
49600
|
model,
|
|
49393
49601
|
runId,
|
|
49394
49602
|
sessionId: result.id,
|
|
49603
|
+
baseUrl: options.url,
|
|
49395
49604
|
maxTurns: effectiveOptions.minimal ? 10 : 30,
|
|
49396
49605
|
a11y: effectiveOptions.a11y,
|
|
49397
49606
|
persona: persona ? {
|
|
@@ -49474,27 +49683,46 @@ async function runSingleScenario(scenario, runId, options) {
|
|
|
49474
49683
|
closeSession(result.id);
|
|
49475
49684
|
const lightpandaNote = options.engine === "lightpanda" ? " (Running with Lightpanda \u2014 no screenshots)" : options.engine === "bun" ? " (Running with Bun.WebView \u2014 native, ~11x faster)" : "";
|
|
49476
49685
|
const networkMeta = networkErrors.length > 0 ? { networkErrors: networkErrors.slice(0, 20) } : {};
|
|
49477
|
-
|
|
49686
|
+
const baseReasoning = agentResult.reasoning ? agentResult.reasoning + lightpandaNote : lightpandaNote || "";
|
|
49687
|
+
const assertionOutcome = await applyStructuredAssertionsToResult({
|
|
49688
|
+
page,
|
|
49689
|
+
scenario,
|
|
49690
|
+
consoleErrors,
|
|
49478
49691
|
status: agentResult.status,
|
|
49479
|
-
reasoning:
|
|
49692
|
+
reasoning: baseReasoning
|
|
49693
|
+
});
|
|
49694
|
+
const structuredAssertionMeta = assertionOutcome.assertionResults.length > 0 ? {
|
|
49695
|
+
structuredAssertions: {
|
|
49696
|
+
passed: assertionOutcome.assertionsPassed,
|
|
49697
|
+
failed: assertionOutcome.assertionsFailed,
|
|
49698
|
+
results: assertionOutcome.assertionResults
|
|
49699
|
+
}
|
|
49700
|
+
} : {};
|
|
49701
|
+
let updatedResult = updateResult(result.id, {
|
|
49702
|
+
status: assertionOutcome.status,
|
|
49703
|
+
reasoning: assertionOutcome.reasoning || undefined,
|
|
49480
49704
|
stepsCompleted: agentResult.stepsCompleted,
|
|
49481
49705
|
durationMs: Date.now() - new Date(result.createdAt).getTime(),
|
|
49482
49706
|
tokensUsed: agentResult.tokensUsed,
|
|
49483
49707
|
costCents: estimateCost(model, agentResult.tokensUsed),
|
|
49484
|
-
metadata: {
|
|
49708
|
+
metadata: {
|
|
49709
|
+
consoleLogs,
|
|
49710
|
+
...networkErrors.length > 0 ? networkMeta : {},
|
|
49711
|
+
...structuredAssertionMeta
|
|
49712
|
+
}
|
|
49485
49713
|
});
|
|
49486
|
-
if (
|
|
49487
|
-
const failureAnalysis = analyzeFailure(null,
|
|
49714
|
+
if (assertionOutcome.status === "failed" || assertionOutcome.status === "error") {
|
|
49715
|
+
const failureAnalysis = analyzeFailure(null, assertionOutcome.reasoning ?? null);
|
|
49488
49716
|
if (failureAnalysis) {
|
|
49489
49717
|
updatedResult = updateResult(result.id, { failureAnalysis });
|
|
49490
49718
|
}
|
|
49491
49719
|
}
|
|
49492
|
-
if (
|
|
49720
|
+
if (assertionOutcome.status === "passed") {
|
|
49493
49721
|
try {
|
|
49494
49722
|
updateScenarioPassedCache(scenario.id, options.url);
|
|
49495
49723
|
} catch {}
|
|
49496
49724
|
}
|
|
49497
|
-
const eventType =
|
|
49725
|
+
const eventType = assertionOutcome.status === "passed" ? "scenario:pass" : "scenario:fail";
|
|
49498
49726
|
emit({ type: eventType, scenarioId: scenario.id, scenarioName: scenario.name, resultId: result.id, runId });
|
|
49499
49727
|
return updatedResult;
|
|
49500
49728
|
} catch (error) {
|
|
@@ -49519,7 +49747,8 @@ async function runSingleScenario(scenario, runId, options) {
|
|
|
49519
49747
|
} finally {
|
|
49520
49748
|
if (harPath) {
|
|
49521
49749
|
try {
|
|
49522
|
-
|
|
49750
|
+
const existing = getResult(result.id);
|
|
49751
|
+
updateResult(result.id, { metadata: { ...existing?.metadata ?? {}, harPath } });
|
|
49523
49752
|
} catch {}
|
|
49524
49753
|
}
|
|
49525
49754
|
if (browser) {
|
|
@@ -49691,22 +49920,31 @@ async function runBatch(scenarios, options) {
|
|
|
49691
49920
|
}
|
|
49692
49921
|
return { run: finalRun, results };
|
|
49693
49922
|
}
|
|
49694
|
-
|
|
49695
|
-
|
|
49923
|
+
function findScenarioInList(scenarios, id) {
|
|
49924
|
+
return scenarios.find((scenario) => scenario.id === id || scenario.shortId === id || scenario.id.startsWith(id)) ?? null;
|
|
49925
|
+
}
|
|
49926
|
+
function resolveScenariosForRun(options) {
|
|
49696
49927
|
if (options.scenarioIds && options.scenarioIds.length > 0) {
|
|
49697
|
-
const
|
|
49698
|
-
|
|
49699
|
-
|
|
49700
|
-
|
|
49701
|
-
|
|
49928
|
+
const scoped = listScenarios({ projectId: options.projectId });
|
|
49929
|
+
const resolved = [];
|
|
49930
|
+
const seen = new Set;
|
|
49931
|
+
for (const id of options.scenarioIds) {
|
|
49932
|
+
const scenario = findScenarioInList(scoped, id) ?? getScenario(id);
|
|
49933
|
+
if (scenario && !seen.has(scenario.id)) {
|
|
49934
|
+
resolved.push(scenario);
|
|
49935
|
+
seen.add(scenario.id);
|
|
49936
|
+
}
|
|
49702
49937
|
}
|
|
49703
|
-
|
|
49704
|
-
scenarios = listScenarios({
|
|
49705
|
-
projectId: options.projectId,
|
|
49706
|
-
tags: options.tags,
|
|
49707
|
-
priority: options.priority
|
|
49708
|
-
});
|
|
49938
|
+
return resolved;
|
|
49709
49939
|
}
|
|
49940
|
+
return listScenarios({
|
|
49941
|
+
projectId: options.projectId,
|
|
49942
|
+
tags: options.tags,
|
|
49943
|
+
priority: options.priority
|
|
49944
|
+
});
|
|
49945
|
+
}
|
|
49946
|
+
async function runByFilter(options) {
|
|
49947
|
+
const scenarios = resolveScenariosForRun(options);
|
|
49710
49948
|
if (scenarios.length === 0) {
|
|
49711
49949
|
const config = loadConfig();
|
|
49712
49950
|
const model = resolveModel(options.model ?? config.defaultModel);
|
|
@@ -50870,18 +51108,7 @@ function normalizeFilter(input) {
|
|
|
50870
51108
|
};
|
|
50871
51109
|
}
|
|
50872
51110
|
function normalizeExecution(input) {
|
|
50873
|
-
|
|
50874
|
-
if (target === "connector:e2b") {
|
|
50875
|
-
return {
|
|
50876
|
-
target,
|
|
50877
|
-
connector: input?.connector ?? "e2b",
|
|
50878
|
-
operation: input?.operation ?? "run",
|
|
50879
|
-
sandboxTemplate: input?.sandboxTemplate,
|
|
50880
|
-
timeoutMs: input?.timeoutMs,
|
|
50881
|
-
env: input?.env
|
|
50882
|
-
};
|
|
50883
|
-
}
|
|
50884
|
-
return { ...DEFAULT_EXECUTION, timeoutMs: input?.timeoutMs };
|
|
51111
|
+
return input ? workflowExecutionFromValue(input) : DEFAULT_EXECUTION;
|
|
50885
51112
|
}
|
|
50886
51113
|
function createTestingWorkflow(input) {
|
|
50887
51114
|
const db2 = getDatabase();
|
|
@@ -50980,6 +51207,10 @@ function db2() {
|
|
|
50980
51207
|
}
|
|
50981
51208
|
|
|
50982
51209
|
// src/lib/workflow-runner.ts
|
|
51210
|
+
init_database();
|
|
51211
|
+
import { mkdtempSync, rmSync, writeFileSync as writeFileSync3 } from "fs";
|
|
51212
|
+
import { tmpdir } from "os";
|
|
51213
|
+
import { join as join13 } from "path";
|
|
50983
51214
|
function buildWorkflowRunPlan(workflow, options) {
|
|
50984
51215
|
const runOptions = {
|
|
50985
51216
|
url: options.url,
|
|
@@ -50996,10 +51227,10 @@ function buildWorkflowRunPlan(workflow, options) {
|
|
|
50996
51227
|
return {
|
|
50997
51228
|
workflow,
|
|
50998
51229
|
runOptions,
|
|
50999
|
-
|
|
51230
|
+
sandbox: workflow.execution.target === "sandbox" ? buildSandboxPlan(workflow, workflow.execution, runOptions) : null
|
|
51000
51231
|
};
|
|
51001
51232
|
}
|
|
51002
|
-
async function runTestingWorkflow(workflowId, options) {
|
|
51233
|
+
async function runTestingWorkflow(workflowId, options, dependencies = {}) {
|
|
51003
51234
|
const workflow = getTestingWorkflow(workflowId);
|
|
51004
51235
|
if (!workflow)
|
|
51005
51236
|
throw new Error(`Testing workflow not found: ${workflowId}`);
|
|
@@ -51009,13 +51240,25 @@ async function runTestingWorkflow(workflowId, options) {
|
|
|
51009
51240
|
const plan = buildWorkflowRunPlan(workflow, options);
|
|
51010
51241
|
if (options.dryRun)
|
|
51011
51242
|
return { run: null, results: [], plan };
|
|
51012
|
-
if (workflow.execution.target === "
|
|
51013
|
-
const
|
|
51014
|
-
return { run: null, results: [], plan,
|
|
51243
|
+
if (workflow.execution.target === "sandbox") {
|
|
51244
|
+
const sandboxResult = await runViaSandbox(plan, dependencies);
|
|
51245
|
+
return { run: null, results: [], plan, sandboxResult };
|
|
51015
51246
|
}
|
|
51016
|
-
const
|
|
51247
|
+
const runLocal = dependencies.runByFilter ?? runByFilter;
|
|
51248
|
+
const { run, results } = await runLocal(plan.runOptions);
|
|
51017
51249
|
return { run, results, plan };
|
|
51018
51250
|
}
|
|
51251
|
+
function createWorkflowDatabaseBundle(workflow, plan) {
|
|
51252
|
+
if (!plan.sandbox)
|
|
51253
|
+
throw new Error(`Workflow is not configured for sandbox execution: ${workflow.name}`);
|
|
51254
|
+
const localDir = mkdtempSync(join13(tmpdir(), `testers-workflow-${workflow.id.slice(0, 8)}-`));
|
|
51255
|
+
writeFileSync3(join13(localDir, "testers.db"), getDatabase().serialize());
|
|
51256
|
+
return {
|
|
51257
|
+
localDir,
|
|
51258
|
+
remoteDir: plan.sandbox.stateRemoteDir,
|
|
51259
|
+
cleanup: () => rmSync(localDir, { recursive: true, force: true })
|
|
51260
|
+
};
|
|
51261
|
+
}
|
|
51019
51262
|
function validatePersonaIds(workflow) {
|
|
51020
51263
|
for (const personaId of workflow.personaIds) {
|
|
51021
51264
|
if (!getPersona(personaId)) {
|
|
@@ -51023,46 +51266,109 @@ function validatePersonaIds(workflow) {
|
|
|
51023
51266
|
}
|
|
51024
51267
|
}
|
|
51025
51268
|
}
|
|
51026
|
-
function
|
|
51027
|
-
const
|
|
51028
|
-
const
|
|
51029
|
-
|
|
51030
|
-
|
|
51031
|
-
|
|
51269
|
+
function buildSandboxPlan(workflow, execution, runOptions) {
|
|
51270
|
+
const remoteDir = execution.sandboxRemoteDir ?? `/tmp/testers-workflow-${workflow.id.slice(0, 8)}`;
|
|
51271
|
+
const stateRemoteDir = `${remoteDir.replace(/\/+$/, "")}/.testers-state`;
|
|
51272
|
+
return {
|
|
51273
|
+
provider: execution.provider,
|
|
51274
|
+
image: execution.sandboxImage,
|
|
51275
|
+
name: `testers-${workflow.id.slice(0, 8)}`,
|
|
51276
|
+
remoteDir,
|
|
51277
|
+
stateRemoteDir,
|
|
51278
|
+
cleanup: execution.sandboxCleanup ?? "delete",
|
|
51032
51279
|
timeoutMs: execution.timeoutMs,
|
|
51033
|
-
env: execution.env
|
|
51034
|
-
command:
|
|
51035
|
-
|
|
51036
|
-
|
|
51037
|
-
|
|
51038
|
-
|
|
51039
|
-
|
|
51040
|
-
|
|
51041
|
-
|
|
51042
|
-
...runOptions.projectId ? ["--project", runOptions.projectId] : [],
|
|
51043
|
-
...runOptions.model ? ["--model", runOptions.model] : [],
|
|
51044
|
-
"--json"
|
|
51045
|
-
]
|
|
51046
|
-
});
|
|
51047
|
-
return ["connectors", "run", connector, operation, payload];
|
|
51280
|
+
env: execution.env,
|
|
51281
|
+
command: buildSandboxCommand({
|
|
51282
|
+
runOptions,
|
|
51283
|
+
remoteDir,
|
|
51284
|
+
dbPath: `${stateRemoteDir}/testers.db`,
|
|
51285
|
+
setupCommand: execution.setupCommand,
|
|
51286
|
+
packageSpec: execution.packageSpec ?? "@hasna/testers"
|
|
51287
|
+
})
|
|
51288
|
+
};
|
|
51048
51289
|
}
|
|
51049
|
-
|
|
51050
|
-
|
|
51051
|
-
|
|
51052
|
-
|
|
51053
|
-
|
|
51054
|
-
|
|
51055
|
-
|
|
51056
|
-
|
|
51057
|
-
|
|
51058
|
-
|
|
51059
|
-
|
|
51060
|
-
|
|
51061
|
-
|
|
51062
|
-
|
|
51063
|
-
|
|
51290
|
+
function buildSandboxCommand(input) {
|
|
51291
|
+
const args = [
|
|
51292
|
+
"bunx",
|
|
51293
|
+
input.packageSpec,
|
|
51294
|
+
"run",
|
|
51295
|
+
input.runOptions.url,
|
|
51296
|
+
...input.runOptions.scenarioIds?.length ? ["--scenario", input.runOptions.scenarioIds.join(",")] : [],
|
|
51297
|
+
...input.runOptions.tags?.length ? input.runOptions.tags.flatMap((tag) => ["--tag", tag]) : [],
|
|
51298
|
+
...input.runOptions.priority ? ["--priority", input.runOptions.priority] : [],
|
|
51299
|
+
...input.runOptions.projectId ? ["--project", input.runOptions.projectId] : [],
|
|
51300
|
+
...input.runOptions.model ? ["--model", input.runOptions.model] : [],
|
|
51301
|
+
...input.runOptions.headed ? ["--headed"] : [],
|
|
51302
|
+
...input.runOptions.parallel ? ["--parallel", String(input.runOptions.parallel)] : [],
|
|
51303
|
+
...input.runOptions.timeout ? ["--timeout", String(input.runOptions.timeout)] : [],
|
|
51304
|
+
...input.runOptions.personaIds?.length ? ["--persona", input.runOptions.personaIds.join(",")] : [],
|
|
51305
|
+
"--no-auto-generate",
|
|
51306
|
+
"--json"
|
|
51307
|
+
];
|
|
51308
|
+
return [
|
|
51309
|
+
"set -euo pipefail",
|
|
51310
|
+
`mkdir -p ${shellQuote(input.remoteDir)}`,
|
|
51311
|
+
`cd ${shellQuote(input.remoteDir)}`,
|
|
51312
|
+
input.setupCommand,
|
|
51313
|
+
`HASNA_TESTERS_DB_PATH=${shellQuote(input.dbPath)} ${args.map(shellQuote).join(" ")}`
|
|
51314
|
+
].filter(Boolean).join(`
|
|
51315
|
+
`);
|
|
51316
|
+
}
|
|
51317
|
+
async function runViaSandbox(plan, dependencies) {
|
|
51318
|
+
if (!plan.sandbox)
|
|
51319
|
+
throw new Error("Workflow does not have a sandbox plan");
|
|
51320
|
+
const sandboxes = await resolveSandboxesRuntime(dependencies);
|
|
51321
|
+
const createBundle = dependencies.createDatabaseBundle ?? createWorkflowDatabaseBundle;
|
|
51322
|
+
const bundle = createBundle(plan.workflow, plan);
|
|
51323
|
+
try {
|
|
51324
|
+
const raw = await sandboxes.runCommandInSandbox({
|
|
51325
|
+
command: plan.sandbox.command,
|
|
51326
|
+
provider: plan.sandbox.provider,
|
|
51327
|
+
name: plan.sandbox.name,
|
|
51328
|
+
image: plan.sandbox.image,
|
|
51329
|
+
sandboxTimeout: plan.sandbox.timeoutMs,
|
|
51330
|
+
commandTimeoutMs: plan.sandbox.timeoutMs,
|
|
51331
|
+
projectId: plan.workflow.projectId ?? undefined,
|
|
51332
|
+
config: {
|
|
51333
|
+
source: "testers",
|
|
51334
|
+
workflowId: plan.workflow.id,
|
|
51335
|
+
workflowName: plan.workflow.name
|
|
51336
|
+
},
|
|
51337
|
+
sandboxEnvVars: plan.sandbox.env,
|
|
51338
|
+
cleanup: plan.sandbox.cleanup,
|
|
51339
|
+
upload: {
|
|
51340
|
+
localDir: bundle.localDir,
|
|
51341
|
+
remoteDir: bundle.remoteDir
|
|
51342
|
+
}
|
|
51343
|
+
});
|
|
51344
|
+
const exitCode = raw.result.exit_code ?? raw.result.exitCode ?? 0;
|
|
51345
|
+
const stdout = raw.result.stdout ?? "";
|
|
51346
|
+
const stderr = raw.result.stderr ?? "";
|
|
51347
|
+
if (exitCode !== 0) {
|
|
51348
|
+
throw new Error(`Sandbox workflow execution failed (${exitCode}): ${stderr || stdout}`);
|
|
51349
|
+
}
|
|
51350
|
+
return {
|
|
51351
|
+
sandboxId: raw.sandbox.id,
|
|
51352
|
+
sessionId: raw.session.id,
|
|
51353
|
+
exitCode,
|
|
51354
|
+
stdout,
|
|
51355
|
+
stderr,
|
|
51356
|
+
cleanup: raw.cleanup
|
|
51357
|
+
};
|
|
51358
|
+
} finally {
|
|
51359
|
+
bundle.cleanup?.();
|
|
51064
51360
|
}
|
|
51065
|
-
|
|
51361
|
+
}
|
|
51362
|
+
async function resolveSandboxesRuntime(dependencies) {
|
|
51363
|
+
if (dependencies.sandboxes)
|
|
51364
|
+
return dependencies.sandboxes;
|
|
51365
|
+
if (dependencies.createSandboxesSDK)
|
|
51366
|
+
return dependencies.createSandboxesSDK();
|
|
51367
|
+
const mod = await import("@hasna/sandboxes");
|
|
51368
|
+
return mod.createSandboxesSDK();
|
|
51369
|
+
}
|
|
51370
|
+
function shellQuote(value) {
|
|
51371
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
51066
51372
|
}
|
|
51067
51373
|
|
|
51068
51374
|
// src/lib/workflow-agent.ts
|
|
@@ -51414,10 +51720,16 @@ var WorkflowFilterSchema = exports_external.object({
|
|
|
51414
51720
|
priority: exports_external.enum(["low", "medium", "high", "critical"]).optional()
|
|
51415
51721
|
}).optional();
|
|
51416
51722
|
var WorkflowExecutionSchema = exports_external.object({
|
|
51417
|
-
target: exports_external.enum(["local", "connector:e2b"]).default("local"),
|
|
51723
|
+
target: exports_external.enum(["local", "sandbox", "connector:e2b"]).default("local"),
|
|
51418
51724
|
connector: exports_external.string().optional(),
|
|
51419
51725
|
operation: exports_external.string().optional(),
|
|
51726
|
+
provider: exports_external.string().optional(),
|
|
51727
|
+
sandboxImage: exports_external.string().optional(),
|
|
51728
|
+
sandboxRemoteDir: exports_external.string().optional(),
|
|
51729
|
+
sandboxCleanup: exports_external.enum(["delete", "stop", "keep"]).optional(),
|
|
51420
51730
|
sandboxTemplate: exports_external.string().optional(),
|
|
51731
|
+
setupCommand: exports_external.string().optional(),
|
|
51732
|
+
packageSpec: exports_external.string().optional(),
|
|
51421
51733
|
timeoutMs: exports_external.number().int().positive().optional(),
|
|
51422
51734
|
env: exports_external.record(exports_external.string()).optional()
|
|
51423
51735
|
}).optional();
|
|
@@ -51499,7 +51811,7 @@ async function handleRequest(req) {
|
|
|
51499
51811
|
if (pathname === "/api/status" && method === "GET") {
|
|
51500
51812
|
const config2 = loadConfig();
|
|
51501
51813
|
getDatabase();
|
|
51502
|
-
const dbPath = process.env["HASNA_TESTERS_DB_PATH"] ?? process.env["TESTERS_DB_PATH"] ??
|
|
51814
|
+
const dbPath = process.env["HASNA_TESTERS_DB_PATH"] ?? process.env["TESTERS_DB_PATH"] ?? join14(getTestersDir(), "testers.db");
|
|
51503
51815
|
const scenarios = listScenarios();
|
|
51504
51816
|
const runs = listRuns();
|
|
51505
51817
|
return jsonResponse({
|
|
@@ -52229,7 +52541,7 @@ async function handleRequest(req) {
|
|
|
52229
52541
|
return jsonResponse({ routes, apiRoutes, totalCovered: coverageMap.size });
|
|
52230
52542
|
}
|
|
52231
52543
|
if (!pathname.startsWith("/api")) {
|
|
52232
|
-
const dashboardDir =
|
|
52544
|
+
const dashboardDir = join14(import.meta.dir, "..", "..", "dashboard", "dist");
|
|
52233
52545
|
if (!existsSync10(dashboardDir)) {
|
|
52234
52546
|
return new Response(`<!DOCTYPE html>
|
|
52235
52547
|
<html>
|
|
@@ -52248,7 +52560,7 @@ async function handleRequest(req) {
|
|
|
52248
52560
|
}
|
|
52249
52561
|
});
|
|
52250
52562
|
}
|
|
52251
|
-
const filePath =
|
|
52563
|
+
const filePath = join14(dashboardDir, pathname === "/" ? "index.html" : pathname);
|
|
52252
52564
|
if (existsSync10(filePath)) {
|
|
52253
52565
|
const file2 = Bun.file(filePath);
|
|
52254
52566
|
return new Response(file2, {
|
|
@@ -52258,7 +52570,7 @@ async function handleRequest(req) {
|
|
|
52258
52570
|
}
|
|
52259
52571
|
});
|
|
52260
52572
|
}
|
|
52261
|
-
const indexPath =
|
|
52573
|
+
const indexPath = join14(dashboardDir, "index.html");
|
|
52262
52574
|
if (existsSync10(indexPath)) {
|
|
52263
52575
|
const file2 = Bun.file(indexPath);
|
|
52264
52576
|
return new Response(file2, {
|