@sentry/junior 0.145.0 → 0.146.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-L7D2BDVV.js → agent-hooks-SLJADYE5.js} +10 -10
- package/dist/api.js +19 -19
- package/dist/app.js +97 -84
- package/dist/{catalog-runtime-QLAC4Q3W.js → catalog-runtime-RQIMSDPR.js} +5 -5
- package/dist/chat/agent/resume.d.ts +0 -3
- package/dist/chat/agent/skills.d.ts +0 -1
- package/dist/chat/agent/tools.d.ts +0 -1
- package/dist/chat/conversations/message-search.d.ts +32 -0
- package/dist/chat/conversations/sql/message-search.d.ts +4 -0
- package/dist/chat/conversations/tool-source.d.ts +5 -0
- package/dist/chat/db.d.ts +2 -2
- package/dist/chat/slack/message/attachments.d.ts +2 -0
- package/dist/chat/slack/message/blocks.d.ts +2 -0
- package/dist/chat/slack/message/content.d.ts +18 -0
- package/dist/chat/slack/message/identity.d.ts +7 -0
- package/dist/chat/slack/tools/{conversation-search.d.ts → conversation-message-search.d.ts} +21 -14
- package/dist/chat/slack/tools/user-lookup.d.ts +2 -1
- package/dist/chat/task-execution/checkpoint.d.ts +1 -3
- package/dist/chat/task-execution/turn-cursor.d.ts +0 -9
- package/dist/chat/tools/{query-conversation-events.d.ts → search-conversation-events.d.ts} +3 -3
- package/dist/{chunk-2UH3JI64.js → chunk-37EVZP66.js} +41 -29
- package/dist/{chunk-CD2XFGYQ.js → chunk-37JJDS4H.js} +1 -1
- package/dist/{chunk-I47UGQPJ.js → chunk-47OSH2ZO.js} +7 -7
- package/dist/{chunk-RUSS62EN.js → chunk-AISNSNDV.js} +3 -3
- package/dist/{chunk-2LWPFSB4.js → chunk-B63BF443.js} +1 -1
- package/dist/{chunk-64SBYW2O.js → chunk-BLETMLRX.js} +455 -162
- package/dist/{chunk-GDV5LXRA.js → chunk-F7REGDKO.js} +1 -1
- package/dist/{chunk-B46ZMVOV.js → chunk-FEKQHPVA.js} +5 -5
- package/dist/{chunk-5PNPQYTO.js → chunk-FGHADGIC.js} +2 -2
- package/dist/{chunk-GUWLDMGF.js → chunk-FXDDDSPL.js} +4 -4
- package/dist/{chunk-ZIAMN2UW.js → chunk-GDQEU4I7.js} +16 -28
- package/dist/{chunk-QUG4JSZK.js → chunk-GYEKOX7N.js} +1 -1
- package/dist/{chunk-QJBDABQA.js → chunk-H6U2U3EP.js} +10 -10
- package/dist/{chunk-DS3J6WGY.js → chunk-HQE6EJS5.js} +1 -1
- package/dist/{chunk-HISR3DTV.js → chunk-JUA6VU2Z.js} +5 -7
- package/dist/{chunk-PJ4NMVQB.js → chunk-LVW7BLLT.js} +2 -2
- package/dist/{chunk-LVVSIMBB.js → chunk-M6ZWP4RI.js} +1 -1
- package/dist/{chunk-27TEJTZO.js → chunk-MCFIXAV5.js} +1 -1
- package/dist/{chunk-XFKIRN3Q.js → chunk-MKRIZ4VG.js} +2 -3
- package/dist/{chunk-2XET6PKP.js → chunk-OFPYOC3M.js} +15 -16
- package/dist/{chunk-SIN3MXH6.js → chunk-PB222GIA.js} +1 -1
- package/dist/{chunk-DXEQAIUV.js → chunk-PH4Q3A6W.js} +1 -1
- package/dist/{chunk-JTGS3ZZE.js → chunk-QG7OOKIN.js} +1 -1
- package/dist/{chunk-EIX2LQ6L.js → chunk-QSXZ42KX.js} +3 -3
- package/dist/{chunk-ZIMRGFYL.js → chunk-SCGVWUZX.js} +6 -6
- package/dist/{chunk-VTDMB7XX.js → chunk-T5GXFFLA.js} +1 -1
- package/dist/{chunk-WF5HVH3M.js → chunk-TCEJ7XXM.js} +1 -1
- package/dist/{chunk-TZRXYWRE.js → chunk-V6SRLKUB.js} +2 -2
- package/dist/{chunk-ZYAJMESY.js → chunk-W65V465O.js} +2 -2
- package/dist/{chunk-YD54Q45G.js → chunk-X22KCSCO.js} +4 -4
- package/dist/{chunk-HLOUZC5C.js → chunk-X2WMBTS3.js} +4 -4
- package/dist/{chunk-FUBRJA5F.js → chunk-ZDGHGY74.js} +6 -6
- package/dist/cli/chat.js +32 -32
- 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-62PW6LM3.js → db-WWOMXWTT.js} +9 -9
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-6NZNHJAM.js → oauth-callback-server-A6ZZX74U.js} +23 -23
- package/dist/{runner-GCRPG3GQ.js → runner-KSGB2UAV.js} +15 -17
- package/dist/{skills-2S3MDFIQ.js → skills-26QPWKVS.js} +6 -6
- package/dist/{spawn-7WK37BTD.js → spawn-5LAJXZ2P.js} +17 -17
- package/dist/{validation-HAOLCJ5A.js → validation-OPSRGFGH.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-R4XYKMUW.js → work-VMSW7STJ.js} +16 -16
- package/dist/{worker-U2UCVR7M.js → worker-2JNFB7C7.js} +10 -10
- package/package.json +5 -5
- package/dist/chat/conversations/search.d.ts +0 -24
- package/dist/chat/conversations/sql/search.d.ts +0 -4
- package/dist/chat/slack/legacy-attachments.d.ts +0 -4
- package/dist/chat/slack/message.d.ts +0 -12
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** One relevant chat-message match from a prior conversation. */
|
|
2
|
+
export interface ConversationMessageSearchResult {
|
|
3
|
+
channelName?: string;
|
|
4
|
+
conversationId: string;
|
|
5
|
+
excerpt: string;
|
|
6
|
+
messageCreatedAtMs: number;
|
|
7
|
+
messageId: string;
|
|
8
|
+
providerDestinationId: string;
|
|
9
|
+
role: "assistant" | "user";
|
|
10
|
+
}
|
|
11
|
+
/** Runtime-derived public workspace scope for cross-conversation search. */
|
|
12
|
+
export interface ConversationMessageSearchScope {
|
|
13
|
+
kind: "public_provider_tenant";
|
|
14
|
+
provider: "slack";
|
|
15
|
+
providerTenantId: string;
|
|
16
|
+
}
|
|
17
|
+
/** Optional filters that narrow retained public workspace search. */
|
|
18
|
+
export interface ConversationMessageSearchFilters {
|
|
19
|
+
/** Slack channel id of the conversation destination. */
|
|
20
|
+
channelId?: string;
|
|
21
|
+
/** Full-text query over retained visible message text. */
|
|
22
|
+
query?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Search retained public messages within an authorized workspace. */
|
|
25
|
+
export interface ConversationMessageSearchStore {
|
|
26
|
+
search(args: {
|
|
27
|
+
currentConversationId: string;
|
|
28
|
+
filters: ConversationMessageSearchFilters;
|
|
29
|
+
limit: number;
|
|
30
|
+
scope: ConversationMessageSearchScope;
|
|
31
|
+
}): Promise<ConversationMessageSearchResult[]>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JuniorSqlDatabase } from "@/db/db";
|
|
2
|
+
import type { ConversationMessageSearchStore } from "../message-search";
|
|
3
|
+
/** Create a SQL-backed public workspace message search store. */
|
|
4
|
+
export declare function createSqlConversationMessageSearchStore(executor: JuniorSqlDatabase): ConversationMessageSearchStore;
|
package/dist/chat/db.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConversationStore } from "@/chat/conversations/store";
|
|
2
2
|
import type { ConversationEventStore } from "@/chat/conversations/history";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ConversationMessageSearchStore } from "@/chat/conversations/message-search";
|
|
4
4
|
import type { JuniorDatabase, JuniorSqlExecutor } from "@/db/db";
|
|
5
5
|
/** Return the process SQL executor for SQL-specific queries and transactions. */
|
|
6
6
|
export declare function getSqlExecutor(): JuniorSqlExecutor;
|
|
@@ -11,6 +11,6 @@ export declare function getConversationStore(): ConversationStore;
|
|
|
11
11
|
/** Return the canonical SQL-backed conversation event store. */
|
|
12
12
|
export declare function getConversationEventStore(): ConversationEventStore;
|
|
13
13
|
/** Return the SQL-backed public provider-tenant conversation search store. */
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function getConversationMessageSearchStore(): ConversationMessageSearchStore;
|
|
15
15
|
/** Close the process SQL database when it has been opened. */
|
|
16
16
|
export declare function closeDb(): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack message content projection.
|
|
3
|
+
*
|
|
4
|
+
* This module is the typed entry point for agent-visible Slack text. Raw block
|
|
5
|
+
* and attachment details stay behind this boundary.
|
|
6
|
+
*/
|
|
7
|
+
import { type Message } from "chat";
|
|
8
|
+
/** Agent-visible content projected from a Slack message. */
|
|
9
|
+
export interface MessageContent {
|
|
10
|
+
attachmentText: string;
|
|
11
|
+
hasAttachments: boolean;
|
|
12
|
+
text: string;
|
|
13
|
+
topLevelText: string;
|
|
14
|
+
}
|
|
15
|
+
/** Replace top-level text while preserving the parsed attachment projection. */
|
|
16
|
+
export declare function replaceTopLevelText(content: Pick<MessageContent, "attachmentText">, text: string): string;
|
|
17
|
+
/** Parse the agent-visible content and attachment state of a Slack message. */
|
|
18
|
+
export declare function parseContent(message: Pick<Message, "attachments" | "formatted" | "raw" | "text">): MessageContent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Message } from "chat";
|
|
2
|
+
import { type SlackMessageTs } from "@/chat/slack/timestamp";
|
|
3
|
+
/**
|
|
4
|
+
* Preserve the native Slack message timestamp when a synthetic message ID is
|
|
5
|
+
* used for routing or deduplication.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getMessageTimestamp(message: Pick<Message, "id" | "raw">): SlackMessageTs | undefined;
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConversationMessageSearchScope, ConversationMessageSearchStore } from "@/chat/conversations/message-search";
|
|
2
2
|
import { getSlackMessagePermalink } from "@/chat/slack/outbound";
|
|
3
|
-
interface
|
|
3
|
+
interface ConversationMessageSearchToolDeps {
|
|
4
4
|
getPermalink?: typeof getSlackMessagePermalink;
|
|
5
|
-
store?:
|
|
5
|
+
store?: ConversationMessageSearchStore;
|
|
6
6
|
}
|
|
7
|
-
/** Create a tool that searches retained public
|
|
8
|
-
export declare function
|
|
7
|
+
/** Create a tool that searches retained public messages in an authorized Slack workspace. */
|
|
8
|
+
export declare function createSlackConversationMessageSearchTool(scope: ConversationMessageSearchScope, currentConversationId: string, deps?: ConversationMessageSearchToolDeps): Omit<import("../../tools/definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
9
9
|
inputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
10
10
|
outputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
11
11
|
prepareArguments(args: unknown): {
|
|
12
|
-
|
|
12
|
+
channel_id?: string | null | undefined;
|
|
13
|
+
query?: string | null | undefined;
|
|
13
14
|
limit?: number | null | undefined;
|
|
14
15
|
};
|
|
15
16
|
execute?: ((input: unknown, options: import("../../tools/definition").ToolExecuteOptions) => {
|
|
16
17
|
[x: string]: unknown;
|
|
17
|
-
query: string;
|
|
18
18
|
count: number;
|
|
19
|
-
|
|
19
|
+
matches: {
|
|
20
|
+
channel_id: string;
|
|
20
21
|
conversation_id: string;
|
|
21
|
-
|
|
22
|
+
excerpt: string;
|
|
22
23
|
message_id: string;
|
|
23
24
|
message_role: "user" | "assistant";
|
|
24
25
|
message_timestamp: string;
|
|
25
|
-
|
|
26
|
+
thread_ts: string;
|
|
27
|
+
channel_name?: string | undefined;
|
|
26
28
|
permalink?: string | undefined;
|
|
27
29
|
}[];
|
|
28
30
|
target?: string | undefined;
|
|
@@ -31,17 +33,20 @@ export declare function createSlackConversationSearchTool(scope: ConversationSea
|
|
|
31
33
|
arguments: Record<string, unknown>;
|
|
32
34
|
reason?: string | undefined;
|
|
33
35
|
} | undefined;
|
|
36
|
+
channel_id?: string | undefined;
|
|
37
|
+
query?: string | undefined;
|
|
34
38
|
} | Promise<{
|
|
35
39
|
[x: string]: unknown;
|
|
36
|
-
query: string;
|
|
37
40
|
count: number;
|
|
38
|
-
|
|
41
|
+
matches: {
|
|
42
|
+
channel_id: string;
|
|
39
43
|
conversation_id: string;
|
|
40
|
-
|
|
44
|
+
excerpt: string;
|
|
41
45
|
message_id: string;
|
|
42
46
|
message_role: "user" | "assistant";
|
|
43
47
|
message_timestamp: string;
|
|
44
|
-
|
|
48
|
+
thread_ts: string;
|
|
49
|
+
channel_name?: string | undefined;
|
|
45
50
|
permalink?: string | undefined;
|
|
46
51
|
}[];
|
|
47
52
|
target?: string | undefined;
|
|
@@ -50,6 +55,8 @@ export declare function createSlackConversationSearchTool(scope: ConversationSea
|
|
|
50
55
|
arguments: Record<string, unknown>;
|
|
51
56
|
reason?: string | undefined;
|
|
52
57
|
} | undefined;
|
|
58
|
+
channel_id?: string | undefined;
|
|
59
|
+
query?: string | undefined;
|
|
53
60
|
}>) | undefined;
|
|
54
61
|
};
|
|
55
62
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { SlackTeamId } from "@/chat/slack/ids";
|
|
1
2
|
/** Create the tool that resolves Slack users by ID, handle, or email. */
|
|
2
|
-
export declare function createSlackUserLookupTool(): Omit<import("../../tools/definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
3
|
+
export declare function createSlackUserLookupTool(teamId: SlackTeamId): Omit<import("../../tools/definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
3
4
|
inputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
4
5
|
outputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
5
6
|
prepareArguments(args: unknown): {
|
|
@@ -32,12 +32,12 @@ export type TurnCheckpoint = {
|
|
|
32
32
|
/**
|
|
33
33
|
* Lifecycle fields for a checkpoint write.
|
|
34
34
|
* Routing/metrics/provenance are only for SQL dual-write / resume restore.
|
|
35
|
+
* Profile, reasoning, concrete model id, and skills are not checkpoint fields.
|
|
35
36
|
*/
|
|
36
37
|
interface TurnCheckpointWrite {
|
|
37
38
|
conversationId: string;
|
|
38
39
|
turnId: string;
|
|
39
40
|
messages: PiMessage[];
|
|
40
|
-
modelId: string;
|
|
41
41
|
/** Required for running/paused; optional for completed/failed (falls back to stored). */
|
|
42
42
|
sliceId?: number;
|
|
43
43
|
actor?: Actor;
|
|
@@ -48,8 +48,6 @@ interface TurnCheckpointWrite {
|
|
|
48
48
|
dispatchOutcome?: AgentDispatchOutcome;
|
|
49
49
|
source?: Source;
|
|
50
50
|
surface?: AgentTurnSurface;
|
|
51
|
-
loadedSkillNames?: string[];
|
|
52
|
-
reasoningLevel?: string;
|
|
53
51
|
turnStartMessageIndex?: number;
|
|
54
52
|
trailingMessageProvenance?: ConversationMessageProvenance[];
|
|
55
53
|
turnContexts?: PluginTurnContext[];
|
|
@@ -32,9 +32,6 @@ export interface TurnRecord {
|
|
|
32
32
|
resultMessageId?: string;
|
|
33
33
|
errorMessage?: string;
|
|
34
34
|
lastProgressAtMs: number;
|
|
35
|
-
loadedSkillNames?: string[];
|
|
36
|
-
modelId?: string;
|
|
37
|
-
reasoningLevel?: string;
|
|
38
35
|
piMessages: PiMessage[];
|
|
39
36
|
/** Per-message provenance aligned one-to-one with `piMessages`. */
|
|
40
37
|
piMessageProvenance: ConversationMessageProvenance[];
|
|
@@ -89,8 +86,6 @@ export declare function upsertTurnRecord(args: {
|
|
|
89
86
|
destinationVisibility?: ConversationPrivacy;
|
|
90
87
|
source?: Source;
|
|
91
88
|
lastProgressAtMs?: number;
|
|
92
|
-
loadedSkillNames?: string[];
|
|
93
|
-
modelId: string;
|
|
94
89
|
conversationStore?: ConversationStore;
|
|
95
90
|
turnId: string;
|
|
96
91
|
sliceId: number;
|
|
@@ -101,7 +96,6 @@ export declare function upsertTurnRecord(args: {
|
|
|
101
96
|
trailingMessageProvenance?: ConversationMessageProvenance[];
|
|
102
97
|
actor?: Actor;
|
|
103
98
|
resumeReason?: TurnPauseReason;
|
|
104
|
-
reasoningLevel?: string;
|
|
105
99
|
errorMessage?: string;
|
|
106
100
|
resumedFromSliceId?: number;
|
|
107
101
|
traceId?: string;
|
|
@@ -121,12 +115,9 @@ type TurnSummaryWrite = {
|
|
|
121
115
|
destinationVisibility?: ConversationPrivacy;
|
|
122
116
|
source?: Source;
|
|
123
117
|
lastProgressAtMs?: number;
|
|
124
|
-
loadedSkillNames?: string[];
|
|
125
|
-
modelId?: string;
|
|
126
118
|
conversationStore?: ConversationStore;
|
|
127
119
|
actor?: Actor;
|
|
128
120
|
resumeReason?: TurnPauseReason;
|
|
129
|
-
reasoningLevel?: string;
|
|
130
121
|
turnId: string;
|
|
131
122
|
sliceId: number;
|
|
132
123
|
startedAtMs?: number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type KnownConversationEventType } from "@/chat/conversations/history";
|
|
2
2
|
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
3
|
-
/** Create a deferred tool that
|
|
4
|
-
export declare function
|
|
3
|
+
/** Create a deferred tool that searches one conversation's durable event log. */
|
|
4
|
+
export declare function createSearchConversationEventsTool(context: ToolRuntimeContext): Omit<import("./definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
5
5
|
inputSchema: import("./definition").JsonSchemaObject;
|
|
6
6
|
outputSchema: import("./definition").JsonSchemaObject;
|
|
7
7
|
prepareArguments(args: unknown): {
|
|
8
|
-
conversation_id
|
|
8
|
+
conversation_id?: string | null | undefined;
|
|
9
9
|
after_seq?: number | null | undefined;
|
|
10
10
|
before_seq?: number | null | undefined;
|
|
11
11
|
limit?: number | null | undefined;
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
juniorConversations,
|
|
6
6
|
juniorIdentities,
|
|
7
7
|
juniorUsers
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MCFIXAV5.js";
|
|
9
9
|
import {
|
|
10
10
|
TURN_REASONING_LEVELS,
|
|
11
11
|
getChatConfig,
|
|
12
12
|
modelProfileSchema
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-MKRIZ4VG.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-B63BF443.js";
|
|
24
24
|
|
|
25
25
|
// src/chat/conversations/sql/store.ts
|
|
26
26
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -1601,22 +1601,44 @@ function createSqlConversationEventStore(executor) {
|
|
|
1601
1601
|
return new SqlConversationEventStore(executor);
|
|
1602
1602
|
}
|
|
1603
1603
|
|
|
1604
|
-
// src/chat/conversations/sql/search.ts
|
|
1604
|
+
// src/chat/conversations/sql/message-search.ts
|
|
1605
1605
|
import { and as and5, desc as desc3, eq as eq5, isNull as isNull2, ne, sql as sql5 } from "drizzle-orm";
|
|
1606
|
-
var
|
|
1606
|
+
var EXCERPT_WITHOUT_QUERY_CHARS = 240;
|
|
1607
|
+
var SqlConversationMessageSearchStore = class {
|
|
1607
1608
|
constructor(executor) {
|
|
1608
1609
|
this.executor = executor;
|
|
1609
1610
|
}
|
|
1610
1611
|
executor;
|
|
1611
1612
|
async search(args) {
|
|
1612
1613
|
const db = this.executor.db();
|
|
1613
|
-
const
|
|
1614
|
+
const query = args.filters.query?.trim() || void 0;
|
|
1614
1615
|
const text = sql5`${juniorConversationEvents.payload}->>'text'`;
|
|
1615
|
-
const rank = sql5`ts_rank_cd(to_tsvector('english', ${text}), ${tsquery})`;
|
|
1616
|
-
const excerpt = sql5`ts_headline('english', ${text}, ${tsquery}, 'MaxFragments=2, MinWords=8, MaxWords=40, FragmentDelimiter=" … ", StartSel=**, StopSel=**')`;
|
|
1617
1616
|
const role = sql5`${juniorConversationEvents.payload}->>'role'`;
|
|
1618
1617
|
const messageId = sql5`${juniorConversationEvents.payload}->>'messageId'`;
|
|
1618
|
+
const tsquery = query ? sql5`websearch_to_tsquery('english', ${query})` : void 0;
|
|
1619
|
+
const rank = tsquery ? sql5`ts_rank_cd(to_tsvector('english', ${text}), ${tsquery})` : sql5`1`;
|
|
1620
|
+
const excerpt = tsquery ? sql5`ts_headline('english', ${text}, ${tsquery}, 'MaxFragments=2, MinWords=8, MaxWords=40, FragmentDelimiter=" … ", StartSel=**, StopSel=**')` : sql5`left(${text}, ${EXCERPT_WITHOUT_QUERY_CHARS})`;
|
|
1621
|
+
const conditions = [
|
|
1622
|
+
eq5(juniorConversations.source, "slack"),
|
|
1623
|
+
isNull2(juniorConversations.parentConversationId),
|
|
1624
|
+
isNull2(juniorConversations.transcriptPurgedAt),
|
|
1625
|
+
ne(juniorConversations.conversationId, args.currentConversationId),
|
|
1626
|
+
eq5(juniorDestinations.provider, args.scope.provider),
|
|
1627
|
+
eq5(juniorDestinations.providerTenantId, args.scope.providerTenantId),
|
|
1628
|
+
eq5(juniorDestinations.visibility, "public"),
|
|
1629
|
+
eq5(juniorConversationEvents.type, "message"),
|
|
1630
|
+
sql5`${role} in ('user', 'assistant')`
|
|
1631
|
+
];
|
|
1632
|
+
if (tsquery) {
|
|
1633
|
+
conditions.push(sql5`to_tsvector('english', ${text}) @@ ${tsquery}`);
|
|
1634
|
+
}
|
|
1635
|
+
if (args.filters.channelId) {
|
|
1636
|
+
conditions.push(
|
|
1637
|
+
eq5(juniorDestinations.providerDestinationId, args.filters.channelId)
|
|
1638
|
+
);
|
|
1639
|
+
}
|
|
1619
1640
|
const bestPerConversation = db.selectDistinctOn([juniorConversations.conversationId], {
|
|
1641
|
+
channelName: juniorDestinations.displayName,
|
|
1620
1642
|
conversationId: juniorConversations.conversationId,
|
|
1621
1643
|
excerpt: excerpt.as("excerpt"),
|
|
1622
1644
|
lastActivityAt: juniorConversations.lastActivityAt,
|
|
@@ -1634,27 +1656,15 @@ var SqlConversationSearchStore = class {
|
|
|
1634
1656
|
).innerJoin(
|
|
1635
1657
|
juniorDestinations,
|
|
1636
1658
|
eq5(juniorDestinations.id, juniorConversations.destinationId)
|
|
1637
|
-
).where(
|
|
1638
|
-
and5(
|
|
1639
|
-
eq5(juniorConversations.source, "slack"),
|
|
1640
|
-
isNull2(juniorConversations.parentConversationId),
|
|
1641
|
-
isNull2(juniorConversations.transcriptPurgedAt),
|
|
1642
|
-
ne(juniorConversations.conversationId, args.currentConversationId),
|
|
1643
|
-
eq5(juniorDestinations.provider, args.scope.provider),
|
|
1644
|
-
eq5(juniorDestinations.providerTenantId, args.scope.providerTenantId),
|
|
1645
|
-
eq5(juniorDestinations.visibility, "public"),
|
|
1646
|
-
eq5(juniorConversationEvents.type, "message"),
|
|
1647
|
-
sql5`${role} in ('user', 'assistant')`,
|
|
1648
|
-
sql5`to_tsvector('english', ${text}) @@ ${tsquery}`
|
|
1649
|
-
)
|
|
1650
|
-
).orderBy(
|
|
1659
|
+
).where(and5(...conditions)).orderBy(
|
|
1651
1660
|
juniorConversations.conversationId,
|
|
1652
1661
|
desc3(rank),
|
|
1653
1662
|
desc3(juniorConversationEvents.createdAt)
|
|
1654
1663
|
).as("best_conversation_matches");
|
|
1655
1664
|
const rows = await db.select().from(bestPerConversation).orderBy(
|
|
1656
1665
|
desc3(bestPerConversation.rank),
|
|
1657
|
-
desc3(bestPerConversation.lastActivityAt)
|
|
1666
|
+
desc3(bestPerConversation.lastActivityAt),
|
|
1667
|
+
desc3(bestPerConversation.messageCreatedAt)
|
|
1658
1668
|
).limit(args.limit);
|
|
1659
1669
|
return rows.map((row) => ({
|
|
1660
1670
|
conversationId: row.conversationId,
|
|
@@ -1662,12 +1672,13 @@ var SqlConversationSearchStore = class {
|
|
|
1662
1672
|
messageCreatedAtMs: row.messageCreatedAt.getTime(),
|
|
1663
1673
|
messageId: row.messageId,
|
|
1664
1674
|
providerDestinationId: row.providerDestinationId,
|
|
1665
|
-
role: row.role
|
|
1675
|
+
role: row.role,
|
|
1676
|
+
...row.channelName ? { channelName: row.channelName } : {}
|
|
1666
1677
|
}));
|
|
1667
1678
|
}
|
|
1668
1679
|
};
|
|
1669
|
-
function
|
|
1670
|
-
return new
|
|
1680
|
+
function createSqlConversationMessageSearchStore(executor) {
|
|
1681
|
+
return new SqlConversationMessageSearchStore(executor);
|
|
1671
1682
|
}
|
|
1672
1683
|
|
|
1673
1684
|
// src/chat/db.ts
|
|
@@ -1699,7 +1710,7 @@ function getSqlExecutor() {
|
|
|
1699
1710
|
db,
|
|
1700
1711
|
store: createSqlStore(db),
|
|
1701
1712
|
eventStore: createSqlConversationEventStore(db),
|
|
1702
|
-
searchStore:
|
|
1713
|
+
searchStore: createSqlConversationMessageSearchStore(db)
|
|
1703
1714
|
};
|
|
1704
1715
|
}
|
|
1705
1716
|
return current.db;
|
|
@@ -1715,7 +1726,7 @@ function getConversationEventStore() {
|
|
|
1715
1726
|
getSqlExecutor();
|
|
1716
1727
|
return current.eventStore;
|
|
1717
1728
|
}
|
|
1718
|
-
function
|
|
1729
|
+
function getConversationMessageSearchStore() {
|
|
1719
1730
|
getSqlExecutor();
|
|
1720
1731
|
return current.searchStore;
|
|
1721
1732
|
}
|
|
@@ -1730,6 +1741,7 @@ export {
|
|
|
1730
1741
|
parseDestination,
|
|
1731
1742
|
requireSlackDestination,
|
|
1732
1743
|
sameDestination,
|
|
1744
|
+
upsertIdentity,
|
|
1733
1745
|
parseSessionSource,
|
|
1734
1746
|
bindProviderConversation,
|
|
1735
1747
|
locationFromRow,
|
|
@@ -1748,6 +1760,6 @@ export {
|
|
|
1748
1760
|
getDb,
|
|
1749
1761
|
getConversationStore,
|
|
1750
1762
|
getConversationEventStore,
|
|
1751
|
-
|
|
1763
|
+
getConversationMessageSearchStore,
|
|
1752
1764
|
closeDb
|
|
1753
1765
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveBaseUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZDGHGY74.js";
|
|
4
4
|
import {
|
|
5
5
|
createPluginLogger,
|
|
6
6
|
getPlugins
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SCGVWUZX.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb,
|
|
10
10
|
parseDestination
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-37EVZP66.js";
|
|
12
12
|
import {
|
|
13
13
|
sleep
|
|
14
14
|
} from "./chunk-EM225ITJ.js";
|
|
15
15
|
import {
|
|
16
16
|
acquireActiveLock,
|
|
17
17
|
getStateAdapter
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-GYEKOX7N.js";
|
|
19
19
|
import {
|
|
20
20
|
pluginCatalogRuntime
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PB222GIA.js";
|
|
22
22
|
import {
|
|
23
23
|
fetchWithBoundedOAuthErrorBodies
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-37JJDS4H.js";
|
|
25
25
|
import {
|
|
26
26
|
isRecord
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-B63BF443.js";
|
|
28
28
|
|
|
29
29
|
// src/chat/capabilities/router.ts
|
|
30
30
|
var ProviderCredentialRouter = class {
|
|
@@ -18,20 +18,20 @@ import {
|
|
|
18
18
|
releaseConversationWork,
|
|
19
19
|
requestAnotherSlice,
|
|
20
20
|
startConversationWork
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-X2WMBTS3.js";
|
|
22
22
|
import {
|
|
23
23
|
ConversationQueueMessageRejectedError
|
|
24
24
|
} from "./chunk-JAL3CH4G.js";
|
|
25
25
|
import {
|
|
26
26
|
getChatConfig,
|
|
27
27
|
isProviderRetryError
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-MKRIZ4VG.js";
|
|
29
29
|
import {
|
|
30
30
|
logException,
|
|
31
31
|
logInfo,
|
|
32
32
|
logWarn,
|
|
33
33
|
withLogContext
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-B63BF443.js";
|
|
35
35
|
|
|
36
36
|
// src/chat/task-execution/worker.ts
|
|
37
37
|
var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|