@badger_badger/badger_hq 1.5.1 → 1.6.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/CHANGELOG.md +27 -0
- package/README.md +16 -12
- package/dist/{agent-session-Bsn8W7Xv.d.cts → agent-session-oZI9RyQ_.d.cts} +618 -188
- package/dist/{agent-session-Bsn8W7Xv.d.ts → agent-session-oZI9RyQ_.d.ts} +618 -188
- package/dist/index.cjs +102 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +982 -148
- package/dist/index.d.ts +982 -148
- package/dist/index.js +92 -4
- package/dist/index.js.map +1 -1
- package/dist/mongo/index.cjs +171 -6
- package/dist/mongo/index.cjs.map +1 -1
- package/dist/mongo/index.d.cts +567 -101
- package/dist/mongo/index.d.ts +567 -101
- package/dist/mongo/index.js +170 -7
- package/dist/mongo/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -88,6 +88,21 @@ var SOURCE_ROUTE_VALUES = ["scraper", "monitor", "waiting_for_scraper"];
|
|
|
88
88
|
var SourceRoute = zod.z.enum(SOURCE_ROUTE_VALUES);
|
|
89
89
|
var SOURCE_STATUS_VALUES = ["active", "paused", "closed", "access_problem"];
|
|
90
90
|
var SourceStatus = zod.z.enum(SOURCE_STATUS_VALUES);
|
|
91
|
+
var ACCESS_ISSUE_VALUES = [
|
|
92
|
+
"login_required",
|
|
93
|
+
"private",
|
|
94
|
+
"bot_detection",
|
|
95
|
+
"captcha",
|
|
96
|
+
"geo_blocked",
|
|
97
|
+
"rate_limited",
|
|
98
|
+
"not_found",
|
|
99
|
+
"no_collector",
|
|
100
|
+
"collector_full",
|
|
101
|
+
"other"
|
|
102
|
+
];
|
|
103
|
+
var AccessIssue = zod.z.enum(ACCESS_ISSUE_VALUES);
|
|
104
|
+
var CAPTURE_WINDOW_MODE_VALUES = ["last_days", "range"];
|
|
105
|
+
var CaptureWindowMode = zod.z.enum(CAPTURE_WINDOW_MODE_VALUES);
|
|
91
106
|
var DISCOVERED_BY_TYPE_VALUES = ["scout", "analyst", "agent", "client", "import"];
|
|
92
107
|
var DiscoveredByType = zod.z.enum(DISCOVERED_BY_TYPE_VALUES);
|
|
93
108
|
var SOURCE_IMPORT_KIND_VALUES = ["create", "update"];
|
|
@@ -135,6 +150,8 @@ var AGENT_SOURCE_OUTCOME_VALUES = [
|
|
|
135
150
|
var AgentSourceOutcome = zod.z.enum(AGENT_SOURCE_OUTCOME_VALUES);
|
|
136
151
|
var CAPTURE_STATUS_VALUES = ["uploaded", "analyzing", "analyzed", "failed", "expired"];
|
|
137
152
|
var CaptureStatus = zod.z.enum(CAPTURE_STATUS_VALUES);
|
|
153
|
+
var HOURS_LOG_SOURCE_VALUES = ["manual", "inferred"];
|
|
154
|
+
var HoursLogSource = zod.z.enum(HOURS_LOG_SOURCE_VALUES);
|
|
138
155
|
var CAPTURE_DOM_STATUS_VALUES = ["ok", "unavailable", "truncated"];
|
|
139
156
|
var CaptureDomStatus = zod.z.enum(CAPTURE_DOM_STATUS_VALUES);
|
|
140
157
|
var LLM_CAPABILITY_VALUES = ["plan", "vision_extract", "judge", "chat"];
|
|
@@ -216,6 +233,51 @@ var TaskCriteriaSchema = zod.z.object({
|
|
|
216
233
|
coverageWindow: CoverageWindowSchema.optional(),
|
|
217
234
|
emergency: zod.z.boolean().default(false)
|
|
218
235
|
});
|
|
236
|
+
var MAX_CAPTURE_WINDOW_DAYS = 90;
|
|
237
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
238
|
+
function isHttpUrl(value) {
|
|
239
|
+
try {
|
|
240
|
+
const { protocol } = new URL(value);
|
|
241
|
+
return protocol === "http:" || protocol === "https:";
|
|
242
|
+
} catch {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
var WindowDate = zod.z.union([zod.z.date(), zod.z.string().datetime({ offset: true })]).pipe(zod.z.coerce.date());
|
|
247
|
+
var TaskTargetSchema = zod.z.object({
|
|
248
|
+
sourceId: ObjectIdString.optional(),
|
|
249
|
+
platform: Platform,
|
|
250
|
+
url: zod.z.string().url().refine(isHttpUrl, "Expected an http(s) URL"),
|
|
251
|
+
label: zod.z.string().min(1).max(200).optional(),
|
|
252
|
+
/** Why a person collects it instead of a scraper. */
|
|
253
|
+
accessIssue: AccessIssue.optional(),
|
|
254
|
+
note: zod.z.string().max(500).optional()
|
|
255
|
+
});
|
|
256
|
+
var LastDaysWindowSchema = zod.z.object({
|
|
257
|
+
mode: zod.z.literal(CaptureWindowMode.enum.last_days),
|
|
258
|
+
days: zod.z.number().int().min(1).max(MAX_CAPTURE_WINDOW_DAYS)
|
|
259
|
+
});
|
|
260
|
+
var RangeWindowSchema = zod.z.object({
|
|
261
|
+
mode: zod.z.literal(CaptureWindowMode.enum.range),
|
|
262
|
+
start: WindowDate,
|
|
263
|
+
end: WindowDate
|
|
264
|
+
});
|
|
265
|
+
var CaptureWindowSchema = zod.z.discriminatedUnion("mode", [LastDaysWindowSchema, RangeWindowSchema]).superRefine((w, ctx) => {
|
|
266
|
+
if (w.mode !== "range" || !(w.start instanceof Date) || !(w.end instanceof Date)) return;
|
|
267
|
+
if (w.end.getTime() <= w.start.getTime()) {
|
|
268
|
+
ctx.addIssue({
|
|
269
|
+
code: zod.z.ZodIssueCode.custom,
|
|
270
|
+
message: "captureWindow.end must be after captureWindow.start",
|
|
271
|
+
path: ["end"]
|
|
272
|
+
});
|
|
273
|
+
} else if (w.end.getTime() - w.start.getTime() > MAX_CAPTURE_WINDOW_DAYS * DAY_MS) {
|
|
274
|
+
ctx.addIssue({
|
|
275
|
+
code: zod.z.ZodIssueCode.custom,
|
|
276
|
+
message: `captureWindow range must be at most ${MAX_CAPTURE_WINDOW_DAYS} days`,
|
|
277
|
+
path: ["end"]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
});
|
|
219
281
|
var MissionSchema = zod.z.object({
|
|
220
282
|
_id: ObjectIdString,
|
|
221
283
|
orgId: ClerkOrgId,
|
|
@@ -251,6 +313,10 @@ var TaskSchema = zod.z.object({
|
|
|
251
313
|
keywords: zod.z.array(zod.z.string().min(1)).default([]),
|
|
252
314
|
searchQueries: zod.z.array(zod.z.string().min(1)).default([]),
|
|
253
315
|
criteria: TaskCriteriaSchema,
|
|
316
|
+
/** Monitor: the one source to collect. Discovery: optional source to search inside. */
|
|
317
|
+
target: TaskTargetSchema.optional(),
|
|
318
|
+
/** Monitor: what to capture (last N days, or a fixed range). */
|
|
319
|
+
captureWindow: CaptureWindowSchema.optional(),
|
|
254
320
|
status: TaskStatus.default("draft"),
|
|
255
321
|
approvedBy: ClerkUserId.optional(),
|
|
256
322
|
approvedAt: zod.z.coerce.date().optional(),
|
|
@@ -309,7 +375,9 @@ var HoursLogSchema = zod.z.object({
|
|
|
309
375
|
scoutUserId: ClerkUserId,
|
|
310
376
|
minutes: zod.z.number().int().positive(),
|
|
311
377
|
note: zod.z.string(),
|
|
312
|
-
date: zod.z.coerce.date()
|
|
378
|
+
date: zod.z.coerce.date(),
|
|
379
|
+
assignmentId: ObjectIdString.optional(),
|
|
380
|
+
source: HoursLogSource.optional()
|
|
313
381
|
}).merge(TimestampsSchema).merge(SoftDeleteSchema);
|
|
314
382
|
var HoursLogCreateSchema = HoursLogSchema.omit({
|
|
315
383
|
_id: true,
|
|
@@ -715,6 +783,8 @@ var AgentSessionSchema = zod.z.object({
|
|
|
715
783
|
lastSeq: count(),
|
|
716
784
|
stats: AgentSessionStatsSchema.default({}),
|
|
717
785
|
budget: AgentSessionBudgetSchema.default({}),
|
|
786
|
+
/** The task's capture window as dates, fixed when the session started (`last_days` counted back from then). */
|
|
787
|
+
captureWindow: CoverageWindowSchema.optional(),
|
|
718
788
|
/** Mode-specific engine state (search plan cursor, monitor queue). Opaque to clients. */
|
|
719
789
|
state: zod.z.unknown().optional()
|
|
720
790
|
}).merge(TimestampsSchema);
|
|
@@ -820,7 +890,14 @@ var CaptureDomSummarySchema = zod.z.object({
|
|
|
820
890
|
var CaptureSchema = zod.z.object({
|
|
821
891
|
_id: ObjectIdString,
|
|
822
892
|
orgId: ClerkOrgId,
|
|
823
|
-
|
|
893
|
+
/** Legacy: captures uploaded into a live session. Task-tagged captures have none. */
|
|
894
|
+
sessionId: ObjectIdString.optional(),
|
|
895
|
+
/** The assignment (and so the task) the person sent this capture for. */
|
|
896
|
+
assignmentId: ObjectIdString.optional(),
|
|
897
|
+
taskId: ObjectIdString.optional(),
|
|
898
|
+
missionId: ObjectIdString.optional(),
|
|
899
|
+
/** Who sent it; used to work out their hours. */
|
|
900
|
+
userId: ClerkUserId.optional(),
|
|
824
901
|
/** From `chrome.tabs`, never from page content. */
|
|
825
902
|
url: zod.z.string().url(),
|
|
826
903
|
title: zod.z.string().max(500),
|
|
@@ -836,6 +913,10 @@ var CaptureSchema = zod.z.object({
|
|
|
836
913
|
/** Validated `vision_extract` output; shape depends on session mode. */
|
|
837
914
|
analysis: zod.z.unknown().optional(),
|
|
838
915
|
error: zod.z.string().max(1e3).optional(),
|
|
916
|
+
/** Analysis attempts by the capture worker; it gives up (`failed`) after a few. */
|
|
917
|
+
attempts: zod.z.number().int().min(0).default(0),
|
|
918
|
+
/** When the worker claimed it (`analyzing`); an old claim is taken over after a restart. */
|
|
919
|
+
claimedAt: zod.z.coerce.date().optional(),
|
|
839
920
|
/** Blob deleted and status set to `expired` after this instant (CAPTURE_RETENTION_DAYS). */
|
|
840
921
|
expiresAt: zod.z.coerce.date()
|
|
841
922
|
}).merge(TimestampsSchema);
|
|
@@ -916,6 +997,7 @@ var AgentTaskCriteriaSchema = zod.z.object({
|
|
|
916
997
|
coverageWindow: CoverageWindowSchema.optional(),
|
|
917
998
|
emergency: zod.z.boolean()
|
|
918
999
|
});
|
|
1000
|
+
var AgentTaskTargetSchema = TaskTargetSchema.omit({ sourceId: true });
|
|
919
1001
|
var AgentTaskSchema = zod.z.object({
|
|
920
1002
|
id: ObjectIdString,
|
|
921
1003
|
title: zod.z.string(),
|
|
@@ -924,6 +1006,8 @@ var AgentTaskSchema = zod.z.object({
|
|
|
924
1006
|
keywords: zod.z.array(zod.z.string()),
|
|
925
1007
|
searchQueries: zod.z.array(zod.z.string()),
|
|
926
1008
|
criteria: AgentTaskCriteriaSchema,
|
|
1009
|
+
target: AgentTaskTargetSchema.optional(),
|
|
1010
|
+
captureWindow: CaptureWindowSchema.optional(),
|
|
927
1011
|
status: TaskStatus,
|
|
928
1012
|
version: zod.z.number().int().min(1),
|
|
929
1013
|
updatedAt: zod.z.coerce.date()
|
|
@@ -984,7 +1068,11 @@ var AgentSessionViewSchema = zod.z.object({
|
|
|
984
1068
|
endedAt: zod.z.coerce.date().nullable(),
|
|
985
1069
|
activeMinutes: zod.z.number().int().min(0),
|
|
986
1070
|
lastSeq: zod.z.number().int().min(0),
|
|
987
|
-
stats: AgentSessionStatsSchema
|
|
1071
|
+
stats: AgentSessionStatsSchema,
|
|
1072
|
+
/** The task's source (no internal id), when it has one. */
|
|
1073
|
+
target: AgentTaskTargetSchema.optional(),
|
|
1074
|
+
/** The capture window resolved to dates when the session started. */
|
|
1075
|
+
captureWindow: CoverageWindowSchema.optional()
|
|
988
1076
|
});
|
|
989
1077
|
var AgentMessageViewSchema = zod.z.object({
|
|
990
1078
|
id: ObjectIdString,
|
|
@@ -1101,6 +1189,7 @@ var PriorityAlertResponseSchema = zod.z.object({
|
|
|
1101
1189
|
var INTERNAL_ERROR_CODE_VALUES = ["UNAUTHENTICATED", "NOT_FOUND", "VALIDATION_ERROR", "INTERNAL"];
|
|
1102
1190
|
var InternalErrorCode = zod.z.enum(INTERNAL_ERROR_CODE_VALUES);
|
|
1103
1191
|
|
|
1192
|
+
exports.ACCESS_ISSUE_VALUES = ACCESS_ISSUE_VALUES;
|
|
1104
1193
|
exports.AGENT_CARD_KIND_VALUES = AGENT_CARD_KIND_VALUES;
|
|
1105
1194
|
exports.AGENT_ERROR_CODE_VALUES = AGENT_ERROR_CODE_VALUES;
|
|
1106
1195
|
exports.AGENT_MESSAGE_KIND_VALUES = AGENT_MESSAGE_KIND_VALUES;
|
|
@@ -1112,6 +1201,7 @@ exports.AGENT_SOURCE_OUTCOME_VALUES = AGENT_SOURCE_OUTCOME_VALUES;
|
|
|
1112
1201
|
exports.ASSIGNEE_TYPE_VALUES = ASSIGNEE_TYPE_VALUES;
|
|
1113
1202
|
exports.ASSIGNMENT_SOURCE_VALUES = ASSIGNMENT_SOURCE_VALUES;
|
|
1114
1203
|
exports.ASSIGNMENT_STATUS_VALUES = ASSIGNMENT_STATUS_VALUES;
|
|
1204
|
+
exports.AccessIssue = AccessIssue;
|
|
1115
1205
|
exports.AgentActiveSessionResponseSchema = AgentActiveSessionResponseSchema;
|
|
1116
1206
|
exports.AgentAssignmentItemSchema = AgentAssignmentItemSchema;
|
|
1117
1207
|
exports.AgentAssignmentVersionSchema = AgentAssignmentVersionSchema;
|
|
@@ -1149,6 +1239,7 @@ exports.AgentSourceOutcome = AgentSourceOutcome;
|
|
|
1149
1239
|
exports.AgentStreamEventSchema = AgentStreamEventSchema;
|
|
1150
1240
|
exports.AgentTaskCriteriaSchema = AgentTaskCriteriaSchema;
|
|
1151
1241
|
exports.AgentTaskSchema = AgentTaskSchema;
|
|
1242
|
+
exports.AgentTaskTargetSchema = AgentTaskTargetSchema;
|
|
1152
1243
|
exports.AnalystProfileSchema = AnalystProfileSchema;
|
|
1153
1244
|
exports.AnalystProfileUpdateSchema = AnalystProfileUpdateSchema;
|
|
1154
1245
|
exports.ApiErrorSchema = ApiErrorSchema;
|
|
@@ -1167,6 +1258,7 @@ exports.AvailabilityWindowSchema = AvailabilityWindowSchema;
|
|
|
1167
1258
|
exports.BlobRefSchema = BlobRefSchema;
|
|
1168
1259
|
exports.CAPTURE_DOM_STATUS_VALUES = CAPTURE_DOM_STATUS_VALUES;
|
|
1169
1260
|
exports.CAPTURE_STATUS_VALUES = CAPTURE_STATUS_VALUES;
|
|
1261
|
+
exports.CAPTURE_WINDOW_MODE_VALUES = CAPTURE_WINDOW_MODE_VALUES;
|
|
1170
1262
|
exports.COLLECTIONS = COLLECTIONS;
|
|
1171
1263
|
exports.COLLECTOR_TYPE_VALUES = COLLECTOR_TYPE_VALUES;
|
|
1172
1264
|
exports.CaptureCreateSchema = CaptureCreateSchema;
|
|
@@ -1178,6 +1270,8 @@ exports.CaptureRegionSchema = CaptureRegionSchema;
|
|
|
1178
1270
|
exports.CaptureSchema = CaptureSchema;
|
|
1179
1271
|
exports.CaptureStatus = CaptureStatus;
|
|
1180
1272
|
exports.CaptureThumbCardSchema = CaptureThumbCardSchema;
|
|
1273
|
+
exports.CaptureWindowMode = CaptureWindowMode;
|
|
1274
|
+
exports.CaptureWindowSchema = CaptureWindowSchema;
|
|
1181
1275
|
exports.ClerkOrgId = ClerkOrgId;
|
|
1182
1276
|
exports.ClerkUserId = ClerkUserId;
|
|
1183
1277
|
exports.CollectorSchema = CollectorSchema;
|
|
@@ -1218,8 +1312,10 @@ exports.Email = Email;
|
|
|
1218
1312
|
exports.GLOBAL_LOAD_SCOPE = GLOBAL_LOAD_SCOPE;
|
|
1219
1313
|
exports.GeoSchema = GeoSchema;
|
|
1220
1314
|
exports.HHmm = HHmm;
|
|
1315
|
+
exports.HOURS_LOG_SOURCE_VALUES = HOURS_LOG_SOURCE_VALUES;
|
|
1221
1316
|
exports.HoursLogCreateSchema = HoursLogCreateSchema;
|
|
1222
1317
|
exports.HoursLogSchema = HoursLogSchema;
|
|
1318
|
+
exports.HoursLogSource = HoursLogSource;
|
|
1223
1319
|
exports.HoursLogUpdateSchema = HoursLogUpdateSchema;
|
|
1224
1320
|
exports.HoursProposalCardSchema = HoursProposalCardSchema;
|
|
1225
1321
|
exports.INTERNAL_ERROR_CODE_VALUES = INTERNAL_ERROR_CODE_VALUES;
|
|
@@ -1237,6 +1333,7 @@ exports.LlmProvider = LlmProvider;
|
|
|
1237
1333
|
exports.LlmUsageSchema = LlmUsageSchema;
|
|
1238
1334
|
exports.LoadScope = LoadScope;
|
|
1239
1335
|
exports.MAX_AGENT_MESSAGE_TEXT_LENGTH = MAX_AGENT_MESSAGE_TEXT_LENGTH;
|
|
1336
|
+
exports.MAX_CAPTURE_WINDOW_DAYS = MAX_CAPTURE_WINDOW_DAYS;
|
|
1240
1337
|
exports.MAX_RATING_COMMENT_LENGTH = MAX_RATING_COMMENT_LENGTH;
|
|
1241
1338
|
exports.MAX_SOURCE_IMPORT_ROW_ERRORS = MAX_SOURCE_IMPORT_ROW_ERRORS;
|
|
1242
1339
|
exports.MAX_SOURCE_INTAKE_CANDIDATES = MAX_SOURCE_INTAKE_CANDIDATES;
|
|
@@ -1327,10 +1424,12 @@ exports.TaskKind = TaskKind;
|
|
|
1327
1424
|
exports.TaskOrigin = TaskOrigin;
|
|
1328
1425
|
exports.TaskSchema = TaskSchema;
|
|
1329
1426
|
exports.TaskStatus = TaskStatus;
|
|
1427
|
+
exports.TaskTargetSchema = TaskTargetSchema;
|
|
1330
1428
|
exports.TaskUpdateSchema = TaskUpdateSchema;
|
|
1331
1429
|
exports.TimeZone = TimeZone;
|
|
1332
1430
|
exports.TimestampsSchema = TimestampsSchema;
|
|
1333
1431
|
exports.VETTING_STATUS_VALUES = VETTING_STATUS_VALUES;
|
|
1334
1432
|
exports.VettingStatus = VettingStatus;
|
|
1433
|
+
exports.isHttpUrl = isHttpUrl;
|
|
1335
1434
|
//# sourceMappingURL=index.cjs.map
|
|
1336
1435
|
//# sourceMappingURL=index.cjs.map
|