@sentry/junior 0.316.0 → 0.318.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/{admin-QYiDMnsu.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-Cr5Fhjf-.js → agent-runner-DeYymwh2.js} +13494 -13135
- package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
- package/dist/{agent-update-delivery-BY13DPSD.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +600 -130
- package/dist/api/schema.js +6 -6
- package/dist/api.js +228 -214
- package/dist/{app-BhvzRD__.d.ts → app-DKAOuaoC.d.ts} +33 -18
- package/dist/app.d.ts +1 -1
- package/dist/app.js +193 -177
- package/dist/{thread-context-fiMNylbg.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/catalog-runtime-BfdAnztW.js +6 -0
- package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
- package/dist/{adapter-context-Bref7aPI.js → channel-access-A0de5lRv.js} +2 -42
- package/dist/{chat-core-engine-3dtlMku3.js → chat-core-engine-D3Wd7f5n.js} +6 -5
- package/dist/{child-message--2G3Ft26.js → child-message-peFWLcCZ.js} +2 -6
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -4
- package/dist/cli/snapshot-create.js +4 -2
- package/dist/cli/upgrade.js +5 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-DbQUFe_F.js → continue-in-slack-YxwMQVeR.js} +3 -3
- package/dist/{conversation-feed-B84pMjHo.js → conversation-feed-Cj7IuBtM.js} +3 -3
- package/dist/{proxy-path-BTmXDjfx.js → conversation-privacy-Cr_dNW1p.js} +2 -16
- package/dist/{conversation-turn-DzEpTIaf.js → conversation-turn-Bru4w_FD.js} +196 -80
- package/dist/{create-DUJBXr6E.js → create-Btl1y1rq.js} +12 -11
- package/dist/{credential-sync-JH_K9Adg.js → credential-sync-DTarZ63K.js} +20 -15
- package/dist/{db-DhzvUY23.js → db-of6e3sGt.js} +20724 -27256
- package/dist/{deployment-BhvrhQeh.js → deployment-C0qXa0FD.js} +17 -15
- package/dist/{engine-context-C9Nal48K.js → engine-context-C_QL_bMQ.js} +304 -56
- package/dist/{html-B_12WjKT.js → html-9_pS9SjY.js} +6 -2
- package/dist/instrumentation.js +15 -7
- package/dist/{job-runner-DO8nslyY.js → job-runner-B2XEvpif.js} +392 -26
- package/dist/{lineage-D3AZAJVe.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-B0zsb5Cp.js → list-HRP3TIRl.js} +238 -550
- package/dist/{logging-B8KEJegM.js → logging-BnOG0qz2.js} +4 -50
- package/dist/{session-stop-DponjDUZ.js → mailbox-turn-Byrry9o1.js} +4807 -7102
- package/dist/{list-mkB_GU8R.js → markers-CTTtJqYn.js} +171 -124
- package/dist/{message-B5fKDYzz.js → message-BRUuLgrY.js} +13 -24
- package/dist/{model-input-CuMWy37l.js → model-input-CFC62mf-.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +21 -7
- package/dist/{oauth-callback-server-B3Vvlydo.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-6ERrGPbA.js → oauth-relay-BvHFH0fV.js} +2 -2
- package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
- package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
- package/dist/profile-iHw1uu32.js +4657 -0
- package/dist/{transcript-CCi7323k.js → prompt-DEkStuxG.js} +92 -98
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/registry-Cl7Labpe.js +3279 -0
- package/dist/reports-C1d9azyV.js +195 -0
- package/dist/{resolve-D5JVvv6A.js → resolve-DC6zBuDV.js} +9 -29
- package/dist/{result-CS_7mo8a.js → result-DxewDuXb.js} +27 -118
- package/dist/run-conversation-Cz2ubZK-.js +337 -0
- package/dist/{runner-BzAES5W3.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-Dwhk2Q5F.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-z5-wA6N4.js → schema-BTojNBr5.js} +48 -86
- package/dist/sender-actors-77zTQbSG.js +84 -0
- package/dist/{service-account-D6AsAtc1.js → service-account-YDCPSByj.js} +3 -1
- package/dist/{skills-DgJ9GBPR.js → skills-CleC0Hze.js} +6 -5
- package/dist/{slack-conversation-unfurl-Dq71EkhM.js → slack-conversation-unfurl-BNQLC12R.js} +7 -6
- package/dist/{spawn-BJWpdwhQ.js → spawn-DuZfodPa.js} +5 -5
- package/dist/{system-prompt-table-iIgpmslr.js → system-prompt-table-Ci6Ck4gk.js} +88 -69
- package/dist/{task-runner-BJae4JwE.js → task-runner-BJ9Up3bG.js} +30 -53
- package/dist/topics-BoCkoPJJ.js +21 -0
- package/dist/turn-membership-VT7XZh-L.js +856 -0
- package/dist/{turn-wake-BjDW7x-5.js → turn-wake-C7HeLHAM.js} +3 -4
- package/dist/{media-BebquhET.js → types-DCzTAA63.js} +629 -593
- package/dist/user-customization-CvfuY9Eo.js +93 -0
- package/dist/users-Cb9c1k9q.js +181 -0
- package/dist/{validation-D5WmmmhX.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-CBQoanXb.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-Cyb4kF17.js → worker-ChWYQdhm.js} +5 -4
- package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
- package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
- package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
- package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
- package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
- package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
- package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
- package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
- package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
- package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
- package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
- package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
- package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
- package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
- package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
- package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
- package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
- package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
- package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
- package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
- package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
- package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
- package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
- package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
- package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
- package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
- package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
- package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
- package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
- package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/package.json +5 -5
- package/dist/people-CUtFApfL.js +0 -81
- package/dist/start-conversation-B-LIqqNi.js +0 -162
- package/dist/turn-session-routing-D15orfwy.js +0 -1309
- package/dist/user-customization-B27StpVQ.js +0 -9
- package/dist/web-message-id-C6P83ans.js +0 -10
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "diff",
|
|
3
|
+
"version": "10",
|
|
4
|
+
"dialect": "postgres",
|
|
5
|
+
"id": "811305d1-7881-43e6-9f0c-280f35526253",
|
|
6
|
+
"prevIds": ["69888e8a-0d59-4095-b43a-c3e1ba2c6cc1"],
|
|
7
|
+
"footprints": [
|
|
8
|
+
{
|
|
9
|
+
"statementType": "add_column",
|
|
10
|
+
"statementTarget": [
|
|
11
|
+
"column",
|
|
12
|
+
"public",
|
|
13
|
+
"junior_turns",
|
|
14
|
+
"discarded_cost_micro_usd"
|
|
15
|
+
],
|
|
16
|
+
"writes": [
|
|
17
|
+
"s|col|public.junior_turns.discarded_cost_micro_usd",
|
|
18
|
+
"n|col|public.junior_turns.discarded_cost_micro_usd",
|
|
19
|
+
"e|col|public.junior_turns.discarded_cost_micro_usd"
|
|
20
|
+
],
|
|
21
|
+
"reads": ["n|tbl|public.junior_turns", "n|sch|public"]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"statementType": "add_column",
|
|
25
|
+
"statementTarget": [
|
|
26
|
+
"column",
|
|
27
|
+
"public",
|
|
28
|
+
"junior_turns",
|
|
29
|
+
"discarded_tokens"
|
|
30
|
+
],
|
|
31
|
+
"writes": [
|
|
32
|
+
"s|col|public.junior_turns.discarded_tokens",
|
|
33
|
+
"n|col|public.junior_turns.discarded_tokens",
|
|
34
|
+
"e|col|public.junior_turns.discarded_tokens"
|
|
35
|
+
],
|
|
36
|
+
"reads": ["n|tbl|public.junior_turns", "n|sch|public"]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"deltas": [
|
|
40
|
+
{
|
|
41
|
+
"op": "create",
|
|
42
|
+
"row": {
|
|
43
|
+
"schema": "public",
|
|
44
|
+
"table": "junior_turns",
|
|
45
|
+
"name": "discarded_cost_micro_usd",
|
|
46
|
+
"type": "bigint",
|
|
47
|
+
"typeSchema": null,
|
|
48
|
+
"notNull": true,
|
|
49
|
+
"dimensions": 0,
|
|
50
|
+
"default": "0",
|
|
51
|
+
"generated": null,
|
|
52
|
+
"identity": null,
|
|
53
|
+
"entityType": "columns"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"op": "create",
|
|
58
|
+
"row": {
|
|
59
|
+
"schema": "public",
|
|
60
|
+
"table": "junior_turns",
|
|
61
|
+
"name": "discarded_tokens",
|
|
62
|
+
"type": "jsonb",
|
|
63
|
+
"typeSchema": null,
|
|
64
|
+
"notNull": false,
|
|
65
|
+
"dimensions": 0,
|
|
66
|
+
"default": null,
|
|
67
|
+
"generated": null,
|
|
68
|
+
"identity": null,
|
|
69
|
+
"entityType": "columns"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.318.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
66
66
|
"@neondatabase/serverless": "^1.1.0",
|
|
67
67
|
"@sentry/api": "2.16.0",
|
|
68
|
-
"@sentry/junior-plugin-api": "0.
|
|
68
|
+
"@sentry/junior-plugin-api": "0.318.0",
|
|
69
69
|
"@sentry/nitro": "11.16.0",
|
|
70
70
|
"@sentry/node": "11.16.0",
|
|
71
71
|
"@sentry/server-utils": "11.16.0",
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
"@emnapi/core": "^1.10.0",
|
|
110
110
|
"@emnapi/runtime": "^1.10.0",
|
|
111
111
|
"@hono/node-server": "2.1.3",
|
|
112
|
-
"@sentry/junior-github": "0.
|
|
113
|
-
"@sentry/junior-notion": "0.
|
|
114
|
-
"@sentry/junior-sentry": "0.
|
|
112
|
+
"@sentry/junior-github": "0.318.0",
|
|
113
|
+
"@sentry/junior-notion": "0.318.0",
|
|
114
|
+
"@sentry/junior-sentry": "0.318.0",
|
|
115
115
|
"@sentry/junior-testing": "0.0.0",
|
|
116
116
|
"@types/node": "^24.19.2",
|
|
117
117
|
"@types/pg": "^8.15.6",
|
package/dist/people-CUtFApfL.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { V as slackMention, ku as juniorIdentities, o as getSqlExecutor } from "./db-DhzvUY23.js";
|
|
2
|
-
import { N as normalizeIdentityEmail } from "./logging-B8KEJegM.js";
|
|
3
|
-
import { and, eq, inArray, or, sql } from "drizzle-orm";
|
|
4
|
-
import { alias } from "drizzle-orm/pg-core";
|
|
5
|
-
// src/chat/events/people.ts
|
|
6
|
-
const linkedSlackIdentity = alias(juniorIdentities, "event_people_slack");
|
|
7
|
-
function personKey(person) {
|
|
8
|
-
return "email" in person ? `email:${normalizeIdentityEmail(person.email)}` : `${person.provider}:${person.handle.toLowerCase()}`;
|
|
9
|
-
}
|
|
10
|
-
function personCondition(person) {
|
|
11
|
-
if ("email" in person) return and(eq(juniorIdentities.emailVerified, true), eq(juniorIdentities.emailNormalized, normalizeIdentityEmail(person.email)));
|
|
12
|
-
return and(eq(juniorIdentities.provider, person.provider), sql`lower(${juniorIdentities.handle}) = lower(${person.handle})`);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Read the Slack users in one workspace whose linked User has an identity that
|
|
16
|
-
* matches `condition`, by person key. A key with more than one Slack user is
|
|
17
|
-
* ambiguous, so callers must not mention it.
|
|
18
|
-
*/
|
|
19
|
-
async function readLinkedSlackUsers(condition, slackTeamId) {
|
|
20
|
-
const rows = await getSqlExecutor().db().select({
|
|
21
|
-
emailNormalized: juniorIdentities.emailNormalized,
|
|
22
|
-
emailVerified: juniorIdentities.emailVerified,
|
|
23
|
-
handle: juniorIdentities.handle,
|
|
24
|
-
provider: juniorIdentities.provider,
|
|
25
|
-
slackUserId: linkedSlackIdentity.providerSubjectId
|
|
26
|
-
}).from(juniorIdentities).innerJoin(linkedSlackIdentity, and(eq(linkedSlackIdentity.userId, juniorIdentities.userId), eq(linkedSlackIdentity.kind, "user"), eq(linkedSlackIdentity.provider, "slack"), eq(linkedSlackIdentity.providerTenantId, slackTeamId))).where(and(eq(juniorIdentities.kind, "user"), condition));
|
|
27
|
-
const slackUsersByKey = /* @__PURE__ */ new Map();
|
|
28
|
-
const add = (key, slackUserId) => {
|
|
29
|
-
const users = slackUsersByKey.get(key) ?? /* @__PURE__ */ new Set();
|
|
30
|
-
users.add(slackUserId);
|
|
31
|
-
slackUsersByKey.set(key, users);
|
|
32
|
-
};
|
|
33
|
-
for (const row of rows) {
|
|
34
|
-
if (row.handle) add(`${row.provider}:${row.handle.toLowerCase()}`, row.slackUserId);
|
|
35
|
-
if (row.emailVerified && row.emailNormalized) add(`email:${row.emailNormalized}`, row.slackUserId);
|
|
36
|
-
}
|
|
37
|
-
return slackUsersByKey;
|
|
38
|
-
}
|
|
39
|
-
function soleMention(users) {
|
|
40
|
-
return users?.size === 1 ? slackMention([...users][0]) : void 0;
|
|
41
|
-
}
|
|
42
|
-
const HANDLE_MENTION_PATTERN = /(?<![\w.@/-])@([A-Za-z0-9][A-Za-z0-9_.-]*[A-Za-z0-9]|[A-Za-z0-9])/g;
|
|
43
|
-
const MAX_REPLY_HANDLES = 50;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the `@handle` words in reply text to Slack mentions of known people
|
|
46
|
-
* in one Slack workspace, by `provider:handle` key in lowercase. A handle
|
|
47
|
-
* resolves only when exactly one linked Slack user has it for that provider.
|
|
48
|
-
* Plugins pick the provider when they format the reply.
|
|
49
|
-
*/
|
|
50
|
-
async function resolveHandleMentions(text, slackTeamId) {
|
|
51
|
-
const handles = [...new Set([...text.matchAll(HANDLE_MENTION_PATTERN)].map((match) => match[1].toLowerCase()))].slice(0, MAX_REPLY_HANDLES);
|
|
52
|
-
if (handles.length === 0) return /* @__PURE__ */ new Map();
|
|
53
|
-
const slackUsersByKey = await readLinkedSlackUsers(inArray(sql`lower(${juniorIdentities.handle})`, handles), slackTeamId);
|
|
54
|
-
const mentions = /* @__PURE__ */ new Map();
|
|
55
|
-
for (const [key, users] of slackUsersByKey) {
|
|
56
|
-
const mention = soleMention(users);
|
|
57
|
-
if (mention && !key.startsWith("email:")) mentions.set(key, mention);
|
|
58
|
-
}
|
|
59
|
-
return mentions;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Resolve the Event people to Slack mentions through linked user identities
|
|
63
|
-
* in one Slack workspace, with one query. Returns them in input order, with
|
|
64
|
-
* no duplicates.
|
|
65
|
-
*
|
|
66
|
-
* A person resolves only when exactly one linked Slack user in that workspace
|
|
67
|
-
* matches. Core drops unlinked and ambiguous people, so a provider value never
|
|
68
|
-
* guesses a mention. The Event author is not resolved here: a handle can be
|
|
69
|
-
* renamed or reused, so only the trust decision names the author.
|
|
70
|
-
*/
|
|
71
|
-
async function resolveEventMentions(people, slackTeamId) {
|
|
72
|
-
if (people.length === 0) return [];
|
|
73
|
-
const slackUsersByKey = await readLinkedSlackUsers(or(...people.map(personCondition)), slackTeamId);
|
|
74
|
-
const mentions = [];
|
|
75
|
-
for (const person of people) {
|
|
76
|
-
const mention = soleMention(slackUsersByKey.get(personKey(person)));
|
|
77
|
-
if (mention && !mentions.includes(mention)) mentions.push(mention);
|
|
78
|
-
}
|
|
79
|
-
return mentions;
|
|
80
|
-
}
|
|
81
|
-
export { resolveHandleMentions as n, resolveEventMentions as t };
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { $i as getVercelConversationWorkQueue, Ad as readPrivateSlackFile, Bl as conversationDetailTouch, Cu as juniorAttachments, Ju as agentWatch, Md as streamPrivateSlackFile, Wt as isPersonInput, Zd as ToolInputError, bo as getDashboardConversationLink, xd as SlackActionError } from "./db-DhzvUY23.js";
|
|
2
|
-
import { A as fileFields, B as zodToolDefinition, H as juniorToolOutputSchema, L as AttachmentSourceUnavailableError, h as webActorFromUser, o as readLeadSpace, p as createConversationId, u as appendAndEnqueueWebMessage, z as zodTool } from "./turn-session-routing-D15orfwy.js";
|
|
3
|
-
import * as z from "zod";
|
|
4
|
-
import { subscribableResourceSchema } from "@sentry/junior-plugin-api";
|
|
5
|
-
import { and, eq, inArray, isNull, sql } from "drizzle-orm";
|
|
6
|
-
// src/chat/slack/attachments.ts
|
|
7
|
-
/** Save the vision summary for a stored Slack attachment. */
|
|
8
|
-
async function recordSlackAttachment(args) {
|
|
9
|
-
const db = args.db.db();
|
|
10
|
-
await db.with(conversationDetailTouch(db, [args.conversationId])).update(juniorAttachments).set({ visionSummary: args.visionSummary }).where(and(eq(juniorAttachments.id, args.attachmentId), eq(juniorAttachments.conversationId, args.conversationId), isNull(juniorAttachments.deleteRequestedAt)));
|
|
11
|
-
}
|
|
12
|
-
/** Read a saved vision summary for one live attachment. */
|
|
13
|
-
async function readAttachmentVisionSummary(args) {
|
|
14
|
-
const [row] = await args.db.db().select({ visionSummary: juniorAttachments.visionSummary }).from(juniorAttachments).where(and(eq(juniorAttachments.id, args.attachmentId), eq(juniorAttachments.conversationId, args.conversationId), isNull(juniorAttachments.deleteRequestedAt)));
|
|
15
|
-
return row?.visionSummary;
|
|
16
|
-
}
|
|
17
|
-
/** Match live conversation attachments to Slack file ids. */
|
|
18
|
-
async function matchSlackAttachments(args) {
|
|
19
|
-
if (args.providerIds.length === 0) return [];
|
|
20
|
-
return (await args.db.db().select({
|
|
21
|
-
id: juniorAttachments.id,
|
|
22
|
-
providerId: juniorAttachments.providerId,
|
|
23
|
-
bytes: juniorAttachments.bytes,
|
|
24
|
-
contentType: juniorAttachments.contentType,
|
|
25
|
-
storageKey: juniorAttachments.storageKey,
|
|
26
|
-
storageProvider: juniorAttachments.storageProvider,
|
|
27
|
-
title: juniorAttachments.title
|
|
28
|
-
}).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, args.conversationId), eq(juniorAttachments.provider, "slack"), inArray(juniorAttachments.providerId, args.providerIds), isNull(juniorAttachments.deleteRequestedAt)))).map((row) => {
|
|
29
|
-
const { bytes, contentType, filename } = fileFields(row);
|
|
30
|
-
const attachment = {
|
|
31
|
-
bytes,
|
|
32
|
-
contentType,
|
|
33
|
-
filename,
|
|
34
|
-
id: row.id,
|
|
35
|
-
providerId: row.providerId
|
|
36
|
-
};
|
|
37
|
-
return row.storageKey === null ? {
|
|
38
|
-
...attachment,
|
|
39
|
-
pending: true
|
|
40
|
-
} : attachment;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Fingerprint the live Slack attachments that `matchSlackAttachments` can
|
|
45
|
-
* return for a Conversation. It changes when one is recorded, stored, or
|
|
46
|
-
* deleted, so a reader can tell that stored messages may now show other
|
|
47
|
-
* files, or a file that is no longer pending.
|
|
48
|
-
*/
|
|
49
|
-
function slackAttachmentsVersionQuery(db, conversationId) {
|
|
50
|
-
return db.select({ version: sql`coalesce(md5(string_agg(concat(${juniorAttachments.id}, ':', ${juniorAttachments.storageKey} is null), ',' order by ${juniorAttachments.id})), '')` }).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, conversationId), eq(juniorAttachments.provider, "slack"), isNull(juniorAttachments.deleteRequestedAt)));
|
|
51
|
-
}
|
|
52
|
-
/** Read the Slack file identity retained by the Chat SDK. */
|
|
53
|
-
function getSlackFileId(attachment) {
|
|
54
|
-
const metadataId = attachment.fetchMetadata?.["fileId"];
|
|
55
|
-
if (metadataId) return metadataId;
|
|
56
|
-
return (attachment.url ?? attachment.fetchMetadata?.["url"] ?? "").match(/(?:^|[-/])(F[A-Z0-9]+)(?:[-/]|$)/)?.[1];
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Look up a Slack file that Junior recorded without storing it yet.
|
|
60
|
-
*
|
|
61
|
-
* Uses the installation token that the caller binds: the Slack turn, or the
|
|
62
|
-
* dashboard route for the conversation's Slack team.
|
|
63
|
-
*/
|
|
64
|
-
const readSlackAttachmentSource = async (source) => {
|
|
65
|
-
const unavailable = (cause) => new AttachmentSourceUnavailableError("The Slack file was deleted, or this app can no longer access it.", { cause });
|
|
66
|
-
if (source.provider !== "slack") throw unavailable();
|
|
67
|
-
const file = await readPrivateSlackFile(source.id);
|
|
68
|
-
if (!file) throw unavailable();
|
|
69
|
-
return {
|
|
70
|
-
bytes: file.bytes,
|
|
71
|
-
open: async () => {
|
|
72
|
-
try {
|
|
73
|
-
return await streamPrivateSlackFile(file.url);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (error instanceof SlackActionError && (error.code === "not_found" || error.statusCode === 403)) throw unavailable(error);
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
// src/chat/lead/start-conversation.ts
|
|
82
|
-
/**
|
|
83
|
-
* Create the Conversation and enqueue the task as its first Message. Repeat
|
|
84
|
-
* calls with the same `messageKey` are safe.
|
|
85
|
-
*/
|
|
86
|
-
async function startLeadConversation(args) {
|
|
87
|
-
const space = await readLeadSpace(args.leadConversationId);
|
|
88
|
-
if (!space) throw new Error("Only a Space's Lead can start a Conversation");
|
|
89
|
-
const idempotencyKey = `lead:${args.leadConversationId}:${args.messageKey}`;
|
|
90
|
-
const conversationId = createConversationId({
|
|
91
|
-
actorEmail: args.person.email,
|
|
92
|
-
idempotencyKey
|
|
93
|
-
});
|
|
94
|
-
await appendAndEnqueueWebMessage({
|
|
95
|
-
actor: webActorFromUser(args.person),
|
|
96
|
-
conversationId,
|
|
97
|
-
idempotencyKey,
|
|
98
|
-
message: args.task,
|
|
99
|
-
rootSpaceId: space.id,
|
|
100
|
-
rootTitle: args.title,
|
|
101
|
-
rootVisibility: space.visibility
|
|
102
|
-
}, {
|
|
103
|
-
nowMs: Date.now(),
|
|
104
|
-
queue: args.queue
|
|
105
|
-
});
|
|
106
|
-
return { conversationId };
|
|
107
|
-
}
|
|
108
|
-
// src/chat/tools/start-conversation.ts
|
|
109
|
-
/** Static definition of `startConversation`, which only a Lead lists. */
|
|
110
|
-
const startConversationToolDefinition = zodToolDefinition({
|
|
111
|
-
description: [
|
|
112
|
-
"Start a new conversation in this Space that does one piece of the work that the person asked for. It is a public conversation of the person, and it starts at once.",
|
|
113
|
-
"Your task is its first message, and it runs as the person, so write the task as the person's request.",
|
|
114
|
-
"Use messageAgent instead for work that a conversation already does."
|
|
115
|
-
].join(" "),
|
|
116
|
-
exposure: "modelOnly",
|
|
117
|
-
approvalMode: "auto",
|
|
118
|
-
annotations: {
|
|
119
|
-
destructiveHint: false,
|
|
120
|
-
idempotentHint: true,
|
|
121
|
-
openWorldHint: false,
|
|
122
|
-
readOnlyHint: false
|
|
123
|
-
},
|
|
124
|
-
inputSchema: z.object({
|
|
125
|
-
task: z.string().trim().min(1).describe("Self-contained brief for a peer who has not seen this conversation: the goal, the targets, the facts you know, the constraints, and what done means."),
|
|
126
|
-
title: z.string().trim().min(1).max(60).describe("Short display title of the new conversation.")
|
|
127
|
-
}).strict(),
|
|
128
|
-
outputSchema: juniorToolOutputSchema.extend({
|
|
129
|
-
conversation_id: z.string().min(1).describe("ID of the new conversation. Pass it to messageAgent to steer it."),
|
|
130
|
-
url: z.string().url().optional().describe("Link to the new conversation."),
|
|
131
|
-
subscribable: subscribableResourceSchema.describe("Watch it with watchEvents only when the person asks to hear back.")
|
|
132
|
-
})
|
|
133
|
-
});
|
|
134
|
-
/** Create the tool that starts a Conversation from a Lead Turn. */
|
|
135
|
-
function createStartConversationTool(context) {
|
|
136
|
-
return zodTool({
|
|
137
|
-
...startConversationToolDefinition,
|
|
138
|
-
execute: async (input, options) => {
|
|
139
|
-
if (!options.toolCallId || !context.turnId) throw new ToolInputError("startConversation requires an active Turn and tool call ID. No change to the call can fix this.");
|
|
140
|
-
const person = isPersonInput(context.source.kind) ? (await context.resolveActorIdentity?.())?.user : void 0;
|
|
141
|
-
if (!person) throw new ToolInputError("startConversation needs a person: no member asked for this Turn's work. Tell the members what you would start instead.");
|
|
142
|
-
const { conversationId } = await startLeadConversation({
|
|
143
|
-
leadConversationId: context.conversationId,
|
|
144
|
-
messageKey: `${context.turnId}:${options.toolCallId}`,
|
|
145
|
-
person,
|
|
146
|
-
queue: context.conversationWorkQueue ?? getVercelConversationWorkQueue(),
|
|
147
|
-
task: input.task,
|
|
148
|
-
title: input.title
|
|
149
|
-
});
|
|
150
|
-
const url = getDashboardConversationLink(conversationId);
|
|
151
|
-
return {
|
|
152
|
-
conversation_id: conversationId,
|
|
153
|
-
...url ? { url } : void 0,
|
|
154
|
-
subscribable: agentWatch({
|
|
155
|
-
conversationId,
|
|
156
|
-
title: input.title
|
|
157
|
-
})
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
export { readAttachmentVisionSummary as a, slackAttachmentsVersionQuery as c, matchSlackAttachments as i, startConversationToolDefinition as n, readSlackAttachmentSource as o, getSlackFileId as r, recordSlackAttachment as s, createStartConversationTool as t };
|