@oneuptime/common 14.0.97 → 14.0.98

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.
Files changed (75) hide show
  1. package/Models/DatabaseModels/CodeRepository.d.mts +3 -0
  2. package/Models/DatabaseModels/CodeRepository.d.ts +3 -0
  3. package/Models/DatabaseModels/CodeRepository.js +104 -0
  4. package/Models/DatabaseModels/Index.js +2 -0
  5. package/Models/DatabaseModels/SecurityCaseEvidence.d.mts +4 -0
  6. package/Models/DatabaseModels/SecurityCaseEvidence.d.ts +4 -0
  7. package/Models/DatabaseModels/SecurityCaseEvidence.js +64 -5
  8. package/Models/DatabaseModels/SecurityHunt.d.mts +34 -0
  9. package/Models/DatabaseModels/SecurityHunt.d.ts +34 -0
  10. package/Models/DatabaseModels/SecurityHunt.js +608 -0
  11. package/Models/DatabaseModels/SecurityHunt.mjs +2 -0
  12. package/Types/AI/AIChatTypes.d.mts +1 -0
  13. package/Types/AI/AIChatTypes.d.ts +1 -0
  14. package/Types/AI/AIRunEventType.d.mts +1 -0
  15. package/Types/AI/AIRunEventType.d.ts +1 -0
  16. package/Types/AI/AIRunEventType.js +8 -0
  17. package/Types/AI/AiTokenCount.d.mts +22 -1
  18. package/Types/AI/AiTokenCount.d.ts +22 -1
  19. package/Types/AI/AiTokenCount.js +126 -57
  20. package/Types/AI/AiTokenCount.mjs +2 -0
  21. package/Types/AI/CodeFixTaskContext.d.mts +1 -0
  22. package/Types/AI/CodeFixTaskContext.d.ts +1 -0
  23. package/Types/CodeRepository/CodeRepositorySetting.d.mts +1 -0
  24. package/Types/CodeRepository/CodeRepositorySetting.d.ts +1 -0
  25. package/Types/CodeRepository/CodeRepositorySetting.js +2 -0
  26. package/Types/Email/EmailTemplateType.d.mts +1 -0
  27. package/Types/Email/EmailTemplateType.d.ts +1 -0
  28. package/Types/Email/EmailTemplateType.js +2 -0
  29. package/Types/Link.d.mts +1 -0
  30. package/Types/Link.d.ts +1 -0
  31. package/Types/NotificationSetting/NotificationEmailRollupCategory.d.mts +1 -0
  32. package/Types/NotificationSetting/NotificationEmailRollupCategory.d.ts +1 -0
  33. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +9 -0
  34. package/Types/NotificationSetting/NotificationSettingEventType.d.mts +1 -0
  35. package/Types/NotificationSetting/NotificationSettingEventType.d.ts +1 -0
  36. package/Types/NotificationSetting/NotificationSettingEventType.js +6 -0
  37. package/Types/SecurityCase/SecurityCaseEventEvidence.d.mts +67 -0
  38. package/Types/SecurityCase/SecurityCaseEventEvidence.d.ts +67 -0
  39. package/Types/SecurityCase/SecurityCaseEventEvidence.js +271 -0
  40. package/Types/SecurityCase/SecurityCaseEventEvidence.mjs +13 -0
  41. package/Types/SecurityCase/SecurityCaseEvidenceKind.d.mts +2 -1
  42. package/Types/SecurityCase/SecurityCaseEvidenceKind.d.ts +2 -1
  43. package/Types/SecurityCase/SecurityCaseEvidenceKind.js +11 -1
  44. package/Types/SecurityEvent/SecurityHunt.d.mts +122 -0
  45. package/Types/SecurityEvent/SecurityHunt.d.ts +122 -0
  46. package/Types/SecurityEvent/SecurityHunt.js +391 -0
  47. package/Types/SecurityEvent/SecurityHunt.mjs +32 -0
  48. package/Types/Workflow/RunRecord.d.mts +3 -14
  49. package/Types/Workflow/RunRecord.d.ts +3 -14
  50. package/Types/Workflow/RunRecord.js +10 -51
  51. package/Utils/AI/InvestigationLogStall.d.mts +38 -0
  52. package/Utils/AI/InvestigationLogStall.d.ts +38 -0
  53. package/Utils/AI/InvestigationLogStall.js +163 -0
  54. package/Utils/AI/InvestigationLogStall.mjs +11 -0
  55. package/Utils/Project/RecordNumber.d.mts +43 -0
  56. package/Utils/Project/RecordNumber.d.ts +43 -0
  57. package/Utils/Project/RecordNumber.js +151 -0
  58. package/Utils/Project/RecordNumber.mjs +6 -0
  59. package/Utils/SecurityCase/SecurityCaseMarkdown.d.mts +9 -0
  60. package/Utils/SecurityCase/SecurityCaseMarkdown.d.ts +9 -0
  61. package/Utils/SecurityCase/SecurityCaseMarkdown.js +20 -0
  62. package/Utils/SecurityCase/SecurityCaseMarkdown.mjs +2 -0
  63. package/Utils/SecurityEvent/SecurityEventSearch.d.mts +56 -0
  64. package/Utils/SecurityEvent/SecurityEventSearch.d.ts +56 -0
  65. package/Utils/SecurityEvent/SecurityEventSearch.js +422 -0
  66. package/Utils/SecurityEvent/SecurityEventSearch.mjs +21 -0
  67. package/Utils/SecurityEvent/SecurityHuntSearch.d.mts +12 -0
  68. package/Utils/SecurityEvent/SecurityHuntSearch.d.ts +12 -0
  69. package/Utils/SecurityEvent/SecurityHuntSearch.js +51 -0
  70. package/Utils/SecurityEvent/SecurityHuntSearch.mjs +3 -0
  71. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +9 -0
  72. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +9 -0
  73. package/Utils/Suggestions/TracePerformanceFixSuggestion.js +69 -1
  74. package/Utils/Suggestions/TracePerformanceFixSuggestion.mjs +4 -0
  75. package/package.json +1 -1
