@sentry/junior 0.91.0 → 0.92.1
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-MXAF7RQL.js → agent-hooks-KL7I3ZRC.js} +7 -7
- package/dist/api/people/list.d.ts +3 -3
- package/dist/api/people/list.js +15 -15
- package/dist/api/people/list.query.d.ts +2 -2
- package/dist/api/people/profile.d.ts +3 -3
- package/dist/api/people/profile.js +12 -12
- package/dist/api/people/profile.query.d.ts +2 -2
- package/dist/api/people/shared.d.ts +13 -13
- package/dist/api/people/types.d.ts +12 -12
- package/dist/api-reference.d.ts +1 -1
- package/dist/app.js +365 -265
- package/dist/{catalog-runtime-DXE6NXHT.js → catalog-runtime-NZHMSMYC.js} +2 -2
- package/dist/chat/actor.d.ts +75 -0
- package/dist/chat/agent/prompt.d.ts +2 -2
- package/dist/chat/agent/request.d.ts +13 -13
- package/dist/chat/agent/resume.d.ts +5 -4
- package/dist/chat/agent/tools.d.ts +4 -2
- package/dist/chat/capabilities/jr-rpc-command.d.ts +1 -1
- package/dist/chat/conversation-privacy.d.ts +11 -0
- package/dist/chat/conversations/sql/migrations.d.ts +1 -1
- package/dist/chat/conversations/sql/schema/conversations.d.ts +2 -19
- package/dist/chat/conversations/sql/schema.d.ts +2 -19
- package/dist/chat/conversations/sql/store.d.ts +3 -3
- package/dist/chat/conversations/store.d.ts +4 -4
- package/dist/chat/credentials/context.d.ts +4 -4
- package/dist/chat/logging.d.ts +2 -2
- package/dist/chat/no-reply.d.ts +1 -1
- package/dist/chat/oauth-flow.d.ts +1 -1
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/pi/transcript.d.ts +15 -0
- package/dist/chat/plugins/agent-hooks.d.ts +5 -3
- package/dist/chat/plugins/credential-hooks.d.ts +2 -8
- package/dist/chat/prompt.d.ts +3 -6
- package/dist/chat/runtime/reply-executor.d.ts +1 -1
- package/dist/chat/runtime/turn-input.d.ts +1 -1
- package/dist/chat/sandbox/egress/schemas.d.ts +2 -2
- package/dist/chat/sandbox/egress/session.d.ts +1 -1
- package/dist/chat/services/context-compaction.d.ts +1 -1
- package/dist/chat/services/conversation-memory.d.ts +1 -1
- package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/message-actor-identity.d.ts +4 -4
- package/dist/chat/services/pending-auth.d.ts +2 -2
- package/dist/chat/services/plugin-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/provider-default-config.d.ts +1 -1
- package/dist/chat/services/subscribed-decision.d.ts +1 -1
- package/dist/chat/services/turn-result.d.ts +1 -1
- package/dist/chat/services/turn-session-record.d.ts +11 -8
- package/dist/chat/services/turn-thinking-level.d.ts +1 -1
- package/dist/chat/slack/assistant-thread/title.d.ts +1 -1
- package/dist/chat/slack/tools/canvas/create.d.ts +41 -1
- package/dist/chat/slack/tools/canvas/edit.d.ts +60 -1
- package/dist/chat/slack/tools/canvas/read.d.ts +60 -1
- package/dist/chat/slack/tools/canvas/write.d.ts +41 -1
- package/dist/chat/slack/tools/channel-list-messages.d.ts +45 -1
- package/dist/chat/slack/tools/context.d.ts +3 -3
- package/dist/chat/slack/tools/list/add-items.d.ts +42 -1
- package/dist/chat/slack/tools/list/create.d.ts +40 -1
- package/dist/chat/slack/tools/list/get-items.d.ts +40 -1
- package/dist/chat/slack/tools/list/update-item.d.ts +46 -1
- package/dist/chat/slack/tools/message-add-reaction.d.ts +40 -1
- package/dist/chat/slack/tools/send-message.d.ts +45 -1
- package/dist/chat/slack/tools/thread-read.d.ts +44 -1
- package/dist/chat/slack/tools/user-lookup.d.ts +45 -1
- package/dist/chat/slack/user.d.ts +3 -3
- package/dist/chat/slack/vision-context.d.ts +2 -2
- package/dist/chat/sql/schema.d.ts +2 -19
- package/dist/chat/state/conversation-details.d.ts +4 -4
- package/dist/chat/state/conversation.d.ts +1 -1
- package/dist/chat/state/session-log.d.ts +140 -26
- package/dist/chat/state/turn-session.d.ts +18 -5
- package/dist/chat/task-execution/slack-work.d.ts +2 -2
- package/dist/chat/task-execution/state.d.ts +4 -4
- package/dist/chat/tool-support/zod-tool.d.ts +16 -4
- package/dist/chat/tools/advisor/tool.d.ts +41 -1
- package/dist/chat/tools/definition.d.ts +10 -0
- package/dist/chat/tools/execute-tool.d.ts +41 -1
- package/dist/chat/tools/resource-events.d.ts +124 -3
- package/dist/chat/tools/runtime/report-progress.d.ts +40 -1
- package/dist/chat/tools/sandbox/bash.d.ts +41 -1
- package/dist/chat/tools/sandbox/edit-file.d.ts +44 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +42 -1
- package/dist/chat/tools/sandbox/grep.d.ts +46 -1
- package/dist/chat/tools/sandbox/list-dir.d.ts +41 -1
- package/dist/chat/tools/sandbox/read-file.d.ts +42 -1
- package/dist/chat/tools/sandbox/write-file.d.ts +41 -1
- package/dist/chat/tools/search-tools.d.ts +102 -1
- package/dist/chat/tools/skill/call-mcp-tool.d.ts +10 -1
- package/dist/chat/tools/skill/load-skill.d.ts +40 -1
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +100 -1
- package/dist/chat/tools/system-time.d.ts +38 -1
- package/dist/chat/tools/types.d.ts +4 -4
- package/dist/chat/tools/web/fetch-tool.d.ts +41 -1
- package/dist/chat/tools/web/image-generate.d.ts +62 -1
- package/dist/chat/tools/web/search.d.ts +41 -1
- package/dist/{chunk-HXL2ZV74.js → chunk-3F54A3YM.js} +82 -11
- package/dist/{chunk-ZGDTBSQ7.js → chunk-56SIBIVF.js} +930 -660
- package/dist/{chunk-DACFZ5CI.js → chunk-7K3JALTQ.js} +18 -12
- package/dist/{chunk-IRRMABQD.js → chunk-APIVR44P.js} +10 -10
- package/dist/{chunk-XP7F4LYB.js → chunk-BTH37NCU.js} +4 -4
- package/dist/{chunk-5GBUZI6M.js → chunk-H7KUZAMZ.js} +4 -4
- package/dist/{chunk-PIB4EOW6.js → chunk-IWKVXO3F.js} +19 -72
- package/dist/{chunk-TYUXD3FN.js → chunk-MC4ZZE4Q.js} +1 -1
- package/dist/{chunk-2S7M37HY.js → chunk-NIFONS4W.js} +86 -47
- package/dist/{chunk-AOISHLSF.js → chunk-O6ZYIHFC.js} +143 -20
- package/dist/{chunk-GCWD2VHP.js → chunk-OQQU3SD6.js} +285 -124
- package/dist/{chunk-NW7AXDA5.js → chunk-OZJXGX4U.js} +2 -2
- package/dist/{chunk-KC42JAAQ.js → chunk-PFXC67GJ.js} +3 -3
- package/dist/{chunk-QCKGI74V.js → chunk-PGR4WGZW.js} +10 -10
- package/dist/{chunk-ZUK7BL63.js → chunk-S6QKIGRM.js} +66 -54
- package/dist/{chunk-IX76WFJV.js → chunk-TF5VLGA7.js} +10 -10
- package/dist/{chunk-AN2437E3.js → chunk-YTNPU7I2.js} +2 -2
- package/dist/{chunk-3MPOMK3K.js → chunk-YYBX2BD5.js} +61 -3
- package/dist/{chunk-ONFOWI2D.js → chunk-Z4FOYQXW.js} +16 -15
- package/dist/{chunk-RS6ANWVT.js → chunk-ZATRYQLR.js} +1 -1
- package/dist/cli/chat.js +20 -20
- package/dist/cli/check.js +3 -3
- package/dist/cli/plugins.js +9 -9
- package/dist/cli/snapshot-warmup.js +6 -6
- package/dist/cli/upgrade.js +9 -9
- package/dist/{db-CXI7PR5U.js → db-GCK43OO3.js} +4 -4
- package/dist/instrumentation.js +1 -1
- package/dist/reporting/conversations.d.ts +3 -3
- package/dist/reporting.d.ts +1 -1
- package/dist/reporting.js +48 -50
- package/dist/{runner-FKL3RAHA.js → runner-Y73GZ2VE.js} +20 -18
- package/dist/{validation-I7GD2YWS.js → validation-KYAWETI4.js} +3 -3
- package/package.json +6 -6
- package/dist/chat/requester.d.ts +0 -68
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getStateAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZATRYQLR.js";
|
|
4
4
|
import {
|
|
5
5
|
logException,
|
|
6
6
|
logInfo,
|
|
7
7
|
logWarn
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-S6QKIGRM.js";
|
|
9
9
|
|
|
10
10
|
// src/chat/plugins/logging.ts
|
|
11
11
|
function createPluginLogger(plugin) {
|
|
@@ -88,17 +88,17 @@ function coercePendingAuthState(value) {
|
|
|
88
88
|
}
|
|
89
89
|
const kind = value.kind;
|
|
90
90
|
const provider = toOptionalString(value.provider);
|
|
91
|
-
const
|
|
91
|
+
const actorId = toOptionalString(value.actorId);
|
|
92
92
|
const scope = toOptionalString(value.scope);
|
|
93
93
|
const sessionId = toOptionalString(value.sessionId);
|
|
94
94
|
const linkSentAtMs = toOptionalNumber(value.linkSentAtMs);
|
|
95
|
-
if (kind !== "mcp" && kind !== "plugin" || !provider || !
|
|
95
|
+
if (kind !== "mcp" && kind !== "plugin" || !provider || !actorId || !sessionId || typeof linkSentAtMs !== "number") {
|
|
96
96
|
return void 0;
|
|
97
97
|
}
|
|
98
98
|
return {
|
|
99
99
|
kind,
|
|
100
100
|
provider,
|
|
101
|
-
|
|
101
|
+
actorId,
|
|
102
102
|
...scope ? { scope } : {},
|
|
103
103
|
sessionId,
|
|
104
104
|
linkSentAtMs
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeSlackConversationId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7K3JALTQ.js";
|
|
4
4
|
import {
|
|
5
5
|
getStateAdapter
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZATRYQLR.js";
|
|
7
7
|
import {
|
|
8
8
|
parseSlackThreadId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YYBX2BD5.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
parseStoredSlackActor
|
|
12
|
+
} from "./chunk-S6QKIGRM.js";
|
|
13
13
|
import {
|
|
14
14
|
isRecord,
|
|
15
15
|
toOptionalNumber
|
|
@@ -174,8 +174,8 @@ function conversationContextKey(conversationId) {
|
|
|
174
174
|
function conversationTitleKey(conversationId) {
|
|
175
175
|
return `${CONVERSATION_PREFIX}:${conversationId}:title`;
|
|
176
176
|
}
|
|
177
|
-
function
|
|
178
|
-
return
|
|
177
|
+
function parseOriginActor(value) {
|
|
178
|
+
return parseStoredSlackActor(value);
|
|
179
179
|
}
|
|
180
180
|
function parseOriginSurface(value) {
|
|
181
181
|
if (value === "slack" || value === "api" || value === "scheduler" || value === "internal") {
|
|
@@ -187,7 +187,7 @@ function storedContextFromInput(context) {
|
|
|
187
187
|
return {
|
|
188
188
|
...context.channelName ? { channelName: context.channelName } : {},
|
|
189
189
|
...context.originSurface ? { originSurface: context.originSurface } : {},
|
|
190
|
-
...context.
|
|
190
|
+
...context.originActor ? { originActor: context.originActor } : {},
|
|
191
191
|
startedAtMs: context.startedAtMs
|
|
192
192
|
};
|
|
193
193
|
}
|
|
@@ -198,7 +198,7 @@ function parseContext(value) {
|
|
|
198
198
|
return {
|
|
199
199
|
...typeof value.channelName === "string" && value.channelName.trim() ? { channelName: value.channelName.trim() } : {},
|
|
200
200
|
...parseOriginSurface(value.originSurface) ? { originSurface: parseOriginSurface(value.originSurface) } : {},
|
|
201
|
-
...
|
|
201
|
+
...parseOriginActor(value.originActor) ? { originActor: parseOriginActor(value.originActor) } : {},
|
|
202
202
|
startedAtMs
|
|
203
203
|
};
|
|
204
204
|
}
|
|
@@ -255,7 +255,7 @@ async function getConversationDetails(conversationId) {
|
|
|
255
255
|
...title?.titleSourceMessageId ? { titleSourceMessageId: title.titleSourceMessageId } : {},
|
|
256
256
|
...context?.channelName ? { channelName: context.channelName } : {},
|
|
257
257
|
...context?.originSurface ? { originSurface: context.originSurface } : {},
|
|
258
|
-
...context?.
|
|
258
|
+
...context?.originActor ? { originActor: context.originActor } : {},
|
|
259
259
|
...context?.startedAtMs !== void 0 ? { startedAtMs: context.startedAtMs } : {}
|
|
260
260
|
};
|
|
261
261
|
}
|
|
@@ -1340,27 +1340,35 @@ function extractGenAiUsageSummary(...sources) {
|
|
|
1340
1340
|
return summary;
|
|
1341
1341
|
}
|
|
1342
1342
|
function extractGenAiUsageAttributes(...sources) {
|
|
1343
|
-
const {
|
|
1343
|
+
const {
|
|
1344
|
+
inputTokens,
|
|
1345
|
+
outputTokens,
|
|
1346
|
+
cachedInputTokens,
|
|
1347
|
+
cacheCreationTokens,
|
|
1348
|
+
totalTokens
|
|
1349
|
+
} = extractGenAiUsageSummary(...sources);
|
|
1344
1350
|
const semanticInputTokens = sumTokenCounts(
|
|
1345
1351
|
inputTokens,
|
|
1346
1352
|
cachedInputTokens,
|
|
1347
1353
|
cacheCreationTokens
|
|
1348
1354
|
);
|
|
1355
|
+
const semanticTotalTokens = totalTokens ?? sumTokenCounts(semanticInputTokens, outputTokens);
|
|
1349
1356
|
return {
|
|
1350
1357
|
...semanticInputTokens !== void 0 ? { "gen_ai.usage.input_tokens": semanticInputTokens } : {},
|
|
1351
1358
|
...outputTokens !== void 0 ? { "gen_ai.usage.output_tokens": outputTokens } : {},
|
|
1352
|
-
...
|
|
1353
|
-
...
|
|
1359
|
+
...semanticTotalTokens !== void 0 ? { "gen_ai.usage.total_tokens": semanticTotalTokens } : {},
|
|
1360
|
+
...cachedInputTokens !== void 0 ? { "gen_ai.usage.input_tokens.cached": cachedInputTokens } : {},
|
|
1361
|
+
...cacheCreationTokens !== void 0 ? { "gen_ai.usage.input_tokens.cache_write": cacheCreationTokens } : {}
|
|
1354
1362
|
};
|
|
1355
1363
|
}
|
|
1356
1364
|
|
|
1357
|
-
// src/chat/
|
|
1365
|
+
// src/chat/actor.ts
|
|
1358
1366
|
import { z } from "zod";
|
|
1359
|
-
import {
|
|
1367
|
+
import { actorSchema } from "@sentry/junior-plugin-api";
|
|
1360
1368
|
var SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
1361
1369
|
var EMAIL_PATTERN = /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;
|
|
1362
1370
|
var exactStoredStringSchema = z.string().min(1).refine((value) => value === value.trim());
|
|
1363
|
-
var
|
|
1371
|
+
var storedSlackActorSchema = z.object({
|
|
1364
1372
|
email: exactStoredStringSchema.optional(),
|
|
1365
1373
|
fullName: exactStoredStringSchema.optional(),
|
|
1366
1374
|
platform: z.literal("slack").optional(),
|
|
@@ -1368,10 +1376,13 @@ var storedSlackRequesterSchema = z.object({
|
|
|
1368
1376
|
slackUserName: exactStoredStringSchema.optional(),
|
|
1369
1377
|
teamId: exactStoredStringSchema.optional()
|
|
1370
1378
|
}).strict();
|
|
1371
|
-
function
|
|
1372
|
-
const result =
|
|
1379
|
+
function parseActor(value) {
|
|
1380
|
+
const result = actorSchema.safeParse(value);
|
|
1373
1381
|
return result.success ? result.data : void 0;
|
|
1374
1382
|
}
|
|
1383
|
+
function isUserActor(actor) {
|
|
1384
|
+
return Boolean(actor && "userId" in actor);
|
|
1385
|
+
}
|
|
1375
1386
|
function clean(value) {
|
|
1376
1387
|
const trimmed = value?.trim();
|
|
1377
1388
|
return trimmed ? trimmed : void 0;
|
|
@@ -1382,7 +1393,7 @@ function isSyntheticActorUserId(value) {
|
|
|
1382
1393
|
function isSlackUserId(value) {
|
|
1383
1394
|
return SLACK_USER_ID_DISPLAY_PATTERN.test(value);
|
|
1384
1395
|
}
|
|
1385
|
-
function
|
|
1396
|
+
function cleanActorDisplayName(value, userId) {
|
|
1386
1397
|
const displayName = clean(value);
|
|
1387
1398
|
if (!displayName) {
|
|
1388
1399
|
return void 0;
|
|
@@ -1395,7 +1406,7 @@ function cleanRequesterDisplayName(value, userId) {
|
|
|
1395
1406
|
}
|
|
1396
1407
|
return isSlackUserId(displayName) ? void 0 : displayName;
|
|
1397
1408
|
}
|
|
1398
|
-
function
|
|
1409
|
+
function cleanActorEmail(value) {
|
|
1399
1410
|
const email = clean(value);
|
|
1400
1411
|
return email && EMAIL_PATTERN.test(email) ? email : void 0;
|
|
1401
1412
|
}
|
|
@@ -1411,7 +1422,7 @@ function parseActorUserId(value) {
|
|
|
1411
1422
|
function isActorUserId(value) {
|
|
1412
1423
|
return parseActorUserId(value) === value;
|
|
1413
1424
|
}
|
|
1414
|
-
function
|
|
1425
|
+
function createActor(input, context) {
|
|
1415
1426
|
const platform = context.platform ?? input?.platform;
|
|
1416
1427
|
if (!platform) {
|
|
1417
1428
|
return void 0;
|
|
@@ -1424,8 +1435,8 @@ function createRequester(input, context) {
|
|
|
1424
1435
|
if (input?.userId !== void 0 && !inputUserId) {
|
|
1425
1436
|
return void 0;
|
|
1426
1437
|
}
|
|
1427
|
-
const
|
|
1428
|
-
if (!
|
|
1438
|
+
const actorUserId = contextUserId ?? inputUserId;
|
|
1439
|
+
if (!actorUserId) {
|
|
1429
1440
|
return void 0;
|
|
1430
1441
|
}
|
|
1431
1442
|
const contextTeamId = parseSlackTeamId(context.teamId);
|
|
@@ -1436,34 +1447,34 @@ function createRequester(input, context) {
|
|
|
1436
1447
|
if (input?.teamId !== void 0 && !inputTeamId) {
|
|
1437
1448
|
return void 0;
|
|
1438
1449
|
}
|
|
1439
|
-
const
|
|
1440
|
-
if (platform === "slack" && !
|
|
1450
|
+
const actorTeamId = contextTeamId ?? inputTeamId;
|
|
1451
|
+
if (platform === "slack" && !actorTeamId) {
|
|
1441
1452
|
return void 0;
|
|
1442
1453
|
}
|
|
1443
1454
|
const canUseInputProfile = (!contextUserId || !inputUserId || contextUserId === inputUserId) && (platform !== "slack" || !contextTeamId || !inputTeamId || contextTeamId === inputTeamId);
|
|
1444
|
-
const
|
|
1445
|
-
...canUseInputProfile &&
|
|
1446
|
-
...canUseInputProfile &&
|
|
1447
|
-
fullName:
|
|
1455
|
+
const actor = {
|
|
1456
|
+
...canUseInputProfile && cleanActorEmail(input?.email) ? { email: cleanActorEmail(input?.email) } : {},
|
|
1457
|
+
...canUseInputProfile && cleanActorDisplayName(input?.fullName, actorUserId) ? {
|
|
1458
|
+
fullName: cleanActorDisplayName(input?.fullName, actorUserId)
|
|
1448
1459
|
} : {},
|
|
1449
1460
|
platform,
|
|
1450
|
-
userId:
|
|
1451
|
-
...canUseInputProfile &&
|
|
1452
|
-
userName:
|
|
1461
|
+
userId: actorUserId,
|
|
1462
|
+
...canUseInputProfile && cleanActorDisplayName(input?.userName, actorUserId) ? {
|
|
1463
|
+
userName: cleanActorDisplayName(input?.userName, actorUserId)
|
|
1453
1464
|
} : {}
|
|
1454
1465
|
};
|
|
1455
1466
|
if (platform === "slack") {
|
|
1456
|
-
return { ...
|
|
1467
|
+
return { ...actor, platform, teamId: actorTeamId };
|
|
1457
1468
|
}
|
|
1458
|
-
return { ...
|
|
1469
|
+
return { ...actor, platform };
|
|
1459
1470
|
}
|
|
1460
|
-
function
|
|
1471
|
+
function createSlackActor(teamId, userId, profile) {
|
|
1461
1472
|
const actorUserId = parseActorUserId(userId);
|
|
1462
1473
|
const actorTeamId = parseSlackTeamId(teamId);
|
|
1463
1474
|
if (!actorTeamId || !actorUserId) {
|
|
1464
|
-
throw new Error("Slack
|
|
1475
|
+
throw new Error("Slack actor requires team and user ids");
|
|
1465
1476
|
}
|
|
1466
|
-
const
|
|
1477
|
+
const actor = createActor(
|
|
1467
1478
|
{
|
|
1468
1479
|
email: profile?.email,
|
|
1469
1480
|
fullName: profile?.fullName,
|
|
@@ -1474,13 +1485,13 @@ function createSlackRequester(teamId, userId, profile) {
|
|
|
1474
1485
|
},
|
|
1475
1486
|
{ teamId: actorTeamId, userId: actorUserId }
|
|
1476
1487
|
);
|
|
1477
|
-
if (!
|
|
1478
|
-
throw new Error("Slack
|
|
1488
|
+
if (!actor || actor.platform !== "slack") {
|
|
1489
|
+
throw new Error("Slack actor requires team and user ids");
|
|
1479
1490
|
}
|
|
1480
|
-
return
|
|
1491
|
+
return actor;
|
|
1481
1492
|
}
|
|
1482
|
-
function
|
|
1483
|
-
const parsed =
|
|
1493
|
+
function parseStoredSlackActor(value) {
|
|
1494
|
+
const parsed = storedSlackActorSchema.safeParse(value);
|
|
1484
1495
|
if (!parsed.success) {
|
|
1485
1496
|
return void 0;
|
|
1486
1497
|
}
|
|
@@ -1495,31 +1506,31 @@ function parseStoredSlackRequester(value) {
|
|
|
1495
1506
|
}
|
|
1496
1507
|
return parsed.data;
|
|
1497
1508
|
}
|
|
1498
|
-
function
|
|
1509
|
+
function toStoredSlackActor(actor) {
|
|
1499
1510
|
return {
|
|
1500
|
-
...
|
|
1501
|
-
...
|
|
1502
|
-
platform:
|
|
1503
|
-
slackUserId:
|
|
1504
|
-
...
|
|
1505
|
-
teamId:
|
|
1511
|
+
...actor.email ? { email: actor.email } : {},
|
|
1512
|
+
...actor.fullName ? { fullName: actor.fullName } : {},
|
|
1513
|
+
platform: actor.platform,
|
|
1514
|
+
slackUserId: actor.userId,
|
|
1515
|
+
...actor.userName ? { slackUserName: actor.userName } : {},
|
|
1516
|
+
teamId: actor.teamId
|
|
1506
1517
|
};
|
|
1507
1518
|
}
|
|
1508
|
-
function
|
|
1509
|
-
if (args.
|
|
1510
|
-
if (args.
|
|
1511
|
-
throw new Error("Stored Slack
|
|
1519
|
+
function createSlackResumeActor(args) {
|
|
1520
|
+
if (args.actor) {
|
|
1521
|
+
if (args.actor.platform !== "slack" || args.actor.teamId !== args.teamId || args.actor.userId !== args.userId) {
|
|
1522
|
+
throw new Error("Stored Slack actor did not match resume actor");
|
|
1512
1523
|
}
|
|
1513
1524
|
}
|
|
1514
|
-
const
|
|
1525
|
+
const actor = createActor(args.actor, {
|
|
1515
1526
|
platform: "slack",
|
|
1516
1527
|
teamId: args.teamId,
|
|
1517
1528
|
userId: args.userId
|
|
1518
1529
|
});
|
|
1519
|
-
if (!
|
|
1520
|
-
throw new Error("Slack
|
|
1530
|
+
if (!actor || actor.platform !== "slack") {
|
|
1531
|
+
throw new Error("Slack actor requires team and user ids");
|
|
1521
1532
|
}
|
|
1522
|
-
return
|
|
1533
|
+
return actor;
|
|
1523
1534
|
}
|
|
1524
1535
|
|
|
1525
1536
|
export {
|
|
@@ -1545,13 +1556,14 @@ export {
|
|
|
1545
1556
|
serializeGenAiAttribute,
|
|
1546
1557
|
extractGenAiUsageSummary,
|
|
1547
1558
|
extractGenAiUsageAttributes,
|
|
1548
|
-
|
|
1549
|
-
|
|
1559
|
+
storedSlackActorSchema,
|
|
1560
|
+
parseActor,
|
|
1561
|
+
isUserActor,
|
|
1550
1562
|
parseActorUserId,
|
|
1551
1563
|
isActorUserId,
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1564
|
+
createActor,
|
|
1565
|
+
createSlackActor,
|
|
1566
|
+
parseStoredSlackActor,
|
|
1567
|
+
toStoredSlackActor,
|
|
1568
|
+
createSlackResumeActor
|
|
1557
1569
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PFXC67GJ.js";
|
|
4
4
|
import {
|
|
5
5
|
getDefaultRedisStateAdapterFor,
|
|
6
6
|
getStateAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZATRYQLR.js";
|
|
8
8
|
import {
|
|
9
9
|
getChatConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3F54A3YM.js";
|
|
11
11
|
import {
|
|
12
12
|
parseDestination,
|
|
13
13
|
sameDestination
|
|
14
14
|
} from "./chunk-GHGPTPBL.js";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
parseStoredSlackActor
|
|
17
|
+
} from "./chunk-S6QKIGRM.js";
|
|
18
18
|
import {
|
|
19
19
|
isRecord,
|
|
20
20
|
toOptionalNumber,
|
|
@@ -150,8 +150,8 @@ function normalizeMessage(value) {
|
|
|
150
150
|
function isFinalAttempt(message) {
|
|
151
151
|
return (message.attemptCount ?? 0) >= CONVERSATION_WORK_MAX_DELIVERY_ATTEMPTS - 1;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
153
|
+
function normalizeActor(value) {
|
|
154
|
+
return parseStoredSlackActor(value);
|
|
155
155
|
}
|
|
156
156
|
function normalizeLease(value) {
|
|
157
157
|
if (!isRecord(value)) {
|
|
@@ -228,7 +228,7 @@ function normalizeConversation(conversationId, value) {
|
|
|
228
228
|
...destination ? { destination } : {},
|
|
229
229
|
...toOptionalString(value.title) ? { title: toOptionalString(value.title) } : {},
|
|
230
230
|
...toOptionalString(value.channelName) ? { channelName: toOptionalString(value.channelName) } : {},
|
|
231
|
-
...
|
|
231
|
+
...normalizeActor(value.actor) ? { actor: normalizeActor(value.actor) } : {},
|
|
232
232
|
...normalizeSource(value.source) ? { source: normalizeSource(value.source) } : {}
|
|
233
233
|
};
|
|
234
234
|
}
|
|
@@ -766,7 +766,7 @@ async function recordConversationActivity(args) {
|
|
|
766
766
|
...current.destination ?? args.destination ? { destination: current.destination ?? args.destination } : {},
|
|
767
767
|
...current.source ?? args.source ? { source: current.source ?? args.source } : {},
|
|
768
768
|
...current.channelName ?? args.channelName ? { channelName: current.channelName ?? args.channelName } : {},
|
|
769
|
-
...current.
|
|
769
|
+
...current.actor ?? args.actor ? { actor: current.actor ?? args.actor } : {},
|
|
770
770
|
...current.title ?? args.title ? { title: current.title ?? args.title } : {},
|
|
771
771
|
lastActivityAtMs: Math.max(current.lastActivityAtMs, activityAtMs),
|
|
772
772
|
updatedAtMs: nowMs,
|
|
@@ -803,7 +803,7 @@ async function recordConversationExecution(args) {
|
|
|
803
803
|
...current.destination ?? args.destination ? { destination: current.destination ?? args.destination } : {},
|
|
804
804
|
...current.source ?? args.source ? { source: current.source ?? args.source } : {},
|
|
805
805
|
...current.channelName ?? args.channelName ? { channelName: current.channelName ?? args.channelName } : {},
|
|
806
|
-
...current.
|
|
806
|
+
...current.actor ?? args.actor ? { actor: current.actor ?? args.actor } : {},
|
|
807
807
|
...current.title ?? args.title ? { title: current.title ?? args.title } : {},
|
|
808
808
|
createdAtMs: Math.min(current.createdAtMs, args.createdAtMs),
|
|
809
809
|
lastActivityAtMs: Math.max(
|
|
@@ -143,10 +143,12 @@ function contentMetadata(content) {
|
|
|
143
143
|
return { type: typeof part };
|
|
144
144
|
}
|
|
145
145
|
const record = part;
|
|
146
|
-
const type =
|
|
146
|
+
const type = canonicalContentPartType(
|
|
147
|
+
typeof record.type === "string" ? record.type : "unknown"
|
|
148
|
+
);
|
|
147
149
|
return {
|
|
148
150
|
type,
|
|
149
|
-
...typeof record.text === "string" ? { chars: record.text.length } : {},
|
|
151
|
+
...typeof record.text === "string" ? { chars: record.text.length } : typeof record.thinking === "string" && record.thinking.length > 0 ? { chars: record.thinking.length } : {},
|
|
150
152
|
...typeof record.mimeType === "string" ? { mimeType: record.mimeType } : {},
|
|
151
153
|
...typeof record.mediaType === "string" ? { mediaType: record.mediaType } : {},
|
|
152
154
|
...typeof record.data === "string" ? { dataChars: record.data.length } : {}
|
|
@@ -224,10 +226,14 @@ function summarizeContent(content) {
|
|
|
224
226
|
continue;
|
|
225
227
|
}
|
|
226
228
|
const record = part;
|
|
227
|
-
const type =
|
|
229
|
+
const type = canonicalContentPartType(
|
|
230
|
+
typeof record.type === "string" ? record.type : "unknown"
|
|
231
|
+
);
|
|
228
232
|
partTypes.add(type);
|
|
229
233
|
if (typeof record.text === "string") {
|
|
230
234
|
chars += record.text.length;
|
|
235
|
+
} else if (typeof record.thinking === "string") {
|
|
236
|
+
chars += record.thinking.length;
|
|
231
237
|
} else if (typeof record.data === "string") {
|
|
232
238
|
chars += record.data.length;
|
|
233
239
|
} else {
|
|
@@ -236,6 +242,56 @@ function summarizeContent(content) {
|
|
|
236
242
|
}
|
|
237
243
|
return { chars, partTypes: [...partTypes] };
|
|
238
244
|
}
|
|
245
|
+
function normalizeFinishReason(reason) {
|
|
246
|
+
return reason === "toolUse" ? "tool_use" : reason;
|
|
247
|
+
}
|
|
248
|
+
function canonicalContentPartType(type) {
|
|
249
|
+
if (type === "thinking") return "reasoning";
|
|
250
|
+
if (type === "toolCall") return "tool_call";
|
|
251
|
+
return type;
|
|
252
|
+
}
|
|
253
|
+
function toCanonicalPart(part) {
|
|
254
|
+
if (part.type === "text") {
|
|
255
|
+
return { type: "text", content: part.text };
|
|
256
|
+
}
|
|
257
|
+
if (part.type === "thinking") {
|
|
258
|
+
if (part.redacted) {
|
|
259
|
+
return { type: "reasoning", redacted: true };
|
|
260
|
+
}
|
|
261
|
+
return { type: "reasoning", content: part.thinking };
|
|
262
|
+
}
|
|
263
|
+
if (part.type === "toolCall") {
|
|
264
|
+
return {
|
|
265
|
+
type: "tool_call",
|
|
266
|
+
id: part.id,
|
|
267
|
+
name: part.name,
|
|
268
|
+
arguments: part.arguments
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return { type: "image", mimeType: part.mimeType };
|
|
272
|
+
}
|
|
273
|
+
function toCanonicalOutputMessage(message) {
|
|
274
|
+
return {
|
|
275
|
+
role: "assistant",
|
|
276
|
+
parts: message.content.map(toCanonicalPart),
|
|
277
|
+
finish_reason: normalizeFinishReason(message.stopReason)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function toCanonicalInputMessage(message) {
|
|
281
|
+
if (message.role === "user") {
|
|
282
|
+
const parts = typeof message.content === "string" ? [{ type: "text", content: message.content }] : message.content.map(toCanonicalPart);
|
|
283
|
+
return { role: "user", parts };
|
|
284
|
+
}
|
|
285
|
+
if (message.role === "toolResult") {
|
|
286
|
+
return {
|
|
287
|
+
role: "tool",
|
|
288
|
+
id: message.toolCallId,
|
|
289
|
+
name: message.toolName,
|
|
290
|
+
parts: message.content.map(toCanonicalPart)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
return toCanonicalOutputMessage(message);
|
|
294
|
+
}
|
|
239
295
|
function toGenAiMessagesTraceAttributes(prefix, messages) {
|
|
240
296
|
let contentChars = 0;
|
|
241
297
|
const roles = /* @__PURE__ */ new Set();
|
|
@@ -276,5 +332,7 @@ export {
|
|
|
276
332
|
toGenAiTextMetadata,
|
|
277
333
|
toGenAiPayloadMetadata,
|
|
278
334
|
toGenAiPayloadTraceAttributes,
|
|
335
|
+
toCanonicalOutputMessage,
|
|
336
|
+
toCanonicalInputMessage,
|
|
279
337
|
toGenAiMessagesTraceAttributes
|
|
280
338
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
3
3
|
buildConversationStatePatch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PFXC67GJ.js";
|
|
5
5
|
import {
|
|
6
6
|
abandonAgentTurnSessionRecord,
|
|
7
7
|
getAgentTurnSessionRecord,
|
|
8
8
|
upsertAgentTurnSessionRecord
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OQQU3SD6.js";
|
|
10
10
|
import {
|
|
11
11
|
getStateAdapter
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZATRYQLR.js";
|
|
13
13
|
import {
|
|
14
14
|
getPiMessageRole,
|
|
15
15
|
trimTrailingAssistantMessages
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3F54A3YM.js";
|
|
17
17
|
import {
|
|
18
18
|
getActiveTraceId,
|
|
19
19
|
logException
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-S6QKIGRM.js";
|
|
21
21
|
import {
|
|
22
22
|
isRecord,
|
|
23
23
|
toOptionalString
|
|
@@ -152,7 +152,7 @@ function logSessionRecordError(error, eventName, args, attributes, message) {
|
|
|
152
152
|
eventName,
|
|
153
153
|
{
|
|
154
154
|
slackThreadId: args.logContext.threadId,
|
|
155
|
-
slackUserId: args.logContext.
|
|
155
|
+
slackUserId: args.logContext.actorId,
|
|
156
156
|
slackChannelId: args.logContext.channelId,
|
|
157
157
|
runId: args.logContext.runId,
|
|
158
158
|
assistantUserName: args.logContext.assistantUserName,
|
|
@@ -219,9 +219,10 @@ async function persistRunningSessionRecord(args) {
|
|
|
219
219
|
sliceId: args.sliceId,
|
|
220
220
|
state: "running",
|
|
221
221
|
piMessages: args.messages,
|
|
222
|
+
...args.trailingMessageProvenance ? { trailingMessageProvenance: args.trailingMessageProvenance } : {},
|
|
222
223
|
...args.surface ?? latestSessionRecord?.surface ? { surface: args.surface ?? latestSessionRecord?.surface } : {},
|
|
223
224
|
...args.loadedSkillNames ? { loadedSkillNames: args.loadedSkillNames } : {},
|
|
224
|
-
...args.
|
|
225
|
+
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
225
226
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {},
|
|
226
227
|
...(args.turnStartMessageIndex ?? latestSessionRecord?.turnStartMessageIndex) !== void 0 ? {
|
|
227
228
|
turnStartMessageIndex: args.turnStartMessageIndex ?? latestSessionRecord?.turnStartMessageIndex
|
|
@@ -276,7 +277,7 @@ async function persistCompletedSessionRecord(args) {
|
|
|
276
277
|
...args.loadedSkillNames ?? latestSessionRecord?.loadedSkillNames ? {
|
|
277
278
|
loadedSkillNames: args.loadedSkillNames ?? latestSessionRecord?.loadedSkillNames
|
|
278
279
|
} : {},
|
|
279
|
-
...args.
|
|
280
|
+
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
280
281
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {},
|
|
281
282
|
...(args.turnStartMessageIndex ?? latestSessionRecord?.turnStartMessageIndex) !== void 0 ? {
|
|
282
283
|
turnStartMessageIndex: args.turnStartMessageIndex ?? latestSessionRecord?.turnStartMessageIndex
|
|
@@ -306,7 +307,7 @@ async function completeDeliveredTurn(args) {
|
|
|
306
307
|
allMessages: args.messages,
|
|
307
308
|
loadedSkillNames: args.loadedSkillNames,
|
|
308
309
|
logContext: args.logContext,
|
|
309
|
-
|
|
310
|
+
actor: args.actor,
|
|
310
311
|
surface: args.surface,
|
|
311
312
|
turnStartMessageIndex: args.turnStartMessageIndex
|
|
312
313
|
});
|
|
@@ -347,7 +348,7 @@ async function persistAuthPauseSessionRecord(args) {
|
|
|
347
348
|
resumeReason: "auth",
|
|
348
349
|
resumedFromSliceId: args.currentSliceId,
|
|
349
350
|
errorMessage: args.errorMessage,
|
|
350
|
-
...args.
|
|
351
|
+
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
351
352
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {}
|
|
352
353
|
});
|
|
353
354
|
} catch (recordError) {
|
|
@@ -407,7 +408,7 @@ async function persistTimeoutSessionRecord(args) {
|
|
|
407
408
|
resumeReason: "timeout",
|
|
408
409
|
resumedFromSliceId: latestSessionRecord?.resumedFromSliceId,
|
|
409
410
|
errorMessage: `Agent continuation exceeded slice limit (${AGENT_CONTINUE_MAX_SLICES})`,
|
|
410
|
-
...args.
|
|
411
|
+
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
411
412
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {}
|
|
412
413
|
});
|
|
413
414
|
}
|
|
@@ -427,7 +428,7 @@ async function persistTimeoutSessionRecord(args) {
|
|
|
427
428
|
resumeReason: "timeout",
|
|
428
429
|
resumedFromSliceId: args.currentSliceId,
|
|
429
430
|
errorMessage: args.errorMessage,
|
|
430
|
-
...args.
|
|
431
|
+
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
431
432
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {}
|
|
432
433
|
});
|
|
433
434
|
} catch (recordError) {
|
|
@@ -479,7 +480,7 @@ async function persistYieldSessionRecord(args) {
|
|
|
479
480
|
resumeReason: "yield",
|
|
480
481
|
resumedFromSliceId: latestSessionRecord?.resumedFromSliceId,
|
|
481
482
|
errorMessage: args.errorMessage,
|
|
482
|
-
...args.
|
|
483
|
+
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
483
484
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {}
|
|
484
485
|
});
|
|
485
486
|
} catch (recordError) {
|
|
@@ -869,14 +870,14 @@ function canReusePendingAuthLink(args) {
|
|
|
869
870
|
if (!pendingAuth) {
|
|
870
871
|
return false;
|
|
871
872
|
}
|
|
872
|
-
return pendingAuth.kind === args.kind && pendingAuth.provider === args.provider && pendingAuth.
|
|
873
|
+
return pendingAuth.kind === args.kind && pendingAuth.provider === args.provider && pendingAuth.actorId === args.actorId && pendingAuth.scope === args.scope && pendingAuth.sessionId === args.sessionId && pendingAuth.linkSentAtMs + AUTH_LINK_REUSE_WINDOW_MS > (args.nowMs ?? Date.now());
|
|
873
874
|
}
|
|
874
875
|
function getConversationPendingAuth(args) {
|
|
875
876
|
const pendingAuth = args.conversation.processing.pendingAuth;
|
|
876
877
|
if (!pendingAuth) {
|
|
877
878
|
return void 0;
|
|
878
879
|
}
|
|
879
|
-
if (pendingAuth.kind !== args.kind || pendingAuth.provider !== args.provider || pendingAuth.
|
|
880
|
+
if (pendingAuth.kind !== args.kind || pendingAuth.provider !== args.provider || pendingAuth.actorId !== args.actorId || pendingAuth.scope !== args.scope) {
|
|
880
881
|
return void 0;
|
|
881
882
|
}
|
|
882
883
|
return pendingAuth;
|