@sentry/junior 0.315.0 → 0.317.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-5jUYY46p.js → admin-CAugg87B.js} +1 -1
- package/dist/{agent-runner-C7GNLRB6.js → agent-runner-AjrEV6Qe.js} +13532 -12811
- package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
- package/dist/{agent-update-delivery-BNEYQsAf.js → agent-update-delivery-B_YIZcgf.js} +10 -37
- package/dist/api/schema.d.ts +609 -104
- package/dist/api/schema.js +6 -6
- package/dist/api.js +373 -469
- package/dist/{app-D_bAXRDe.d.ts → app-MoNAsVV5.d.ts} +52 -28
- package/dist/app.d.ts +1 -1
- package/dist/app.js +177 -132
- package/dist/catalog-runtime-DfSpJZdY.js +6 -0
- package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
- package/dist/{adapter-context-BlSGE44V.js → channel-access-j-YAVYK4.js} +2 -42
- package/dist/{chat-core-engine-CxkwRpn9.js → chat-core-engine-aH85nEHv.js} +4 -3
- package/dist/{child-message--2G3Ft26.js → child-message-DHjQLEd1.js} +1 -1
- package/dist/cli/chat.js +23 -23
- 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 +5 -2
- package/dist/cli/upgrade.js +27 -5
- package/dist/config-CHQ8X251.js +2422 -0
- package/dist/{continue-in-slack-BGKjIdFp.js → continue-in-slack-D-FZ8Fin.js} +2 -3
- package/dist/{conversation-feed-Sl8lKKmR.js → conversation-feed--9S0_PXL.js} +9 -4
- package/dist/{proxy-path-Dc-0jXGi.js → conversation-privacy-B1uXn5sf.js} +2 -16
- package/dist/{conversation-turn-BoLK9i6g.js → conversation-turn-BUE_7xaN.js} +102 -172
- package/dist/{create-BOycVH9h.js → create-DoDIYgtZ.js} +12 -10
- package/dist/{credential-sync-Mn4OdkEh.js → credential-sync-BJOqGnjV.js} +17 -12
- package/dist/{db-DXTOYRzR.js → db-BFmyYZtJ.js} +20276 -27398
- package/dist/{deployment-CG3TchWh.js → deployment-DXq9ZLU4.js} +17 -15
- package/dist/{engine-context-dyWlfNdD.js → engine-context-CgQ7mlHt.js} +264 -50
- package/dist/{html-CfXEwl_h.js → html-B3VKTGbJ.js} +6 -2
- package/dist/instrumentation.js +15 -7
- package/dist/{job-runner-CySgpi9v.js → job-runner-A1lCkybD.js} +397 -22
- package/dist/{lineage-tRTOcrsL.js → lineage-Bktb0UcV.js} +1 -1
- package/dist/{list-DXBz8SYL.js → list-Bxvg5wXf.js} +260 -698
- package/dist/{logging-czs0nqLC.js → logging--smS7XRK.js} +2 -2
- package/dist/{mailbox-turn-79Nv1JXv.js → mailbox-turn-uSXhUFc9.js} +648 -2957
- package/dist/{message-BTox2Cmb.js → message-BNenhsmB.js} +12 -22
- package/dist/{model-input-IRGa98V7.js → model-input-BReSnwHp.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +20 -6
- package/dist/{oauth-callback-server-NXK7AlBp.js → oauth-callback-server-CE4soEIY.js} +2 -2
- package/dist/{oauth-relay-6NBPSpFE.js → oauth-relay-C36gX1gH.js} +2 -2
- package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
- package/dist/{parent-result-Dg6P6roR.js → parent-result-Ck1rFYRQ.js} +93 -106
- package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
- package/dist/profile-BQ-iBDsZ.js +4657 -0
- package/dist/{transcript-BHhJVY0P.js → prompt-Dv7gkpD6.js} +97 -103
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/registry-iXMT5Jmh.js +3279 -0
- package/dist/reports-WKHfGTsU.js +195 -0
- package/dist/{resolve-BUFkmxkT.js → resolve-tony4ibz.js} +9 -29
- package/dist/{result-DfATzX77.js → result-Bta_dlWa.js} +42 -117
- package/dist/run-conversation-DL6ru7iW.js +336 -0
- package/dist/{runner-CmKP3inb.js → runner-BstDRbD9.js} +7 -7
- package/dist/{sandbox-egress-signals-DYo5BsM7.js → sandbox-egress-signals-oSJMJOnn.js} +1 -1
- package/dist/{schema-DrBMdPmv.js → schema-DfqrHACA.js} +67 -84
- package/dist/sender-actors-CPglLd5R.js +83 -0
- package/dist/{service-account-CxTX7nnR.js → service-account-CTV_jaNu.js} +3 -1
- package/dist/{skills-BlHUDj7k.js → skills-BCEU41zM.js} +4 -4
- package/dist/{slack-conversation-unfurl-Dhe3lB1U.js → slack-conversation-unfurl-DxVmhbGP.js} +7 -6
- package/dist/{spawn-CfvlFdfz.js → spawn-frczVPIr.js} +11 -8
- package/dist/{system-prompt-table-CDCYVwqN.js → system-prompt-table-CiXy0eNR.js} +91 -70
- package/dist/{task-runner-DcdQJd9e.js → task-runner-C9Yc2_ae.js} +35 -49
- package/dist/{thread-context-DF5uDcWN.js → thread-context-CqZDKErp.js} +6 -6
- package/dist/topics-SRN7IVX-.js +24 -0
- package/dist/turn-membership-CENFf3kI.js +856 -0
- package/dist/{turn-wake-um5Ubd4m.js → turn-wake-BhloiI2h.js} +4 -5
- package/dist/{media-Cr9pGkzr.js → types-C4iC-IMC.js} +819 -777
- package/dist/user-customization-CvfuY9Eo.js +93 -0
- package/dist/users-ByG5RCEJ.js +181 -0
- package/dist/{validation-CJyuOPD2.js → validation-8gjfR91V.js} +1 -1
- package/dist/{version-Bhe7RPIe.js → version-BeZhWWBE.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-D8PRgUqr.js → worker-BqMQQNRk.js} +5 -4
- package/migrations/20261125171254_conversation_visibility/migration.sql +4 -0
- package/migrations/20261125171254_conversation_visibility/snapshot.json +67 -0
- package/migrations/20261125171257_conversation_visibility_backfill/migration.sql +25 -0
- package/migrations/20261125171257_conversation_visibility_backfill/snapshot.json +9 -0
- package/migrations/20261125213232_drop_versions_notify/migration.sql +19 -0
- package/migrations/20261125213232_drop_versions_notify/snapshot.json +9 -0
- package/migrations/20261125225138_conversation_kind_root_thread/migration.sql +23 -0
- package/migrations/20261125225138_conversation_kind_root_thread/snapshot.json +55 -0
- package/migrations/20261125225142_conversation_kind_root_thread_backfill/migration.sql +7 -0
- package/migrations/20261125225142_conversation_kind_root_thread_backfill/snapshot.json +9 -0
- package/migrations/20261126000151_conversation_event_message_role_seq_index/migration.sql +1 -0
- package/migrations/20261126000151_conversation_event_message_role_seq_index/snapshot.json +69 -0
- package/migrations/20261126012917_merge_leaves/migration.sql +2 -0
- package/migrations/20261126012917_merge_leaves/snapshot.json +12 -0
- 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/package.json +5 -5
- package/skills/jr-rpc/SKILL.md +3 -5
- package/dist/direct-url-BYgYfuIy.js +0 -22
- package/dist/markers-CE0HMXWT.js +0 -67
- package/dist/people-Cegp1Iwq.js +0 -81
- package/dist/start-conversation-Uh8Sk1EF.js +0 -162
- package/dist/turn-session-routing-GtetHsdO.js +0 -1309
- package/dist/user-customization-B27StpVQ.js +0 -9
- package/dist/web-message-id-C6P83ans.js +0 -10
package/skills/jr-rpc/SKILL.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: jr-rpc
|
|
3
|
-
description:
|
|
3
|
+
description: Read low-level config and list installed plugins via jr-rpc bash commands. Use only when the user explicitly asks to read provider defaults/config or list installed plugins. Do not use for PR, branch, push, or auth-order questions; load the matching provider skill instead.
|
|
4
4
|
allowed-tools: bash
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# jr-rpc
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Read low-level config and list installed plugins for the current agent turn.
|
|
10
10
|
|
|
11
11
|
## Plugins
|
|
12
12
|
|
|
@@ -18,13 +18,11 @@ Command syntax:
|
|
|
18
18
|
|
|
19
19
|
## Configuration
|
|
20
20
|
|
|
21
|
-
`jr-rpc config get|
|
|
21
|
+
`jr-rpc config get|list` — read the configuration of the conversation's Slack channel and Space. A Space's value wins over the channel's. Change a value with the `setConfiguration` tool.
|
|
22
22
|
|
|
23
23
|
Command syntax:
|
|
24
24
|
|
|
25
25
|
- `jr-rpc config get <key>`
|
|
26
|
-
- `jr-rpc config set <key> <value> [--json]`
|
|
27
|
-
- `jr-rpc config unset <key>`
|
|
28
26
|
- `jr-rpc config list [--prefix <value>]`
|
|
29
27
|
|
|
30
28
|
Rules:
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/db/direct-url.ts
|
|
2
|
-
const NEON_POOLER_SUFFIX = "-pooler";
|
|
3
|
-
/**
|
|
4
|
-
* Pick the database URL for work that needs its own Postgres session, such as
|
|
5
|
-
* the `junior upgrade` migration lock or a `LISTEN`.
|
|
6
|
-
*
|
|
7
|
-
* A transaction-mode pooler, such as Neon's `-pooler` endpoint, shares one
|
|
8
|
-
* server session between clients. It keeps a session advisory lock after the
|
|
9
|
-
* client leaves, and it does not support `LISTEN`. For Neon, use the
|
|
10
|
-
* `DATABASE_URL` host without the `-pooler` suffix. The direct endpoint takes
|
|
11
|
-
* the same user, password, database, and parameters, so it always reaches the
|
|
12
|
-
* database that `DATABASE_URL` names.
|
|
13
|
-
*/
|
|
14
|
-
function readDirectDatabaseUrl(databaseUrl) {
|
|
15
|
-
if (!URL.canParse(databaseUrl)) return databaseUrl;
|
|
16
|
-
const url = new URL(databaseUrl);
|
|
17
|
-
const [endpoint, ...domain] = url.hostname.split(".");
|
|
18
|
-
if (!endpoint?.endsWith(NEON_POOLER_SUFFIX) || !url.hostname.endsWith(".neon.tech")) return databaseUrl;
|
|
19
|
-
url.hostname = [endpoint.slice(0, -7), ...domain].join(".");
|
|
20
|
-
return url.toString();
|
|
21
|
-
}
|
|
22
|
-
export { readDirectDatabaseUrl as t };
|
package/dist/markers-CE0HMXWT.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { b as readAgentConfig, dn as getConversationWorkState } from "./mailbox-turn-79Nv1JXv.js";
|
|
2
|
-
import { n as getConversationEventStore, o as getSqlExecutor, uu as juniorConversationEvents } from "./db-DXTOYRzR.js";
|
|
3
|
-
import { b as readChildConversationSender } from "./parent-result-Dg6P6roR.js";
|
|
4
|
-
import { and, eq, inArray } from "drizzle-orm";
|
|
5
|
-
// src/chat/agent-invocations/markers.ts
|
|
6
|
-
const SUBAGENT_KIND = "agent";
|
|
7
|
-
const SUBAGENT_STARTED_KEY_PREFIX = "subagent_started:";
|
|
8
|
-
const SUBAGENT_ENDED_KEY_PREFIX = "subagent_ended:";
|
|
9
|
-
/**
|
|
10
|
-
* Record in the parent Conversation that a child agent got one task or
|
|
11
|
-
* message. Write it before the input reaches the child's mailbox, so the
|
|
12
|
-
* child cannot end first.
|
|
13
|
-
*/
|
|
14
|
-
async function recordSubagentStartedMarker(start) {
|
|
15
|
-
await getConversationEventStore().append(start.parentConversationId, [{
|
|
16
|
-
idempotencyKey: `${SUBAGENT_STARTED_KEY_PREFIX}${start.markerId}`,
|
|
17
|
-
data: {
|
|
18
|
-
type: "subagent_started",
|
|
19
|
-
subagentInvocationId: start.markerId,
|
|
20
|
-
subagentKind: SUBAGENT_KIND,
|
|
21
|
-
childConversationId: start.childConversationId,
|
|
22
|
-
...start.agentName ? { agentName: start.agentName } : void 0,
|
|
23
|
-
parentToolCallId: start.parentToolCallId,
|
|
24
|
-
task: start.input,
|
|
25
|
-
...start.title ? { title: start.title } : void 0,
|
|
26
|
-
...start.reasoningLevel ? { reasoningLevel: start.reasoningLevel } : void 0
|
|
27
|
-
},
|
|
28
|
-
createdAtMs: start.createdAtMs
|
|
29
|
-
}]);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Record in the parent Conversation how the work of a child agent ended.
|
|
33
|
-
* Each parent message has its own `subagent_started` marker, named by the
|
|
34
|
-
* message id, and each one that the child already took ends with `outcome`.
|
|
35
|
-
* A parent message that still waits in the child's mailbox stays open,
|
|
36
|
-
* because later work reads it, unless `includeWaiting` is set, as for a stop
|
|
37
|
-
* that skips it. Write it before the child's result reaches the parent.
|
|
38
|
-
*/
|
|
39
|
-
async function recordChildAgentEnded(childConversationId, outcome, options = {}) {
|
|
40
|
-
if (!await readAgentConfig(childConversationId)) return;
|
|
41
|
-
const work = await getConversationWorkState({
|
|
42
|
-
conversationId: childConversationId,
|
|
43
|
-
state: options.state
|
|
44
|
-
});
|
|
45
|
-
const running = new Set(work?.runningInboundMessageIds);
|
|
46
|
-
const waiting = new Set(options.includeWaiting ? [] : (work?.messages ?? []).map((message) => message.inboundMessageId).filter((id) => !running.has(id)));
|
|
47
|
-
const taken = (work?.execution.inboundMessageIds ?? []).filter((id) => !waiting.has(id));
|
|
48
|
-
if (taken.length === 0) return;
|
|
49
|
-
const sender = await readChildConversationSender(childConversationId);
|
|
50
|
-
if (!sender) return;
|
|
51
|
-
const keys = await getSqlExecutor().db().select({ idempotencyKey: juniorConversationEvents.idempotencyKey }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, sender.parentConversationId), inArray(juniorConversationEvents.idempotencyKey, taken.flatMap((id) => [`${SUBAGENT_STARTED_KEY_PREFIX}${id}`, `${SUBAGENT_ENDED_KEY_PREFIX}${id}`]))));
|
|
52
|
-
const found = new Set(keys.map((row) => row.idempotencyKey));
|
|
53
|
-
const open = taken.filter((id) => found.has(`${SUBAGENT_STARTED_KEY_PREFIX}${id}`) && !found.has(`${SUBAGENT_ENDED_KEY_PREFIX}${id}`));
|
|
54
|
-
if (open.length > 0) await appendSubagentEnded(sender.parentConversationId, open, outcome, options.nowMs ?? Date.now());
|
|
55
|
-
}
|
|
56
|
-
async function appendSubagentEnded(parentConversationId, markerIds, outcome, createdAtMs) {
|
|
57
|
-
await getConversationEventStore().append(parentConversationId, markerIds.map((id) => ({
|
|
58
|
-
idempotencyKey: `${SUBAGENT_ENDED_KEY_PREFIX}${id}`,
|
|
59
|
-
data: {
|
|
60
|
-
type: "subagent_ended",
|
|
61
|
-
subagentInvocationId: id,
|
|
62
|
-
outcome
|
|
63
|
-
},
|
|
64
|
-
createdAtMs
|
|
65
|
-
})));
|
|
66
|
-
}
|
|
67
|
-
export { recordSubagentStartedMarker as n, recordChildAgentEnded as t };
|
package/dist/people-Cegp1Iwq.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { V as slackMention, o as getSqlExecutor, wu as juniorIdentities } from "./db-DXTOYRzR.js";
|
|
2
|
-
import { N as normalizeIdentityEmail } from "./logging-czs0nqLC.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, Ed as readPrivateSlackFile, Od as streamPrivateSlackFile, Uu as agentWatch, Wt as isPersonInput, _d as SlackActionError, bo as getDashboardConversationLink, hc as conversationDetailTouch, qd as ToolInputError, vu as juniorAttachments } from "./db-DXTOYRzR.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-GtetHsdO.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 };
|