@@ -4,10 +4,24 @@ export interface AiTokenWeight {
4
4
  }
5
5
  export declare const CACHE_READ_TOKEN_WEIGHT: AiTokenWeight;
6
6
  export declare const CACHE_WRITE_TOKEN_WEIGHT: AiTokenWeight;
7
+ export declare const FRESH_TOKEN_WEIGHT: AiTokenWeight;
8
+ export interface AiTokenCacheWeights {
9
+ read: AiTokenWeight;
10
+ write: AiTokenWeight;
11
+ isModelPriced: boolean;
12
+ }
13
+ export declare const DEFAULT_CACHE_TOKEN_WEIGHTS: AiTokenCacheWeights;
7
14
  export interface AiTokenUsage {
8
15
  totalTokens?: number | null | undefined;
9
16
  cachedInputTokens?: number | null | undefined;
10
17
  cacheCreationTokens?: number | null | undefined;
18
+ modelName?: string | null | undefined;
19
+ }
20
+ export interface AiTokenUsageSum {
21
+ totalTokens: number;
22
+ cachedInputTokens: number;
23
+ cacheCreationTokens: number;
24
+ modelName: string | null;
11
25
  }
12
26
  export interface AiTokenCountBreakdown {
13
27
  countedTokens: number;
@@ -17,11 +31,18 @@ export interface AiTokenCountBreakdown {
17
31
  countedCacheReadTokens: number;
18
32
  cacheWriteTokens: number;
19
33
  countedCacheWriteTokens: number;
34
+ cacheWeights: AiTokenCacheWeights;
20
35
  }
21
36
  export default class AiTokenCount {
22
37
  static count(usage: AiTokenUsage): number;
23
38
  static getBreakdown(usage: AiTokenUsage): AiTokenCountBreakdown;
24
- static add(usages: Array<AiTokenUsage>): Required<AiTokenUsage>;
39
+ static getCacheWeights(modelName: string | null | undefined): AiTokenCacheWeights;
40
+ static sumByModel(usages: Array<AiTokenUsage>): Array<AiTokenUsageSum>;
41
+ static countAll(usages: Array<AiTokenUsage>): number;
25
42
  static toTokenCount(value: unknown): number;
43
+ private static toModelName;
44
+ private static isPrice;
45
+ private static toWeight;
46
+ private static greatestCommonDivisor;
26
47
  private static weigh;
27
48
  }
@@ -4,10 +4,24 @@ export interface AiTokenWeight {
4
4
  }
5
5
  export declare const CACHE_READ_TOKEN_WEIGHT: AiTokenWeight;
6
6
  export declare const CACHE_WRITE_TOKEN_WEIGHT: AiTokenWeight;
7
+ export declare const FRESH_TOKEN_WEIGHT: AiTokenWeight;
8
+ export interface AiTokenCacheWeights {
9
+ read: AiTokenWeight;
10
+ write: AiTokenWeight;
11
+ isModelPriced: boolean;
12
+ }
13
+ export declare const DEFAULT_CACHE_TOKEN_WEIGHTS: AiTokenCacheWeights;
7
14
  export interface AiTokenUsage {
8
15
  totalTokens?: number | null | undefined;
9
16
  cachedInputTokens?: number | null | undefined;
10
17
  cacheCreationTokens?: number | null | undefined;
18
+ modelName?: string | null | undefined;
19
+ }
20
+ export interface AiTokenUsageSum {
21
+ totalTokens: number;
22
+ cachedInputTokens: number;
23
+ cacheCreationTokens: number;
24
+ modelName: string | null;
11
25
  }
12
26
  export interface AiTokenCountBreakdown {
13
27
  countedTokens: number;
@@ -17,11 +31,18 @@ export interface AiTokenCountBreakdown {
17
31
  countedCacheReadTokens: number;
18
32
  cacheWriteTokens: number;
19
33
  countedCacheWriteTokens: number;
34
+ cacheWeights: AiTokenCacheWeights;
20
35
  }
21
36
  export default class AiTokenCount {
22
37
  static count(usage: AiTokenUsage): number;
23
38
  static getBreakdown(usage: AiTokenUsage): AiTokenCountBreakdown;
24
- static add(usages: Array<AiTokenUsage>): Required<AiTokenUsage>;
39
+ static getCacheWeights(modelName: string | null | undefined): AiTokenCacheWeights;
40
+ static sumByModel(usages: Array<AiTokenUsage>): Array<AiTokenUsageSum>;
41
+ static countAll(usages: Array<AiTokenUsage>): number;
25
42
  static toTokenCount(value: unknown): number;
43
+ private static toModelName;
44
+ private static isPrice;
45
+ private static toWeight;
46
+ private static greatestCommonDivisor;
26
47
  private static weigh;
27
48
  }
@@ -1,55 +1,43 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CACHE_TOKEN_WEIGHTS = exports.FRESH_TOKEN_WEIGHT = exports.CACHE_WRITE_TOKEN_WEIGHT = exports.CACHE_READ_TOKEN_WEIGHT = void 0;
4
+ const LlmCostCatalog_1 = require("../Telemetry/LlmCostCatalog");
2
5
  /*
3
- * How OneUptime counts the tokens of its own AI calls (issue #5073): the
4
- * "Tokens Used" of the AI Logs, the tokens of each AI run (an
5
- * investigation, an Ask AI answer, a fix), the project's daily AI token
6
- * limit and the incident and alert ones, and the AI credits a call through
7
- * the OneUptime-hosted provider is charged.
8
- *
9
- * A token counts for what it costs. A token the model reads fresh, and every
10
- * token it writes, counts as one. A token the provider serves from its prompt
11
- * cache - a token the model already read on an earlier call of the same
12
- * investigation or chat, sent again with the conversation - costs a tenth of
13
- * a fresh one at Anthropic (less on its newest models) and on OpenAI's
14
- * current models, and counts as a tenth. A token written to the cache costs a
15
- * quarter more than a fresh one at Anthropic (its 5-minute cache, the one
16
- * OneUptime asks for), and counts as one and a quarter. Without the cache an
17
- * agent loop pays for its whole conversation again on every call, so counting
18
- * every cached token as a fresh one made AI work count several times what it
19
- * cost - and the more OneUptime caches, the further apart the two would grow.
20
- *
21
- * The providers report cached tokens two ways, and both are counted alike:
22
- *
23
- * - The OpenAI wire (OpenAI, Azure OpenAI, Groq, Mistral, OpenAI-compatible
24
- * servers) counts them inside prompt_tokens, and reports how many in
25
- * prompt_tokens_details.cached_tokens. It never reports a cache write:
26
- * writing costs nothing extra there.
27
- * - Anthropic reports input_tokens WITHOUT them, and cache_read_input_tokens
28
- * and cache_creation_input_tokens apart; LLMService adds them back.
29
- *
30
- * Either way totalTokens holds every token of the call (LlmLog.totalTokens,
31
- * as the provider counted them), and the cached ones are a part of it.
32
- *
33
- * Pure and free of React and server code: the server counts with it, and the
34
- * dashboard's AI Logs show the same count.
6
+ * A token read from the provider's prompt cache counts as a tenth of a
7
+ * token, for a model the cost catalog lists no cache price for.
35
8
  */
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.CACHE_WRITE_TOKEN_WEIGHT = exports.CACHE_READ_TOKEN_WEIGHT = void 0;
38
- // A token read from the provider's prompt cache counts as a tenth of a token.
39
9
  exports.CACHE_READ_TOKEN_WEIGHT = {
40
10
  numerator: 1,
41
11
  denominator: 10,
42
12
  };
43
- // A token written to the provider's prompt cache counts as one and a quarter.
13
+ /*
14
+ * A token written to the provider's prompt cache counts as one and a
15
+ * quarter, for a model the cost catalog lists no cache price for.
16
+ */
44
17
  exports.CACHE_WRITE_TOKEN_WEIGHT = {
45
18
  numerator: 5,
46
19
  denominator: 4,
47
20
  };
21
+ // A token that counts for exactly what a fresh one does.
22
+ exports.FRESH_TOKEN_WEIGHT = {
23
+ numerator: 1,
24
+ denominator: 1,
25
+ };
26
+ /*
27
+ * A model's weights are its prices to a millionth of a token: finer than any
28
+ * price list is written, and whole numbers either way.
29
+ */
30
+ const MODEL_WEIGHT_DENOMINATOR = 1000000;
31
+ exports.DEFAULT_CACHE_TOKEN_WEIGHTS = {
32
+ read: exports.CACHE_READ_TOKEN_WEIGHT,
33
+ write: exports.CACHE_WRITE_TOKEN_WEIGHT,
34
+ isModelPriced: false,
35
+ };
48
36
  class AiTokenCount {
49
37
  /*
50
- * What a call - or a sum of calls - counts as: its fresh tokens, a tenth
51
- * of the tokens read from the prompt cache and one and a quarter of the
52
- * tokens written to it, each weighted part rounded up to a whole token.
38
+ * What a call - or a sum of calls of one model - counts as: its fresh
39
+ * tokens, and the tokens read from and written to the prompt cache at the
40
+ * model's weights, each weighted part rounded up to a whole token.
53
41
  */
54
42
  static count(usage) {
55
43
  return this.getBreakdown(usage).countedTokens;
@@ -64,8 +52,9 @@ class AiTokenCount {
64
52
  const cacheReadTokens = this.toTokenCount(usage.cachedInputTokens);
65
53
  const cacheWriteTokens = this.toTokenCount(usage.cacheCreationTokens);
66
54
  const freshTokens = Math.max(0, totalTokens - cacheReadTokens - cacheWriteTokens);
67
- const countedCacheReadTokens = this.weigh(cacheReadTokens, exports.CACHE_READ_TOKEN_WEIGHT);
68
- const countedCacheWriteTokens = this.weigh(cacheWriteTokens, exports.CACHE_WRITE_TOKEN_WEIGHT);
55
+ const cacheWeights = this.getCacheWeights(usage.modelName);
56
+ const countedCacheReadTokens = this.weigh(cacheReadTokens, cacheWeights.read);
57
+ const countedCacheWriteTokens = this.weigh(cacheWriteTokens, cacheWeights.write);
69
58
  return {
70
59
  countedTokens: freshTokens + countedCacheReadTokens + countedCacheWriteTokens,
71
60
  totalTokens,
@@ -74,29 +63,76 @@ class AiTokenCount {
74
63
  countedCacheReadTokens,
75
64
  cacheWriteTokens,
76
65
  countedCacheWriteTokens,
66
+ cacheWeights,
77
67
  };
78
68
  }
79
69
  /*
80
- * The tokens of several calls added up, part by part - what a day of AI
81
- * Logs rows sums to before it is counted.
70
+ * What a model's cached tokens count as: the price its provider charges
71
+ * for a token read from, and one written to, its prompt cache, over the
72
+ * price of a fresh input token - the model's list prices in the cost
73
+ * catalog, at their standard tier (every long-prompt tier keeps the same
74
+ * shares). A model the catalog has no cache price for counts them as a
75
+ * tenth and one and a quarter; a model it has a read price but no write
76
+ * price for is not charged extra for a write, which counts as one.
82
77
  */
83
- static add(usages) {
84
- const sum = {
85
- total: 0,
86
- read: 0,
87
- write: 0,
88
- };
89
- for (const usage of usages) {
90
- sum.total += this.toTokenCount(usage.totalTokens);
91
- sum.read += this.toTokenCount(usage.cachedInputTokens);
92
- sum.write += this.toTokenCount(usage.cacheCreationTokens);
78
+ static getCacheWeights(modelName) {
79
+ const name = typeof modelName === "string" ? modelName.trim() : "";
80
+ if (!name) {
81
+ return exports.DEFAULT_CACHE_TOKEN_WEIGHTS;
82
+ }
83
+ const price = LlmCostCatalog_1.LlmCostCatalogUtil.findPriceForModel(name);
84
+ if (!price ||
85
+ !this.isPrice(price.inputPricePerMillionTokensInUSD) ||
86
+ price.inputPricePerMillionTokensInUSD <= 0 ||
87
+ !this.isPrice(price.cacheReadPricePerMillionTokensInUSD)) {
88
+ return exports.DEFAULT_CACHE_TOKEN_WEIGHTS;
93
89
  }
90
+ const inputPrice = price.inputPricePerMillionTokensInUSD;
94
91
  return {
95
- totalTokens: sum.total,
96
- cachedInputTokens: sum.read,
97
- cacheCreationTokens: sum.write,
92
+ read: this.toWeight(price.cacheReadPricePerMillionTokensInUSD, inputPrice),
93
+ write: this.isPrice(price.cacheWritePricePerMillionTokensInUSD)
94
+ ? this.toWeight(price.cacheWritePricePerMillionTokensInUSD, inputPrice)
95
+ : exports.FRESH_TOKEN_WEIGHT,
96
+ isModelPriced: true,
98
97
  };
99
98
  }
99
+ /*
100
+ * The tokens of several calls added up, part by part, one sum for each
101
+ * model - what a day of AI Logs rows sums to before it is counted, in the
102
+ * order each model first appears.
103
+ */
104
+ static sumByModel(usages) {
105
+ const sums = new Map();
106
+ for (const usage of usages) {
107
+ const modelName = this.toModelName(usage.modelName);
108
+ const key = modelName === null ? "" : `model:${modelName}`;
109
+ let sum = sums.get(key);
110
+ if (!sum) {
111
+ sum = {
112
+ totalTokens: 0,
113
+ cachedInputTokens: 0,
114
+ cacheCreationTokens: 0,
115
+ modelName,
116
+ };
117
+ sums.set(key, sum);
118
+ }
119
+ sum.totalTokens += this.toTokenCount(usage.totalTokens);
120
+ sum.cachedInputTokens += this.toTokenCount(usage.cachedInputTokens);
121
+ sum.cacheCreationTokens += this.toTokenCount(usage.cacheCreationTokens);
122
+ }
123
+ return Array.from(sums.values());
124
+ }
125
+ /*
126
+ * What several calls count as together: each model's sum counted at that
127
+ * model's weights, and the counts added up. A model's weighted parts are
128
+ * rounded up once for all its calls, where the AI Logs round each call's,
129
+ * so the sum can count a token or so per call less than its rows add up to.
130
+ */
131
+ static countAll(usages) {
132
+ return this.sumByModel(usages).reduce((total, sum) => {
133
+ return total + this.count(sum);
134
+ }, 0);
135
+ }
100
136
  /*
101
137
  * A token count as a whole, non-negative number: a count reported as a
102
138
  * string (a SQL sum), a fraction, a negative number or anything else that
@@ -113,9 +149,42 @@ class AiTokenCount {
113
149
  }
114
150
  return Math.floor(parsed);
115
151
  }
152
+ // A model's name as a sum keeps it: trimmed, or null when it names none.
153
+ static toModelName(value) {
154
+ if (typeof value !== "string") {
155
+ return null;
156
+ }
157
+ const trimmed = value.trim();
158
+ return trimmed.length > 0 ? trimmed : null;
159
+ }
160
+ static isPrice(value) {
161
+ return typeof value === "number" && Number.isFinite(value) && value >= 0;
162
+ }
163
+ // A price over the input price, as a whole-number fraction in lowest terms.
164
+ static toWeight(price, inputPrice) {
165
+ const numerator = Math.round((price / inputPrice) * MODEL_WEIGHT_DENOMINATOR);
166
+ if (numerator <= 0) {
167
+ return { numerator: 0, denominator: 1 };
168
+ }
169
+ const divisor = this.greatestCommonDivisor(numerator, MODEL_WEIGHT_DENOMINATOR);
170
+ return {
171
+ numerator: numerator / divisor,
172
+ denominator: MODEL_WEIGHT_DENOMINATOR / divisor,
173
+ };
174
+ }
175
+ static greatestCommonDivisor(a, b) {
176
+ let x = a;
177
+ let y = b;
178
+ while (y !== 0) {
179
+ const rest = x % y;
180
+ x = y;
181
+ y = rest;
182
+ }
183
+ return x;
184
+ }
116
185
  // Tokens times a weight, rounded up to a whole token, in whole numbers.
117
186
  static weigh(tokens, weight) {
118
- if (tokens <= 0) {
187
+ if (tokens <= 0 || weight.numerator <= 0) {
119
188
  return 0;
120
189
  }
121
190
  return Math.ceil((tokens * weight.numerator) / weight.denominator);
@@ -2,3 +2,5 @@ import commonJsModule from "./AiTokenCount.js";
2
2
  export default commonJsModule.default;
3
3
  export const CACHE_READ_TOKEN_WEIGHT = commonJsModule.CACHE_READ_TOKEN_WEIGHT;
4
4
  export const CACHE_WRITE_TOKEN_WEIGHT = commonJsModule.CACHE_WRITE_TOKEN_WEIGHT;
5
+ export const DEFAULT_CACHE_TOKEN_WEIGHTS = commonJsModule.DEFAULT_CACHE_TOKEN_WEIGHTS;
6
+ export const FRESH_TOKEN_WEIGHT = commonJsModule.FRESH_TOKEN_WEIGHT;
@@ -84,6 +84,7 @@ export interface CodeFixTaskContext {
84
84
  request?: CodeTaskRequest | undefined;
85
85
  productionReview?: ProductionReviewTaskContext | undefined;
86
86
  allowedCodeRepositoryIds?: Array<string> | undefined;
87
+ pickedCodeRepositoryId?: string | undefined;
87
88
  }
88
89
  export declare function getProductionReviewTaskContext(taskContext: CodeFixTaskContext | null | undefined): ProductionReviewTaskContext | null;
89
90
  export declare function getCodeTaskRequest(taskContext: CodeFixTaskContext | null | undefined): CodeTaskRequest | null;
@@ -84,6 +84,7 @@ export interface CodeFixTaskContext {
84
84
  request?: CodeTaskRequest | undefined;
85
85
  productionReview?: ProductionReviewTaskContext | undefined;
86
86
  allowedCodeRepositoryIds?: Array<string> | undefined;
87
+ pickedCodeRepositoryId?: string | undefined;
87
88
  }
88
89
  export declare function getProductionReviewTaskContext(taskContext: CodeFixTaskContext | null | undefined): ProductionReviewTaskContext | null;
89
90
  export declare function getCodeTaskRequest(taskContext: CodeFixTaskContext | null | undefined): CodeTaskRequest | null;
@@ -5,6 +5,7 @@ export declare enum CodeRepositorySetting {
5
5
  PullRequests = "pull-requests",
6
6
  TriggerLabel = "trigger-label",
7
7
  ProductionReviewComment = "production-review-comment",
8
+ ProductionReviewLlmProvider = "production-review-llm-provider",
8
9
  Commands = "commands",
9
10
  Branches = "branches"
10
11
  }
@@ -5,6 +5,7 @@ export declare enum CodeRepositorySetting {
5
5
  PullRequests = "pull-requests",
6
6
  TriggerLabel = "trigger-label",
7
7
  ProductionReviewComment = "production-review-comment",
8
+ ProductionReviewLlmProvider = "production-review-llm-provider",
8
9
  Commands = "commands",
9
10
  Branches = "branches"
10
11
  }
@@ -28,6 +28,8 @@ var CodeRepositorySetting;
28
28
  CodeRepositorySetting["PullRequests"] = "pull-requests";
29
29
  CodeRepositorySetting["TriggerLabel"] = "trigger-label";
30
30
  CodeRepositorySetting["ProductionReviewComment"] = "production-review-comment";
31
+ // The LLM provider OneUptime AI reads pull requests with in its reviews.
32
+ CodeRepositorySetting["ProductionReviewLlmProvider"] = "production-review-llm-provider";
31
33
  // Only on a repository whose operator set build and test commands.
32
34
  CodeRepositorySetting["Commands"] = "commands";
33
35
  /*
@@ -95,6 +95,7 @@ declare enum EmailTemplateType {
95
95
  SecurityPlaybookApprovalRequested = "SecurityPlaybookApprovalRequested.hbs",
96
96
  SecurityCaseTargetDue = "SecurityCaseTargetDue.hbs",
97
97
  SecurityCaseTaskAssigned = "SecurityCaseTaskAssigned.hbs",
98
+ SecurityHuntFound = "SecurityHuntFound.hbs",
98
99
  ProjectSubscriptionOverdue = "ProjectSubscriptionOverdue.hbs",
99
100
  Invoice = "Invoice.hbs",
100
101
  ClickhouseCapacityWarning = "ClickhouseCapacityWarning.hbs",
@@ -95,6 +95,7 @@ declare enum EmailTemplateType {
95
95
  SecurityPlaybookApprovalRequested = "SecurityPlaybookApprovalRequested.hbs",
96
96
  SecurityCaseTargetDue = "SecurityCaseTargetDue.hbs",
97
97
  SecurityCaseTaskAssigned = "SecurityCaseTaskAssigned.hbs",
98
+ SecurityHuntFound = "SecurityHuntFound.hbs",
98
99
  ProjectSubscriptionOverdue = "ProjectSubscriptionOverdue.hbs",
99
100
  Invoice = "Invoice.hbs",
100
101
  ClickhouseCapacityWarning = "ClickhouseCapacityWarning.hbs",
@@ -99,6 +99,8 @@ var EmailTemplateType;
99
99
  EmailTemplateType["SecurityPlaybookApprovalRequested"] = "SecurityPlaybookApprovalRequested.hbs";
100
100
  EmailTemplateType["SecurityCaseTargetDue"] = "SecurityCaseTargetDue.hbs";
101
101
  EmailTemplateType["SecurityCaseTaskAssigned"] = "SecurityCaseTaskAssigned.hbs";
102
+ // A scheduled hunt found security events (SecurityHuntNotifications).
103
+ EmailTemplateType["SecurityHuntFound"] = "SecurityHuntFound.hbs";
102
104
  EmailTemplateType["ProjectSubscriptionOverdue"] = "ProjectSubscriptionOverdue.hbs";
103
105
  EmailTemplateType["Invoice"] = "Invoice.hbs";
104
106
  EmailTemplateType["ClickhouseCapacityWarning"] = "ClickhouseCapacityWarning.hbs";
package/Types/Link.d.mts CHANGED
@@ -6,4 +6,5 @@ export default interface Link {
6
6
  openInNewTab?: boolean | undefined;
7
7
  isRecordName?: boolean | undefined;
8
8
  recordName?: string | undefined;
9
+ recordNumber?: string | undefined;
9
10
  }
package/Types/Link.d.ts CHANGED
@@ -6,4 +6,5 @@ export default interface Link {
6
6
  openInNewTab?: boolean | undefined;
7
7
  isRecordName?: boolean | undefined;
8
8
  recordName?: string | undefined;
9
+ recordNumber?: string | undefined;
9
10
  }
@@ -12,6 +12,7 @@ export declare enum RollupCategory {
12
12
  Slos = "slos",
13
13
  IncomingCalls = "incoming-calls",
14
14
  SecurityCases = "security-cases",
15
+ SecurityHunts = "security-hunts",
15
16
  OnCall = "on-call",
16
17
  Other = "other"
17
18
  }
@@ -12,6 +12,7 @@ export declare enum RollupCategory {
12
12
  Slos = "slos",
13
13
  IncomingCalls = "incoming-calls",
14
14
  SecurityCases = "security-cases",
15
+ SecurityHunts = "security-hunts",
15
16
  OnCall = "on-call",
16
17
  Other = "other"
17
18
  }
@@ -40,6 +40,7 @@ var RollupCategory;
40
40
  RollupCategory["Slos"] = "slos";
41
41
  RollupCategory["IncomingCalls"] = "incoming-calls";
42
42
  RollupCategory["SecurityCases"] = "security-cases";
43
+ RollupCategory["SecurityHunts"] = "security-hunts";
43
44
  RollupCategory["OnCall"] = "on-call";
44
45
  RollupCategory["Other"] = "other";
45
46
  })(RollupCategory || (exports.RollupCategory = RollupCategory = {}));
@@ -61,6 +62,7 @@ exports.ROLLUP_CATEGORY_LABEL = {
61
62
  [RollupCategory.Slos]: "SLOs",
62
63
  [RollupCategory.IncomingCalls]: "Incoming Calls",
63
64
  [RollupCategory.SecurityCases]: "Security Cases",
65
+ [RollupCategory.SecurityHunts]: "Security Hunts",
64
66
  [RollupCategory.OnCall]: "On Call",
65
67
  [RollupCategory.Other]: "Other",
66
68
  };
@@ -149,6 +151,12 @@ exports.ROLLUP_CATEGORY_BY_EVENT_TYPE = {
149
151
  // Never held back (NEVER_ROLLED_UP_EVENT_TYPES): filed here all the same.
150
152
  [NotificationSettingEventType_1.default.SEND_SECURITY_CASE_TARGET_NOTIFICATION]: RollupCategory.SecurityCases,
151
153
  [NotificationSettingEventType_1.default.SEND_SECURITY_CASE_TASK_ASSIGNED_NOTIFICATION]: RollupCategory.SecurityCases,
154
+ /*
155
+ * Scheduled hunts. A category of their own: twenty hunts that run on the
156
+ * hour and all find something roll up with each other, never with a
157
+ * case's email.
158
+ */
159
+ [NotificationSettingEventType_1.default.SEND_SECURITY_HUNT_FOUND_NOTIFICATION]: RollupCategory.SecurityHunts,
152
160
  /*
153
161
  * On Call Notifications, including the two shift reminders. Five of these
154
162
  * seven are never rolled up at all (see NotificationEmailRollupPolicy); they
@@ -192,6 +200,7 @@ exports.ROLLUP_CATEGORY_ORDER = [
192
200
  RollupCategory.AlertEpisodes,
193
201
  RollupCategory.IncomingCalls,
194
202
  RollupCategory.SecurityCases,
203
+ RollupCategory.SecurityHunts,
195
204
  RollupCategory.Slos,
196
205
  RollupCategory.Monitors,
197
206
  RollupCategory.ScheduledMaintenance,
@@ -46,6 +46,7 @@ declare enum NotificationSettingEventType {
46
46
  SEND_SECURITY_PLAYBOOK_APPROVAL_NOTIFICATION = "Send notification when a playbook step on a security case is waiting for my approval",
47
47
  SEND_SECURITY_CASE_TARGET_NOTIFICATION = "Send notification when a security case is about to miss, or misses, a response target",
48
48
  SEND_SECURITY_CASE_TASK_ASSIGNED_NOTIFICATION = "Send notification when a task on a security case is assigned to me",
49
+ SEND_SECURITY_HUNT_FOUND_NOTIFICATION = "Send notification when a scheduled hunt that names me or my team finds security events",
49
50
  SEND_WHEN_USER_IS_ON_CALL_ROSTER = "When user is on-call roster",
50
51
  SEND_WHEN_USER_IS_NEXT_ON_CALL_ROSTER = "When user is next on-call roster",
51
52
  SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY = "When user is added to on-call policy",
@@ -46,6 +46,7 @@ declare enum NotificationSettingEventType {
46
46
  SEND_SECURITY_PLAYBOOK_APPROVAL_NOTIFICATION = "Send notification when a playbook step on a security case is waiting for my approval",
47
47
  SEND_SECURITY_CASE_TARGET_NOTIFICATION = "Send notification when a security case is about to miss, or misses, a response target",
48
48
  SEND_SECURITY_CASE_TASK_ASSIGNED_NOTIFICATION = "Send notification when a task on a security case is assigned to me",
49
+ SEND_SECURITY_HUNT_FOUND_NOTIFICATION = "Send notification when a scheduled hunt that names me or my team finds security events",
49
50
  SEND_WHEN_USER_IS_ON_CALL_ROSTER = "When user is on-call roster",
50
51
  SEND_WHEN_USER_IS_NEXT_ON_CALL_ROSTER = "When user is next on-call roster",
51
52
  SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY = "When user is added to on-call policy",
@@ -79,6 +79,12 @@ var NotificationSettingEventType;
79
79
  NotificationSettingEventType["SEND_SECURITY_CASE_TARGET_NOTIFICATION"] = "Send notification when a security case is about to miss, or misses, a response target";
80
80
  // A task on a security case is handed to the person (SecurityCaseTaskService).
81
81
  NotificationSettingEventType["SEND_SECURITY_CASE_TASK_ASSIGNED_NOTIFICATION"] = "Send notification when a task on a security case is assigned to me";
82
+ /*
83
+ * A scheduled hunt found security events (SecurityHuntNotifications): told
84
+ * to the people the hunt names and the members of the teams it names, who
85
+ * can read its project's hunts and security events.
86
+ */
87
+ NotificationSettingEventType["SEND_SECURITY_HUNT_FOUND_NOTIFICATION"] = "Send notification when a scheduled hunt that names me or my team finds security events";
82
88
  // On Call Notifications
83
89
  NotificationSettingEventType["SEND_WHEN_USER_IS_ON_CALL_ROSTER"] = "When user is on-call roster";
84
90
  NotificationSettingEventType["SEND_WHEN_USER_IS_NEXT_ON_CALL_ROSTER"] = "When user is next on-call roster";
@@ -0,0 +1,67 @@
1
+ export declare const SECURITY_CASE_EVENT_EVIDENCE_MAX_PER_ADD: number;
2
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_TEXT_MAX_LENGTH: number;
3
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_LIST_MAX: number;
4
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_ATTRIBUTES_MAX: number;
5
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_ATTRIBUTE_VALUE_MAX_LENGTH: number;
6
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_COLUMNS: ReadonlyArray<string>;
7
+ export interface SecurityCaseEventHunt {
8
+ id: string;
9
+ name: string;
10
+ }
11
+ export interface SecurityCaseEventSnapshot {
12
+ time: string;
13
+ eventUid: string;
14
+ sourceId: string;
15
+ severityName: string;
16
+ className: string;
17
+ categoryName: string;
18
+ activityName: string;
19
+ statusName: string;
20
+ message: string;
21
+ vendorName: string;
22
+ productName: string;
23
+ ruleName: string;
24
+ principalUser: string;
25
+ principalHost: string;
26
+ principalIp: string;
27
+ targetUser: string;
28
+ targetHost: string;
29
+ targetIp: string;
30
+ targetPort: number | null;
31
+ processName: string;
32
+ processCommandLine: string;
33
+ observables: Array<string>;
34
+ mitreTactics: Array<string>;
35
+ mitreTechniques: Array<string>;
36
+ attributes: {
37
+ [key: string]: string;
38
+ };
39
+ hunt: SecurityCaseEventHunt | null;
40
+ }
41
+ export interface SecurityCaseEventReference {
42
+ eventUid: string;
43
+ time: Date;
44
+ }
45
+ export interface SecurityCaseEventsAddResult {
46
+ added: Array<string>;
47
+ alreadyOnCase: Array<string>;
48
+ notFound: Array<string>;
49
+ }
50
+ export declare function readSecurityCaseEventsAddResult(value: unknown): SecurityCaseEventsAddResult;
51
+ export declare const SECURITY_CASE_EVENTS_ADD_REASONS: {
52
+ alreadyOnCase: {
53
+ message: string;
54
+ };
55
+ notFound: {
56
+ message: string;
57
+ };
58
+ };
59
+ export declare function buildSecurityCaseEventSnapshot(data: {
60
+ event: {
61
+ [column: string]: unknown;
62
+ };
63
+ hunt?: SecurityCaseEventHunt | null | undefined;
64
+ }): SecurityCaseEventSnapshot;
65
+ export declare function readSecurityCaseEventSnapshot(value: unknown): SecurityCaseEventSnapshot | null;
66
+ export declare function getSecurityCaseEventEvidenceName(snapshot: Pick<SecurityCaseEventSnapshot, "message" | "className" | "activityName">): string;
67
+ export declare function readSecurityCaseEventReferences(value: unknown): Array<SecurityCaseEventReference>;
@@ -0,0 +1,67 @@
1
+ export declare const SECURITY_CASE_EVENT_EVIDENCE_MAX_PER_ADD: number;
2
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_TEXT_MAX_LENGTH: number;
3
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_LIST_MAX: number;
4
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_ATTRIBUTES_MAX: number;
5
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_ATTRIBUTE_VALUE_MAX_LENGTH: number;
6
+ export declare const SECURITY_CASE_EVENT_SNAPSHOT_COLUMNS: ReadonlyArray<string>;
7
+ export interface SecurityCaseEventHunt {
8
+ id: string;
9
+ name: string;
10
+ }
11
+ export interface SecurityCaseEventSnapshot {
12
+ time: string;
13
+ eventUid: string;
14
+ sourceId: string;
15
+ severityName: string;
16
+ className: string;
17
+ categoryName: string;
18
+ activityName: string;
19
+ statusName: string;
20
+ message: string;
21
+ vendorName: string;
22
+ productName: string;
23
+ ruleName: string;
24
+ principalUser: string;
25
+ principalHost: string;
26
+ principalIp: string;
27
+ targetUser: string;
28
+ targetHost: string;
29
+ targetIp: string;
30
+ targetPort: number | null;
31
+ processName: string;
32
+ processCommandLine: string;
33
+ observables: Array<string>;
34
+ mitreTactics: Array<string>;
35
+ mitreTechniques: Array<string>;
36
+ attributes: {
37
+ [key: string]: string;
38
+ };
39
+ hunt: SecurityCaseEventHunt | null;
40
+ }
41
+ export interface SecurityCaseEventReference {
42
+ eventUid: string;
43
+ time: Date;
44
+ }
45
+ export interface SecurityCaseEventsAddResult {
46
+ added: Array<string>;
47
+ alreadyOnCase: Array<string>;
48
+ notFound: Array<string>;
49
+ }
50
+ export declare function readSecurityCaseEventsAddResult(value: unknown): SecurityCaseEventsAddResult;
51
+ export declare const SECURITY_CASE_EVENTS_ADD_REASONS: {
52
+ alreadyOnCase: {
53
+ message: string;
54
+ };
55
+ notFound: {
56
+ message: string;
57
+ };
58
+ };
59
+ export declare function buildSecurityCaseEventSnapshot(data: {
60
+ event: {
61
+ [column: string]: unknown;
62
+ };
63
+ hunt?: SecurityCaseEventHunt | null | undefined;
64
+ }): SecurityCaseEventSnapshot;
65
+ export declare function readSecurityCaseEventSnapshot(value: unknown): SecurityCaseEventSnapshot | null;
66
+ export declare function getSecurityCaseEventEvidenceName(snapshot: Pick<SecurityCaseEventSnapshot, "message" | "className" | "activityName">): string;
67
+ export declare function readSecurityCaseEventReferences(value: unknown): Array<SecurityCaseEventReference>;