@sentry/junior 0.146.0 → 0.148.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-SLJADYE5.js → agent-hooks-VAUYT6PD.js} +10 -10
- package/dist/api/conversations/access.d.ts +2 -1
- package/dist/api/conversations/archive.d.ts +3 -5
- package/dist/api/conversations/create.d.ts +6 -0
- package/dist/api/conversations/detail.d.ts +2 -295
- package/dist/api/conversations/event-list.d.ts +2 -192
- package/dist/api/conversations/list.d.ts +4 -66
- package/dist/api/conversations/routes.d.ts +1 -1
- package/dist/api/conversations/stats.d.ts +0 -54
- package/dist/api/http.d.ts +2 -6
- package/dist/api/locations/detail.d.ts +3 -111
- package/dist/api/locations/list.d.ts +0 -45
- package/dist/api/locations/query.d.ts +2 -1
- package/dist/api/locations/routes.d.ts +1 -1
- package/dist/api/people/list.d.ts +0 -29
- package/dist/api/people/profile.d.ts +2 -106
- package/dist/api/people/profile.query.d.ts +2 -1
- package/dist/api/people/routes.d.ts +1 -1
- package/dist/api/people/shared.d.ts +1 -1
- package/dist/api/people/spend.d.ts +3 -4
- package/dist/api/personal-tokens/routes.d.ts +2 -2
- package/dist/api/route.d.ts +8 -14
- package/dist/api/schema/conversation.d.ts +64 -29
- package/dist/api/schema/location.d.ts +4 -0
- package/dist/api/schema/person.d.ts +7 -3
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -1
- package/dist/api/stats.d.ts +0 -13
- package/dist/api/validation.d.ts +7 -0
- package/dist/api/viewer.d.ts +3 -0
- package/dist/api.d.ts +2 -1
- package/dist/api.js +630 -564
- package/dist/app.js +369 -309
- package/dist/{catalog-runtime-RQIMSDPR.js → catalog-runtime-WADOZVTB.js} +5 -5
- package/dist/chat/actor.d.ts +4 -1
- package/dist/chat/agent/prompt.d.ts +0 -2
- package/dist/chat/agent/request.d.ts +4 -5
- package/dist/chat/agent/resume.d.ts +1 -0
- package/dist/chat/agent/sandbox.d.ts +2 -2
- package/dist/chat/agent/tools.d.ts +0 -2
- package/dist/chat/agent-dispatch/context.d.ts +2 -2
- package/dist/chat/agent-dispatch/types.d.ts +2 -2
- package/dist/chat/agent-invocations/types.d.ts +52 -0
- package/dist/chat/api-turns/work.d.ts +103 -0
- package/dist/chat/capabilities/jr-rpc-command.d.ts +2 -2
- package/dist/chat/configuration/service.d.ts +5 -2
- package/dist/chat/configuration/sql.d.ts +9 -0
- package/dist/chat/configuration/types.d.ts +17 -13
- package/dist/chat/conversations/history.d.ts +63 -0
- package/dist/chat/conversations/projection.d.ts +10 -0
- package/dist/chat/conversations/provenance.d.ts +6 -0
- package/dist/chat/conversations/sql/actor-identity.d.ts +19 -0
- package/dist/chat/conversations/store.d.ts +1 -1
- package/dist/chat/credentials/unlink-provider.d.ts +2 -1
- package/dist/chat/credentials/user-token-store.d.ts +2 -0
- package/dist/chat/event-tasks/tool-support.d.ts +2 -0
- package/dist/chat/identities/sql.d.ts +8 -0
- package/dist/chat/logging.d.ts +2 -0
- package/dist/chat/mcp/auth-store.d.ts +0 -2
- package/dist/chat/mcp/oauth.d.ts +0 -2
- package/dist/chat/oauth-flow.d.ts +3 -1
- package/dist/chat/pi/client.d.ts +2 -0
- package/dist/chat/plugins/credential-hooks.d.ts +2 -0
- package/dist/chat/prompt.d.ts +0 -2
- package/dist/chat/resource-events/notification.d.ts +2 -1
- package/dist/chat/resource-events/store.d.ts +1 -1
- package/dist/chat/runtime/delivered-turn-state.d.ts +1 -4
- package/dist/chat/runtime/reply-executor.d.ts +1 -1
- package/dist/chat/runtime/slack-runtime.d.ts +2 -1
- package/dist/chat/runtime/thread-state.d.ts +8 -11
- package/dist/chat/runtime/turn-input.d.ts +4 -2
- package/dist/chat/runtime/turn-preparation.d.ts +11 -4
- package/dist/chat/sandbox/command-result.d.ts +2 -0
- package/dist/chat/sandbox/egress/schemas.d.ts +6 -0
- package/dist/chat/scheduled-tasks/tool-support.d.ts +7 -5
- package/dist/chat/scheduled-tasks/tools/create.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/list.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/update.d.ts +4 -2
- package/dist/chat/services/mcp-auth-orchestration.d.ts +0 -3
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
- package/dist/chat/services/provider-default-config.d.ts +2 -2
- package/dist/chat/services/subscribed-decision.d.ts +3 -0
- package/dist/chat/services/subscribed-reply-policy.d.ts +1 -0
- package/dist/chat/services/turn-result.d.ts +0 -3
- package/dist/chat/services/turn-router.d.ts +3 -0
- package/dist/chat/slack/assistant-thread/lifecycle.d.ts +0 -1
- package/dist/chat/slack/assistant-thread/title.d.ts +0 -3
- package/dist/chat/slack/channel.d.ts +26 -0
- package/dist/chat/slack/dispatch-turn.d.ts +2 -1
- package/dist/chat/slack/timestamp-param.d.ts +0 -2
- package/dist/chat/slack/{tools → tool-support}/canvas/api.d.ts +1 -1
- package/dist/chat/slack/tool-support/canvas/context.d.ts +11 -0
- package/dist/chat/slack/tool-support/channel-access.d.ts +42 -0
- package/dist/chat/slack/tool-support/channel-target.d.ts +27 -0
- package/dist/chat/slack/{tools → tool-support}/list/api.d.ts +8 -1
- package/dist/chat/slack/tool-support/list/params.d.ts +5 -0
- package/dist/chat/slack/tools/canvas/create.d.ts +3 -1
- package/dist/chat/slack/tools/canvas/edit.d.ts +2 -0
- package/dist/chat/slack/tools/canvas/read.d.ts +2 -0
- package/dist/chat/slack/tools/canvas/write.d.ts +2 -0
- package/dist/chat/slack/tools/{user-lookup.d.ts → channel-join.d.ts} +6 -5
- package/dist/chat/slack/tools/channel-list-messages.d.ts +5 -2
- package/dist/chat/slack/tools/conversation-message-search.d.ts +4 -8
- package/dist/chat/slack/tools/list/add-items.d.ts +4 -1
- package/dist/chat/slack/tools/list/create.d.ts +2 -0
- package/dist/chat/slack/tools/list/get-items.d.ts +5 -3
- package/dist/chat/slack/tools/list/update-item.d.ts +5 -1
- package/dist/chat/slack/tools/message-add-reaction.d.ts +3 -1
- package/dist/chat/slack/tools/public-search.d.ts +65 -2
- package/dist/chat/slack/tools/send-files.d.ts +3 -1
- package/dist/chat/slack/tools/thread-read.d.ts +4 -5
- package/dist/chat/slack/vision-cache.d.ts +5 -0
- package/dist/chat/source.d.ts +2 -0
- package/dist/chat/state/conversation.d.ts +4 -5
- package/dist/chat/task-execution/checkpoint.d.ts +1 -0
- package/dist/chat/task-execution/state.d.ts +9 -4
- package/dist/chat/task-execution/store.d.ts +3 -2
- package/dist/chat/task-execution/turn-cursor.d.ts +2 -0
- package/dist/chat/task-execution/worker.d.ts +2 -0
- package/dist/chat/tasks/read.d.ts +1 -1
- package/dist/chat/tool-support/structured-result.d.ts +1 -0
- package/dist/chat/tool-support/timed-out-tool-result.d.ts +11 -0
- package/dist/chat/tools/create-event-task.d.ts +2 -0
- package/dist/chat/tools/delete-event-task.d.ts +2 -0
- package/dist/chat/tools/handoff/tool.d.ts +2 -0
- package/dist/chat/tools/list-event-tasks.d.ts +2 -0
- package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
- package/dist/chat/tools/runtime/report-progress.d.ts +2 -0
- package/dist/chat/tools/runtime/spawn-agent.d.ts +2 -0
- package/dist/chat/tools/search-conversation-events.d.ts +3 -1
- package/dist/chat/tools/search-resource-event-types.d.ts +2 -0
- package/dist/chat/tools/search-tools.d.ts +2 -0
- package/dist/chat/tools/skill/load-skill.d.ts +2 -0
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +2 -0
- package/dist/chat/tools/stop-watching-resources.d.ts +2 -0
- package/dist/chat/tools/system-time.d.ts +2 -0
- package/dist/chat/tools/types.d.ts +11 -10
- package/dist/chat/tools/update-event-task.d.ts +2 -0
- package/dist/chat/tools/user-lookup.d.ts +29 -0
- package/dist/chat/tools/watch-resource-events.d.ts +4 -2
- package/dist/chat/tools/web/fetch-tool.d.ts +2 -0
- package/dist/chat/tools/web/image-generate.d.ts +2 -0
- package/dist/chat/tools/web/search.d.ts +2 -0
- package/dist/{chunk-GYEKOX7N.js → chunk-2B3PT3V2.js} +1 -1
- package/dist/{chunk-JLMVCNXL.js → chunk-45LOR4PU.js} +22 -4
- package/dist/{chunk-FGHADGIC.js → chunk-4AQZYNHM.js} +2 -2
- package/dist/{chunk-W65V465O.js → chunk-4EA2SFK2.js} +66 -4
- package/dist/{chunk-MKRIZ4VG.js → chunk-4GXJUYJV.js} +4 -2
- package/dist/{chunk-F7REGDKO.js → chunk-55F4QU2V.js} +2 -1
- package/dist/{chunk-M6ZWP4RI.js → chunk-7OEIXFC3.js} +2 -2
- package/dist/{chunk-MCFIXAV5.js → chunk-D3WPMGEX.js} +55 -37
- package/dist/{chunk-AISNSNDV.js → chunk-D6YX4NNN.js} +22 -10
- package/dist/chunk-DUY5CDAM.js +36 -0
- package/dist/{chunk-B63BF443.js → chunk-EAI67NTM.js} +9 -1
- package/dist/{chunk-FEKQHPVA.js → chunk-EINWQFXI.js} +9 -8
- package/dist/chunk-GDFF3BQG.js +136 -0
- package/dist/{chunk-X22KCSCO.js → chunk-GXYDVZKM.js} +7 -5
- package/dist/{chunk-X2WMBTS3.js → chunk-HLPLT3NY.js} +8 -5
- package/dist/{chunk-PB222GIA.js → chunk-HWQGBIH7.js} +1 -1
- package/dist/chunk-IL4EDBMV.js +566 -0
- package/dist/{chunk-HQE6EJS5.js → chunk-LAZGHEYU.js} +1 -1
- package/dist/{chunk-QG7OOKIN.js → chunk-LE5H7LMT.js} +1 -1
- package/dist/chunk-LNVEIJ2L.js +48 -0
- package/dist/{chunk-JUA6VU2Z.js → chunk-OJCP3C3J.js} +12 -23
- package/dist/{chunk-37JJDS4H.js → chunk-POSZWRGL.js} +1 -1
- package/dist/{chunk-TCEJ7XXM.js → chunk-QOWHHM3F.js} +1 -1
- package/dist/{chunk-H6U2U3EP.js → chunk-RRJV5UR5.js} +304 -65
- package/dist/{chunk-OFPYOC3M.js → chunk-ULAU5ZGU.js} +127 -120
- package/dist/{chunk-V6SRLKUB.js → chunk-V2FXMOEA.js} +2 -2
- package/dist/{chunk-GDQEU4I7.js → chunk-VCYSOXON.js} +296 -526
- package/dist/{chunk-BLETMLRX.js → chunk-VMNRXKAH.js} +1374 -989
- package/dist/{chunk-37EVZP66.js → chunk-VRHTNBA6.js} +167 -92
- package/dist/{chunk-FXDDDSPL.js → chunk-VY6W3T43.js} +4 -4
- package/dist/{chunk-ZDGHGY74.js → chunk-WCN4YSH7.js} +13 -6
- package/dist/{chunk-PH4Q3A6W.js → chunk-WOONT5ZP.js} +1 -1
- package/dist/{chunk-47OSH2ZO.js → chunk-XJ42NBP5.js} +395 -206
- package/dist/{chunk-SCGVWUZX.js → chunk-ZCHIC2GM.js} +92 -75
- package/dist/chunk-ZPL2RR7F.js +798 -0
- package/dist/cli/chat.js +33 -35
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/agent-invocations.d.ts +20 -0
- package/dist/db/schema/conversation-annotations.d.ts +2 -2
- package/dist/db/schema/location-configurations.d.ts +127 -0
- package/dist/db/schema.d.ts +150 -3
- package/dist/{db-WWOMXWTT.js → db-XUKZRFFK.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-A6ZZX74U.js → oauth-callback-server-LPZMMGFI.js} +25 -26
- package/dist/{runner-KSGB2UAV.js → runner-DGKUTMPX.js} +22 -41
- package/dist/{skills-26QPWKVS.js → skills-P7YUFSXM.js} +6 -6
- package/dist/spawn-DSK3ZEVD.js +38 -0
- package/dist/{validation-OPSRGFGH.js → validation-S7U5M5NR.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-VMSW7STJ.js → work-GAA7TVAD.js} +18 -19
- package/dist/{worker-2JNFB7C7.js → worker-JXPJH3QB.js} +11 -10
- package/migrations/0024_misty_typhoid_mary.sql +12 -0
- package/migrations/meta/0024_snapshot.json +2275 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -5
- package/dist/api/health.d.ts +0 -7
- package/dist/api/personal-tokens/create.d.ts +0 -11
- package/dist/api/personal-tokens/list.d.ts +0 -12
- package/dist/api/personal-tokens/revoke.d.ts +0 -5
- package/dist/api/plugin-reports.d.ts +0 -63
- package/dist/api/plugins.d.ts +0 -8
- package/dist/api/runtime.d.ts +0 -24
- package/dist/api/skills.d.ts +0 -6
- package/dist/chat/slack/tools/canvas/context.d.ts +0 -18
- package/dist/chat/slack/tools/channel-access.d.ts +0 -30
- package/dist/chat/state/artifacts.d.ts +0 -30
- package/dist/chat/tool-support/turn-deadline-result.d.ts +0 -3
- package/dist/chunk-HLXXQI5Q.js +0 -238
- package/dist/chunk-LVW7BLLT.js +0 -115
- package/dist/chunk-Q6QZTTLS.js +0 -55
- package/dist/chunk-QSXZ42KX.js +0 -285
- package/dist/chunk-R776HKPK.js +0 -81
- package/dist/chunk-T5GXFFLA.js +0 -67
- package/dist/spawn-5LAJXZ2P.js +0 -39
- /package/dist/chat/slack/{tools → tool-support}/canvas/markdown.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/channel-capabilities.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/context.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
juniorConversations,
|
|
6
6
|
juniorIdentities,
|
|
7
7
|
juniorUsers
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-D3WPMGEX.js";
|
|
9
9
|
import {
|
|
10
10
|
TURN_REASONING_LEVELS,
|
|
11
11
|
getChatConfig,
|
|
12
12
|
modelProfileSchema
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4GXJUYJV.js";
|
|
14
14
|
import {
|
|
15
15
|
juniorDestinations
|
|
16
16
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "./chunk-F3B2YJ76.js";
|
|
21
21
|
import {
|
|
22
22
|
normalizeIdentityEmail
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-EAI67NTM.js";
|
|
24
24
|
|
|
25
25
|
// src/chat/conversations/sql/store.ts
|
|
26
26
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -104,7 +104,7 @@ async function existingIdentity(executor, identity) {
|
|
|
104
104
|
);
|
|
105
105
|
return rows[0];
|
|
106
106
|
}
|
|
107
|
-
async function
|
|
107
|
+
async function upsertIdentityRecord(executor, identity, linkedUserId, nowMs) {
|
|
108
108
|
const emailNormalized = normalizeIdentityEmail(identity.email);
|
|
109
109
|
const email = emailNormalized ? identity.email?.trim() || emailNormalized : void 0;
|
|
110
110
|
const existing = await existingIdentity(executor, identity);
|
|
@@ -119,7 +119,13 @@ async function upsertIdentity(executor, identity, nowMs = Date.now()) {
|
|
|
119
119
|
if (existing?.userId && verifiedUserId && existing.userId !== verifiedUserId) {
|
|
120
120
|
throw new Error("Identity verified email conflicts with linked user");
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
if (linkedUserId && verifiedUserId && linkedUserId !== verifiedUserId) {
|
|
123
|
+
throw new Error("Linked identity conflicts with verified email user");
|
|
124
|
+
}
|
|
125
|
+
if (existing?.userId && linkedUserId && existing.userId !== linkedUserId) {
|
|
126
|
+
throw new Error("Identity conflicts with linked user");
|
|
127
|
+
}
|
|
128
|
+
const userId = existing?.userId ?? linkedUserId ?? verifiedUserId;
|
|
123
129
|
const rows = await executor.db().insert(juniorIdentities).values({
|
|
124
130
|
id: randomUUID(),
|
|
125
131
|
userId: userId ?? null,
|
|
@@ -145,21 +151,27 @@ async function upsertIdentity(executor, identity, nowMs = Date.now()) {
|
|
|
145
151
|
set: {
|
|
146
152
|
kind: sql`excluded.kind`,
|
|
147
153
|
userId: sql`coalesce(${juniorIdentities.userId}, excluded.user_id)`,
|
|
148
|
-
displayName: sql`coalesce(${juniorIdentities.displayName}, excluded.display_name)`,
|
|
149
|
-
handle: sql`coalesce(${juniorIdentities.handle}, excluded.handle)`,
|
|
154
|
+
displayName: linkedUserId ? sql`coalesce(excluded.display_name, ${juniorIdentities.displayName})` : sql`coalesce(${juniorIdentities.displayName}, excluded.display_name)`,
|
|
155
|
+
handle: linkedUserId ? sql`coalesce(excluded.handle, ${juniorIdentities.handle})` : sql`coalesce(${juniorIdentities.handle}, excluded.handle)`,
|
|
150
156
|
email: sql`case when ${juniorIdentities.emailVerified} then coalesce(${juniorIdentities.email}, excluded.email) when excluded.email_verified then excluded.email else coalesce(${juniorIdentities.email}, excluded.email) end`,
|
|
151
157
|
emailNormalized: sql`case when ${juniorIdentities.emailVerified} then coalesce(${juniorIdentities.emailNormalized}, excluded.email_normalized) when excluded.email_verified then excluded.email_normalized else coalesce(${juniorIdentities.emailNormalized}, excluded.email_normalized) end`,
|
|
152
158
|
emailVerified: sql`${juniorIdentities.emailVerified} OR excluded.email_verified`,
|
|
153
159
|
avatarUrl: sql`coalesce(${juniorIdentities.avatarUrl}, excluded.avatar_url)`,
|
|
154
160
|
metadata: sql`coalesce(${juniorIdentities.metadata}, excluded.metadata_json)`,
|
|
155
161
|
updatedAt: sql`excluded.updated_at`
|
|
156
|
-
}
|
|
162
|
+
},
|
|
163
|
+
...linkedUserId ? {
|
|
164
|
+
setWhere: sql`${juniorIdentities.userId} IS NULL OR ${juniorIdentities.userId} = excluded.user_id`
|
|
165
|
+
} : {}
|
|
157
166
|
}).returning({
|
|
158
167
|
id: juniorIdentities.id,
|
|
159
168
|
userId: juniorIdentities.userId
|
|
160
169
|
});
|
|
161
170
|
const row = rows[0];
|
|
162
171
|
if (!row) {
|
|
172
|
+
if (linkedUserId) {
|
|
173
|
+
throw new Error("Identity conflicts with linked user");
|
|
174
|
+
}
|
|
163
175
|
throw new Error("Identity upsert returned no row");
|
|
164
176
|
}
|
|
165
177
|
return {
|
|
@@ -167,6 +179,32 @@ async function upsertIdentity(executor, identity, nowMs = Date.now()) {
|
|
|
167
179
|
...row.userId ? { userId: row.userId } : {}
|
|
168
180
|
};
|
|
169
181
|
}
|
|
182
|
+
async function upsertIdentity(executor, identity, nowMs = Date.now()) {
|
|
183
|
+
return await upsertIdentityRecord(executor, identity, void 0, nowMs);
|
|
184
|
+
}
|
|
185
|
+
async function upsertLinkedIdentity(executor, userId, identity, nowMs = Date.now()) {
|
|
186
|
+
return await upsertIdentityRecord(executor, identity, userId, nowMs);
|
|
187
|
+
}
|
|
188
|
+
async function deleteProviderIdentityForSlackUser(executor, slackTeamId, slackUserId, provider, providerSubjectId) {
|
|
189
|
+
const slackRows = await executor.db().select({ userId: juniorIdentities.userId }).from(juniorIdentities).where(
|
|
190
|
+
and(
|
|
191
|
+
eq(juniorIdentities.kind, "user"),
|
|
192
|
+
eq(juniorIdentities.provider, "slack"),
|
|
193
|
+
eq(juniorIdentities.providerTenantId, slackTeamId),
|
|
194
|
+
eq(juniorIdentities.providerSubjectId, slackUserId)
|
|
195
|
+
)
|
|
196
|
+
).limit(1);
|
|
197
|
+
const userId = slackRows[0]?.userId;
|
|
198
|
+
if (!userId) return;
|
|
199
|
+
await executor.db().delete(juniorIdentities).where(
|
|
200
|
+
and(
|
|
201
|
+
eq(juniorIdentities.userId, userId),
|
|
202
|
+
eq(juniorIdentities.provider, provider),
|
|
203
|
+
eq(juniorIdentities.providerTenantId, ""),
|
|
204
|
+
eq(juniorIdentities.providerSubjectId, providerSubjectId)
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
170
208
|
|
|
171
209
|
// src/chat/source.ts
|
|
172
210
|
import { sourceSchema } from "@sentry/junior-plugin-api";
|
|
@@ -177,7 +215,14 @@ function normalizeSessionSource(value) {
|
|
|
177
215
|
if (value.platform === "local") {
|
|
178
216
|
return {
|
|
179
217
|
platform: "local",
|
|
180
|
-
visibility:
|
|
218
|
+
visibility: value.visibility,
|
|
219
|
+
conversationId: value.conversationId
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (value.platform === "web") {
|
|
223
|
+
return {
|
|
224
|
+
platform: "web",
|
|
225
|
+
visibility: value.visibility,
|
|
181
226
|
conversationId: value.conversationId
|
|
182
227
|
};
|
|
183
228
|
}
|
|
@@ -224,6 +269,109 @@ async function bindProviderConversation(executor, args) {
|
|
|
224
269
|
}
|
|
225
270
|
}
|
|
226
271
|
|
|
272
|
+
// src/chat/conversations/sql/actor-identity.ts
|
|
273
|
+
function identityFromActor(actor) {
|
|
274
|
+
if (actor?.slackUserId) {
|
|
275
|
+
return {
|
|
276
|
+
kind: "user",
|
|
277
|
+
provider: "slack",
|
|
278
|
+
providerTenantId: actor.teamId,
|
|
279
|
+
providerSubjectId: actor.slackUserId,
|
|
280
|
+
...actor.fullName ? { displayName: actor.fullName } : {},
|
|
281
|
+
...actor.slackUserName ? { handle: actor.slackUserName } : {},
|
|
282
|
+
...actor.email ? { email: actor.email, emailVerified: true } : {},
|
|
283
|
+
metadata: { platform: "slack" }
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
const email = actor?.email?.trim().toLowerCase();
|
|
287
|
+
if (!email) {
|
|
288
|
+
return void 0;
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
kind: "user",
|
|
292
|
+
provider: "junior",
|
|
293
|
+
providerSubjectId: email,
|
|
294
|
+
email,
|
|
295
|
+
emailVerified: true,
|
|
296
|
+
...actor?.fullName ? { displayName: actor.fullName } : {},
|
|
297
|
+
metadata: { platform: "web" }
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function systemIdentityFromSource(source) {
|
|
301
|
+
if (source === "scheduler") {
|
|
302
|
+
return {
|
|
303
|
+
kind: "system",
|
|
304
|
+
provider: "junior",
|
|
305
|
+
providerSubjectId: "scheduler",
|
|
306
|
+
displayName: "Junior Scheduler"
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (source === "local") {
|
|
310
|
+
return {
|
|
311
|
+
kind: "system",
|
|
312
|
+
provider: "junior",
|
|
313
|
+
providerSubjectId: "local-cli",
|
|
314
|
+
displayName: "Local CLI"
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (source === "resource_event") {
|
|
318
|
+
return {
|
|
319
|
+
kind: "system",
|
|
320
|
+
provider: "junior",
|
|
321
|
+
providerSubjectId: "resource-event",
|
|
322
|
+
displayName: "Resource Event"
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
return void 0;
|
|
326
|
+
}
|
|
327
|
+
function actorIdentityForConversation(conversation) {
|
|
328
|
+
return identityFromActor(conversation.actor) ?? systemIdentityFromSource(conversation.source);
|
|
329
|
+
}
|
|
330
|
+
function actorFromIdentityRow(identity, userDisplayName) {
|
|
331
|
+
if (!identity) {
|
|
332
|
+
return void 0;
|
|
333
|
+
}
|
|
334
|
+
const fullName = userDisplayName?.trim() ? userDisplayName : identity.displayName;
|
|
335
|
+
const email = identity.emailNormalized ?? identity.email ?? void 0;
|
|
336
|
+
if (identity.provider === "slack") {
|
|
337
|
+
return {
|
|
338
|
+
...email ? { email } : {},
|
|
339
|
+
...fullName ? { fullName } : {},
|
|
340
|
+
platform: "slack",
|
|
341
|
+
slackUserId: identity.providerSubjectId,
|
|
342
|
+
...identity.handle ? { slackUserName: identity.handle } : {},
|
|
343
|
+
...identity.providerTenantId ? { teamId: identity.providerTenantId } : {}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (identity.provider === "junior" && email) {
|
|
347
|
+
return {
|
|
348
|
+
email,
|
|
349
|
+
...fullName ? { fullName } : {}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
return void 0;
|
|
353
|
+
}
|
|
354
|
+
function mergeActor(current2, next) {
|
|
355
|
+
if (!current2) {
|
|
356
|
+
return next;
|
|
357
|
+
}
|
|
358
|
+
if (!next) {
|
|
359
|
+
return current2;
|
|
360
|
+
}
|
|
361
|
+
if (current2.slackUserId && next.slackUserId && current2.slackUserId !== next.slackUserId) {
|
|
362
|
+
return current2;
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
...current2,
|
|
366
|
+
...current2.email ?? next.email ? { email: current2.email ?? next.email } : {},
|
|
367
|
+
...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : {},
|
|
368
|
+
...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : {},
|
|
369
|
+
...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : {},
|
|
370
|
+
...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : {},
|
|
371
|
+
...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : {}
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
227
375
|
// src/chat/conversations/location.ts
|
|
228
376
|
import { nonBlankStringSchema } from "@sentry/junior-plugin-api";
|
|
229
377
|
import { z } from "zod";
|
|
@@ -289,56 +437,11 @@ function tenantId2(value) {
|
|
|
289
437
|
return value ?? "";
|
|
290
438
|
}
|
|
291
439
|
function sourceFromValue(value) {
|
|
292
|
-
if (value === "api" || value === "internal" || value === "local" || value === "plugin" || value === "resource_event" || value === "scheduler" || value === "slack") {
|
|
440
|
+
if (value === "api" || value === "internal" || value === "local" || value === "plugin" || value === "resource_event" || value === "scheduler" || value === "slack" || value === "web") {
|
|
293
441
|
return value;
|
|
294
442
|
}
|
|
295
443
|
return void 0;
|
|
296
444
|
}
|
|
297
|
-
function identityFromActor(actor) {
|
|
298
|
-
if (!actor?.slackUserId) {
|
|
299
|
-
return void 0;
|
|
300
|
-
}
|
|
301
|
-
return {
|
|
302
|
-
kind: "user",
|
|
303
|
-
provider: "slack",
|
|
304
|
-
providerTenantId: actor.teamId,
|
|
305
|
-
providerSubjectId: actor.slackUserId,
|
|
306
|
-
...actor.fullName ? { displayName: actor.fullName } : {},
|
|
307
|
-
...actor.slackUserName ? { handle: actor.slackUserName } : {},
|
|
308
|
-
...actor.email ? { email: actor.email, emailVerified: true } : {},
|
|
309
|
-
metadata: { platform: "slack" }
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
function systemIdentityFromSource(source) {
|
|
313
|
-
if (source === "scheduler") {
|
|
314
|
-
return {
|
|
315
|
-
kind: "system",
|
|
316
|
-
provider: "junior",
|
|
317
|
-
providerSubjectId: "scheduler",
|
|
318
|
-
displayName: "Junior Scheduler"
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
if (source === "local") {
|
|
322
|
-
return {
|
|
323
|
-
kind: "system",
|
|
324
|
-
provider: "junior",
|
|
325
|
-
providerSubjectId: "local-cli",
|
|
326
|
-
displayName: "Local CLI"
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
if (source === "resource_event") {
|
|
330
|
-
return {
|
|
331
|
-
kind: "system",
|
|
332
|
-
provider: "junior",
|
|
333
|
-
providerSubjectId: "resource-event",
|
|
334
|
-
displayName: "Resource Event"
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
return void 0;
|
|
338
|
-
}
|
|
339
|
-
function actorIdentityForConversation(conversation) {
|
|
340
|
-
return identityFromActor(conversation.actor) ?? systemIdentityFromSource(conversation.source);
|
|
341
|
-
}
|
|
342
445
|
function originTypeFromSource(source) {
|
|
343
446
|
return source;
|
|
344
447
|
}
|
|
@@ -370,8 +473,10 @@ function destinationUpsertFromDestination(args) {
|
|
|
370
473
|
provider: "local",
|
|
371
474
|
providerTenantId: localWorkspaceFromConversationId(destination.conversationId) ?? localWorkspaceFromConversationId(args.conversationId ?? ""),
|
|
372
475
|
providerDestinationId: destination.conversationId,
|
|
373
|
-
|
|
374
|
-
|
|
476
|
+
// Match Slack: only refresh when a live visibility signal is present so
|
|
477
|
+
// execution-metadata writes cannot clobber public dashboard roots.
|
|
478
|
+
refreshVisibility: args.visibility !== void 0,
|
|
479
|
+
visibility: args.visibility ?? "direct",
|
|
375
480
|
metadata: { platform: "local" }
|
|
376
481
|
};
|
|
377
482
|
}
|
|
@@ -385,20 +490,6 @@ function executionStatusFromValue(value) {
|
|
|
385
490
|
function executionStatusToSql(status) {
|
|
386
491
|
return status === "paused" ? "awaiting_resume" : status;
|
|
387
492
|
}
|
|
388
|
-
function actorFromIdentityRow(identity, userDisplayName) {
|
|
389
|
-
if (!identity || identity.provider !== "slack") {
|
|
390
|
-
return void 0;
|
|
391
|
-
}
|
|
392
|
-
const fullName = userDisplayName?.trim() ? userDisplayName : identity.displayName;
|
|
393
|
-
return {
|
|
394
|
-
...identity.emailNormalized ? { email: identity.emailNormalized } : identity.email ? { email: identity.email } : {},
|
|
395
|
-
...fullName ? { fullName } : {},
|
|
396
|
-
platform: "slack",
|
|
397
|
-
slackUserId: identity.providerSubjectId,
|
|
398
|
-
...identity.handle ? { slackUserName: identity.handle } : {},
|
|
399
|
-
...identity.providerTenantId ? { teamId: identity.providerTenantId } : {}
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
493
|
function destinationFromRow(destination) {
|
|
403
494
|
const value = destination?.provider === "slack" ? {
|
|
404
495
|
platform: "slack",
|
|
@@ -499,26 +590,6 @@ function assertSameConversationDestination(args) {
|
|
|
499
590
|
`Conversation destination changed for ${args.conversationId}`
|
|
500
591
|
);
|
|
501
592
|
}
|
|
502
|
-
function mergeActor(current2, next) {
|
|
503
|
-
if (!current2) {
|
|
504
|
-
return next;
|
|
505
|
-
}
|
|
506
|
-
if (!next) {
|
|
507
|
-
return current2;
|
|
508
|
-
}
|
|
509
|
-
if (current2.slackUserId && next.slackUserId && current2.slackUserId !== next.slackUserId) {
|
|
510
|
-
return current2;
|
|
511
|
-
}
|
|
512
|
-
return {
|
|
513
|
-
...current2,
|
|
514
|
-
...current2.email ?? next.email ? { email: current2.email ?? next.email } : {},
|
|
515
|
-
...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : {},
|
|
516
|
-
...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : {},
|
|
517
|
-
...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : {},
|
|
518
|
-
...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : {},
|
|
519
|
-
...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : {}
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
593
|
function tokenTotal(usage) {
|
|
523
594
|
if (!usage) return 0;
|
|
524
595
|
if (usage.totalTokens !== void 0) return usage.totalTokens;
|
|
@@ -826,7 +897,8 @@ var SqlStore = class {
|
|
|
826
897
|
}).onConflictDoUpdate({
|
|
827
898
|
target: juniorConversations.conversationId,
|
|
828
899
|
set: {
|
|
829
|
-
|
|
900
|
+
// Origin source is set-once so dashboard continues cannot rewrite a Slack root.
|
|
901
|
+
source: sql2`coalesce(${juniorConversations.source}, excluded.source)`,
|
|
830
902
|
sessionSource: sql2`coalesce(${juniorConversations.sessionSource}, excluded.source_json)`,
|
|
831
903
|
originType: sql2`coalesce(excluded.origin_type, ${juniorConversations.originType})`,
|
|
832
904
|
originId: sql2`coalesce(excluded.origin_id, ${juniorConversations.originId})`,
|
|
@@ -1120,6 +1192,7 @@ var turnRoutedEventDataSchema = z3.object({
|
|
|
1120
1192
|
turnId: z3.string().min(1),
|
|
1121
1193
|
modelProfile: modelProfileSchema,
|
|
1122
1194
|
modelId: z3.string().min(1),
|
|
1195
|
+
costUsd: z3.number().finite().nonnegative().optional(),
|
|
1123
1196
|
reasoningLevel: z3.enum(TURN_REASONING_LEVELS),
|
|
1124
1197
|
confidence: z3.number().min(0).max(1).optional(),
|
|
1125
1198
|
source: z3.enum(["configured", "inherited", "router"])
|
|
@@ -1742,6 +1815,8 @@ export {
|
|
|
1742
1815
|
requireSlackDestination,
|
|
1743
1816
|
sameDestination,
|
|
1744
1817
|
upsertIdentity,
|
|
1818
|
+
upsertLinkedIdentity,
|
|
1819
|
+
deleteProviderIdentityForSlackUser,
|
|
1745
1820
|
parseSessionSource,
|
|
1746
1821
|
bindProviderConversation,
|
|
1747
1822
|
locationFromRow,
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
} from "./chunk-EM225ITJ.js";
|
|
5
5
|
import {
|
|
6
6
|
getStateAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-2B3PT3V2.js";
|
|
8
8
|
import {
|
|
9
9
|
toOptionalTrimmed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4GXJUYJV.js";
|
|
11
11
|
import {
|
|
12
12
|
pluginCatalogRuntime
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-HWQGBIH7.js";
|
|
14
14
|
import {
|
|
15
15
|
setSpanAttributes,
|
|
16
16
|
setSpanStatus,
|
|
17
17
|
withSpan
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EAI67NTM.js";
|
|
19
19
|
|
|
20
20
|
// src/chat/sandbox/resources.ts
|
|
21
21
|
var configuredResources;
|
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
isDmChannel,
|
|
5
5
|
normalizeSlackConversationId,
|
|
6
6
|
withSlackRetries
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-V2FXMOEA.js";
|
|
8
8
|
import {
|
|
9
9
|
parseDestination
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VRHTNBA6.js";
|
|
11
11
|
import {
|
|
12
12
|
getStateAdapter
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2B3PT3V2.js";
|
|
14
14
|
import {
|
|
15
15
|
normalizeSlackEmojiName
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-4GXJUYJV.js";
|
|
17
17
|
import {
|
|
18
18
|
pluginCatalogRuntime
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HWQGBIH7.js";
|
|
20
20
|
import {
|
|
21
21
|
parseSlackMessageTs,
|
|
22
22
|
parseSlackUserId
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isRecord,
|
|
26
26
|
logInfo,
|
|
27
27
|
logWarn
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-EAI67NTM.js";
|
|
29
29
|
|
|
30
30
|
// src/chat/slack/outbound.ts
|
|
31
31
|
var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
|
|
@@ -289,6 +289,7 @@ async function removeReactionFromMessage(input) {
|
|
|
289
289
|
// src/chat/oauth-flow.ts
|
|
290
290
|
import { randomBytes } from "crypto";
|
|
291
291
|
import {
|
|
292
|
+
actorSchema,
|
|
292
293
|
sourceSchema
|
|
293
294
|
} from "@sentry/junior-plugin-api";
|
|
294
295
|
|
|
@@ -517,6 +518,10 @@ function parseOAuthStatePayload(value) {
|
|
|
517
518
|
if (typeof value.userId !== "string" || typeof value.provider !== "string") {
|
|
518
519
|
return void 0;
|
|
519
520
|
}
|
|
521
|
+
const actor = value.actor === void 0 ? void 0 : actorSchema.safeParse(value.actor);
|
|
522
|
+
if (value.actor !== void 0 && (!actor || !actor.success)) {
|
|
523
|
+
return void 0;
|
|
524
|
+
}
|
|
520
525
|
const destination = parseDestination(value.destination);
|
|
521
526
|
if (value.destination !== void 0 && !destination) {
|
|
522
527
|
return void 0;
|
|
@@ -528,6 +533,7 @@ function parseOAuthStatePayload(value) {
|
|
|
528
533
|
return {
|
|
529
534
|
userId: value.userId,
|
|
530
535
|
provider: value.provider,
|
|
536
|
+
...actor?.success ? { actor: actor.data } : {},
|
|
531
537
|
...optionalString(value.channelId) ? { channelId: optionalString(value.channelId) } : {},
|
|
532
538
|
...destination ? { destination } : {},
|
|
533
539
|
...source?.success ? { source: source.data } : {},
|
|
@@ -650,6 +656,7 @@ async function startOAuthFlow(provider, input) {
|
|
|
650
656
|
{
|
|
651
657
|
userId: input.actorId,
|
|
652
658
|
provider,
|
|
659
|
+
...input.actor ? { actor: input.actor } : {},
|
|
653
660
|
...input.channelId ? { channelId: input.channelId } : {},
|
|
654
661
|
...input.destination ? { destination: input.destination } : {},
|
|
655
662
|
...input.source ? { source: input.source } : {},
|