@sentry/junior 0.108.0 → 0.110.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-NU5HK3PS.js → agent-hooks-ELT4ODFF.js} +12 -13
- package/dist/api/conversations/access.d.ts +9 -0
- package/dist/api/conversations/aggregate.d.ts +12 -1
- package/dist/api/conversations/archive.d.ts +3 -5
- package/dist/api/conversations/detail.d.ts +156 -7
- package/dist/api/conversations/events.d.ts +2 -2
- package/dist/api/conversations/list.d.ts +57 -6
- package/dist/api/conversations/projection.d.ts +6 -7
- package/dist/api/conversations/reporting.d.ts +10 -4
- package/dist/api/conversations/routes.d.ts +2 -1
- package/dist/api/conversations/shared.d.ts +1 -1
- package/dist/api/conversations/stats.d.ts +37 -6
- package/dist/api/conversations/stats.query.d.ts +1 -1
- package/dist/api/conversations/usage.d.ts +9 -0
- package/dist/api/http.d.ts +7 -0
- package/dist/api/locations/detail.d.ts +102 -6
- package/dist/api/locations/list.d.ts +43 -5
- package/dist/api/locations/query.d.ts +4 -2
- package/dist/api/locations/routes.d.ts +2 -1
- package/dist/api/people/list.d.ts +28 -6
- package/dist/api/people/list.query.d.ts +1 -1
- package/dist/api/people/profile.d.ts +96 -7
- package/dist/api/people/profile.query.d.ts +4 -2
- package/dist/api/people/routes.d.ts +2 -1
- package/dist/api/people/shared.d.ts +1219 -2
- package/dist/api/route.d.ts +18 -4
- package/dist/api/schema/common.d.ts +6 -0
- package/dist/api/{conversations/schema.d.ts → schema/conversation.d.ts} +88 -9
- package/dist/api/{locations/schema.d.ts → schema/location.d.ts} +5 -0
- package/dist/api/{people/schema.d.ts → schema/person.d.ts} +37 -45
- package/dist/api/schema.d.ts +8 -22
- package/dist/api/schema.js +10 -2
- package/dist/api.d.ts +5 -1
- package/dist/api.js +838 -369
- package/dist/app.d.ts +1 -0
- package/dist/app.js +1564 -486
- package/dist/catalog-runtime-4GI22PXK.js +16 -0
- package/dist/chat/agent/resume.d.ts +11 -12
- package/dist/chat/conversations/history.d.ts +3 -0
- package/dist/chat/conversations/sql/privacy.d.ts +3 -15
- package/dist/chat/conversations/sql/store.d.ts +0 -7
- package/dist/chat/log-context.d.ts +40 -0
- package/dist/chat/logging.d.ts +3 -26
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/pi/sql-model-usage.d.ts +4 -1
- package/dist/chat/runtime/slack-resume.d.ts +2 -2
- package/dist/chat/services/auth-pause.d.ts +4 -0
- package/dist/chat/services/context-compaction.d.ts +1 -0
- package/dist/chat/services/turn-session-record.d.ts +0 -2
- package/dist/chat/slack/reply.d.ts +7 -19
- package/dist/chat/state/conversation.d.ts +1 -0
- package/dist/chat/task-execution/queue-signing.d.ts +10 -8
- package/dist/chat/task-execution/queue.d.ts +9 -7
- package/dist/chat/task-execution/slack-work.d.ts +6 -6
- package/dist/{chunk-UD6THJ2I.js → chunk-2T7TIEXI.js} +197 -12
- package/dist/{chunk-CEA3A3UA.js → chunk-2ZTTXTSZ.js} +24 -1
- package/dist/{chunk-XKB7LGIW.js → chunk-3S7YYHBI.js} +3 -139
- package/dist/chunk-3TV7OEHL.js +10 -0
- package/dist/{chunk-A5CO2EHL.js → chunk-3UBQI73J.js} +11 -15
- package/dist/{chunk-7FBGKXPE.js → chunk-42WRQLJ6.js} +10 -33
- package/dist/{chunk-TE4QHJH4.js → chunk-4QU44P7Q.js} +135 -595
- package/dist/{chunk-RT5BUHR5.js → chunk-6Y5L4BOM.js} +3 -5
- package/dist/{chunk-VIXFG2VC.js → chunk-C4MZ3GP5.js} +1 -2
- package/dist/{chunk-3RGQLX2F.js → chunk-C5XAFTHY.js} +1011 -29
- package/dist/{chunk-PUAMO4PI.js → chunk-FPK7XY3F.js} +139 -99
- package/dist/{chunk-H3QYZL7K.js → chunk-GK47NBDE.js} +28 -3
- package/dist/{chunk-O24R4DCK.js → chunk-IYKPU7H6.js} +94 -56
- package/dist/chunk-JQFJO5WH.js +477 -0
- package/dist/{chunk-VH6KWKG2.js → chunk-L5XQPJ7T.js} +3 -3
- package/dist/{chunk-2XXEKR44.js → chunk-MIAKQNYX.js} +43 -31
- package/dist/{chunk-KPMPQ6AA.js → chunk-RHHRKSPI.js} +249 -223
- package/dist/{chunk-YT72TOEK.js → chunk-SBOBTS27.js} +2 -2
- package/dist/{chunk-B5I5LMSP.js → chunk-W6RJZG7F.js} +5 -7
- package/dist/chunk-W75ZPAGG.js +44 -0
- package/dist/{chunk-SS67LUOK.js → chunk-WNOVRQ67.js} +6 -7
- package/dist/{chunk-YIPD3L6L.js → chunk-Y3H2DN6F.js} +8 -10
- package/dist/{chunk-DY7TRYB5.js → chunk-Y5FK3CNG.js} +1 -1
- package/dist/chunk-ZKIOWEFL.js +125 -0
- package/dist/cli/chat.js +23 -24
- package/dist/cli/check.js +9 -7
- package/dist/cli/plugins.js +16 -17
- package/dist/cli/snapshot-warmup.js +11 -10
- package/dist/cli/upgrade.js +314 -3505
- package/dist/db/db.d.ts +1 -1
- package/dist/db/schema/conversations.d.ts +17 -0
- package/dist/db/schema.d.ts +17 -0
- package/dist/{db-AMRBAT5D.js → db-Y6W6CWWW.js} +8 -7
- package/dist/instrumentation.js +4 -3
- package/dist/nitro.js +4 -4
- package/dist/reporting-schema.d.ts +46 -0
- package/dist/{runner-TQH5GAJ4.js → runner-BBFV5GLR.js} +17 -21
- package/dist/{skills-ITNHBARB.js → skills-AR4AF32L.js} +8 -6
- package/dist/{validation-AGQ46ZGV.js → validation-FBIEPTC2.js} +8 -6
- package/dist/version.d.ts +2 -0
- package/dist/version.js +7 -0
- package/migrations/0006_drop_legacy_conversation_messages.sql +1 -0
- package/migrations/0007_thick_sugar_man.sql +23 -0
- package/migrations/README.md +12 -9
- package/migrations/meta/0006_snapshot.json +948 -0
- package/migrations/meta/0007_snapshot.json +1013 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +9 -5
- package/dist/catalog-runtime-FOFNPR3P.js +0 -14
- package/dist/chunk-AHJR2IFF.js +0 -115
- package/dist/chunk-B7PUBQQM.js +0 -53
- package/dist/chunk-G3E7SCME.js +0 -28
- package/dist/chunk-J3B3FPP2.js +0 -1061
- package/dist/chunk-OB42YVAE.js +0 -16
- package/dist/chunk-TWINAEZQ.js +0 -1283
|
@@ -1,38 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
SANDBOX_WORKSPACE_ROOT
|
|
7
|
-
} from "./chunk-G3E7SCME.js";
|
|
2
|
+
SANDBOX_WORKSPACE_ROOT,
|
|
3
|
+
getStateAdapter
|
|
4
|
+
} from "./chunk-GK47NBDE.js";
|
|
8
5
|
import {
|
|
9
6
|
isConversationChannel,
|
|
10
7
|
isConversationScopedChannel,
|
|
11
8
|
isDmChannel,
|
|
12
9
|
normalizeSlackConversationId
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-L5XQPJ7T.js";
|
|
14
11
|
import {
|
|
15
12
|
getDb
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4QU44P7Q.js";
|
|
17
14
|
import {
|
|
18
15
|
botConfig,
|
|
19
16
|
completeObject,
|
|
20
17
|
embedTexts,
|
|
21
18
|
standardModelId
|
|
22
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WNOVRQ67.js";
|
|
23
20
|
import {
|
|
24
21
|
isActorUserId,
|
|
25
22
|
parseActorUserId
|
|
26
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-C4MZ3GP5.js";
|
|
27
24
|
import {
|
|
25
|
+
logException,
|
|
28
26
|
logInfo,
|
|
29
27
|
logWarn
|
|
30
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-IYKPU7H6.js";
|
|
31
29
|
import {
|
|
32
30
|
parseSlackChannelReferenceId,
|
|
33
31
|
parseSlackMessageTs,
|
|
34
32
|
parseSlackTeamId
|
|
35
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-42WRQLJ6.js";
|
|
36
34
|
|
|
37
35
|
// src/chat/plugins/agent-hooks.ts
|
|
38
36
|
import {
|
|
@@ -40,6 +38,37 @@ import {
|
|
|
40
38
|
resourceEventSchema
|
|
41
39
|
} from "@sentry/junior-plugin-api";
|
|
42
40
|
|
|
41
|
+
// src/chat/plugins/logging.ts
|
|
42
|
+
function createPluginLogger(plugin) {
|
|
43
|
+
return {
|
|
44
|
+
info(message, metadata) {
|
|
45
|
+
logInfo(
|
|
46
|
+
"agent_plugin_log_info",
|
|
47
|
+
{},
|
|
48
|
+
{ "app.plugin.name": plugin, ...metadata },
|
|
49
|
+
message
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
warn(message, metadata) {
|
|
53
|
+
logWarn(
|
|
54
|
+
"agent_plugin_log_warn",
|
|
55
|
+
{},
|
|
56
|
+
{ "app.plugin.name": plugin, ...metadata },
|
|
57
|
+
message
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
error(message, metadata) {
|
|
61
|
+
logException(
|
|
62
|
+
new Error(message),
|
|
63
|
+
"agent_plugin_log_error",
|
|
64
|
+
{},
|
|
65
|
+
{ "app.plugin.name": plugin, ...metadata },
|
|
66
|
+
message
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
43
72
|
// src/chat/plugins/model.ts
|
|
44
73
|
function createPluginModel(pluginName, options = {}, runtime = {}) {
|
|
45
74
|
return {
|
|
@@ -77,6 +106,77 @@ function createPluginEmbedder(pluginName, runtime = {}) {
|
|
|
77
106
|
};
|
|
78
107
|
}
|
|
79
108
|
|
|
109
|
+
// src/chat/plugins/state.ts
|
|
110
|
+
import { createHash } from "crypto";
|
|
111
|
+
var MAX_PLUGIN_STATE_KEY_LENGTH = 512;
|
|
112
|
+
function hashKeyPart(value) {
|
|
113
|
+
return createHash("sha256").update(value).digest("hex").slice(0, 32);
|
|
114
|
+
}
|
|
115
|
+
function pluginStateKey(plugin, key) {
|
|
116
|
+
const pluginPrefix = `junior:${plugin}`;
|
|
117
|
+
if (key === pluginPrefix || key.startsWith(`${pluginPrefix}:`)) {
|
|
118
|
+
return key;
|
|
119
|
+
}
|
|
120
|
+
return `junior:plugin_state:${hashKeyPart(plugin)}:${hashKeyPart(key)}`;
|
|
121
|
+
}
|
|
122
|
+
function validatePluginStateKey(key) {
|
|
123
|
+
if (!key.trim()) {
|
|
124
|
+
throw new Error("Plugin state key is required");
|
|
125
|
+
}
|
|
126
|
+
if (key.length > MAX_PLUGIN_STATE_KEY_LENGTH) {
|
|
127
|
+
throw new Error("Plugin state key exceeds the maximum length");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function createPluginState(plugin, adapter) {
|
|
131
|
+
const getAdapter = () => adapter ?? getStateAdapter();
|
|
132
|
+
return {
|
|
133
|
+
async delete(key) {
|
|
134
|
+
validatePluginStateKey(key);
|
|
135
|
+
const state = getAdapter();
|
|
136
|
+
await state.connect();
|
|
137
|
+
await state.delete(pluginStateKey(plugin, key));
|
|
138
|
+
},
|
|
139
|
+
async get(key) {
|
|
140
|
+
validatePluginStateKey(key);
|
|
141
|
+
const state = getAdapter();
|
|
142
|
+
await state.connect();
|
|
143
|
+
const value = await state.get(pluginStateKey(plugin, key));
|
|
144
|
+
return value ?? void 0;
|
|
145
|
+
},
|
|
146
|
+
async set(key, value, ttlMs) {
|
|
147
|
+
validatePluginStateKey(key);
|
|
148
|
+
const state = getAdapter();
|
|
149
|
+
await state.connect();
|
|
150
|
+
await state.set(pluginStateKey(plugin, key), value, ttlMs);
|
|
151
|
+
},
|
|
152
|
+
async setIfNotExists(key, value, ttlMs) {
|
|
153
|
+
validatePluginStateKey(key);
|
|
154
|
+
const state = getAdapter();
|
|
155
|
+
await state.connect();
|
|
156
|
+
return await state.setIfNotExists(
|
|
157
|
+
pluginStateKey(plugin, key),
|
|
158
|
+
value,
|
|
159
|
+
ttlMs
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
async withLock(key, ttlMs, callback) {
|
|
163
|
+
validatePluginStateKey(key);
|
|
164
|
+
const state = getAdapter();
|
|
165
|
+
await state.connect();
|
|
166
|
+
const lockKey = pluginStateKey(plugin, key);
|
|
167
|
+
const lock = await state.acquireLock(lockKey, ttlMs);
|
|
168
|
+
if (!lock) {
|
|
169
|
+
throw new Error(`Could not acquire plugin state lock for ${key}`);
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return await callback();
|
|
173
|
+
} finally {
|
|
174
|
+
await state.releaseLock(lock);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
80
180
|
// src/chat/slack/dashboard-link.ts
|
|
81
181
|
var dashboardConversationLinkOptions;
|
|
82
182
|
function withHttps(host) {
|
|
@@ -306,6 +406,9 @@ var registeredPlugins = [];
|
|
|
306
406
|
var PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
307
407
|
var PLUGIN_TOOL_NAME_RE = /^[a-z][A-Za-z0-9]*$/;
|
|
308
408
|
var OPERATIONAL_REPORT_MAX_METRICS = 8;
|
|
409
|
+
var OPERATIONAL_REPORT_MAX_WIDGETS = 12;
|
|
410
|
+
var OPERATIONAL_REPORT_MAX_CHART_SERIES = 8;
|
|
411
|
+
var OPERATIONAL_REPORT_MAX_CHART_CATEGORIES = 100;
|
|
309
412
|
var OPERATIONAL_REPORT_MAX_RECORD_SETS = 8;
|
|
310
413
|
var OPERATIONAL_REPORT_MAX_FIELDS = 8;
|
|
311
414
|
var OPERATIONAL_REPORT_MAX_RECORDS = 25;
|
|
@@ -904,6 +1007,83 @@ function sanitizeOperationalReport(args) {
|
|
|
904
1007
|
}).filter(
|
|
905
1008
|
(recordSet) => Boolean(recordSet)
|
|
906
1009
|
);
|
|
1010
|
+
const widgets = args.report.widgets?.slice(0, OPERATIONAL_REPORT_MAX_WIDGETS).map((widget, widgetIndex) => {
|
|
1011
|
+
const id = operationalReportText(widget.id, OPERATIONAL_REPORT_MAX_LABEL_LENGTH) ?? String(widgetIndex);
|
|
1012
|
+
const title2 = operationalReportText(
|
|
1013
|
+
widget.title,
|
|
1014
|
+
OPERATIONAL_REPORT_MAX_LABEL_LENGTH
|
|
1015
|
+
);
|
|
1016
|
+
if (!title2) {
|
|
1017
|
+
return void 0;
|
|
1018
|
+
}
|
|
1019
|
+
const seriesEntries = widget.series.slice(0, OPERATIONAL_REPORT_MAX_CHART_SERIES).map((item) => {
|
|
1020
|
+
const key = operationalReportText(
|
|
1021
|
+
item.key,
|
|
1022
|
+
OPERATIONAL_REPORT_MAX_LABEL_LENGTH
|
|
1023
|
+
);
|
|
1024
|
+
const label = operationalReportText(
|
|
1025
|
+
item.label,
|
|
1026
|
+
OPERATIONAL_REPORT_MAX_LABEL_LENGTH
|
|
1027
|
+
);
|
|
1028
|
+
if (!key || !label) {
|
|
1029
|
+
return void 0;
|
|
1030
|
+
}
|
|
1031
|
+
const sanitizedSeries = { key, label };
|
|
1032
|
+
const tone = operationalReportTone(item.tone);
|
|
1033
|
+
if (tone) {
|
|
1034
|
+
sanitizedSeries.tone = tone;
|
|
1035
|
+
}
|
|
1036
|
+
return { sanitizedSeries, sourceKey: item.key };
|
|
1037
|
+
}).filter((item) => Boolean(item));
|
|
1038
|
+
if (!seriesEntries.length) {
|
|
1039
|
+
return void 0;
|
|
1040
|
+
}
|
|
1041
|
+
const series = seriesEntries.map((item) => item.sanitizedSeries);
|
|
1042
|
+
const categories = widget.categories.slice(-OPERATIONAL_REPORT_MAX_CHART_CATEGORIES).map((category, categoryIndex) => ({
|
|
1043
|
+
id: operationalReportText(
|
|
1044
|
+
category.id,
|
|
1045
|
+
OPERATIONAL_REPORT_MAX_LABEL_LENGTH
|
|
1046
|
+
) ?? `${widgetIndex}:${categoryIndex}`,
|
|
1047
|
+
label: operationalReportText(
|
|
1048
|
+
category.label,
|
|
1049
|
+
OPERATIONAL_REPORT_MAX_LABEL_LENGTH
|
|
1050
|
+
) ?? String(categoryIndex + 1),
|
|
1051
|
+
values: Object.fromEntries(
|
|
1052
|
+
seriesEntries.map(({ sanitizedSeries, sourceKey }) => [
|
|
1053
|
+
sanitizedSeries.key,
|
|
1054
|
+
Number.isFinite(category.values[sourceKey]) ? category.values[sourceKey] : 0
|
|
1055
|
+
])
|
|
1056
|
+
)
|
|
1057
|
+
}));
|
|
1058
|
+
const sanitizedWidget = {
|
|
1059
|
+
categories,
|
|
1060
|
+
id,
|
|
1061
|
+
series,
|
|
1062
|
+
title: title2,
|
|
1063
|
+
type: "bar_chart"
|
|
1064
|
+
};
|
|
1065
|
+
const description = operationalReportText(
|
|
1066
|
+
widget.description,
|
|
1067
|
+
OPERATIONAL_REPORT_MAX_VALUE_LENGTH
|
|
1068
|
+
);
|
|
1069
|
+
if (description) {
|
|
1070
|
+
sanitizedWidget.description = description;
|
|
1071
|
+
}
|
|
1072
|
+
const emptyText = operationalReportText(
|
|
1073
|
+
widget.emptyText,
|
|
1074
|
+
OPERATIONAL_REPORT_MAX_VALUE_LENGTH
|
|
1075
|
+
);
|
|
1076
|
+
if (emptyText) {
|
|
1077
|
+
sanitizedWidget.emptyText = emptyText;
|
|
1078
|
+
}
|
|
1079
|
+
const timeRangeDays = widget.timeRangeDays?.filter(
|
|
1080
|
+
(days) => days === 7 || days === 30 || days === 90
|
|
1081
|
+
);
|
|
1082
|
+
if (timeRangeDays?.length) {
|
|
1083
|
+
sanitizedWidget.timeRangeDays = [...new Set(timeRangeDays)];
|
|
1084
|
+
}
|
|
1085
|
+
return sanitizedWidget;
|
|
1086
|
+
}).filter((widget) => Boolean(widget));
|
|
907
1087
|
const sanitized = {
|
|
908
1088
|
pluginName: args.pluginName
|
|
909
1089
|
};
|
|
@@ -920,6 +1100,9 @@ function sanitizeOperationalReport(args) {
|
|
|
920
1100
|
if (metrics?.length) {
|
|
921
1101
|
sanitized.metrics = metrics;
|
|
922
1102
|
}
|
|
1103
|
+
if (widgets?.length) {
|
|
1104
|
+
sanitized.widgets = widgets;
|
|
1105
|
+
}
|
|
923
1106
|
const title = operationalReportText(
|
|
924
1107
|
args.report.title,
|
|
925
1108
|
OPERATIONAL_REPORT_MAX_LABEL_LENGTH
|
|
@@ -1105,8 +1288,10 @@ function createPluginHookRunner(input = {}) {
|
|
|
1105
1288
|
}
|
|
1106
1289
|
|
|
1107
1290
|
export {
|
|
1291
|
+
createPluginLogger,
|
|
1108
1292
|
createPluginModel,
|
|
1109
1293
|
createPluginEmbedder,
|
|
1294
|
+
createPluginState,
|
|
1110
1295
|
setDashboardConversationLinkOptions,
|
|
1111
1296
|
getDashboardConversationLink,
|
|
1112
1297
|
getSlackToolContext,
|
|
@@ -59,12 +59,35 @@ var pluginOperationalRecordSetSchema = z.object({
|
|
|
59
59
|
records: z.array(pluginOperationalRecordSchema).optional(),
|
|
60
60
|
title: z.string()
|
|
61
61
|
}).strict();
|
|
62
|
+
var pluginOperationalBarChartWidgetSchema = z.object({
|
|
63
|
+
categories: z.array(
|
|
64
|
+
z.object({
|
|
65
|
+
id: z.string().min(1),
|
|
66
|
+
label: z.string().min(1),
|
|
67
|
+
values: z.record(z.string(), z.number().finite())
|
|
68
|
+
}).strict()
|
|
69
|
+
).max(100),
|
|
70
|
+
description: z.string().optional(),
|
|
71
|
+
emptyText: z.string().optional(),
|
|
72
|
+
id: z.string().min(1),
|
|
73
|
+
series: z.array(
|
|
74
|
+
z.object({
|
|
75
|
+
key: z.string().min(1),
|
|
76
|
+
label: z.string().min(1),
|
|
77
|
+
tone: pluginOperationalToneSchema.optional()
|
|
78
|
+
}).strict()
|
|
79
|
+
).min(1).max(8),
|
|
80
|
+
timeRangeDays: z.array(z.union([z.literal(7), z.literal(30), z.literal(90)])).min(1).max(3).optional(),
|
|
81
|
+
title: z.string().min(1),
|
|
82
|
+
type: z.literal("bar_chart")
|
|
83
|
+
}).strict();
|
|
62
84
|
var pluginOperationalReportSchema = z.object({
|
|
63
85
|
generatedAt: z.string().optional(),
|
|
64
86
|
metrics: z.array(pluginOperationalMetricSchema).optional(),
|
|
65
87
|
recordSets: z.array(pluginOperationalRecordSetSchema).optional(),
|
|
66
88
|
title: z.string().optional(),
|
|
67
|
-
pluginName: z.string()
|
|
89
|
+
pluginName: z.string(),
|
|
90
|
+
widgets: z.array(pluginOperationalBarChartWidgetSchema).max(12).optional()
|
|
68
91
|
}).strict();
|
|
69
92
|
var pluginOperationalReportFeedSchema = z.object({
|
|
70
93
|
generatedAt: z.string(),
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
healthReportSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2ZTTXTSZ.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeSlackConversationId
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
juniorConversationEvents,
|
|
9
|
-
juniorConversations
|
|
10
|
-
} from "./chunk-TE4QHJH4.js";
|
|
11
|
-
import {
|
|
12
|
-
juniorDestinations
|
|
13
|
-
} from "./chunk-VFUK3X5B.js";
|
|
6
|
+
} from "./chunk-L5XQPJ7T.js";
|
|
14
7
|
import {
|
|
15
8
|
parseSlackThreadId
|
|
16
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6Y5L4BOM.js";
|
|
17
10
|
import {
|
|
18
11
|
getClient
|
|
19
12
|
} from "./chunk-6GWA276C.js";
|
|
@@ -66,133 +59,6 @@ function buildSentryConversationUrl(conversationId) {
|
|
|
66
59
|
return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
|
|
67
60
|
}
|
|
68
61
|
|
|
69
|
-
// src/chat/conversations/sql/privacy.ts
|
|
70
|
-
import { and, asc, eq, getTableColumns, inArray, sql } from "drizzle-orm";
|
|
71
|
-
var MAX_LINEAGE_DEPTH = 32;
|
|
72
|
-
var conversationEventColumns = getTableColumns(juniorConversationEvents);
|
|
73
|
-
function rootVisibilitySnapshotSql(conversationId) {
|
|
74
|
-
return sql`(
|
|
75
|
-
with recursive lineage(
|
|
76
|
-
conversation_id,
|
|
77
|
-
parent_conversation_id,
|
|
78
|
-
destination_id,
|
|
79
|
-
path,
|
|
80
|
-
depth
|
|
81
|
-
) as (
|
|
82
|
-
select
|
|
83
|
-
requested.conversation_id,
|
|
84
|
-
requested.parent_conversation_id,
|
|
85
|
-
requested.destination_id,
|
|
86
|
-
array[requested.conversation_id]::text[],
|
|
87
|
-
1
|
|
88
|
-
from junior_conversations requested
|
|
89
|
-
where requested.conversation_id = ${conversationId}
|
|
90
|
-
|
|
91
|
-
union all
|
|
92
|
-
|
|
93
|
-
select
|
|
94
|
-
parent.conversation_id,
|
|
95
|
-
parent.parent_conversation_id,
|
|
96
|
-
parent.destination_id,
|
|
97
|
-
lineage.path || parent.conversation_id,
|
|
98
|
-
lineage.depth + 1
|
|
99
|
-
from lineage
|
|
100
|
-
join junior_conversations parent
|
|
101
|
-
on parent.conversation_id = lineage.parent_conversation_id
|
|
102
|
-
where lineage.depth < ${MAX_LINEAGE_DEPTH}
|
|
103
|
-
and not (parent.conversation_id = any(lineage.path))
|
|
104
|
-
),
|
|
105
|
-
root_candidate as (
|
|
106
|
-
select lineage.conversation_id, lineage.destination_id
|
|
107
|
-
from lineage
|
|
108
|
-
where lineage.parent_conversation_id is null
|
|
109
|
-
and lineage.destination_id is not null
|
|
110
|
-
limit 1
|
|
111
|
-
)
|
|
112
|
-
select jsonb_build_object(
|
|
113
|
-
'rootConversationId', coalesce(root.conversation_id, ${conversationId}),
|
|
114
|
-
'visibility', destination.visibility
|
|
115
|
-
)
|
|
116
|
-
from (select 1) seed
|
|
117
|
-
left join root_candidate root on true
|
|
118
|
-
left join junior_destinations destination
|
|
119
|
-
on destination.id = root.destination_id
|
|
120
|
-
)`;
|
|
121
|
-
}
|
|
122
|
-
async function readConversationEventPrivacySnapshot(executor, args) {
|
|
123
|
-
const rows = await executor.db().select({
|
|
124
|
-
privacy: rootVisibilitySnapshotSql(args.conversationId),
|
|
125
|
-
event: {
|
|
126
|
-
...conversationEventColumns,
|
|
127
|
-
// Replacement history is model context, never dashboard report data.
|
|
128
|
-
// Keep the required replacement field while redacting its contents.
|
|
129
|
-
payload: sql`case
|
|
130
|
-
when ${juniorConversationEvents.type} in ('compaction', 'handoff')
|
|
131
|
-
then jsonb_set(
|
|
132
|
-
${juniorConversationEvents.payload},
|
|
133
|
-
'{replacementHistory}',
|
|
134
|
-
'[]'::jsonb
|
|
135
|
-
)
|
|
136
|
-
else ${juniorConversationEvents.payload}
|
|
137
|
-
end`
|
|
138
|
-
}
|
|
139
|
-
}).from(juniorConversations).leftJoin(
|
|
140
|
-
juniorConversationEvents,
|
|
141
|
-
and(
|
|
142
|
-
eq(juniorConversationEvents.conversationId, args.conversationId),
|
|
143
|
-
inArray(juniorConversationEvents.type, [...args.eventTypes])
|
|
144
|
-
)
|
|
145
|
-
).where(eq(juniorConversations.conversationId, args.conversationId)).orderBy(asc(juniorConversationEvents.seq));
|
|
146
|
-
const first = rows[0];
|
|
147
|
-
if (!first) return void 0;
|
|
148
|
-
return {
|
|
149
|
-
...first.privacy,
|
|
150
|
-
events: rows.flatMap(({ event }) => event ? [event] : [])
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
async function readLineageRow(executor, conversationId) {
|
|
154
|
-
const rows = await executor.db().select({
|
|
155
|
-
parentId: juniorConversations.parentConversationId,
|
|
156
|
-
destinationId: juniorConversations.destinationId
|
|
157
|
-
}).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId));
|
|
158
|
-
return rows[0];
|
|
159
|
-
}
|
|
160
|
-
async function traceLineage(executor, conversationId) {
|
|
161
|
-
let currentId = conversationId;
|
|
162
|
-
const seen = /* @__PURE__ */ new Set();
|
|
163
|
-
while (!seen.has(currentId) && seen.size < MAX_LINEAGE_DEPTH) {
|
|
164
|
-
seen.add(currentId);
|
|
165
|
-
const row = await readLineageRow(executor, currentId);
|
|
166
|
-
if (!row) return void 0;
|
|
167
|
-
if (row.parentId) {
|
|
168
|
-
currentId = row.parentId;
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (!row.destinationId) {
|
|
172
|
-
return void 0;
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
destinationId: row.destinationId,
|
|
176
|
-
rootConversationId: currentId
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
return void 0;
|
|
180
|
-
}
|
|
181
|
-
async function readCandidateVisibility(executor, candidate) {
|
|
182
|
-
const destinations = await executor.db().select({ visibility: juniorDestinations.visibility }).from(juniorDestinations).where(eq(juniorDestinations.id, candidate.destinationId)).for("share");
|
|
183
|
-
return {
|
|
184
|
-
rootConversationId: candidate.rootConversationId,
|
|
185
|
-
visibility: destinations[0]?.visibility ?? null
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
async function resolveRootVisibility(executor, conversationId) {
|
|
189
|
-
const candidate = await traceLineage(executor, conversationId);
|
|
190
|
-
if (!candidate) {
|
|
191
|
-
return { rootConversationId: conversationId, visibility: null };
|
|
192
|
-
}
|
|
193
|
-
return readCandidateVisibility(executor, candidate);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
62
|
// src/chat/slack/conversation-context.ts
|
|
197
63
|
function normalizeConversationName(type, channelName) {
|
|
198
64
|
const trimmed = channelName?.trim();
|
|
@@ -279,8 +145,6 @@ export {
|
|
|
279
145
|
readHealthReport,
|
|
280
146
|
GET,
|
|
281
147
|
buildSentryConversationUrl,
|
|
282
|
-
readConversationEventPrivacySnapshot,
|
|
283
|
-
resolveRootVisibility,
|
|
284
148
|
conversationVisibilityFromSlackChannelType,
|
|
285
149
|
resolveSlackChannelTypeFromMessage,
|
|
286
150
|
resolveSlackConversationContext,
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
} from "./chunk-KNFROR7R.js";
|
|
6
6
|
import {
|
|
7
7
|
clearPendingAuth,
|
|
8
|
+
coerceThreadConversationState,
|
|
9
|
+
getAgentTurnSessionRecord,
|
|
8
10
|
getInterruptionMarker,
|
|
9
11
|
getPersistedThreadState,
|
|
10
12
|
hydrateConversationMessages,
|
|
@@ -12,26 +14,20 @@ import {
|
|
|
12
14
|
markTurnCompleted,
|
|
13
15
|
mergeArtifactsState,
|
|
14
16
|
updateConversationStats
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
coerceThreadConversationState,
|
|
18
|
-
getAgentTurnSessionRecord
|
|
19
|
-
} from "./chunk-J3B3FPP2.js";
|
|
17
|
+
} from "./chunk-C5XAFTHY.js";
|
|
20
18
|
import {
|
|
21
19
|
createPluginEmbedder,
|
|
20
|
+
createPluginLogger,
|
|
22
21
|
createPluginModel,
|
|
22
|
+
createPluginState,
|
|
23
23
|
getPlugins
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import {
|
|
26
|
-
createPluginLogger,
|
|
27
|
-
createPluginState
|
|
28
|
-
} from "./chunk-AHJR2IFF.js";
|
|
24
|
+
} from "./chunk-2T7TIEXI.js";
|
|
29
25
|
import {
|
|
30
26
|
getStateAdapter
|
|
31
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GK47NBDE.js";
|
|
32
28
|
import {
|
|
33
29
|
getDb
|
|
34
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-4QU44P7Q.js";
|
|
35
31
|
import {
|
|
36
32
|
getPiMessageRole,
|
|
37
33
|
instructionTextForProjection,
|
|
@@ -39,13 +35,13 @@ import {
|
|
|
39
35
|
isToolResultMessage,
|
|
40
36
|
normalizeToolNameFromResult,
|
|
41
37
|
stripRuntimeTurnContext
|
|
42
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-WNOVRQ67.js";
|
|
43
39
|
import {
|
|
44
40
|
buildTurnFailureResponse
|
|
45
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-IYKPU7H6.js";
|
|
46
42
|
import {
|
|
47
43
|
parseSlackMessageTs
|
|
48
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-42WRQLJ6.js";
|
|
49
45
|
|
|
50
46
|
// src/chat/services/turn-failure-response.ts
|
|
51
47
|
function requireTurnFailureEventId(eventId, eventName) {
|
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var JUNIOR_RETENTION_ROUTE = "/api/internal/retention";
|
|
5
|
-
var JUNIOR_RETENTION_CRON_SCHEDULE = "0 4 * * *";
|
|
6
|
-
var JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE = "/api/internal/agent/continue";
|
|
7
|
-
var JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE = "/api/internal/plugin/tasks";
|
|
8
|
-
var LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION = "api/internal/agent/continue.ts";
|
|
9
|
-
function toOptionalTrimmed(value) {
|
|
10
|
-
const trimmed = value?.trim();
|
|
11
|
-
return trimmed ? trimmed : void 0;
|
|
1
|
+
// src/chat/coerce.ts
|
|
2
|
+
function toOptionalString(value) {
|
|
3
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
12
4
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
5
|
+
function toOptionalNumber(value) {
|
|
6
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
15
7
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
const serviceVersion = getDeploymentServiceVersion();
|
|
19
|
-
const deploymentId = toOptionalTrimmed(process.env.VERCEL_DEPLOYMENT_ID);
|
|
20
|
-
if (serviceVersion) {
|
|
21
|
-
attributes["service.version"] = serviceVersion;
|
|
22
|
-
}
|
|
23
|
-
if (deploymentId) {
|
|
24
|
-
attributes["deployment.id"] = deploymentId;
|
|
25
|
-
}
|
|
26
|
-
return attributes;
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null;
|
|
27
10
|
}
|
|
28
11
|
|
|
29
12
|
// src/chat/slack/timestamp.ts
|
|
@@ -77,15 +60,9 @@ function parseSlackUserId(value) {
|
|
|
77
60
|
}
|
|
78
61
|
|
|
79
62
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
JUNIOR_RETENTION_CRON_SCHEDULE,
|
|
84
|
-
JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
|
|
85
|
-
JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE,
|
|
86
|
-
LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION,
|
|
87
|
-
getDeploymentServiceVersion,
|
|
88
|
-
getDeploymentTelemetryAttributes,
|
|
63
|
+
toOptionalString,
|
|
64
|
+
toOptionalNumber,
|
|
65
|
+
isRecord,
|
|
89
66
|
parseSlackMessageTs,
|
|
90
67
|
parseSlackChannelId,
|
|
91
68
|
parseSlackChannelReferenceId,
|