@bike4mind/cli 0.2.82 → 0.3.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/{ConfigStore-DTyUBb3A.mjs → ConfigStore-o5AblHqQ.mjs} +538 -115
- package/dist/commands/doctorCommand.mjs +1 -1
- package/dist/commands/headlessCommand.mjs +8 -4
- package/dist/commands/mcpCommand.mjs +1 -1
- package/dist/commands/updateCommand.mjs +1 -1
- package/dist/index.mjs +427 -21
- package/dist/{store-Dw1nZX2Y.mjs → store-B7-LLvvx.mjs} +18 -0
- package/dist/store-B_ILRSdP.mjs +3 -0
- package/dist/{tools-C0eJHV0Y.mjs → tools-BImjpPlR.mjs} +560 -110
- package/dist/{treeSitterEngine-DCSXcm_3.mjs → treeSitterEngine-BFTHnDwH.mjs} +4 -1
- package/dist/{updateChecker-CPr5OfMn.mjs → updateChecker-CEeSpbaK.mjs} +1 -1
- package/package.json +25 -27
- package/dist/store-nZExNOWX.mjs +0 -3
|
@@ -6,7 +6,7 @@ import os, { homedir } from "os";
|
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { v4 } from "uuid";
|
|
8
8
|
import * as z$2 from "zod";
|
|
9
|
-
import z$1, { z } from "zod";
|
|
9
|
+
import z$1, { ZodError, z } from "zod";
|
|
10
10
|
import dayjs from "dayjs";
|
|
11
11
|
import timezone from "dayjs/plugin/timezone.js";
|
|
12
12
|
import utc from "dayjs/plugin/utc.js";
|
|
@@ -23,9 +23,41 @@ let CollectionType = /* @__PURE__ */ function(CollectionType) {
|
|
|
23
23
|
}({});
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region ../../b4m-core/common/dist/index.mjs
|
|
26
|
+
var HTTPError = class extends Error {
|
|
27
|
+
constructor(statusCode, message, additionalInfo) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.statusCode = statusCode;
|
|
30
|
+
this.additionalInfo = additionalInfo;
|
|
31
|
+
this.name = "HTTPError";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var InternalServerError = class extends HTTPError {
|
|
35
|
+
constructor(message, additionalInfo) {
|
|
36
|
+
super(500, message, additionalInfo);
|
|
37
|
+
this.additionalInfo = additionalInfo;
|
|
38
|
+
this.name = "InternalServerError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var NotFoundError = class extends HTTPError {
|
|
42
|
+
constructor(message, additionalInfo) {
|
|
43
|
+
super(404, message, additionalInfo);
|
|
44
|
+
this.additionalInfo = additionalInfo;
|
|
45
|
+
this.name = "NotFoundError";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var UnprocessableEntityError = class extends HTTPError {
|
|
49
|
+
constructor(message, additionalInfo) {
|
|
50
|
+
super(422, message, additionalInfo);
|
|
51
|
+
this.additionalInfo = additionalInfo;
|
|
52
|
+
this.name = "UnprocessableEntityError";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function isZodError(err) {
|
|
56
|
+
return Boolean(err && (err instanceof ZodError || err.name === "ZodError"));
|
|
57
|
+
}
|
|
26
58
|
/**
|
|
27
|
-
* Error thrown when user denies permission for a tool
|
|
28
|
-
* This should break the agent loop immediately and return control to the user
|
|
59
|
+
* Error thrown when user denies permission for a tool.
|
|
60
|
+
* This should break the agent loop immediately and return control to the user.
|
|
29
61
|
*/
|
|
30
62
|
var PermissionDeniedError = class extends Error {
|
|
31
63
|
constructor(toolName, toolArgs) {
|
|
@@ -35,6 +67,18 @@ var PermissionDeniedError = class extends Error {
|
|
|
35
67
|
this.name = "PermissionDeniedError";
|
|
36
68
|
}
|
|
37
69
|
};
|
|
70
|
+
function secureParameters(params, schema) {
|
|
71
|
+
try {
|
|
72
|
+
return schema.parse(params);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
if (isZodError(e)) throw new UnprocessableEntityError(e.issues.map((err) => `${err.path.join(".")}: ${err.message}`).join(", "));
|
|
75
|
+
throw new InternalServerError();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function obfuscateApiKey(apiKey) {
|
|
79
|
+
if (!apiKey) return apiKey;
|
|
80
|
+
return `${apiKey.slice(0, 3)}${"*".repeat(apiKey.length - 6)}${apiKey.slice(-3)}`;
|
|
81
|
+
}
|
|
38
82
|
/**
|
|
39
83
|
* Model backends
|
|
40
84
|
*/
|
|
@@ -57,6 +101,7 @@ let ImageModels = /* @__PURE__ */ function(ImageModels) {
|
|
|
57
101
|
ImageModels["GPT_IMAGE_1"] = "gpt-image-1";
|
|
58
102
|
ImageModels["GPT_IMAGE_1_5"] = "gpt-image-1.5";
|
|
59
103
|
ImageModels["GPT_IMAGE_1_MINI"] = "gpt-image-1-mini";
|
|
104
|
+
ImageModels["GPT_IMAGE_2"] = "gpt-image-2";
|
|
60
105
|
ImageModels["DALL_E_2"] = "dall-e-2";
|
|
61
106
|
ImageModels["FLUX_PRO"] = "flux-pro";
|
|
62
107
|
ImageModels["FLUX_PRO_1_1"] = "flux-pro-1.1";
|
|
@@ -105,6 +150,7 @@ let ChatModels = /* @__PURE__ */ function(ChatModels) {
|
|
|
105
150
|
ChatModels["GPT5_4"] = "gpt-5.4";
|
|
106
151
|
ChatModels["GPT5_4_MINI"] = "gpt-5.4-mini";
|
|
107
152
|
ChatModels["GPT5_4_NANO"] = "gpt-5.4-nano";
|
|
153
|
+
ChatModels["GPT5_5"] = "gpt-5.5";
|
|
108
154
|
ChatModels["LLAMA3_INSTRUCT_8B_V1"] = "meta.llama3-8b-instruct-v1:0";
|
|
109
155
|
ChatModels["LLAMA3_INSTRUCT_70B_V1"] = "meta.llama3-70b-instruct-v1:0";
|
|
110
156
|
ChatModels["LLAMA4_MAVERICK_17B_INSTRUCT_BEDROCK"] = "us.meta.llama4-maverick-17b-instruct-v1:0";
|
|
@@ -176,27 +222,30 @@ const supportedChatModels = z.enum(ChatModels);
|
|
|
176
222
|
* o1-preview and o1-mini do NOT support reasoning_effort.
|
|
177
223
|
*/
|
|
178
224
|
const REASONING_SUPPORTED_MODELS = new Set([
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
225
|
+
"o1-2024-12-17",
|
|
226
|
+
"o3-mini-2025-01-31",
|
|
227
|
+
"o3-2025-04-16",
|
|
228
|
+
"o4-mini-2025-04-16",
|
|
229
|
+
"gpt-5",
|
|
230
|
+
"gpt-5-mini",
|
|
231
|
+
"gpt-5-nano",
|
|
232
|
+
"gpt-5.1",
|
|
233
|
+
"gpt-5.2"
|
|
188
234
|
]);
|
|
189
235
|
/**
|
|
190
236
|
* Models that only support temperature=1 (no custom temperature).
|
|
191
|
-
* Includes
|
|
192
|
-
*
|
|
237
|
+
* Includes:
|
|
238
|
+
* - All reasoning models (OpenAI requires temp=1 when reasoning is active)
|
|
239
|
+
* - chat-latest variants that enforce this constraint
|
|
240
|
+
* - GPT-5.5, which rejects custom temperature even though it does not expose
|
|
241
|
+
* reasoning controls
|
|
193
242
|
*/
|
|
194
243
|
const FIXED_TEMPERATURE_MODELS = new Set([
|
|
195
244
|
...REASONING_SUPPORTED_MODELS,
|
|
196
|
-
|
|
197
|
-
|
|
245
|
+
"gpt-5.1-chat-latest",
|
|
246
|
+
"gpt-5.2-chat-latest",
|
|
247
|
+
"gpt-5.5"
|
|
198
248
|
]);
|
|
199
|
-
new Set([ChatModels.CLAUDE_4_7_OPUS, ChatModels.CLAUDE_4_7_OPUS_BEDROCK]);
|
|
200
249
|
/**
|
|
201
250
|
* Speech to Text Models
|
|
202
251
|
*
|
|
@@ -250,49 +299,62 @@ z$1.enum([
|
|
|
250
299
|
"gemini"
|
|
251
300
|
]);
|
|
252
301
|
z$1.enum(["openai"]);
|
|
253
|
-
VideoModels.SORA_2, VideoModels.SORA_2_PRO;
|
|
254
302
|
VIDEO_SIZE_CONSTRAINTS.SORA.durations;
|
|
255
303
|
VIDEO_SIZE_CONSTRAINTS.SORA.sizes;
|
|
256
304
|
z.object({
|
|
305
|
+
/** Text description of the video to generate */
|
|
257
306
|
prompt: z.string().min(1).max(1e4),
|
|
258
|
-
|
|
307
|
+
/** Model to use for generation */
|
|
308
|
+
model: z.enum(VideoModels).prefault("sora-2"),
|
|
309
|
+
/** Video duration in seconds: 4, 8, or 12 */
|
|
259
310
|
seconds: z.union([
|
|
260
311
|
z.literal(4),
|
|
261
312
|
z.literal(8),
|
|
262
313
|
z.literal(12)
|
|
263
314
|
]).prefault(4),
|
|
315
|
+
/** Video resolution */
|
|
264
316
|
size: z.enum([
|
|
265
317
|
"720x1280",
|
|
266
318
|
"1280x720",
|
|
267
319
|
"1024x1792",
|
|
268
320
|
"1792x1024"
|
|
269
321
|
]).prefault(VIDEO_SIZE_CONSTRAINTS.SORA.defaultSize),
|
|
322
|
+
/** Optional user identifier for abuse tracking */
|
|
270
323
|
user: z.string().optional()
|
|
271
324
|
});
|
|
272
325
|
z.object({
|
|
326
|
+
/** Unique identifier for the video generation job */
|
|
273
327
|
id: z.string(),
|
|
328
|
+
/** Current status of the job */
|
|
274
329
|
status: z.enum([
|
|
275
330
|
"queued",
|
|
276
331
|
"in_progress",
|
|
277
332
|
"completed",
|
|
278
333
|
"failed"
|
|
279
334
|
]),
|
|
335
|
+
/** Error message if the job failed */
|
|
280
336
|
error: z.object({
|
|
281
337
|
message: z.string(),
|
|
282
338
|
code: z.string().optional()
|
|
283
339
|
}).optional(),
|
|
340
|
+
/** Timestamp when the job was created */
|
|
284
341
|
created_at: z.number().optional()
|
|
285
342
|
});
|
|
286
343
|
z.object({
|
|
344
|
+
/** Unique identifier for the video */
|
|
287
345
|
id: z.string(),
|
|
346
|
+
/** Status should be 'completed' */
|
|
288
347
|
status: z.literal("completed"),
|
|
348
|
+
/** URL to download the video (temporary, expires after a period) */
|
|
289
349
|
video_url: z.url().optional(),
|
|
350
|
+
/** Video duration in seconds */
|
|
290
351
|
duration: z.number().optional(),
|
|
352
|
+
/** Video resolution */
|
|
291
353
|
resolution: z.string().optional()
|
|
292
354
|
});
|
|
293
355
|
z.object({
|
|
294
356
|
prompt: z.string().min(1),
|
|
295
|
-
model: z.enum(VideoModels).optional().prefault(
|
|
357
|
+
model: z.enum(VideoModels).optional().prefault("sora-2"),
|
|
296
358
|
seconds: z.union([
|
|
297
359
|
z.literal(4),
|
|
298
360
|
z.literal(8),
|
|
@@ -681,8 +743,14 @@ const groupShareSchema = z.object({
|
|
|
681
743
|
const userShareSchema = z.object({
|
|
682
744
|
userId: z.string(),
|
|
683
745
|
permissions: z.array(z.enum(Permission)),
|
|
746
|
+
/** The project ID if the user is shared from a project */
|
|
684
747
|
projectId: z.string().optional(),
|
|
685
|
-
extraData: z.object({
|
|
748
|
+
extraData: z.object({
|
|
749
|
+
/** The last time the user exported data */
|
|
750
|
+
lastExportDate: z.date().optional() }).optional(),
|
|
751
|
+
/**
|
|
752
|
+
* TODO: To be replaced with proper user zod schema
|
|
753
|
+
*/
|
|
686
754
|
user: z.any().optional()
|
|
687
755
|
});
|
|
688
756
|
const shareableDocumentSchema = z.object({
|
|
@@ -691,7 +759,6 @@ const shareableDocumentSchema = z.object({
|
|
|
691
759
|
users: z.array(userShareSchema),
|
|
692
760
|
groups: z.array(groupShareSchema)
|
|
693
761
|
});
|
|
694
|
-
ChatModels.GPT4o_MINI;
|
|
695
762
|
let ApiKeyScope = /* @__PURE__ */ function(ApiKeyScope) {
|
|
696
763
|
ApiKeyScope["READ_NOTEBOOKS"] = "notebooks:read";
|
|
697
764
|
ApiKeyScope["WRITE_NOTEBOOKS"] = "notebooks:write";
|
|
@@ -732,6 +799,9 @@ const BaseCreditTransaction = z.object({
|
|
|
732
799
|
id: z.string().optional(),
|
|
733
800
|
ownerId: z.string(),
|
|
734
801
|
ownerType: z.enum(CreditHolderType),
|
|
802
|
+
/**
|
|
803
|
+
* Credits used or added
|
|
804
|
+
*/
|
|
735
805
|
credits: z.number(),
|
|
736
806
|
description: z.string().optional(),
|
|
737
807
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
@@ -743,6 +813,9 @@ const BaseCreditTransaction = z.object({
|
|
|
743
813
|
*/
|
|
744
814
|
const PurchaseTransaction = BaseCreditTransaction.extend({
|
|
745
815
|
type: z.literal("purchase"),
|
|
816
|
+
/**
|
|
817
|
+
* @deprecated Use ownerId and ownerType instead
|
|
818
|
+
*/
|
|
746
819
|
userId: z.string().optional(),
|
|
747
820
|
status: z.enum(CreditPurchaseStatus),
|
|
748
821
|
stripePaymentIntentId: z.string(),
|
|
@@ -768,7 +841,13 @@ const ReceivedCreditTransaction = BaseCreditTransaction.extend({
|
|
|
768
841
|
*/
|
|
769
842
|
const GenericCreditAddTransaction = BaseCreditTransaction.extend({
|
|
770
843
|
type: z.literal("generic_add"),
|
|
844
|
+
/**
|
|
845
|
+
* @deprecated Use ownerId and ownerType instead
|
|
846
|
+
*/
|
|
771
847
|
userId: z.string().optional(),
|
|
848
|
+
/**
|
|
849
|
+
* Optional reason/source for the transaction (e.g., 'admin_grant', 'refund', 'adjustment', 'legacy_purchase')
|
|
850
|
+
*/
|
|
772
851
|
reason: z.string().optional()
|
|
773
852
|
});
|
|
774
853
|
/**
|
|
@@ -778,7 +857,13 @@ const GenericCreditAddTransaction = BaseCreditTransaction.extend({
|
|
|
778
857
|
*/
|
|
779
858
|
const GenericCreditDeductTransaction = BaseCreditTransaction.extend({
|
|
780
859
|
type: z.literal("generic_deduct"),
|
|
860
|
+
/**
|
|
861
|
+
* @deprecated Use ownerId and ownerType instead
|
|
862
|
+
*/
|
|
781
863
|
userId: z.string().optional(),
|
|
864
|
+
/**
|
|
865
|
+
* Optional reason/source for the transaction (e.g., 'admin_adjustment', 'legacy_usage', 'manual_deduction')
|
|
866
|
+
*/
|
|
782
867
|
reason: z.string().optional()
|
|
783
868
|
});
|
|
784
869
|
const TextGenerationUsageTransaction = BaseCreditTransaction.extend({
|
|
@@ -899,6 +984,15 @@ let TagType = /* @__PURE__ */ function(TagType) {
|
|
|
899
984
|
TagType["SESSION"] = "session";
|
|
900
985
|
return TagType;
|
|
901
986
|
}({});
|
|
987
|
+
const SRE_BLOCKED_FILE_DEFAULTS = [
|
|
988
|
+
"infra/**",
|
|
989
|
+
"*.secret*",
|
|
990
|
+
"*.env*",
|
|
991
|
+
"*migration*",
|
|
992
|
+
".github/workflows/**",
|
|
993
|
+
"**/package.json",
|
|
994
|
+
"pnpm-lock.yaml"
|
|
995
|
+
];
|
|
902
996
|
const SRE_GATE_DEFAULTS = {
|
|
903
997
|
enabled: true,
|
|
904
998
|
autoThreshold: 85,
|
|
@@ -914,38 +1008,68 @@ const SreGateConfigSchema = z.object({
|
|
|
914
1008
|
message: "autoThreshold must be >= askThreshold",
|
|
915
1009
|
path: ["autoThreshold"]
|
|
916
1010
|
});
|
|
917
|
-
/**
|
|
918
|
-
*
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1011
|
+
/**
|
|
1012
|
+
* Each repo is a completely independent, self-contained configuration unit.
|
|
1013
|
+
* No defaults, no inheritance — every project is different.
|
|
1014
|
+
*/
|
|
1015
|
+
const SreRepoConfigSchema = z.object({
|
|
1016
|
+
/** GitHub org/user that owns the target repo */
|
|
1017
|
+
owner: z.string().min(1),
|
|
1018
|
+
/** Repository name */
|
|
1019
|
+
repo: z.string().min(1),
|
|
1020
|
+
/** Whether this repo's SRE pipeline is active */
|
|
927
1021
|
enabled: z.boolean().default(false),
|
|
928
|
-
|
|
929
|
-
maxDiffLines: z.number().min(1).default(50),
|
|
1022
|
+
/** LLM model ID for Diagnostician */
|
|
930
1023
|
modelId: z.string().default("claude-sonnet-4-20250514"),
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1024
|
+
/** Max diff lines per fix */
|
|
1025
|
+
maxDiffLines: z.number().min(1).default(50),
|
|
1026
|
+
/** Max fixes dispatched per day for this repo */
|
|
1027
|
+
maxFixesPerDay: z.number().min(0).default(5),
|
|
1028
|
+
/** Max revision attempts before escalating to human */
|
|
1029
|
+
maxRevisions: z.number().int().min(0).max(10).default(2),
|
|
1030
|
+
/** Log actions without dispatching */
|
|
1031
|
+
dryRun: z.boolean().default(false),
|
|
1032
|
+
/** Comma-separated GitHub usernames to request as PR reviewers */
|
|
1033
|
+
reviewers: z.string().default(""),
|
|
1034
|
+
/** Default branch name (auto-detected via GitHub API if empty) */
|
|
1035
|
+
defaultBranch: z.string().default(""),
|
|
1036
|
+
/** Build command for the workflow */
|
|
1037
|
+
buildCommand: z.string().default(""),
|
|
1038
|
+
/** Files the Surgeon can modify (glob patterns). Base patterns always merged in. */
|
|
1039
|
+
allowedFilePatterns: z.array(z.string()).default([]),
|
|
1040
|
+
/** Files never auto-fixed (glob patterns) */
|
|
1041
|
+
blockedFilePatterns: z.array(z.string()).default([...SRE_BLOCKED_FILE_DEFAULTS]),
|
|
1042
|
+
/** HMAC secret for webhook verification (encrypted at rest) */
|
|
1043
|
+
webhookSecret: z.string().default(""),
|
|
1044
|
+
/** Bearer token for workflow callback auth (encrypted at rest) */
|
|
1045
|
+
callbackToken: z.string().default(""),
|
|
1046
|
+
/** Human-in-the-loop approval gates */
|
|
1047
|
+
gates: z.object({
|
|
1048
|
+
sentinelToDiagnostician: SreGateConfigSchema.default({ ...SRE_GATE_DEFAULTS }),
|
|
1049
|
+
diagnosticianToSurgeon: SreGateConfigSchema.default({ ...SRE_GATE_DEFAULTS })
|
|
1050
|
+
}).default({
|
|
1051
|
+
sentinelToDiagnostician: { ...SRE_GATE_DEFAULTS },
|
|
1052
|
+
diagnosticianToSurgeon: { ...SRE_GATE_DEFAULTS }
|
|
1053
|
+
}),
|
|
1054
|
+
/** Circuit breaker */
|
|
1055
|
+
circuitBreaker: z.object({
|
|
1056
|
+
failureThreshold: z.number().min(1).default(3),
|
|
1057
|
+
cooldownMinutes: z.number().min(1).default(30)
|
|
1058
|
+
}).default({
|
|
1059
|
+
failureThreshold: 3,
|
|
1060
|
+
cooldownMinutes: 30
|
|
1061
|
+
}),
|
|
1062
|
+
/** Token budget per analysis */
|
|
1063
|
+
tokenBudget: z.object({
|
|
1064
|
+
maxInputTokens: z.number().default(5e4),
|
|
1065
|
+
maxOutputTokens: z.number().default(8e3),
|
|
1066
|
+
maxGithubApiCalls: z.number().default(20)
|
|
942
1067
|
}).default({
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
webhookSecret: "",
|
|
947
|
-
callbackToken: ""
|
|
1068
|
+
maxInputTokens: 5e4,
|
|
1069
|
+
maxOutputTokens: 8e3,
|
|
1070
|
+
maxGithubApiCalls: 20
|
|
948
1071
|
}),
|
|
1072
|
+
/** Error sources */
|
|
949
1073
|
sources: z.object({
|
|
950
1074
|
cloudwatch: z.object({ enabled: z.boolean().default(false) }).default({ enabled: false }),
|
|
951
1075
|
github: z.object({
|
|
@@ -974,32 +1098,7 @@ const SreAgentConfigSchema = z.object({
|
|
|
974
1098
|
}
|
|
975
1099
|
}
|
|
976
1100
|
}),
|
|
977
|
-
|
|
978
|
-
sentinelToDiagnostician: SreGateConfigSchema.default({ ...SRE_GATE_DEFAULTS }),
|
|
979
|
-
diagnosticianToSurgeon: SreGateConfigSchema.default({ ...SRE_GATE_DEFAULTS })
|
|
980
|
-
}).default({
|
|
981
|
-
sentinelToDiagnostician: { ...SRE_GATE_DEFAULTS },
|
|
982
|
-
diagnosticianToSurgeon: { ...SRE_GATE_DEFAULTS }
|
|
983
|
-
}),
|
|
984
|
-
allowedFilePatterns: z.array(z.string()).default([...SRE_BASE_ALLOWED_PATTERNS]).transform((patterns) => {
|
|
985
|
-
return [...new Set([...SRE_BASE_ALLOWED_PATTERNS, ...patterns])];
|
|
986
|
-
}),
|
|
987
|
-
blockedFilePatterns: z.array(z.string()).default([
|
|
988
|
-
"infra/**",
|
|
989
|
-
"*.secret*",
|
|
990
|
-
"*.env*",
|
|
991
|
-
"*migration*",
|
|
992
|
-
".github/workflows/**",
|
|
993
|
-
"**/package.json",
|
|
994
|
-
"pnpm-lock.yaml"
|
|
995
|
-
]),
|
|
996
|
-
circuitBreaker: z.object({
|
|
997
|
-
failureThreshold: z.number().min(1).default(3),
|
|
998
|
-
cooldownMinutes: z.number().min(1).default(30)
|
|
999
|
-
}).default({
|
|
1000
|
-
failureThreshold: 3,
|
|
1001
|
-
cooldownMinutes: 30
|
|
1002
|
-
}),
|
|
1101
|
+
/** Recurrence guard */
|
|
1003
1102
|
recurrence: z.object({
|
|
1004
1103
|
enabled: z.boolean().default(true),
|
|
1005
1104
|
windowDays: z.number().int().min(1).max(30).default(14),
|
|
@@ -1009,15 +1108,7 @@ const SreAgentConfigSchema = z.object({
|
|
|
1009
1108
|
windowDays: 14,
|
|
1010
1109
|
threshold: 1
|
|
1011
1110
|
}),
|
|
1012
|
-
|
|
1013
|
-
maxInputTokens: z.number().default(5e4),
|
|
1014
|
-
maxOutputTokens: z.number().default(8e3),
|
|
1015
|
-
maxGithubApiCalls: z.number().default(20)
|
|
1016
|
-
}).default({
|
|
1017
|
-
maxInputTokens: 5e4,
|
|
1018
|
-
maxOutputTokens: 8e3,
|
|
1019
|
-
maxGithubApiCalls: 20
|
|
1020
|
-
}),
|
|
1111
|
+
/** Pattern library */
|
|
1021
1112
|
patternLibrary: z.object({
|
|
1022
1113
|
enabled: z.boolean().default(true),
|
|
1023
1114
|
minConfidence: z.number().min(0).max(100).default(80)
|
|
@@ -1025,10 +1116,48 @@ const SreAgentConfigSchema = z.object({
|
|
|
1025
1116
|
enabled: true,
|
|
1026
1117
|
minConfidence: 80
|
|
1027
1118
|
}),
|
|
1028
|
-
|
|
1029
|
-
|
|
1119
|
+
/** Slack integration */
|
|
1120
|
+
slack: z.object({
|
|
1121
|
+
workspaceId: z.string().optional(),
|
|
1122
|
+
channelId: z.string().optional(),
|
|
1123
|
+
approverIds: z.string().default("")
|
|
1124
|
+
}).default({ approverIds: "" })
|
|
1030
1125
|
});
|
|
1031
1126
|
/**
|
|
1127
|
+
* SRE Agent Config — stored in AdminSettings.
|
|
1128
|
+
*
|
|
1129
|
+
* Structure: `{ repos[] }`. Each repo is fully self-contained.
|
|
1130
|
+
* v1 (flat) configs are transparently migrated via `z.preprocess`.
|
|
1131
|
+
*/
|
|
1132
|
+
const SreAgentConfigSchema = z.preprocess((raw) => {
|
|
1133
|
+
const obj = raw && typeof raw === "object" ? raw : {};
|
|
1134
|
+
if (obj.repos) return obj;
|
|
1135
|
+
const github = obj.github ?? {};
|
|
1136
|
+
const legacyRepo = github.owner && github.repo ? {
|
|
1137
|
+
owner: github.owner,
|
|
1138
|
+
repo: github.repo,
|
|
1139
|
+
reviewers: github.reviewers || "",
|
|
1140
|
+
webhookSecret: github.webhookSecret || "",
|
|
1141
|
+
callbackToken: github.callbackToken || "",
|
|
1142
|
+
...obj.enabled !== void 0 ? { enabled: obj.enabled } : {},
|
|
1143
|
+
...obj.modelId !== void 0 ? { modelId: obj.modelId } : {},
|
|
1144
|
+
...obj.maxDiffLines !== void 0 ? { maxDiffLines: obj.maxDiffLines } : {},
|
|
1145
|
+
...obj.maxFixesPerDay !== void 0 ? { maxFixesPerDay: obj.maxFixesPerDay } : {},
|
|
1146
|
+
...obj.maxRevisions !== void 0 ? { maxRevisions: obj.maxRevisions } : {},
|
|
1147
|
+
...obj.dryRun !== void 0 ? { dryRun: obj.dryRun } : {},
|
|
1148
|
+
...obj.gates ? { gates: obj.gates } : {},
|
|
1149
|
+
...obj.circuitBreaker ? { circuitBreaker: obj.circuitBreaker } : {},
|
|
1150
|
+
...obj.tokenBudget ? { tokenBudget: obj.tokenBudget } : {},
|
|
1151
|
+
...obj.recurrence ? { recurrence: obj.recurrence } : {},
|
|
1152
|
+
...obj.patternLibrary ? { patternLibrary: obj.patternLibrary } : {},
|
|
1153
|
+
...obj.allowedFilePatterns ? { allowedFilePatterns: obj.allowedFilePatterns } : {},
|
|
1154
|
+
...obj.blockedFilePatterns ? { blockedFilePatterns: obj.blockedFilePatterns } : {},
|
|
1155
|
+
...obj.sources ? { sources: obj.sources } : {},
|
|
1156
|
+
...obj.slack ? { slack: obj.slack } : {}
|
|
1157
|
+
} : null;
|
|
1158
|
+
return { repos: legacyRepo ? [legacyRepo] : [] };
|
|
1159
|
+
}, z.object({ repos: z.array(SreRepoConfigSchema).default([]) }));
|
|
1160
|
+
/**
|
|
1032
1161
|
* Configuration schema for the SecOps Triage feature.
|
|
1033
1162
|
*
|
|
1034
1163
|
* Controls automatic GitHub issue creation for critical/high ZAP scan findings.
|
|
@@ -1037,9 +1166,13 @@ const SreAgentConfigSchema = z.object({
|
|
|
1037
1166
|
* Setting name: 'secopsTriageConfig'
|
|
1038
1167
|
*/
|
|
1039
1168
|
const SecopsTriageConfigSchema = z.object({
|
|
1169
|
+
/** Master kill switch */
|
|
1040
1170
|
enabled: z.boolean().default(false),
|
|
1171
|
+
/** GitHub repository to create issues in (e.g. 'MillionOnMars/lumina5') */
|
|
1041
1172
|
githubRepo: z.string().default("MillionOnMars/lumina5"),
|
|
1173
|
+
/** Minimum ZAP severity level that triggers issue creation */
|
|
1042
1174
|
severityThreshold: z.enum(["critical", "high"]).default("high"),
|
|
1175
|
+
/** Map ZAP severity levels to GitHub issue priority labels */
|
|
1043
1176
|
severityToPriority: z.object({
|
|
1044
1177
|
critical: z.enum(["P0", "P1"]).default("P0"),
|
|
1045
1178
|
high: z.enum(["P0", "P1"]).default("P1")
|
|
@@ -1047,11 +1180,17 @@ const SecopsTriageConfigSchema = z.object({
|
|
|
1047
1180
|
critical: "P0",
|
|
1048
1181
|
high: "P1"
|
|
1049
1182
|
}),
|
|
1183
|
+
/** Maximum number of issues to create per scan (sorted by severity, highest first) */
|
|
1050
1184
|
maxIssuesPerScan: z.number().min(1).max(100).default(20),
|
|
1185
|
+
/** Slack workspace ID to use for posting (must match an active workspace in Admin → Slack Workspaces). Falls back to first active workspace if not set. */
|
|
1051
1186
|
slackWorkspaceId: z.string().optional(),
|
|
1187
|
+
/** Slack channel ID to post triage summary to (optional) */
|
|
1052
1188
|
slackChannelId: z.string().optional(),
|
|
1189
|
+
/** Enable LLM enrichment: per-finding remediation guidance + overall health assessment */
|
|
1053
1190
|
llmEnrichment: z.boolean().default(false),
|
|
1191
|
+
/** LLM model ID to use for enrichment (e.g. 'claude-3-5-haiku-20241022') */
|
|
1054
1192
|
modelId: z.string().optional(),
|
|
1193
|
+
/** Log actions without creating real GitHub issues or posting to Slack */
|
|
1055
1194
|
dryRun: z.boolean().default(false)
|
|
1056
1195
|
}).refine((data) => !data.llmEnrichment || !!data.modelId, {
|
|
1057
1196
|
message: "modelId is required when llmEnrichment is enabled",
|
|
@@ -1100,7 +1239,6 @@ let SupportedFabFileMimeTypes = /* @__PURE__ */ function(SupportedFabFileMimeTyp
|
|
|
1100
1239
|
SupportedFabFileMimeTypes["CONF"] = "text/plain";
|
|
1101
1240
|
return SupportedFabFileMimeTypes;
|
|
1102
1241
|
}({});
|
|
1103
|
-
SupportedFabFileMimeTypes.TS, SupportedFabFileMimeTypes.JS, SupportedFabFileMimeTypes.CSS, SupportedFabFileMimeTypes.PY, SupportedFabFileMimeTypes.JAVA, SupportedFabFileMimeTypes.CPP, SupportedFabFileMimeTypes.CS, SupportedFabFileMimeTypes.PHP, SupportedFabFileMimeTypes.RUBY, SupportedFabFileMimeTypes.GO, SupportedFabFileMimeTypes.SWIFT, SupportedFabFileMimeTypes.KOTLIN, SupportedFabFileMimeTypes.RUST;
|
|
1104
1242
|
/**
|
|
1105
1243
|
* ========================================
|
|
1106
1244
|
* Client to Server Actions
|
|
@@ -1873,6 +2011,7 @@ const TavernHeartbeatLogAction = z.object({
|
|
|
1873
2011
|
/** Server → Client: real-time quest board update (replaces polling) */
|
|
1874
2012
|
const TavernQuestUpdateAction = z.object({
|
|
1875
2013
|
action: z.literal("tavern_quest_update"),
|
|
2014
|
+
/** The full refreshed quest list (top-level only, no sub-quests) */
|
|
1876
2015
|
quests: z.array(z.object({
|
|
1877
2016
|
_id: z.string(),
|
|
1878
2017
|
title: z.string(),
|
|
@@ -1936,6 +2075,26 @@ const CcAgentStatus = z.enum([
|
|
|
1936
2075
|
"disconnected"
|
|
1937
2076
|
]);
|
|
1938
2077
|
/**
|
|
2078
|
+
* Engine behind a code agent. Drives chip color in the Tavern and gates which
|
|
2079
|
+
* command shapes the server will dispatch to the bridge.
|
|
2080
|
+
* - `claude`: the official Claude Code CLI, surfaced via hooks + transcript
|
|
2081
|
+
* tail (observer+). Read-only — no interactive commands.
|
|
2082
|
+
* - `sdk-embedded`: Claude Agent SDK hosted in-process inside cc-bridge.
|
|
2083
|
+
* Interactive — prompt composer + permission resolver + abort.
|
|
2084
|
+
* - `b4m-cli`: the in-house `@bike4mind/cli` announcing over cc-bridge
|
|
2085
|
+
* loopback. Interactive.
|
|
2086
|
+
*/
|
|
2087
|
+
const CcAgentSource = z.enum([
|
|
2088
|
+
"claude",
|
|
2089
|
+
"sdk-embedded",
|
|
2090
|
+
"b4m-cli"
|
|
2091
|
+
]);
|
|
2092
|
+
/**
|
|
2093
|
+
* Capabilities an agent exposes. Gates interactive UI in `CodeAgentModal`.
|
|
2094
|
+
* Open-ended for forward-compat; v1 recognises `interactive` only.
|
|
2095
|
+
*/
|
|
2096
|
+
const CcAgentCapability = z.enum(["interactive"]);
|
|
2097
|
+
/**
|
|
1939
2098
|
* Bridge → Server: announce a new Claude Code session.
|
|
1940
2099
|
*
|
|
1941
2100
|
* The server persists an ActiveCodeAgent record keyed by instanceId, picks a
|
|
@@ -1949,12 +2108,27 @@ const CcBridgeAccessTokenSchema = z.string().max(512).optional();
|
|
|
1949
2108
|
const CcAgentRegisterAction = z.object({
|
|
1950
2109
|
action: z.literal("cc_agent_register"),
|
|
1951
2110
|
accessToken: CcBridgeAccessTokenSchema,
|
|
2111
|
+
/** Stable ID the bridge generates per CC session (uuid). */
|
|
1952
2112
|
instanceId: z.string().min(1).max(128),
|
|
2113
|
+
/** ID of the paired device (from `CcBridgeDevice`). */
|
|
1953
2114
|
deviceId: z.string().min(1).max(128),
|
|
2115
|
+
/** Display name — typically the basename of workspacePath. */
|
|
1954
2116
|
workspaceName: z.string().min(1).max(200),
|
|
2117
|
+
/** Absolute cwd of the CC session on the user's machine. Bound below
|
|
2118
|
+
* Linux PATH_MAX (4096) to keep broadcasts and Mongo docs small. */
|
|
1955
2119
|
workspacePath: z.string().max(1024),
|
|
2120
|
+
/** Claude Code CLI version if the bridge can detect it. */
|
|
1956
2121
|
claudeVersion: z.string().max(32).optional(),
|
|
1957
|
-
|
|
2122
|
+
/** ISO timestamp the CC session started. */
|
|
2123
|
+
startedAt: z.string().max(40),
|
|
2124
|
+
/** Engine behind this session. Drives chip color + command dispatch. Older
|
|
2125
|
+
* bridges that predate the interactive path don't send this; server defaults
|
|
2126
|
+
* to `'claude'` (observer+) to preserve their current behavior. */
|
|
2127
|
+
source: CcAgentSource.optional(),
|
|
2128
|
+
/** Capabilities this session supports. Gates interactive UI affordances in
|
|
2129
|
+
* the modal. Absent == read-only (observer+). `max(8)` is a belt-and-braces
|
|
2130
|
+
* bound; we only recognise `'interactive'` today. */
|
|
2131
|
+
capabilities: z.array(CcAgentCapability).max(8).optional()
|
|
1958
2132
|
});
|
|
1959
2133
|
/**
|
|
1960
2134
|
* Bridge → Server: stream an event for an already-registered session.
|
|
@@ -1964,39 +2138,68 @@ const CcAgentRegisterAction = z.object({
|
|
|
1964
2138
|
* 2. Tailing the session's transcript.jsonl in `~/.claude/projects/`
|
|
1965
2139
|
* (observer+ mode) → `message`, `tool_use`, `tool_result`.
|
|
1966
2140
|
*
|
|
1967
|
-
*
|
|
1968
|
-
*
|
|
1969
|
-
* `
|
|
2141
|
+
* The interactive SDK-embed path (inside cc-bridge, per D13) and B4M CLI
|
|
2142
|
+
* announces emit the same shapes plus the `permission_request` /
|
|
2143
|
+
* `permission_resolved` variants below for the prompt-the-user flow.
|
|
1970
2144
|
*/
|
|
1971
2145
|
const CcAgentEventPayload = z.discriminatedUnion("type", [
|
|
1972
2146
|
z.object({
|
|
1973
2147
|
type: z.literal("status"),
|
|
1974
2148
|
status: CcAgentStatus,
|
|
2149
|
+
/** Optional human-readable reason for the status change. Bounded here
|
|
2150
|
+
* to defend against oversized broadcasts; the server also truncates to
|
|
2151
|
+
* MAX_SUMMARY_LEN before persisting. */
|
|
1975
2152
|
text: z.string().max(4e3).optional()
|
|
1976
2153
|
}),
|
|
1977
2154
|
z.object({
|
|
1978
2155
|
type: z.literal("message"),
|
|
1979
2156
|
role: z.enum(["user", "assistant"]),
|
|
2157
|
+
/** Full message text (bridge clamps to this cap before sending). */
|
|
1980
2158
|
text: z.string().max(4e3)
|
|
1981
2159
|
}),
|
|
1982
2160
|
z.object({
|
|
1983
2161
|
type: z.literal("tool_use"),
|
|
2162
|
+
/** Tool name as emitted by Claude (e.g. `Bash`, `Read`, `Edit`). */
|
|
1984
2163
|
tool: z.string().min(1).max(128),
|
|
2164
|
+
/** Stable ID so a later `tool_result` can be matched back. */
|
|
1985
2165
|
toolUseId: z.string().min(1).max(128),
|
|
2166
|
+
/** Human-readable summary of the tool input (e.g. command, file path).
|
|
2167
|
+
* Bridge pre-summarizes rich inputs; we don't store raw JSON blobs. */
|
|
1986
2168
|
text: z.string().max(4e3).optional()
|
|
1987
2169
|
}),
|
|
1988
2170
|
z.object({
|
|
1989
2171
|
type: z.literal("tool_result"),
|
|
1990
2172
|
tool: z.string().min(1).max(128).optional(),
|
|
1991
2173
|
toolUseId: z.string().min(1).max(128),
|
|
2174
|
+
/** Result body (truncated by the bridge to this cap). */
|
|
1992
2175
|
text: z.string().max(4e3).optional(),
|
|
1993
2176
|
isError: z.boolean().optional()
|
|
2177
|
+
}),
|
|
2178
|
+
z.object({
|
|
2179
|
+
type: z.literal("permission_request"),
|
|
2180
|
+
/** Opaque id the agent generated. The resolve command must echo it. */
|
|
2181
|
+
requestId: z.string().min(1).max(128),
|
|
2182
|
+
/** Tool (or broader capability) the agent wants to use, e.g. `Bash`. */
|
|
2183
|
+
toolName: z.string().min(1).max(128),
|
|
2184
|
+
/** Human-readable summary of what the agent wants to do. Bridge/CLI
|
|
2185
|
+
* pre-summarizes rich input blobs; this is display-safe. */
|
|
2186
|
+
input: z.string().max(4e3).optional()
|
|
2187
|
+
}),
|
|
2188
|
+
z.object({
|
|
2189
|
+
type: z.literal("permission_resolved"),
|
|
2190
|
+
requestId: z.string().min(1).max(128),
|
|
2191
|
+
allow: z.boolean(),
|
|
2192
|
+
/** Who resolved it; `'auto'` covers SDK/CLI local rules. */
|
|
2193
|
+
resolvedBy: z.enum(["user", "auto"]).optional()
|
|
1994
2194
|
})
|
|
1995
2195
|
]);
|
|
1996
2196
|
const CcAgentEventAction = z.object({
|
|
1997
2197
|
action: z.literal("cc_agent_event"),
|
|
1998
2198
|
accessToken: CcBridgeAccessTokenSchema,
|
|
1999
2199
|
instanceId: z.string().min(1).max(128),
|
|
2200
|
+
/** ISO timestamp when the event occurred on the user's machine. `.datetime()`
|
|
2201
|
+
* gives an explicit first-line validator; the handler still defends with a
|
|
2202
|
+
* `new Date()` fallback for older bridges. */
|
|
2000
2203
|
timestamp: z.string().datetime().max(40),
|
|
2001
2204
|
event: CcAgentEventPayload
|
|
2002
2205
|
});
|
|
@@ -2012,6 +2215,38 @@ const CcAgentDisconnectAction = z.object({
|
|
|
2012
2215
|
instanceId: z.string().min(1).max(128),
|
|
2013
2216
|
reason: z.string().max(200).optional()
|
|
2014
2217
|
});
|
|
2218
|
+
/**
|
|
2219
|
+
* Server → Bridge: a user-driven command the bridge should apply to one of
|
|
2220
|
+
* its active sessions. Dispatched by `POST /api/cc-bridge/command` after the
|
|
2221
|
+
* server validates ownership + rate-limits, pushed over the bridge's WS via
|
|
2222
|
+
* the existing `sendToConnection` mechanism.
|
|
2223
|
+
*
|
|
2224
|
+
* The bridge is responsible for routing to the right local session and (for
|
|
2225
|
+
* external engines like the B4M CLI) forwarding over its loopback back-channel.
|
|
2226
|
+
*/
|
|
2227
|
+
const CcAgentCommandPayload = z.discriminatedUnion("type", [
|
|
2228
|
+
z.object({
|
|
2229
|
+
type: z.literal("send_prompt"),
|
|
2230
|
+
/** Full prompt text. Same cap as user-turn messages; UI will enforce. */
|
|
2231
|
+
text: z.string().min(1).max(4e3)
|
|
2232
|
+
}),
|
|
2233
|
+
z.object({
|
|
2234
|
+
type: z.literal("resolve_permission"),
|
|
2235
|
+
/** Must match the `requestId` from a prior `permission_request` event. */
|
|
2236
|
+
requestId: z.string().min(1).max(128),
|
|
2237
|
+
allow: z.boolean()
|
|
2238
|
+
}),
|
|
2239
|
+
z.object({ type: z.literal("abort") })
|
|
2240
|
+
]);
|
|
2241
|
+
const CcAgentCommandAction = z.object({
|
|
2242
|
+
action: z.literal("cc_agent_command"),
|
|
2243
|
+
/** Target session on the bridge; bridge looks it up in its session map. */
|
|
2244
|
+
instanceId: z.string().min(1).max(128),
|
|
2245
|
+
/** Server-minted correlation id so the client can follow up on failures
|
|
2246
|
+
* without racing against the eventual event echo. */
|
|
2247
|
+
requestId: z.string().min(1).max(128),
|
|
2248
|
+
command: CcAgentCommandPayload
|
|
2249
|
+
});
|
|
2015
2250
|
const SessionCreatedAction = shareableDocumentSchema.extend({
|
|
2016
2251
|
action: z.literal("session.created"),
|
|
2017
2252
|
id: z.string(),
|
|
@@ -2102,7 +2337,8 @@ z.discriminatedUnion("action", [
|
|
|
2102
2337
|
TavernQuestUpdateAction,
|
|
2103
2338
|
TavernStockUpdateAction,
|
|
2104
2339
|
JupyterNotebookProgressAction,
|
|
2105
|
-
DataLakeBatchProgressAction
|
|
2340
|
+
DataLakeBatchProgressAction,
|
|
2341
|
+
CcAgentCommandAction
|
|
2106
2342
|
]);
|
|
2107
2343
|
z.object({
|
|
2108
2344
|
model: z.string(),
|
|
@@ -2618,10 +2854,15 @@ z$1.object({
|
|
|
2618
2854
|
fileName: z$1.string(),
|
|
2619
2855
|
mimeType: z$1.string(),
|
|
2620
2856
|
fileSize: z$1.number(),
|
|
2857
|
+
/** The path to the file */
|
|
2621
2858
|
path: z$1.string().optional(),
|
|
2859
|
+
/** SHA-256 content hash for deduplication */
|
|
2622
2860
|
contentHash: z$1.string().optional(),
|
|
2861
|
+
/** Batch ID for data lake uploads */
|
|
2623
2862
|
batchId: z$1.string().optional(),
|
|
2863
|
+
/** Original relative path from folder upload */
|
|
2624
2864
|
relativePath: z$1.string().optional(),
|
|
2865
|
+
/** Tags to apply to the file on creation */
|
|
2625
2866
|
tags: z$1.array(z$1.object({
|
|
2626
2867
|
name: z$1.string(),
|
|
2627
2868
|
strength: z$1.number()
|
|
@@ -2633,7 +2874,9 @@ z$1.object({
|
|
|
2633
2874
|
mimeType: z$1.string(),
|
|
2634
2875
|
fileSize: z$1.number(),
|
|
2635
2876
|
fileContent: z$1.string().optional(),
|
|
2877
|
+
/** Set to true if the file should be publicly accessible */
|
|
2636
2878
|
public: z$1.boolean().optional(),
|
|
2879
|
+
/** The prefix to use for the file path */
|
|
2637
2880
|
prefix: z$1.string().optional()
|
|
2638
2881
|
});
|
|
2639
2882
|
/**
|
|
@@ -2648,12 +2891,12 @@ const BFL_SAFETY_TOLERANCE = {
|
|
|
2648
2891
|
* List of image models supported by BlackForest Labs
|
|
2649
2892
|
*/
|
|
2650
2893
|
const BFL_IMAGE_MODELS = [
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2894
|
+
"flux-pro-1.1",
|
|
2895
|
+
"flux-pro",
|
|
2896
|
+
"flux-pro-1.1-ultra",
|
|
2897
|
+
"flux-pro-1.0-fill",
|
|
2898
|
+
"flux-kontext-pro",
|
|
2899
|
+
"flux-kontext-max"
|
|
2657
2900
|
];
|
|
2658
2901
|
const CommonBFLParams = z.object({
|
|
2659
2902
|
prompt: z.string().nullable().optional(),
|
|
@@ -2689,12 +2932,12 @@ CommonBFLParams.extend({
|
|
|
2689
2932
|
* XAI/Grok Image Models
|
|
2690
2933
|
* Based on https://docs.x.ai/docs/guides/image-generations
|
|
2691
2934
|
*/
|
|
2692
|
-
const XAI_IMAGE_MODELS = [
|
|
2935
|
+
const XAI_IMAGE_MODELS = ["grok-2-image"];
|
|
2693
2936
|
/**
|
|
2694
2937
|
* Gemini Image Models (Nano Banana)
|
|
2695
2938
|
* Based on https://ai.google.dev/gemini-api/docs/image-generation
|
|
2696
2939
|
*/
|
|
2697
|
-
const GEMINI_IMAGE_MODELS = [
|
|
2940
|
+
const GEMINI_IMAGE_MODELS = ["gemini-2.5-flash-image", "gemini-3-pro-image-preview"];
|
|
2698
2941
|
z.object({
|
|
2699
2942
|
prompt: z.string().min(1),
|
|
2700
2943
|
n: z.number().min(1).max(8).prefault(1).optional(),
|
|
@@ -2736,9 +2979,10 @@ const ChatCompletionCreateInputSchema = z.object({
|
|
|
2736
2979
|
})).optional()
|
|
2737
2980
|
});
|
|
2738
2981
|
const OPENAI_IMAGE_MODELS = [
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2982
|
+
"gpt-image-1",
|
|
2983
|
+
"gpt-image-1.5",
|
|
2984
|
+
"gpt-image-1-mini",
|
|
2985
|
+
"gpt-image-2"
|
|
2742
2986
|
];
|
|
2743
2987
|
const ALL_IMAGE_MODELS = [
|
|
2744
2988
|
...OPENAI_IMAGE_MODELS,
|
|
@@ -2751,9 +2995,23 @@ const OPENAI_GPT_IMAGE_1_IMAGE_SIZES = [
|
|
|
2751
2995
|
"1024x1536",
|
|
2752
2996
|
"1536x1024"
|
|
2753
2997
|
];
|
|
2998
|
+
const OPENAI_GPT_IMAGE_2_IMAGE_SIZES = [
|
|
2999
|
+
"1024x1024",
|
|
3000
|
+
"1536x1024",
|
|
3001
|
+
"1024x1536",
|
|
3002
|
+
"2048x2048",
|
|
3003
|
+
"2048x1152",
|
|
3004
|
+
"3840x2160",
|
|
3005
|
+
"2160x3840",
|
|
3006
|
+
"auto"
|
|
3007
|
+
];
|
|
2754
3008
|
const BFL_IMAGE_SIZES = ["1024x768"];
|
|
2755
3009
|
const OPENAI_IMAGE_SIZES = [...OPENAI_GPT_IMAGE_1_IMAGE_SIZES];
|
|
2756
|
-
const ALL_IMAGE_SIZES = [
|
|
3010
|
+
const ALL_IMAGE_SIZES = [
|
|
3011
|
+
...OPENAI_IMAGE_SIZES,
|
|
3012
|
+
...OPENAI_GPT_IMAGE_2_IMAGE_SIZES,
|
|
3013
|
+
...BFL_IMAGE_SIZES
|
|
3014
|
+
];
|
|
2757
3015
|
z.enum(OPENAI_IMAGE_SIZES);
|
|
2758
3016
|
const ImageSizeSchema = z.union([z.enum(ALL_IMAGE_SIZES), z.string().regex(/^\d+x\d+$/, { error: "Size must be in format 'widthxheight'" })]);
|
|
2759
3017
|
const OpenAIImageQualitySchema = z.enum([
|
|
@@ -2761,7 +3019,8 @@ const OpenAIImageQualitySchema = z.enum([
|
|
|
2761
3019
|
"hd",
|
|
2762
3020
|
"low",
|
|
2763
3021
|
"medium",
|
|
2764
|
-
"high"
|
|
3022
|
+
"high",
|
|
3023
|
+
"auto"
|
|
2765
3024
|
]);
|
|
2766
3025
|
const OpenAIImageStyleSchema = z.enum(["vivid", "natural"]);
|
|
2767
3026
|
/**
|
|
@@ -2769,8 +3028,8 @@ const OpenAIImageStyleSchema = z.enum(["vivid", "natural"]);
|
|
|
2769
3028
|
* Prevents Zod validation failures when clients send stale persisted model names.
|
|
2770
3029
|
*/
|
|
2771
3030
|
const LEGACY_IMAGE_MODEL_MAP = {
|
|
2772
|
-
"dall-e-3":
|
|
2773
|
-
"dall-e-2":
|
|
3031
|
+
"dall-e-3": "gpt-image-1",
|
|
3032
|
+
"dall-e-2": "gpt-image-1"
|
|
2774
3033
|
};
|
|
2775
3034
|
const OpenAIImageGenerationInput = z.object({
|
|
2776
3035
|
prompt: z.string(),
|
|
@@ -2939,6 +3198,9 @@ z.enum([
|
|
|
2939
3198
|
"WolframAlphaKey",
|
|
2940
3199
|
"FmpApiKey",
|
|
2941
3200
|
"EnableFmpFinancialData",
|
|
3201
|
+
"PotionQuestApiKey",
|
|
3202
|
+
"EnablePotionQuest",
|
|
3203
|
+
"EnableTavernQuestBoardContext",
|
|
2942
3204
|
"VectorThreshold",
|
|
2943
3205
|
"bflApiKey",
|
|
2944
3206
|
"EnableMCPServer",
|
|
@@ -3211,7 +3473,13 @@ const WhatsNewSyncConfigSchema = z.object({
|
|
|
3211
3473
|
"failed"
|
|
3212
3474
|
]).optional(),
|
|
3213
3475
|
lastSyncModalId: z.string().optional(),
|
|
3476
|
+
/** Error message from last sync attempt (only populated when lastSyncResult is 'failed') */
|
|
3214
3477
|
lastSyncError: z.string().max(500).optional(),
|
|
3478
|
+
/**
|
|
3479
|
+
* Admin override for distribution URL.
|
|
3480
|
+
* Must be validated against domain allowlist (CloudFront/S3 only) before saving.
|
|
3481
|
+
* Takes precedence over SST secret when set.
|
|
3482
|
+
*/
|
|
3215
3483
|
distributionUrlOverride: z.url().nullable().optional()
|
|
3216
3484
|
});
|
|
3217
3485
|
const CONTEXT_TELEMETRY_VALIDATION_LIMITS = {
|
|
@@ -3302,31 +3570,57 @@ const CONTEXT_TELEMETRY_VALIDATION_LIMITS = {
|
|
|
3302
3570
|
};
|
|
3303
3571
|
const CT = CONTEXT_TELEMETRY_VALIDATION_LIMITS;
|
|
3304
3572
|
const ContextTelemetryAlertsSchema = z.object({
|
|
3573
|
+
/** Whether telemetry alerts are enabled */
|
|
3305
3574
|
enabled: z.boolean().default(false),
|
|
3575
|
+
/** MongoDB ObjectId of the Slack workspace to use */
|
|
3306
3576
|
slackWorkspaceId: z.string().optional(),
|
|
3577
|
+
/** Slack channel ID for posting anomaly alerts */
|
|
3307
3578
|
slackChannelId: z.string().optional(),
|
|
3579
|
+
/** GitHub repository owner (user or organization) */
|
|
3308
3580
|
githubOwner: z.string().optional(),
|
|
3581
|
+
/** GitHub repository name */
|
|
3309
3582
|
githubRepo: z.string().optional(),
|
|
3583
|
+
/** Whether to automatically create GitHub issues for anomalies that meet the threshold */
|
|
3310
3584
|
autoCreateIssues: z.boolean().default(false),
|
|
3585
|
+
/** Model ID for priority analysis (e.g., 'gpt-4o-mini', 'claude-3-haiku') */
|
|
3311
3586
|
modelId: z.string().optional(),
|
|
3587
|
+
/** Temperature for LLM responses (lower = more deterministic) */
|
|
3312
3588
|
temperature: z.number().min(CT.temperature.min).max(CT.temperature.max).default(CT.temperature.default),
|
|
3589
|
+
/** Maximum tokens for LLM response */
|
|
3313
3590
|
maxTokens: z.number().min(CT.maxTokens.min).max(CT.maxTokens.max).default(CT.maxTokens.default),
|
|
3591
|
+
/** Timeout for LLM calls in milliseconds */
|
|
3314
3592
|
timeoutMs: z.number().min(CT.timeoutMs.min).max(CT.timeoutMs.max).default(CT.timeoutMs.default),
|
|
3593
|
+
/** Minimum anomaly score to use LLM analysis. Lower scores use rule-based analysis (saves cost). */
|
|
3315
3594
|
llmAnalysisThreshold: z.number().min(CT.llmAnalysisThreshold.min).max(CT.llmAnalysisThreshold.max).default(CT.llmAnalysisThreshold.default),
|
|
3595
|
+
/** Minimum anomaly score to trigger alerts (default: 30) */
|
|
3316
3596
|
alertThreshold: z.number().min(CT.alertThreshold.min).max(CT.alertThreshold.max).default(CT.alertThreshold.default),
|
|
3597
|
+
/** Score threshold that triggers @here mentions (default: 50) */
|
|
3317
3598
|
criticalThreshold: z.number().min(CT.criticalThreshold.min).max(CT.criticalThreshold.max).default(CT.criticalThreshold.default),
|
|
3599
|
+
/** Deduplication window in minutes (default: 5) - for Slack alerts */
|
|
3318
3600
|
dedupWindowMinutes: z.number().min(CT.dedupWindowMinutes.min).max(CT.dedupWindowMinutes.max).default(CT.dedupWindowMinutes.default),
|
|
3601
|
+
/** Days to look back for closed issues when checking for regressions (default: 30) */
|
|
3319
3602
|
regressionLookbackDays: z.number().min(CT.regressionLookbackDays.min).max(CT.regressionLookbackDays.max).default(CT.regressionLookbackDays.default),
|
|
3603
|
+
/** Hours after issue closure before same fingerprint is considered regression (default: 48) */
|
|
3320
3604
|
regressionGracePeriodHours: z.number().min(CT.regressionGracePeriodHours.min).max(CT.regressionGracePeriodHours.max).default(CT.regressionGracePeriodHours.default),
|
|
3605
|
+
/** Hours before re-alerting Slack for same fingerprint - duplicate cooldown (default: 24) */
|
|
3321
3606
|
duplicateAlertCooldownHours: z.number().min(CT.duplicateAlertCooldownHours.min).max(CT.duplicateAlertCooldownHours.max).default(CT.duplicateAlertCooldownHours.default),
|
|
3607
|
+
/** Whether to use LLM for priority determination (falls back to rule-based if disabled/fails) */
|
|
3322
3608
|
enableLlmPriority: z.boolean().default(false),
|
|
3609
|
+
/** Custom prompt template for LLM priority analysis (optional) */
|
|
3323
3610
|
promptTemplate: z.string().min(CT.promptTemplate.min, `Prompt template must be at least ${CT.promptTemplate.min} characters`).max(CT.promptTemplate.max, `Prompt template cannot exceed ${CT.promptTemplate.max.toLocaleString()} characters`).trim().optional(),
|
|
3611
|
+
/** Number of days to look back for historical baseline computation (default: 7) */
|
|
3324
3612
|
baselineWindowDays: z.number().min(CT.baselineWindowDays.min).max(CT.baselineWindowDays.max).default(CT.baselineWindowDays.default),
|
|
3613
|
+
/** P95 response time target in milliseconds (default: 60000 = 60s) */
|
|
3325
3614
|
sloResponseTimeP95Ms: z.number().min(CT.sloResponseTimeP95Ms.min).max(CT.sloResponseTimeP95Ms.max).default(CT.sloResponseTimeP95Ms.default),
|
|
3615
|
+
/** Time to first token target in milliseconds (default: 5000 = 5s) */
|
|
3326
3616
|
sloFirstTokenTimeMs: z.number().min(CT.sloFirstTokenTimeMs.min).max(CT.sloFirstTokenTimeMs.max).default(CT.sloFirstTokenTimeMs.default),
|
|
3617
|
+
/** Acceptable error rate percentage (default: 2%) */
|
|
3327
3618
|
sloErrorRatePercent: z.number().min(CT.sloErrorRatePercent.min).max(CT.sloErrorRatePercent.max).default(CT.sloErrorRatePercent.default),
|
|
3619
|
+
/** Maximum acceptable context utilization percentage (default: 85%) */
|
|
3328
3620
|
sloContextUtilizationPercent: z.number().min(CT.sloContextUtilizationPercent.min).max(CT.sloContextUtilizationPercent.max).default(CT.sloContextUtilizationPercent.default),
|
|
3621
|
+
/** Maximum GitHub issues to create per hour (prevents runaway automation) */
|
|
3329
3622
|
maxIssuesPerHour: z.number().min(CT.maxIssuesPerHour.min).max(CT.maxIssuesPerHour.max).default(CT.maxIssuesPerHour.default),
|
|
3623
|
+
/** When enabled, logs what would happen without creating issues or sending alerts */
|
|
3330
3624
|
dryRun: z.boolean().default(false)
|
|
3331
3625
|
});
|
|
3332
3626
|
const LT = {
|
|
@@ -3702,6 +3996,10 @@ const API_SERVICE_GROUPS = {
|
|
|
3702
3996
|
{
|
|
3703
3997
|
key: "FmpApiKey",
|
|
3704
3998
|
order: 3
|
|
3999
|
+
},
|
|
4000
|
+
{
|
|
4001
|
+
key: "PotionQuestApiKey",
|
|
4002
|
+
order: 4
|
|
3705
4003
|
}
|
|
3706
4004
|
]
|
|
3707
4005
|
},
|
|
@@ -3882,6 +4180,14 @@ const API_SERVICE_GROUPS = {
|
|
|
3882
4180
|
{
|
|
3883
4181
|
key: "EnableFmpFinancialData",
|
|
3884
4182
|
order: 22
|
|
4183
|
+
},
|
|
4184
|
+
{
|
|
4185
|
+
key: "EnablePotionQuest",
|
|
4186
|
+
order: 23
|
|
4187
|
+
},
|
|
4188
|
+
{
|
|
4189
|
+
key: "EnableTavernQuestBoardContext",
|
|
4190
|
+
order: 24
|
|
3885
4191
|
}
|
|
3886
4192
|
]
|
|
3887
4193
|
},
|
|
@@ -4090,7 +4396,7 @@ const API_SERVICE_GROUPS = {
|
|
|
4090
4396
|
makeStringSetting({
|
|
4091
4397
|
key: "DefaultAPIModel",
|
|
4092
4398
|
name: "Default API Model",
|
|
4093
|
-
defaultValue:
|
|
4399
|
+
defaultValue: "gpt-5",
|
|
4094
4400
|
description: "The default AI model to use for API requests when no model is specified.",
|
|
4095
4401
|
options: CHAT_MODELS,
|
|
4096
4402
|
category: "AI",
|
|
@@ -4478,7 +4784,7 @@ makeStringSetting({
|
|
|
4478
4784
|
}), makeStringSetting({
|
|
4479
4785
|
key: "serverStatus",
|
|
4480
4786
|
name: "Server Status",
|
|
4481
|
-
defaultValue:
|
|
4787
|
+
defaultValue: "live",
|
|
4482
4788
|
description: "The current status of the server.",
|
|
4483
4789
|
category: "Admin",
|
|
4484
4790
|
group: API_SERVICE_GROUPS.ADMIN.id,
|
|
@@ -4650,6 +4956,31 @@ makeStringSetting({
|
|
|
4650
4956
|
category: "Experimental",
|
|
4651
4957
|
group: API_SERVICE_GROUPS.EXPERIMENTAL.id,
|
|
4652
4958
|
order: 13
|
|
4959
|
+
}), makeStringSetting({
|
|
4960
|
+
key: "PotionQuestApiKey",
|
|
4961
|
+
name: "PotionQuest API Key",
|
|
4962
|
+
defaultValue: "",
|
|
4963
|
+
description: "API key for PotionQuest (procedural RPG content: NPCs, encounters, quests, loot, prophecies, legendary affixes, dice rolls). Get one at potionquest.com.",
|
|
4964
|
+
category: "Tools",
|
|
4965
|
+
group: API_SERVICE_GROUPS.SEARCH.id,
|
|
4966
|
+
order: 4,
|
|
4967
|
+
isSensitive: true
|
|
4968
|
+
}), makeBooleanSetting({
|
|
4969
|
+
key: "EnablePotionQuest",
|
|
4970
|
+
name: "Enable PotionQuest Tools",
|
|
4971
|
+
defaultValue: false,
|
|
4972
|
+
description: "Whether to expose the PotionQuest dice + content generators as tools to tavern agents. Requires PotionQuestApiKey to be set.",
|
|
4973
|
+
category: "Experimental",
|
|
4974
|
+
group: API_SERVICE_GROUPS.EXPERIMENTAL.id,
|
|
4975
|
+
order: 14
|
|
4976
|
+
}), makeBooleanSetting({
|
|
4977
|
+
key: "EnableTavernQuestBoardContext",
|
|
4978
|
+
name: "Inject Quest Board Into Heartbeat Prompt",
|
|
4979
|
+
defaultValue: true,
|
|
4980
|
+
description: "Whether agent heartbeats see the quest board and their claimed quests in the system prompt. Toggle OFF for diagnostic isolation: when disabled, agents only see user @mentions and direct context, removing the pull from previously-claimed quests. The quest board itself still functions; only the prompt context is suppressed.",
|
|
4981
|
+
category: "Experimental",
|
|
4982
|
+
group: API_SERVICE_GROUPS.EXPERIMENTAL.id,
|
|
4983
|
+
order: 15
|
|
4653
4984
|
}), makeNumberSetting({
|
|
4654
4985
|
key: "VectorThreshold",
|
|
4655
4986
|
name: "Vector Threshold",
|
|
@@ -4795,7 +5126,7 @@ makeStringSetting({
|
|
|
4795
5126
|
}), makeStringSetting({
|
|
4796
5127
|
key: "defaultEmbeddingModel",
|
|
4797
5128
|
name: "Default Embedding Model",
|
|
4798
|
-
defaultValue:
|
|
5129
|
+
defaultValue: "text-embedding-ada-002",
|
|
4799
5130
|
description: "The default embedding model to use",
|
|
4800
5131
|
category: "AI",
|
|
4801
5132
|
group: API_SERVICE_GROUPS.EMBEDDING.id,
|
|
@@ -4967,7 +5298,7 @@ makeStringSetting({
|
|
|
4967
5298
|
}), makeStringSetting({
|
|
4968
5299
|
key: "EmailAnalysisModel",
|
|
4969
5300
|
name: "Email Analysis Model",
|
|
4970
|
-
defaultValue:
|
|
5301
|
+
defaultValue: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
4971
5302
|
description: "The AI model to use for email analysis. Defaults to Claude 4.5 Haiku via Bedrock.",
|
|
4972
5303
|
options: CHAT_MODELS,
|
|
4973
5304
|
category: "AI",
|
|
@@ -5201,11 +5532,15 @@ z.preprocess((val) => {
|
|
|
5201
5532
|
return val;
|
|
5202
5533
|
}, z.boolean());
|
|
5203
5534
|
const AnonymousSessionIdSchema = z.object({
|
|
5535
|
+
/** SHA256(userId|orgId|dailySalt|date) - cannot be reversed */
|
|
5204
5536
|
hash: z.string(),
|
|
5537
|
+
/** YYYY-MM-DD for salt lookup during deletion */
|
|
5205
5538
|
dateKey: z.string()
|
|
5206
5539
|
});
|
|
5207
5540
|
const SpanContextSchema = z.object({
|
|
5541
|
+
/** gen_ai.trace_id */
|
|
5208
5542
|
traceId: z.string(),
|
|
5543
|
+
/** gen_ai.span_id */
|
|
5209
5544
|
spanId: z.string()
|
|
5210
5545
|
});
|
|
5211
5546
|
const OperationSchema = z.object({
|
|
@@ -5223,6 +5558,7 @@ const OperationSchema = z.object({
|
|
|
5223
5558
|
]).optional()
|
|
5224
5559
|
});
|
|
5225
5560
|
const ModelTelemetrySchema = z.object({
|
|
5561
|
+
/** gen_ai.request.model */
|
|
5226
5562
|
modelId: z.string(),
|
|
5227
5563
|
provider: z.enum([
|
|
5228
5564
|
"anthropic",
|
|
@@ -5236,6 +5572,7 @@ const ModelTelemetrySchema = z.object({
|
|
|
5236
5572
|
fallbackReason: z.string().optional(),
|
|
5237
5573
|
originalModelId: z.string().optional(),
|
|
5238
5574
|
usedThinking: z.boolean(),
|
|
5575
|
+
/** Extended thinking tokens */
|
|
5239
5576
|
thinkingTokensUsed: z.number().optional(),
|
|
5240
5577
|
usedTools: z.boolean()
|
|
5241
5578
|
});
|
|
@@ -5248,6 +5585,7 @@ const SystemPromptDetailSchema = z.object({
|
|
|
5248
5585
|
"session",
|
|
5249
5586
|
"org"
|
|
5250
5587
|
]),
|
|
5588
|
+
/** e.g., "date_context", "tool_guidance" */
|
|
5251
5589
|
name: z.string(),
|
|
5252
5590
|
tokenCount: z.number(),
|
|
5253
5591
|
wasIncluded: z.boolean(),
|
|
@@ -5263,6 +5601,7 @@ const SystemPromptsTelemetrySchema = z.object({
|
|
|
5263
5601
|
duplicateCount: z.number()
|
|
5264
5602
|
});
|
|
5265
5603
|
const FeatureContributionSchema = z.object({
|
|
5604
|
+
/** e.g., "mementos", "quest_master", "deep_research" */
|
|
5266
5605
|
featureName: z.string(),
|
|
5267
5606
|
messagesAdded: z.number(),
|
|
5268
5607
|
tokenCount: z.number(),
|
|
@@ -5281,18 +5620,24 @@ const TokensBySourceSchema = z.object({
|
|
|
5281
5620
|
userPrompt: z.number()
|
|
5282
5621
|
});
|
|
5283
5622
|
z.object({
|
|
5623
|
+
/** gen_ai.usage.input_tokens */
|
|
5284
5624
|
inputTokens: z.number(),
|
|
5625
|
+
/** gen_ai.usage.output_tokens */
|
|
5285
5626
|
outputTokens: z.number(),
|
|
5286
5627
|
contextWindowLimit: z.number(),
|
|
5287
5628
|
utilizationPercentage: z.number(),
|
|
5288
5629
|
reservedOutputTokens: z.number(),
|
|
5289
5630
|
overflowDetected: z.boolean(),
|
|
5290
5631
|
overflowAmount: z.number().optional(),
|
|
5632
|
+
/** Token breakdown by source */
|
|
5291
5633
|
tokensBySource: TokensBySourceSchema
|
|
5292
5634
|
});
|
|
5293
5635
|
const CacheTelemetrySchema = z.object({
|
|
5636
|
+
/** Anthropic cache_read_input_tokens */
|
|
5294
5637
|
cacheReadTokens: z.number(),
|
|
5638
|
+
/** Anthropic cache_creation_input_tokens */
|
|
5295
5639
|
cacheWriteTokens: z.number(),
|
|
5640
|
+
/** 0-100% */
|
|
5296
5641
|
cacheHitRate: z.number(),
|
|
5297
5642
|
costSavingsPercent: z.number().optional()
|
|
5298
5643
|
});
|
|
@@ -5325,14 +5670,18 @@ const ToolErrorCategorySchema = z.enum([
|
|
|
5325
5670
|
]);
|
|
5326
5671
|
const ToolTelemetrySchema = z.object({
|
|
5327
5672
|
toolName: z.string(),
|
|
5673
|
+
/** MCP vs native tool */
|
|
5328
5674
|
isMcpTool: z.boolean(),
|
|
5675
|
+
/** For MCP tools */
|
|
5329
5676
|
mcpServerName: z.string().optional(),
|
|
5330
5677
|
invocationCount: z.number(),
|
|
5331
5678
|
successCount: z.number(),
|
|
5332
5679
|
failureCount: z.number(),
|
|
5333
5680
|
totalDurationMs: z.number(),
|
|
5334
5681
|
maxDurationMs: z.number(),
|
|
5682
|
+
/** Retry tracking */
|
|
5335
5683
|
retryCount: z.number(),
|
|
5684
|
+
/** Max 200 chars */
|
|
5336
5685
|
lastError: z.string().max(200).optional(),
|
|
5337
5686
|
errorCategories: z.array(ToolErrorCategorySchema).optional()
|
|
5338
5687
|
});
|
|
@@ -5361,6 +5710,7 @@ const PerformanceTelemetrySchema = z.object({
|
|
|
5361
5710
|
contextRetrievalMs: z.number().optional(),
|
|
5362
5711
|
modelInferenceMs: z.number().optional(),
|
|
5363
5712
|
toolExecutionMs: z.number().optional(),
|
|
5713
|
+
/** Latency percentiles for trend analysis */
|
|
5364
5714
|
latencyPercentiles: LatencyPercentilesSchema.optional()
|
|
5365
5715
|
});
|
|
5366
5716
|
const AnomalySeveritySchema = z.enum([
|
|
@@ -5380,17 +5730,29 @@ const PrimaryAnomalySchema = z.enum([
|
|
|
5380
5730
|
]);
|
|
5381
5731
|
const AnomaliesTelemetrySchema = z.object({
|
|
5382
5732
|
contextOverflow: z.boolean(),
|
|
5733
|
+
/** >= 90% */
|
|
5383
5734
|
highUtilization: z.boolean(),
|
|
5735
|
+
/** >= 95% */
|
|
5384
5736
|
criticalUtilization: z.boolean(),
|
|
5737
|
+
/** >= 50% */
|
|
5385
5738
|
highTruncation: z.boolean(),
|
|
5739
|
+
/** >= 75% */
|
|
5386
5740
|
criticalTruncation: z.boolean(),
|
|
5741
|
+
/** >= 3 failures */
|
|
5387
5742
|
toolFailureSpike: z.boolean(),
|
|
5743
|
+
/** > 30s */
|
|
5388
5744
|
toolTimeout: z.boolean(),
|
|
5745
|
+
/** > 5min */
|
|
5389
5746
|
subagentTimeout: z.boolean(),
|
|
5747
|
+
/** > 10s */
|
|
5390
5748
|
slowFirstToken: z.boolean(),
|
|
5749
|
+
/** > 60s */
|
|
5391
5750
|
slowTotalResponse: z.boolean(),
|
|
5751
|
+
/** 0-100 */
|
|
5392
5752
|
anomalyScore: z.number().min(0).max(100),
|
|
5753
|
+
/** Severity mapping */
|
|
5393
5754
|
severity: AnomalySeveritySchema,
|
|
5755
|
+
/** Pattern-based dedup key, e.g., "tool_failure_claude-3-5-sonnet_delegate-to-agent" */
|
|
5394
5756
|
dedupKey: z.string(),
|
|
5395
5757
|
primaryAnomaly: PrimaryAnomalySchema
|
|
5396
5758
|
});
|
|
@@ -5406,19 +5768,25 @@ const RequestMetadataSchema = z.object({
|
|
|
5406
5768
|
enabledFeatures: z.array(z.string())
|
|
5407
5769
|
});
|
|
5408
5770
|
const ContextWindowTelemetryWithOptionalSourceSchema = z.object({
|
|
5771
|
+
/** gen_ai.usage.input_tokens */
|
|
5409
5772
|
inputTokens: z.number(),
|
|
5773
|
+
/** gen_ai.usage.output_tokens */
|
|
5410
5774
|
outputTokens: z.number(),
|
|
5411
5775
|
contextWindowLimit: z.number(),
|
|
5412
5776
|
utilizationPercentage: z.number(),
|
|
5413
5777
|
reservedOutputTokens: z.number(),
|
|
5414
5778
|
overflowDetected: z.boolean(),
|
|
5415
5779
|
overflowAmount: z.number().optional(),
|
|
5780
|
+
/** Token breakdown by source (enhanced only) */
|
|
5416
5781
|
tokensBySource: TokensBySourceSchema.optional()
|
|
5417
5782
|
});
|
|
5418
5783
|
const ContextTelemetrySchema = z.object({
|
|
5419
5784
|
schemaVersion: z.enum(["1.0", "1.1"]),
|
|
5785
|
+
/** ISO 8601 */
|
|
5420
5786
|
timestamp: z.string(),
|
|
5787
|
+
/** Self-monitoring: time to capture telemetry */
|
|
5421
5788
|
captureOverheadMs: z.number(),
|
|
5789
|
+
/** Capture level: basic or enhanced */
|
|
5422
5790
|
captureLevel: z.enum(["basic", "enhanced"]).optional(),
|
|
5423
5791
|
anonymousSessionId: AnonymousSessionIdSchema,
|
|
5424
5792
|
spanContext: SpanContextSchema.optional(),
|
|
@@ -5438,7 +5806,9 @@ const ContextTelemetrySchema = z.object({
|
|
|
5438
5806
|
captureErrors: z.array(z.string()).optional()
|
|
5439
5807
|
});
|
|
5440
5808
|
const ALERT_THRESHOLDS = {
|
|
5809
|
+
/** Minimum score to trigger any alert */
|
|
5441
5810
|
warning: 30,
|
|
5811
|
+
/** Score threshold for @here mentions */
|
|
5442
5812
|
critical: 50
|
|
5443
5813
|
};
|
|
5444
5814
|
z.object({
|
|
@@ -5611,6 +5981,7 @@ const PromptMetaFunctionCallSchema = z.object({
|
|
|
5611
5981
|
success: z.boolean().optional(),
|
|
5612
5982
|
error: z.string().optional(),
|
|
5613
5983
|
creditsUsed: z.number().optional(),
|
|
5984
|
+
/** Tool use ID for Anthropic API tool pairing (#6181) */
|
|
5614
5985
|
id: z.string().optional()
|
|
5615
5986
|
});
|
|
5616
5987
|
const PromptMetaPerformanceSchema = z.object({
|
|
@@ -5658,24 +6029,33 @@ const ToolHealthSchema = z.object({
|
|
|
5658
6029
|
successRate: z.number().optional()
|
|
5659
6030
|
});
|
|
5660
6031
|
const CitableSourceSchema = z.object({
|
|
6032
|
+
/** Unique identifier - can be URL, UUID, or composite key */
|
|
5661
6033
|
id: z.string(),
|
|
6034
|
+
/** Source classification for UI rendering */
|
|
5662
6035
|
type: z.enum([
|
|
5663
6036
|
"web_url",
|
|
5664
6037
|
"document",
|
|
5665
6038
|
"dataset",
|
|
5666
6039
|
"mcp"
|
|
5667
6040
|
]),
|
|
6041
|
+
/** Human-readable title/name */
|
|
5668
6042
|
title: z.string(),
|
|
6043
|
+
/** Navigation target (external URL, deep link, or hash route) */
|
|
5669
6044
|
url: z.string().optional(),
|
|
6045
|
+
/** Brief description or excerpt (1-2 sentences) */
|
|
5670
6046
|
description: z.string().optional(),
|
|
6047
|
+
/** ISO 8601 timestamp for freshness indication */
|
|
5671
6048
|
timestamp: z.string().optional(),
|
|
6049
|
+
/** Attribution for non-report sources */
|
|
5672
6050
|
author: z.string().optional(),
|
|
6051
|
+
/** Processing status for real-time updates */
|
|
5673
6052
|
status: z.enum([
|
|
5674
6053
|
"pending",
|
|
5675
6054
|
"processing",
|
|
5676
6055
|
"complete",
|
|
5677
6056
|
"error"
|
|
5678
6057
|
]).optional(),
|
|
6058
|
+
/** Extensibility metadata */
|
|
5679
6059
|
metadata: z.looseObject({
|
|
5680
6060
|
sourceSystem: z.string().optional(),
|
|
5681
6061
|
icon: z.string().optional(),
|
|
@@ -5804,6 +6184,7 @@ let FileEvents = /* @__PURE__ */ function(FileEvents) {
|
|
|
5804
6184
|
FileEvents["DELETE_ALL_FILES"] = "All Files Deleted";
|
|
5805
6185
|
FileEvents["UPDATE_FILE"] = "File Updated";
|
|
5806
6186
|
FileEvents["GENERATE_FILE_PRESIGNED_URL"] = "File Presigned URL Generated";
|
|
6187
|
+
FileEvents["UNSHARE_FILE"] = "File Unshared";
|
|
5807
6188
|
return FileEvents;
|
|
5808
6189
|
}({});
|
|
5809
6190
|
let InviteEvents = /* @__PURE__ */ function(InviteEvents) {
|
|
@@ -6411,11 +6792,14 @@ const InferTaxonomyFolderEntry = z$1.object({
|
|
|
6411
6792
|
fileName: z$1.string(),
|
|
6412
6793
|
fileSize: z$1.number(),
|
|
6413
6794
|
mimeType: z$1.string().optional(),
|
|
6795
|
+
/** First ~500 chars of file content for AI analysis */
|
|
6414
6796
|
contentSample: z$1.string().max(1e3).optional()
|
|
6415
6797
|
});
|
|
6416
6798
|
z$1.object({
|
|
6417
6799
|
folderTree: z$1.array(InferTaxonomyFolderEntry).min(1).max(500),
|
|
6800
|
+
/** If re-running for an existing data lake, pass its prefix */
|
|
6418
6801
|
existingPrefix: z$1.string().optional(),
|
|
6802
|
+
/** User description of the data (helps the AI) */
|
|
6419
6803
|
context: z$1.string().max(2e3).optional()
|
|
6420
6804
|
});
|
|
6421
6805
|
z$1.object({ hashes: z$1.array(z$1.string().regex(sha256Regex)).min(1).max(500) });
|
|
@@ -6621,6 +7005,7 @@ OpenAIImageGenerationInput.extend({
|
|
|
6621
7005
|
image: z.string()
|
|
6622
7006
|
});
|
|
6623
7007
|
z.object({
|
|
7008
|
+
/** Notebook session ID */
|
|
6624
7009
|
sessionId: z.string(),
|
|
6625
7010
|
historyCount: z.number(),
|
|
6626
7011
|
imageConfig: GenerateImageToolCallSchema.optional(),
|
|
@@ -6630,9 +7015,11 @@ z.object({
|
|
|
6630
7015
|
searchers: z.array(z.any()).optional()
|
|
6631
7016
|
}).optional(),
|
|
6632
7017
|
fabFileIds: z.array(z.string()),
|
|
7018
|
+
/** Prompt message */
|
|
6633
7019
|
message: z.string(),
|
|
6634
7020
|
messageFileIds: z.array(z.string()).prefault([]),
|
|
6635
7021
|
questId: z.string().optional(),
|
|
7022
|
+
/** Extra context messages to include in the conversation from external sources */
|
|
6636
7023
|
extraContextMessages: z.array(z.object({
|
|
6637
7024
|
role: z.enum([
|
|
6638
7025
|
"user",
|
|
@@ -6644,27 +7031,48 @@ z.object({
|
|
|
6644
7031
|
content: z.union([z.string(), z.array(z.any())]),
|
|
6645
7032
|
fabFileIds: z.array(z.string()).optional()
|
|
6646
7033
|
})).optional(),
|
|
7034
|
+
/** Dashboard related params */
|
|
6647
7035
|
dashboardParams: DashboardParamsSchema.optional(),
|
|
7036
|
+
/** LLM params */
|
|
6648
7037
|
params: ChatCompletionCreateInputSchema,
|
|
7038
|
+
/** Whether Quest Master is enabled */
|
|
6649
7039
|
enableQuestMaster: z.boolean().optional(),
|
|
7040
|
+
/** Whether Mementos is enabled */
|
|
6650
7041
|
enableMementos: z.boolean().optional(),
|
|
7042
|
+
/** Whether Artifacts is enabled */
|
|
6651
7043
|
enableArtifacts: z.boolean().optional(),
|
|
7044
|
+
/** Whether Agents is enabled */
|
|
6652
7045
|
enableAgents: z.boolean().optional(),
|
|
7046
|
+
/** Whether Lattice (financial pro-forma modeling) is enabled */
|
|
6653
7047
|
enableLattice: z.boolean().optional(),
|
|
7048
|
+
/** LLM tools to enable (built-in tools or MCP tool names) */
|
|
6654
7049
|
tools: z.array(z.union([b4mLLMTools, z.string()])).optional(),
|
|
7050
|
+
/** Enabled MCP servers */
|
|
6655
7051
|
mcpServers: z.array(z.string()).optional(),
|
|
7052
|
+
/** Project ID */
|
|
6656
7053
|
projectId: z.string().optional(),
|
|
7054
|
+
/** Organization ID */
|
|
6657
7055
|
organizationId: z.string().nullable().optional(),
|
|
7056
|
+
/** Tool prompt ID to use for the LLM */
|
|
6658
7057
|
toolPromptId: z.string().optional(),
|
|
7058
|
+
/** Quest Master related params */
|
|
6659
7059
|
questMaster: QuestMasterParamsSchema.optional(),
|
|
7060
|
+
/** Research Mode related params */
|
|
6660
7061
|
researchMode: ResearchModeParamsSchema.optional(),
|
|
7062
|
+
/** Fallback model ID to try if primary model fails */
|
|
6661
7063
|
fallbackModel: z.string().optional(),
|
|
7064
|
+
/** Embedding model to use */
|
|
6662
7065
|
embeddingModel: z.string().optional(),
|
|
7066
|
+
/** User's timezone (IANA format, e.g., "America/New_York") */
|
|
6663
7067
|
timezone: z.string().optional(),
|
|
7068
|
+
/** Persona-based sub-agent filter — only these agent names are available for delegation */
|
|
6664
7069
|
allowedAgents: z.array(z.string()).optional(),
|
|
7070
|
+
/** When true, Quest Processor injects Slack-specific tool configs (help, notebooks, curated files) */
|
|
6665
7071
|
enableSlackTools: z.boolean().optional()
|
|
6666
7072
|
}).extend({
|
|
7073
|
+
/** Notebook session ID */
|
|
6667
7074
|
sessionId: z.string().optional(),
|
|
7075
|
+
/** Notebook session name */
|
|
6668
7076
|
sessionName: z.string().optional()
|
|
6669
7077
|
});
|
|
6670
7078
|
z.object({
|
|
@@ -6943,20 +7351,35 @@ const ExportFormatSchema = z.enum([
|
|
|
6943
7351
|
"html"
|
|
6944
7352
|
]);
|
|
6945
7353
|
z.object({
|
|
6946
|
-
|
|
7354
|
+
/** Curation type: transcript (Option 1) or executive_summary (Option 2) */
|
|
7355
|
+
curationType: CurationTypeSchema.prefault("transcript"),
|
|
7356
|
+
/** Include code artifacts in the curated notebook */
|
|
6947
7357
|
includeCode: z.boolean().prefault(true),
|
|
7358
|
+
/** Include diagrams (Mermaid, SVG) in the curated notebook */
|
|
6948
7359
|
includeDiagrams: z.boolean().prefault(true),
|
|
7360
|
+
/** Include data visualizations (Recharts) in the curated notebook */
|
|
6949
7361
|
includeDataViz: z.boolean().prefault(true),
|
|
7362
|
+
/** Include QuestMaster plans in the curated notebook */
|
|
6950
7363
|
includeQuestMaster: z.boolean().prefault(true),
|
|
7364
|
+
/** Include Deep Research findings in the curated notebook */
|
|
6951
7365
|
includeResearch: z.boolean().prefault(true),
|
|
7366
|
+
/** Include images in the curated notebook */
|
|
6952
7367
|
includeImages: z.boolean().prefault(true),
|
|
7368
|
+
/** Token budget for processing (varies by curation type) */
|
|
6953
7369
|
tokenBudget: z.number().optional(),
|
|
7370
|
+
/** Export format for the curated notebook */
|
|
6954
7371
|
exportFormat: ExportFormatSchema.prefault("markdown"),
|
|
7372
|
+
/** Custom notebook name (optional, defaults to curated-notebook-{sessionId}) */
|
|
6955
7373
|
customNotebookName: z.string().optional()
|
|
6956
7374
|
});
|
|
6957
7375
|
function isGPTImageModel(model) {
|
|
6958
7376
|
if (!model) return false;
|
|
6959
|
-
return OPENAI_IMAGE_MODELS.includes(model) || model.startsWith("gpt-image-
|
|
7377
|
+
return OPENAI_IMAGE_MODELS.includes(model) || model.startsWith("gpt-image-");
|
|
7378
|
+
}
|
|
7379
|
+
/** Returns true specifically for gpt-image-2 (including versioned snapshots like gpt-image-2-2026-04-21). */
|
|
7380
|
+
function isGPTImage2Model(model) {
|
|
7381
|
+
if (!model) return false;
|
|
7382
|
+
return model === "gpt-image-2" || model.startsWith("gpt-image-2");
|
|
6960
7383
|
}
|
|
6961
7384
|
/**
|
|
6962
7385
|
* Telemetry Error Sanitizer
|
|
@@ -8994,4 +9417,4 @@ var ConfigStore = class {
|
|
|
8994
9417
|
}
|
|
8995
9418
|
};
|
|
8996
9419
|
//#endregion
|
|
8997
|
-
export {
|
|
9420
|
+
export { RechartsChartTypeList as $, ImageGenerationUsageTransaction as A, secureParameters as At, NotFoundError as B, FileEvents as C, getMcpProviderMetadata as Ct, GenericCreditAddTransaction as D, obfuscateApiKey as Dt, GenerateImageToolCallSchema as E, isGPTImageModel as Et, KnowledgeType as F, ProfileEvents as G, OpenAIImageGenerationInput as H, LLMEvents as I, PurchaseTransaction as J, ProjectEvents as K, MiscEvents as L, InboxEvents as M, validateNotebookPath as Mt, InviteEvents as N, CollectionType as Nt, GenericCreditDeductTransaction as O, resolveNavigationIntents as Ot, InviteType as P, ReceivedCreditTransaction as Q, ModalEvents as R, FeedbackEvents as S, getDataLakeTags as St, GEMINI_IMAGE_MODELS as T, isGPTImage2Model as Tt, Permission as U, OpenAIEmbeddingModel as V, PermissionDeniedError as W, REASONING_SUPPORTED_MODELS as X, QuestMasterParamsSchema as Y, RealtimeVoiceUsageTransaction as Z, CompletionApiUsageTransaction as _, VideoModels as _t, ApiKeyEvents as a, SessionEvents as at, FIXED_TEMPERATURE_MODELS as b, b4mLLMTools as bt, AppFileEvents as c, SupportedFabFileMimeTypes as ct, BFL_IMAGE_MODELS as d, TextGenerationUsageTransaction as dt, RegInviteEvents as et, BFL_SAFETY_TOLERANCE as f, ToolUsageTransaction as ft, ChatModels as g, VideoGenerationUsageTransaction as gt, ChatCompletionCreateInputSchema as h, VIDEO_SIZE_CONSTRAINTS as ht, AiEvents as i, ResearchTaskType as it, ImageModels as j, validateJupyterKernelName as jt, ImageEditUsageTransaction as k, sanitizeTelemetryError as kt, ArtifactTypeSchema as l, TagType as lt, CREDIT_DEDUCT_TRANSACTION_TYPES as m, UiNavigationEvents as mt, logger as n, ResearchTaskExecutionType as nt, ApiKeyScope as o, SpeechToTextModels as ot, BedrockEmbeddingModel as p, TransferCreditTransaction as pt, PromptMetaZodSchema as q, ALERT_THRESHOLDS as r, ResearchTaskPeriodicFrequencyType as rt, ApiKeyType as s, SubscriptionCreditTransaction as st, ConfigStore as t, ResearchModeParamsSchema as tt, AuthEvents as u, TaskScheduleHandler as ut, DashboardParamsSchema as v, VoyageAIEmbeddingModel as vt, FriendshipEvents as w, getViewById as wt, FavoriteDocumentType as x, getAccessibleDataLakes as xt, ElabsEvents as y, XAI_IMAGE_MODELS as yt, ModelBackend as z };
|