lua-cli 3.48.0 → 3.49.0
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/api-exports.d.ts +624 -15
- package/dist/api-exports.js +1021 -163
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +5103 -3126
- package/dist/index.js.map +1 -1
- package/dist/voice/test/index.d.ts +4 -4
- package/dist/voice-exports.d.ts +1 -1
- package/dist/voice-exports.js.map +1 -1
- package/dist/workflow-builder.d.ts +8 -1
- package/dist/workflow-builder.js +924 -145
- package/dist/workflow-builder.js.map +1 -1
- package/docs/CLI_REFERENCE.md +7 -5
- package/docs/README.md +3 -3
- package/docs/api/LuaDecision.md +9 -3
- package/docs/api/LuaWorkflow.md +1 -1
- package/docs/api/Workflows.md +2 -2
- package/package.json +2 -2
- package/template/package.json +1 -1
package/dist/workflow-builder.js
CHANGED
|
@@ -1195,6 +1195,7 @@ var DECISION_LIMITS = {
|
|
|
1195
1195
|
minLevels: 2,
|
|
1196
1196
|
maxLevels: 10,
|
|
1197
1197
|
maxInstructionChars: 4e3,
|
|
1198
|
+
maxQuestionsChars: 1e5,
|
|
1198
1199
|
maxStateChars: 12e4,
|
|
1199
1200
|
maxImages: 4,
|
|
1200
1201
|
maxImageBytes: 5 * 1024 * 1024,
|
|
@@ -1260,7 +1261,14 @@ var DecisionOptionsSchema = z.object({
|
|
|
1260
1261
|
"none"
|
|
1261
1262
|
]).optional()
|
|
1262
1263
|
});
|
|
1263
|
-
var DecisionQuestionsSchema = z.record(NameSchema, DecisionQuestionSchema).refine((questions) => Object.keys(questions).length >= 1 && Object.keys(questions).length <= DECISION_LIMITS.maxQuestions, `a decision needs between 1 and ${DECISION_LIMITS.maxQuestions} questions`)
|
|
1264
|
+
var DecisionQuestionsSchema = z.record(NameSchema, DecisionQuestionSchema).refine((questions) => Object.keys(questions).length >= 1 && Object.keys(questions).length <= DECISION_LIMITS.maxQuestions, `a decision needs between 1 and ${DECISION_LIMITS.maxQuestions} questions`).superRefine((questions, ctx) => {
|
|
1265
|
+
const chars = JSON.stringify(questions).length;
|
|
1266
|
+
if (chars <= DECISION_LIMITS.maxQuestionsChars) return;
|
|
1267
|
+
ctx.addIssue({
|
|
1268
|
+
code: z.ZodIssueCode.custom,
|
|
1269
|
+
message: `the questions take ${chars} characters as JSON, more than the ${DECISION_LIMITS.maxQuestionsChars} characters a decision may hold`
|
|
1270
|
+
});
|
|
1271
|
+
});
|
|
1264
1272
|
var DecisionDefinitionSchema = DecisionOptionsSchema.extend({
|
|
1265
1273
|
name: z.string().regex(DECISION_NAME_PATTERN, "a decision name is 1 to 64 letters, digits, underscores or hyphens"),
|
|
1266
1274
|
description: z.string().max(DECISION_LIMITS.maxInstructionChars).optional(),
|
|
@@ -1351,6 +1359,158 @@ function supervisionSubjectId(agentId2) {
|
|
|
1351
1359
|
}
|
|
1352
1360
|
__name(supervisionSubjectId, "supervisionSubjectId");
|
|
1353
1361
|
__name4(supervisionSubjectId, "supervisionSubjectId");
|
|
1362
|
+
var MESSAGING_CHANNELS = new Set(CHANNEL_CONVERSATION_CHANNELS);
|
|
1363
|
+
var VOICE_CHANNELS = /* @__PURE__ */ new Set([
|
|
1364
|
+
"phone",
|
|
1365
|
+
"meeting",
|
|
1366
|
+
"voice"
|
|
1367
|
+
]);
|
|
1368
|
+
var TURN_CATEGORIES = /* @__PURE__ */ new Set([
|
|
1369
|
+
"llm:inference",
|
|
1370
|
+
"llm:chat-modes",
|
|
1371
|
+
"llm:delegation",
|
|
1372
|
+
"decision:ask"
|
|
1373
|
+
]);
|
|
1374
|
+
var AGENT_TOOL_CATEGORIES = /* @__PURE__ */ new Set([
|
|
1375
|
+
"llm:media:describe",
|
|
1376
|
+
"tool:image-generate",
|
|
1377
|
+
"tool:image-edit"
|
|
1378
|
+
]);
|
|
1379
|
+
function isModelCallCategory(category) {
|
|
1380
|
+
return category.startsWith("llm:") || category.startsWith("voice:") || category === "embedding" || category === "workflow:job" || category === "decision:ask" || category.startsWith("tool:image-");
|
|
1381
|
+
}
|
|
1382
|
+
__name(isModelCallCategory, "isModelCallCategory");
|
|
1383
|
+
__name4(isModelCallCategory, "isModelCallCategory");
|
|
1384
|
+
function deriveUsageSurface(row) {
|
|
1385
|
+
const { category, channel } = row;
|
|
1386
|
+
const data = row.data;
|
|
1387
|
+
if (!isModelCallCategory(category)) return void 0;
|
|
1388
|
+
if (category === "workflow:job") return "workflow-job";
|
|
1389
|
+
if (category === "llm:sandbox") return "tool-code";
|
|
1390
|
+
if (category === "llm:builder") return "builder";
|
|
1391
|
+
if (category === "llm:website") return "website";
|
|
1392
|
+
if (category.startsWith("voice:") || category === "llm:voice") return "voice";
|
|
1393
|
+
if (category.startsWith("llm:tool:") || AGENT_TOOL_CATEGORIES.has(category)) return "agent-tool";
|
|
1394
|
+
if (!TURN_CATEGORIES.has(category)) return "background";
|
|
1395
|
+
if (channel === "workflow") return "workflow-step";
|
|
1396
|
+
if (data?.gateway === "livekit-inference") return "voice";
|
|
1397
|
+
if (channel === "dev") return "dev";
|
|
1398
|
+
if (channel && VOICE_CHANNELS.has(channel)) return "voice";
|
|
1399
|
+
if (channel && MESSAGING_CHANNELS.has(channel)) return "channel";
|
|
1400
|
+
return "chat";
|
|
1401
|
+
}
|
|
1402
|
+
__name(deriveUsageSurface, "deriveUsageSurface");
|
|
1403
|
+
__name4(deriveUsageSurface, "deriveUsageSurface");
|
|
1404
|
+
var count = /* @__PURE__ */ __name4((v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.floor(v) : void 0, "count");
|
|
1405
|
+
function fromRaw(raw, id2, model) {
|
|
1406
|
+
const fiveMin = count(raw.cache_creation?.ephemeral_5m_input_tokens);
|
|
1407
|
+
const oneHour = count(raw.cache_creation?.ephemeral_1h_input_tokens);
|
|
1408
|
+
const split = !!(fiveMin || oneHour);
|
|
1409
|
+
const flatWrite = count(raw.cache_creation_input_tokens);
|
|
1410
|
+
const read = count(raw.cache_read_input_tokens);
|
|
1411
|
+
return {
|
|
1412
|
+
...typeof id2 === "string" && id2 ? {
|
|
1413
|
+
id: id2
|
|
1414
|
+
} : {},
|
|
1415
|
+
...typeof model === "string" && model ? {
|
|
1416
|
+
model
|
|
1417
|
+
} : {},
|
|
1418
|
+
inputTokens: count(raw.input_tokens) ?? 0,
|
|
1419
|
+
outputTokens: count(raw.output_tokens) ?? 0,
|
|
1420
|
+
...read ? {
|
|
1421
|
+
cacheReadTokens: read
|
|
1422
|
+
} : {},
|
|
1423
|
+
...split ? {
|
|
1424
|
+
...fiveMin ? {
|
|
1425
|
+
cacheCreationTokens5m: fiveMin
|
|
1426
|
+
} : {},
|
|
1427
|
+
...oneHour ? {
|
|
1428
|
+
cacheCreationTokens1h: oneHour
|
|
1429
|
+
} : {}
|
|
1430
|
+
} : flatWrite ? {
|
|
1431
|
+
cacheCreationTokens: flatWrite
|
|
1432
|
+
} : {},
|
|
1433
|
+
...typeof raw.service_tier === "string" && raw.service_tier && raw.service_tier !== "standard" ? {
|
|
1434
|
+
serviceTier: raw.service_tier
|
|
1435
|
+
} : {}
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
__name(fromRaw, "fromRaw");
|
|
1439
|
+
__name4(fromRaw, "fromRaw");
|
|
1440
|
+
function anthropicMessageUsage(message) {
|
|
1441
|
+
if (!message || typeof message !== "object") return void 0;
|
|
1442
|
+
const m = message;
|
|
1443
|
+
if (!m.usage || typeof m.usage !== "object") return void 0;
|
|
1444
|
+
return fromRaw(m.usage, m.id, m.model);
|
|
1445
|
+
}
|
|
1446
|
+
__name(anthropicMessageUsage, "anthropicMessageUsage");
|
|
1447
|
+
__name4(anthropicMessageUsage, "anthropicMessageUsage");
|
|
1448
|
+
var AnthropicSseUsageReader = class {
|
|
1449
|
+
static {
|
|
1450
|
+
__name(this, "AnthropicSseUsageReader");
|
|
1451
|
+
}
|
|
1452
|
+
static {
|
|
1453
|
+
__name4(this, "AnthropicSseUsageReader");
|
|
1454
|
+
}
|
|
1455
|
+
pending = "";
|
|
1456
|
+
raw;
|
|
1457
|
+
id;
|
|
1458
|
+
model;
|
|
1459
|
+
push(chunk) {
|
|
1460
|
+
const text2 = this.pending + chunk;
|
|
1461
|
+
const lines = text2.split("\n");
|
|
1462
|
+
this.pending = lines.pop() ?? "";
|
|
1463
|
+
for (const line of lines) this.line(line);
|
|
1464
|
+
}
|
|
1465
|
+
result() {
|
|
1466
|
+
if (this.pending) {
|
|
1467
|
+
this.line(this.pending);
|
|
1468
|
+
this.pending = "";
|
|
1469
|
+
}
|
|
1470
|
+
return this.raw ? fromRaw(this.raw, this.id, this.model) : void 0;
|
|
1471
|
+
}
|
|
1472
|
+
line(line) {
|
|
1473
|
+
const trimmed = line.trim();
|
|
1474
|
+
if (!trimmed.startsWith("data:")) return;
|
|
1475
|
+
let event;
|
|
1476
|
+
try {
|
|
1477
|
+
event = JSON.parse(trimmed.slice(5).trim());
|
|
1478
|
+
} catch {
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
if (event.type === "message_start" && event.message) {
|
|
1482
|
+
this.id = event.message.id;
|
|
1483
|
+
this.model = event.message.model;
|
|
1484
|
+
this.raw = {
|
|
1485
|
+
...event.message.usage ?? {}
|
|
1486
|
+
};
|
|
1487
|
+
} else if (event.type === "message_delta" && event.usage && typeof event.usage === "object") {
|
|
1488
|
+
const delta = event.usage;
|
|
1489
|
+
const merged = {
|
|
1490
|
+
...this.raw ?? {}
|
|
1491
|
+
};
|
|
1492
|
+
for (const [key, value3] of Object.entries(delta)) {
|
|
1493
|
+
if (value3 !== null && value3 !== void 0) merged[key] = value3;
|
|
1494
|
+
}
|
|
1495
|
+
this.raw = merged;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
function parseAnthropicReplyUsage(body) {
|
|
1500
|
+
const start = body.trimStart();
|
|
1501
|
+
if (start.startsWith("{")) {
|
|
1502
|
+
try {
|
|
1503
|
+
return anthropicMessageUsage(JSON.parse(start));
|
|
1504
|
+
} catch {
|
|
1505
|
+
return void 0;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
const reader = new AnthropicSseUsageReader();
|
|
1509
|
+
reader.push(body);
|
|
1510
|
+
return reader.result();
|
|
1511
|
+
}
|
|
1512
|
+
__name(parseAnthropicReplyUsage, "parseAnthropicReplyUsage");
|
|
1513
|
+
__name4(parseAnthropicReplyUsage, "parseAnthropicReplyUsage");
|
|
1354
1514
|
var SUPERVISION_OPS = {
|
|
1355
1515
|
"agents.list": "discover",
|
|
1356
1516
|
"agents.get": "discover",
|
|
@@ -3430,24 +3590,24 @@ __name4(addresses, "addresses");
|
|
|
3430
3590
|
function recordFacts(value3) {
|
|
3431
3591
|
const senders = [];
|
|
3432
3592
|
const labels = [];
|
|
3433
|
-
let
|
|
3593
|
+
let isRecord32 = false;
|
|
3434
3594
|
if (isPlainObject(value3.author_member)) {
|
|
3435
|
-
|
|
3595
|
+
isRecord32 = true;
|
|
3436
3596
|
const email = lower(value3.author_member.email);
|
|
3437
3597
|
if (email) senders.push(email);
|
|
3438
3598
|
const userId = lower(value3.author_member.user_id);
|
|
3439
3599
|
if (userId) senders.push(userId);
|
|
3440
3600
|
}
|
|
3441
3601
|
if (typeof value3.channel_id === "string") {
|
|
3442
|
-
|
|
3602
|
+
isRecord32 = true;
|
|
3443
3603
|
labels.push(...idOrName(value3.channel_id));
|
|
3444
3604
|
}
|
|
3445
3605
|
if (Array.isArray(value3.channel_ids)) {
|
|
3446
|
-
|
|
3606
|
+
isRecord32 = true;
|
|
3447
3607
|
for (const id2 of value3.channel_ids) labels.push(...idOrName(id2));
|
|
3448
3608
|
}
|
|
3449
3609
|
if (Array.isArray(value3.channels) && (value3.author_member || value3.message !== void 0)) {
|
|
3450
|
-
|
|
3610
|
+
isRecord32 = true;
|
|
3451
3611
|
for (const channel of value3.channels) labels.push(...idOrName(channel));
|
|
3452
3612
|
}
|
|
3453
3613
|
for (const key of [
|
|
@@ -3456,11 +3616,11 @@ function recordFacts(value3) {
|
|
|
3456
3616
|
]) {
|
|
3457
3617
|
const field = value3[key];
|
|
3458
3618
|
if (isPlainObject(field) && isPlainObject(field.emailAddress)) {
|
|
3459
|
-
|
|
3619
|
+
isRecord32 = true;
|
|
3460
3620
|
const address = lower(field.emailAddress.address);
|
|
3461
3621
|
if (address) senders.push(address);
|
|
3462
3622
|
} else if (key === "from" && typeof field === "string" && field.includes("@")) {
|
|
3463
|
-
|
|
3623
|
+
isRecord32 = true;
|
|
3464
3624
|
senders.push(...addresses(field));
|
|
3465
3625
|
}
|
|
3466
3626
|
}
|
|
@@ -3468,12 +3628,12 @@ function recordFacts(value3) {
|
|
|
3468
3628
|
const organizer = value3.organizer;
|
|
3469
3629
|
const address = isPlainObject(organizer.emailAddress) ? lower(organizer.emailAddress.address) : lower(organizer.email);
|
|
3470
3630
|
if (address) {
|
|
3471
|
-
|
|
3631
|
+
isRecord32 = true;
|
|
3472
3632
|
senders.push(address);
|
|
3473
3633
|
}
|
|
3474
3634
|
}
|
|
3475
3635
|
if (Array.isArray(value3.categories)) {
|
|
3476
|
-
|
|
3636
|
+
isRecord32 = true;
|
|
3477
3637
|
for (const category of value3.categories) labels.push(...idOrName(category));
|
|
3478
3638
|
}
|
|
3479
3639
|
if (isPlainObject(value3.from)) {
|
|
@@ -3484,13 +3644,13 @@ function recordFacts(value3) {
|
|
|
3484
3644
|
]) {
|
|
3485
3645
|
const identity = value3.from[key];
|
|
3486
3646
|
if (!isPlainObject(identity)) continue;
|
|
3487
|
-
|
|
3647
|
+
isRecord32 = true;
|
|
3488
3648
|
const id2 = lower(identity.id);
|
|
3489
3649
|
if (id2) senders.push(id2);
|
|
3490
3650
|
}
|
|
3491
3651
|
}
|
|
3492
3652
|
if (isPlainObject(value3.channelIdentity)) {
|
|
3493
|
-
|
|
3653
|
+
isRecord32 = true;
|
|
3494
3654
|
for (const key of [
|
|
3495
3655
|
"channelId",
|
|
3496
3656
|
"teamId"
|
|
@@ -3500,21 +3660,21 @@ function recordFacts(value3) {
|
|
|
3500
3660
|
}
|
|
3501
3661
|
}
|
|
3502
3662
|
if (typeof value3.chatId === "string") {
|
|
3503
|
-
|
|
3663
|
+
isRecord32 = true;
|
|
3504
3664
|
labels.push(...idOrName(value3.chatId));
|
|
3505
3665
|
}
|
|
3506
3666
|
if (typeof value3.parentFolderId === "string") {
|
|
3507
|
-
|
|
3667
|
+
isRecord32 = true;
|
|
3508
3668
|
labels.push(...idOrName(value3.parentFolderId));
|
|
3509
3669
|
}
|
|
3510
3670
|
let gmailSenderUnknown = false;
|
|
3511
3671
|
const gmailMessage = typeof value3.threadId === "string" && (Array.isArray(value3.labelIds) || "payload" in value3 || "raw" in value3) || isPlainObject(value3.payload) && Array.isArray(value3.payload.headers);
|
|
3512
3672
|
if (Array.isArray(value3.labelIds)) {
|
|
3513
|
-
|
|
3673
|
+
isRecord32 = true;
|
|
3514
3674
|
for (const id2 of value3.labelIds) labels.push(...idOrName(id2));
|
|
3515
3675
|
}
|
|
3516
3676
|
if (gmailMessage) {
|
|
3517
|
-
|
|
3677
|
+
isRecord32 = true;
|
|
3518
3678
|
const headers = isPlainObject(value3.payload) && Array.isArray(value3.payload.headers) ? value3.payload.headers : [];
|
|
3519
3679
|
const from = headers.find((header) => isPlainObject(header) && lower(header.name) === "from");
|
|
3520
3680
|
const fromAddresses = addresses(from?.value);
|
|
@@ -3522,11 +3682,11 @@ function recordFacts(value3) {
|
|
|
3522
3682
|
else gmailSenderUnknown = true;
|
|
3523
3683
|
}
|
|
3524
3684
|
if (Array.isArray(value3.labels)) {
|
|
3525
|
-
|
|
3685
|
+
isRecord32 = true;
|
|
3526
3686
|
for (const label of value3.labels) labels.push(...idOrName(label));
|
|
3527
3687
|
}
|
|
3528
3688
|
if (typeof value3.ts === "string" && (typeof value3.user === "string" || typeof value3.bot_id === "string")) {
|
|
3529
|
-
|
|
3689
|
+
isRecord32 = true;
|
|
3530
3690
|
for (const id2 of [
|
|
3531
3691
|
value3.user,
|
|
3532
3692
|
value3.bot_id,
|
|
@@ -3542,7 +3702,7 @@ function recordFacts(value3) {
|
|
|
3542
3702
|
labels.push(...idOrName(value3.channel));
|
|
3543
3703
|
}
|
|
3544
3704
|
return {
|
|
3545
|
-
isRecord:
|
|
3705
|
+
isRecord: isRecord32,
|
|
3546
3706
|
senders,
|
|
3547
3707
|
labels,
|
|
3548
3708
|
gmailSenderUnknown
|
|
@@ -6477,6 +6637,10 @@ var BROWSER_COMMANDS = [
|
|
|
6477
6637
|
name: "close",
|
|
6478
6638
|
description: "Close the session\u2019s browser."
|
|
6479
6639
|
},
|
|
6640
|
+
{
|
|
6641
|
+
name: "read",
|
|
6642
|
+
description: "Read one page in a fresh session that is closed afterwards: open the URL, wait, return its title and content. Args: url, waitFor?(load|networkidle|selector), selector?, format?(text|html|markdown), timeoutMs?."
|
|
6643
|
+
},
|
|
6480
6644
|
// perception
|
|
6481
6645
|
{
|
|
6482
6646
|
name: "snapshot",
|
|
@@ -6650,6 +6814,91 @@ var BROWSER_COMMANDS = [
|
|
|
6650
6814
|
}
|
|
6651
6815
|
];
|
|
6652
6816
|
var BROWSER_COMMAND_NAMES = BROWSER_COMMANDS.map((c) => c.name);
|
|
6817
|
+
var SERVER_TRIGGERED_BROWSER_SOURCES = [
|
|
6818
|
+
"job",
|
|
6819
|
+
"webhook",
|
|
6820
|
+
"web-route",
|
|
6821
|
+
"trigger",
|
|
6822
|
+
"workflow-step",
|
|
6823
|
+
"workflow-script"
|
|
6824
|
+
];
|
|
6825
|
+
function isServerTriggeredBrowserSource(logSource) {
|
|
6826
|
+
return SERVER_TRIGGERED_BROWSER_SOURCES.includes(logSource);
|
|
6827
|
+
}
|
|
6828
|
+
__name(isServerTriggeredBrowserSource, "isServerTriggeredBrowserSource");
|
|
6829
|
+
__name4(isServerTriggeredBrowserSource, "isServerTriggeredBrowserSource");
|
|
6830
|
+
var BROWSER_FALLBACKS = [
|
|
6831
|
+
"browser-use",
|
|
6832
|
+
"none"
|
|
6833
|
+
];
|
|
6834
|
+
var DEFAULT_BROWSER_FALLBACK = "browser-use";
|
|
6835
|
+
function resolveBrowserFallback(raw) {
|
|
6836
|
+
return BROWSER_FALLBACKS.includes(raw) ? raw : DEFAULT_BROWSER_FALLBACK;
|
|
6837
|
+
}
|
|
6838
|
+
__name(resolveBrowserFallback, "resolveBrowserFallback");
|
|
6839
|
+
__name4(resolveBrowserFallback, "resolveBrowserFallback");
|
|
6840
|
+
var PROXY_COUNTRY_CODE = /^[a-z]{2}$/;
|
|
6841
|
+
function resolveBrowserProxyCountry(raw) {
|
|
6842
|
+
if (typeof raw !== "string") return void 0;
|
|
6843
|
+
const code = raw.trim().toLowerCase();
|
|
6844
|
+
return PROXY_COUNTRY_CODE.test(code) ? code : void 0;
|
|
6845
|
+
}
|
|
6846
|
+
__name(resolveBrowserProxyCountry, "resolveBrowserProxyCountry");
|
|
6847
|
+
__name4(resolveBrowserProxyCountry, "resolveBrowserProxyCountry");
|
|
6848
|
+
var BROWSER_LOG_CONTENT_MODES = [
|
|
6849
|
+
"summary",
|
|
6850
|
+
"full",
|
|
6851
|
+
"none"
|
|
6852
|
+
];
|
|
6853
|
+
var DEFAULT_BROWSER_LOG_CONTENT = "summary";
|
|
6854
|
+
var BROWSER_SCREENSHOT_POLICIES = [
|
|
6855
|
+
"always",
|
|
6856
|
+
"onError",
|
|
6857
|
+
"never"
|
|
6858
|
+
];
|
|
6859
|
+
var DEFAULT_BROWSER_SCREENSHOT_POLICY = "onError";
|
|
6860
|
+
function resolveBrowserLogOptions(raw) {
|
|
6861
|
+
const logContent = BROWSER_LOG_CONTENT_MODES.includes(raw.logContent) ? raw.logContent : DEFAULT_BROWSER_LOG_CONTENT;
|
|
6862
|
+
const screenshots = BROWSER_SCREENSHOT_POLICIES.includes(raw.screenshots) ? raw.screenshots : DEFAULT_BROWSER_SCREENSHOT_POLICY;
|
|
6863
|
+
return {
|
|
6864
|
+
logContent,
|
|
6865
|
+
screenshots
|
|
6866
|
+
};
|
|
6867
|
+
}
|
|
6868
|
+
__name(resolveBrowserLogOptions, "resolveBrowserLogOptions");
|
|
6869
|
+
__name4(resolveBrowserLogOptions, "resolveBrowserLogOptions");
|
|
6870
|
+
function browserProfileNotFoundMessage(name) {
|
|
6871
|
+
return `No browser named '${name}' is attached to this agent. Add it to the agent's \`browsers\` list and push again.`;
|
|
6872
|
+
}
|
|
6873
|
+
__name(browserProfileNotFoundMessage, "browserProfileNotFoundMessage");
|
|
6874
|
+
__name4(browserProfileNotFoundMessage, "browserProfileNotFoundMessage");
|
|
6875
|
+
var BROWSER_LIMIT_KEYS = [
|
|
6876
|
+
"maxSessionMinutes",
|
|
6877
|
+
"idleTimeoutSeconds",
|
|
6878
|
+
"maxConcurrentSessions"
|
|
6879
|
+
];
|
|
6880
|
+
var BROWSER_LIMIT_MAX = {
|
|
6881
|
+
maxSessionMinutes: 60,
|
|
6882
|
+
idleTimeoutSeconds: 15 * 60,
|
|
6883
|
+
maxConcurrentSessions: 100
|
|
6884
|
+
};
|
|
6885
|
+
function resolveBrowserLimits(pick) {
|
|
6886
|
+
const limits = {};
|
|
6887
|
+
for (const key of BROWSER_LIMIT_KEYS) {
|
|
6888
|
+
const value3 = pick(key);
|
|
6889
|
+
if (typeof value3 === "number" && Number.isInteger(value3) && value3 > 0) limits[key] = value3;
|
|
6890
|
+
}
|
|
6891
|
+
return limits;
|
|
6892
|
+
}
|
|
6893
|
+
__name(resolveBrowserLimits, "resolveBrowserLimits");
|
|
6894
|
+
__name4(resolveBrowserLimits, "resolveBrowserLimits");
|
|
6895
|
+
var BROWSER_EXECUTE_METHOD = "execute";
|
|
6896
|
+
var BROWSER_GLOBAL_METHODS = [
|
|
6897
|
+
...BROWSER_COMMAND_NAMES,
|
|
6898
|
+
BROWSER_EXECUTE_METHOD
|
|
6899
|
+
];
|
|
6900
|
+
var BROWSER_EXECUTE_DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
6901
|
+
var BROWSER_EXECUTE_MAX_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
6653
6902
|
var LOG_FIELDS_MAX_KEYS = 32;
|
|
6654
6903
|
var LOG_FIELD_MAX_VALUE_BYTES = 1024;
|
|
6655
6904
|
var LOG_FIELDS_MAX_BYTES = 8192;
|
|
@@ -6870,6 +7119,640 @@ function isDesktopFileSessionId(value3) {
|
|
|
6870
7119
|
}
|
|
6871
7120
|
__name(isDesktopFileSessionId, "isDesktopFileSessionId");
|
|
6872
7121
|
__name4(isDesktopFileSessionId, "isDesktopFileSessionId");
|
|
7122
|
+
var BROWSER_READ_FORMATS = [
|
|
7123
|
+
"text",
|
|
7124
|
+
"html",
|
|
7125
|
+
"markdown"
|
|
7126
|
+
];
|
|
7127
|
+
var BROWSER_READ_DEFAULT_TIMEOUT_MS = 6e4;
|
|
7128
|
+
var BROWSER_READ_MIN_TIMEOUT_MS = 1e3;
|
|
7129
|
+
var BROWSER_READ_MAX_TIMEOUT_MS = 1e5;
|
|
7130
|
+
var BROWSER_READ_MAX_CONTENT_CHARS = 1e5;
|
|
7131
|
+
var BROWSER_READ_DEFAULT_SELECTOR = "body";
|
|
7132
|
+
var BROWSER_READ_MATCH_SEPARATOR = "\n\n";
|
|
7133
|
+
var BROWSER_READ_LOGIN_BLOCKER = "login_required";
|
|
7134
|
+
var BROWSER_ERROR_NAME = "BrowserError";
|
|
7135
|
+
function browserError(code, message, status) {
|
|
7136
|
+
return Object.assign(new Error(message), {
|
|
7137
|
+
name: BROWSER_ERROR_NAME,
|
|
7138
|
+
code,
|
|
7139
|
+
...typeof status === "number" ? {
|
|
7140
|
+
status
|
|
7141
|
+
} : {}
|
|
7142
|
+
});
|
|
7143
|
+
}
|
|
7144
|
+
__name(browserError, "browserError");
|
|
7145
|
+
__name4(browserError, "browserError");
|
|
7146
|
+
function isRecord(value3) {
|
|
7147
|
+
return typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
|
|
7148
|
+
}
|
|
7149
|
+
__name(isRecord, "isRecord");
|
|
7150
|
+
__name4(isRecord, "isRecord");
|
|
7151
|
+
function optionalString(raw, field) {
|
|
7152
|
+
const value3 = raw[field];
|
|
7153
|
+
if (value3 === void 0 || value3 === null || value3 === "") return void 0;
|
|
7154
|
+
if (typeof value3 !== "string") throw new TypeError(`${field} must be a string`);
|
|
7155
|
+
if (value3.startsWith("-")) throw new TypeError(`${field} may not start with '-'`);
|
|
7156
|
+
if (value3.includes("\0")) throw new TypeError(`${field} may not contain NUL`);
|
|
7157
|
+
return value3;
|
|
7158
|
+
}
|
|
7159
|
+
__name(optionalString, "optionalString");
|
|
7160
|
+
__name4(optionalString, "optionalString");
|
|
7161
|
+
function readUrl(value3) {
|
|
7162
|
+
if (typeof value3 !== "string" || !/^https?:\/\//i.test(value3.trim()) || value3.includes("\0")) {
|
|
7163
|
+
throw new TypeError("url must be an absolute http(s) URL");
|
|
7164
|
+
}
|
|
7165
|
+
return value3.trim();
|
|
7166
|
+
}
|
|
7167
|
+
__name(readUrl, "readUrl");
|
|
7168
|
+
__name4(readUrl, "readUrl");
|
|
7169
|
+
function readFormat(value3) {
|
|
7170
|
+
if (value3 === void 0 || value3 === null || value3 === "") return "text";
|
|
7171
|
+
if (!BROWSER_READ_FORMATS.includes(value3)) {
|
|
7172
|
+
throw new TypeError(`format must be one of: ${BROWSER_READ_FORMATS.join(", ")}`);
|
|
7173
|
+
}
|
|
7174
|
+
return value3;
|
|
7175
|
+
}
|
|
7176
|
+
__name(readFormat, "readFormat");
|
|
7177
|
+
__name4(readFormat, "readFormat");
|
|
7178
|
+
function readTimeout(value3) {
|
|
7179
|
+
if (value3 === void 0 || value3 === null) return BROWSER_READ_DEFAULT_TIMEOUT_MS;
|
|
7180
|
+
if (typeof value3 !== "number" || !Number.isFinite(value3)) throw new TypeError("timeoutMs must be a number");
|
|
7181
|
+
return Math.min(BROWSER_READ_MAX_TIMEOUT_MS, Math.max(BROWSER_READ_MIN_TIMEOUT_MS, Math.round(value3)));
|
|
7182
|
+
}
|
|
7183
|
+
__name(readTimeout, "readTimeout");
|
|
7184
|
+
__name4(readTimeout, "readTimeout");
|
|
7185
|
+
function parseBrowserReadPayload(raw) {
|
|
7186
|
+
try {
|
|
7187
|
+
const input = isRecord(raw) ? raw : {};
|
|
7188
|
+
const waitFor = optionalString(input, "waitFor");
|
|
7189
|
+
return {
|
|
7190
|
+
payload: {
|
|
7191
|
+
url: readUrl(input.url),
|
|
7192
|
+
...waitFor ? {
|
|
7193
|
+
waitFor
|
|
7194
|
+
} : {},
|
|
7195
|
+
selector: optionalString(input, "selector") ?? BROWSER_READ_DEFAULT_SELECTOR,
|
|
7196
|
+
format: readFormat(input.format),
|
|
7197
|
+
timeoutMs: readTimeout(input.timeoutMs)
|
|
7198
|
+
}
|
|
7199
|
+
};
|
|
7200
|
+
} catch (error) {
|
|
7201
|
+
return {
|
|
7202
|
+
error: {
|
|
7203
|
+
code: "invalid_argument",
|
|
7204
|
+
message: `read: ${error.message}`
|
|
7205
|
+
}
|
|
7206
|
+
};
|
|
7207
|
+
}
|
|
7208
|
+
}
|
|
7209
|
+
__name(parseBrowserReadPayload, "parseBrowserReadPayload");
|
|
7210
|
+
__name4(parseBrowserReadPayload, "parseBrowserReadPayload");
|
|
7211
|
+
function clampBrowserReadContent(content, maxChars = BROWSER_READ_MAX_CONTENT_CHARS) {
|
|
7212
|
+
if (content.length <= maxChars) return {
|
|
7213
|
+
content,
|
|
7214
|
+
truncated: false
|
|
7215
|
+
};
|
|
7216
|
+
return {
|
|
7217
|
+
content: content.slice(0, maxChars),
|
|
7218
|
+
truncated: true
|
|
7219
|
+
};
|
|
7220
|
+
}
|
|
7221
|
+
__name(clampBrowserReadContent, "clampBrowserReadContent");
|
|
7222
|
+
__name4(clampBrowserReadContent, "clampBrowserReadContent");
|
|
7223
|
+
function joinBrowserReadMatches(parts, maxChars = BROWSER_READ_MAX_CONTENT_CHARS) {
|
|
7224
|
+
const kept = parts.map((part) => part.trim()).filter((part) => part.length > 0);
|
|
7225
|
+
return clampBrowserReadContent(kept.join(BROWSER_READ_MATCH_SEPARATOR), maxChars);
|
|
7226
|
+
}
|
|
7227
|
+
__name(joinBrowserReadMatches, "joinBrowserReadMatches");
|
|
7228
|
+
__name4(joinBrowserReadMatches, "joinBrowserReadMatches");
|
|
7229
|
+
var HTTP_STATUS_FAILURE = /ERR_HTTP_RESPONSE_CODE_FAILURE/;
|
|
7230
|
+
function isBrowserReadHttpFailure(message) {
|
|
7231
|
+
return HTTP_STATUS_FAILURE.test(message ?? "");
|
|
7232
|
+
}
|
|
7233
|
+
__name(isBrowserReadHttpFailure, "isBrowserReadHttpFailure");
|
|
7234
|
+
__name4(isBrowserReadHttpFailure, "isBrowserReadHttpFailure");
|
|
7235
|
+
function browserReadHttpErrorMessage(url, status) {
|
|
7236
|
+
const answered = status === void 0 ? "an HTTP error status" : `HTTP ${status}`;
|
|
7237
|
+
return `read: ${url} answered ${answered} with no page to read`;
|
|
7238
|
+
}
|
|
7239
|
+
__name(browserReadHttpErrorMessage, "browserReadHttpErrorMessage");
|
|
7240
|
+
__name4(browserReadHttpErrorMessage, "browserReadHttpErrorMessage");
|
|
7241
|
+
function urlOf(value3) {
|
|
7242
|
+
if (!value3) return void 0;
|
|
7243
|
+
try {
|
|
7244
|
+
return new URL(value3);
|
|
7245
|
+
} catch {
|
|
7246
|
+
return void 0;
|
|
7247
|
+
}
|
|
7248
|
+
}
|
|
7249
|
+
__name(urlOf, "urlOf");
|
|
7250
|
+
__name4(urlOf, "urlOf");
|
|
7251
|
+
function answeredDocuments(requests) {
|
|
7252
|
+
if (!Array.isArray(requests)) return [];
|
|
7253
|
+
const answered = [];
|
|
7254
|
+
for (const entry of requests) {
|
|
7255
|
+
if (!isRecord(entry) || typeof entry.status !== "number" || typeof entry.url !== "string") continue;
|
|
7256
|
+
const url = urlOf(entry.url);
|
|
7257
|
+
if (url) answered.unshift({
|
|
7258
|
+
url,
|
|
7259
|
+
status: entry.status
|
|
7260
|
+
});
|
|
7261
|
+
}
|
|
7262
|
+
return answered;
|
|
7263
|
+
}
|
|
7264
|
+
__name(answeredDocuments, "answeredDocuments");
|
|
7265
|
+
__name4(answeredDocuments, "answeredDocuments");
|
|
7266
|
+
function documentStatusOf(requests, requestedUrl, finalUrl) {
|
|
7267
|
+
const latestFirst = answeredDocuments(requests);
|
|
7268
|
+
const final = urlOf(finalUrl);
|
|
7269
|
+
const requested = urlOf(requestedUrl);
|
|
7270
|
+
const match = latestFirst.find((doc) => doc.url.href === final?.href) ?? latestFirst.find((doc) => doc.url.href === requested?.href) ?? latestFirst.find((doc) => doc.url.host === final?.host);
|
|
7271
|
+
return match?.status;
|
|
7272
|
+
}
|
|
7273
|
+
__name(documentStatusOf, "documentStatusOf");
|
|
7274
|
+
__name4(documentStatusOf, "documentStatusOf");
|
|
7275
|
+
var LOGIN_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
7276
|
+
"login",
|
|
7277
|
+
"log-in",
|
|
7278
|
+
"logon",
|
|
7279
|
+
"signin",
|
|
7280
|
+
"sign-in",
|
|
7281
|
+
"sign_in",
|
|
7282
|
+
"auth",
|
|
7283
|
+
"authenticate",
|
|
7284
|
+
"authorize",
|
|
7285
|
+
"sso"
|
|
7286
|
+
]);
|
|
7287
|
+
var LOGIN_HOST_LABELS = /* @__PURE__ */ new Set([
|
|
7288
|
+
"login",
|
|
7289
|
+
"signin",
|
|
7290
|
+
"auth",
|
|
7291
|
+
"sso"
|
|
7292
|
+
]);
|
|
7293
|
+
function isLoginUrl(url) {
|
|
7294
|
+
const segments = url.pathname.toLowerCase().split("/");
|
|
7295
|
+
return segments.some((segment) => LOGIN_PATH_SEGMENTS.has(segment)) || LOGIN_HOST_LABELS.has(url.hostname.split(".")[0]);
|
|
7296
|
+
}
|
|
7297
|
+
__name(isLoginUrl, "isLoginUrl");
|
|
7298
|
+
__name4(isLoginUrl, "isLoginUrl");
|
|
7299
|
+
function isLoginRedirect(requestedUrl, finalUrl) {
|
|
7300
|
+
const requested = urlOf(requestedUrl);
|
|
7301
|
+
const final = urlOf(finalUrl);
|
|
7302
|
+
return Boolean(requested && final && !isLoginUrl(requested) && isLoginUrl(final));
|
|
7303
|
+
}
|
|
7304
|
+
__name(isLoginRedirect, "isLoginRedirect");
|
|
7305
|
+
__name4(isLoginRedirect, "isLoginRedirect");
|
|
7306
|
+
function browserReadLoginBlock() {
|
|
7307
|
+
return {
|
|
7308
|
+
blocked: true,
|
|
7309
|
+
blocker: BROWSER_READ_LOGIN_BLOCKER,
|
|
7310
|
+
blockerKind: "login",
|
|
7311
|
+
blockerGuidance: "This URL redirected to a sign-in page, so the content is the sign-in form, not the page you asked for. The page needs a signed-in session: read it on the desktop browser where the user is signed in, or use a public URL."
|
|
7312
|
+
};
|
|
7313
|
+
}
|
|
7314
|
+
__name(browserReadLoginBlock, "browserReadLoginBlock");
|
|
7315
|
+
__name4(browserReadLoginBlock, "browserReadLoginBlock");
|
|
7316
|
+
var AGENT_LOG_SOURCES = [
|
|
7317
|
+
"skill",
|
|
7318
|
+
"job",
|
|
7319
|
+
"webhook",
|
|
7320
|
+
"web-route",
|
|
7321
|
+
"trigger",
|
|
7322
|
+
"preprocessor",
|
|
7323
|
+
"postprocessor",
|
|
7324
|
+
"user_message",
|
|
7325
|
+
"agent_response",
|
|
7326
|
+
"agent_error",
|
|
7327
|
+
"runtime",
|
|
7328
|
+
"mcp",
|
|
7329
|
+
"rag",
|
|
7330
|
+
"device",
|
|
7331
|
+
"device-trigger",
|
|
7332
|
+
"model-resolver",
|
|
7333
|
+
"workflow-step",
|
|
7334
|
+
"workflow-script",
|
|
7335
|
+
"workflow",
|
|
7336
|
+
"supervision",
|
|
7337
|
+
"browser",
|
|
7338
|
+
"decisions"
|
|
7339
|
+
];
|
|
7340
|
+
var AGENT_LOG_ENVIRONMENTS = [
|
|
7341
|
+
"production",
|
|
7342
|
+
"sandbox"
|
|
7343
|
+
];
|
|
7344
|
+
var AGENT_LOG_FIELDS_MAX_WIRE_KEYS = LOG_FIELDS_MAX_KEYS + 1;
|
|
7345
|
+
function utf8Bytes(value3) {
|
|
7346
|
+
let bytes = 0;
|
|
7347
|
+
for (let i = 0; i < value3.length; ) {
|
|
7348
|
+
const code = value3.charCodeAt(i);
|
|
7349
|
+
if (code < 128) {
|
|
7350
|
+
bytes += 1;
|
|
7351
|
+
i += 1;
|
|
7352
|
+
} else if (code < 2048) {
|
|
7353
|
+
bytes += 2;
|
|
7354
|
+
i += 1;
|
|
7355
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
7356
|
+
const next = value3.charCodeAt(i + 1);
|
|
7357
|
+
if (next >= 56320 && next <= 57343) {
|
|
7358
|
+
bytes += 4;
|
|
7359
|
+
i += 2;
|
|
7360
|
+
} else {
|
|
7361
|
+
bytes += 3;
|
|
7362
|
+
i += 1;
|
|
7363
|
+
}
|
|
7364
|
+
} else {
|
|
7365
|
+
bytes += 3;
|
|
7366
|
+
i += 1;
|
|
7367
|
+
}
|
|
7368
|
+
}
|
|
7369
|
+
return bytes;
|
|
7370
|
+
}
|
|
7371
|
+
__name(utf8Bytes, "utf8Bytes");
|
|
7372
|
+
__name4(utf8Bytes, "utf8Bytes");
|
|
7373
|
+
function isPlainFieldKey(key) {
|
|
7374
|
+
if (!LOG_FIELD_KEY_PATTERN.test(key)) return false;
|
|
7375
|
+
if (key === LOG_FIELDS_CLAMPED_KEY) return false;
|
|
7376
|
+
return !LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS.some((pattern) => pattern.test(key));
|
|
7377
|
+
}
|
|
7378
|
+
__name(isPlainFieldKey, "isPlainFieldKey");
|
|
7379
|
+
__name4(isPlainFieldKey, "isPlainFieldKey");
|
|
7380
|
+
function describeAgentLogFieldsViolation(value3) {
|
|
7381
|
+
if (typeof value3 !== "object" || value3 === null || Array.isArray(value3)) {
|
|
7382
|
+
return "fields must be an object";
|
|
7383
|
+
}
|
|
7384
|
+
const entries = Object.entries(value3);
|
|
7385
|
+
let userKeys = 0;
|
|
7386
|
+
for (const [key, entry] of entries) {
|
|
7387
|
+
if (key === LOG_FIELDS_CLAMPED_KEY) {
|
|
7388
|
+
if (entry !== true) return `fields.${key} must be true`;
|
|
7389
|
+
continue;
|
|
7390
|
+
}
|
|
7391
|
+
userKeys += 1;
|
|
7392
|
+
if (key.endsWith(LOG_FIELD_ARRAY_COUNT_SUFFIX)) {
|
|
7393
|
+
const base = key.slice(0, -LOG_FIELD_ARRAY_COUNT_SUFFIX.length);
|
|
7394
|
+
if (!isPlainFieldKey(base)) return `fields key \`${key}\` is not a legal field key`;
|
|
7395
|
+
if (typeof entry !== "number" || !Number.isFinite(entry)) {
|
|
7396
|
+
return `fields.${key} must be a finite number`;
|
|
7397
|
+
}
|
|
7398
|
+
continue;
|
|
7399
|
+
}
|
|
7400
|
+
if (!isPlainFieldKey(key)) return `fields key \`${key}\` is not a legal field key`;
|
|
7401
|
+
if (typeof entry === "string") {
|
|
7402
|
+
if (utf8Bytes(entry) > LOG_FIELD_MAX_VALUE_BYTES) {
|
|
7403
|
+
return `fields.${key} exceeds ${LOG_FIELD_MAX_VALUE_BYTES} bytes`;
|
|
7404
|
+
}
|
|
7405
|
+
continue;
|
|
7406
|
+
}
|
|
7407
|
+
if (typeof entry === "boolean") continue;
|
|
7408
|
+
if (typeof entry === "number") {
|
|
7409
|
+
if (!Number.isFinite(entry)) return `fields.${key} must be a finite number`;
|
|
7410
|
+
continue;
|
|
7411
|
+
}
|
|
7412
|
+
return `fields.${key} must be a string, number or boolean`;
|
|
7413
|
+
}
|
|
7414
|
+
if (userKeys > LOG_FIELDS_MAX_KEYS) {
|
|
7415
|
+
return `fields has ${userKeys} keys, over the cap of ${LOG_FIELDS_MAX_KEYS}`;
|
|
7416
|
+
}
|
|
7417
|
+
if (utf8Bytes(JSON.stringify(value3)) > LOG_FIELDS_MAX_BYTES) {
|
|
7418
|
+
return `fields exceeds ${LOG_FIELDS_MAX_BYTES} bytes`;
|
|
7419
|
+
}
|
|
7420
|
+
return void 0;
|
|
7421
|
+
}
|
|
7422
|
+
__name(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
|
|
7423
|
+
__name4(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
|
|
7424
|
+
function isAgentLogFields(value3) {
|
|
7425
|
+
return describeAgentLogFieldsViolation(value3) === void 0;
|
|
7426
|
+
}
|
|
7427
|
+
__name(isAgentLogFields, "isAgentLogFields");
|
|
7428
|
+
__name4(isAgentLogFields, "isAgentLogFields");
|
|
7429
|
+
var BROWSER_LOG_EVENT_KINDS = [
|
|
7430
|
+
"session.opened",
|
|
7431
|
+
"command",
|
|
7432
|
+
"navigation",
|
|
7433
|
+
"blocked",
|
|
7434
|
+
"wall",
|
|
7435
|
+
"fallback",
|
|
7436
|
+
"confirm",
|
|
7437
|
+
"agent.step",
|
|
7438
|
+
"session.closed"
|
|
7439
|
+
];
|
|
7440
|
+
var BROWSER_LOG_ENGINES = [
|
|
7441
|
+
"desktop",
|
|
7442
|
+
"agent-browser",
|
|
7443
|
+
"browser-use",
|
|
7444
|
+
"none"
|
|
7445
|
+
];
|
|
7446
|
+
var BROWSER_SESSION_OPEN_REASONS = [
|
|
7447
|
+
"desktop-online",
|
|
7448
|
+
"cloud-fallback",
|
|
7449
|
+
"stepwise-cloud",
|
|
7450
|
+
"pinned",
|
|
7451
|
+
"none"
|
|
7452
|
+
];
|
|
7453
|
+
var BROWSER_BLOCK_KINDS = [
|
|
7454
|
+
"domain",
|
|
7455
|
+
"private-network",
|
|
7456
|
+
"policy",
|
|
7457
|
+
"concurrency",
|
|
7458
|
+
"bot-block"
|
|
7459
|
+
];
|
|
7460
|
+
var BROWSER_WALL_KINDS = [
|
|
7461
|
+
"captcha",
|
|
7462
|
+
"bot-block",
|
|
7463
|
+
"consent",
|
|
7464
|
+
"login",
|
|
7465
|
+
"empty-content"
|
|
7466
|
+
];
|
|
7467
|
+
var BROWSER_WALL_NEXT_ACTIONS = [
|
|
7468
|
+
"fallback",
|
|
7469
|
+
"retry",
|
|
7470
|
+
"ask-user",
|
|
7471
|
+
"gave-up"
|
|
7472
|
+
];
|
|
7473
|
+
var BROWSER_CONFIRM_DECISIONS = [
|
|
7474
|
+
"pending",
|
|
7475
|
+
"approved",
|
|
7476
|
+
"denied",
|
|
7477
|
+
"expired"
|
|
7478
|
+
];
|
|
7479
|
+
var BROWSER_SESSION_CLOSE_REASONS = [
|
|
7480
|
+
"done",
|
|
7481
|
+
"idle",
|
|
7482
|
+
"max-minutes",
|
|
7483
|
+
"max-steps",
|
|
7484
|
+
"cost-cap",
|
|
7485
|
+
"error",
|
|
7486
|
+
"reaped"
|
|
7487
|
+
];
|
|
7488
|
+
var BROWSER_LOG_CONTEXT_KEYS = [
|
|
7489
|
+
"runId",
|
|
7490
|
+
"executionId",
|
|
7491
|
+
"primitiveId",
|
|
7492
|
+
"primitiveName",
|
|
7493
|
+
"channel",
|
|
7494
|
+
"orgId",
|
|
7495
|
+
"environment",
|
|
7496
|
+
"agentVersion"
|
|
7497
|
+
];
|
|
7498
|
+
var BROWSER_LOG_ID_MAX_CHARS = 256;
|
|
7499
|
+
var BROWSER_LOG_TEXT_MAX_CHARS = 64 * 1024;
|
|
7500
|
+
var isString = /* @__PURE__ */ __name4((value3) => typeof value3 === "string", "isString");
|
|
7501
|
+
var isBoolean = /* @__PURE__ */ __name4((value3) => typeof value3 === "boolean", "isBoolean");
|
|
7502
|
+
var isCount = /* @__PURE__ */ __name4((value3) => typeof value3 === "number" && Number.isFinite(value3) && value3 >= 0, "isCount");
|
|
7503
|
+
var isPlainObject2 = /* @__PURE__ */ __name4((value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3), "isPlainObject");
|
|
7504
|
+
var oneOf = /* @__PURE__ */ __name4((values) => (value3) => typeof value3 === "string" && values.includes(value3), "oneOf");
|
|
7505
|
+
var isLimits = /* @__PURE__ */ __name4((value3) => isPlainObject2(value3) && Object.values(value3).every((entry) => isCount(entry)), "isLimits");
|
|
7506
|
+
var EVENT_SHAPES = {
|
|
7507
|
+
"session.opened": {
|
|
7508
|
+
required: {
|
|
7509
|
+
reason: oneOf(BROWSER_SESSION_OPEN_REASONS)
|
|
7510
|
+
},
|
|
7511
|
+
optional: {
|
|
7512
|
+
limits: isLimits,
|
|
7513
|
+
region: isString,
|
|
7514
|
+
liveUrl: isString
|
|
7515
|
+
}
|
|
7516
|
+
},
|
|
7517
|
+
command: {
|
|
7518
|
+
required: {
|
|
7519
|
+
name: oneOf(BROWSER_COMMAND_NAMES),
|
|
7520
|
+
durationMs: isCount,
|
|
7521
|
+
ok: isBoolean
|
|
7522
|
+
},
|
|
7523
|
+
optional: {
|
|
7524
|
+
args: isPlainObject2,
|
|
7525
|
+
urlBefore: isString,
|
|
7526
|
+
urlAfter: isString,
|
|
7527
|
+
resultBytes: isCount,
|
|
7528
|
+
errorCode: isString,
|
|
7529
|
+
errorMessage: isString,
|
|
7530
|
+
title: isString,
|
|
7531
|
+
pageText: isString,
|
|
7532
|
+
screenshotRef: isString
|
|
7533
|
+
}
|
|
7534
|
+
},
|
|
7535
|
+
navigation: {
|
|
7536
|
+
required: {
|
|
7537
|
+
url: isString
|
|
7538
|
+
},
|
|
7539
|
+
optional: {
|
|
7540
|
+
finalUrl: isString,
|
|
7541
|
+
status: isCount,
|
|
7542
|
+
redirects: isCount
|
|
7543
|
+
}
|
|
7544
|
+
},
|
|
7545
|
+
blocked: {
|
|
7546
|
+
required: {
|
|
7547
|
+
kind: oneOf(BROWSER_BLOCK_KINDS)
|
|
7548
|
+
},
|
|
7549
|
+
optional: {
|
|
7550
|
+
rule: isString,
|
|
7551
|
+
target: isString,
|
|
7552
|
+
command: oneOf(BROWSER_COMMAND_NAMES),
|
|
7553
|
+
reason: isString
|
|
7554
|
+
}
|
|
7555
|
+
},
|
|
7556
|
+
wall: {
|
|
7557
|
+
required: {
|
|
7558
|
+
kind: oneOf(BROWSER_WALL_KINDS),
|
|
7559
|
+
url: isString,
|
|
7560
|
+
nextAction: oneOf(BROWSER_WALL_NEXT_ACTIONS)
|
|
7561
|
+
},
|
|
7562
|
+
optional: {}
|
|
7563
|
+
},
|
|
7564
|
+
fallback: {
|
|
7565
|
+
required: {
|
|
7566
|
+
from: oneOf(BROWSER_LOG_ENGINES),
|
|
7567
|
+
to: oneOf(BROWSER_LOG_ENGINES),
|
|
7568
|
+
reason: isString,
|
|
7569
|
+
provider: isString
|
|
7570
|
+
},
|
|
7571
|
+
optional: {}
|
|
7572
|
+
},
|
|
7573
|
+
confirm: {
|
|
7574
|
+
required: {
|
|
7575
|
+
action: isString,
|
|
7576
|
+
decision: oneOf(BROWSER_CONFIRM_DECISIONS)
|
|
7577
|
+
},
|
|
7578
|
+
optional: {
|
|
7579
|
+
decidedBy: isString
|
|
7580
|
+
}
|
|
7581
|
+
},
|
|
7582
|
+
"agent.step": {
|
|
7583
|
+
required: {
|
|
7584
|
+
step: isCount,
|
|
7585
|
+
action: isString
|
|
7586
|
+
},
|
|
7587
|
+
optional: {
|
|
7588
|
+
intent: isString,
|
|
7589
|
+
url: isString
|
|
7590
|
+
}
|
|
7591
|
+
},
|
|
7592
|
+
"session.closed": {
|
|
7593
|
+
required: {
|
|
7594
|
+
reason: oneOf(BROWSER_SESSION_CLOSE_REASONS),
|
|
7595
|
+
durationMs: isCount,
|
|
7596
|
+
pagesVisited: isCount,
|
|
7597
|
+
bytes: isCount
|
|
7598
|
+
},
|
|
7599
|
+
optional: {
|
|
7600
|
+
costUsd: isCount
|
|
7601
|
+
}
|
|
7602
|
+
}
|
|
7603
|
+
};
|
|
7604
|
+
var BASE_KEYS = /* @__PURE__ */ new Set([
|
|
7605
|
+
"event",
|
|
7606
|
+
"sessionId",
|
|
7607
|
+
"engine",
|
|
7608
|
+
"at"
|
|
7609
|
+
]);
|
|
7610
|
+
function describeBaseViolation(event) {
|
|
7611
|
+
if (!BROWSER_LOG_EVENT_KINDS.includes(event.event)) return "event is not a known kind";
|
|
7612
|
+
if (typeof event.sessionId !== "string" || event.sessionId.length === 0) return "sessionId must be a string";
|
|
7613
|
+
if (event.sessionId.length > BROWSER_LOG_ID_MAX_CHARS) return "sessionId is too long";
|
|
7614
|
+
if (!BROWSER_LOG_ENGINES.includes(event.engine)) return "engine is not a known engine";
|
|
7615
|
+
if (typeof event.at !== "string" || Number.isNaN(Date.parse(event.at))) return "at must be an ISO timestamp";
|
|
7616
|
+
return void 0;
|
|
7617
|
+
}
|
|
7618
|
+
__name(describeBaseViolation, "describeBaseViolation");
|
|
7619
|
+
__name4(describeBaseViolation, "describeBaseViolation");
|
|
7620
|
+
function describeFieldViolation(key, value3, check) {
|
|
7621
|
+
if (!check) return `${key} is not a field of this event`;
|
|
7622
|
+
if (!check(value3)) return `${key} has the wrong type`;
|
|
7623
|
+
if (typeof value3 === "string" && value3.length > BROWSER_LOG_TEXT_MAX_CHARS) return `${key} is too long`;
|
|
7624
|
+
return void 0;
|
|
7625
|
+
}
|
|
7626
|
+
__name(describeFieldViolation, "describeFieldViolation");
|
|
7627
|
+
__name4(describeFieldViolation, "describeFieldViolation");
|
|
7628
|
+
function describeBrowserLogEventViolation(value3) {
|
|
7629
|
+
if (!isPlainObject2(value3)) return "event must be an object";
|
|
7630
|
+
const event = value3;
|
|
7631
|
+
const base = describeBaseViolation(event);
|
|
7632
|
+
if (base) return base;
|
|
7633
|
+
const shape = EVENT_SHAPES[event.event];
|
|
7634
|
+
for (const key of Object.keys(shape.required)) {
|
|
7635
|
+
if (event[key] === void 0) return `${key} is required`;
|
|
7636
|
+
}
|
|
7637
|
+
for (const [key, entry] of Object.entries(event)) {
|
|
7638
|
+
if (BASE_KEYS.has(key) || entry === void 0) continue;
|
|
7639
|
+
const violation = describeFieldViolation(key, entry, shape.required[key] ?? shape.optional[key]);
|
|
7640
|
+
if (violation) return violation;
|
|
7641
|
+
}
|
|
7642
|
+
return void 0;
|
|
7643
|
+
}
|
|
7644
|
+
__name(describeBrowserLogEventViolation, "describeBrowserLogEventViolation");
|
|
7645
|
+
__name4(describeBrowserLogEventViolation, "describeBrowserLogEventViolation");
|
|
7646
|
+
function isBrowserLogEvent(value3) {
|
|
7647
|
+
return describeBrowserLogEventViolation(value3) === void 0;
|
|
7648
|
+
}
|
|
7649
|
+
__name(isBrowserLogEvent, "isBrowserLogEvent");
|
|
7650
|
+
__name4(isBrowserLogEvent, "isBrowserLogEvent");
|
|
7651
|
+
function describeBrowserLogContextViolation(value3) {
|
|
7652
|
+
if (value3 === void 0) return void 0;
|
|
7653
|
+
if (!isPlainObject2(value3)) return "logContext must be an object";
|
|
7654
|
+
for (const [key, entry] of Object.entries(value3)) {
|
|
7655
|
+
if (!BROWSER_LOG_CONTEXT_KEYS.includes(key)) return `logContext.${key} is not allowed`;
|
|
7656
|
+
if (entry === void 0) continue;
|
|
7657
|
+
if (typeof entry !== "string") return `logContext.${key} must be a string`;
|
|
7658
|
+
if (entry.length > BROWSER_LOG_ID_MAX_CHARS) return `logContext.${key} is too long`;
|
|
7659
|
+
if (key === "environment" && !AGENT_LOG_ENVIRONMENTS.includes(entry)) {
|
|
7660
|
+
return "logContext.environment is not a known environment";
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
return void 0;
|
|
7664
|
+
}
|
|
7665
|
+
__name(describeBrowserLogContextViolation, "describeBrowserLogContextViolation");
|
|
7666
|
+
__name4(describeBrowserLogContextViolation, "describeBrowserLogContextViolation");
|
|
7667
|
+
var BROWSER_WORKER_SESSION_ID_SEPARATOR = ":";
|
|
7668
|
+
function browserWorkerSessionId(ref) {
|
|
7669
|
+
return [
|
|
7670
|
+
ref.agentId,
|
|
7671
|
+
ref.userId,
|
|
7672
|
+
ref.sessionKey
|
|
7673
|
+
].join(BROWSER_WORKER_SESSION_ID_SEPARATOR);
|
|
7674
|
+
}
|
|
7675
|
+
__name(browserWorkerSessionId, "browserWorkerSessionId");
|
|
7676
|
+
__name4(browserWorkerSessionId, "browserWorkerSessionId");
|
|
7677
|
+
var BROWSER_WORKER_BLOCK_REASON_MAX_CHARS = 1024;
|
|
7678
|
+
function browserLogContextOfWorkerContext(context) {
|
|
7679
|
+
const out = {};
|
|
7680
|
+
if (context?.runId) out.runId = context.runId;
|
|
7681
|
+
if (context?.primitiveId) out.primitiveId = context.primitiveId;
|
|
7682
|
+
if (context?.primitiveName) out.primitiveName = context.primitiveName;
|
|
7683
|
+
if (context?.channel) out.channel = context.channel;
|
|
7684
|
+
return out;
|
|
7685
|
+
}
|
|
7686
|
+
__name(browserLogContextOfWorkerContext, "browserLogContextOfWorkerContext");
|
|
7687
|
+
__name4(browserLogContextOfWorkerContext, "browserLogContextOfWorkerContext");
|
|
7688
|
+
function browserLogEventOfWorkerEvent(event, mapping = {}) {
|
|
7689
|
+
const base = {
|
|
7690
|
+
sessionId: mapping.sessionId ?? event.sessionId,
|
|
7691
|
+
engine: "agent-browser",
|
|
7692
|
+
at: event.at
|
|
7693
|
+
};
|
|
7694
|
+
switch (event.event) {
|
|
7695
|
+
case "session.opened":
|
|
7696
|
+
return {
|
|
7697
|
+
...base,
|
|
7698
|
+
event: "session.opened",
|
|
7699
|
+
reason: mapping.reason ?? "stepwise-cloud",
|
|
7700
|
+
limits: {
|
|
7701
|
+
...event.limits
|
|
7702
|
+
}
|
|
7703
|
+
};
|
|
7704
|
+
case "session.closed":
|
|
7705
|
+
return {
|
|
7706
|
+
...base,
|
|
7707
|
+
event: "session.closed",
|
|
7708
|
+
reason: event.reason,
|
|
7709
|
+
durationMs: event.durationMs,
|
|
7710
|
+
pagesVisited: event.pagesVisited,
|
|
7711
|
+
bytes: event.bytes
|
|
7712
|
+
};
|
|
7713
|
+
case "command":
|
|
7714
|
+
return {
|
|
7715
|
+
...base,
|
|
7716
|
+
event: "command",
|
|
7717
|
+
name: event.name,
|
|
7718
|
+
ok: event.ok,
|
|
7719
|
+
durationMs: event.durationMs,
|
|
7720
|
+
resultBytes: event.resultBytes,
|
|
7721
|
+
urlAfter: event.urlAfter,
|
|
7722
|
+
title: event.title,
|
|
7723
|
+
errorCode: event.errorCode,
|
|
7724
|
+
errorMessage: event.errorMessage
|
|
7725
|
+
};
|
|
7726
|
+
case "navigation":
|
|
7727
|
+
if (!event.ok) return void 0;
|
|
7728
|
+
return {
|
|
7729
|
+
...base,
|
|
7730
|
+
event: "navigation",
|
|
7731
|
+
url: event.url,
|
|
7732
|
+
finalUrl: event.finalUrl
|
|
7733
|
+
};
|
|
7734
|
+
case "blocked":
|
|
7735
|
+
return {
|
|
7736
|
+
...base,
|
|
7737
|
+
event: "blocked",
|
|
7738
|
+
kind: event.kind,
|
|
7739
|
+
rule: event.rule,
|
|
7740
|
+
target: event.target,
|
|
7741
|
+
command: event.command,
|
|
7742
|
+
reason: event.detail ? event.detail.slice(0, BROWSER_WORKER_BLOCK_REASON_MAX_CHARS) : void 0
|
|
7743
|
+
};
|
|
7744
|
+
case "wall":
|
|
7745
|
+
return {
|
|
7746
|
+
...base,
|
|
7747
|
+
event: "wall",
|
|
7748
|
+
kind: event.kind,
|
|
7749
|
+
url: event.url,
|
|
7750
|
+
nextAction: event.nextAction
|
|
7751
|
+
};
|
|
7752
|
+
}
|
|
7753
|
+
}
|
|
7754
|
+
__name(browserLogEventOfWorkerEvent, "browserLogEventOfWorkerEvent");
|
|
7755
|
+
__name4(browserLogEventOfWorkerEvent, "browserLogEventOfWorkerEvent");
|
|
6873
7756
|
var WORKFLOW_RETRY_BACKOFFS = [
|
|
6874
7757
|
"fixed",
|
|
6875
7758
|
"exponential"
|
|
@@ -7376,114 +8259,6 @@ function buildPersonalSpaceStartingPersona(agentName) {
|
|
|
7376
8259
|
}
|
|
7377
8260
|
__name(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
|
|
7378
8261
|
__name4(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
|
|
7379
|
-
var AGENT_LOG_SOURCES = [
|
|
7380
|
-
"skill",
|
|
7381
|
-
"job",
|
|
7382
|
-
"webhook",
|
|
7383
|
-
"web-route",
|
|
7384
|
-
"trigger",
|
|
7385
|
-
"preprocessor",
|
|
7386
|
-
"postprocessor",
|
|
7387
|
-
"user_message",
|
|
7388
|
-
"agent_response",
|
|
7389
|
-
"agent_error",
|
|
7390
|
-
"runtime",
|
|
7391
|
-
"mcp",
|
|
7392
|
-
"rag",
|
|
7393
|
-
"device",
|
|
7394
|
-
"device-trigger",
|
|
7395
|
-
"model-resolver",
|
|
7396
|
-
"workflow-step",
|
|
7397
|
-
"workflow-script",
|
|
7398
|
-
"workflow",
|
|
7399
|
-
"supervision",
|
|
7400
|
-
"decisions"
|
|
7401
|
-
];
|
|
7402
|
-
var AGENT_LOG_FIELDS_MAX_WIRE_KEYS = LOG_FIELDS_MAX_KEYS + 1;
|
|
7403
|
-
function utf8Bytes(value3) {
|
|
7404
|
-
let bytes = 0;
|
|
7405
|
-
for (let i = 0; i < value3.length; ) {
|
|
7406
|
-
const code = value3.charCodeAt(i);
|
|
7407
|
-
if (code < 128) {
|
|
7408
|
-
bytes += 1;
|
|
7409
|
-
i += 1;
|
|
7410
|
-
} else if (code < 2048) {
|
|
7411
|
-
bytes += 2;
|
|
7412
|
-
i += 1;
|
|
7413
|
-
} else if (code >= 55296 && code <= 56319) {
|
|
7414
|
-
const next = value3.charCodeAt(i + 1);
|
|
7415
|
-
if (next >= 56320 && next <= 57343) {
|
|
7416
|
-
bytes += 4;
|
|
7417
|
-
i += 2;
|
|
7418
|
-
} else {
|
|
7419
|
-
bytes += 3;
|
|
7420
|
-
i += 1;
|
|
7421
|
-
}
|
|
7422
|
-
} else {
|
|
7423
|
-
bytes += 3;
|
|
7424
|
-
i += 1;
|
|
7425
|
-
}
|
|
7426
|
-
}
|
|
7427
|
-
return bytes;
|
|
7428
|
-
}
|
|
7429
|
-
__name(utf8Bytes, "utf8Bytes");
|
|
7430
|
-
__name4(utf8Bytes, "utf8Bytes");
|
|
7431
|
-
function isPlainFieldKey(key) {
|
|
7432
|
-
if (!LOG_FIELD_KEY_PATTERN.test(key)) return false;
|
|
7433
|
-
if (key === LOG_FIELDS_CLAMPED_KEY) return false;
|
|
7434
|
-
return !LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS.some((pattern) => pattern.test(key));
|
|
7435
|
-
}
|
|
7436
|
-
__name(isPlainFieldKey, "isPlainFieldKey");
|
|
7437
|
-
__name4(isPlainFieldKey, "isPlainFieldKey");
|
|
7438
|
-
function describeAgentLogFieldsViolation(value3) {
|
|
7439
|
-
if (typeof value3 !== "object" || value3 === null || Array.isArray(value3)) {
|
|
7440
|
-
return "fields must be an object";
|
|
7441
|
-
}
|
|
7442
|
-
const entries = Object.entries(value3);
|
|
7443
|
-
let userKeys = 0;
|
|
7444
|
-
for (const [key, entry] of entries) {
|
|
7445
|
-
if (key === LOG_FIELDS_CLAMPED_KEY) {
|
|
7446
|
-
if (entry !== true) return `fields.${key} must be true`;
|
|
7447
|
-
continue;
|
|
7448
|
-
}
|
|
7449
|
-
userKeys += 1;
|
|
7450
|
-
if (key.endsWith(LOG_FIELD_ARRAY_COUNT_SUFFIX)) {
|
|
7451
|
-
const base = key.slice(0, -LOG_FIELD_ARRAY_COUNT_SUFFIX.length);
|
|
7452
|
-
if (!isPlainFieldKey(base)) return `fields key \`${key}\` is not a legal field key`;
|
|
7453
|
-
if (typeof entry !== "number" || !Number.isFinite(entry)) {
|
|
7454
|
-
return `fields.${key} must be a finite number`;
|
|
7455
|
-
}
|
|
7456
|
-
continue;
|
|
7457
|
-
}
|
|
7458
|
-
if (!isPlainFieldKey(key)) return `fields key \`${key}\` is not a legal field key`;
|
|
7459
|
-
if (typeof entry === "string") {
|
|
7460
|
-
if (utf8Bytes(entry) > LOG_FIELD_MAX_VALUE_BYTES) {
|
|
7461
|
-
return `fields.${key} exceeds ${LOG_FIELD_MAX_VALUE_BYTES} bytes`;
|
|
7462
|
-
}
|
|
7463
|
-
continue;
|
|
7464
|
-
}
|
|
7465
|
-
if (typeof entry === "boolean") continue;
|
|
7466
|
-
if (typeof entry === "number") {
|
|
7467
|
-
if (!Number.isFinite(entry)) return `fields.${key} must be a finite number`;
|
|
7468
|
-
continue;
|
|
7469
|
-
}
|
|
7470
|
-
return `fields.${key} must be a string, number or boolean`;
|
|
7471
|
-
}
|
|
7472
|
-
if (userKeys > LOG_FIELDS_MAX_KEYS) {
|
|
7473
|
-
return `fields has ${userKeys} keys, over the cap of ${LOG_FIELDS_MAX_KEYS}`;
|
|
7474
|
-
}
|
|
7475
|
-
if (utf8Bytes(JSON.stringify(value3)) > LOG_FIELDS_MAX_BYTES) {
|
|
7476
|
-
return `fields exceeds ${LOG_FIELDS_MAX_BYTES} bytes`;
|
|
7477
|
-
}
|
|
7478
|
-
return void 0;
|
|
7479
|
-
}
|
|
7480
|
-
__name(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
|
|
7481
|
-
__name4(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
|
|
7482
|
-
function isAgentLogFields(value3) {
|
|
7483
|
-
return describeAgentLogFieldsViolation(value3) === void 0;
|
|
7484
|
-
}
|
|
7485
|
-
__name(isAgentLogFields, "isAgentLogFields");
|
|
7486
|
-
__name4(isAgentLogFields, "isAgentLogFields");
|
|
7487
8262
|
var LOG_DRAIN_TYPES_PHASE1 = [
|
|
7488
8263
|
"http",
|
|
7489
8264
|
"otlp",
|
|
@@ -8271,13 +9046,13 @@ __name4(parseLogTimeBound, "parseLogTimeBound");
|
|
|
8271
9046
|
var CORE_DRAINING_CODE = "CORE_DRAINING";
|
|
8272
9047
|
var CORE_DRAINING_DEFAULT_RETRY_MS = 1e3;
|
|
8273
9048
|
var CORE_DRAINING_MAX_RETRY_MS = 5e3;
|
|
8274
|
-
function
|
|
9049
|
+
function isRecord2(value3) {
|
|
8275
9050
|
return typeof value3 === "object" && value3 !== null;
|
|
8276
9051
|
}
|
|
8277
|
-
__name(
|
|
8278
|
-
__name4(
|
|
9052
|
+
__name(isRecord2, "isRecord2");
|
|
9053
|
+
__name4(isRecord2, "isRecord");
|
|
8279
9054
|
function isCoreDrainingErrorResponse(value3) {
|
|
8280
|
-
if (!
|
|
9055
|
+
if (!isRecord2(value3) || !isRecord2(value3.error)) return false;
|
|
8281
9056
|
return value3.error.code === CORE_DRAINING_CODE && typeof value3.error.message === "string" && value3.error.retryable === true;
|
|
8282
9057
|
}
|
|
8283
9058
|
__name(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
|
|
@@ -8360,7 +9135,7 @@ var PluginClassSchema = z2.enum([
|
|
|
8360
9135
|
var ModelDescriptorSchema = z2.string().min(1).max(200);
|
|
8361
9136
|
var InferenceModelSchema = z2.object({
|
|
8362
9137
|
kind: z2.literal("inference"),
|
|
8363
|
-
/** Provider-prefixed model id (e.g. `'openai/
|
|
9138
|
+
/** Provider-prefixed model id (e.g. `'openai/chat-latest'`). */
|
|
8364
9139
|
model: ModelDescriptorSchema,
|
|
8365
9140
|
/**
|
|
8366
9141
|
* TTS-only — provider voice id. Inference's TTS API takes voice
|
|
@@ -10960,11 +11735,11 @@ function confidenceOf(n2) {
|
|
|
10960
11735
|
}
|
|
10961
11736
|
__name(confidenceOf, "confidenceOf");
|
|
10962
11737
|
__name4(confidenceOf, "confidenceOf");
|
|
10963
|
-
function rateOf(
|
|
11738
|
+
function rateOf(count2, conversations) {
|
|
10964
11739
|
return {
|
|
10965
|
-
count,
|
|
10966
|
-
rate: conversations > 0 ?
|
|
10967
|
-
confidence: confidenceOf(
|
|
11740
|
+
count: count2,
|
|
11741
|
+
rate: conversations > 0 ? count2 / conversations : null,
|
|
11742
|
+
confidence: confidenceOf(count2)
|
|
10968
11743
|
};
|
|
10969
11744
|
}
|
|
10970
11745
|
__name(rateOf, "rateOf");
|
|
@@ -15148,11 +15923,11 @@ function isConditionalJoinId(stepId) {
|
|
|
15148
15923
|
}
|
|
15149
15924
|
__name(isConditionalJoinId, "isConditionalJoinId");
|
|
15150
15925
|
__name5(isConditionalJoinId, "isConditionalJoinId");
|
|
15151
|
-
function
|
|
15926
|
+
function isPlainObject3(v) {
|
|
15152
15927
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
15153
15928
|
}
|
|
15154
|
-
__name(
|
|
15155
|
-
__name5(
|
|
15929
|
+
__name(isPlainObject3, "isPlainObject");
|
|
15930
|
+
__name5(isPlainObject3, "isPlainObject");
|
|
15156
15931
|
function leafValue(row) {
|
|
15157
15932
|
if (row.status === "completed") return row.output === void 0 ? null : row.output;
|
|
15158
15933
|
return continuedFailureValue(row.error, row.killReason);
|
|
@@ -15175,7 +15950,7 @@ function deriveRunOutput(steps) {
|
|
|
15175
15950
|
if (leaves.length === 1) {
|
|
15176
15951
|
const leaf = leaves[0];
|
|
15177
15952
|
const value22 = leafValue(leaf);
|
|
15178
|
-
if (isConditionalJoinId(leaf.stepId) &&
|
|
15953
|
+
if (isConditionalJoinId(leaf.stepId) && isPlainObject3(value22)) {
|
|
15179
15954
|
const keys = Object.keys(value22);
|
|
15180
15955
|
if (keys.length === 1) return {
|
|
15181
15956
|
output: value22[keys[0]],
|
|
@@ -16802,9 +17577,9 @@ function estimateGraph(envelopeOrGraph) {
|
|
|
16802
17577
|
}
|
|
16803
17578
|
__name(estimateGraph, "estimateGraph");
|
|
16804
17579
|
__name5(estimateGraph, "estimateGraph");
|
|
16805
|
-
var
|
|
17580
|
+
var isRecord3 = /* @__PURE__ */ __name5((v) => !!v && typeof v === "object" && !Array.isArray(v), "isRecord");
|
|
16806
17581
|
function* singleStepsOf(entry) {
|
|
16807
|
-
if (!
|
|
17582
|
+
if (!isRecord3(entry)) return;
|
|
16808
17583
|
switch (entry.type) {
|
|
16809
17584
|
case "step":
|
|
16810
17585
|
case "agent":
|
|
@@ -16830,8 +17605,8 @@ function* singleStepsOf(entry) {
|
|
|
16830
17605
|
__name(singleStepsOf, "singleStepsOf");
|
|
16831
17606
|
__name5(singleStepsOf, "singleStepsOf");
|
|
16832
17607
|
function entriesOf(graph) {
|
|
16833
|
-
const definition =
|
|
16834
|
-
const entries =
|
|
17608
|
+
const definition = isRecord3(graph) ? graph.definition : void 0;
|
|
17609
|
+
const entries = isRecord3(definition) ? definition.graph : void 0;
|
|
16835
17610
|
return Array.isArray(entries) ? entries : [];
|
|
16836
17611
|
}
|
|
16837
17612
|
__name(entriesOf, "entriesOf");
|
|
@@ -16852,7 +17627,7 @@ function inheritTargets(graphs) {
|
|
|
16852
17627
|
__name(inheritTargets, "inheritTargets");
|
|
16853
17628
|
__name5(inheritTargets, "inheritTargets");
|
|
16854
17629
|
function needsInheritedWorkspace(graph) {
|
|
16855
|
-
if (!
|
|
17630
|
+
if (!isRecord3(graph) || graph.workspace !== void 0) return false;
|
|
16856
17631
|
for (const entry of entriesOf(graph)) {
|
|
16857
17632
|
for (const node of singleStepsOf(entry)) {
|
|
16858
17633
|
if (node.workspace !== void 0 && node.workspace !== "inherit") return true;
|
|
@@ -17876,6 +18651,10 @@ function createWorkflow(cfg) {
|
|
|
17876
18651
|
const n2 = cfg.backfillOnEnable.maxOccurrences;
|
|
17877
18652
|
if (!Number.isInteger(n2) || n2 < 1 || n2 > 200) throw new LuaWorkflowBuildError("invalid-envelope", "backfillOnEnable.maxOccurrences must be an integer in 1..200 (backfill-max-occurrences-out-of-range; the org maxBatchItems twin is checked at publish/R56)");
|
|
17878
18653
|
}
|
|
18654
|
+
if (cfg.concurrencyKey !== void 0) {
|
|
18655
|
+
if (cfg.concurrencyKey !== "correlationKey") throw new LuaWorkflowBuildError("invalid-envelope", "concurrencyKey must be 'correlationKey'");
|
|
18656
|
+
if (cfg.concurrencyPolicy !== "forbid") throw new LuaWorkflowBuildError("concurrency-key-requires-forbid", `workflow "${cfg.name}": concurrencyKey requires concurrencyPolicy:'forbid'`, "set concurrencyPolicy:'forbid' or remove concurrencyKey");
|
|
18657
|
+
}
|
|
17879
18658
|
if (cfg.health !== void 0) {
|
|
17880
18659
|
const issues = validateScheduleHealth(cfg.health, {
|
|
17881
18660
|
target: "workflow",
|