@sentry/junior 0.102.3 → 0.104.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/{agent-hooks-I4I2DHSW.js → agent-hooks-EOFSY2PD.js} +5 -5
- package/dist/api/conversations/archive.d.ts +7 -0
- package/dist/api/conversations/detail.d.ts +7 -0
- package/dist/api/conversations/list.d.ts +109 -0
- package/dist/api/conversations/routes.d.ts +3 -0
- package/dist/api/conversations/schema.d.ts +88 -69
- package/dist/api/conversations/stats.d.ts +7 -0
- package/dist/api/conversations/subagent.d.ts +7 -0
- package/dist/api/http.d.ts +5 -0
- package/dist/api/locations/detail.d.ts +10 -2
- package/dist/api/locations/list.d.ts +7 -0
- package/dist/api/locations/routes.d.ts +3 -0
- package/dist/api/locations/schema.d.ts +4 -3
- package/dist/api/people/list.d.ts +7 -0
- package/dist/api/people/profile.d.ts +7 -0
- package/dist/api/people/routes.d.ts +3 -0
- package/dist/api/people/schema.d.ts +35 -33
- package/dist/api/people/shared.d.ts +4 -4
- package/dist/api/route.d.ts +7 -0
- package/dist/api/schema.js +11 -17
- package/dist/api.js +2184 -88
- package/dist/app.js +120 -162
- package/dist/chat/conversations/history.d.ts +6 -6
- package/dist/chat/conversations/store.d.ts +1 -0
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/resource-events/store.d.ts +2 -2
- package/dist/chat/sandbox/runtime-dependencies.d.ts +2 -0
- package/dist/chat/sandbox/sandbox.d.ts +1 -0
- package/dist/chat/services/provider-retry.d.ts +1 -2
- package/dist/chat/slack/tools/conversation-search.d.ts +2 -2
- package/dist/chat/state/session-log.d.ts +2 -2
- package/dist/chat/task-execution/store.d.ts +2 -2
- package/dist/chat/tools/search-tools.d.ts +2 -2
- package/dist/{chunk-ZSHL44IQ.js → chunk-4PDVOHXP.js} +1 -1
- package/dist/{chunk-3OABPOHR.js → chunk-7G4J3CR7.js} +11 -2
- package/dist/chunk-AIRE7Q2W.js +362 -0
- package/dist/{chunk-QZGVPPIJ.js → chunk-BCULHGZK.js} +24 -4
- package/dist/{chunk-IQ36I3DF.js → chunk-CCTCIISK.js} +1 -1
- package/dist/{chunk-SHBPSE7A.js → chunk-M3UAVLEN.js} +2 -3
- package/dist/{chunk-EMUZSROX.js → chunk-O7ILGCMJ.js} +78 -1
- package/dist/{chunk-EOB77KME.js → chunk-QDKRE3LS.js} +340 -9
- package/dist/{chunk-DTUSCR2Y.js → chunk-QVTVCJR4.js} +7 -7
- package/dist/{chunk-5K4N73TP.js → chunk-RMZ65YAA.js} +3 -3
- package/dist/{chunk-VSAFV2GI.js → chunk-RYDF4GOX.js} +3 -3
- package/dist/{chunk-ZIX4PNBI.js → chunk-TMWUGGSA.js} +37 -35
- package/dist/{chunk-3UK5DFKW.js → chunk-U26ZWZCN.js} +1 -1
- package/dist/{chunk-X2IPNCB5.js → chunk-VDHMFCDY.js} +65 -12
- package/dist/cli/chat.js +13 -14
- package/dist/cli/plugins.js +6 -6
- package/dist/cli/snapshot-warmup.js +7 -3
- package/dist/cli/upgrade.js +6 -7
- package/dist/db/schema/conversations.d.ts +17 -0
- package/dist/db/schema.d.ts +17 -0
- package/dist/{db-6QP6HY7U.js → db-PDMC67T3.js} +2 -2
- package/dist/{legacy-import-R3BMM2GH.js → legacy-import-G333RHJZ.js} +3 -3
- package/dist/reporting-schema.d.ts +4 -4
- package/dist/{runner-C2ZTIOUD.js → runner-6A7MQRUE.js} +9 -10
- package/migrations/0004_useful_magus.sql +1 -0
- package/migrations/meta/0004_snapshot.json +1041 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -6
- package/dist/api/conversations/list.query.d.ts +0 -103
- package/dist/chunk-2RNOB32R.js +0 -17
- package/dist/chunk-4XNQSJAX.js +0 -331
- package/dist/chunk-4YN2ZXKB.js +0 -66
- package/dist/chunk-B5QS4AVO.js +0 -319
- package/dist/chunk-F4CQEUTP.js +0 -77
- package/dist/chunk-HYDQULR2.js +0 -214
- package/dist/chunk-KFP3TZOS.js +0 -102
- package/dist/chunk-LJB2TLVT.js +0 -273
- package/dist/chunk-LVUKF5CE.js +0 -63
- package/dist/chunk-NSP6OGL2.js +0 -671
- package/dist/chunk-QNVHH5PU.js +0 -20
- package/dist/chunk-QOZOJNSE.js +0 -96
- package/dist/chunk-WPHCUGN7.js +0 -84
- package/dist/detail-OEIVZYXS.js +0 -68
- package/dist/detail-V37NTVBN.js +0 -29
- package/dist/list-AJ6RWBOG.js +0 -30
- package/dist/list-FWLIZHSW.js +0 -30
- package/dist/list-NTUT6A5M.js +0 -121
- package/dist/plugin-conversations-F3IBVNFX.js +0 -37
- package/dist/profile-3FRQP4HP.js +0 -212
- package/dist/reporting/plugin-conversations.d.ts +0 -3
- package/dist/stats-7UFY6FPE.js +0 -174
- package/dist/subagent-X3ZWJHR4.js +0 -49
|
@@ -47,7 +47,7 @@ declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
47
47
|
sessionId: z.ZodDefault<z.ZodString>;
|
|
48
48
|
message: z.ZodPipe<z.ZodObject<{
|
|
49
49
|
role: z.ZodString;
|
|
50
|
-
}, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").
|
|
50
|
+
}, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").BashExecutionMessage | import("@earendil-works/pi-agent-core").CustomMessage<unknown> | import("@earendil-works/pi-agent-core").BranchSummaryMessage | import("@earendil-works/pi-agent-core").CompactionSummaryMessage, {
|
|
51
51
|
[x: string]: unknown;
|
|
52
52
|
role: string;
|
|
53
53
|
}>>;
|
|
@@ -85,7 +85,7 @@ declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
85
85
|
sessionId: z.ZodDefault<z.ZodString>;
|
|
86
86
|
messages: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
87
87
|
role: z.ZodString;
|
|
88
|
-
}, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").
|
|
88
|
+
}, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").BashExecutionMessage | import("@earendil-works/pi-agent-core").CustomMessage<unknown> | import("@earendil-works/pi-agent-core").BranchSummaryMessage | import("@earendil-works/pi-agent-core").CompactionSummaryMessage, {
|
|
89
89
|
[x: string]: unknown;
|
|
90
90
|
role: string;
|
|
91
91
|
}>>>;
|
|
@@ -128,7 +128,7 @@ export declare function completeConversationWork(args: {
|
|
|
128
128
|
conversationStore?: ConversationStore;
|
|
129
129
|
nowMs?: number;
|
|
130
130
|
state?: StateAdapter;
|
|
131
|
-
}): Promise<"
|
|
131
|
+
}): Promise<"pending" | "completed" | "lost_lease">;
|
|
132
132
|
/** Record one failed delivery attempt and dead-letter messages at their limit. */
|
|
133
133
|
export declare function recordAttemptFailure(args: {
|
|
134
134
|
conversationId: string;
|
|
@@ -145,7 +145,7 @@ export declare function deadLetterAttempt(args: {
|
|
|
145
145
|
conversationStore?: ConversationStore;
|
|
146
146
|
nowMs?: number;
|
|
147
147
|
state?: StateAdapter;
|
|
148
|
-
}): Promise<"
|
|
148
|
+
}): Promise<"pending" | "failed" | "lost_lease">;
|
|
149
149
|
/** Clear an expired durable lease so a later worker can resume safely. */
|
|
150
150
|
export declare function clearExpiredConversationLease(args: {
|
|
151
151
|
conversationId: string;
|
|
@@ -32,7 +32,7 @@ export declare function createSearchToolsTool(catalogTools: Record<string, AnyTo
|
|
|
32
32
|
tools: {
|
|
33
33
|
tool_name: string;
|
|
34
34
|
description: string;
|
|
35
|
-
exposure: "
|
|
35
|
+
exposure: "hidden" | "direct" | "deferred" | "modelOnly";
|
|
36
36
|
signature: string;
|
|
37
37
|
call: {
|
|
38
38
|
tool_name: string;
|
|
@@ -77,7 +77,7 @@ export declare function createSearchToolsTool(catalogTools: Record<string, AnyTo
|
|
|
77
77
|
tools: {
|
|
78
78
|
tool_name: string;
|
|
79
79
|
description: string;
|
|
80
|
-
exposure: "
|
|
80
|
+
exposure: "hidden" | "direct" | "deferred" | "modelOnly";
|
|
81
81
|
signature: string;
|
|
82
82
|
call: {
|
|
83
83
|
tool_name: string;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getStateAdapter,
|
|
9
9
|
toOptionalTrimmed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M3UAVLEN.js";
|
|
11
11
|
import {
|
|
12
12
|
pluginCatalogRuntime
|
|
13
13
|
} from "./chunk-77LHNQK4.js";
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
withSpan
|
|
16
16
|
} from "./chunk-AEWZ7F65.js";
|
|
17
17
|
|
|
18
|
+
// src/chat/sandbox/runtime-dependencies.ts
|
|
19
|
+
var GLOBAL_RUNTIME_DEPENDENCIES = [
|
|
20
|
+
{ type: "system", package: "docker" }
|
|
21
|
+
];
|
|
22
|
+
|
|
18
23
|
// src/chat/sandbox/runtime-dependency-snapshots.ts
|
|
19
24
|
import { createHash } from "crypto";
|
|
20
25
|
import { Sandbox } from "@vercel/sandbox";
|
|
@@ -180,7 +185,10 @@ function parseFloatingDepMaxAgeMs() {
|
|
|
180
185
|
return parsed;
|
|
181
186
|
}
|
|
182
187
|
function buildDependencyProfile(runtime) {
|
|
183
|
-
const dependencies =
|
|
188
|
+
const dependencies = [
|
|
189
|
+
...GLOBAL_RUNTIME_DEPENDENCIES,
|
|
190
|
+
...pluginCatalogRuntime.getRuntimeDependencies()
|
|
191
|
+
];
|
|
184
192
|
const postinstall = pluginCatalogRuntime.getRuntimePostinstall();
|
|
185
193
|
if (dependencies.length === 0 && postinstall.length === 0) {
|
|
186
194
|
return null;
|
|
@@ -693,6 +701,7 @@ export {
|
|
|
693
701
|
runNonInteractiveCommand,
|
|
694
702
|
getVercelSandboxCredentials,
|
|
695
703
|
getSandboxResources,
|
|
704
|
+
GLOBAL_RUNTIME_DEPENDENCIES,
|
|
696
705
|
createSandboxInstance,
|
|
697
706
|
getRuntimeDependencyProfileHash,
|
|
698
707
|
resolveRuntimeDependencySnapshot,
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import {
|
|
2
|
+
usageSchema
|
|
3
|
+
} from "./chunk-PDO5BLNM.js";
|
|
4
|
+
import {
|
|
5
|
+
juniorDestinationKindSchema
|
|
6
|
+
} from "./chunk-FXFQNHRU.js";
|
|
7
|
+
|
|
8
|
+
// src/api/activity.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var dailyConversationActivitySchema = z.object({
|
|
11
|
+
active: z.number(),
|
|
12
|
+
conversations: z.number(),
|
|
13
|
+
date: z.string(),
|
|
14
|
+
durationMs: z.number(),
|
|
15
|
+
failed: z.number(),
|
|
16
|
+
tokens: z.number().optional()
|
|
17
|
+
}).strict();
|
|
18
|
+
function emptyActivityDay(date) {
|
|
19
|
+
return {
|
|
20
|
+
active: 0,
|
|
21
|
+
conversations: 0,
|
|
22
|
+
date,
|
|
23
|
+
durationMs: 0,
|
|
24
|
+
failed: 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function activityDays(days, nowMs, count) {
|
|
28
|
+
const items = [];
|
|
29
|
+
const end = new Date(nowMs);
|
|
30
|
+
end.setUTCHours(0, 0, 0, 0);
|
|
31
|
+
const start = new Date(end);
|
|
32
|
+
start.setUTCDate(start.getUTCDate() - (count - 1));
|
|
33
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
34
|
+
const date = cursor.toISOString().slice(0, 10);
|
|
35
|
+
items.push(days.get(date) ?? emptyActivityDay(date));
|
|
36
|
+
}
|
|
37
|
+
return items;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/api/conversations/schema.ts
|
|
41
|
+
import { z as z2 } from "zod";
|
|
42
|
+
var conversationReportStatusSchema = z2.enum([
|
|
43
|
+
"active",
|
|
44
|
+
"completed",
|
|
45
|
+
"failed"
|
|
46
|
+
]);
|
|
47
|
+
var conversationSurfaceSchema = z2.enum([
|
|
48
|
+
"api",
|
|
49
|
+
"internal",
|
|
50
|
+
"scheduler",
|
|
51
|
+
"slack"
|
|
52
|
+
]);
|
|
53
|
+
var conversationUsageSchema = usageSchema;
|
|
54
|
+
var actorIdentitySchema = z2.object({
|
|
55
|
+
email: z2.string().optional(),
|
|
56
|
+
fullName: z2.string().optional(),
|
|
57
|
+
slackUserId: z2.string().optional(),
|
|
58
|
+
slackUserName: z2.string().optional()
|
|
59
|
+
}).strict();
|
|
60
|
+
var conversationSummaryReportSchema = z2.object({
|
|
61
|
+
displayTitle: z2.string(),
|
|
62
|
+
cumulativeDurationMs: z2.number(),
|
|
63
|
+
cumulativeUsage: conversationUsageSchema.optional(),
|
|
64
|
+
conversationId: z2.string(),
|
|
65
|
+
status: conversationReportStatusSchema,
|
|
66
|
+
startedAt: z2.string(),
|
|
67
|
+
lastSeenAt: z2.string(),
|
|
68
|
+
lastProgressAt: z2.string(),
|
|
69
|
+
surface: conversationSurfaceSchema,
|
|
70
|
+
actorIdentity: actorIdentitySchema.optional(),
|
|
71
|
+
archivedAt: z2.string().optional(),
|
|
72
|
+
channel: z2.string().optional(),
|
|
73
|
+
channelName: z2.string().optional(),
|
|
74
|
+
channelNameRedacted: z2.boolean().optional(),
|
|
75
|
+
locationId: z2.string().optional(),
|
|
76
|
+
sentryTraceUrl: z2.string().optional(),
|
|
77
|
+
traceId: z2.string().optional()
|
|
78
|
+
}).strict();
|
|
79
|
+
var transcriptPartTypeSchema = z2.enum([
|
|
80
|
+
"text",
|
|
81
|
+
"thinking",
|
|
82
|
+
"tool_call",
|
|
83
|
+
"tool_result",
|
|
84
|
+
"unknown"
|
|
85
|
+
]);
|
|
86
|
+
var transcriptPartSchema = z2.object({
|
|
87
|
+
bytes: z2.number().optional(),
|
|
88
|
+
chars: z2.number().optional(),
|
|
89
|
+
id: z2.string().optional(),
|
|
90
|
+
input: z2.unknown().optional(),
|
|
91
|
+
inputKeys: z2.array(z2.string()).optional(),
|
|
92
|
+
inputSizeBytes: z2.number().optional(),
|
|
93
|
+
inputSizeChars: z2.number().optional(),
|
|
94
|
+
inputType: z2.string().optional(),
|
|
95
|
+
name: z2.string().optional(),
|
|
96
|
+
output: z2.unknown().optional(),
|
|
97
|
+
outputKeys: z2.array(z2.string()).optional(),
|
|
98
|
+
outputSizeBytes: z2.number().optional(),
|
|
99
|
+
outputSizeChars: z2.number().optional(),
|
|
100
|
+
outputType: z2.string().optional(),
|
|
101
|
+
redacted: z2.boolean().optional(),
|
|
102
|
+
sourceType: z2.string().optional(),
|
|
103
|
+
text: z2.string().optional(),
|
|
104
|
+
type: transcriptPartTypeSchema
|
|
105
|
+
}).strict();
|
|
106
|
+
var transcriptRoleSchema = z2.enum([
|
|
107
|
+
"assistant",
|
|
108
|
+
"system",
|
|
109
|
+
"tool",
|
|
110
|
+
"toolResult",
|
|
111
|
+
"unknown",
|
|
112
|
+
"user"
|
|
113
|
+
]);
|
|
114
|
+
var transcriptMessageSchema = z2.object({
|
|
115
|
+
outcome: z2.enum(["error", "aborted"]).optional(),
|
|
116
|
+
parts: z2.array(transcriptPartSchema),
|
|
117
|
+
role: transcriptRoleSchema,
|
|
118
|
+
timestamp: z2.number().optional()
|
|
119
|
+
}).strict();
|
|
120
|
+
var conversationActivityStatusSchema = z2.enum([
|
|
121
|
+
"aborted",
|
|
122
|
+
"completed",
|
|
123
|
+
"error",
|
|
124
|
+
"running",
|
|
125
|
+
"success"
|
|
126
|
+
]);
|
|
127
|
+
var conversationSubagentActivityReportSchema = z2.object({
|
|
128
|
+
type: z2.literal("subagent"),
|
|
129
|
+
createdAt: z2.string(),
|
|
130
|
+
endedAt: z2.string().optional(),
|
|
131
|
+
id: z2.string(),
|
|
132
|
+
modelId: z2.string().optional(),
|
|
133
|
+
outcome: z2.enum(["success", "error", "aborted"]).optional(),
|
|
134
|
+
parentToolCallId: z2.string().optional(),
|
|
135
|
+
reasoningLevel: z2.string().optional(),
|
|
136
|
+
status: conversationActivityStatusSchema,
|
|
137
|
+
subagentKind: z2.string(),
|
|
138
|
+
transcriptAvailable: z2.boolean().optional()
|
|
139
|
+
}).strict();
|
|
140
|
+
var conversationToolActivityReportSchema = z2.object({
|
|
141
|
+
type: z2.literal("tool_execution"),
|
|
142
|
+
args: z2.unknown().optional(),
|
|
143
|
+
createdAt: z2.string(),
|
|
144
|
+
id: z2.string(),
|
|
145
|
+
inputKeys: z2.array(z2.string()).optional(),
|
|
146
|
+
inputSizeBytes: z2.number().optional(),
|
|
147
|
+
inputSizeChars: z2.number().optional(),
|
|
148
|
+
inputType: z2.string().optional(),
|
|
149
|
+
redacted: z2.boolean().optional(),
|
|
150
|
+
status: conversationActivityStatusSchema,
|
|
151
|
+
subagents: z2.array(conversationSubagentActivityReportSchema),
|
|
152
|
+
toolCallId: z2.string(),
|
|
153
|
+
toolName: z2.string()
|
|
154
|
+
}).strict();
|
|
155
|
+
var conversationActivityReportSchema = z2.discriminatedUnion("type", [
|
|
156
|
+
conversationToolActivityReportSchema,
|
|
157
|
+
conversationSubagentActivityReportSchema
|
|
158
|
+
]);
|
|
159
|
+
var conversationContextEventSchema = z2.discriminatedUnion("type", [
|
|
160
|
+
z2.object({
|
|
161
|
+
type: z2.literal("context_compacted"),
|
|
162
|
+
createdAt: z2.string(),
|
|
163
|
+
modelId: z2.string().optional(),
|
|
164
|
+
summary: z2.string().optional(),
|
|
165
|
+
transcriptIndex: z2.number().int().nonnegative()
|
|
166
|
+
}).strict(),
|
|
167
|
+
z2.object({
|
|
168
|
+
type: z2.literal("model_handoff"),
|
|
169
|
+
createdAt: z2.string(),
|
|
170
|
+
fromModelId: z2.string().optional(),
|
|
171
|
+
message: z2.string().optional(),
|
|
172
|
+
toModelId: z2.string(),
|
|
173
|
+
transcriptIndex: z2.number().int().nonnegative()
|
|
174
|
+
}).strict()
|
|
175
|
+
]);
|
|
176
|
+
var conversationDetailReportSchema = conversationSummaryReportSchema.extend({
|
|
177
|
+
activity: z2.array(conversationActivityReportSchema).optional(),
|
|
178
|
+
modelId: z2.string().optional(),
|
|
179
|
+
reasoningLevel: z2.string().optional(),
|
|
180
|
+
contextEvents: z2.array(conversationContextEventSchema).optional(),
|
|
181
|
+
transcriptAvailable: z2.boolean(),
|
|
182
|
+
transcriptMetadata: z2.array(transcriptMessageSchema).optional(),
|
|
183
|
+
transcriptMessageCount: z2.number().optional(),
|
|
184
|
+
transcriptRedacted: z2.boolean().optional(),
|
|
185
|
+
transcriptRedactionReason: z2.literal("non_public_conversation").optional(),
|
|
186
|
+
transcriptExpired: z2.boolean().optional(),
|
|
187
|
+
transcriptExpiredAt: z2.string().optional(),
|
|
188
|
+
transcript: z2.array(transcriptMessageSchema),
|
|
189
|
+
generatedAt: z2.string(),
|
|
190
|
+
sentryConversationUrl: z2.string().optional()
|
|
191
|
+
}).strict();
|
|
192
|
+
var conversationSubagentTranscriptReportSchema = z2.object({
|
|
193
|
+
type: z2.literal("subagent"),
|
|
194
|
+
createdAt: z2.string(),
|
|
195
|
+
endedAt: z2.string().optional(),
|
|
196
|
+
id: z2.string(),
|
|
197
|
+
modelId: z2.string().optional(),
|
|
198
|
+
outcome: z2.enum(["success", "error", "aborted"]).optional(),
|
|
199
|
+
parentToolCallId: z2.string().optional(),
|
|
200
|
+
reasoningLevel: z2.string().optional(),
|
|
201
|
+
status: conversationActivityStatusSchema,
|
|
202
|
+
subagentConversationId: z2.string().optional(),
|
|
203
|
+
subagentKind: z2.string(),
|
|
204
|
+
subagentSentryConversationUrl: z2.string().optional(),
|
|
205
|
+
transcript: z2.array(transcriptMessageSchema),
|
|
206
|
+
transcriptAvailable: z2.boolean(),
|
|
207
|
+
transcriptMessageCount: z2.number().optional(),
|
|
208
|
+
transcriptRedacted: z2.boolean().optional(),
|
|
209
|
+
transcriptRedactionReason: z2.literal("non_public_conversation").optional(),
|
|
210
|
+
transcriptExpired: z2.boolean().optional(),
|
|
211
|
+
transcriptExpiredAt: z2.string().optional(),
|
|
212
|
+
unavailableReason: z2.enum(["missing_transcript_range", "missing_transcript_ref", "not_found"]).optional()
|
|
213
|
+
}).strict();
|
|
214
|
+
var conversationFeedSchema = z2.object({
|
|
215
|
+
conversations: z2.array(conversationSummaryReportSchema),
|
|
216
|
+
source: z2.literal("conversation_index"),
|
|
217
|
+
generatedAt: z2.string()
|
|
218
|
+
}).strict();
|
|
219
|
+
var conversationStatsItemSchema = z2.object({
|
|
220
|
+
active: z2.number(),
|
|
221
|
+
conversations: z2.number(),
|
|
222
|
+
durationMs: z2.number(),
|
|
223
|
+
failed: z2.number(),
|
|
224
|
+
label: z2.string(),
|
|
225
|
+
costUsd: z2.number().optional(),
|
|
226
|
+
tokens: z2.number().optional()
|
|
227
|
+
}).strict();
|
|
228
|
+
var conversationStatsReportSchema = z2.object({
|
|
229
|
+
active: z2.number(),
|
|
230
|
+
conversations: z2.number(),
|
|
231
|
+
durationMs: z2.number(),
|
|
232
|
+
failed: z2.number(),
|
|
233
|
+
generatedAt: z2.string(),
|
|
234
|
+
locations: z2.array(conversationStatsItemSchema),
|
|
235
|
+
actors: z2.array(conversationStatsItemSchema),
|
|
236
|
+
source: z2.literal("conversation_index"),
|
|
237
|
+
costUsd: z2.number().optional(),
|
|
238
|
+
tokens: z2.number().optional(),
|
|
239
|
+
windowEnd: z2.string(),
|
|
240
|
+
windowStart: z2.string()
|
|
241
|
+
}).strict();
|
|
242
|
+
|
|
243
|
+
// src/api/people/schema.ts
|
|
244
|
+
import { z as z3 } from "zod";
|
|
245
|
+
var peopleConversationSummaryReportSchema = conversationSummaryReportSchema.omit({
|
|
246
|
+
cumulativeUsage: true,
|
|
247
|
+
sentryTraceUrl: true,
|
|
248
|
+
traceId: true
|
|
249
|
+
});
|
|
250
|
+
var peopleConversationStatsItemSchema = conversationStatsItemSchema.omit({ costUsd: true });
|
|
251
|
+
var actorActivityDayReportSchema = z3.object({
|
|
252
|
+
active: z3.number(),
|
|
253
|
+
conversations: z3.number(),
|
|
254
|
+
date: z3.string(),
|
|
255
|
+
durationMs: z3.number(),
|
|
256
|
+
failed: z3.number(),
|
|
257
|
+
tokens: z3.number().optional()
|
|
258
|
+
}).strict();
|
|
259
|
+
var peopleActivityDayReportSchema = z3.object({
|
|
260
|
+
activePeople: z3.number(),
|
|
261
|
+
conversations: z3.number(),
|
|
262
|
+
date: z3.string()
|
|
263
|
+
}).strict();
|
|
264
|
+
var actorTotalsReportSchema = z3.object({
|
|
265
|
+
active: z3.number(),
|
|
266
|
+
activeDays: z3.number(),
|
|
267
|
+
conversations: z3.number(),
|
|
268
|
+
durationMs: z3.number(),
|
|
269
|
+
failed: z3.number(),
|
|
270
|
+
tokens: z3.number().optional()
|
|
271
|
+
}).strict();
|
|
272
|
+
var identifiedActorSchema = actorIdentitySchema.extend({ email: z3.string().min(1) }).strict();
|
|
273
|
+
var actorSummaryReportSchema = actorTotalsReportSchema.extend({
|
|
274
|
+
firstSeenAt: z3.string(),
|
|
275
|
+
lastSeenAt: z3.string(),
|
|
276
|
+
actor: identifiedActorSchema
|
|
277
|
+
}).strict();
|
|
278
|
+
var actorDirectoryReportSchema = z3.object({
|
|
279
|
+
activityDays: z3.array(peopleActivityDayReportSchema),
|
|
280
|
+
generatedAt: z3.string(),
|
|
281
|
+
people: z3.array(actorSummaryReportSchema),
|
|
282
|
+
source: z3.literal("conversation_index"),
|
|
283
|
+
windowEnd: z3.string(),
|
|
284
|
+
windowStart: z3.string()
|
|
285
|
+
}).strict();
|
|
286
|
+
var actorProfileReportSchema = z3.object({
|
|
287
|
+
activityDays: z3.array(actorActivityDayReportSchema),
|
|
288
|
+
generatedAt: z3.string(),
|
|
289
|
+
locations: z3.array(peopleConversationStatsItemSchema),
|
|
290
|
+
recentConversations: z3.array(peopleConversationSummaryReportSchema),
|
|
291
|
+
actor: identifiedActorSchema,
|
|
292
|
+
source: z3.literal("conversation_index"),
|
|
293
|
+
surfaces: z3.array(peopleConversationStatsItemSchema),
|
|
294
|
+
totals: actorTotalsReportSchema,
|
|
295
|
+
windowEnd: z3.string(),
|
|
296
|
+
windowStart: z3.string()
|
|
297
|
+
}).strict();
|
|
298
|
+
|
|
299
|
+
// src/api/locations/schema.ts
|
|
300
|
+
import { z as z4 } from "zod";
|
|
301
|
+
var locationSummaryReportSchema = conversationStatsItemSchema.extend({
|
|
302
|
+
id: z4.string(),
|
|
303
|
+
firstSeenAt: z4.string(),
|
|
304
|
+
kind: juniorDestinationKindSchema,
|
|
305
|
+
lastSeenAt: z4.string(),
|
|
306
|
+
provider: z4.string(),
|
|
307
|
+
providerDestinationId: z4.string(),
|
|
308
|
+
visibility: z4.literal("public")
|
|
309
|
+
}).strict();
|
|
310
|
+
var locationActorSummaryReportSchema = conversationStatsItemSchema.extend({ actor: actorIdentitySchema }).strict();
|
|
311
|
+
var locationActivityDayReportSchema = z4.object({
|
|
312
|
+
date: z4.string(),
|
|
313
|
+
privateConversations: z4.number(),
|
|
314
|
+
publicConversations: z4.number()
|
|
315
|
+
}).strict();
|
|
316
|
+
var locationDirectoryReportSchema = z4.object({
|
|
317
|
+
activityDays: z4.array(locationActivityDayReportSchema),
|
|
318
|
+
generatedAt: z4.string(),
|
|
319
|
+
locations: z4.array(locationSummaryReportSchema),
|
|
320
|
+
privateActivity: conversationStatsItemSchema,
|
|
321
|
+
source: z4.literal("conversation_index"),
|
|
322
|
+
windowEnd: z4.string(),
|
|
323
|
+
windowStart: z4.string()
|
|
324
|
+
}).strict();
|
|
325
|
+
var locationDetailReportSchema = locationSummaryReportSchema.extend({
|
|
326
|
+
activityDays: z4.array(dailyConversationActivitySchema),
|
|
327
|
+
actors: z4.array(locationActorSummaryReportSchema),
|
|
328
|
+
generatedAt: z4.string(),
|
|
329
|
+
recentConversations: z4.array(conversationSummaryReportSchema),
|
|
330
|
+
source: z4.literal("conversation_index"),
|
|
331
|
+
windowEnd: z4.string(),
|
|
332
|
+
windowStart: z4.string()
|
|
333
|
+
}).strict();
|
|
334
|
+
|
|
335
|
+
// src/api/schema.ts
|
|
336
|
+
import { z as z5 } from "zod";
|
|
337
|
+
var conversationParamsSchema = z5.object({ conversationId: z5.string().min(1) }).strict();
|
|
338
|
+
var conversationFeedQuerySchema = z5.object({
|
|
339
|
+
actorEmail: z5.string().trim().email().transform((value) => value.toLowerCase()).optional()
|
|
340
|
+
}).strict();
|
|
341
|
+
var subagentParamsSchema = conversationParamsSchema.extend({ subagentId: z5.string().min(1) }).strict();
|
|
342
|
+
var personParamsSchema = z5.object({ email: z5.string().trim().min(1) }).strict();
|
|
343
|
+
var locationParamsSchema = z5.object({ locationId: z5.string().min(1) }).strict();
|
|
344
|
+
|
|
345
|
+
export {
|
|
346
|
+
dailyConversationActivitySchema,
|
|
347
|
+
activityDays,
|
|
348
|
+
conversationDetailReportSchema,
|
|
349
|
+
conversationSubagentTranscriptReportSchema,
|
|
350
|
+
conversationFeedSchema,
|
|
351
|
+
conversationStatsReportSchema,
|
|
352
|
+
actorDirectoryReportSchema,
|
|
353
|
+
actorProfileReportSchema,
|
|
354
|
+
locationActivityDayReportSchema,
|
|
355
|
+
locationDirectoryReportSchema,
|
|
356
|
+
locationDetailReportSchema,
|
|
357
|
+
conversationParamsSchema,
|
|
358
|
+
conversationFeedQuerySchema,
|
|
359
|
+
subagentParamsSchema,
|
|
360
|
+
personParamsSchema,
|
|
361
|
+
locationParamsSchema
|
|
362
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getConnectedStateContext,
|
|
4
4
|
getStateAdapter,
|
|
5
5
|
modelProfileSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M3UAVLEN.js";
|
|
7
7
|
import {
|
|
8
8
|
juniorDestinations,
|
|
9
9
|
timestamptz
|
|
@@ -153,7 +153,8 @@ var juniorConversations = pgTable3(
|
|
|
153
153
|
usage: jsonb2("usage_json").$type(),
|
|
154
154
|
executionDurationMs: integer("execution_duration_ms").notNull().default(0),
|
|
155
155
|
executionUsage: jsonb2("execution_usage_json").$type(),
|
|
156
|
-
metricRunId: text3("metric_run_id")
|
|
156
|
+
metricRunId: text3("metric_run_id"),
|
|
157
|
+
archivedAt: timestamptz("archived_at")
|
|
157
158
|
},
|
|
158
159
|
(table) => [
|
|
159
160
|
index2("junior_conversations_last_activity_idx").on(
|
|
@@ -537,6 +538,7 @@ function conversationFromRow(readRow) {
|
|
|
537
538
|
execution,
|
|
538
539
|
...destination ? { destination } : {},
|
|
539
540
|
...actor ? { actor } : {},
|
|
541
|
+
...msFromDate(row.archivedAt) !== void 0 ? { archivedAtMs: msFromDate(row.archivedAt) } : {},
|
|
540
542
|
...row.channelName ? { channelName: row.channelName } : {},
|
|
541
543
|
...source ? { source } : {},
|
|
542
544
|
...row.title ? { title: row.title } : {},
|
|
@@ -969,7 +971,7 @@ function createSqlStore(executor) {
|
|
|
969
971
|
}
|
|
970
972
|
|
|
971
973
|
// src/chat/conversations/sql/history.ts
|
|
972
|
-
import { and as and3, asc as asc2, eq as eq3, sql as sql7 } from "drizzle-orm";
|
|
974
|
+
import { and as and3, asc as asc2, eq as eq3, isNotNull, sql as sql7 } from "drizzle-orm";
|
|
973
975
|
|
|
974
976
|
// src/chat/conversations/history.ts
|
|
975
977
|
import { z as z3 } from "zod";
|
|
@@ -1533,6 +1535,12 @@ var SqlAgentStepStore = class {
|
|
|
1533
1535
|
conversationId,
|
|
1534
1536
|
newestCreatedAtMs
|
|
1535
1537
|
);
|
|
1538
|
+
await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
|
|
1539
|
+
and3(
|
|
1540
|
+
eq3(juniorConversations.conversationId, conversationId),
|
|
1541
|
+
isNotNull(juniorConversations.archivedAt)
|
|
1542
|
+
)
|
|
1543
|
+
);
|
|
1536
1544
|
const cursor = await this.readCursor(conversationId);
|
|
1537
1545
|
const contextEpoch = cursor.maxEpoch ?? 0;
|
|
1538
1546
|
let seq = cursor.nextSeq;
|
|
@@ -1546,6 +1554,12 @@ var SqlAgentStepStore = class {
|
|
|
1546
1554
|
const parsed = contextEpochStartSchema.parse(opts);
|
|
1547
1555
|
await this.executor.transaction(async () => {
|
|
1548
1556
|
await ensureConversationRow(this.executor, conversationId, Date.now());
|
|
1557
|
+
await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
|
|
1558
|
+
and3(
|
|
1559
|
+
eq3(juniorConversations.conversationId, conversationId),
|
|
1560
|
+
isNotNull(juniorConversations.archivedAt)
|
|
1561
|
+
)
|
|
1562
|
+
);
|
|
1549
1563
|
const cursor = await this.readCursor(conversationId);
|
|
1550
1564
|
const contextEpoch = parsed.reason === "initial" ? cursor.maxEpoch ?? 0 : (cursor.maxEpoch ?? -1) + 1;
|
|
1551
1565
|
let seq = cursor.nextSeq;
|
|
@@ -1596,7 +1610,7 @@ function createSqlAgentStepStore(executor) {
|
|
|
1596
1610
|
}
|
|
1597
1611
|
|
|
1598
1612
|
// src/chat/conversations/sql/messages.ts
|
|
1599
|
-
import { and as and4, asc as asc3, eq as eq4, isNull as isNull2, sql as sql8 } from "drizzle-orm";
|
|
1613
|
+
import { and as and4, asc as asc3, eq as eq4, isNotNull as isNotNull2, isNull as isNull2, sql as sql8 } from "drizzle-orm";
|
|
1600
1614
|
function messageFromRow(row) {
|
|
1601
1615
|
return {
|
|
1602
1616
|
conversationId: row.conversationId,
|
|
@@ -1627,6 +1641,12 @@ var SqlConversationMessageStore = class {
|
|
|
1627
1641
|
conversationId,
|
|
1628
1642
|
newestCreatedAtMs
|
|
1629
1643
|
);
|
|
1644
|
+
await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
|
|
1645
|
+
and4(
|
|
1646
|
+
eq4(juniorConversations.conversationId, conversationId),
|
|
1647
|
+
isNotNull2(juniorConversations.archivedAt)
|
|
1648
|
+
)
|
|
1649
|
+
);
|
|
1630
1650
|
await this.executor.db().insert(juniorConversationMessages).values(
|
|
1631
1651
|
messages.map((message) => ({
|
|
1632
1652
|
conversationId,
|
|
@@ -216,7 +216,7 @@ var PROVIDER_RETRY_DELAYS_MS = [2e3, 4e3, 8e3];
|
|
|
216
216
|
var PROVIDER_ERROR_PREFIX = "AI provider error:";
|
|
217
217
|
var PROVIDER_RETRY_ERROR_NAME = "ProviderRetryError";
|
|
218
218
|
var NON_RETRYABLE_PROVIDER_ERROR_PATTERNS = [
|
|
219
|
-
/invalid.?api.?key|no api key|authentication|authorization|permission|forbidden|
|
|
219
|
+
/invalid.?api.?key|no api key|authentication|authorization|permission|forbidden|(?:invalid|missing|expired|revoked).{0,24}\bcredentials?\b|\bcredentials?\b.{0,24}(?:invalid|missing|expired|revoked)|\bno\b.{0,16}\bcredentials?\b/i,
|
|
220
220
|
/context.?length|context.?window/i,
|
|
221
221
|
/content.?policy|validation|bad request|\b(?:400|401|403)\b/i,
|
|
222
222
|
/unsupported model|invalid model|unknown ai gateway model|unknown model|mismatched api/i,
|
|
@@ -244,8 +244,7 @@ function isRetryableProviderFailure(errorMessage) {
|
|
|
244
244
|
}
|
|
245
245
|
function nextProviderRetry(args) {
|
|
246
246
|
const delayMs = PROVIDER_RETRY_DELAYS_MS[args.attempt];
|
|
247
|
-
|
|
248
|
-
if (delayMs === void 0 || args.lastAssistant?.stopReason !== "error" || !errorMessage || !isRetryableProviderFailure(errorMessage)) {
|
|
247
|
+
if (delayMs === void 0 || !args.retryableFailure) {
|
|
249
248
|
return void 0;
|
|
250
249
|
}
|
|
251
250
|
const messages = trimTrailingAssistantMessages(args.messages);
|
|
@@ -1,9 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
healthReportSchema
|
|
3
|
+
} from "./chunk-CEA3A3UA.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeSlackConversationId
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CCTCIISK.js";
|
|
4
7
|
import {
|
|
5
8
|
parseSlackThreadId
|
|
6
9
|
} from "./chunk-RT5BUHR5.js";
|
|
10
|
+
import {
|
|
11
|
+
getClient
|
|
12
|
+
} from "./chunk-6GWA276C.js";
|
|
13
|
+
|
|
14
|
+
// src/handlers/health.ts
|
|
15
|
+
function readHealthReport() {
|
|
16
|
+
return healthReportSchema.parse({
|
|
17
|
+
status: "ok",
|
|
18
|
+
service: "junior",
|
|
19
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function GET() {
|
|
23
|
+
return Response.json(readHealthReport());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/chat/sentry-links.ts
|
|
27
|
+
function getSentryOrgSlug() {
|
|
28
|
+
const slug = process.env.SENTRY_ORG_SLUG?.trim();
|
|
29
|
+
return slug || void 0;
|
|
30
|
+
}
|
|
31
|
+
function isSentrySaasDsnHost(host) {
|
|
32
|
+
return host === "sentry.io" || host.endsWith(".sentry.io");
|
|
33
|
+
}
|
|
34
|
+
function buildSentryWebBaseUrl(dsn) {
|
|
35
|
+
if (isSentrySaasDsnHost(dsn.host)) {
|
|
36
|
+
return "https://sentry.io";
|
|
37
|
+
}
|
|
38
|
+
const port = dsn.port ? `:${dsn.port}` : "";
|
|
39
|
+
const path = dsn.path ? `/${dsn.path}` : "";
|
|
40
|
+
return `${dsn.protocol}://${dsn.host}${port}${path}`;
|
|
41
|
+
}
|
|
42
|
+
function buildSentryConversationUrl(conversationId) {
|
|
43
|
+
const client = getClient();
|
|
44
|
+
const dsn = client?.getDsn();
|
|
45
|
+
if (!dsn?.host || !dsn.projectId) {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
const orgSlug = getSentryOrgSlug();
|
|
49
|
+
if (!orgSlug) {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
const encodedId = encodeURIComponent(conversationId);
|
|
53
|
+
const params = new URLSearchParams();
|
|
54
|
+
params.set("project", dsn.projectId);
|
|
55
|
+
const path = `explore/conversations/${encodedId}/?${params.toString()}`;
|
|
56
|
+
if (isSentrySaasDsnHost(dsn.host)) {
|
|
57
|
+
return `https://${orgSlug}.sentry.io/${path}`;
|
|
58
|
+
}
|
|
59
|
+
return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
|
|
60
|
+
}
|
|
61
|
+
function buildSentryTraceUrl(traceId) {
|
|
62
|
+
const client = getClient();
|
|
63
|
+
const dsn = client?.getDsn();
|
|
64
|
+
if (!dsn?.host || !dsn.projectId) {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
const orgSlug = getSentryOrgSlug();
|
|
68
|
+
if (!orgSlug) {
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
const encodedTraceId = encodeURIComponent(traceId);
|
|
72
|
+
const params = new URLSearchParams();
|
|
73
|
+
params.set("project", dsn.projectId);
|
|
74
|
+
const path = `performance/trace/${encodedTraceId}/?${params.toString()}`;
|
|
75
|
+
if (isSentrySaasDsnHost(dsn.host)) {
|
|
76
|
+
return `https://${orgSlug}.sentry.io/${path}`;
|
|
77
|
+
}
|
|
78
|
+
return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
|
|
79
|
+
}
|
|
7
80
|
|
|
8
81
|
// src/chat/slack/conversation-context.ts
|
|
9
82
|
function normalizeConversationName(type, channelName) {
|
|
@@ -88,6 +161,10 @@ function formatSlackConversationRedactedLabel(context) {
|
|
|
88
161
|
}
|
|
89
162
|
|
|
90
163
|
export {
|
|
164
|
+
readHealthReport,
|
|
165
|
+
GET,
|
|
166
|
+
buildSentryConversationUrl,
|
|
167
|
+
buildSentryTraceUrl,
|
|
91
168
|
conversationVisibilityFromSlackChannelType,
|
|
92
169
|
resolveSlackChannelTypeFromMessage,
|
|
93
170
|
resolveSlackConversationContext,
|