lua-cli 3.39.3 → 3.40.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 +434 -23
- package/dist/api-exports.js +1727 -525
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +1538 -158
- package/dist/index.js.map +1 -1
- package/dist/voice/test/index.d.ts +16 -5
- package/dist/workflow-builder.d.ts +52 -1
- package/dist/workflow-builder.js +1069 -259
- package/dist/workflow-builder.js.map +1 -1
- package/docs/API_REFERENCE.md +115 -45
- package/docs/api/Agents.md +111 -0
- package/docs/workflows/schedule-health.md +77 -0
- package/docs/workflows/schedules.md +6 -2
- package/package.json +6 -4
- package/template/package.json +1 -1
package/dist/workflow-builder.js
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value3) => __defProp(target, "name", { value: value3, configurable: true });
|
|
3
3
|
|
|
4
|
+
// ../shared-types/dist/workflow-job-tools.mjs
|
|
5
|
+
var __defProp2 = Object.defineProperty;
|
|
6
|
+
var __name2 = /* @__PURE__ */ __name((target, value3) => __defProp2(target, "name", { value: value3, configurable: true }), "__name");
|
|
7
|
+
var WORKFLOW_JOB_TOOLS = [
|
|
8
|
+
"shell",
|
|
9
|
+
"read",
|
|
10
|
+
"write",
|
|
11
|
+
"edit",
|
|
12
|
+
"glob",
|
|
13
|
+
"grep",
|
|
14
|
+
"git",
|
|
15
|
+
"gh",
|
|
16
|
+
"fetch",
|
|
17
|
+
"ripwire"
|
|
18
|
+
];
|
|
19
|
+
var WORKFLOW_JOB_READ_ONLY_DROPPED = [
|
|
20
|
+
"write",
|
|
21
|
+
"edit",
|
|
22
|
+
"git",
|
|
23
|
+
"shell"
|
|
24
|
+
];
|
|
25
|
+
var WORKFLOW_JOB_DEFAULT_TOOLS = [
|
|
26
|
+
"shell",
|
|
27
|
+
"read",
|
|
28
|
+
"write",
|
|
29
|
+
"edit",
|
|
30
|
+
"glob",
|
|
31
|
+
"grep",
|
|
32
|
+
"git"
|
|
33
|
+
];
|
|
34
|
+
function effectiveJobTools(jobTools, readOnly) {
|
|
35
|
+
const base = jobTools?.length ? jobTools : WORKFLOW_JOB_DEFAULT_TOOLS;
|
|
36
|
+
const out = [];
|
|
37
|
+
for (const id2 of base) {
|
|
38
|
+
if (readOnly && WORKFLOW_JOB_READ_ONLY_DROPPED.includes(id2)) continue;
|
|
39
|
+
if (!out.includes(id2)) out.push(id2);
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
__name(effectiveJobTools, "effectiveJobTools");
|
|
44
|
+
__name2(effectiveJobTools, "effectiveJobTools");
|
|
45
|
+
var WORKFLOW_JOB_PLUGINS = [
|
|
46
|
+
"lua-agent-builder"
|
|
47
|
+
];
|
|
48
|
+
var WORKFLOW_JOB_PLUGIN_ROOT = "/opt/lua/plugins";
|
|
49
|
+
var WORKFLOW_JOB_PLUGINS_MAX = 4;
|
|
50
|
+
function isWorkflowJobPluginId(id2) {
|
|
51
|
+
return typeof id2 === "string" && WORKFLOW_JOB_PLUGINS.includes(id2);
|
|
52
|
+
}
|
|
53
|
+
__name(isWorkflowJobPluginId, "isWorkflowJobPluginId");
|
|
54
|
+
__name2(isWorkflowJobPluginId, "isWorkflowJobPluginId");
|
|
55
|
+
function workflowJobPluginDir(id2) {
|
|
56
|
+
return `${WORKFLOW_JOB_PLUGIN_ROOT}/${id2}`;
|
|
57
|
+
}
|
|
58
|
+
__name(workflowJobPluginDir, "workflowJobPluginDir");
|
|
59
|
+
__name2(workflowJobPluginDir, "workflowJobPluginDir");
|
|
60
|
+
function workflowJobPluginsProblem(plugins) {
|
|
61
|
+
if (plugins === void 0) return null;
|
|
62
|
+
if (!Array.isArray(plugins)) return "plugins must be an array of plugin ids";
|
|
63
|
+
if (plugins.length > WORKFLOW_JOB_PLUGINS_MAX) return `at most ${WORKFLOW_JOB_PLUGINS_MAX} plugins per step`;
|
|
64
|
+
const unknown = plugins.filter((p) => !isWorkflowJobPluginId(p));
|
|
65
|
+
if (unknown.length) return `unknown plugin ${unknown.map((u) => JSON.stringify(u)).join(", ")} (allowed: ${WORKFLOW_JOB_PLUGINS.join(", ")})`;
|
|
66
|
+
if (new Set(plugins).size !== plugins.length) return "plugins must not repeat";
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
__name(workflowJobPluginsProblem, "workflowJobPluginsProblem");
|
|
70
|
+
__name2(workflowJobPluginsProblem, "workflowJobPluginsProblem");
|
|
71
|
+
function workflowJobTargetProblem(target, plugins) {
|
|
72
|
+
if (target === void 0) return null;
|
|
73
|
+
if (!target || typeof target !== "object" || Array.isArray(target)) return "target must be { agentId }";
|
|
74
|
+
const keys = Object.keys(target);
|
|
75
|
+
const agentId = target.agentId;
|
|
76
|
+
if (keys.length !== 1 || typeof agentId !== "string" || !agentId.trim() || agentId.length > 256) return "target must be exactly { agentId: <non-empty string> }";
|
|
77
|
+
if (!Array.isArray(plugins) || plugins.length === 0) return "`target` is legal only beside `plugins`";
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
__name(workflowJobTargetProblem, "workflowJobTargetProblem");
|
|
81
|
+
__name2(workflowJobTargetProblem, "workflowJobTargetProblem");
|
|
82
|
+
|
|
4
83
|
// src/types/workflow.ts
|
|
5
84
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
6
85
|
|
|
@@ -9,8 +88,8 @@ import { z } from "zod";
|
|
|
9
88
|
import { z as z2 } from "zod";
|
|
10
89
|
import { z as z3 } from "zod";
|
|
11
90
|
import { z as z4 } from "zod";
|
|
12
|
-
var
|
|
13
|
-
var
|
|
91
|
+
var __defProp3 = Object.defineProperty;
|
|
92
|
+
var __name3 = /* @__PURE__ */ __name((target, value3) => __defProp3(target, "name", { value: value3, configurable: true }), "__name");
|
|
14
93
|
var PLUMBING_THREAD_CHANNELS = [
|
|
15
94
|
"trigger",
|
|
16
95
|
"template-install",
|
|
@@ -38,12 +117,12 @@ function isChannelConversationChannel(channel) {
|
|
|
38
117
|
return !!channel && CHANNEL_CONVERSATION_CHANNELS.includes(channel);
|
|
39
118
|
}
|
|
40
119
|
__name(isChannelConversationChannel, "isChannelConversationChannel");
|
|
41
|
-
|
|
120
|
+
__name3(isChannelConversationChannel, "isChannelConversationChannel");
|
|
42
121
|
function isChannelConversationThread(threadId, channel) {
|
|
43
122
|
return !!threadId && isChannelConversationChannel(channel);
|
|
44
123
|
}
|
|
45
124
|
__name(isChannelConversationThread, "isChannelConversationThread");
|
|
46
|
-
|
|
125
|
+
__name3(isChannelConversationThread, "isChannelConversationThread");
|
|
47
126
|
function isPersonaTextObject(value3) {
|
|
48
127
|
if (value3 === null || typeof value3 !== "object" || Array.isArray(value3)) return false;
|
|
49
128
|
const obj = value3;
|
|
@@ -54,7 +133,7 @@ function isPersonaTextObject(value3) {
|
|
|
54
133
|
return true;
|
|
55
134
|
}
|
|
56
135
|
__name(isPersonaTextObject, "isPersonaTextObject");
|
|
57
|
-
|
|
136
|
+
__name3(isPersonaTextObject, "isPersonaTextObject");
|
|
58
137
|
function flattenPersonaText(input, isVoice = false) {
|
|
59
138
|
if (input == null) return "";
|
|
60
139
|
if (typeof input === "string") return input;
|
|
@@ -65,7 +144,7 @@ function flattenPersonaText(input, isVoice = false) {
|
|
|
65
144
|
return parts.join("\n\n");
|
|
66
145
|
}
|
|
67
146
|
__name(flattenPersonaText, "flattenPersonaText");
|
|
68
|
-
|
|
147
|
+
__name3(flattenPersonaText, "flattenPersonaText");
|
|
69
148
|
function flattenPersonaTextAll(input) {
|
|
70
149
|
if (input == null) return "";
|
|
71
150
|
if (typeof input === "string") return input;
|
|
@@ -76,16 +155,16 @@ function flattenPersonaTextAll(input) {
|
|
|
76
155
|
return parts.join("\n\n");
|
|
77
156
|
}
|
|
78
157
|
__name(flattenPersonaTextAll, "flattenPersonaTextAll");
|
|
79
|
-
|
|
158
|
+
__name3(flattenPersonaTextAll, "flattenPersonaTextAll");
|
|
80
159
|
function hasPersonaTextContent(input) {
|
|
81
160
|
if (input == null) return false;
|
|
82
161
|
if (typeof input === "string") return input.trim().length > 0;
|
|
83
162
|
return Boolean(input.base?.trim() || input.voice?.trim() || input.text?.trim());
|
|
84
163
|
}
|
|
85
164
|
__name(hasPersonaTextContent, "hasPersonaTextContent");
|
|
86
|
-
|
|
165
|
+
__name3(hasPersonaTextContent, "hasPersonaTextContent");
|
|
87
166
|
function personaToLiteral(persona) {
|
|
88
|
-
const formatValue = /* @__PURE__ */
|
|
167
|
+
const formatValue = /* @__PURE__ */ __name3((v) => {
|
|
89
168
|
if (v.includes("\n")) {
|
|
90
169
|
return "`" + v.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$") + "`";
|
|
91
170
|
}
|
|
@@ -99,7 +178,7 @@ function personaToLiteral(persona) {
|
|
|
99
178
|
return `{ ${parts.join(", ")} }`;
|
|
100
179
|
}
|
|
101
180
|
__name(personaToLiteral, "personaToLiteral");
|
|
102
|
-
|
|
181
|
+
__name3(personaToLiteral, "personaToLiteral");
|
|
103
182
|
function aiGenerateInputFromSimplified(prompt, content) {
|
|
104
183
|
if (content === void 0) {
|
|
105
184
|
return {
|
|
@@ -117,7 +196,45 @@ function aiGenerateInputFromSimplified(prompt, content) {
|
|
|
117
196
|
};
|
|
118
197
|
}
|
|
119
198
|
__name(aiGenerateInputFromSimplified, "aiGenerateInputFromSimplified");
|
|
120
|
-
|
|
199
|
+
__name3(aiGenerateInputFromSimplified, "aiGenerateInputFromSimplified");
|
|
200
|
+
var PLATFORM_INVOCATION_CALLERS = [
|
|
201
|
+
"workflow-step",
|
|
202
|
+
"supervision-preview"
|
|
203
|
+
];
|
|
204
|
+
function isPlatformInvocationCaller(v) {
|
|
205
|
+
return typeof v === "string" && PLATFORM_INVOCATION_CALLERS.includes(v);
|
|
206
|
+
}
|
|
207
|
+
__name(isPlatformInvocationCaller, "isPlatformInvocationCaller");
|
|
208
|
+
__name3(isPlatformInvocationCaller, "isPlatformInvocationCaller");
|
|
209
|
+
function supervisionSubjectId(agentId) {
|
|
210
|
+
return `agent:${agentId}`;
|
|
211
|
+
}
|
|
212
|
+
__name(supervisionSubjectId, "supervisionSubjectId");
|
|
213
|
+
__name3(supervisionSubjectId, "supervisionSubjectId");
|
|
214
|
+
var SUPERVISION_OPS = {
|
|
215
|
+
"agents.list": "discover",
|
|
216
|
+
"agents.get": "discover",
|
|
217
|
+
logs: "observe",
|
|
218
|
+
"runs.list": "observe",
|
|
219
|
+
"runs.get": "observe",
|
|
220
|
+
"data.get": "observe",
|
|
221
|
+
"data.query": "observe",
|
|
222
|
+
"versions.list": "observe",
|
|
223
|
+
"versions.get": "observe",
|
|
224
|
+
"versions.diff": "observe",
|
|
225
|
+
"versions.preview": "preview",
|
|
226
|
+
"versions.promote": "release",
|
|
227
|
+
"persona.versions": "observe",
|
|
228
|
+
"persona.activate": "release",
|
|
229
|
+
"source.list": "observe",
|
|
230
|
+
"source.get": "observe",
|
|
231
|
+
"env.keys": "observe"
|
|
232
|
+
};
|
|
233
|
+
function isSupervisionOp(op) {
|
|
234
|
+
return typeof op === "string" && Object.prototype.hasOwnProperty.call(SUPERVISION_OPS, op);
|
|
235
|
+
}
|
|
236
|
+
__name(isSupervisionOp, "isSupervisionOp");
|
|
237
|
+
__name3(isSupervisionOp, "isSupervisionOp");
|
|
121
238
|
var REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST = [
|
|
122
239
|
"sendChannelMessage",
|
|
123
240
|
"sendWhatsappTemplate",
|
|
@@ -133,7 +250,7 @@ function isAllowedReviewableExecuteTool(tool) {
|
|
|
133
250
|
return REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST.includes(tool);
|
|
134
251
|
}
|
|
135
252
|
__name(isAllowedReviewableExecuteTool, "isAllowedReviewableExecuteTool");
|
|
136
|
-
|
|
253
|
+
__name3(isAllowedReviewableExecuteTool, "isAllowedReviewableExecuteTool");
|
|
137
254
|
var REVIEWABLE_STANDING_START_TOOLS = [
|
|
138
255
|
"scheduleWorkflow"
|
|
139
256
|
];
|
|
@@ -141,19 +258,19 @@ function isReviewableStandingStartTool(tool) {
|
|
|
141
258
|
return REVIEWABLE_STANDING_START_TOOLS.includes(tool);
|
|
142
259
|
}
|
|
143
260
|
__name(isReviewableStandingStartTool, "isReviewableStandingStartTool");
|
|
144
|
-
|
|
261
|
+
__name3(isReviewableStandingStartTool, "isReviewableStandingStartTool");
|
|
145
262
|
var REVIEWABLE_MCP_SEND_TOOL_SUFFIX = "_create_messaging_message";
|
|
146
263
|
function isReviewableMcpSendTool(tool) {
|
|
147
264
|
return tool.length > REVIEWABLE_MCP_SEND_TOOL_SUFFIX.length && tool.endsWith(REVIEWABLE_MCP_SEND_TOOL_SUFFIX);
|
|
148
265
|
}
|
|
149
266
|
__name(isReviewableMcpSendTool, "isReviewableMcpSendTool");
|
|
150
|
-
|
|
267
|
+
__name3(isReviewableMcpSendTool, "isReviewableMcpSendTool");
|
|
151
268
|
var MCP_TOOL_READ_VERB_RE = /(?:^|_)(list|get|search|read|fetch|find|query|describe|count|retrieve|lookup|show|view)(_|[A-Z0-9]|$)/;
|
|
152
269
|
function mcpActionTokens(action) {
|
|
153
270
|
return action.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
154
271
|
}
|
|
155
272
|
__name(mcpActionTokens, "mcpActionTokens");
|
|
156
|
-
|
|
273
|
+
__name3(mcpActionTokens, "mcpActionTokens");
|
|
157
274
|
function isReviewableMcpDraftTool(tool) {
|
|
158
275
|
const sep = tool.indexOf("_");
|
|
159
276
|
if (sep <= 0 || sep >= tool.length - 1) return false;
|
|
@@ -163,7 +280,7 @@ function isReviewableMcpDraftTool(tool) {
|
|
|
163
280
|
return !MCP_TOOL_READ_VERB_RE.test(action);
|
|
164
281
|
}
|
|
165
282
|
__name(isReviewableMcpDraftTool, "isReviewableMcpDraftTool");
|
|
166
|
-
|
|
283
|
+
__name3(isReviewableMcpDraftTool, "isReviewableMcpDraftTool");
|
|
167
284
|
var MCP_DRAFT_CREATE_VERBS = /* @__PURE__ */ new Set([
|
|
168
285
|
"create",
|
|
169
286
|
"compose",
|
|
@@ -181,7 +298,7 @@ function isMcpDraftCreateTool(tool) {
|
|
|
181
298
|
return tokens[0] === "draft" || tokens.some((t) => MCP_DRAFT_CREATE_VERBS.has(t));
|
|
182
299
|
}
|
|
183
300
|
__name(isMcpDraftCreateTool, "isMcpDraftCreateTool");
|
|
184
|
-
|
|
301
|
+
__name3(isMcpDraftCreateTool, "isMcpDraftCreateTool");
|
|
185
302
|
function mcpSendSiblingForDraftTool(tool, availableToolIds) {
|
|
186
303
|
const candidates = [
|
|
187
304
|
...availableToolIds
|
|
@@ -192,12 +309,12 @@ function mcpSendSiblingForDraftTool(tool, availableToolIds) {
|
|
|
192
309
|
return candidates[0]?.id;
|
|
193
310
|
}
|
|
194
311
|
__name(mcpSendSiblingForDraftTool, "mcpSendSiblingForDraftTool");
|
|
195
|
-
|
|
312
|
+
__name3(mcpSendSiblingForDraftTool, "mcpSendSiblingForDraftTool");
|
|
196
313
|
function isReviewableExecuteTool(tool) {
|
|
197
314
|
return isAllowedReviewableExecuteTool(tool) || isReviewableMcpSendTool(tool) || isReviewableStandingStartTool(tool);
|
|
198
315
|
}
|
|
199
316
|
__name(isReviewableExecuteTool, "isReviewableExecuteTool");
|
|
200
|
-
|
|
317
|
+
__name3(isReviewableExecuteTool, "isReviewableExecuteTool");
|
|
201
318
|
var NON_INTERACTIVE_CHANNELS = [
|
|
202
319
|
"trigger",
|
|
203
320
|
"agent-invocation",
|
|
@@ -209,18 +326,23 @@ function isInteractiveChannel(channel) {
|
|
|
209
326
|
return !NON_INTERACTIVE_CHANNELS.includes(channel);
|
|
210
327
|
}
|
|
211
328
|
__name(isInteractiveChannel, "isInteractiveChannel");
|
|
212
|
-
|
|
329
|
+
__name3(isInteractiveChannel, "isInteractiveChannel");
|
|
213
330
|
function isInteractiveTurn(turn) {
|
|
214
331
|
if (typeof turn.interactive === "boolean") return turn.interactive;
|
|
215
332
|
return isInteractiveChannel(turn.channel);
|
|
216
333
|
}
|
|
217
334
|
__name(isInteractiveTurn, "isInteractiveTurn");
|
|
218
|
-
|
|
335
|
+
__name3(isInteractiveTurn, "isInteractiveTurn");
|
|
219
336
|
function removeNavigateBlock(input) {
|
|
220
337
|
return input.replace(/::: navigate[\s\S]*?:::/g, "").trim();
|
|
221
338
|
}
|
|
222
339
|
__name(removeNavigateBlock, "removeNavigateBlock");
|
|
223
|
-
|
|
340
|
+
__name3(removeNavigateBlock, "removeNavigateBlock");
|
|
341
|
+
function removeHiddenBlocks(input) {
|
|
342
|
+
return input.replace(/::: hide\b[\s\S]*?:::/gi, "").replace(/::: hide\b[\s\S]*$/gi, "").trim();
|
|
343
|
+
}
|
|
344
|
+
__name(removeHiddenBlocks, "removeHiddenBlocks");
|
|
345
|
+
__name3(removeHiddenBlocks, "removeHiddenBlocks");
|
|
224
346
|
function transformChatHistoryContentParts(parts) {
|
|
225
347
|
const content = [];
|
|
226
348
|
for (const rawPart of parts ?? []) {
|
|
@@ -365,14 +487,14 @@ function transformChatHistoryContentParts(parts) {
|
|
|
365
487
|
return content;
|
|
366
488
|
}
|
|
367
489
|
__name(transformChatHistoryContentParts, "transformChatHistoryContentParts");
|
|
368
|
-
|
|
490
|
+
__name3(transformChatHistoryContentParts, "transformChatHistoryContentParts");
|
|
369
491
|
var RICH_PARTS_MESSAGE_ID_PREFIX = "rich-parts:";
|
|
370
492
|
var SCREENSHOT_MESSAGE_ID_PREFIX = "screenshot:";
|
|
371
493
|
function isSyntheticSideRow(id2) {
|
|
372
494
|
return id2.startsWith(SCREENSHOT_MESSAGE_ID_PREFIX) || id2.startsWith(RICH_PARTS_MESSAGE_ID_PREFIX);
|
|
373
495
|
}
|
|
374
496
|
__name(isSyntheticSideRow, "isSyntheticSideRow");
|
|
375
|
-
|
|
497
|
+
__name3(isSyntheticSideRow, "isSyntheticSideRow");
|
|
376
498
|
function mergeRichPartMirrorMessages(messages, sameTurnGroup) {
|
|
377
499
|
const merged = [];
|
|
378
500
|
for (const message of messages) {
|
|
@@ -411,7 +533,7 @@ function mergeRichPartMirrorMessages(messages, sameTurnGroup) {
|
|
|
411
533
|
return merged;
|
|
412
534
|
}
|
|
413
535
|
__name(mergeRichPartMirrorMessages, "mergeRichPartMirrorMessages");
|
|
414
|
-
|
|
536
|
+
__name3(mergeRichPartMirrorMessages, "mergeRichPartMirrorMessages");
|
|
415
537
|
function citationDedupeKeys(part) {
|
|
416
538
|
if (part.type !== "source-url" && part.type !== "source-document") return [];
|
|
417
539
|
const keys = [];
|
|
@@ -420,10 +542,10 @@ function citationDedupeKeys(part) {
|
|
|
420
542
|
return keys;
|
|
421
543
|
}
|
|
422
544
|
__name(citationDedupeKeys, "citationDedupeKeys");
|
|
423
|
-
|
|
545
|
+
__name3(citationDedupeKeys, "citationDedupeKeys");
|
|
424
546
|
function foldRichPartsIntoMessages(messages, records, makeMessage, sameTurnGroup) {
|
|
425
547
|
if (messages.length === 0 || records.length === 0) return messages;
|
|
426
|
-
const messageTime = /* @__PURE__ */
|
|
548
|
+
const messageTime = /* @__PURE__ */ __name3((m) => m.createdAt ? new Date(m.createdAt).getTime() : Number.NEGATIVE_INFINITY, "messageTime");
|
|
427
549
|
const finiteTimes = messages.map(messageTime).filter(Number.isFinite);
|
|
428
550
|
const oldest = finiteTimes.length > 0 ? Math.min(...finiteTimes) : Number.NEGATIVE_INFINITY;
|
|
429
551
|
const synthetic = [];
|
|
@@ -457,7 +579,7 @@ function foldRichPartsIntoMessages(messages, records, makeMessage, sameTurnGroup
|
|
|
457
579
|
return mergeRichPartMirrorMessages(combined, sameTurnGroup);
|
|
458
580
|
}
|
|
459
581
|
__name(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
|
|
460
|
-
|
|
582
|
+
__name3(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
|
|
461
583
|
var BROWSER_COMMANDS = [
|
|
462
584
|
// health + lifecycle / navigation
|
|
463
585
|
{
|
|
@@ -683,7 +805,7 @@ var LuaLogFieldsError = class _LuaLogFieldsError extends Error {
|
|
|
683
805
|
__name(this, "_LuaLogFieldsError");
|
|
684
806
|
}
|
|
685
807
|
static {
|
|
686
|
-
|
|
808
|
+
__name3(this, "LuaLogFieldsError");
|
|
687
809
|
}
|
|
688
810
|
constructor(message) {
|
|
689
811
|
super(message);
|
|
@@ -714,7 +836,7 @@ function utf8WidthAt(value3, index) {
|
|
|
714
836
|
};
|
|
715
837
|
}
|
|
716
838
|
__name(utf8WidthAt, "utf8WidthAt");
|
|
717
|
-
|
|
839
|
+
__name3(utf8WidthAt, "utf8WidthAt");
|
|
718
840
|
function utf8ByteLength(value3) {
|
|
719
841
|
let bytes = 0;
|
|
720
842
|
for (let i = 0; i < value3.length; ) {
|
|
@@ -725,7 +847,7 @@ function utf8ByteLength(value3) {
|
|
|
725
847
|
return bytes;
|
|
726
848
|
}
|
|
727
849
|
__name(utf8ByteLength, "utf8ByteLength");
|
|
728
|
-
|
|
850
|
+
__name3(utf8ByteLength, "utf8ByteLength");
|
|
729
851
|
function clampUtf8(value3, maxBytes) {
|
|
730
852
|
let bytes = 0;
|
|
731
853
|
for (let i = 0; i < value3.length; ) {
|
|
@@ -737,7 +859,7 @@ function clampUtf8(value3, maxBytes) {
|
|
|
737
859
|
return value3;
|
|
738
860
|
}
|
|
739
861
|
__name(clampUtf8, "clampUtf8");
|
|
740
|
-
|
|
862
|
+
__name3(clampUtf8, "clampUtf8");
|
|
741
863
|
function mapBytes(fields, withMark) {
|
|
742
864
|
return utf8ByteLength(JSON.stringify(withMark ? {
|
|
743
865
|
...fields,
|
|
@@ -745,7 +867,7 @@ function mapBytes(fields, withMark) {
|
|
|
745
867
|
} : fields));
|
|
746
868
|
}
|
|
747
869
|
__name(mapBytes, "mapBytes");
|
|
748
|
-
|
|
870
|
+
__name3(mapBytes, "mapBytes");
|
|
749
871
|
function withValueCap(fields, capBytes) {
|
|
750
872
|
const out = {};
|
|
751
873
|
for (const [key, value3] of Object.entries(fields)) {
|
|
@@ -754,7 +876,7 @@ function withValueCap(fields, capBytes) {
|
|
|
754
876
|
return out;
|
|
755
877
|
}
|
|
756
878
|
__name(withValueCap, "withValueCap");
|
|
757
|
-
|
|
879
|
+
__name3(withValueCap, "withValueCap");
|
|
758
880
|
function describeValue(value3) {
|
|
759
881
|
if (value3 === null) return "null";
|
|
760
882
|
if (value3 === void 0) return "undefined";
|
|
@@ -762,7 +884,7 @@ function describeValue(value3) {
|
|
|
762
884
|
return typeof value3 === "object" ? "an object" : `a ${typeof value3}`;
|
|
763
885
|
}
|
|
764
886
|
__name(describeValue, "describeValue");
|
|
765
|
-
|
|
887
|
+
__name3(describeValue, "describeValue");
|
|
766
888
|
function assertValidLogFieldKey(key) {
|
|
767
889
|
if (!LOG_FIELD_KEY_PATTERN.test(key)) {
|
|
768
890
|
throw new LuaLogFieldsError(`log fields: key \`${key}\` is not allowed \u2014 a key must match ${LOG_FIELD_KEY_PATTERN.source} (lower-case, starts with a letter, then letters/digits/underscore, at most 64 characters)`);
|
|
@@ -775,7 +897,7 @@ function assertValidLogFieldKey(key) {
|
|
|
775
897
|
}
|
|
776
898
|
}
|
|
777
899
|
__name(assertValidLogFieldKey, "assertValidLogFieldKey");
|
|
778
|
-
|
|
900
|
+
__name3(assertValidLogFieldKey, "assertValidLogFieldKey");
|
|
779
901
|
function normalizeLogFields(fields) {
|
|
780
902
|
if (fields === void 0 || fields === null) return void 0;
|
|
781
903
|
if (typeof fields !== "object" || Array.isArray(fields)) {
|
|
@@ -825,7 +947,7 @@ function normalizeLogFields(fields) {
|
|
|
825
947
|
return out;
|
|
826
948
|
}
|
|
827
949
|
__name(normalizeLogFields, "normalizeLogFields");
|
|
828
|
-
|
|
950
|
+
__name3(normalizeLogFields, "normalizeLogFields");
|
|
829
951
|
function clampLogFields(out) {
|
|
830
952
|
let clamped = false;
|
|
831
953
|
for (const [key, value3] of Object.entries(out)) {
|
|
@@ -857,7 +979,7 @@ function clampLogFields(out) {
|
|
|
857
979
|
return true;
|
|
858
980
|
}
|
|
859
981
|
__name(clampLogFields, "clampLogFields");
|
|
860
|
-
|
|
982
|
+
__name3(clampLogFields, "clampLogFields");
|
|
861
983
|
var DESKTOP_FILE_COMMANDS = [
|
|
862
984
|
"files_roots",
|
|
863
985
|
"files_stat",
|
|
@@ -879,12 +1001,12 @@ function isDesktopFileCommandName(value3) {
|
|
|
879
1001
|
return typeof value3 === "string" && DESKTOP_FILE_COMMAND_SET.has(value3);
|
|
880
1002
|
}
|
|
881
1003
|
__name(isDesktopFileCommandName, "isDesktopFileCommandName");
|
|
882
|
-
|
|
1004
|
+
__name3(isDesktopFileCommandName, "isDesktopFileCommandName");
|
|
883
1005
|
function isDesktopFileSessionId(value3) {
|
|
884
1006
|
return typeof value3 === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value3);
|
|
885
1007
|
}
|
|
886
1008
|
__name(isDesktopFileSessionId, "isDesktopFileSessionId");
|
|
887
|
-
|
|
1009
|
+
__name3(isDesktopFileSessionId, "isDesktopFileSessionId");
|
|
888
1010
|
var WORKFLOW_RETRY_BACKOFFS = [
|
|
889
1011
|
"fixed",
|
|
890
1012
|
"exponential"
|
|
@@ -902,12 +1024,12 @@ function workflowRetryMaxAttemptsMessage(got) {
|
|
|
902
1024
|
return `\`retry.maxAttempts\` must be an integer ${WORKFLOW_RETRY_MIN_ATTEMPTS}..${WORKFLOW_RETRY_MAX_ATTEMPTS}${tail}`;
|
|
903
1025
|
}
|
|
904
1026
|
__name(workflowRetryMaxAttemptsMessage, "workflowRetryMaxAttemptsMessage");
|
|
905
|
-
|
|
1027
|
+
__name3(workflowRetryMaxAttemptsMessage, "workflowRetryMaxAttemptsMessage");
|
|
906
1028
|
function isWithinWorkflowRetryAttempts(value3) {
|
|
907
1029
|
return typeof value3 === "number" && Number.isInteger(value3) && value3 >= WORKFLOW_RETRY_MIN_ATTEMPTS && value3 <= WORKFLOW_RETRY_MAX_ATTEMPTS;
|
|
908
1030
|
}
|
|
909
1031
|
__name(isWithinWorkflowRetryAttempts, "isWithinWorkflowRetryAttempts");
|
|
910
|
-
|
|
1032
|
+
__name3(isWithinWorkflowRetryAttempts, "isWithinWorkflowRetryAttempts");
|
|
911
1033
|
var WORKFLOW_RETRY_ENGINE_KEYS = [
|
|
912
1034
|
"budgetBaseAttempt"
|
|
913
1035
|
];
|
|
@@ -919,13 +1041,13 @@ function workflowRetryUnknownMembersMessage(keys) {
|
|
|
919
1041
|
return `\`retry\` has no member ${named.join(", ")}; members: ${WORKFLOW_RETRY_POLICY_KEYS.join(", ")}`;
|
|
920
1042
|
}
|
|
921
1043
|
__name(workflowRetryUnknownMembersMessage, "workflowRetryUnknownMembersMessage");
|
|
922
|
-
|
|
1044
|
+
__name3(workflowRetryUnknownMembersMessage, "workflowRetryUnknownMembersMessage");
|
|
923
1045
|
function unknownWorkflowRetryMembers(retry) {
|
|
924
1046
|
if (!retry || typeof retry !== "object" || Array.isArray(retry)) return [];
|
|
925
1047
|
return Object.keys(retry).filter((k) => !WORKFLOW_RETRY_POLICY_KEYS.includes(k));
|
|
926
1048
|
}
|
|
927
1049
|
__name(unknownWorkflowRetryMembers, "unknownWorkflowRetryMembers");
|
|
928
|
-
|
|
1050
|
+
__name3(unknownWorkflowRetryMembers, "unknownWorkflowRetryMembers");
|
|
929
1051
|
function authoredRetryPolicy(retry) {
|
|
930
1052
|
if (!retry || typeof retry !== "object" || Array.isArray(retry)) return void 0;
|
|
931
1053
|
const src = retry;
|
|
@@ -934,34 +1056,34 @@ function authoredRetryPolicy(retry) {
|
|
|
934
1056
|
return Object.keys(out).length ? out : void 0;
|
|
935
1057
|
}
|
|
936
1058
|
__name(authoredRetryPolicy, "authoredRetryPolicy");
|
|
937
|
-
|
|
1059
|
+
__name3(authoredRetryPolicy, "authoredRetryPolicy");
|
|
938
1060
|
function retryBudgetBaseAttempt(row) {
|
|
939
1061
|
const base = row.retry?.budgetBaseAttempt;
|
|
940
1062
|
return typeof base === "number" && Number.isSafeInteger(base) && base > 0 ? base : 0;
|
|
941
1063
|
}
|
|
942
1064
|
__name(retryBudgetBaseAttempt, "retryBudgetBaseAttempt");
|
|
943
|
-
|
|
1065
|
+
__name3(retryBudgetBaseAttempt, "retryBudgetBaseAttempt");
|
|
944
1066
|
function retryBudgetAttempt(row) {
|
|
945
1067
|
return Math.max(0, row.attempt - retryBudgetBaseAttempt(row));
|
|
946
1068
|
}
|
|
947
1069
|
__name(retryBudgetAttempt, "retryBudgetAttempt");
|
|
948
|
-
|
|
1070
|
+
__name3(retryBudgetAttempt, "retryBudgetAttempt");
|
|
949
1071
|
function retryBudgetMaxAttempts(row) {
|
|
950
1072
|
const max = row.retry?.maxAttempts;
|
|
951
1073
|
return typeof max === "number" && Number.isFinite(max) && max >= 1 ? max : 1;
|
|
952
1074
|
}
|
|
953
1075
|
__name(retryBudgetMaxAttempts, "retryBudgetMaxAttempts");
|
|
954
|
-
|
|
1076
|
+
__name3(retryBudgetMaxAttempts, "retryBudgetMaxAttempts");
|
|
955
1077
|
function retryBudgetRemaining(row) {
|
|
956
1078
|
return retryBudgetAttempt(row) < retryBudgetMaxAttempts(row);
|
|
957
1079
|
}
|
|
958
1080
|
__name(retryBudgetRemaining, "retryBudgetRemaining");
|
|
959
|
-
|
|
1081
|
+
__name3(retryBudgetRemaining, "retryBudgetRemaining");
|
|
960
1082
|
function retriesRemaining(row) {
|
|
961
1083
|
return Math.max(0, retryBudgetMaxAttempts(row) - retryBudgetAttempt(row));
|
|
962
1084
|
}
|
|
963
1085
|
__name(retriesRemaining, "retriesRemaining");
|
|
964
|
-
|
|
1086
|
+
__name3(retriesRemaining, "retriesRemaining");
|
|
965
1087
|
var WORKFLOW_JOB_RESOURCES = [
|
|
966
1088
|
"small",
|
|
967
1089
|
"medium",
|
|
@@ -982,7 +1104,7 @@ function workflowModelCostComparison(estimate, onAgentModel, agentModel) {
|
|
|
982
1104
|
return `\u2248 ${ratio}\xD7 the cost of running every step on ${agentModel}`;
|
|
983
1105
|
}
|
|
984
1106
|
__name(workflowModelCostComparison, "workflowModelCostComparison");
|
|
985
|
-
|
|
1107
|
+
__name3(workflowModelCostComparison, "workflowModelCostComparison");
|
|
986
1108
|
var WORKFLOW_DEFAULT_TASK_CLASS_MAP = Object.freeze({
|
|
987
1109
|
classify: "fast",
|
|
988
1110
|
extract: "fast",
|
|
@@ -998,13 +1120,13 @@ function modelClassRank(modelClass) {
|
|
|
998
1120
|
return WORKFLOW_MODEL_CLASSES.indexOf(modelClass);
|
|
999
1121
|
}
|
|
1000
1122
|
__name(modelClassRank, "modelClassRank");
|
|
1001
|
-
|
|
1123
|
+
__name3(modelClassRank, "modelClassRank");
|
|
1002
1124
|
function modelClassesAtOrBelow(maxClass) {
|
|
1003
1125
|
const ceiling = modelClassRank(maxClass);
|
|
1004
1126
|
return WORKFLOW_MODEL_CLASSES.filter((c) => modelClassRank(c) <= ceiling);
|
|
1005
1127
|
}
|
|
1006
1128
|
__name(modelClassesAtOrBelow, "modelClassesAtOrBelow");
|
|
1007
|
-
|
|
1129
|
+
__name3(modelClassesAtOrBelow, "modelClassesAtOrBelow");
|
|
1008
1130
|
var WORKFLOW_AUTONOMY_NUMERIC_KEYS = [
|
|
1009
1131
|
"maxCredits",
|
|
1010
1132
|
"maxSteps",
|
|
@@ -1034,7 +1156,7 @@ function workflowAutonomyMaxRunsPerHourCeiling(env) {
|
|
|
1034
1156
|
return Number.isFinite(raw) && raw > 0 ? raw : WORKFLOW_AUTONOMY_MAX_RUNS_PER_HOUR_CEILING;
|
|
1035
1157
|
}
|
|
1036
1158
|
__name(workflowAutonomyMaxRunsPerHourCeiling, "workflowAutonomyMaxRunsPerHourCeiling");
|
|
1037
|
-
|
|
1159
|
+
__name3(workflowAutonomyMaxRunsPerHourCeiling, "workflowAutonomyMaxRunsPerHourCeiling");
|
|
1038
1160
|
var WORKFLOW_AUTONOMY_FORMS_DEFAULT = Object.freeze([
|
|
1039
1161
|
"graph",
|
|
1040
1162
|
"static"
|
|
@@ -1044,12 +1166,12 @@ function isWithinWorkflowAutonomyRange(value3, ceiling) {
|
|
|
1044
1166
|
return typeof value3 === "number" && Number.isInteger(value3) && value3 >= WORKFLOW_AUTONOMY_MIN_VALUE && value3 <= ceiling;
|
|
1045
1167
|
}
|
|
1046
1168
|
__name(isWithinWorkflowAutonomyRange, "isWithinWorkflowAutonomyRange");
|
|
1047
|
-
|
|
1169
|
+
__name3(isWithinWorkflowAutonomyRange, "isWithinWorkflowAutonomyRange");
|
|
1048
1170
|
function workflowAutonomyRangeMessage(key, ceiling) {
|
|
1049
1171
|
return `\`${key}\` must be an integer ${WORKFLOW_AUTONOMY_MIN_VALUE}..${ceiling}`;
|
|
1050
1172
|
}
|
|
1051
1173
|
__name(workflowAutonomyRangeMessage, "workflowAutonomyRangeMessage");
|
|
1052
|
-
|
|
1174
|
+
__name3(workflowAutonomyRangeMessage, "workflowAutonomyRangeMessage");
|
|
1053
1175
|
var WORKFLOW_JOB_RANGES = Object.freeze({
|
|
1054
1176
|
/** Coding-turn cap (`claude -p --max-turns`); absent ⇒ the cluster default (LUA_WF_JOB_MAX_TURNS). */
|
|
1055
1177
|
maxTurns: Object.freeze({
|
|
@@ -1073,13 +1195,13 @@ function isWithinWorkflowJobRange(member, value3) {
|
|
|
1073
1195
|
return typeof value3 === "number" && Number.isInteger(value3) && value3 >= min && value3 <= max;
|
|
1074
1196
|
}
|
|
1075
1197
|
__name(isWithinWorkflowJobRange, "isWithinWorkflowJobRange");
|
|
1076
|
-
|
|
1198
|
+
__name3(isWithinWorkflowJobRange, "isWithinWorkflowJobRange");
|
|
1077
1199
|
function workflowJobRangeMessage(member) {
|
|
1078
1200
|
const { min, max } = WORKFLOW_JOB_RANGES[member];
|
|
1079
1201
|
return `\`${member}\` must be an integer ${min}..${max}`;
|
|
1080
1202
|
}
|
|
1081
1203
|
__name(workflowJobRangeMessage, "workflowJobRangeMessage");
|
|
1082
|
-
|
|
1204
|
+
__name3(workflowJobRangeMessage, "workflowJobRangeMessage");
|
|
1083
1205
|
var WORKFLOW_SINGLE_STEP_TYPES = [
|
|
1084
1206
|
"agent",
|
|
1085
1207
|
"tool",
|
|
@@ -1103,33 +1225,33 @@ function isWorkflowSingleStepType(type) {
|
|
|
1103
1225
|
return typeof type === "string" && WORKFLOW_SINGLE_STEP_TYPES.includes(type);
|
|
1104
1226
|
}
|
|
1105
1227
|
__name(isWorkflowSingleStepType, "isWorkflowSingleStepType");
|
|
1106
|
-
|
|
1228
|
+
__name3(isWorkflowSingleStepType, "isWorkflowSingleStepType");
|
|
1107
1229
|
function isWorkflowHitlEntryType(type) {
|
|
1108
1230
|
return typeof type === "string" && WORKFLOW_HITL_ENTRY_TYPES.includes(type);
|
|
1109
1231
|
}
|
|
1110
1232
|
__name(isWorkflowHitlEntryType, "isWorkflowHitlEntryType");
|
|
1111
|
-
|
|
1233
|
+
__name3(isWorkflowHitlEntryType, "isWorkflowHitlEntryType");
|
|
1112
1234
|
function isWorkflowArmEntryType(type) {
|
|
1113
1235
|
return typeof type === "string" && WORKFLOW_ARM_ENTRY_TYPES.includes(type);
|
|
1114
1236
|
}
|
|
1115
1237
|
__name(isWorkflowArmEntryType, "isWorkflowArmEntryType");
|
|
1116
|
-
|
|
1238
|
+
__name3(isWorkflowArmEntryType, "isWorkflowArmEntryType");
|
|
1117
1239
|
function workflowContainerRunsHitlArm(container) {
|
|
1118
1240
|
return typeof container === "string" && WORKFLOW_HITL_ARM_CONTAINERS.includes(container);
|
|
1119
1241
|
}
|
|
1120
1242
|
__name(workflowContainerRunsHitlArm, "workflowContainerRunsHitlArm");
|
|
1121
|
-
|
|
1243
|
+
__name3(workflowContainerRunsHitlArm, "workflowContainerRunsHitlArm");
|
|
1122
1244
|
function workflowHitlArmUnsupportedMessage(type, id2, container) {
|
|
1123
1245
|
const legal = WORKFLOW_HITL_ARM_CONTAINERS.map((c) => `\`${c}\``).join(" / ");
|
|
1124
1246
|
return `the engine does not run \`${type}\` inside a \`${container}\` yet (node "${id2}") \u2014 place it at the top level, as a ${legal} arm, or inside a child \`workflow\``;
|
|
1125
1247
|
}
|
|
1126
1248
|
__name(workflowHitlArmUnsupportedMessage, "workflowHitlArmUnsupportedMessage");
|
|
1127
|
-
|
|
1249
|
+
__name3(workflowHitlArmUnsupportedMessage, "workflowHitlArmUnsupportedMessage");
|
|
1128
1250
|
function workflowHitlArmShapeMessage(type, id2, shape) {
|
|
1129
1251
|
return shape === "mapped-arm" ? `\`${type}\` arm "${id2}" takes the previous output as its payload \u2014 it cannot head a [mapping, step] chain; map before the container instead` : `a chunked foreach hands each child a slice of items, not one \u2014 \`${type}\` body "${id2}" takes one item; drop \`chunk\``;
|
|
1130
1252
|
}
|
|
1131
1253
|
__name(workflowHitlArmShapeMessage, "workflowHitlArmShapeMessage");
|
|
1132
|
-
|
|
1254
|
+
__name3(workflowHitlArmShapeMessage, "workflowHitlArmShapeMessage");
|
|
1133
1255
|
var WORKFLOW_GRAPH_ENTRY_STEP_KINDS = Object.freeze({
|
|
1134
1256
|
agent: "agent",
|
|
1135
1257
|
tool: "tool",
|
|
@@ -1162,13 +1284,13 @@ function isModelIdSentinel(input) {
|
|
|
1162
1284
|
return lower === "auto" || lower.startsWith("auto/");
|
|
1163
1285
|
}
|
|
1164
1286
|
__name(isModelIdSentinel, "isModelIdSentinel");
|
|
1165
|
-
|
|
1287
|
+
__name3(isModelIdSentinel, "isModelIdSentinel");
|
|
1166
1288
|
var MODEL_CLASS_REF_PREFIX = "class/";
|
|
1167
1289
|
function isModelClassRef(input) {
|
|
1168
1290
|
return modelClassOf(input) !== void 0;
|
|
1169
1291
|
}
|
|
1170
1292
|
__name(isModelClassRef, "isModelClassRef");
|
|
1171
|
-
|
|
1293
|
+
__name3(isModelClassRef, "isModelClassRef");
|
|
1172
1294
|
function modelClassOf(input) {
|
|
1173
1295
|
const lower = (input ?? "").trim().toLowerCase();
|
|
1174
1296
|
if (!lower.startsWith(MODEL_CLASS_REF_PREFIX)) return void 0;
|
|
@@ -1176,12 +1298,12 @@ function modelClassOf(input) {
|
|
|
1176
1298
|
return WORKFLOW_MODEL_CLASSES.includes(c) ? c : void 0;
|
|
1177
1299
|
}
|
|
1178
1300
|
__name(modelClassOf, "modelClassOf");
|
|
1179
|
-
|
|
1301
|
+
__name3(modelClassOf, "modelClassOf");
|
|
1180
1302
|
function modelClassRef(modelClass) {
|
|
1181
1303
|
return `${MODEL_CLASS_REF_PREFIX}${modelClass}`;
|
|
1182
1304
|
}
|
|
1183
1305
|
__name(modelClassRef, "modelClassRef");
|
|
1184
|
-
|
|
1306
|
+
__name3(modelClassRef, "modelClassRef");
|
|
1185
1307
|
function normalizeModelId(input, registry) {
|
|
1186
1308
|
const requested = typeof input === "string" ? input.trim() : "";
|
|
1187
1309
|
if (!requested) return {
|
|
@@ -1255,7 +1377,7 @@ function normalizeModelId(input, registry) {
|
|
|
1255
1377
|
};
|
|
1256
1378
|
}
|
|
1257
1379
|
__name(normalizeModelId, "normalizeModelId");
|
|
1258
|
-
|
|
1380
|
+
__name3(normalizeModelId, "normalizeModelId");
|
|
1259
1381
|
function modelUnresolvedMessage(r) {
|
|
1260
1382
|
if (r.reason === "empty") return "model pin is empty \u2014 pin an approved model (provider/model) or omit `model`";
|
|
1261
1383
|
if (r.reason === "ambiguous") {
|
|
@@ -1264,12 +1386,12 @@ function modelUnresolvedMessage(r) {
|
|
|
1264
1386
|
return r.candidates.length ? `model "${r.requested}" does not resolve to an approved model \u2014 accepted forms: ${r.candidates.join(", ")}` : `model "${r.requested}" does not resolve to an approved model \u2014 accepted forms are the registry's provider-prefixed ids (provider/model) or a bare id that names exactly one of them`;
|
|
1265
1387
|
}
|
|
1266
1388
|
__name(modelUnresolvedMessage, "modelUnresolvedMessage");
|
|
1267
|
-
|
|
1389
|
+
__name3(modelUnresolvedMessage, "modelUnresolvedMessage");
|
|
1268
1390
|
function modelClassUnresolvedMessage(ref) {
|
|
1269
1391
|
return `model "${ref.trim()}" is a model-class request that was not resolved before dispatch \u2014 a class is resolved to a concrete approved model by the class map at dispatch, and is never sent to a provider as written; this step refuses rather than run on a substituted model`;
|
|
1270
1392
|
}
|
|
1271
1393
|
__name(modelClassUnresolvedMessage, "modelClassUnresolvedMessage");
|
|
1272
|
-
|
|
1394
|
+
__name3(modelClassUnresolvedMessage, "modelClassUnresolvedMessage");
|
|
1273
1395
|
function providerModelId(code) {
|
|
1274
1396
|
const requested = typeof code === "string" ? code.trim() : "";
|
|
1275
1397
|
if (!requested || isModelIdSentinel(requested)) return requested;
|
|
@@ -1280,13 +1402,13 @@ function providerModelId(code) {
|
|
|
1280
1402
|
return requested.slice(slash + 1);
|
|
1281
1403
|
}
|
|
1282
1404
|
__name(providerModelId, "providerModelId");
|
|
1283
|
-
|
|
1405
|
+
__name3(providerModelId, "providerModelId");
|
|
1284
1406
|
var MODEL_SNAPSHOT_SUFFIX = /(?:[-@](?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])|-(?:19|20)\d{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))$/;
|
|
1285
1407
|
function providerModelFamily(code) {
|
|
1286
1408
|
return providerModelId(code).toLowerCase().replace(MODEL_SNAPSHOT_SUFFIX, "");
|
|
1287
1409
|
}
|
|
1288
1410
|
__name(providerModelFamily, "providerModelFamily");
|
|
1289
|
-
|
|
1411
|
+
__name3(providerModelFamily, "providerModelFamily");
|
|
1290
1412
|
var IMPLICIT_MODEL_SELECTION_SOURCES = [
|
|
1291
1413
|
"workspace-default",
|
|
1292
1414
|
"platform-default"
|
|
@@ -1295,13 +1417,13 @@ function isImplicitModelSelectionSource(source) {
|
|
|
1295
1417
|
return source !== void 0 && IMPLICIT_MODEL_SELECTION_SOURCES.includes(source);
|
|
1296
1418
|
}
|
|
1297
1419
|
__name(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
|
|
1298
|
-
|
|
1420
|
+
__name3(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
|
|
1299
1421
|
var PLATFORM_FALLBACK_MODEL_SOURCE = "platform-fallback";
|
|
1300
1422
|
function isPlatformFallbackModelSource(source) {
|
|
1301
1423
|
return source === PLATFORM_FALLBACK_MODEL_SOURCE;
|
|
1302
1424
|
}
|
|
1303
1425
|
__name(isPlatformFallbackModelSource, "isPlatformFallbackModelSource");
|
|
1304
|
-
|
|
1426
|
+
__name3(isPlatformFallbackModelSource, "isPlatformFallbackModelSource");
|
|
1305
1427
|
function resolveRequireToolApproval(rules) {
|
|
1306
1428
|
const raw = rules?.requireToolApproval ?? rules?.requireApproval;
|
|
1307
1429
|
if (raw === void 0 || raw === null) return void 0;
|
|
@@ -1311,7 +1433,7 @@ function resolveRequireToolApproval(rules) {
|
|
|
1311
1433
|
return list.filter((t) => typeof t === "string");
|
|
1312
1434
|
}
|
|
1313
1435
|
__name(resolveRequireToolApproval, "resolveRequireToolApproval");
|
|
1314
|
-
|
|
1436
|
+
__name3(resolveRequireToolApproval, "resolveRequireToolApproval");
|
|
1315
1437
|
var AGENT_NAME_TOKEN = "[Your Agent Name]";
|
|
1316
1438
|
var DEFAULT_PERSONA_GUIDE = `# ${AGENT_NAME_TOKEN} - Persona
|
|
1317
1439
|
|
|
@@ -1363,7 +1485,7 @@ function buildDefaultPersona(agentName) {
|
|
|
1363
1485
|
return DEFAULT_PERSONA_GUIDE.replace(AGENT_NAME_TOKEN, () => agentName || "My Agent");
|
|
1364
1486
|
}
|
|
1365
1487
|
__name(buildDefaultPersona, "buildDefaultPersona");
|
|
1366
|
-
|
|
1488
|
+
__name3(buildDefaultPersona, "buildDefaultPersona");
|
|
1367
1489
|
var PERSONAL_SPACE_STARTING_PERSONA = `# ${AGENT_NAME_TOKEN}
|
|
1368
1490
|
|
|
1369
1491
|
You are ${AGENT_NAME_TOKEN}, the assistant for whoever is chatting with you here. Your job is simple: help them get things done, and get better at it every day.
|
|
@@ -1400,11 +1522,12 @@ function buildPersonalSpaceStartingPersona(agentName) {
|
|
|
1400
1522
|
return PERSONAL_SPACE_STARTING_PERSONA.replace(new RegExp(AGENT_NAME_TOKEN.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), () => agentName || "Your assistant");
|
|
1401
1523
|
}
|
|
1402
1524
|
__name(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
|
|
1403
|
-
|
|
1525
|
+
__name3(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
|
|
1404
1526
|
var AGENT_LOG_SOURCES = [
|
|
1405
1527
|
"skill",
|
|
1406
1528
|
"job",
|
|
1407
1529
|
"webhook",
|
|
1530
|
+
"web-route",
|
|
1408
1531
|
"trigger",
|
|
1409
1532
|
"preprocessor",
|
|
1410
1533
|
"postprocessor",
|
|
@@ -1419,7 +1542,8 @@ var AGENT_LOG_SOURCES = [
|
|
|
1419
1542
|
"model-resolver",
|
|
1420
1543
|
"workflow-step",
|
|
1421
1544
|
"workflow-script",
|
|
1422
|
-
"workflow"
|
|
1545
|
+
"workflow",
|
|
1546
|
+
"supervision"
|
|
1423
1547
|
];
|
|
1424
1548
|
var AGENT_LOG_FIELDS_MAX_WIRE_KEYS = LOG_FIELDS_MAX_KEYS + 1;
|
|
1425
1549
|
function utf8Bytes(value3) {
|
|
@@ -1449,14 +1573,14 @@ function utf8Bytes(value3) {
|
|
|
1449
1573
|
return bytes;
|
|
1450
1574
|
}
|
|
1451
1575
|
__name(utf8Bytes, "utf8Bytes");
|
|
1452
|
-
|
|
1576
|
+
__name3(utf8Bytes, "utf8Bytes");
|
|
1453
1577
|
function isPlainFieldKey(key) {
|
|
1454
1578
|
if (!LOG_FIELD_KEY_PATTERN.test(key)) return false;
|
|
1455
1579
|
if (key === LOG_FIELDS_CLAMPED_KEY) return false;
|
|
1456
1580
|
return !LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS.some((pattern) => pattern.test(key));
|
|
1457
1581
|
}
|
|
1458
1582
|
__name(isPlainFieldKey, "isPlainFieldKey");
|
|
1459
|
-
|
|
1583
|
+
__name3(isPlainFieldKey, "isPlainFieldKey");
|
|
1460
1584
|
function describeAgentLogFieldsViolation(value3) {
|
|
1461
1585
|
if (typeof value3 !== "object" || value3 === null || Array.isArray(value3)) {
|
|
1462
1586
|
return "fields must be an object";
|
|
@@ -1500,12 +1624,12 @@ function describeAgentLogFieldsViolation(value3) {
|
|
|
1500
1624
|
return void 0;
|
|
1501
1625
|
}
|
|
1502
1626
|
__name(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
|
|
1503
|
-
|
|
1627
|
+
__name3(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
|
|
1504
1628
|
function isAgentLogFields(value3) {
|
|
1505
1629
|
return describeAgentLogFieldsViolation(value3) === void 0;
|
|
1506
1630
|
}
|
|
1507
1631
|
__name(isAgentLogFields, "isAgentLogFields");
|
|
1508
|
-
|
|
1632
|
+
__name3(isAgentLogFields, "isAgentLogFields");
|
|
1509
1633
|
var LOG_DRAIN_TYPES_PHASE1 = [
|
|
1510
1634
|
"http",
|
|
1511
1635
|
"otlp",
|
|
@@ -1547,7 +1671,7 @@ function maxDrainsForTier(tier) {
|
|
|
1547
1671
|
return tier === "enterprise" ? LOG_DRAIN_MAX_PER_ORG_ENTERPRISE : LOG_DRAIN_MAX_PER_ORG;
|
|
1548
1672
|
}
|
|
1549
1673
|
__name(maxDrainsForTier, "maxDrainsForTier");
|
|
1550
|
-
|
|
1674
|
+
__name3(maxDrainsForTier, "maxDrainsForTier");
|
|
1551
1675
|
var LOG_DRAIN_DATADOG_SITES = [
|
|
1552
1676
|
"datadoghq.com",
|
|
1553
1677
|
"datadoghq.eu",
|
|
@@ -1575,7 +1699,7 @@ function resolvePresetEndpoint(type, site) {
|
|
|
1575
1699
|
return template3.replace("{site}", site);
|
|
1576
1700
|
}
|
|
1577
1701
|
__name(resolvePresetEndpoint, "resolvePresetEndpoint");
|
|
1578
|
-
|
|
1702
|
+
__name3(resolvePresetEndpoint, "resolvePresetEndpoint");
|
|
1579
1703
|
var LOG_DRAIN_BUCKET_NAME_PATTERN = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
|
|
1580
1704
|
var LOG_DRAIN_BUCKET_HOST_PATTERNS = Object.freeze({
|
|
1581
1705
|
aws: [
|
|
@@ -1597,7 +1721,7 @@ function isLogDrainBucketHostAllowed(provider, host) {
|
|
|
1597
1721
|
return (LOG_DRAIN_BUCKET_HOST_PATTERNS[provider] ?? []).some((pattern) => pattern.test(normalized));
|
|
1598
1722
|
}
|
|
1599
1723
|
__name(isLogDrainBucketHostAllowed, "isLogDrainBucketHostAllowed");
|
|
1600
|
-
|
|
1724
|
+
__name3(isLogDrainBucketHostAllowed, "isLogDrainBucketHostAllowed");
|
|
1601
1725
|
function resolveDrainBucketEndpoint(bucket) {
|
|
1602
1726
|
if (!LOG_DRAIN_BUCKET_NAME_PATTERN.test(bucket.bucket)) {
|
|
1603
1727
|
throw new Error("log drain bucket name is not a valid S3 bucket label");
|
|
@@ -1618,12 +1742,12 @@ function resolveDrainBucketEndpoint(bucket) {
|
|
|
1618
1742
|
return `https://${url.host}/${bucket.bucket}`;
|
|
1619
1743
|
}
|
|
1620
1744
|
__name(resolveDrainBucketEndpoint, "resolveDrainBucketEndpoint");
|
|
1621
|
-
|
|
1745
|
+
__name3(resolveDrainBucketEndpoint, "resolveDrainBucketEndpoint");
|
|
1622
1746
|
function drainBucketUsesPathStyle(provider) {
|
|
1623
1747
|
return provider !== "aws";
|
|
1624
1748
|
}
|
|
1625
1749
|
__name(drainBucketUsesPathStyle, "drainBucketUsesPathStyle");
|
|
1626
|
-
|
|
1750
|
+
__name3(drainBucketUsesPathStyle, "drainBucketUsesPathStyle");
|
|
1627
1751
|
function presetIntakeHosts(type) {
|
|
1628
1752
|
const template3 = LOG_DRAIN_ENDPOINT_TEMPLATES[type];
|
|
1629
1753
|
const sites = LOG_DRAIN_PRESET_SITES[type];
|
|
@@ -1638,7 +1762,7 @@ function presetIntakeHosts(type) {
|
|
|
1638
1762
|
return hosts;
|
|
1639
1763
|
}
|
|
1640
1764
|
__name(presetIntakeHosts, "presetIntakeHosts");
|
|
1641
|
-
|
|
1765
|
+
__name3(presetIntakeHosts, "presetIntakeHosts");
|
|
1642
1766
|
var LOG_DRAIN_PRESET_HOST_SUFFIXES = {
|
|
1643
1767
|
axiom: [
|
|
1644
1768
|
".axiom.co"
|
|
@@ -1654,7 +1778,7 @@ function presetHostAllowlist(type) {
|
|
|
1654
1778
|
];
|
|
1655
1779
|
}
|
|
1656
1780
|
__name(presetHostAllowlist, "presetHostAllowlist");
|
|
1657
|
-
|
|
1781
|
+
__name3(presetHostAllowlist, "presetHostAllowlist");
|
|
1658
1782
|
function drainHostAllowlistAllows(allowlist, host) {
|
|
1659
1783
|
const needle = host.toLowerCase();
|
|
1660
1784
|
return allowlist.some((raw) => {
|
|
@@ -1664,25 +1788,25 @@ function drainHostAllowlistAllows(allowlist, host) {
|
|
|
1664
1788
|
});
|
|
1665
1789
|
}
|
|
1666
1790
|
__name(drainHostAllowlistAllows, "drainHostAllowlistAllows");
|
|
1667
|
-
|
|
1791
|
+
__name3(drainHostAllowlistAllows, "drainHostAllowlistAllows");
|
|
1668
1792
|
function drainDestinationIsVendorPinned(type) {
|
|
1669
1793
|
if (LOG_DRAIN_ENDPOINT_TEMPLATES[type]) return true;
|
|
1670
1794
|
return presetHostAllowlist(type).length > 0;
|
|
1671
1795
|
}
|
|
1672
1796
|
__name(drainDestinationIsVendorPinned, "drainDestinationIsVendorPinned");
|
|
1673
|
-
|
|
1797
|
+
__name3(drainDestinationIsVendorPinned, "drainDestinationIsVendorPinned");
|
|
1674
1798
|
function drainVerificationOwnership(input) {
|
|
1675
1799
|
if (input.proved === true) return "verified";
|
|
1676
1800
|
if (input.mode === "test-post" && drainDestinationIsVendorPinned(input.type)) return "verified";
|
|
1677
1801
|
return "reachability-only";
|
|
1678
1802
|
}
|
|
1679
1803
|
__name(drainVerificationOwnership, "drainVerificationOwnership");
|
|
1680
|
-
|
|
1804
|
+
__name3(drainVerificationOwnership, "drainVerificationOwnership");
|
|
1681
1805
|
function drainOwnershipOrDefault(ownership) {
|
|
1682
1806
|
return ownership === "verified" ? "verified" : "reachability-only";
|
|
1683
1807
|
}
|
|
1684
1808
|
__name(drainOwnershipOrDefault, "drainOwnershipOrDefault");
|
|
1685
|
-
|
|
1809
|
+
__name3(drainOwnershipOrDefault, "drainOwnershipOrDefault");
|
|
1686
1810
|
var DRAIN_CONTENT_ACK_ERROR_CODE = "DRAIN_CONTENT_ACK_REQUIRED";
|
|
1687
1811
|
var DRAIN_CONTENT_ACK_FIELD = "includeContentAck";
|
|
1688
1812
|
var DrainContentAckRequiredError = class extends Error {
|
|
@@ -1690,7 +1814,7 @@ var DrainContentAckRequiredError = class extends Error {
|
|
|
1690
1814
|
__name(this, "DrainContentAckRequiredError");
|
|
1691
1815
|
}
|
|
1692
1816
|
static {
|
|
1693
|
-
|
|
1817
|
+
__name3(this, "DrainContentAckRequiredError");
|
|
1694
1818
|
}
|
|
1695
1819
|
code = DRAIN_CONTENT_ACK_ERROR_CODE;
|
|
1696
1820
|
field = DRAIN_CONTENT_ACK_FIELD;
|
|
@@ -1713,7 +1837,7 @@ function assertDrainContentAck(input) {
|
|
|
1713
1837
|
};
|
|
1714
1838
|
}
|
|
1715
1839
|
__name(assertDrainContentAck, "assertDrainContentAck");
|
|
1716
|
-
|
|
1840
|
+
__name3(assertDrainContentAck, "assertDrainContentAck");
|
|
1717
1841
|
var LOG_DRAIN_PRESET_PATHS = {
|
|
1718
1842
|
// https://docs.splunk.com/Documentation/Splunk/latest/Data/HECExamples
|
|
1719
1843
|
splunk: {
|
|
@@ -1796,13 +1920,13 @@ function composePresetEndpoint(type, endpoint) {
|
|
|
1796
1920
|
};
|
|
1797
1921
|
}
|
|
1798
1922
|
__name(composePresetEndpoint, "composePresetEndpoint");
|
|
1799
|
-
|
|
1923
|
+
__name3(composePresetEndpoint, "composePresetEndpoint");
|
|
1800
1924
|
function joinPresetEndpointToken(endpoint, token) {
|
|
1801
1925
|
if (typeof token !== "string" || !PRESET_SEGMENT_RE.test(token)) return endpoint;
|
|
1802
1926
|
return endpoint.endsWith("/") ? `${endpoint}${token}` : `${endpoint}/${token}`;
|
|
1803
1927
|
}
|
|
1804
1928
|
__name(joinPresetEndpointToken, "joinPresetEndpointToken");
|
|
1805
|
-
|
|
1929
|
+
__name3(joinPresetEndpointToken, "joinPresetEndpointToken");
|
|
1806
1930
|
var LOG_DRAIN_QUOTAS = {
|
|
1807
1931
|
team: {
|
|
1808
1932
|
eventsPerDay: 1e6,
|
|
@@ -1825,18 +1949,18 @@ function nextLogDrainQuotaResetAt(now) {
|
|
|
1825
1949
|
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1)).toISOString();
|
|
1826
1950
|
}
|
|
1827
1951
|
__name(nextLogDrainQuotaResetAt, "nextLogDrainQuotaResetAt");
|
|
1828
|
-
|
|
1952
|
+
__name3(nextLogDrainQuotaResetAt, "nextLogDrainQuotaResetAt");
|
|
1829
1953
|
function logDrainQuotaWindowExpired(usage, now) {
|
|
1830
1954
|
const resetsAt = Date.parse(usage?.resetsAt ?? "");
|
|
1831
1955
|
if (!Number.isFinite(resetsAt)) return true;
|
|
1832
1956
|
return now.getTime() >= resetsAt;
|
|
1833
1957
|
}
|
|
1834
1958
|
__name(logDrainQuotaWindowExpired, "logDrainQuotaWindowExpired");
|
|
1835
|
-
|
|
1959
|
+
__name3(logDrainQuotaWindowExpired, "logDrainQuotaWindowExpired");
|
|
1836
1960
|
function logDrainQuotaRatio(usage, now) {
|
|
1837
1961
|
if (!usage) return 0;
|
|
1838
1962
|
if (now && logDrainQuotaWindowExpired(usage, now)) return 0;
|
|
1839
|
-
const dimension = /* @__PURE__ */
|
|
1963
|
+
const dimension = /* @__PURE__ */ __name3((used, limit) => {
|
|
1840
1964
|
if (!Number.isFinite(limit) || limit <= 0) return 0;
|
|
1841
1965
|
if (!Number.isFinite(used) || used <= 0) return 0;
|
|
1842
1966
|
return used / limit;
|
|
@@ -1844,7 +1968,7 @@ function logDrainQuotaRatio(usage, now) {
|
|
|
1844
1968
|
return Math.max(dimension(usage.usedEvents, usage.eventsPerDay), dimension(usage.usedBytes, usage.bytesPerDay));
|
|
1845
1969
|
}
|
|
1846
1970
|
__name(logDrainQuotaRatio, "logDrainQuotaRatio");
|
|
1847
|
-
|
|
1971
|
+
__name3(logDrainQuotaRatio, "logDrainQuotaRatio");
|
|
1848
1972
|
function logDrainQuotaDegradationForRatio(ratio) {
|
|
1849
1973
|
if (!Number.isFinite(ratio)) return "none";
|
|
1850
1974
|
if (ratio >= LOG_DRAIN_QUOTA_PAUSE_RATIO) return "paused";
|
|
@@ -1853,17 +1977,17 @@ function logDrainQuotaDegradationForRatio(ratio) {
|
|
|
1853
1977
|
return "none";
|
|
1854
1978
|
}
|
|
1855
1979
|
__name(logDrainQuotaDegradationForRatio, "logDrainQuotaDegradationForRatio");
|
|
1856
|
-
|
|
1980
|
+
__name3(logDrainQuotaDegradationForRatio, "logDrainQuotaDegradationForRatio");
|
|
1857
1981
|
function logDrainQuotaDegradation(usage, now) {
|
|
1858
1982
|
return logDrainQuotaDegradationForRatio(logDrainQuotaRatio(usage, now));
|
|
1859
1983
|
}
|
|
1860
1984
|
__name(logDrainQuotaDegradation, "logDrainQuotaDegradation");
|
|
1861
|
-
|
|
1985
|
+
__name3(logDrainQuotaDegradation, "logDrainQuotaDegradation");
|
|
1862
1986
|
function logDrainQuotaWarned(usage, now) {
|
|
1863
1987
|
return logDrainQuotaRatio(usage, now) >= LOG_DRAIN_QUOTA_WARN_RATIO;
|
|
1864
1988
|
}
|
|
1865
1989
|
__name(logDrainQuotaWarned, "logDrainQuotaWarned");
|
|
1866
|
-
|
|
1990
|
+
__name3(logDrainQuotaWarned, "logDrainQuotaWarned");
|
|
1867
1991
|
function logDrainQuotaDroppedSeverities(degradation) {
|
|
1868
1992
|
switch (degradation) {
|
|
1869
1993
|
case "debug_dropped":
|
|
@@ -1880,7 +2004,7 @@ function logDrainQuotaDroppedSeverities(degradation) {
|
|
|
1880
2004
|
}
|
|
1881
2005
|
}
|
|
1882
2006
|
__name(logDrainQuotaDroppedSeverities, "logDrainQuotaDroppedSeverities");
|
|
1883
|
-
|
|
2007
|
+
__name3(logDrainQuotaDroppedSeverities, "logDrainQuotaDroppedSeverities");
|
|
1884
2008
|
var LOG_EXPORT_SOURCES = [
|
|
1885
2009
|
...AGENT_LOG_SOURCES,
|
|
1886
2010
|
"execution"
|
|
@@ -1895,7 +2019,7 @@ function isLogExportSource(source) {
|
|
|
1895
2019
|
return LOG_EXPORT_SOURCES.includes(source);
|
|
1896
2020
|
}
|
|
1897
2021
|
__name(isLogExportSource, "isLogExportSource");
|
|
1898
|
-
|
|
2022
|
+
__name3(isLogExportSource, "isLogExportSource");
|
|
1899
2023
|
var LOG_DRAIN_NOTICE_RATE_LIMIT_MS = 60 * 6e4;
|
|
1900
2024
|
var LOG_DRAIN_VERIFICATION_STALE_MS = 24 * 60 * 6e4;
|
|
1901
2025
|
var LOG_DRAIN_DIGEST_INTERVAL_MS = 24 * 60 * 6e4;
|
|
@@ -1908,17 +2032,17 @@ function clamp(value3, max) {
|
|
|
1908
2032
|
return trimmed.length <= max ? trimmed : `${trimmed.slice(0, max - 1)}\u2026`;
|
|
1909
2033
|
}
|
|
1910
2034
|
__name(clamp, "clamp");
|
|
1911
|
-
|
|
2035
|
+
__name3(clamp, "clamp");
|
|
1912
2036
|
function numberOr(value3, fallback) {
|
|
1913
2037
|
return typeof value3 === "number" && Number.isFinite(value3) ? value3 : fallback;
|
|
1914
2038
|
}
|
|
1915
2039
|
__name(numberOr, "numberOr");
|
|
1916
|
-
|
|
2040
|
+
__name3(numberOr, "numberOr");
|
|
1917
2041
|
function isoOr(value3) {
|
|
1918
2042
|
return typeof value3 === "string" && value3.length > 0 ? value3 : void 0;
|
|
1919
2043
|
}
|
|
1920
2044
|
__name(isoOr, "isoOr");
|
|
1921
|
-
|
|
2045
|
+
__name3(isoOr, "isoOr");
|
|
1922
2046
|
function logDrainNoticeView(drain, now) {
|
|
1923
2047
|
const health = drain.health ?? {};
|
|
1924
2048
|
const quota = drain.quota;
|
|
@@ -1946,18 +2070,18 @@ function logDrainNoticeView(drain, now) {
|
|
|
1946
2070
|
return view;
|
|
1947
2071
|
}
|
|
1948
2072
|
__name(logDrainNoticeView, "logDrainNoticeView");
|
|
1949
|
-
|
|
2073
|
+
__name3(logDrainNoticeView, "logDrainNoticeView");
|
|
1950
2074
|
function logDrainHealthCardPath(orgId, drainId) {
|
|
1951
2075
|
return `/orgs/${encodeURIComponent(orgId)}/log-drains/${encodeURIComponent(drainId)}`;
|
|
1952
2076
|
}
|
|
1953
2077
|
__name(logDrainHealthCardPath, "logDrainHealthCardPath");
|
|
1954
|
-
|
|
2078
|
+
__name3(logDrainHealthCardPath, "logDrainHealthCardPath");
|
|
1955
2079
|
function percent(ratio) {
|
|
1956
2080
|
if (!Number.isFinite(ratio) || ratio <= 0) return "0%";
|
|
1957
2081
|
return `${Math.round(ratio * 100)}%`;
|
|
1958
2082
|
}
|
|
1959
2083
|
__name(percent, "percent");
|
|
1960
|
-
|
|
2084
|
+
__name3(percent, "percent");
|
|
1961
2085
|
function becauseClause(view) {
|
|
1962
2086
|
const bits = [];
|
|
1963
2087
|
if (view.lastStatusCode) bits.push(`HTTP ${view.lastStatusCode}`);
|
|
@@ -1965,7 +2089,7 @@ function becauseClause(view) {
|
|
|
1965
2089
|
return bits.length ? ` Last error: ${bits.join(" \u2014 ")}.` : "";
|
|
1966
2090
|
}
|
|
1967
2091
|
__name(becauseClause, "becauseClause");
|
|
1968
|
-
|
|
2092
|
+
__name3(becauseClause, "becauseClause");
|
|
1969
2093
|
function logDrainNoticeCopy(payload) {
|
|
1970
2094
|
const view = payload.drain;
|
|
1971
2095
|
const name = view.name || view.id;
|
|
@@ -2034,7 +2158,7 @@ function logDrainNoticeCopy(payload) {
|
|
|
2034
2158
|
}
|
|
2035
2159
|
}
|
|
2036
2160
|
__name(logDrainNoticeCopy, "logDrainNoticeCopy");
|
|
2037
|
-
|
|
2161
|
+
__name3(logDrainNoticeCopy, "logDrainNoticeCopy");
|
|
2038
2162
|
function logDrainNoticeLabel(kind) {
|
|
2039
2163
|
switch (kind) {
|
|
2040
2164
|
case "failing":
|
|
@@ -2056,7 +2180,7 @@ function logDrainNoticeLabel(kind) {
|
|
|
2056
2180
|
}
|
|
2057
2181
|
}
|
|
2058
2182
|
__name(logDrainNoticeLabel, "logDrainNoticeLabel");
|
|
2059
|
-
|
|
2183
|
+
__name3(logDrainNoticeLabel, "logDrainNoticeLabel");
|
|
2060
2184
|
function logDrainNoticeDigestCopy(payload) {
|
|
2061
2185
|
const entries = [
|
|
2062
2186
|
...payload.entries ?? []
|
|
@@ -2075,7 +2199,7 @@ function logDrainNoticeDigestCopy(payload) {
|
|
|
2075
2199
|
};
|
|
2076
2200
|
}
|
|
2077
2201
|
__name(logDrainNoticeDigestCopy, "logDrainNoticeDigestCopy");
|
|
2078
|
-
|
|
2202
|
+
__name3(logDrainNoticeDigestCopy, "logDrainNoticeDigestCopy");
|
|
2079
2203
|
var LOG_DRAIN_USAGE_LINE_ITEM = "log_drain_events";
|
|
2080
2204
|
var LOG_DRAIN_BYTES_PER_GIB = 1024 ** 3;
|
|
2081
2205
|
var DEFAULT_LOG_DRAIN_PLAN_CONFIG = {
|
|
@@ -2121,7 +2245,7 @@ function finiteNonNegative(value3) {
|
|
|
2121
2245
|
return typeof value3 === "number" && Number.isFinite(value3) && value3 >= 0 ? value3 : void 0;
|
|
2122
2246
|
}
|
|
2123
2247
|
__name(finiteNonNegative, "finiteNonNegative");
|
|
2124
|
-
|
|
2248
|
+
__name3(finiteNonNegative, "finiteNonNegative");
|
|
2125
2249
|
function mergeLimits(base, stored) {
|
|
2126
2250
|
const patch = stored ?? {};
|
|
2127
2251
|
return {
|
|
@@ -2130,7 +2254,7 @@ function mergeLimits(base, stored) {
|
|
|
2130
2254
|
};
|
|
2131
2255
|
}
|
|
2132
2256
|
__name(mergeLimits, "mergeLimits");
|
|
2133
|
-
|
|
2257
|
+
__name3(mergeLimits, "mergeLimits");
|
|
2134
2258
|
function mergeCard(base, stored) {
|
|
2135
2259
|
const patch = stored ?? {};
|
|
2136
2260
|
return {
|
|
@@ -2141,7 +2265,7 @@ function mergeCard(base, stored) {
|
|
|
2141
2265
|
};
|
|
2142
2266
|
}
|
|
2143
2267
|
__name(mergeCard, "mergeCard");
|
|
2144
|
-
|
|
2268
|
+
__name3(mergeCard, "mergeCard");
|
|
2145
2269
|
function resolveStoredLogDrainPlanConfig(stored) {
|
|
2146
2270
|
const values = stored;
|
|
2147
2271
|
if (!values || typeof values.version !== "number" || !Number.isFinite(values.version)) {
|
|
@@ -2177,12 +2301,12 @@ function resolveStoredLogDrainPlanConfig(stored) {
|
|
|
2177
2301
|
};
|
|
2178
2302
|
}
|
|
2179
2303
|
__name(resolveStoredLogDrainPlanConfig, "resolveStoredLogDrainPlanConfig");
|
|
2180
|
-
|
|
2304
|
+
__name3(resolveStoredLogDrainPlanConfig, "resolveStoredLogDrainPlanConfig");
|
|
2181
2305
|
function logDrainPlanTierOverride(config, orgId) {
|
|
2182
2306
|
return orgId ? config.orgs?.[orgId]?.tier : void 0;
|
|
2183
2307
|
}
|
|
2184
2308
|
__name(logDrainPlanTierOverride, "logDrainPlanTierOverride");
|
|
2185
|
-
|
|
2309
|
+
__name3(logDrainPlanTierOverride, "logDrainPlanTierOverride");
|
|
2186
2310
|
function logDrainQuotaLimitsFor(config, orgId, tier) {
|
|
2187
2311
|
const base = config.tiers[tier] ?? config.tiers.team ?? LOG_DRAIN_QUOTAS.team;
|
|
2188
2312
|
const override = orgId ? config.orgs?.[orgId] : void 0;
|
|
@@ -2195,7 +2319,7 @@ function logDrainQuotaLimitsFor(config, orgId, tier) {
|
|
|
2195
2319
|
};
|
|
2196
2320
|
}
|
|
2197
2321
|
__name(logDrainQuotaLimitsFor, "logDrainQuotaLimitsFor");
|
|
2198
|
-
|
|
2322
|
+
__name3(logDrainQuotaLimitsFor, "logDrainQuotaLimitsFor");
|
|
2199
2323
|
function logDrainPriceCardFor(config, orgId, tier) {
|
|
2200
2324
|
const base = config.pricing[tier] ?? config.pricing.team ?? DEFAULT_LOG_DRAIN_PLAN_CONFIG.pricing.team;
|
|
2201
2325
|
const override = orgId ? config.orgs?.[orgId]?.pricing : void 0;
|
|
@@ -2204,7 +2328,7 @@ function logDrainPriceCardFor(config, orgId, tier) {
|
|
|
2204
2328
|
};
|
|
2205
2329
|
}
|
|
2206
2330
|
__name(logDrainPriceCardFor, "logDrainPriceCardFor");
|
|
2207
|
-
|
|
2331
|
+
__name3(logDrainPriceCardFor, "logDrainPriceCardFor");
|
|
2208
2332
|
function priceDrainUsage(totals, card, tier) {
|
|
2209
2333
|
const billableRecords = Math.max(0, Math.floor(finiteNonNegative(totals?.billableRecords) ?? 0));
|
|
2210
2334
|
const billableBytes = Math.max(0, Math.floor(finiteNonNegative(totals?.billableBytes) ?? 0));
|
|
@@ -2215,7 +2339,7 @@ function priceDrainUsage(totals, card, tier) {
|
|
|
2215
2339
|
const eventsUsd = overageEvents / 1e6 * card.usdPerMillionEvents;
|
|
2216
2340
|
const bytesUsd = overageBytes / LOG_DRAIN_BYTES_PER_GIB * card.usdPerGiB;
|
|
2217
2341
|
const unpriced = card.usdPerMillionEvents === 0 && card.usdPerGiB === 0;
|
|
2218
|
-
const round = /* @__PURE__ */
|
|
2342
|
+
const round = /* @__PURE__ */ __name3((usd) => Math.round(usd * 100) / 100, "round");
|
|
2219
2343
|
return {
|
|
2220
2344
|
lineItem: LOG_DRAIN_USAGE_LINE_ITEM,
|
|
2221
2345
|
tier,
|
|
@@ -2232,7 +2356,7 @@ function priceDrainUsage(totals, card, tier) {
|
|
|
2232
2356
|
};
|
|
2233
2357
|
}
|
|
2234
2358
|
__name(priceDrainUsage, "priceDrainUsage");
|
|
2235
|
-
|
|
2359
|
+
__name3(priceDrainUsage, "priceDrainUsage");
|
|
2236
2360
|
var LOG_CURSOR_MAX_LENGTH = 512;
|
|
2237
2361
|
var LOG_CURSOR_MAX_ID_LENGTH = 128;
|
|
2238
2362
|
var LOG_RELATIVE_TIME_PATTERN = /^(\d{1,9})([smhd])$/;
|
|
@@ -2250,7 +2374,7 @@ function encodeLogCursor(c) {
|
|
|
2250
2374
|
}), "utf8").toString("base64url");
|
|
2251
2375
|
}
|
|
2252
2376
|
__name(encodeLogCursor, "encodeLogCursor");
|
|
2253
|
-
|
|
2377
|
+
__name3(encodeLogCursor, "encodeLogCursor");
|
|
2254
2378
|
function decodeLogCursor(raw) {
|
|
2255
2379
|
if (typeof raw !== "string") return null;
|
|
2256
2380
|
const trimmed = raw.trim();
|
|
@@ -2271,7 +2395,7 @@ function decodeLogCursor(raw) {
|
|
|
2271
2395
|
};
|
|
2272
2396
|
}
|
|
2273
2397
|
__name(decodeLogCursor, "decodeLogCursor");
|
|
2274
|
-
|
|
2398
|
+
__name3(decodeLogCursor, "decodeLogCursor");
|
|
2275
2399
|
function parseLogTimeBound(raw, now = /* @__PURE__ */ new Date()) {
|
|
2276
2400
|
if (typeof raw !== "string") return null;
|
|
2277
2401
|
const value3 = raw.trim();
|
|
@@ -2289,7 +2413,7 @@ function parseLogTimeBound(raw, now = /* @__PURE__ */ new Date()) {
|
|
|
2289
2413
|
return Number.isNaN(at) ? null : new Date(at);
|
|
2290
2414
|
}
|
|
2291
2415
|
__name(parseLogTimeBound, "parseLogTimeBound");
|
|
2292
|
-
|
|
2416
|
+
__name3(parseLogTimeBound, "parseLogTimeBound");
|
|
2293
2417
|
var CORE_DRAINING_CODE = "CORE_DRAINING";
|
|
2294
2418
|
var CORE_DRAINING_DEFAULT_RETRY_MS = 1e3;
|
|
2295
2419
|
var CORE_DRAINING_MAX_RETRY_MS = 5e3;
|
|
@@ -2297,13 +2421,13 @@ function isRecord(value3) {
|
|
|
2297
2421
|
return typeof value3 === "object" && value3 !== null;
|
|
2298
2422
|
}
|
|
2299
2423
|
__name(isRecord, "isRecord");
|
|
2300
|
-
|
|
2424
|
+
__name3(isRecord, "isRecord");
|
|
2301
2425
|
function isCoreDrainingErrorResponse(value3) {
|
|
2302
2426
|
if (!isRecord(value3) || !isRecord(value3.error)) return false;
|
|
2303
2427
|
return value3.error.code === CORE_DRAINING_CODE && typeof value3.error.message === "string" && value3.error.retryable === true;
|
|
2304
2428
|
}
|
|
2305
2429
|
__name(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
|
|
2306
|
-
|
|
2430
|
+
__name3(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
|
|
2307
2431
|
function coreDrainingRetryDelayMs(retryAfter, nowMs = Date.now()) {
|
|
2308
2432
|
if (retryAfter === null) return CORE_DRAINING_DEFAULT_RETRY_MS;
|
|
2309
2433
|
const seconds = /^\d+$/.test(retryAfter.trim()) ? Number(retryAfter) : Number.NaN;
|
|
@@ -2312,7 +2436,7 @@ function coreDrainingRetryDelayMs(retryAfter, nowMs = Date.now()) {
|
|
|
2312
2436
|
return Math.min(Math.max(0, delayMs), CORE_DRAINING_MAX_RETRY_MS);
|
|
2313
2437
|
}
|
|
2314
2438
|
__name(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
|
|
2315
|
-
|
|
2439
|
+
__name3(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
|
|
2316
2440
|
async function readCoreDrainingRetryDelayMs(response) {
|
|
2317
2441
|
if (response.status !== 503) return null;
|
|
2318
2442
|
try {
|
|
@@ -2324,7 +2448,7 @@ async function readCoreDrainingRetryDelayMs(response) {
|
|
|
2324
2448
|
return coreDrainingRetryDelayMs(response.headers.get("Retry-After"));
|
|
2325
2449
|
}
|
|
2326
2450
|
__name(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
|
|
2327
|
-
|
|
2451
|
+
__name3(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
|
|
2328
2452
|
function waitForCoreDrain(delayMs, signal) {
|
|
2329
2453
|
return new Promise((resolve, reject) => {
|
|
2330
2454
|
if (signal?.aborted) {
|
|
@@ -2340,14 +2464,14 @@ function waitForCoreDrain(delayMs, signal) {
|
|
|
2340
2464
|
reject(signal?.reason ?? new DOMException("Aborted", "AbortError"));
|
|
2341
2465
|
}
|
|
2342
2466
|
__name(onAbort, "onAbort");
|
|
2343
|
-
|
|
2467
|
+
__name3(onAbort, "onAbort");
|
|
2344
2468
|
signal?.addEventListener("abort", onAbort, {
|
|
2345
2469
|
once: true
|
|
2346
2470
|
});
|
|
2347
2471
|
});
|
|
2348
2472
|
}
|
|
2349
2473
|
__name(waitForCoreDrain, "waitForCoreDrain");
|
|
2350
|
-
|
|
2474
|
+
__name3(waitForCoreDrain, "waitForCoreDrain");
|
|
2351
2475
|
async function fetchWithCoreDrainRetry(run, options = {}) {
|
|
2352
2476
|
const first = await run();
|
|
2353
2477
|
const delayMs = await readCoreDrainingRetryDelayMs(first);
|
|
@@ -2362,7 +2486,7 @@ async function fetchWithCoreDrainRetry(run, options = {}) {
|
|
|
2362
2486
|
return run();
|
|
2363
2487
|
}
|
|
2364
2488
|
__name(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
|
|
2365
|
-
|
|
2489
|
+
__name3(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
|
|
2366
2490
|
var VoiceNameSchema = z.string().regex(/^[a-zA-Z0-9_-]+$/, "Voice name must contain only alphanumeric characters, underscores, or hyphens").min(1).max(64);
|
|
2367
2491
|
var PluginProviderSchema = z.enum([
|
|
2368
2492
|
"deepgram",
|
|
@@ -2621,7 +2745,7 @@ function resolveLuaJobTimeoutSeconds(timeout) {
|
|
|
2621
2745
|
return resolved;
|
|
2622
2746
|
}
|
|
2623
2747
|
__name(resolveLuaJobTimeoutSeconds, "resolveLuaJobTimeoutSeconds");
|
|
2624
|
-
|
|
2748
|
+
__name3(resolveLuaJobTimeoutSeconds, "resolveLuaJobTimeoutSeconds");
|
|
2625
2749
|
function normalizeLuaJobExecutionTimeoutSeconds(timeout) {
|
|
2626
2750
|
if (typeof timeout !== "number" || !Number.isFinite(timeout)) {
|
|
2627
2751
|
return LUA_JOB_DEFAULT_TIMEOUT_SECONDS;
|
|
@@ -2629,7 +2753,7 @@ function normalizeLuaJobExecutionTimeoutSeconds(timeout) {
|
|
|
2629
2753
|
return Math.min(Math.max(timeout, LUA_JOB_MIN_TIMEOUT_SECONDS), LUA_JOB_MAX_TIMEOUT_SECONDS);
|
|
2630
2754
|
}
|
|
2631
2755
|
__name(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
|
|
2632
|
-
|
|
2756
|
+
__name3(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
|
|
2633
2757
|
var KEYS = /* @__PURE__ */ new Set([
|
|
2634
2758
|
"v",
|
|
2635
2759
|
"kind",
|
|
@@ -2645,7 +2769,7 @@ function isId(value3) {
|
|
|
2645
2769
|
return typeof value3 === "string" && value3.length > 0 && value3.length <= MAX_ID_LENGTH;
|
|
2646
2770
|
}
|
|
2647
2771
|
__name(isId, "isId");
|
|
2648
|
-
|
|
2772
|
+
__name3(isId, "isId");
|
|
2649
2773
|
function parseScheduledJobFire(raw) {
|
|
2650
2774
|
if (new TextEncoder().encode(raw).byteLength > MAX_BODY_BYTES) {
|
|
2651
2775
|
throw new Error("Invalid scheduled job fire: body is too large");
|
|
@@ -2693,14 +2817,14 @@ function parseScheduledJobFire(raw) {
|
|
|
2693
2817
|
};
|
|
2694
2818
|
}
|
|
2695
2819
|
__name(parseScheduledJobFire, "parseScheduledJobFire");
|
|
2696
|
-
|
|
2820
|
+
__name3(parseScheduledJobFire, "parseScheduledJobFire");
|
|
2697
2821
|
var TEMPLATE_TRIGGER_URL_ENV_PREFIX = "LUA_TRIGGER_URL__";
|
|
2698
2822
|
function triggerUrlEnvKey(triggerKey) {
|
|
2699
2823
|
const upper = triggerKey.trim().replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
2700
2824
|
return `${TEMPLATE_TRIGGER_URL_ENV_PREFIX}${upper}`;
|
|
2701
2825
|
}
|
|
2702
2826
|
__name(triggerUrlEnvKey, "triggerUrlEnvKey");
|
|
2703
|
-
|
|
2827
|
+
__name3(triggerUrlEnvKey, "triggerUrlEnvKey");
|
|
2704
2828
|
var TEMPLATE_INSTALL_POLICY_PER_WORKSPACE_VALUES = Object.freeze([
|
|
2705
2829
|
"single",
|
|
2706
2830
|
"multiple"
|
|
@@ -2740,7 +2864,7 @@ function deviceCredentialScopes(operations) {
|
|
|
2740
2864
|
];
|
|
2741
2865
|
}
|
|
2742
2866
|
__name(deviceCredentialScopes, "deviceCredentialScopes");
|
|
2743
|
-
|
|
2867
|
+
__name3(deviceCredentialScopes, "deviceCredentialScopes");
|
|
2744
2868
|
var DeviceBindingSchema = z2.object({
|
|
2745
2869
|
agentId: z2.string().min(1).max(256),
|
|
2746
2870
|
deviceName: z2.string().min(1).max(256),
|
|
@@ -2857,12 +2981,12 @@ function parsePrincipalContext(value3) {
|
|
|
2857
2981
|
return parsed.success ? parsed.data : void 0;
|
|
2858
2982
|
}
|
|
2859
2983
|
__name(parsePrincipalContext, "parsePrincipalContext");
|
|
2860
|
-
|
|
2984
|
+
__name3(parsePrincipalContext, "parsePrincipalContext");
|
|
2861
2985
|
function isDeviceCredentialPrincipal(context) {
|
|
2862
2986
|
return context?.credential.type === "deviceCredential";
|
|
2863
2987
|
}
|
|
2864
2988
|
__name(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
|
|
2865
|
-
|
|
2989
|
+
__name3(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
|
|
2866
2990
|
var DeviceCredentialClaimSchema = z2.object({
|
|
2867
2991
|
credential: z2.object({
|
|
2868
2992
|
type: z2.literal("deviceCredential")
|
|
@@ -2872,19 +2996,19 @@ function hasDeviceCredentialType(value3) {
|
|
|
2872
2996
|
return DeviceCredentialClaimSchema.safeParse(value3).success;
|
|
2873
2997
|
}
|
|
2874
2998
|
__name(hasDeviceCredentialType, "hasDeviceCredentialType");
|
|
2875
|
-
|
|
2999
|
+
__name3(hasDeviceCredentialType, "hasDeviceCredentialType");
|
|
2876
3000
|
function sessionAuthTime(context) {
|
|
2877
3001
|
if (!context || context.credential.type !== "firstPartySession") return void 0;
|
|
2878
3002
|
const authTime = context.authTime;
|
|
2879
3003
|
return typeof authTime === "number" && Number.isInteger(authTime) && authTime >= 0 && authTime <= SESSION_AUTH_TIME_MAX_S ? authTime : void 0;
|
|
2880
3004
|
}
|
|
2881
3005
|
__name(sessionAuthTime, "sessionAuthTime");
|
|
2882
|
-
|
|
3006
|
+
__name3(sessionAuthTime, "sessionAuthTime");
|
|
2883
3007
|
function isTypedApiKeyPrincipal(context) {
|
|
2884
3008
|
return context?.subject.subjectType === "apiKey" && context.credential.type === "apiKey" && !context.compatibility;
|
|
2885
3009
|
}
|
|
2886
3010
|
__name(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
|
|
2887
|
-
|
|
3011
|
+
__name3(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
|
|
2888
3012
|
function typedApiKeyPrincipalId(context) {
|
|
2889
3013
|
if (!context || !isTypedApiKeyPrincipal(context) || !context.subject.subjectId || context.credential.id !== context.subject.subjectId || context.actor?.actorType !== "apiKey" || context.actor.actorId !== context.subject.subjectId || context.owner?.type !== "user" || !context.owner.id) {
|
|
2890
3014
|
return void 0;
|
|
@@ -2892,7 +3016,7 @@ function typedApiKeyPrincipalId(context) {
|
|
|
2892
3016
|
return context.subject.subjectId;
|
|
2893
3017
|
}
|
|
2894
3018
|
__name(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
|
|
2895
|
-
|
|
3019
|
+
__name3(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
|
|
2896
3020
|
var LUA_CLIENT_APPS = [
|
|
2897
3021
|
"desktop",
|
|
2898
3022
|
"web",
|
|
@@ -2937,13 +3061,13 @@ function parseLuaClientHeader(value3) {
|
|
|
2937
3061
|
return void 0;
|
|
2938
3062
|
}
|
|
2939
3063
|
__name(parseLuaClientHeader, "parseLuaClientHeader");
|
|
2940
|
-
|
|
3064
|
+
__name3(parseLuaClientHeader, "parseLuaClientHeader");
|
|
2941
3065
|
function serializeLuaClientHeader(client) {
|
|
2942
3066
|
if (!client) return void 0;
|
|
2943
3067
|
return `${client.app}/${client.version === "unknown" ? "unversioned" : client.version}`;
|
|
2944
3068
|
}
|
|
2945
3069
|
__name(serializeLuaClientHeader, "serializeLuaClientHeader");
|
|
2946
|
-
|
|
3070
|
+
__name3(serializeLuaClientHeader, "serializeLuaClientHeader");
|
|
2947
3071
|
function formatLuaClientHeader(app, version) {
|
|
2948
3072
|
if (typeof version !== "string") return `${app}/unversioned`;
|
|
2949
3073
|
const normalized = version.trim();
|
|
@@ -2952,7 +3076,7 @@ function formatLuaClientHeader(app, version) {
|
|
|
2952
3076
|
return `${app}/unversioned`;
|
|
2953
3077
|
}
|
|
2954
3078
|
__name(formatLuaClientHeader, "formatLuaClientHeader");
|
|
2955
|
-
|
|
3079
|
+
__name3(formatLuaClientHeader, "formatLuaClientHeader");
|
|
2956
3080
|
function luaClientMetricLabels(client) {
|
|
2957
3081
|
const canonical2 = parseLuaClientHeader(serializeLuaClientHeader(client));
|
|
2958
3082
|
return {
|
|
@@ -2961,7 +3085,7 @@ function luaClientMetricLabels(client) {
|
|
|
2961
3085
|
};
|
|
2962
3086
|
}
|
|
2963
3087
|
__name(luaClientMetricLabels, "luaClientMetricLabels");
|
|
2964
|
-
|
|
3088
|
+
__name3(luaClientMetricLabels, "luaClientMetricLabels");
|
|
2965
3089
|
var AUTHZ_PROJECTION_VERSION = 1;
|
|
2966
3090
|
var ProjectedScopeSchema = z3.string().min(1).max(128);
|
|
2967
3091
|
var DisplayRoleSchema = z3.object({
|
|
@@ -3110,29 +3234,29 @@ function parseEffectiveAuthorization(value3) {
|
|
|
3110
3234
|
return parsed.success ? parsed.data : void 0;
|
|
3111
3235
|
}
|
|
3112
3236
|
__name(parseEffectiveAuthorization, "parseEffectiveAuthorization");
|
|
3113
|
-
|
|
3237
|
+
__name3(parseEffectiveAuthorization, "parseEffectiveAuthorization");
|
|
3114
3238
|
function parseResourcePage(value3) {
|
|
3115
3239
|
const parsed = ResourcePageSchema.safeParse(value3);
|
|
3116
3240
|
return parsed.success ? parsed.data : void 0;
|
|
3117
3241
|
}
|
|
3118
3242
|
__name(parseResourcePage, "parseResourcePage");
|
|
3119
|
-
|
|
3243
|
+
__name3(parseResourcePage, "parseResourcePage");
|
|
3120
3244
|
function capabilitiesFor(profiles, profileId) {
|
|
3121
3245
|
if (!profileId) return [];
|
|
3122
3246
|
return profiles[profileId] ?? [];
|
|
3123
3247
|
}
|
|
3124
3248
|
__name(capabilitiesFor, "capabilitiesFor");
|
|
3125
|
-
|
|
3249
|
+
__name3(capabilitiesFor, "capabilitiesFor");
|
|
3126
3250
|
function isKnownProfile(profiles, profileId) {
|
|
3127
3251
|
return profileId !== void 0 && Object.prototype.hasOwnProperty.call(profiles, profileId);
|
|
3128
3252
|
}
|
|
3129
3253
|
__name(isKnownProfile, "isKnownProfile");
|
|
3130
|
-
|
|
3254
|
+
__name3(isKnownProfile, "isKnownProfile");
|
|
3131
3255
|
function hasCapability(profiles, profileId, required) {
|
|
3132
3256
|
return capabilitiesFor(profiles, profileId).includes(required);
|
|
3133
3257
|
}
|
|
3134
3258
|
__name(hasCapability, "hasCapability");
|
|
3135
|
-
|
|
3259
|
+
__name3(hasCapability, "hasCapability");
|
|
3136
3260
|
function workflowJobId(id2) {
|
|
3137
3261
|
switch (id2.kind) {
|
|
3138
3262
|
case "start":
|
|
@@ -3188,48 +3312,48 @@ function workflowJobId(id2) {
|
|
|
3188
3312
|
}
|
|
3189
3313
|
}
|
|
3190
3314
|
__name(workflowJobId, "workflowJobId");
|
|
3191
|
-
|
|
3315
|
+
__name3(workflowJobId, "workflowJobId");
|
|
3192
3316
|
function assertNever(id2) {
|
|
3193
3317
|
throw new Error(`workflowJobId: unknown wake kind ${JSON.stringify(id2)}`);
|
|
3194
3318
|
}
|
|
3195
3319
|
__name(assertNever, "assertNever");
|
|
3196
|
-
|
|
3320
|
+
__name3(assertNever, "assertNever");
|
|
3197
3321
|
function agentStepJobId(msg) {
|
|
3198
3322
|
return `${msg.runId}_${msg.stepId}_${msg.attempt}_x${msg.executionId}`;
|
|
3199
3323
|
}
|
|
3200
3324
|
__name(agentStepJobId, "agentStepJobId");
|
|
3201
|
-
|
|
3325
|
+
__name3(agentStepJobId, "agentStepJobId");
|
|
3202
3326
|
function heavyStepJobId(msg) {
|
|
3203
3327
|
return `${msg.runId}_${msg.stepId}_${msg.attempt}_x${msg.executionId}`;
|
|
3204
3328
|
}
|
|
3205
3329
|
__name(heavyStepJobId, "heavyStepJobId");
|
|
3206
|
-
|
|
3330
|
+
__name3(heavyStepJobId, "heavyStepJobId");
|
|
3207
3331
|
function jobSpawnJobId(msg) {
|
|
3208
3332
|
return `${msg.runId}_${msg.stepId}_${msg.attempt}_s${msg.segment}_${msg.executionId}`;
|
|
3209
3333
|
}
|
|
3210
3334
|
__name(jobSpawnJobId, "jobSpawnJobId");
|
|
3211
|
-
|
|
3335
|
+
__name3(jobSpawnJobId, "jobSpawnJobId");
|
|
3212
3336
|
function exportAutoJobId(exportId, suffix) {
|
|
3213
3337
|
return suffix ? `${exportId}:${suffix}` : exportId;
|
|
3214
3338
|
}
|
|
3215
3339
|
__name(exportAutoJobId, "exportAutoJobId");
|
|
3216
|
-
|
|
3340
|
+
__name3(exportAutoJobId, "exportAutoJobId");
|
|
3217
3341
|
var SYSTEM_USER_PREFIX = "system:";
|
|
3218
3342
|
function isSystemRun(identity) {
|
|
3219
3343
|
return identity.userId.startsWith(SYSTEM_USER_PREFIX);
|
|
3220
3344
|
}
|
|
3221
3345
|
__name(isSystemRun, "isSystemRun");
|
|
3222
|
-
|
|
3346
|
+
__name3(isSystemRun, "isSystemRun");
|
|
3223
3347
|
function creatorUserId(identity) {
|
|
3224
3348
|
return isSystemRun(identity) ? void 0 : identity.userId;
|
|
3225
3349
|
}
|
|
3226
3350
|
__name(creatorUserId, "creatorUserId");
|
|
3227
|
-
|
|
3351
|
+
__name3(creatorUserId, "creatorUserId");
|
|
3228
3352
|
function actingUserId(identity) {
|
|
3229
3353
|
return creatorUserId(identity);
|
|
3230
3354
|
}
|
|
3231
3355
|
__name(actingUserId, "actingUserId");
|
|
3232
|
-
|
|
3356
|
+
__name3(actingUserId, "actingUserId");
|
|
3233
3357
|
var WORKFLOW_RUN_IN_FLIGHT = [
|
|
3234
3358
|
"queued",
|
|
3235
3359
|
"running",
|
|
@@ -3292,27 +3416,27 @@ function isWorkflowSignalEventSite(value3) {
|
|
|
3292
3416
|
return typeof value3 === "string" && WORKFLOW_SIGNAL_EVENT_SITES.includes(value3);
|
|
3293
3417
|
}
|
|
3294
3418
|
__name(isWorkflowSignalEventSite, "isWorkflowSignalEventSite");
|
|
3295
|
-
|
|
3419
|
+
__name3(isWorkflowSignalEventSite, "isWorkflowSignalEventSite");
|
|
3296
3420
|
var ARCHIVE_WINDOW_MARGIN_DAYS = 7;
|
|
3297
3421
|
function shouldSkipArchive(run, manifestSha256, sinkSha256) {
|
|
3298
3422
|
if (!run.completedAt || !run.exportedAt || run.exportedAt < run.completedAt) return false;
|
|
3299
3423
|
return !!manifestSha256 && manifestSha256 === sinkSha256;
|
|
3300
3424
|
}
|
|
3301
3425
|
__name(shouldSkipArchive, "shouldSkipArchive");
|
|
3302
|
-
|
|
3426
|
+
__name3(shouldSkipArchive, "shouldSkipArchive");
|
|
3303
3427
|
function isArchiveWindowTooOld(run, retentionDays, now = Date.now(), marginDays = ARCHIVE_WINDOW_MARGIN_DAYS) {
|
|
3304
3428
|
if (!run.completedAt) return false;
|
|
3305
3429
|
const cutoff = now - Math.max(retentionDays - marginDays, 0) * 864e5;
|
|
3306
3430
|
return run.completedAt < cutoff;
|
|
3307
3431
|
}
|
|
3308
3432
|
__name(isArchiveWindowTooOld, "isArchiveWindowTooOld");
|
|
3309
|
-
|
|
3433
|
+
__name3(isArchiveWindowTooOld, "isArchiveWindowTooOld");
|
|
3310
3434
|
var WORKFLOW_ORG_PURGING_TTL_S = 7 * 86400;
|
|
3311
3435
|
function workflowOrgPurgingKey(orgId) {
|
|
3312
3436
|
return `wf:org:${orgId}:purging`;
|
|
3313
3437
|
}
|
|
3314
3438
|
__name(workflowOrgPurgingKey, "workflowOrgPurgingKey");
|
|
3315
|
-
|
|
3439
|
+
__name3(workflowOrgPurgingKey, "workflowOrgPurgingKey");
|
|
3316
3440
|
var WORKFLOW_ORG_PURGE_FORCE_AFTER_MS = 10 * 6e4;
|
|
3317
3441
|
var IDEMPOTENCY_HOLDING_STATUSES = [
|
|
3318
3442
|
...WORKFLOW_RUN_IN_FLIGHT,
|
|
@@ -3325,22 +3449,22 @@ function isCloudTaskRunId(id2) {
|
|
|
3325
3449
|
return id2.startsWith(CLOUD_TASK_RUN_ID_PREFIX);
|
|
3326
3450
|
}
|
|
3327
3451
|
__name(isCloudTaskRunId, "isCloudTaskRunId");
|
|
3328
|
-
|
|
3452
|
+
__name3(isCloudTaskRunId, "isCloudTaskRunId");
|
|
3329
3453
|
function isScheduledWorkflowRunId(id2) {
|
|
3330
3454
|
return id2.startsWith(WORKFLOW_SCHEDULED_RUN_ID_PREFIX);
|
|
3331
3455
|
}
|
|
3332
3456
|
__name(isScheduledWorkflowRunId, "isScheduledWorkflowRunId");
|
|
3333
|
-
|
|
3457
|
+
__name3(isScheduledWorkflowRunId, "isScheduledWorkflowRunId");
|
|
3334
3458
|
function scheduledWorkflowRunId(jobId, scheduledTime) {
|
|
3335
3459
|
const key = typeof scheduledTime === "number" ? String(scheduledTime) : scheduledTimeKey(scheduledTime);
|
|
3336
3460
|
return `${WORKFLOW_SCHEDULED_RUN_ID_PREFIX}${jobId}_${key}`;
|
|
3337
3461
|
}
|
|
3338
3462
|
__name(scheduledWorkflowRunId, "scheduledWorkflowRunId");
|
|
3339
|
-
|
|
3463
|
+
__name3(scheduledWorkflowRunId, "scheduledWorkflowRunId");
|
|
3340
3464
|
var WORKFLOW_SCHEDULE_KEY_MAX = 128;
|
|
3341
3465
|
function renderWorkflowScheduleKeyTemplate(template3, ctx) {
|
|
3342
3466
|
if (!template3) return void 0;
|
|
3343
|
-
const read = /* @__PURE__ */
|
|
3467
|
+
const read = /* @__PURE__ */ __name3((path) => path.split(".").reduce((o, k) => o && typeof o === "object" ? o[k] : void 0, ctx.input), "read");
|
|
3344
3468
|
let unresolved = false;
|
|
3345
3469
|
const out = template3.replace(/\$\{\s*([a-zA-Z0-9_.]+)\s*\}/g, (_m, expr) => {
|
|
3346
3470
|
let v = "";
|
|
@@ -3355,7 +3479,7 @@ function renderWorkflowScheduleKeyTemplate(template3, ctx) {
|
|
|
3355
3479
|
return key && /^[A-Za-z0-9:_\-.\/]+$/.test(key) ? key : void 0;
|
|
3356
3480
|
}
|
|
3357
3481
|
__name(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
|
|
3358
|
-
|
|
3482
|
+
__name3(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
|
|
3359
3483
|
var WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX = "sched:";
|
|
3360
3484
|
function scheduledWorkflowIdempotencyKey(jobId, rendered) {
|
|
3361
3485
|
const head = `${WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX}${jobId}:`;
|
|
@@ -3365,7 +3489,7 @@ function scheduledWorkflowIdempotencyKey(jobId, rendered) {
|
|
|
3365
3489
|
return `${head}${rendered.slice(0, Math.max(0, room))}~${digest}`;
|
|
3366
3490
|
}
|
|
3367
3491
|
__name(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
|
|
3368
|
-
|
|
3492
|
+
__name3(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
|
|
3369
3493
|
function stableKeyDigest(s) {
|
|
3370
3494
|
let a = 2166136261;
|
|
3371
3495
|
let b = 84696351;
|
|
@@ -3377,23 +3501,23 @@ function stableKeyDigest(s) {
|
|
|
3377
3501
|
return (a >>> 0).toString(16).padStart(8, "0") + (b >>> 0).toString(16).padStart(8, "0");
|
|
3378
3502
|
}
|
|
3379
3503
|
__name(stableKeyDigest, "stableKeyDigest");
|
|
3380
|
-
|
|
3504
|
+
__name3(stableKeyDigest, "stableKeyDigest");
|
|
3381
3505
|
var WORKFLOW_OPERATION_ID_PREFIX = "wf:";
|
|
3382
3506
|
function workflowOperationId(runId, stepId, billingEpoch) {
|
|
3383
3507
|
return `${WORKFLOW_OPERATION_ID_PREFIX}${runId}:${stepId}:${billingEpoch}`;
|
|
3384
3508
|
}
|
|
3385
3509
|
__name(workflowOperationId, "workflowOperationId");
|
|
3386
|
-
|
|
3510
|
+
__name3(workflowOperationId, "workflowOperationId");
|
|
3387
3511
|
function workflowOccurrenceId(lineageId, stepId) {
|
|
3388
3512
|
return `${lineageId}:${stepId}`;
|
|
3389
3513
|
}
|
|
3390
3514
|
__name(workflowOccurrenceId, "workflowOccurrenceId");
|
|
3391
|
-
|
|
3515
|
+
__name3(workflowOccurrenceId, "workflowOccurrenceId");
|
|
3392
3516
|
function workflowOrgSlotKey(orgId, kind) {
|
|
3393
3517
|
return `wf:org:${orgId}:${kind}`;
|
|
3394
3518
|
}
|
|
3395
3519
|
__name(workflowOrgSlotKey, "workflowOrgSlotKey");
|
|
3396
|
-
|
|
3520
|
+
__name3(workflowOrgSlotKey, "workflowOrgSlotKey");
|
|
3397
3521
|
var WORKFLOW_CONNECTION_KEY_RE = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
3398
3522
|
var WORKFLOW_JOB_MODEL_SOURCE_LABELS = {
|
|
3399
3523
|
stamp: "lease stamp",
|
|
@@ -3407,17 +3531,17 @@ function workflowJobModelSourceLabel(source) {
|
|
|
3407
3531
|
return WORKFLOW_JOB_MODEL_SOURCE_LABELS[source];
|
|
3408
3532
|
}
|
|
3409
3533
|
__name(workflowJobModelSourceLabel, "workflowJobModelSourceLabel");
|
|
3410
|
-
|
|
3534
|
+
__name3(workflowJobModelSourceLabel, "workflowJobModelSourceLabel");
|
|
3411
3535
|
function scheduledTimeKey(scheduledTime) {
|
|
3412
3536
|
return scheduledTime.replace(/[^0-9TZ]/g, "");
|
|
3413
3537
|
}
|
|
3414
3538
|
__name(scheduledTimeKey, "scheduledTimeKey");
|
|
3415
|
-
|
|
3539
|
+
__name3(scheduledTimeKey, "scheduledTimeKey");
|
|
3416
3540
|
function scheduledWorkflowRunIdForTime(jobId, scheduledTime) {
|
|
3417
3541
|
return scheduledWorkflowRunId(jobId, scheduledTime);
|
|
3418
3542
|
}
|
|
3419
3543
|
__name(scheduledWorkflowRunIdForTime, "scheduledWorkflowRunIdForTime");
|
|
3420
|
-
|
|
3544
|
+
__name3(scheduledWorkflowRunIdForTime, "scheduledWorkflowRunIdForTime");
|
|
3421
3545
|
var WORKFLOW_SUSPEND_KINDS = [
|
|
3422
3546
|
"input",
|
|
3423
3547
|
"approval",
|
|
@@ -3430,18 +3554,227 @@ var WORKFLOW_RUN_NOTIFICATION_SUSPENDED_KINDS = [
|
|
|
3430
3554
|
];
|
|
3431
3555
|
var WORKFLOW_SIGNAL_PAYLOAD_MAX_BYTES = 64 * 1024;
|
|
3432
3556
|
var WORKFLOW_RESOLVE_OUTPUT_MAX_BYTES = 256 * 1024;
|
|
3557
|
+
var SCHEDULE_HEALTH_NOTIFY_CHANNELS = [
|
|
3558
|
+
"app",
|
|
3559
|
+
"email",
|
|
3560
|
+
"emailApp"
|
|
3561
|
+
];
|
|
3562
|
+
var SCHEDULE_HEALTH_DEFAULT_NOTIFY = "emailApp";
|
|
3563
|
+
var SCHEDULE_HEALTH_LIMITS = {
|
|
3564
|
+
maxSilenceMinutes: {
|
|
3565
|
+
min: 5,
|
|
3566
|
+
max: 43200
|
|
3567
|
+
},
|
|
3568
|
+
alertAfterConsecutiveFailures: {
|
|
3569
|
+
min: 1,
|
|
3570
|
+
max: 50
|
|
3571
|
+
},
|
|
3572
|
+
/** The platform's auto-disable trip (PRO-726 / 07 §7.1.6): a streak can never pass it on these kinds. */
|
|
3573
|
+
parkedKindsMaxFailures: 3
|
|
3574
|
+
};
|
|
3575
|
+
var KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
3576
|
+
"maxSilenceMinutes",
|
|
3577
|
+
"alertAfterConsecutiveFailures",
|
|
3578
|
+
"notify"
|
|
3579
|
+
]);
|
|
3580
|
+
function isInt(v) {
|
|
3581
|
+
return typeof v === "number" && Number.isInteger(v);
|
|
3582
|
+
}
|
|
3583
|
+
__name(isInt, "isInt");
|
|
3584
|
+
__name3(isInt, "isInt");
|
|
3585
|
+
function validateScheduleHealth(health, opts) {
|
|
3586
|
+
const base = opts.path ?? "health";
|
|
3587
|
+
const issues = [];
|
|
3588
|
+
if (health === null || typeof health !== "object" || Array.isArray(health)) {
|
|
3589
|
+
return [
|
|
3590
|
+
{
|
|
3591
|
+
code: "health-not-object",
|
|
3592
|
+
path: base,
|
|
3593
|
+
message: `${base} must be an object`
|
|
3594
|
+
}
|
|
3595
|
+
];
|
|
3596
|
+
}
|
|
3597
|
+
const h = health;
|
|
3598
|
+
for (const key of Object.keys(h)) {
|
|
3599
|
+
if (!KNOWN_KEYS.has(key)) {
|
|
3600
|
+
issues.push({
|
|
3601
|
+
code: "health-unknown-field",
|
|
3602
|
+
path: `${base}.${key}`,
|
|
3603
|
+
message: `${base}.${key} is not a health field (maxSilenceMinutes, alertAfterConsecutiveFailures, notify)`
|
|
3604
|
+
});
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
const silence = h.maxSilenceMinutes;
|
|
3608
|
+
const failures = h.alertAfterConsecutiveFailures;
|
|
3609
|
+
if (silence === void 0 && failures === void 0) {
|
|
3610
|
+
issues.push({
|
|
3611
|
+
code: "health-empty",
|
|
3612
|
+
path: base,
|
|
3613
|
+
message: `${base} needs maxSilenceMinutes and/or alertAfterConsecutiveFailures`
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3616
|
+
const { min: sMin, max: sMax } = SCHEDULE_HEALTH_LIMITS.maxSilenceMinutes;
|
|
3617
|
+
if (silence !== void 0 && (!isInt(silence) || silence < sMin || silence > sMax)) {
|
|
3618
|
+
issues.push({
|
|
3619
|
+
code: "health-silence-invalid",
|
|
3620
|
+
path: `${base}.maxSilenceMinutes`,
|
|
3621
|
+
message: `${base}.maxSilenceMinutes must be an integer in ${sMin}..${sMax}`
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
const fMin = SCHEDULE_HEALTH_LIMITS.alertAfterConsecutiveFailures.min;
|
|
3625
|
+
const fMax = opts.target === "workflow" ? SCHEDULE_HEALTH_LIMITS.parkedKindsMaxFailures : SCHEDULE_HEALTH_LIMITS.alertAfterConsecutiveFailures.max;
|
|
3626
|
+
if (failures !== void 0) {
|
|
3627
|
+
if (!isInt(failures) || failures < fMin) {
|
|
3628
|
+
issues.push({
|
|
3629
|
+
code: "health-failures-invalid",
|
|
3630
|
+
path: `${base}.alertAfterConsecutiveFailures`,
|
|
3631
|
+
message: `${base}.alertAfterConsecutiveFailures must be an integer in ${fMin}..${fMax}`
|
|
3632
|
+
});
|
|
3633
|
+
} else if (failures > fMax) {
|
|
3634
|
+
issues.push({
|
|
3635
|
+
code: opts.target === "workflow" ? "health-failures-unreachable" : "health-failures-invalid",
|
|
3636
|
+
path: `${base}.alertAfterConsecutiveFailures`,
|
|
3637
|
+
message: opts.target === "workflow" ? `${base}.alertAfterConsecutiveFailures must be \u2264 ${fMax}: a workflow schedule is turned off after ${fMax} consecutive failures, so a longer streak can never happen (the turn-off itself always alerts)` : `${base}.alertAfterConsecutiveFailures must be an integer in ${fMin}..${fMax}`
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
if (h.notify !== void 0 && !SCHEDULE_HEALTH_NOTIFY_CHANNELS.includes(h.notify)) {
|
|
3642
|
+
issues.push({
|
|
3643
|
+
code: "health-notify-invalid",
|
|
3644
|
+
path: `${base}.notify`,
|
|
3645
|
+
message: `${base}.notify must be one of ${SCHEDULE_HEALTH_NOTIFY_CHANNELS.join(", ")}`
|
|
3646
|
+
});
|
|
3647
|
+
}
|
|
3648
|
+
const triggers = (opts.triggers ?? []).filter((t) => !!t && typeof t === "object");
|
|
3649
|
+
if (opts.triggers !== void 0 && triggers.length === 0) {
|
|
3650
|
+
issues.push({
|
|
3651
|
+
code: "health-requires-schedule",
|
|
3652
|
+
path: base,
|
|
3653
|
+
message: `${base} needs a schedule to watch`
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
if (isInt(silence) && triggers.length > 0) {
|
|
3657
|
+
if (triggers.every((t) => t.type === "once")) {
|
|
3658
|
+
issues.push({
|
|
3659
|
+
code: "health-silence-on-once",
|
|
3660
|
+
path: `${base}.maxSilenceMinutes`,
|
|
3661
|
+
message: `${base}.maxSilenceMinutes needs a recurring schedule; a one-time schedule has no cadence to fall silent against`
|
|
3662
|
+
});
|
|
3663
|
+
} else {
|
|
3664
|
+
const intervals = triggers.filter((t) => t.type === "interval" && isInt(t.seconds)).map((t) => t.seconds);
|
|
3665
|
+
const onlyIntervals = intervals.length === triggers.filter((t) => t.type !== "once").length;
|
|
3666
|
+
if (onlyIntervals && intervals.length > 0) {
|
|
3667
|
+
const fastest = Math.min(...intervals);
|
|
3668
|
+
if (silence * 60 <= fastest) {
|
|
3669
|
+
issues.push({
|
|
3670
|
+
code: "health-silence-shorter-than-interval",
|
|
3671
|
+
path: `${base}.maxSilenceMinutes`,
|
|
3672
|
+
message: `${base}.maxSilenceMinutes (${silence} min) must be longer than the schedule's interval (${fastest}s), or every healthy gap alerts`
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
return issues;
|
|
3679
|
+
}
|
|
3680
|
+
__name(validateScheduleHealth, "validateScheduleHealth");
|
|
3681
|
+
__name3(validateScheduleHealth, "validateScheduleHealth");
|
|
3682
|
+
function normalizeScheduleHealth(health) {
|
|
3683
|
+
return {
|
|
3684
|
+
...health.maxSilenceMinutes !== void 0 ? {
|
|
3685
|
+
maxSilenceMinutes: health.maxSilenceMinutes
|
|
3686
|
+
} : {},
|
|
3687
|
+
...health.alertAfterConsecutiveFailures !== void 0 ? {
|
|
3688
|
+
alertAfterConsecutiveFailures: health.alertAfterConsecutiveFailures
|
|
3689
|
+
} : {},
|
|
3690
|
+
notify: health.notify ?? SCHEDULE_HEALTH_DEFAULT_NOTIFY
|
|
3691
|
+
};
|
|
3692
|
+
}
|
|
3693
|
+
__name(normalizeScheduleHealth, "normalizeScheduleHealth");
|
|
3694
|
+
__name3(normalizeScheduleHealth, "normalizeScheduleHealth");
|
|
3695
|
+
function evaluateScheduleHealth(subject, now) {
|
|
3696
|
+
const parked = subject.status === "failed";
|
|
3697
|
+
if (parked) return {
|
|
3698
|
+
watched: true,
|
|
3699
|
+
condition: "auto_disabled"
|
|
3700
|
+
};
|
|
3701
|
+
if (subject.active === false || subject.status !== "active") return {
|
|
3702
|
+
watched: false,
|
|
3703
|
+
condition: null
|
|
3704
|
+
};
|
|
3705
|
+
const threshold = subject.health.alertAfterConsecutiveFailures;
|
|
3706
|
+
if (threshold !== void 0 && subject.consecutiveFailures >= threshold) {
|
|
3707
|
+
return {
|
|
3708
|
+
watched: true,
|
|
3709
|
+
condition: "failures"
|
|
3710
|
+
};
|
|
3711
|
+
}
|
|
3712
|
+
const window = subject.health.maxSilenceMinutes;
|
|
3713
|
+
if (window !== void 0) {
|
|
3714
|
+
const baseline = Math.max(subject.lastSucceededAt ?? 0, subject.state?.watchFrom ?? now);
|
|
3715
|
+
const silentMs = now - baseline;
|
|
3716
|
+
if (silentMs > window * 6e4) {
|
|
3717
|
+
return {
|
|
3718
|
+
watched: true,
|
|
3719
|
+
condition: "silence",
|
|
3720
|
+
silentForMinutes: Math.floor(silentMs / 6e4)
|
|
3721
|
+
};
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
return {
|
|
3725
|
+
watched: true,
|
|
3726
|
+
condition: null
|
|
3727
|
+
};
|
|
3728
|
+
}
|
|
3729
|
+
__name(evaluateScheduleHealth, "evaluateScheduleHealth");
|
|
3730
|
+
__name3(evaluateScheduleHealth, "evaluateScheduleHealth");
|
|
3731
|
+
function scheduleHealthView(health, state3) {
|
|
3732
|
+
if (!health) return void 0;
|
|
3733
|
+
const incident = state3?.incident;
|
|
3734
|
+
return {
|
|
3735
|
+
config: {
|
|
3736
|
+
...health.maxSilenceMinutes !== void 0 ? {
|
|
3737
|
+
maxSilenceMinutes: health.maxSilenceMinutes
|
|
3738
|
+
} : {},
|
|
3739
|
+
...health.alertAfterConsecutiveFailures !== void 0 ? {
|
|
3740
|
+
alertAfterConsecutiveFailures: health.alertAfterConsecutiveFailures
|
|
3741
|
+
} : {},
|
|
3742
|
+
...health.notify ? {
|
|
3743
|
+
notify: health.notify
|
|
3744
|
+
} : {}
|
|
3745
|
+
},
|
|
3746
|
+
state: incident ? "alerting" : state3?.watchFrom !== void 0 ? "ok" : "unwatched",
|
|
3747
|
+
...incident ? {
|
|
3748
|
+
condition: incident.condition,
|
|
3749
|
+
since: incident.openedAt
|
|
3750
|
+
} : {},
|
|
3751
|
+
...state3?.lastSucceededAt !== void 0 ? {
|
|
3752
|
+
lastSucceededAt: state3.lastSucceededAt
|
|
3753
|
+
} : {},
|
|
3754
|
+
...state3?.checkedAt !== void 0 ? {
|
|
3755
|
+
checkedAt: state3.checkedAt
|
|
3756
|
+
} : {}
|
|
3757
|
+
};
|
|
3758
|
+
}
|
|
3759
|
+
__name(scheduleHealthView, "scheduleHealthView");
|
|
3760
|
+
__name3(scheduleHealthView, "scheduleHealthView");
|
|
3761
|
+
function scheduleHealthSourceId(agentId, jobId) {
|
|
3762
|
+
return `schedule-health:${agentId}:${jobId}`;
|
|
3763
|
+
}
|
|
3764
|
+
__name(scheduleHealthSourceId, "scheduleHealthSourceId");
|
|
3765
|
+
__name3(scheduleHealthSourceId, "scheduleHealthSourceId");
|
|
3433
3766
|
var WORKFLOW_GOAL_JUDGE_SELF = "$self";
|
|
3434
3767
|
function workflowGoalJudgeKind(judge) {
|
|
3435
3768
|
return judge && typeof judge === "object" && judge.predicate !== void 0 ? "predicate" : "agent";
|
|
3436
3769
|
}
|
|
3437
3770
|
__name(workflowGoalJudgeKind, "workflowGoalJudgeKind");
|
|
3438
|
-
|
|
3771
|
+
__name3(workflowGoalJudgeKind, "workflowGoalJudgeKind");
|
|
3439
3772
|
function isWorkflowGoalJudgeComplete(judge) {
|
|
3440
3773
|
if (workflowGoalJudgeKind(judge) === "predicate") return true;
|
|
3441
3774
|
return typeof judge.agentId === "string" && judge.agentId.length > 0 && !!judge.schema && typeof judge.schema === "object" && !Array.isArray(judge.schema);
|
|
3442
3775
|
}
|
|
3443
3776
|
__name(isWorkflowGoalJudgeComplete, "isWorkflowGoalJudgeComplete");
|
|
3444
|
-
|
|
3777
|
+
__name3(isWorkflowGoalJudgeComplete, "isWorkflowGoalJudgeComplete");
|
|
3445
3778
|
function normalizeWorkflowGoalJudge(judge) {
|
|
3446
3779
|
if (workflowGoalJudgeKind(judge) === "agent") return judge;
|
|
3447
3780
|
return {
|
|
@@ -3453,7 +3786,7 @@ function normalizeWorkflowGoalJudge(judge) {
|
|
|
3453
3786
|
};
|
|
3454
3787
|
}
|
|
3455
3788
|
__name(normalizeWorkflowGoalJudge, "normalizeWorkflowGoalJudge");
|
|
3456
|
-
|
|
3789
|
+
__name3(normalizeWorkflowGoalJudge, "normalizeWorkflowGoalJudge");
|
|
3457
3790
|
var REDACTED_PLACEHOLDER = "[REDACTED]";
|
|
3458
3791
|
var PROVIDER_MESSAGE_MAX_CHARS = 300;
|
|
3459
3792
|
var ERROR_MESSAGE_MAX_CHARS = 2e3;
|
|
@@ -3541,7 +3874,7 @@ function groupCount(re) {
|
|
|
3541
3874
|
return n2;
|
|
3542
3875
|
}
|
|
3543
3876
|
__name(groupCount, "groupCount");
|
|
3544
|
-
|
|
3877
|
+
__name3(groupCount, "groupCount");
|
|
3545
3878
|
var WORKFLOW_SECRET_KEY_RE = /(^|[_\-.\s])(secret|token|password|passwd|pwd|passphrase|api[_-]?key|apikey|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|authorization|auth[_-]?token|access[_-]?token|id[_-]?token|refresh[_-]?token|session[_-]?key|credential(s)?)([_\-.\s]|$)|^(secret|token|password|passwd|pwd|passphrase|apikey|authorization|credentials?)$/i;
|
|
3546
3879
|
var WORKFLOW_RESERVED_SECRET_KEYS = Object.freeze([
|
|
3547
3880
|
"secret",
|
|
@@ -3569,7 +3902,7 @@ function isWorkflowSecretKey(key) {
|
|
|
3569
3902
|
return WORKFLOW_SECRET_KEY_RE.test(key);
|
|
3570
3903
|
}
|
|
3571
3904
|
__name(isWorkflowSecretKey, "isWorkflowSecretKey");
|
|
3572
|
-
|
|
3905
|
+
__name3(isWorkflowSecretKey, "isWorkflowSecretKey");
|
|
3573
3906
|
function applyPatterns(text, patterns) {
|
|
3574
3907
|
let out = text;
|
|
3575
3908
|
for (const { re, suffix } of patterns) {
|
|
@@ -3589,13 +3922,13 @@ function applyPatterns(text, patterns) {
|
|
|
3589
3922
|
return out;
|
|
3590
3923
|
}
|
|
3591
3924
|
__name(applyPatterns, "applyPatterns");
|
|
3592
|
-
|
|
3925
|
+
__name3(applyPatterns, "applyPatterns");
|
|
3593
3926
|
function scrubSecretText(text) {
|
|
3594
3927
|
if (typeof text !== "string" || text.length < 4) return text;
|
|
3595
3928
|
return applyPatterns(applyPatterns(text, SECRET_LITERAL_PATTERNS), SECRET_PAIR_PATTERNS);
|
|
3596
3929
|
}
|
|
3597
3930
|
__name(scrubSecretText, "scrubSecretText");
|
|
3598
|
-
|
|
3931
|
+
__name3(scrubSecretText, "scrubSecretText");
|
|
3599
3932
|
var SCRUB_INPUT_MAX_CHARS = 16 * 1024;
|
|
3600
3933
|
var SCRUB_CUT_BACKOFF_CHARS = 256;
|
|
3601
3934
|
function boundScrubInput(text, max = SCRUB_INPUT_MAX_CHARS) {
|
|
@@ -3606,12 +3939,12 @@ function boundScrubInput(text, max = SCRUB_INPUT_MAX_CHARS) {
|
|
|
3606
3939
|
return `${text.slice(0, cut)}\u2026`;
|
|
3607
3940
|
}
|
|
3608
3941
|
__name(boundScrubInput, "boundScrubInput");
|
|
3609
|
-
|
|
3942
|
+
__name3(boundScrubInput, "boundScrubInput");
|
|
3610
3943
|
function scrubSecretLines(lines) {
|
|
3611
3944
|
return lines.map((l) => typeof l === "string" ? scrubSecretText(boundScrubInput(l)) : l);
|
|
3612
3945
|
}
|
|
3613
3946
|
__name(scrubSecretLines, "scrubSecretLines");
|
|
3614
|
-
|
|
3947
|
+
__name3(scrubSecretLines, "scrubSecretLines");
|
|
3615
3948
|
function messageText(value3) {
|
|
3616
3949
|
if (typeof value3 === "string") return value3;
|
|
3617
3950
|
if (value3 instanceof Error) return value3.message;
|
|
@@ -3627,7 +3960,7 @@ function messageText(value3) {
|
|
|
3627
3960
|
return value3 === void 0 || value3 === null ? "" : String(value3);
|
|
3628
3961
|
}
|
|
3629
3962
|
__name(messageText, "messageText");
|
|
3630
|
-
|
|
3963
|
+
__name3(messageText, "messageText");
|
|
3631
3964
|
function scrubProviderMessage(raw, max = PROVIDER_MESSAGE_MAX_CHARS) {
|
|
3632
3965
|
const text = boundScrubInput(messageText(raw)).replace(/\s+/g, " ").trim();
|
|
3633
3966
|
if (!text) return void 0;
|
|
@@ -3635,12 +3968,12 @@ function scrubProviderMessage(raw, max = PROVIDER_MESSAGE_MAX_CHARS) {
|
|
|
3635
3968
|
return out.length > max ? `${out.slice(0, max - 1)}\u2026` : out;
|
|
3636
3969
|
}
|
|
3637
3970
|
__name(scrubProviderMessage, "scrubProviderMessage");
|
|
3638
|
-
|
|
3971
|
+
__name3(scrubProviderMessage, "scrubProviderMessage");
|
|
3639
3972
|
function scrubStepErrorMessage(raw) {
|
|
3640
3973
|
return scrubProviderMessage(raw, ERROR_MESSAGE_MAX_CHARS);
|
|
3641
3974
|
}
|
|
3642
3975
|
__name(scrubStepErrorMessage, "scrubStepErrorMessage");
|
|
3643
|
-
|
|
3976
|
+
__name3(scrubStepErrorMessage, "scrubStepErrorMessage");
|
|
3644
3977
|
var WORKFLOW_AUDIT_EVENTS = [
|
|
3645
3978
|
// --- definitions / versions / templates (13, 11 §11.11.5) ---
|
|
3646
3979
|
"workflow.published",
|
|
@@ -3753,7 +4086,7 @@ function isWorkflowAuditEvent(action) {
|
|
|
3753
4086
|
return typeof action === "string" && WORKFLOW_AUDIT_EVENTS.includes(action);
|
|
3754
4087
|
}
|
|
3755
4088
|
__name(isWorkflowAuditEvent, "isWorkflowAuditEvent");
|
|
3756
|
-
|
|
4089
|
+
__name3(isWorkflowAuditEvent, "isWorkflowAuditEvent");
|
|
3757
4090
|
function emptyRetentionCounts() {
|
|
3758
4091
|
return {
|
|
3759
4092
|
runs: 0,
|
|
@@ -3766,7 +4099,7 @@ function emptyRetentionCounts() {
|
|
|
3766
4099
|
};
|
|
3767
4100
|
}
|
|
3768
4101
|
__name(emptyRetentionCounts, "emptyRetentionCounts");
|
|
3769
|
-
|
|
4102
|
+
__name3(emptyRetentionCounts, "emptyRetentionCounts");
|
|
3770
4103
|
var INDENT = " ";
|
|
3771
4104
|
var WRAP_WIDTH = 78;
|
|
3772
4105
|
var NOUNS = {
|
|
@@ -3810,7 +4143,7 @@ function wrap(tokens, indent, width) {
|
|
|
3810
4143
|
return lines.join("\n");
|
|
3811
4144
|
}
|
|
3812
4145
|
__name(wrap, "wrap");
|
|
3813
|
-
|
|
4146
|
+
__name3(wrap, "wrap");
|
|
3814
4147
|
function passthroughPath(target) {
|
|
3815
4148
|
const { owner, repo, number } = target.address;
|
|
3816
4149
|
const base = `repos/${owner}/${repo}`;
|
|
@@ -3820,7 +4153,7 @@ function passthroughPath(target) {
|
|
|
3820
4153
|
return base;
|
|
3821
4154
|
}
|
|
3822
4155
|
__name(passthroughPath, "passthroughPath");
|
|
3823
|
-
|
|
4156
|
+
__name3(passthroughPath, "passthroughPath");
|
|
3824
4157
|
function headerLine(target, position) {
|
|
3825
4158
|
const { owner, repo, number, key, container } = target.address;
|
|
3826
4159
|
const slug = owner && repo ? `${owner}/${repo}` : void 0;
|
|
@@ -3840,7 +4173,7 @@ function headerLine(target, position) {
|
|
|
3840
4173
|
return `${position}. ${parts.join(" ")}`;
|
|
3841
4174
|
}
|
|
3842
4175
|
__name(headerLine, "headerLine");
|
|
3843
|
-
|
|
4176
|
+
__name3(headerLine, "headerLine");
|
|
3844
4177
|
function reachingIt(target) {
|
|
3845
4178
|
const { owner, repo, key } = target.address;
|
|
3846
4179
|
const toolName = GET_TOOL_NAMES[`${target.integrationType}:${target.kind}`];
|
|
@@ -3862,7 +4195,7 @@ function reachingIt(target) {
|
|
|
3862
4195
|
return wrap(tokens, INDENT, WRAP_WIDTH);
|
|
3863
4196
|
}
|
|
3864
4197
|
__name(reachingIt, "reachingIt");
|
|
3865
|
-
|
|
4198
|
+
__name3(reachingIt, "reachingIt");
|
|
3866
4199
|
function renderTargetsBlock(targets) {
|
|
3867
4200
|
if (!targets.length) return "";
|
|
3868
4201
|
const items = targets.map((target, i) => [
|
|
@@ -3880,7 +4213,7 @@ ${PREAMBLE}
|
|
|
3880
4213
|
${items.join("\n\n")}`;
|
|
3881
4214
|
}
|
|
3882
4215
|
__name(renderTargetsBlock, "renderTargetsBlock");
|
|
3883
|
-
|
|
4216
|
+
__name3(renderTargetsBlock, "renderTargetsBlock");
|
|
3884
4217
|
var WORKFLOW_APPROVAL_OUTPUT_DECISIONS = [
|
|
3885
4218
|
"approved",
|
|
3886
4219
|
"denied",
|
|
@@ -3950,7 +4283,7 @@ function workflowApprovalDecisionOf(resumeData) {
|
|
|
3950
4283
|
return resumeData.approved === true ? "approved" : "denied";
|
|
3951
4284
|
}
|
|
3952
4285
|
__name(workflowApprovalDecisionOf, "workflowApprovalDecisionOf");
|
|
3953
|
-
|
|
4286
|
+
__name3(workflowApprovalDecisionOf, "workflowApprovalDecisionOf");
|
|
3954
4287
|
function workflowApprovalOutput(resumeData) {
|
|
3955
4288
|
const decision = typeof resumeData.decision === "string" ? resumeData.decision : workflowApprovalDecisionOf(resumeData);
|
|
3956
4289
|
const note = typeof resumeData.note === "string" && resumeData.note.trim() !== "" ? resumeData.note : void 0;
|
|
@@ -3962,14 +4295,14 @@ function workflowApprovalOutput(resumeData) {
|
|
|
3962
4295
|
};
|
|
3963
4296
|
}
|
|
3964
4297
|
__name(workflowApprovalOutput, "workflowApprovalOutput");
|
|
3965
|
-
|
|
4298
|
+
__name3(workflowApprovalOutput, "workflowApprovalOutput");
|
|
3966
4299
|
function isWorkflowApprovalOutput(value3) {
|
|
3967
4300
|
if (typeof value3 !== "object" || value3 === null || Array.isArray(value3)) return false;
|
|
3968
4301
|
const v = value3;
|
|
3969
4302
|
return typeof v.approved === "boolean" && WORKFLOW_APPROVAL_OUTPUT_DECISIONS.includes(v.decision) && typeof v.text === "string";
|
|
3970
4303
|
}
|
|
3971
4304
|
__name(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
|
|
3972
|
-
|
|
4305
|
+
__name3(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
|
|
3973
4306
|
var JSON_FENCE_RE = /```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n?```/g;
|
|
3974
4307
|
function extractSingleJsonValue(text) {
|
|
3975
4308
|
const trimmed = (text ?? "").trim();
|
|
@@ -4012,7 +4345,7 @@ function extractSingleJsonValue(text) {
|
|
|
4012
4345
|
}
|
|
4013
4346
|
}
|
|
4014
4347
|
__name(extractSingleJsonValue, "extractSingleJsonValue");
|
|
4015
|
-
|
|
4348
|
+
__name3(extractSingleJsonValue, "extractSingleJsonValue");
|
|
4016
4349
|
var DEFAULT_ON_AGENT_FEATURES = [
|
|
4017
4350
|
"workflows",
|
|
4018
4351
|
"workflowCompose",
|
|
@@ -4022,17 +4355,17 @@ function agentFeatureCatalogDefault(featureName) {
|
|
|
4022
4355
|
return DEFAULT_ON_AGENT_FEATURES.includes(featureName);
|
|
4023
4356
|
}
|
|
4024
4357
|
__name(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
|
|
4025
|
-
|
|
4358
|
+
__name3(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
|
|
4026
4359
|
function hasExplicitFeatureActive(row) {
|
|
4027
4360
|
return typeof row?.active === "boolean";
|
|
4028
4361
|
}
|
|
4029
4362
|
__name(hasExplicitFeatureActive, "hasExplicitFeatureActive");
|
|
4030
|
-
|
|
4363
|
+
__name3(hasExplicitFeatureActive, "hasExplicitFeatureActive");
|
|
4031
4364
|
function effectiveFeatureActive(row, catalogDefault) {
|
|
4032
4365
|
return hasExplicitFeatureActive(row) ? row.active : catalogDefault;
|
|
4033
4366
|
}
|
|
4034
4367
|
__name(effectiveFeatureActive, "effectiveFeatureActive");
|
|
4035
|
-
|
|
4368
|
+
__name3(effectiveFeatureActive, "effectiveFeatureActive");
|
|
4036
4369
|
function resolveEffectiveFeature(row, catalogDefault) {
|
|
4037
4370
|
return hasExplicitFeatureActive(row) ? {
|
|
4038
4371
|
active: row.active,
|
|
@@ -4045,7 +4378,7 @@ function resolveEffectiveFeature(row, catalogDefault) {
|
|
|
4045
4378
|
};
|
|
4046
4379
|
}
|
|
4047
4380
|
__name(resolveEffectiveFeature, "resolveEffectiveFeature");
|
|
4048
|
-
|
|
4381
|
+
__name3(resolveEffectiveFeature, "resolveEffectiveFeature");
|
|
4049
4382
|
function asFeatureRow(value3) {
|
|
4050
4383
|
if (value3 === false) return {
|
|
4051
4384
|
active: false
|
|
@@ -4053,12 +4386,12 @@ function asFeatureRow(value3) {
|
|
|
4053
4386
|
return typeof value3 === "object" && value3 !== null && !Array.isArray(value3) ? value3 : void 0;
|
|
4054
4387
|
}
|
|
4055
4388
|
__name(asFeatureRow, "asFeatureRow");
|
|
4056
|
-
|
|
4389
|
+
__name3(asFeatureRow, "asFeatureRow");
|
|
4057
4390
|
function agentFeatureBagCarries(bag, name) {
|
|
4058
4391
|
return bag != null && Object.prototype.hasOwnProperty.call(bag, name) && asFeatureRow(bag[name]) !== void 0;
|
|
4059
4392
|
}
|
|
4060
4393
|
__name(agentFeatureBagCarries, "agentFeatureBagCarries");
|
|
4061
|
-
|
|
4394
|
+
__name3(agentFeatureBagCarries, "agentFeatureBagCarries");
|
|
4062
4395
|
function effectiveAgentFeatureRows(base, override) {
|
|
4063
4396
|
const merged = /* @__PURE__ */ new Map();
|
|
4064
4397
|
for (const [name, value3] of Object.entries(base ?? {})) {
|
|
@@ -4091,7 +4424,7 @@ function effectiveAgentFeatureRows(base, override) {
|
|
|
4091
4424
|
};
|
|
4092
4425
|
}
|
|
4093
4426
|
__name(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
|
|
4094
|
-
|
|
4427
|
+
__name3(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
|
|
4095
4428
|
var SUBAGENT_PER_KEY_FLAG_ENV = "LUA_SUBAGENT_FEATURES_PER_KEY";
|
|
4096
4429
|
var PER_KEY_FLAG_VALUES = /* @__PURE__ */ new Set([
|
|
4097
4430
|
"1",
|
|
@@ -4104,17 +4437,17 @@ function agentFeatureMergeRuleFromEnv(env) {
|
|
|
4104
4437
|
return typeof raw === "string" && PER_KEY_FLAG_VALUES.has(raw.trim().toLowerCase()) ? "per-key" : "wholesale";
|
|
4105
4438
|
}
|
|
4106
4439
|
__name(agentFeatureMergeRuleFromEnv, "agentFeatureMergeRuleFromEnv");
|
|
4107
|
-
|
|
4440
|
+
__name3(agentFeatureMergeRuleFromEnv, "agentFeatureMergeRuleFromEnv");
|
|
4108
4441
|
function effectiveAgentFeatures(base, override, rule) {
|
|
4109
4442
|
if (rule === "wholesale") return override || base || void 0;
|
|
4110
4443
|
return effectiveAgentFeatureRows(base, override).rows;
|
|
4111
4444
|
}
|
|
4112
4445
|
__name(effectiveAgentFeatures, "effectiveAgentFeatures");
|
|
4113
|
-
|
|
4446
|
+
__name3(effectiveAgentFeatures, "effectiveAgentFeatures");
|
|
4114
4447
|
var ONBOARDING_FLOW_KEY = "alpha-choose-meet";
|
|
4115
4448
|
var ONBOARDING_SCHEMA_VERSION = 1;
|
|
4116
4449
|
var id = z4.string().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/);
|
|
4117
|
-
var copy = /* @__PURE__ */
|
|
4450
|
+
var copy = /* @__PURE__ */ __name3((max) => z4.string().max(max), "copy");
|
|
4118
4451
|
var onboardingHeadingSchema = z4.discriminatedUnion("kind", [
|
|
4119
4452
|
z4.object({
|
|
4120
4453
|
kind: z4.literal("plain"),
|
|
@@ -4341,61 +4674,498 @@ function parseOnboardingFlow(value3) {
|
|
|
4341
4674
|
return onboardingFlowSchema.parse(value3);
|
|
4342
4675
|
}
|
|
4343
4676
|
__name(parseOnboardingFlow, "parseOnboardingFlow");
|
|
4344
|
-
|
|
4677
|
+
__name3(parseOnboardingFlow, "parseOnboardingFlow");
|
|
4345
4678
|
function parsePublishedOnboardingResponse(value3) {
|
|
4346
4679
|
return getPublishedOnboardingResponseSchema.parse(value3);
|
|
4347
4680
|
}
|
|
4348
4681
|
__name(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
var __defProp3 = Object.defineProperty;
|
|
4358
|
-
var __name3 = /* @__PURE__ */ __name((target, value3) => __defProp3(target, "name", { value: value3, configurable: true }), "__name");
|
|
4359
|
-
var WORKFLOW_JOB_TOOLS = [
|
|
4360
|
-
"shell",
|
|
4361
|
-
"read",
|
|
4362
|
-
"write",
|
|
4363
|
-
"edit",
|
|
4364
|
-
"glob",
|
|
4365
|
-
"grep",
|
|
4366
|
-
"git",
|
|
4367
|
-
"gh",
|
|
4368
|
-
"fetch",
|
|
4369
|
-
"ripwire"
|
|
4682
|
+
__name3(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
|
|
4683
|
+
var WEB_ROUTE_PROTOCOL_VERSION = 1;
|
|
4684
|
+
var WEB_ROUTE_METHODS = [
|
|
4685
|
+
"GET",
|
|
4686
|
+
"POST",
|
|
4687
|
+
"PUT",
|
|
4688
|
+
"PATCH",
|
|
4689
|
+
"DELETE"
|
|
4370
4690
|
];
|
|
4371
|
-
var
|
|
4372
|
-
"
|
|
4373
|
-
"
|
|
4374
|
-
"
|
|
4375
|
-
"
|
|
4691
|
+
var WEB_ROUTE_REQUEST_HEADER_ALLOWLIST = [
|
|
4692
|
+
"accept",
|
|
4693
|
+
"accept-language",
|
|
4694
|
+
"content-type",
|
|
4695
|
+
"if-none-match",
|
|
4696
|
+
"idempotency-key"
|
|
4376
4697
|
];
|
|
4377
|
-
var
|
|
4378
|
-
"
|
|
4379
|
-
"
|
|
4380
|
-
"
|
|
4381
|
-
"
|
|
4382
|
-
"
|
|
4383
|
-
"
|
|
4384
|
-
"git"
|
|
4698
|
+
var WEB_ROUTE_RESPONSE_HEADER_ALLOWLIST = [
|
|
4699
|
+
"content-type",
|
|
4700
|
+
"cache-control",
|
|
4701
|
+
"etag",
|
|
4702
|
+
"location",
|
|
4703
|
+
"content-disposition",
|
|
4704
|
+
"content-language"
|
|
4385
4705
|
];
|
|
4386
|
-
function
|
|
4387
|
-
const
|
|
4706
|
+
function isForwardableWebRouteRequestHeader(name) {
|
|
4707
|
+
const n2 = name.toLowerCase();
|
|
4708
|
+
return WEB_ROUTE_REQUEST_HEADER_ALLOWLIST.includes(n2) || n2.startsWith("x-lua-");
|
|
4709
|
+
}
|
|
4710
|
+
__name(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
|
|
4711
|
+
__name3(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
|
|
4712
|
+
function isForwardableWebRouteResponseHeader(name) {
|
|
4713
|
+
const n2 = name.toLowerCase();
|
|
4714
|
+
if (n2 === "set-cookie") return false;
|
|
4715
|
+
return WEB_ROUTE_RESPONSE_HEADER_ALLOWLIST.includes(n2) || n2.startsWith("x-lua-");
|
|
4716
|
+
}
|
|
4717
|
+
__name(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
|
|
4718
|
+
__name3(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
|
|
4719
|
+
var WEB_ROUTE_MAX_REQUEST_BODY_BYTES = 1 * 1024 * 1024;
|
|
4720
|
+
var WEB_ROUTE_MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
4721
|
+
function isWebRouteBody(value3) {
|
|
4722
|
+
if (!value3 || typeof value3 !== "object") return false;
|
|
4723
|
+
const b = value3;
|
|
4724
|
+
if (b.kind === "json") return "value" in b;
|
|
4725
|
+
if (b.kind === "text" || b.kind === "base64") return typeof b.value === "string";
|
|
4726
|
+
return false;
|
|
4727
|
+
}
|
|
4728
|
+
__name(isWebRouteBody, "isWebRouteBody");
|
|
4729
|
+
__name3(isWebRouteBody, "isWebRouteBody");
|
|
4730
|
+
function isStringRecord(value3) {
|
|
4731
|
+
if (!value3 || typeof value3 !== "object" || Array.isArray(value3)) return false;
|
|
4732
|
+
return Object.values(value3).every((v) => typeof v === "string");
|
|
4733
|
+
}
|
|
4734
|
+
__name(isStringRecord, "isStringRecord");
|
|
4735
|
+
__name3(isStringRecord, "isStringRecord");
|
|
4736
|
+
function isQueryRecord(value3) {
|
|
4737
|
+
if (!value3 || typeof value3 !== "object" || Array.isArray(value3)) return false;
|
|
4738
|
+
return Object.values(value3).every((v) => typeof v === "string" || Array.isArray(v) && v.every((one) => typeof one === "string"));
|
|
4739
|
+
}
|
|
4740
|
+
__name(isQueryRecord, "isQueryRecord");
|
|
4741
|
+
__name3(isQueryRecord, "isQueryRecord");
|
|
4742
|
+
function isWebRouteInput(value3) {
|
|
4743
|
+
if (!value3 || typeof value3 !== "object") return false;
|
|
4744
|
+
const v = value3;
|
|
4745
|
+
if (v.v !== WEB_ROUTE_PROTOCOL_VERSION) return false;
|
|
4746
|
+
const r = v.request;
|
|
4747
|
+
if (!r || typeof r !== "object") return false;
|
|
4748
|
+
if (!WEB_ROUTE_METHODS.includes(String(r.method))) return false;
|
|
4749
|
+
if (typeof r.path !== "string" || !r.path.startsWith("/")) return false;
|
|
4750
|
+
if (!isStringRecord(r.params)) return false;
|
|
4751
|
+
if (!isQueryRecord(r.query)) return false;
|
|
4752
|
+
if (!isStringRecord(r.headers)) return false;
|
|
4753
|
+
if (r.body !== void 0) {
|
|
4754
|
+
if (r.method === "GET") return false;
|
|
4755
|
+
if (!isWebRouteBody(r.body)) return false;
|
|
4756
|
+
}
|
|
4757
|
+
const a = v.auth;
|
|
4758
|
+
if (!a || typeof a.userId !== "string" || typeof a.orgId !== "string" || typeof a.agentId !== "string") return false;
|
|
4759
|
+
const app = v.app;
|
|
4760
|
+
if (!app || typeof app.id !== "string" || typeof app.name !== "string" || typeof app.origin !== "string") return false;
|
|
4761
|
+
return true;
|
|
4762
|
+
}
|
|
4763
|
+
__name(isWebRouteInput, "isWebRouteInput");
|
|
4764
|
+
__name3(isWebRouteInput, "isWebRouteInput");
|
|
4765
|
+
var EVIDENCE_SESSION_IDLE_MS = 30 * 6e4;
|
|
4766
|
+
var EVIDENCE_MIN_CONVERSATIONS = 20;
|
|
4767
|
+
var EVIDENCE_LOW_CONFIDENCE_N = 5;
|
|
4768
|
+
var EVIDENCE_SNIPPET_MAX_CHARS = 160;
|
|
4769
|
+
var EVIDENCE_EXAMPLES_PER_ITEM = 5;
|
|
4770
|
+
var EVIDENCE_SHOWN_ITEMS = 5;
|
|
4771
|
+
var EVIDENCE_LATENCY_BOUNDS_MS = [
|
|
4772
|
+
500,
|
|
4773
|
+
1e3,
|
|
4774
|
+
2e3,
|
|
4775
|
+
3e3,
|
|
4776
|
+
5e3,
|
|
4777
|
+
8e3,
|
|
4778
|
+
13e3,
|
|
4779
|
+
2e4,
|
|
4780
|
+
3e4,
|
|
4781
|
+
6e4,
|
|
4782
|
+
12e4
|
|
4783
|
+
];
|
|
4784
|
+
var EVIDENCE_WORD_BOUNDS = [
|
|
4785
|
+
4,
|
|
4786
|
+
10,
|
|
4787
|
+
20,
|
|
4788
|
+
40,
|
|
4789
|
+
80,
|
|
4790
|
+
150,
|
|
4791
|
+
300,
|
|
4792
|
+
600
|
|
4793
|
+
];
|
|
4794
|
+
var BAD_CONVERSATION_REASONS = [
|
|
4795
|
+
"thumbs_down",
|
|
4796
|
+
"unfinished",
|
|
4797
|
+
"asked_for_human"
|
|
4798
|
+
];
|
|
4799
|
+
var ATTACHMENT_LINES = [
|
|
4800
|
+
// Audio / video / document lines carry a URL; a reply like "Audio: terrible" is the user's words.
|
|
4801
|
+
[
|
|
4802
|
+
/^\[?audio:\s*https?:\/\/\S+\]?$/i,
|
|
4803
|
+
() => "[Voice message]"
|
|
4804
|
+
],
|
|
4805
|
+
[
|
|
4806
|
+
/^\[?video:\s*https?:\/\/\S+\]?$/i,
|
|
4807
|
+
() => "[Video]"
|
|
4808
|
+
],
|
|
4809
|
+
[
|
|
4810
|
+
/^\[?document:\s*https?:\/\/\S+\]?$/i,
|
|
4811
|
+
() => "[Document]"
|
|
4812
|
+
],
|
|
4813
|
+
// Image lines carry a file name with an extension (spaces allowed): "Image: my photo.jpg".
|
|
4814
|
+
[
|
|
4815
|
+
/^\[?image:\s*(?:https?:\/\/\S+|[^\s][^\n]{0,200}\.[a-z0-9]{2,5})\]?$/i,
|
|
4816
|
+
() => "[Image]"
|
|
4817
|
+
],
|
|
4818
|
+
// "File: name (url)" — bounded classes, no backtracking between the name and the URL.
|
|
4819
|
+
[
|
|
4820
|
+
/^file:\s*([^()]{1,200}?)\s*\(https?:\/\/[^\s)]+\)$/i,
|
|
4821
|
+
(m) => `[File: ${m[1]}]`
|
|
4822
|
+
]
|
|
4823
|
+
];
|
|
4824
|
+
function evidenceDisplayText(text) {
|
|
4825
|
+
const raw = typeof text === "string" ? text : "";
|
|
4826
|
+
if (!raw.trim()) return "";
|
|
4827
|
+
const lines = removeHiddenBlocks(raw).split(/\r?\n/).map((line) => {
|
|
4828
|
+
const t = line.trim();
|
|
4829
|
+
for (const [re, label] of ATTACHMENT_LINES) {
|
|
4830
|
+
const m = t.match(re);
|
|
4831
|
+
if (m) return label(m);
|
|
4832
|
+
}
|
|
4833
|
+
return t.replace(/https?:\/\/cdn\.heylua\.ai\/\S+/gi, "[attachment]");
|
|
4834
|
+
}).filter(Boolean);
|
|
4835
|
+
const out = lines.join(" ").replace(/\s+/g, " ").trim();
|
|
4836
|
+
return out || "[Attachment]";
|
|
4837
|
+
}
|
|
4838
|
+
__name(evidenceDisplayText, "evidenceDisplayText");
|
|
4839
|
+
__name3(evidenceDisplayText, "evidenceDisplayText");
|
|
4840
|
+
function evidenceSnippet(text) {
|
|
4841
|
+
const flat = evidenceDisplayText(text);
|
|
4842
|
+
return flat.length <= EVIDENCE_SNIPPET_MAX_CHARS ? flat : `${flat.slice(0, EVIDENCE_SNIPPET_MAX_CHARS - 1)}\u2026`;
|
|
4843
|
+
}
|
|
4844
|
+
__name(evidenceSnippet, "evidenceSnippet");
|
|
4845
|
+
__name3(evidenceSnippet, "evidenceSnippet");
|
|
4846
|
+
function evidenceWordCount(text) {
|
|
4847
|
+
if (typeof text !== "string") return 0;
|
|
4848
|
+
const t = text.trim();
|
|
4849
|
+
return t ? t.split(/\s+/).length : 0;
|
|
4850
|
+
}
|
|
4851
|
+
__name(evidenceWordCount, "evidenceWordCount");
|
|
4852
|
+
__name3(evidenceWordCount, "evidenceWordCount");
|
|
4853
|
+
function evidenceKey(label) {
|
|
4854
|
+
return label.toLowerCase().replace(/[_\-\s]+/g, " ").trim();
|
|
4855
|
+
}
|
|
4856
|
+
__name(evidenceKey, "evidenceKey");
|
|
4857
|
+
__name3(evidenceKey, "evidenceKey");
|
|
4858
|
+
function evidenceOpaqueKey(text) {
|
|
4859
|
+
let h = 0xcbf29ce484222325n;
|
|
4860
|
+
const prime = 0x100000001b3n;
|
|
4861
|
+
for (const ch of evidenceKey(text)) {
|
|
4862
|
+
h ^= BigInt(ch.codePointAt(0) ?? 0);
|
|
4863
|
+
h = h * prime & 0xffffffffffffffffn;
|
|
4864
|
+
}
|
|
4865
|
+
return `q_${h.toString(16).padStart(16, "0")}`;
|
|
4866
|
+
}
|
|
4867
|
+
__name(evidenceOpaqueKey, "evidenceOpaqueKey");
|
|
4868
|
+
__name3(evidenceOpaqueKey, "evidenceOpaqueKey");
|
|
4869
|
+
function evidenceToolKey(name) {
|
|
4870
|
+
const i = name.indexOf("__");
|
|
4871
|
+
return (i >= 0 ? name.slice(i + 2) : name).toLowerCase();
|
|
4872
|
+
}
|
|
4873
|
+
__name(evidenceToolKey, "evidenceToolKey");
|
|
4874
|
+
__name3(evidenceToolKey, "evidenceToolKey");
|
|
4875
|
+
function evidenceToolSlug(name) {
|
|
4876
|
+
const i = name.indexOf("__");
|
|
4877
|
+
return i >= 0 ? name.slice(0, i).toLowerCase() : "";
|
|
4878
|
+
}
|
|
4879
|
+
__name(evidenceToolSlug, "evidenceToolSlug");
|
|
4880
|
+
__name3(evidenceToolSlug, "evidenceToolSlug");
|
|
4881
|
+
function skillSlugBase(skill) {
|
|
4882
|
+
return skill.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
4883
|
+
}
|
|
4884
|
+
__name(skillSlugBase, "skillSlugBase");
|
|
4885
|
+
__name3(skillSlugBase, "skillSlugBase");
|
|
4886
|
+
function matchDefinedTool(calledName, defined2) {
|
|
4887
|
+
const key = evidenceToolKey(calledName);
|
|
4888
|
+
const candidates = [];
|
|
4889
|
+
defined2.forEach((d, i) => {
|
|
4890
|
+
if (d.name.toLowerCase() === key) candidates.push(i);
|
|
4891
|
+
});
|
|
4892
|
+
if (candidates.length <= 1) return candidates[0] ?? -1;
|
|
4893
|
+
const slug = evidenceToolSlug(calledName);
|
|
4894
|
+
const bySkill = candidates.find((i) => {
|
|
4895
|
+
const base = skillSlugBase(defined2[i].skill);
|
|
4896
|
+
return base !== "" && (slug === base || slug.startsWith(`${base}_`) || base.startsWith(slug));
|
|
4897
|
+
});
|
|
4898
|
+
return bySkill ?? candidates[0];
|
|
4899
|
+
}
|
|
4900
|
+
__name(matchDefinedTool, "matchDefinedTool");
|
|
4901
|
+
__name3(matchDefinedTool, "matchDefinedTool");
|
|
4902
|
+
function isMisunderstoodReason(reason) {
|
|
4903
|
+
return typeof reason === "string" && /misunderst/i.test(reason);
|
|
4904
|
+
}
|
|
4905
|
+
__name(isMisunderstoodReason, "isMisunderstoodReason");
|
|
4906
|
+
__name3(isMisunderstoodReason, "isMisunderstoodReason");
|
|
4907
|
+
function emptyHistogram(bounds) {
|
|
4908
|
+
return {
|
|
4909
|
+
count: 0,
|
|
4910
|
+
sum: 0,
|
|
4911
|
+
buckets: new Array(bounds.length + 1).fill(0)
|
|
4912
|
+
};
|
|
4913
|
+
}
|
|
4914
|
+
__name(emptyHistogram, "emptyHistogram");
|
|
4915
|
+
__name3(emptyHistogram, "emptyHistogram");
|
|
4916
|
+
function addToHistogram(h, bounds, value3) {
|
|
4917
|
+
if (!Number.isFinite(value3) || value3 < 0) return;
|
|
4918
|
+
let i = bounds.findIndex((b) => value3 <= b);
|
|
4919
|
+
if (i < 0) i = bounds.length;
|
|
4920
|
+
h.buckets[i] += 1;
|
|
4921
|
+
h.count += 1;
|
|
4922
|
+
h.sum += value3;
|
|
4923
|
+
}
|
|
4924
|
+
__name(addToHistogram, "addToHistogram");
|
|
4925
|
+
__name3(addToHistogram, "addToHistogram");
|
|
4926
|
+
function mergeHistograms(hs, bounds) {
|
|
4927
|
+
if (hs.length === 0) return null;
|
|
4928
|
+
const out = emptyHistogram(bounds);
|
|
4929
|
+
for (const h of hs) {
|
|
4930
|
+
out.count += h.count;
|
|
4931
|
+
out.sum += h.sum;
|
|
4932
|
+
for (let i = 0; i < out.buckets.length; i++) out.buckets[i] += h.buckets[i] ?? 0;
|
|
4933
|
+
}
|
|
4934
|
+
return out.count > 0 ? out : null;
|
|
4935
|
+
}
|
|
4936
|
+
__name(mergeHistograms, "mergeHistograms");
|
|
4937
|
+
__name3(mergeHistograms, "mergeHistograms");
|
|
4938
|
+
function histogramQuantile(h, bounds, q) {
|
|
4939
|
+
if (h.count === 0) return 0;
|
|
4940
|
+
const target = q * h.count;
|
|
4941
|
+
let seen = 0;
|
|
4942
|
+
for (let i = 0; i < h.buckets.length; i++) {
|
|
4943
|
+
const n2 = h.buckets[i];
|
|
4944
|
+
if (n2 > 0 && seen + n2 >= target) {
|
|
4945
|
+
const lo = i === 0 ? 0 : bounds[i - 1];
|
|
4946
|
+
if (i >= bounds.length) return lo;
|
|
4947
|
+
const hi = bounds[i];
|
|
4948
|
+
return lo + (target - seen) / n2 * (hi - lo);
|
|
4949
|
+
}
|
|
4950
|
+
seen += n2;
|
|
4951
|
+
}
|
|
4952
|
+
return bounds[bounds.length - 1];
|
|
4953
|
+
}
|
|
4954
|
+
__name(histogramQuantile, "histogramQuantile");
|
|
4955
|
+
__name3(histogramQuantile, "histogramQuantile");
|
|
4956
|
+
function mergeCounted(lists) {
|
|
4957
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
4958
|
+
for (const list of [
|
|
4959
|
+
...lists
|
|
4960
|
+
].reverse()) {
|
|
4961
|
+
for (const item of list) {
|
|
4962
|
+
const cur = byKey.get(item.key);
|
|
4963
|
+
if (!cur) {
|
|
4964
|
+
byKey.set(item.key, {
|
|
4965
|
+
...item,
|
|
4966
|
+
examples: item.examples.slice(0, EVIDENCE_EXAMPLES_PER_ITEM)
|
|
4967
|
+
});
|
|
4968
|
+
} else {
|
|
4969
|
+
cur.count += item.count;
|
|
4970
|
+
if (cur.examples.length < EVIDENCE_EXAMPLES_PER_ITEM) {
|
|
4971
|
+
cur.examples.push(...item.examples.slice(0, EVIDENCE_EXAMPLES_PER_ITEM - cur.examples.length));
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
}
|
|
4975
|
+
}
|
|
4976
|
+
return [
|
|
4977
|
+
...byKey.values()
|
|
4978
|
+
].sort((a, b) => b.count - a.count || a.key.localeCompare(b.key));
|
|
4979
|
+
}
|
|
4980
|
+
__name(mergeCounted, "mergeCounted");
|
|
4981
|
+
__name3(mergeCounted, "mergeCounted");
|
|
4982
|
+
function recentRefs(lists) {
|
|
4983
|
+
return lists.flat().sort((a, b) => b.createdAt - a.createdAt).slice(0, EVIDENCE_EXAMPLES_PER_ITEM);
|
|
4984
|
+
}
|
|
4985
|
+
__name(recentRefs, "recentRefs");
|
|
4986
|
+
__name3(recentRefs, "recentRefs");
|
|
4987
|
+
function confidenceOf(n2) {
|
|
4988
|
+
return n2 < EVIDENCE_LOW_CONFIDENCE_N ? "low" : "ok";
|
|
4989
|
+
}
|
|
4990
|
+
__name(confidenceOf, "confidenceOf");
|
|
4991
|
+
__name3(confidenceOf, "confidenceOf");
|
|
4992
|
+
function rateOf(count, conversations) {
|
|
4993
|
+
return {
|
|
4994
|
+
count,
|
|
4995
|
+
rate: conversations > 0 ? count / conversations : null,
|
|
4996
|
+
confidence: confidenceOf(count)
|
|
4997
|
+
};
|
|
4998
|
+
}
|
|
4999
|
+
__name(rateOf, "rateOf");
|
|
5000
|
+
__name3(rateOf, "rateOf");
|
|
5001
|
+
function evidenceDays(from, to) {
|
|
4388
5002
|
const out = [];
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
5003
|
+
const end = Date.parse(`${to}T00:00:00Z`);
|
|
5004
|
+
for (let t = Date.parse(`${from}T00:00:00Z`); t <= end; t += 864e5) {
|
|
5005
|
+
out.push(new Date(t).toISOString().slice(0, 10));
|
|
4392
5006
|
}
|
|
4393
5007
|
return out;
|
|
4394
5008
|
}
|
|
4395
|
-
__name(
|
|
4396
|
-
__name3(
|
|
5009
|
+
__name(evidenceDays, "evidenceDays");
|
|
5010
|
+
__name3(evidenceDays, "evidenceDays");
|
|
5011
|
+
function summarizeEvidence(input) {
|
|
5012
|
+
const { agentId, from, to } = input;
|
|
5013
|
+
const windowDays = evidenceDays(from, to);
|
|
5014
|
+
const readable = /* @__PURE__ */ __name3((s) => s === "ok" || s === "empty", "readable");
|
|
5015
|
+
const covered = /* @__PURE__ */ __name3((d) => readable(d.sources?.messages) && readable(d.sources?.analyses), "covered");
|
|
5016
|
+
const inWindow = input.days.filter((d) => d.date >= from && d.date <= to && covered(d)).sort((a, b) => a.date.localeCompare(b.date));
|
|
5017
|
+
const trackedSince = [
|
|
5018
|
+
...input.days,
|
|
5019
|
+
...input.previous ?? []
|
|
5020
|
+
].filter(covered).map((d) => d.date).sort()[0] ?? null;
|
|
5021
|
+
const sum = /* @__PURE__ */ __name3((f) => inWindow.reduce((acc, d) => acc + (f(d) || 0), 0), "sum");
|
|
5022
|
+
const conversations = sum((d) => d.conversations);
|
|
5023
|
+
const byReason = Object.fromEntries(BAD_CONVERSATION_REASONS.map((r) => [
|
|
5024
|
+
r,
|
|
5025
|
+
sum((d) => d.bad.byReason[r])
|
|
5026
|
+
]));
|
|
5027
|
+
const badTotal = sum((d) => d.bad.total);
|
|
5028
|
+
const prevDays = (input.previous ?? []).filter(covered);
|
|
5029
|
+
const comparable = prevDays.length > 0;
|
|
5030
|
+
const prevReasons = mergeCounted(prevDays.map((d) => d.themes.failureReasons));
|
|
5031
|
+
const prevTopics = mergeCounted(prevDays.map((d) => d.themes.topics));
|
|
5032
|
+
const toThemes = /* @__PURE__ */ __name3((lists, prev) => mergeCounted(lists).slice(0, EVIDENCE_SHOWN_ITEMS).map((t) => ({
|
|
5033
|
+
...t,
|
|
5034
|
+
share: badTotal > 0 ? t.count / badTotal : 0,
|
|
5035
|
+
previousCount: comparable ? prev.find((p) => p.key === t.key)?.count ?? 0 : null,
|
|
5036
|
+
confidence: confidenceOf(t.count)
|
|
5037
|
+
})), "toThemes");
|
|
5038
|
+
const usage = /* @__PURE__ */ new Map();
|
|
5039
|
+
for (const d of inWindow) {
|
|
5040
|
+
for (const t of d.tools) {
|
|
5041
|
+
const cur = usage.get(t.name) ?? {
|
|
5042
|
+
name: t.name,
|
|
5043
|
+
calls: 0,
|
|
5044
|
+
conversations: 0,
|
|
5045
|
+
errors: 0
|
|
5046
|
+
};
|
|
5047
|
+
cur.calls += t.calls;
|
|
5048
|
+
cur.conversations += t.conversations;
|
|
5049
|
+
cur.errors += t.errors;
|
|
5050
|
+
usage.set(t.name, cur);
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
const latestDefined = [
|
|
5054
|
+
...inWindow
|
|
5055
|
+
].reverse().find((d) => d.definedTools)?.definedTools ?? null;
|
|
5056
|
+
const defined2 = input.definedTools !== void 0 ? input.definedTools : latestDefined;
|
|
5057
|
+
const definedKnown = Array.isArray(defined2);
|
|
5058
|
+
const enoughData = conversations >= EVIDENCE_MIN_CONVERSATIONS;
|
|
5059
|
+
const definedList = defined2 ?? [];
|
|
5060
|
+
const definedRows = definedList.map((dt) => ({
|
|
5061
|
+
name: dt.name,
|
|
5062
|
+
skill: dt.skill,
|
|
5063
|
+
calls: 0,
|
|
5064
|
+
conversations: 0,
|
|
5065
|
+
errors: 0
|
|
5066
|
+
}));
|
|
5067
|
+
const matched = /* @__PURE__ */ new Set();
|
|
5068
|
+
for (const u of usage.values()) {
|
|
5069
|
+
const i = matchDefinedTool(u.name, definedList);
|
|
5070
|
+
if (i < 0) continue;
|
|
5071
|
+
matched.add(u.name);
|
|
5072
|
+
definedRows[i].calls += u.calls;
|
|
5073
|
+
definedRows[i].conversations += u.conversations;
|
|
5074
|
+
definedRows[i].errors += u.errors;
|
|
5075
|
+
}
|
|
5076
|
+
definedRows.sort((a, b) => b.calls - a.calls || a.name.localeCompare(b.name));
|
|
5077
|
+
const other = [
|
|
5078
|
+
...usage.values()
|
|
5079
|
+
].filter((u) => !matched.has(u.name)).sort((a, b) => b.calls - a.calls);
|
|
5080
|
+
const rt = mergeHistograms(inWindow.map((d) => d.responseTimeMs).filter((h) => !!h), EVIDENCE_LATENCY_BOUNDS_MS);
|
|
5081
|
+
const wordRows = inWindow.map((d) => d.responseWords).filter((h) => !!h);
|
|
5082
|
+
const rw = mergeHistograms(wordRows, EVIDENCE_WORD_BOUNDS);
|
|
5083
|
+
const short = wordRows.reduce((a, h) => a + h.short, 0);
|
|
5084
|
+
const long = wordRows.reduce((a, h) => a + h.long, 0);
|
|
5085
|
+
return {
|
|
5086
|
+
agentId,
|
|
5087
|
+
window: {
|
|
5088
|
+
from,
|
|
5089
|
+
to,
|
|
5090
|
+
days: windowDays.length
|
|
5091
|
+
},
|
|
5092
|
+
coverage: {
|
|
5093
|
+
daysWithData: inWindow.length,
|
|
5094
|
+
trackedSince,
|
|
5095
|
+
complete: inWindow.length === windowDays.length
|
|
5096
|
+
},
|
|
5097
|
+
conversations,
|
|
5098
|
+
exchanges: sum((d) => d.exchanges),
|
|
5099
|
+
bad: {
|
|
5100
|
+
...rateOf(badTotal, conversations),
|
|
5101
|
+
byReason,
|
|
5102
|
+
examples: recentRefs(inWindow.map((d) => d.examples.bad))
|
|
5103
|
+
},
|
|
5104
|
+
misunderstood: {
|
|
5105
|
+
...rateOf(sum((d) => d.misunderstood), conversations),
|
|
5106
|
+
examples: recentRefs(inWindow.map((d) => d.examples.misunderstood))
|
|
5107
|
+
},
|
|
5108
|
+
unmetIntent: {
|
|
5109
|
+
...rateOf(sum((d) => d.unmetIntent), conversations),
|
|
5110
|
+
questions: mergeCounted(inWindow.map((d) => d.unmetQuestions)).slice(0, EVIDENCE_SHOWN_ITEMS)
|
|
5111
|
+
},
|
|
5112
|
+
loops: {
|
|
5113
|
+
...rateOf(sum((d) => d.loops), conversations),
|
|
5114
|
+
examples: recentRefs(inWindow.map((d) => d.examples.loops))
|
|
5115
|
+
},
|
|
5116
|
+
themes: {
|
|
5117
|
+
failureReasons: toThemes(inWindow.map((d) => d.themes.failureReasons), prevReasons),
|
|
5118
|
+
topics: toThemes(inWindow.map((d) => d.themes.topics), prevTopics),
|
|
5119
|
+
comparable
|
|
5120
|
+
},
|
|
5121
|
+
tools: {
|
|
5122
|
+
enoughData,
|
|
5123
|
+
definedKnown,
|
|
5124
|
+
definedCount: definedRows.length,
|
|
5125
|
+
usedDefinedCount: definedRows.filter((r) => r.calls > 0).length,
|
|
5126
|
+
calledCount: definedRows.filter((r) => r.calls > 0).length + other.filter((u) => u.calls > 0).length,
|
|
5127
|
+
defined: definedRows,
|
|
5128
|
+
unused: enoughData && definedKnown ? definedRows.filter((r) => r.calls === 0).map(({ name, skill }) => ({
|
|
5129
|
+
name,
|
|
5130
|
+
skill
|
|
5131
|
+
})) : [],
|
|
5132
|
+
other
|
|
5133
|
+
},
|
|
5134
|
+
responseTime: rt ? {
|
|
5135
|
+
count: rt.count,
|
|
5136
|
+
avgMs: Math.round(rt.sum / rt.count),
|
|
5137
|
+
medianMs: Math.round(histogramQuantile(rt, EVIDENCE_LATENCY_BOUNDS_MS, 0.5)),
|
|
5138
|
+
p90Ms: Math.round(histogramQuantile(rt, EVIDENCE_LATENCY_BOUNDS_MS, 0.9))
|
|
5139
|
+
} : null,
|
|
5140
|
+
responseLength: rw ? {
|
|
5141
|
+
count: rw.count,
|
|
5142
|
+
avgWords: Math.round(rw.sum / rw.count),
|
|
5143
|
+
medianWords: Math.round(histogramQuantile(rw, EVIDENCE_WORD_BOUNDS, 0.5)),
|
|
5144
|
+
shortRate: short / rw.count,
|
|
5145
|
+
longRate: long / rw.count
|
|
5146
|
+
} : null
|
|
5147
|
+
};
|
|
5148
|
+
}
|
|
5149
|
+
__name(summarizeEvidence, "summarizeEvidence");
|
|
5150
|
+
__name3(summarizeEvidence, "summarizeEvidence");
|
|
5151
|
+
var REVIEW_VERDICT_REASON_ORDER = [
|
|
5152
|
+
"overall_below",
|
|
5153
|
+
"dimension_below",
|
|
5154
|
+
"critical_issues",
|
|
5155
|
+
"issue_count"
|
|
5156
|
+
];
|
|
5157
|
+
function sortVerdictReasons(reasons) {
|
|
5158
|
+
return [
|
|
5159
|
+
...reasons
|
|
5160
|
+
].sort((a, b) => REVIEW_VERDICT_REASON_ORDER.indexOf(a.kind) - REVIEW_VERDICT_REASON_ORDER.indexOf(b.kind));
|
|
5161
|
+
}
|
|
5162
|
+
__name(sortVerdictReasons, "sortVerdictReasons");
|
|
5163
|
+
__name3(sortVerdictReasons, "sortVerdictReasons");
|
|
4397
5164
|
|
|
4398
5165
|
// ../workflow-graph/dist/index.mjs
|
|
5166
|
+
import { createHash } from "crypto";
|
|
5167
|
+
import { z as z5 } from "zod";
|
|
5168
|
+
import { z as z22 } from "zod";
|
|
4399
5169
|
import { createHash as createHash2 } from "crypto";
|
|
4400
5170
|
var __defProp4 = Object.defineProperty;
|
|
4401
5171
|
var __name4 = /* @__PURE__ */ __name((target, value22) => __defProp4(target, "name", { value: value22, configurable: true }), "__name");
|
|
@@ -5623,6 +6393,26 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
|
|
|
5623
6393
|
warn("gh-on-coding-turn", `"${id2}" grants the gh tool on a coding turn \u2014 the pod can open/merge PRs on the workspace repo (purpose:'gh' token, pull_requests:write + contents:write)`, `${path}.jobTools`, id2);
|
|
5624
6394
|
}
|
|
5625
6395
|
}
|
|
6396
|
+
const plugins = node.plugins;
|
|
6397
|
+
const target = node.target;
|
|
6398
|
+
if (target !== void 0) {
|
|
6399
|
+
const problem = workflowJobTargetProblem(target, plugins);
|
|
6400
|
+
if (problem) err("target-invalid", problem, `${path}.target`, id2);
|
|
6401
|
+
}
|
|
6402
|
+
if (plugins !== void 0) {
|
|
6403
|
+
const problem = workflowJobPluginsProblem(plugins);
|
|
6404
|
+
if (problem) err("plugins-invalid", problem, `${path}.plugins`, id2);
|
|
6405
|
+
if (node.type !== "agent") err("plugins-invalid", "`plugins` is legal on agent steps only", `${path}.plugins`, id2);
|
|
6406
|
+
else {
|
|
6407
|
+
if (!isJobTier(node)) err("plugins-invalid", "`plugins` needs tier:'job'", `${path}.plugins`, id2);
|
|
6408
|
+
const provider = classifyModelProvider(jobClassifiablePin(node.model));
|
|
6409
|
+
if (node.harness === "generic" || provider !== null && provider !== "anthropic") err("plugins-invalid", "`plugins` run on the claude-code harness only (an Anthropic model, no `harness:'generic'`)", `${path}.plugins`, id2);
|
|
6410
|
+
const w = workspaceOf(node);
|
|
6411
|
+
const ro = w !== void 0 && w !== "inherit" && w.mount === "ro";
|
|
6412
|
+
const declared = Array.isArray(tools) ? tools : void 0;
|
|
6413
|
+
if (!effectiveJobTools(declared, ro).includes("shell")) err("plugins-invalid", "`plugins` need the `shell` job tool (the plugin drives lua-cli) \u2014 keep it in jobTools and mount rw", `${path}.plugins`, id2);
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
5626
6416
|
if (node.type === "agent" && ws && ws !== "inherit" && ws.mount === "ro" && Array.isArray(tools) && effectiveJobTools(tools, true).length === 0) {
|
|
5627
6417
|
warn("ro-step-has-no-tools", `"${id2}" mounts the workspace read-only and every jobTool it declares (${JSON.stringify(tools)}) is one the ro mount drops [${WORKFLOW_JOB_READ_ONLY_DROPPED.join(", ")}] \u2014 the coding turn would run with no tools at all; keep a read-only tool (read/glob/grep, gh) or mount rw`, `${path}.jobTools`, id2);
|
|
5628
6418
|
}
|
|
@@ -9273,6 +10063,15 @@ var WorkflowBuilderImpl = class WorkflowBuilderImpl2 {
|
|
|
9273
10063
|
throw new LuaWorkflowBuildError("max-turns-invalid", `"${id2}": ${m} must be an integer ${min}..${max}`);
|
|
9274
10064
|
}
|
|
9275
10065
|
}
|
|
10066
|
+
if (opts.plugins !== void 0) {
|
|
10067
|
+
if (tier !== "job") throw new LuaWorkflowBuildError("plugins-invalid", `"${id2}": plugins are only legal on a tier:'job' agent step`);
|
|
10068
|
+
const problem = workflowJobPluginsProblem(opts.plugins);
|
|
10069
|
+
if (problem) throw new LuaWorkflowBuildError("plugins-invalid", `"${id2}": ${problem}`);
|
|
10070
|
+
}
|
|
10071
|
+
if (opts.target !== void 0) {
|
|
10072
|
+
const problem = workflowJobTargetProblem(opts.target, opts.plugins);
|
|
10073
|
+
if (problem) throw new LuaWorkflowBuildError("plugins-invalid", `"${id2}": ${problem}`);
|
|
10074
|
+
}
|
|
9276
10075
|
assertTimeout({
|
|
9277
10076
|
id: id2,
|
|
9278
10077
|
timeoutSeconds: opts.timeoutSeconds,
|
|
@@ -9305,7 +10104,9 @@ var WorkflowBuilderImpl = class WorkflowBuilderImpl2 {
|
|
|
9305
10104
|
harness: opts.harness,
|
|
9306
10105
|
maxTurns: opts.maxTurns,
|
|
9307
10106
|
maxMessages: opts.maxMessages,
|
|
9308
|
-
maxInputTokens: opts.maxInputTokens
|
|
10107
|
+
maxInputTokens: opts.maxInputTokens,
|
|
10108
|
+
plugins: opts.plugins,
|
|
10109
|
+
target: opts.target
|
|
9309
10110
|
});
|
|
9310
10111
|
return this.push({
|
|
9311
10112
|
kind: "declare",
|
|
@@ -9572,6 +10373,15 @@ function createWorkflow(cfg) {
|
|
|
9572
10373
|
const n2 = cfg.backfillOnEnable.maxOccurrences;
|
|
9573
10374
|
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)");
|
|
9574
10375
|
}
|
|
10376
|
+
if (cfg.health !== void 0) {
|
|
10377
|
+
const issues = validateScheduleHealth(cfg.health, {
|
|
10378
|
+
target: "workflow",
|
|
10379
|
+
triggers: cfg.schedule && typeof cfg.schedule === "object" ? [
|
|
10380
|
+
cfg.schedule
|
|
10381
|
+
] : []
|
|
10382
|
+
});
|
|
10383
|
+
if (issues.length > 0) throw new LuaWorkflowBuildError("invalid-envelope", issues.map((i) => `${i.message} (${i.code})`).join("; "));
|
|
10384
|
+
}
|
|
9575
10385
|
const keys = /* @__PURE__ */ new Set();
|
|
9576
10386
|
envRefKeys(cfg.schedule, keys);
|
|
9577
10387
|
envRefKeys(cfg.workspace, keys);
|