@sentry/junior 0.147.0 → 0.149.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-HS6VGUPM.js → agent-hooks-CWMCXAMT.js} +10 -10
- package/dist/api/conversations/access.d.ts +2 -1
- package/dist/api/conversations/aggregate.d.ts +2 -0
- 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 -296
- package/dist/api/conversations/event-list.d.ts +2 -193
- package/dist/api/conversations/list.d.ts +4 -66
- package/dist/api/conversations/pending-messages.d.ts +15 -0
- 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 +3 -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 +130 -25
- 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 +13 -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 +772 -561
- package/dist/app.js +241 -204
- package/dist/{catalog-runtime-M6ZTPYRV.js → catalog-runtime-GAW5APVI.js} +5 -5
- package/dist/chat/actor.d.ts +4 -1
- package/dist/chat/agent/request.d.ts +2 -0
- package/dist/chat/agent/resume.d.ts +1 -0
- package/dist/chat/agent-dispatch/context.d.ts +2 -2
- package/dist/chat/agent-invocations/types.d.ts +52 -0
- package/dist/chat/api-turns/work.d.ts +108 -0
- package/dist/chat/app/services.d.ts +1 -1
- package/dist/chat/conversations/history.d.ts +60 -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/resource-events/store.d.ts +1 -1
- package/dist/chat/runtime/reply-executor.d.ts +1 -3
- package/dist/chat/runtime/slack-runtime.d.ts +2 -1
- package/dist/chat/runtime/turn-preparation.d.ts +9 -0
- package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
- package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
- package/dist/chat/services/conversation-memory.d.ts +2 -2
- package/dist/chat/services/conversation-title.d.ts +20 -0
- package/dist/chat/slack/assistant-thread/title.d.ts +10 -27
- package/dist/chat/slack/channel.d.ts +26 -0
- package/dist/chat/slack/dispatch-turn.d.ts +1 -0
- 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/{tools → tool-support}/canvas/context.d.ts +3 -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/tool-support/list/params.d.ts +5 -0
- package/dist/chat/slack/tools/canvas/create.d.ts +1 -1
- package/dist/chat/slack/tools/channel-join.d.ts +28 -0
- package/dist/chat/slack/tools/channel-list-messages.d.ts +3 -2
- package/dist/chat/slack/tools/conversation-message-search.d.ts +2 -8
- package/dist/chat/slack/tools/message-add-reaction.d.ts +1 -1
- package/dist/chat/slack/tools/public-search.d.ts +63 -2
- package/dist/chat/slack/tools/send-files.d.ts +1 -1
- package/dist/chat/slack/tools/thread-read.d.ts +2 -5
- package/dist/chat/source.d.ts +2 -0
- package/dist/chat/state/conversation.d.ts +1 -0
- 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/tools/search-conversation-events.d.ts +1 -1
- package/dist/chat/tools/types.d.ts +11 -4
- package/dist/chat/tools/watch-resource-events.d.ts +2 -2
- package/dist/{chunk-ORO3PWKQ.js → chunk-25SC7D6Z.js} +1 -1
- package/dist/{chunk-GGB4WL5A.js → chunk-2JHKISQA.js} +1 -1
- package/dist/{chunk-AVZDSUFB.js → chunk-2P6BQQER.js} +4 -4
- package/dist/{chunk-7NVJVJID.js → chunk-32CXPIZE.js} +2 -2
- package/dist/{chunk-YSB2N563.js → chunk-3GYZ5YEH.js} +121 -87
- package/dist/{chunk-DU74WPIC.js → chunk-3I2IVWSZ.js} +1 -1
- package/dist/{chunk-SVHUEHUL.js → chunk-3JVUWLR7.js} +65 -4
- package/dist/{chunk-RXBVB2JM.js → chunk-3KGQOKIG.js} +1 -1
- package/dist/{chunk-YBVXBNSV.js → chunk-4JGM7FXO.js} +2 -2
- package/dist/{chunk-AZ7EAOBE.js → chunk-4YKPOYRV.js} +5 -5
- package/dist/chunk-5CWUQXXT.js +806 -0
- package/dist/{chunk-DLDRQHG5.js → chunk-6G5RCDKP.js} +1 -1
- package/dist/{chunk-AYU72WO7.js → chunk-75DSYFFB.js} +47 -70
- package/dist/{chunk-YHDERDRO.js → chunk-7BH46NB4.js} +91 -75
- package/dist/{chunk-745QJ3ZA.js → chunk-ALJG73MQ.js} +2 -2
- package/dist/chunk-ART7P442.js +48 -0
- package/dist/{chunk-7A4M7PCV.js → chunk-DK5UT6PQ.js} +1180 -556
- package/dist/{chunk-AIOK6LAG.js → chunk-EW2LNCRL.js} +813 -44
- package/dist/chunk-EXW76GW4.js +36 -0
- package/dist/chunk-GDFF3BQG.js +136 -0
- package/dist/{chunk-7UQIVT6G.js → chunk-JMH3DBM5.js} +6 -6
- package/dist/{chunk-CWP5RHVX.js → chunk-JMSMXXED.js} +12 -5
- package/dist/{chunk-CSZINQJ2.js → chunk-MEMURSBG.js} +1 -1
- package/dist/{chunk-YNTTROJT.js → chunk-QIW7OQEO.js} +1 -1
- package/dist/{chunk-Q4R73I43.js → chunk-RB26T3LU.js} +58 -28
- package/dist/{chunk-4LJO56OJ.js → chunk-RLVZIWNQ.js} +1 -1
- package/dist/{chunk-SGZO7UWH.js → chunk-SWHPVZBV.js} +2 -2
- package/dist/{chunk-PVNG6UMU.js → chunk-TFBNBXPU.js} +22 -10
- package/dist/{chunk-EFLJ2WJH.js → chunk-URDCZAL4.js} +5 -5
- package/dist/{chunk-6H5SZR24.js → chunk-UZGASGOD.js} +300 -383
- package/dist/{chunk-YEO3VX72.js → chunk-W7UONUIZ.js} +8 -6
- package/dist/{chunk-JUUKWRBE.js → chunk-X22XXSZA.js} +1 -1
- package/dist/{chunk-X5UY34KT.js → chunk-XPYWWMHR.js} +8 -8
- package/dist/{chunk-IIOOO4FQ.js → chunk-ZYMYLLWG.js} +2 -1
- package/dist/cli/chat.js +32 -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.d.ts +22 -2
- package/dist/{db-CSEW4RII.js → db-JBZLRIVY.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-FUEV5HNG.js → oauth-callback-server-MNTVYY2I.js} +24 -26
- package/dist/{runner-U3XHSKSH.js → runner-K24BWZSZ.js} +23 -25
- package/dist/{skills-AKE6W3WI.js → skills-AU5ST2CG.js} +6 -6
- package/dist/spawn-6PO7CVJ6.js +38 -0
- package/dist/{validation-WDTAULUF.js → validation-IXGZCFRO.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-C3HAO2BG.js → work-WCZIYILX.js} +18 -19
- package/dist/{worker-LNP4YKBM.js → worker-U2AACBEY.js} +11 -10
- 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/channel-access.d.ts +0 -30
- package/dist/chunk-34GS7B6L.js +0 -115
- package/dist/chunk-AVOCH2Z5.js +0 -285
- package/dist/chunk-HLXXQI5Q.js +0 -238
- package/dist/chunk-K4SZAP3K.js +0 -67
- package/dist/chunk-R776HKPK.js +0 -81
- package/dist/chunk-Z4YU7Z4L.js +0 -76
- package/dist/spawn-B6GDTWJ4.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}/list/api.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { FileUpload } from "chat";
|
|
2
|
-
import type { Destination, Identity, LocalDestination, LocalSource, PluginEgress, SlackDestination, SlackSource, Source, User } from "@sentry/junior-plugin-api";
|
|
2
|
+
import type { WebSource, Destination, Identity, LocalDestination, LocalSource, PluginEgress, SlackDestination, SlackSource, Source, User } from "@sentry/junior-plugin-api";
|
|
3
3
|
import type { McpToolManager } from "@/chat/mcp/tool-manager";
|
|
4
4
|
import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
|
|
5
5
|
import type { AgentTurnSurface } from "@/chat/task-execution/checkpoint";
|
|
6
6
|
import type { Skill } from "@/chat/skills";
|
|
7
7
|
import type { LoadSkillMetadata } from "@/chat/tools/skill/load-skill";
|
|
8
8
|
import type { JuniorToolOutput } from "@/chat/tool-support/structured-result";
|
|
9
|
-
import type { LocalActor, Actor, SlackActor } from "@/chat/actor";
|
|
9
|
+
import type { WebActor, LocalActor, Actor, SlackActor } from "@/chat/actor";
|
|
10
10
|
import type { SlackActionToken } from "@/chat/slack/action-token";
|
|
11
11
|
import type { ModelProfile } from "@/chat/model-profile";
|
|
12
12
|
import type { GeneratedArtifactFileRef } from "@/chat/tools/sandbox/file-uploads";
|
|
@@ -58,7 +58,7 @@ interface BaseToolRuntimeContext {
|
|
|
58
58
|
/**
|
|
59
59
|
* Opaque Junior conversation/session identity for this turn.
|
|
60
60
|
* Interactive Slack turns use `slack:{channelId}:{threadTs}`.
|
|
61
|
-
* Scheduled/
|
|
61
|
+
* Scheduled/web turns use an internal id such as `agent-dispatch:{id}`.
|
|
62
62
|
* Do not parse as Slack unless the value starts with `slack:`.
|
|
63
63
|
*/
|
|
64
64
|
conversationId?: string;
|
|
@@ -94,7 +94,14 @@ interface LocalToolRuntimeContext extends BaseToolRuntimeContext {
|
|
|
94
94
|
slack?: never;
|
|
95
95
|
slackActionToken?: never;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
interface WebToolRuntimeContext extends BaseToolRuntimeContext {
|
|
98
|
+
destination: Destination;
|
|
99
|
+
actor?: WebActor;
|
|
100
|
+
source: WebSource;
|
|
101
|
+
slack?: never;
|
|
102
|
+
slackActionToken?: never;
|
|
103
|
+
}
|
|
104
|
+
export type ToolRuntimeContext = LocalToolRuntimeContext | SlackToolRuntimeContext | WebToolRuntimeContext;
|
|
98
105
|
export interface ToolState {
|
|
99
106
|
getOperationResult: <T>(operationKey: string) => T | undefined;
|
|
100
107
|
setOperationResult: (operationKey: string, result: unknown) => void;
|
|
@@ -15,7 +15,7 @@ export declare function createWatchResourceEventsTool(context: ToolRuntimeContex
|
|
|
15
15
|
};
|
|
16
16
|
execute?: ((input: unknown, options: import("./definition").ToolExecuteOptions) => {
|
|
17
17
|
id: string;
|
|
18
|
-
subscription_status: "
|
|
18
|
+
subscription_status: "completed" | "active" | "cancelled";
|
|
19
19
|
identifier: string;
|
|
20
20
|
events: string[];
|
|
21
21
|
expiresAtMs: number;
|
|
@@ -37,7 +37,7 @@ export declare function createWatchResourceEventsTool(context: ToolRuntimeContex
|
|
|
37
37
|
} | undefined;
|
|
38
38
|
} | Promise<{
|
|
39
39
|
id: string;
|
|
40
|
-
subscription_status: "
|
|
40
|
+
subscription_status: "completed" | "active" | "cancelled";
|
|
41
41
|
identifier: string;
|
|
42
42
|
events: string[];
|
|
43
43
|
expiresAtMs: number;
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
} from "./chunk-EM225ITJ.js";
|
|
5
5
|
import {
|
|
6
6
|
getStateAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-25SC7D6Z.js";
|
|
8
8
|
import {
|
|
9
9
|
toOptionalTrimmed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-32CXPIZE.js";
|
|
11
11
|
import {
|
|
12
12
|
pluginCatalogRuntime
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-X22XXSZA.js";
|
|
14
14
|
import {
|
|
15
15
|
setSpanAttributes,
|
|
16
16
|
setSpanStatus,
|
|
17
17
|
withSpan
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-RLVZIWNQ.js";
|
|
19
19
|
|
|
20
20
|
// src/chat/sandbox/resources.ts
|
|
21
21
|
var configuredResources;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
toCanonicalInputMessage,
|
|
4
4
|
toCanonicalOutputMessage,
|
|
5
5
|
toGenAiMessagesTraceAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3KGQOKIG.js";
|
|
7
7
|
import {
|
|
8
8
|
extractGenAiUsageAttributes,
|
|
9
9
|
logException,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
normalizeGenAiFinishReason,
|
|
12
12
|
serializeGenAiAttribute,
|
|
13
13
|
withSpan
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-RLVZIWNQ.js";
|
|
15
15
|
|
|
16
16
|
// src/chat/services/provider-error.ts
|
|
17
17
|
var ProviderError = class extends Error {
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
juniorConversations,
|
|
6
6
|
juniorIdentities,
|
|
7
7
|
juniorUsers
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-3I2IVWSZ.js";
|
|
9
9
|
import {
|
|
10
10
|
TURN_REASONING_LEVELS,
|
|
11
11
|
getChatConfig,
|
|
12
12
|
modelProfileSchema
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-32CXPIZE.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-RLVZIWNQ.js";
|
|
24
24
|
|
|
25
25
|
// src/chat/conversations/sql/store.ts
|
|
26
26
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -215,7 +215,14 @@ function normalizeSessionSource(value) {
|
|
|
215
215
|
if (value.platform === "local") {
|
|
216
216
|
return {
|
|
217
217
|
platform: "local",
|
|
218
|
-
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,
|
|
219
226
|
conversationId: value.conversationId
|
|
220
227
|
};
|
|
221
228
|
}
|
|
@@ -262,6 +269,109 @@ async function bindProviderConversation(executor, args) {
|
|
|
262
269
|
}
|
|
263
270
|
}
|
|
264
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
|
+
|
|
265
375
|
// src/chat/conversations/location.ts
|
|
266
376
|
import { nonBlankStringSchema } from "@sentry/junior-plugin-api";
|
|
267
377
|
import { z } from "zod";
|
|
@@ -327,56 +437,11 @@ function tenantId2(value) {
|
|
|
327
437
|
return value ?? "";
|
|
328
438
|
}
|
|
329
439
|
function sourceFromValue(value) {
|
|
330
|
-
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") {
|
|
331
441
|
return value;
|
|
332
442
|
}
|
|
333
443
|
return void 0;
|
|
334
444
|
}
|
|
335
|
-
function identityFromActor(actor) {
|
|
336
|
-
if (!actor?.slackUserId) {
|
|
337
|
-
return void 0;
|
|
338
|
-
}
|
|
339
|
-
return {
|
|
340
|
-
kind: "user",
|
|
341
|
-
provider: "slack",
|
|
342
|
-
providerTenantId: actor.teamId,
|
|
343
|
-
providerSubjectId: actor.slackUserId,
|
|
344
|
-
...actor.fullName ? { displayName: actor.fullName } : {},
|
|
345
|
-
...actor.slackUserName ? { handle: actor.slackUserName } : {},
|
|
346
|
-
...actor.email ? { email: actor.email, emailVerified: true } : {},
|
|
347
|
-
metadata: { platform: "slack" }
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
function systemIdentityFromSource(source) {
|
|
351
|
-
if (source === "scheduler") {
|
|
352
|
-
return {
|
|
353
|
-
kind: "system",
|
|
354
|
-
provider: "junior",
|
|
355
|
-
providerSubjectId: "scheduler",
|
|
356
|
-
displayName: "Junior Scheduler"
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
if (source === "local") {
|
|
360
|
-
return {
|
|
361
|
-
kind: "system",
|
|
362
|
-
provider: "junior",
|
|
363
|
-
providerSubjectId: "local-cli",
|
|
364
|
-
displayName: "Local CLI"
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
if (source === "resource_event") {
|
|
368
|
-
return {
|
|
369
|
-
kind: "system",
|
|
370
|
-
provider: "junior",
|
|
371
|
-
providerSubjectId: "resource-event",
|
|
372
|
-
displayName: "Resource Event"
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
return void 0;
|
|
376
|
-
}
|
|
377
|
-
function actorIdentityForConversation(conversation) {
|
|
378
|
-
return identityFromActor(conversation.actor) ?? systemIdentityFromSource(conversation.source);
|
|
379
|
-
}
|
|
380
445
|
function originTypeFromSource(source) {
|
|
381
446
|
return source;
|
|
382
447
|
}
|
|
@@ -408,8 +473,10 @@ function destinationUpsertFromDestination(args) {
|
|
|
408
473
|
provider: "local",
|
|
409
474
|
providerTenantId: localWorkspaceFromConversationId(destination.conversationId) ?? localWorkspaceFromConversationId(args.conversationId ?? ""),
|
|
410
475
|
providerDestinationId: destination.conversationId,
|
|
411
|
-
|
|
412
|
-
|
|
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",
|
|
413
480
|
metadata: { platform: "local" }
|
|
414
481
|
};
|
|
415
482
|
}
|
|
@@ -423,20 +490,6 @@ function executionStatusFromValue(value) {
|
|
|
423
490
|
function executionStatusToSql(status) {
|
|
424
491
|
return status === "paused" ? "awaiting_resume" : status;
|
|
425
492
|
}
|
|
426
|
-
function actorFromIdentityRow(identity, userDisplayName) {
|
|
427
|
-
if (!identity || identity.provider !== "slack") {
|
|
428
|
-
return void 0;
|
|
429
|
-
}
|
|
430
|
-
const fullName = userDisplayName?.trim() ? userDisplayName : identity.displayName;
|
|
431
|
-
return {
|
|
432
|
-
...identity.emailNormalized ? { email: identity.emailNormalized } : identity.email ? { email: identity.email } : {},
|
|
433
|
-
...fullName ? { fullName } : {},
|
|
434
|
-
platform: "slack",
|
|
435
|
-
slackUserId: identity.providerSubjectId,
|
|
436
|
-
...identity.handle ? { slackUserName: identity.handle } : {},
|
|
437
|
-
...identity.providerTenantId ? { teamId: identity.providerTenantId } : {}
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
493
|
function destinationFromRow(destination) {
|
|
441
494
|
const value = destination?.provider === "slack" ? {
|
|
442
495
|
platform: "slack",
|
|
@@ -537,26 +590,6 @@ function assertSameConversationDestination(args) {
|
|
|
537
590
|
`Conversation destination changed for ${args.conversationId}`
|
|
538
591
|
);
|
|
539
592
|
}
|
|
540
|
-
function mergeActor(current2, next) {
|
|
541
|
-
if (!current2) {
|
|
542
|
-
return next;
|
|
543
|
-
}
|
|
544
|
-
if (!next) {
|
|
545
|
-
return current2;
|
|
546
|
-
}
|
|
547
|
-
if (current2.slackUserId && next.slackUserId && current2.slackUserId !== next.slackUserId) {
|
|
548
|
-
return current2;
|
|
549
|
-
}
|
|
550
|
-
return {
|
|
551
|
-
...current2,
|
|
552
|
-
...current2.email ?? next.email ? { email: current2.email ?? next.email } : {},
|
|
553
|
-
...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : {},
|
|
554
|
-
...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : {},
|
|
555
|
-
...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : {},
|
|
556
|
-
...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : {},
|
|
557
|
-
...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : {}
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
593
|
function tokenTotal(usage) {
|
|
561
594
|
if (!usage) return 0;
|
|
562
595
|
if (usage.totalTokens !== void 0) return usage.totalTokens;
|
|
@@ -864,7 +897,8 @@ var SqlStore = class {
|
|
|
864
897
|
}).onConflictDoUpdate({
|
|
865
898
|
target: juniorConversations.conversationId,
|
|
866
899
|
set: {
|
|
867
|
-
|
|
900
|
+
// Origin source is set-once so dashboard continues cannot rewrite a Slack root.
|
|
901
|
+
source: sql2`coalesce(${juniorConversations.source}, excluded.source)`,
|
|
868
902
|
sessionSource: sql2`coalesce(${juniorConversations.sessionSource}, excluded.source_json)`,
|
|
869
903
|
originType: sql2`coalesce(excluded.origin_type, ${juniorConversations.originType})`,
|
|
870
904
|
originId: sql2`coalesce(excluded.origin_id, ${juniorConversations.originId})`,
|
|
@@ -68,12 +68,61 @@ var conversationFeedQuerySchema = z2.object({
|
|
|
68
68
|
}).strict();
|
|
69
69
|
var archiveConversationBodySchema = z2.object({ archived: z2.boolean(), lastSeenAt: z2.string().datetime() }).strict();
|
|
70
70
|
var archiveConversationResponseSchema = z2.object({ archived: z2.boolean() }).strict();
|
|
71
|
+
var createConversationBodySchema = z2.object({
|
|
72
|
+
idempotencyKey: z2.string().trim().min(1).max(200),
|
|
73
|
+
message: z2.string().trim().min(1).max(32e3),
|
|
74
|
+
/** New roots default public. Private roots stay participant-only. */
|
|
75
|
+
visibility: z2.enum(["private", "public"]).optional()
|
|
76
|
+
}).strict();
|
|
77
|
+
var createConversationMessageBodySchema = z2.object({
|
|
78
|
+
idempotencyKey: z2.string().trim().min(1).max(200),
|
|
79
|
+
message: z2.string().trim().min(1).max(32e3)
|
|
80
|
+
}).strict();
|
|
81
|
+
var acceptedConversationMessageSchema = z2.object({
|
|
82
|
+
conversationId: z2.string().min(1),
|
|
83
|
+
messageId: z2.string().min(1),
|
|
84
|
+
status: z2.enum(["accepted", "duplicate"])
|
|
85
|
+
}).strict();
|
|
71
86
|
var actorIdentitySchema = z2.object({
|
|
72
87
|
email: z2.string().optional(),
|
|
73
88
|
fullName: z2.string().optional(),
|
|
74
89
|
slackUserId: z2.string().optional(),
|
|
75
90
|
slackUserName: z2.string().optional()
|
|
76
91
|
}).strict();
|
|
92
|
+
var conversationPendingMessageDeliverySchema = z2.enum([
|
|
93
|
+
"defer",
|
|
94
|
+
"interrupt"
|
|
95
|
+
]);
|
|
96
|
+
var conversationPendingMessageSchema = z2.object({
|
|
97
|
+
actorIdentity: actorIdentitySchema.optional(),
|
|
98
|
+
createdAt: z2.string().datetime(),
|
|
99
|
+
delivery: conversationPendingMessageDeliverySchema,
|
|
100
|
+
inboundMessageId: z2.string().min(1),
|
|
101
|
+
messageId: z2.string().min(1),
|
|
102
|
+
receivedAt: z2.string().datetime(),
|
|
103
|
+
role: z2.literal("user"),
|
|
104
|
+
source: z2.enum(["slack", "web"]),
|
|
105
|
+
text: z2.string().optional(),
|
|
106
|
+
redacted: z2.literal(true).optional()
|
|
107
|
+
}).strict().superRefine((data, context) => {
|
|
108
|
+
if (data.text === void 0 === (data.redacted !== true)) {
|
|
109
|
+
context.addIssue({
|
|
110
|
+
code: "custom",
|
|
111
|
+
message: "pending message content must be text or explicitly redacted"
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (data.redacted && data.actorIdentity) {
|
|
115
|
+
context.addIssue({
|
|
116
|
+
code: "custom",
|
|
117
|
+
message: "redacted pending messages must not expose actor identity"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var conversationPendingMessagesReportSchema = z2.object({
|
|
122
|
+
conversationId: z2.string().min(1),
|
|
123
|
+
generatedAt: z2.string().datetime(),
|
|
124
|
+
messages: z2.array(conversationPendingMessageSchema)
|
|
125
|
+
}).strict();
|
|
77
126
|
var conversationAuxiliaryCostsSchema = z2.object({
|
|
78
127
|
costUsd: z2.number().finite().nonnegative(),
|
|
79
128
|
operations: z2.array(
|
|
@@ -105,6 +154,7 @@ var conversationSummaryReportSchema = z2.object({
|
|
|
105
154
|
auxiliaryCosts: conversationAuxiliaryCostsSchema.optional(),
|
|
106
155
|
conversationId: z2.string(),
|
|
107
156
|
isParticipant: z2.boolean(),
|
|
157
|
+
visibility: z2.enum(["private", "public"]).optional(),
|
|
108
158
|
status: conversationReportStatusSchema,
|
|
109
159
|
startedAt: z2.string(),
|
|
110
160
|
lastSeenAt: z2.string(),
|
|
@@ -124,6 +174,7 @@ var conversationReportMessageEventDataSchema = z2.object({
|
|
|
124
174
|
type: z2.literal("message"),
|
|
125
175
|
messageId: z2.string().min(1),
|
|
126
176
|
role: z2.enum(["assistant", "system", "user"]),
|
|
177
|
+
source: z2.literal("web").optional(),
|
|
127
178
|
actorIdentity: actorIdentitySchema.optional(),
|
|
128
179
|
eventType: z2.string().min(1).optional(),
|
|
129
180
|
text: z2.string().optional(),
|
|
@@ -448,10 +499,12 @@ var conversationStatsItemSchema = z2.object({
|
|
|
448
499
|
tokens: z2.number().optional()
|
|
449
500
|
}).strict();
|
|
450
501
|
var conversationMetricDaySchema = z2.object({
|
|
502
|
+
cachedInputTokens: z2.number().optional(),
|
|
451
503
|
conversations: z2.number(),
|
|
452
504
|
costUsd: z2.number().optional(),
|
|
453
505
|
date: z2.string(),
|
|
454
506
|
durationMs: z2.number(),
|
|
507
|
+
inputTokens: z2.number().optional(),
|
|
455
508
|
tokens: z2.number().optional()
|
|
456
509
|
}).strict();
|
|
457
510
|
var guardianMetricDaySchema = z2.object({
|
|
@@ -472,6 +525,7 @@ var guardianStatsSchema = z2.object({
|
|
|
472
525
|
}).strict();
|
|
473
526
|
var conversationStatsReportSchema = z2.object({
|
|
474
527
|
active: z2.number(),
|
|
528
|
+
cachedInputTokens: z2.number().optional(),
|
|
475
529
|
conversations: z2.number(),
|
|
476
530
|
durationMs: z2.number(),
|
|
477
531
|
failed: z2.number(),
|
|
@@ -482,6 +536,7 @@ var conversationStatsReportSchema = z2.object({
|
|
|
482
536
|
actors: z2.array(conversationStatsItemSchema),
|
|
483
537
|
source: z2.literal("conversation_index"),
|
|
484
538
|
costUsd: z2.number().optional(),
|
|
539
|
+
inputTokens: z2.number().optional(),
|
|
485
540
|
tokens: z2.number().optional(),
|
|
486
541
|
windowEnd: z2.string(),
|
|
487
542
|
windowStart: z2.string()
|
|
@@ -717,6 +772,12 @@ export {
|
|
|
717
772
|
conversationFeedQuerySchema,
|
|
718
773
|
archiveConversationBodySchema,
|
|
719
774
|
archiveConversationResponseSchema,
|
|
775
|
+
createConversationBodySchema,
|
|
776
|
+
createConversationMessageBodySchema,
|
|
777
|
+
acceptedConversationMessageSchema,
|
|
778
|
+
conversationPendingMessageDeliverySchema,
|
|
779
|
+
conversationPendingMessageSchema,
|
|
780
|
+
conversationPendingMessagesReportSchema,
|
|
720
781
|
conversationAuxiliaryCostsSchema,
|
|
721
782
|
conversationSummaryReportSchema,
|
|
722
783
|
conversationReportEventDataSchema,
|
|
@@ -728,14 +789,14 @@ export {
|
|
|
728
789
|
conversationStatsReportSchema,
|
|
729
790
|
dailyConversationActivitySchema,
|
|
730
791
|
activityDays,
|
|
731
|
-
personParamsSchema,
|
|
732
|
-
actorDirectoryReportSchema,
|
|
733
|
-
actorProfileReportSchema,
|
|
734
|
-
personalSpendReportSchema,
|
|
735
792
|
locationParamsSchema,
|
|
736
793
|
locationActivityDayReportSchema,
|
|
737
794
|
locationDirectoryReportSchema,
|
|
738
795
|
locationDetailReportSchema,
|
|
796
|
+
personParamsSchema,
|
|
797
|
+
actorDirectoryReportSchema,
|
|
798
|
+
actorProfileReportSchema,
|
|
799
|
+
personalSpendReportSchema,
|
|
739
800
|
personalTokenMetadataSchema,
|
|
740
801
|
personalTokenListSchema,
|
|
741
802
|
createPersonalTokenBodySchema,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
persistConversationMessages
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EW2LNCRL.js";
|
|
4
4
|
import {
|
|
5
5
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
6
6
|
} from "./chunk-3Y47VMHV.js";
|
|
7
7
|
import {
|
|
8
8
|
getDb
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3GYZ5YEH.js";
|
|
10
10
|
import {
|
|
11
11
|
juniorLocationConfigurations
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3I2IVWSZ.js";
|
|
13
13
|
import {
|
|
14
14
|
getStateAdapter
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-25SC7D6Z.js";
|
|
16
16
|
import {
|
|
17
17
|
juniorDestinations
|
|
18
18
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isRecord,
|
|
21
21
|
toOptionalNumber,
|
|
22
22
|
toOptionalString
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-RLVZIWNQ.js";
|
|
24
24
|
|
|
25
25
|
// src/chat/conversations/turn-lifecycle.ts
|
|
26
26
|
var ConversationTurnLifecycleService = class {
|