@sentry/junior 0.312.0 → 0.314.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/{adapter-iIq7ihf7.js → adapter-JARQvoLw.js} +1 -2
- package/dist/{adapter-context-BRjEWRy1.js → adapter-context-B4BrJZuS.js} +2 -2
- package/dist/{admin-DhInw5K9.js → admin-BXGAySz0.js} +1 -1
- package/dist/{agent-runner-C9iDurwX.js → agent-runner-qZU5TR8i.js} +865 -138
- package/dist/agent-update-cS7Z9mnG.js +26 -0
- package/dist/agent-update-delivery-CZ5M8RDa.js +85 -0
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +1 -1
- package/dist/api.js +340 -106
- package/dist/{app-DRFrC8Mw.d.ts → app-D7tKnw9a.d.ts} +4 -21
- package/dist/app.d.ts +2 -2
- package/dist/app.js +80 -171
- package/dist/{background-compaction-queue-DrKi7w3d.js → background-compaction-queue-C_uIBUvS.js} +6 -17
- package/dist/{callback-mFlTUWWx.js → callback-C8SdXCwr.js} +4 -11
- package/dist/{catalog-runtime-D7xapBAX.js → catalog-runtime-BLKtnUL3.js} +1 -1
- package/dist/{channel-access-CJGfNTdn.js → channel-access-BOL29BG3.js} +6 -6
- package/dist/child-message--2G3Ft26.js +19 -0
- package/dist/cli/chat.js +18 -21
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +23 -4
- package/dist/{config-kXB2Y5tl.js → config-BIfHKNXN.js} +40 -35
- package/dist/{continue-in-slack-O6pV5004.js → continue-in-slack-fnmD2Ifb.js} +5 -7
- package/dist/{conversation-feed-uNOv_x68.js → conversation-feed-DdFQuQDR.js} +13 -2
- package/dist/{logging-dQ9ZRGQ8.js → conversation-privacy-DtZhI91r.js} +188 -2
- package/dist/{conversation-turn-CeLbHqdw.js → conversation-turn-DScuDYmN.js} +465 -62
- package/dist/create-CrNt4Ewu.js +212 -0
- package/dist/{credential-sync-I8VBGk05.js → credential-sync-CtqsGjj1.js} +14 -18
- package/dist/{credentialed-Cb6E2phL.js → credentialed-dWRA3-oJ.js} +911 -429
- package/dist/{db-LAyyX8tk.js → db-BTmLKZrp.js} +2245 -50
- package/dist/{db-BbC5stfa.d.ts → db-DcmzbA55.d.ts} +2 -2
- package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
- package/dist/{html-BCZ3Xtb_.js → html-B8rBt7F4.js} +5 -7
- package/dist/{install-DCFJFkC0.js → install-OtFboxOM.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-B_m-4TJw.js → lineage-EULJkGO1.js} +1 -2
- package/dist/{list-CN2QA2R9.js → list-C5400AlJ.js} +284 -113
- package/dist/{thread-state-DhPndWi1.js → mailbox-turn-DL3Lvsm0.js} +4830 -485
- package/dist/markers-DUP8aBOp.js +323 -0
- package/dist/{media-CYm1QD8T.js → media-FYM-Bl3H.js} +42 -14
- package/dist/{message-DSXGj1hM.js → message-DuDelZFr.js} +16 -15
- package/dist/{model-input--TrP9hYV.js → model-input-0osF3pBS.js} +3 -3
- package/dist/nitro.d.ts +2 -4
- package/dist/nitro.js +340 -13
- package/dist/{oauth-callback-server-DHCZC6B4.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
- package/dist/{oauth-relay-pPMGnDZt.js → oauth-relay-PwPMdZJv.js} +1 -1
- package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
- package/dist/{registry-CZOzddwu.js → registry-D6kS6xYH.js} +1402 -64
- package/dist/{statuses-_cRJHXK7.js → reporting-window-C4dbzDiR.js} +1 -27
- package/dist/{resolve-cKOQ14Dh.js → resolve-D8CPJcNK.js} +3 -3
- package/dist/result-D090hxr5.js +402 -0
- package/dist/{runner-DBfUW44l.js → runner-BU7fgrm-.js} +7 -8
- package/dist/{sandbox-egress-signals-BVF_xAm1.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
- package/dist/{schema-Bk9Nm2E8.js → schema-7gW9vBpJ.js} +91 -10
- package/dist/{schema-BEHKxr4I.d.ts → schema-BB6E0wyV.d.ts} +2105 -2753
- package/dist/{service-account-CVYsFjty.js → service-account-plA-uzIB.js} +6 -5
- package/dist/{skills-VTnhAJWm.js → skills-CIosT6bS.js} +3 -3
- package/dist/{slack-conversation-unfurl-fuLnF1jE.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
- package/dist/spawn-DRjdzh3R.js +46 -0
- package/dist/{start-conversation-CEn2KH1A.js → start-conversation-a4NXH4X9.js} +13 -202
- package/dist/{store-DFZaN-Ix.js → store-BuhF1QDm.js} +2 -4
- package/dist/{task-queue-Cx4Lmjyk.js → task-queue-CrRjFzOh.js} +5 -16
- package/dist/{task-runner-CbTwFA6k.js → task-runner-C-pXsgHM.js} +105 -51
- package/dist/{thread-context-BkAZDTX2.js → thread-context-CDX4dSZd.js} +8 -10
- package/dist/turn-session-routing-CZTRU8IY.js +116 -0
- package/dist/turn-wake-Bzq1Efrm.js +154 -0
- package/dist/user-customization-B27StpVQ.js +9 -0
- package/dist/{validation-nIzMtAVJ.js → validation-bTq88sya.js} +1 -1
- package/dist/{vercel-queue-hW90XzbG.js → vercel-queue-nL0Hq3hr.js} +32 -147
- package/dist/{version-Brbtz4Qf.js → version-DGUa1dZK.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-BDA5myRK.js → warmup-CCOuIwAS.js} +831 -3254
- package/dist/{worker-D63RcaVD.js → worker-AkZg7Dg1.js} +5 -6
- package/migrations/0158_keep_legacy_archive_columns.sql +5 -0
- package/migrations/0159_conversation_embeddings_fk_validate.sql +5 -0
- package/migrations/0160_money_micro_usd_repair.sql +99 -0
- package/migrations/0161_agent_config_backfill.sql +34 -0
- package/migrations/0162_inbox_item_deliveries.sql +15 -0
- package/migrations/0163_pg_trgm.sql +2 -0
- package/migrations/0164_search_indexes.sql +4 -0
- package/migrations/0165_drop_legacy_archive_columns.sql +4 -0
- package/migrations/0166_memory_prefix_index.sql +1 -0
- package/migrations/0167_todo_search_indexes.sql +2 -0
- package/migrations/0168_todo_inbox_items.sql +4 -0
- package/migrations/0169_drop_code_urls.sql +2 -0
- package/migrations/meta/0158_snapshot.json +6515 -0
- package/migrations/meta/0159_snapshot.json +6515 -0
- package/migrations/meta/0160_snapshot.json +6515 -0
- package/migrations/meta/0161_snapshot.json +6278 -0
- package/migrations/meta/0162_snapshot.json +6404 -0
- package/migrations/meta/0163_snapshot.json +6404 -0
- package/migrations/meta/0164_snapshot.json +6466 -0
- package/migrations/meta/0165_snapshot.json +6466 -0
- package/migrations/meta/0166_snapshot.json +6494 -0
- package/migrations/meta/0167_snapshot.json +6525 -0
- package/migrations/meta/0168_snapshot.json +6525 -0
- package/migrations/meta/0169_snapshot.json +6513 -0
- package/migrations/meta/_journal.json +84 -0
- package/package.json +9 -18
- package/skills/design-automation-skill/SKILL.md +2 -3
- package/dist/actor-BsBdxDXQ.js +0 -208
- package/dist/child-message-DcsritGf.js +0 -179
- package/dist/conversation-privacy-L4ja1_W6.js +0 -189
- package/dist/executor-SCub-fAq.js +0 -1860
- package/dist/fan-out-Cod-yEHG.js +0 -10
- package/dist/ingest-BDf3D50j.js +0 -3836
- package/dist/result-DcvEOe1r.js +0 -574
- package/dist/result-event-type-BdIJuZxg.js +0 -48
- package/dist/service-account-Ts4ulcrV.js +0 -931
- package/dist/spawn-vxAarlX5.js +0 -73
- package/dist/state-C1P3_Ywk.js +0 -161
|
@@ -1107,6 +1107,90 @@
|
|
|
1107
1107
|
"when": 1795315499375,
|
|
1108
1108
|
"tag": "0157_conversation_lead_actor_index",
|
|
1109
1109
|
"breakpoints": true
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"idx": 158,
|
|
1113
|
+
"version": "7",
|
|
1114
|
+
"when": 1795331749525,
|
|
1115
|
+
"tag": "0158_keep_legacy_archive_columns",
|
|
1116
|
+
"breakpoints": true
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
"idx": 159,
|
|
1120
|
+
"version": "7",
|
|
1121
|
+
"when": 1795374840076,
|
|
1122
|
+
"tag": "0159_conversation_embeddings_fk_validate",
|
|
1123
|
+
"breakpoints": true
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
"idx": 160,
|
|
1127
|
+
"version": "7",
|
|
1128
|
+
"when": 1795380205852,
|
|
1129
|
+
"tag": "0160_money_micro_usd_repair",
|
|
1130
|
+
"breakpoints": true
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
"idx": 161,
|
|
1134
|
+
"version": "7",
|
|
1135
|
+
"when": 1795380206852,
|
|
1136
|
+
"tag": "0161_agent_config_backfill",
|
|
1137
|
+
"breakpoints": true
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
"idx": 162,
|
|
1141
|
+
"version": "7",
|
|
1142
|
+
"when": 1795385696825,
|
|
1143
|
+
"tag": "0162_inbox_item_deliveries",
|
|
1144
|
+
"breakpoints": true
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
"idx": 163,
|
|
1148
|
+
"version": "7",
|
|
1149
|
+
"when": 1795449455852,
|
|
1150
|
+
"tag": "0163_pg_trgm",
|
|
1151
|
+
"breakpoints": true
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"idx": 164,
|
|
1155
|
+
"version": "7",
|
|
1156
|
+
"when": 1795449459671,
|
|
1157
|
+
"tag": "0164_search_indexes",
|
|
1158
|
+
"breakpoints": true
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
"idx": 165,
|
|
1162
|
+
"version": "7",
|
|
1163
|
+
"when": 1795454807296,
|
|
1164
|
+
"tag": "0165_drop_legacy_archive_columns",
|
|
1165
|
+
"breakpoints": true
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
"idx": 166,
|
|
1169
|
+
"version": "7",
|
|
1170
|
+
"when": 1795461906115,
|
|
1171
|
+
"tag": "0166_memory_prefix_index",
|
|
1172
|
+
"breakpoints": true
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"idx": 167,
|
|
1176
|
+
"version": "7",
|
|
1177
|
+
"when": 1795465060510,
|
|
1178
|
+
"tag": "0167_todo_search_indexes",
|
|
1179
|
+
"breakpoints": true
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
"idx": 168,
|
|
1183
|
+
"version": "7",
|
|
1184
|
+
"when": 1795468505604,
|
|
1185
|
+
"tag": "0168_todo_inbox_items",
|
|
1186
|
+
"breakpoints": true
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
"idx": 169,
|
|
1190
|
+
"version": "7",
|
|
1191
|
+
"when": 1795470557967,
|
|
1192
|
+
"tag": "0169_drop_code_urls",
|
|
1193
|
+
"breakpoints": true
|
|
1110
1194
|
}
|
|
1111
1195
|
]
|
|
1112
1196
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.314.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.314.0",
|
|
69
69
|
"@sentry/nitro": "11.14.0",
|
|
70
70
|
"@sentry/node": "11.14.0",
|
|
71
71
|
"@sentry/server-utils": "11.14.0",
|
|
@@ -89,6 +89,9 @@
|
|
|
89
89
|
"jiti": "^2.7.0",
|
|
90
90
|
"jose": "^6.2.3",
|
|
91
91
|
"just-bash": "3.0.1",
|
|
92
|
+
"mdast-util-from-markdown": "^2.1.0",
|
|
93
|
+
"mdast-util-gfm": "^3.1.0",
|
|
94
|
+
"micromark-extension-gfm": "^3.0.0",
|
|
92
95
|
"node-html-markdown": "^2.0.0",
|
|
93
96
|
"p-limit": "^7.3.3",
|
|
94
97
|
"parse5": "^7.3.0",
|
|
@@ -100,37 +103,25 @@
|
|
|
100
103
|
"zod": "^4.6.7"
|
|
101
104
|
},
|
|
102
105
|
"peerDependencies": {
|
|
103
|
-
"
|
|
104
|
-
"nitro": "3.0.260415-beta || 3.0.260429-beta || 3.0.260522-beta || 3.0.260603-beta || 3.0.260610-beta || 3.0.260903-beta",
|
|
105
|
-
"redis": "^5.12.1"
|
|
106
|
-
},
|
|
107
|
-
"peerDependenciesMeta": {
|
|
108
|
-
"bullmq": {
|
|
109
|
-
"optional": true
|
|
110
|
-
},
|
|
111
|
-
"redis": {
|
|
112
|
-
"optional": true
|
|
113
|
-
}
|
|
106
|
+
"nitro": "3.0.260415-beta || 3.0.260429-beta || 3.0.260522-beta || 3.0.260603-beta || 3.0.260610-beta || 3.0.260903-beta"
|
|
114
107
|
},
|
|
115
108
|
"devDependencies": {
|
|
116
109
|
"@emnapi/core": "^1.10.0",
|
|
117
110
|
"@emnapi/runtime": "^1.10.0",
|
|
118
111
|
"@hono/node-server": "2.1.3",
|
|
119
|
-
"@sentry/junior-github": "0.
|
|
120
|
-
"@sentry/junior-notion": "0.
|
|
121
|
-
"@sentry/junior-sentry": "0.
|
|
112
|
+
"@sentry/junior-github": "0.314.0",
|
|
113
|
+
"@sentry/junior-notion": "0.314.0",
|
|
114
|
+
"@sentry/junior-sentry": "0.314.0",
|
|
122
115
|
"@sentry/junior-testing": "0.0.0",
|
|
123
116
|
"@types/node": "^24.19.2",
|
|
124
117
|
"@types/pg": "^8.15.6",
|
|
125
118
|
"@types/web-push": "^3.6.4",
|
|
126
119
|
"@typescript/typescript6": "6.0.2",
|
|
127
120
|
"@vitest/coverage-v8": "4.1.12",
|
|
128
|
-
"bullmq": "6.5.0",
|
|
129
121
|
"dependency-cruiser": "^17.4.0",
|
|
130
122
|
"drizzle-kit": "^0.31.8",
|
|
131
123
|
"msw": "^2.14.6",
|
|
132
124
|
"nitro": "3.0.260522-beta",
|
|
133
|
-
"redis": "5.12.1",
|
|
134
125
|
"tsdown": "0.23.7",
|
|
135
126
|
"typescript": "7.0.2",
|
|
136
127
|
"vercel": "^54.4.0",
|
|
@@ -15,7 +15,7 @@ Use this order:
|
|
|
15
15
|
|
|
16
16
|
1. **Frontmatter description.** Say what one run produces, name both scopes, and write triggers as the work, such as "when a CI check fails and might be flaky". Do not name the caller.
|
|
17
17
|
2. **Purpose.** One or two sentences: what a run produces, and how often a run finds nothing.
|
|
18
|
-
3. **Inputs.**
|
|
18
|
+
3. **Inputs.** Only when values change between setups: one line each, with its default.
|
|
19
19
|
4. **Rules.** Hard limits, then a **Side effects** list with each kind of write the skill can make.
|
|
20
20
|
5. **Workflow.** Numbered steps. The first step reads the target's own conventions: agent docs, contributing guide, and CI files.
|
|
21
21
|
6. **Report.** The format, and the one empty-result line.
|
|
@@ -24,9 +24,8 @@ Put only a brief for parallel workers or a long template in `references/`.
|
|
|
24
24
|
|
|
25
25
|
## Inputs and scope
|
|
26
26
|
|
|
27
|
-
- Give each input a row. Resolve it in this order: the value the request names; the value from the item the request points at, such as a failed run, a pull request, or an issue; the current checkout or a configured default. With none of these, stop and name the missing input.
|
|
28
|
-
- Give each row a default, and say that the request can change it.
|
|
29
27
|
- Values that change between setups are inputs: repos, projects, teams, thresholds, people to tag, and paths that need sign-off. Do not write them into the steps. A skill for one named system can keep its fixed values.
|
|
28
|
+
- Do not explain how to find an input in the request, the item it points at, or the checkout. The agent does that.
|
|
30
29
|
- Use two scopes:
|
|
31
30
|
- **One item**: the request points at one thing. Decide about that thing, and look back over a short window, such as 7 days, for the same problem.
|
|
32
31
|
- **Sweep**: all other requests. Check every item in a default window, such as the last 48 hours.
|
package/dist/actor-BsBdxDXQ.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
// src/chat/slack/timestamp.ts
|
|
3
|
-
/** Native Slack message timestamp, safe to pass as Slack Web API `message_ts`. */
|
|
4
|
-
const slackMessageTsSchema = z.string().trim().regex(/^\d+(?:\.\d+)?$/).brand();
|
|
5
|
-
/** Parse a native Slack message timestamp from untrusted message metadata. */
|
|
6
|
-
function parseSlackMessageTs(value) {
|
|
7
|
-
const parsed = slackMessageTsSchema.safeParse(value);
|
|
8
|
-
return parsed.success ? parsed.data : void 0;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Write a time in milliseconds as a Slack timestamp, for input that has no
|
|
12
|
-
* Slack message of its own, such as a submitted form.
|
|
13
|
-
*/
|
|
14
|
-
function slackMessageTsFromMs(ms) {
|
|
15
|
-
return slackMessageTsSchema.parse((ms / 1e3).toFixed(6));
|
|
16
|
-
}
|
|
17
|
-
// src/chat/slack/ids.ts
|
|
18
|
-
const slackChannelIdSchema = z.string().regex(/^[CDG][A-Z0-9]+$/).brand();
|
|
19
|
-
const slackTeamIdSchema = z.string().regex(/^T[A-Z0-9]+$/).brand();
|
|
20
|
-
const slackUserIdSchema = z.string().regex(/^[UW][A-Z0-9]+$/).brand();
|
|
21
|
-
const slackBotIdSchema = z.string().regex(/^B[A-Z0-9]+$/).brand();
|
|
22
|
-
const SLACK_CHANNEL_MENTION_RE = /^<#([CDG][A-Z0-9]+)(?:\|[^>]*)?>$/;
|
|
23
|
-
function slackChannelReferenceCandidate(value) {
|
|
24
|
-
const trimmed = value.trim();
|
|
25
|
-
if (!trimmed.startsWith("slack:")) return trimmed;
|
|
26
|
-
const parts = trimmed.split(":");
|
|
27
|
-
if (parts.length === 2) return parts[1]?.trim() ?? "";
|
|
28
|
-
if (parts.length === 3 && parseSlackMessageTs(parts[2])) return parts[1]?.trim() ?? "";
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
/** Parse an exact Slack channel/conversation ID from untrusted input. */
|
|
32
|
-
function parseSlackChannelId(value) {
|
|
33
|
-
if (typeof value !== "string") return void 0;
|
|
34
|
-
const parsed = slackChannelIdSchema.safeParse(value.trim());
|
|
35
|
-
return parsed.success ? parsed.data : void 0;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Parse a channel id from common tool/model reference forms.
|
|
39
|
-
*
|
|
40
|
-
* Accepts exact ids (`C123`), Slack mentions (`<#C123>` / `<#C123|name>`),
|
|
41
|
-
* and Junior slack references (`slack:C123`, `slack:C123:ts`). Plain channel
|
|
42
|
-
* names are not ids and are rejected here.
|
|
43
|
-
*/
|
|
44
|
-
function parseSlackChannelReferenceId(value) {
|
|
45
|
-
if (typeof value !== "string") return void 0;
|
|
46
|
-
const trimmed = value.trim();
|
|
47
|
-
const mentionMatch = SLACK_CHANNEL_MENTION_RE.exec(trimmed);
|
|
48
|
-
if (mentionMatch?.[1]) return parseSlackChannelId(mentionMatch[1]);
|
|
49
|
-
return parseSlackChannelId(slackChannelReferenceCandidate(trimmed));
|
|
50
|
-
}
|
|
51
|
-
/** Parse a Slack workspace/team ID from untrusted metadata. */
|
|
52
|
-
function parseSlackTeamId(value) {
|
|
53
|
-
if (typeof value !== "string") return void 0;
|
|
54
|
-
const parsed = slackTeamIdSchema.safeParse(value.trim());
|
|
55
|
-
return parsed.success ? parsed.data : void 0;
|
|
56
|
-
}
|
|
57
|
-
/** Parse a Slack user ID from untrusted metadata. */
|
|
58
|
-
function parseSlackUserId(value) {
|
|
59
|
-
if (typeof value !== "string") return void 0;
|
|
60
|
-
const parsed = slackUserIdSchema.safeParse(value.trim());
|
|
61
|
-
return parsed.success ? parsed.data : void 0;
|
|
62
|
-
}
|
|
63
|
-
// src/chat/actor.ts
|
|
64
|
-
/**
|
|
65
|
-
* Canonical actor identity.
|
|
66
|
-
*
|
|
67
|
-
* Runtime actors are platform-scoped actors. Stored Slack actor parsing
|
|
68
|
-
* remains explicit so durable conversation metadata is not repaired on read.
|
|
69
|
-
*/
|
|
70
|
-
const SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
71
|
-
const EMAIL_PATTERN = /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;
|
|
72
|
-
const exactStoredStringSchema = z.string().min(1).refine((value) => value === value.trim());
|
|
73
|
-
const storedSlackActorSchema = z.object({
|
|
74
|
-
email: exactStoredStringSchema.optional(),
|
|
75
|
-
fullName: exactStoredStringSchema.optional(),
|
|
76
|
-
platform: z.literal("slack").optional(),
|
|
77
|
-
slackUserId: exactStoredStringSchema.optional(),
|
|
78
|
-
slackUserName: exactStoredStringSchema.optional(),
|
|
79
|
-
teamId: exactStoredStringSchema.optional()
|
|
80
|
-
}).strict();
|
|
81
|
-
/** Return whether an actor is a platform-scoped user actor. */
|
|
82
|
-
function isUserActor(actor) {
|
|
83
|
-
return Boolean(actor && "userId" in actor);
|
|
84
|
-
}
|
|
85
|
-
function clean(value) {
|
|
86
|
-
const trimmed = value?.trim();
|
|
87
|
-
return trimmed ? trimmed : void 0;
|
|
88
|
-
}
|
|
89
|
-
function isSyntheticActorUserId(value) {
|
|
90
|
-
return value.toLowerCase() === "unknown";
|
|
91
|
-
}
|
|
92
|
-
/** Return whether a value has the shape of a Slack user id. */
|
|
93
|
-
function isSlackUserId(value) {
|
|
94
|
-
return SLACK_USER_ID_DISPLAY_PATTERN.test(value);
|
|
95
|
-
}
|
|
96
|
-
function cleanActorDisplayName(value, userId) {
|
|
97
|
-
const displayName = clean(value);
|
|
98
|
-
if (!displayName) return;
|
|
99
|
-
if (displayName.toLowerCase() === "unknown") return;
|
|
100
|
-
if (userId && displayName === userId) return;
|
|
101
|
-
return isSlackUserId(displayName) ? void 0 : displayName;
|
|
102
|
-
}
|
|
103
|
-
function cleanActorEmail(value) {
|
|
104
|
-
const email = clean(value);
|
|
105
|
-
return email && EMAIL_PATTERN.test(email) ? email : void 0;
|
|
106
|
-
}
|
|
107
|
-
/** Keep actor ids exact at platform boundaries before they enter owned state. */
|
|
108
|
-
function parseActorUserId(value) {
|
|
109
|
-
if (typeof value !== "string" || value.length === 0) return;
|
|
110
|
-
if (value !== value.trim() || isSyntheticActorUserId(value)) return;
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
113
|
-
/** Assert persisted actor ids without read-side repair. */
|
|
114
|
-
function isActorUserId(value) {
|
|
115
|
-
return parseActorUserId(value) === value;
|
|
116
|
-
}
|
|
117
|
-
/** Build Junior's canonical platform actor from exact actor ids and profile data. */
|
|
118
|
-
function createActor(input, context) {
|
|
119
|
-
const platform = context.platform ?? input?.platform;
|
|
120
|
-
if (!platform) return;
|
|
121
|
-
const contextUserId = parseActorUserId(context.userId);
|
|
122
|
-
if (context.userId !== void 0 && !contextUserId) return;
|
|
123
|
-
const inputUserId = parseActorUserId(input?.userId);
|
|
124
|
-
if (input?.userId !== void 0 && !inputUserId) return;
|
|
125
|
-
const actorUserId = contextUserId ?? inputUserId;
|
|
126
|
-
if (!actorUserId) return;
|
|
127
|
-
const contextTeamId = parseSlackTeamId(context.teamId);
|
|
128
|
-
if (context.teamId !== void 0 && !contextTeamId) return;
|
|
129
|
-
const inputTeamId = parseSlackTeamId(input?.teamId);
|
|
130
|
-
if (input?.teamId !== void 0 && !inputTeamId) return;
|
|
131
|
-
const actorTeamId = contextTeamId ?? inputTeamId;
|
|
132
|
-
if (platform === "slack" && !actorTeamId) return;
|
|
133
|
-
const canUseInputProfile = (!contextUserId || !inputUserId || contextUserId === inputUserId) && (platform !== "slack" || !contextTeamId || !inputTeamId || contextTeamId === inputTeamId);
|
|
134
|
-
const actor = {
|
|
135
|
-
...canUseInputProfile && cleanActorEmail(input?.email) ? { email: cleanActorEmail(input?.email) } : void 0,
|
|
136
|
-
...canUseInputProfile && cleanActorDisplayName(input?.fullName, actorUserId) ? { fullName: cleanActorDisplayName(input?.fullName, actorUserId) } : void 0,
|
|
137
|
-
platform,
|
|
138
|
-
userId: actorUserId,
|
|
139
|
-
...canUseInputProfile && cleanActorDisplayName(input?.userName, actorUserId) ? { userName: cleanActorDisplayName(input?.userName, actorUserId) } : void 0
|
|
140
|
-
};
|
|
141
|
-
if (platform === "slack") return {
|
|
142
|
-
...actor,
|
|
143
|
-
platform,
|
|
144
|
-
teamId: actorTeamId
|
|
145
|
-
};
|
|
146
|
-
return {
|
|
147
|
-
...actor,
|
|
148
|
-
platform
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/** Build Junior's canonical actor from Slack profile data. */
|
|
152
|
-
function createSlackActor(teamId, userId, profile) {
|
|
153
|
-
const actorUserId = parseActorUserId(userId);
|
|
154
|
-
const actorTeamId = parseSlackTeamId(teamId);
|
|
155
|
-
if (!actorTeamId || !actorUserId) throw new Error("Slack actor requires team and user ids");
|
|
156
|
-
const actor = createActor({
|
|
157
|
-
email: profile?.email,
|
|
158
|
-
fullName: profile?.fullName,
|
|
159
|
-
platform: "slack",
|
|
160
|
-
teamId: actorTeamId,
|
|
161
|
-
userId: actorUserId,
|
|
162
|
-
userName: profile?.userName
|
|
163
|
-
}, {
|
|
164
|
-
teamId: actorTeamId,
|
|
165
|
-
userId: actorUserId
|
|
166
|
-
});
|
|
167
|
-
if (!actor || actor.platform !== "slack") throw new Error("Slack actor requires team and user ids");
|
|
168
|
-
return actor;
|
|
169
|
-
}
|
|
170
|
-
/** Parse a serialized Slack actor that crossed a runtime boundary. */
|
|
171
|
-
function parseStoredSlackActor(value) {
|
|
172
|
-
const parsed = storedSlackActorSchema.safeParse(value);
|
|
173
|
-
if (!parsed.success) return;
|
|
174
|
-
if (parsed.data.slackUserId !== void 0 && !parseActorUserId(parsed.data.slackUserId)) return;
|
|
175
|
-
if (parsed.data.teamId !== void 0 && !parseSlackTeamId(parsed.data.teamId)) return;
|
|
176
|
-
if ((parsed.data.platform !== void 0 || parsed.data.teamId !== void 0) && (!parsed.data.platform || !parsed.data.teamId)) return;
|
|
177
|
-
return parsed.data;
|
|
178
|
-
}
|
|
179
|
-
/** Convert a runtime Slack actor into its durable session shape. */
|
|
180
|
-
function toStoredSlackActor(actor) {
|
|
181
|
-
return {
|
|
182
|
-
...actor.email ? { email: actor.email } : void 0,
|
|
183
|
-
...actor.fullName ? { fullName: actor.fullName } : void 0,
|
|
184
|
-
platform: actor.platform,
|
|
185
|
-
slackUserId: actor.userId,
|
|
186
|
-
...actor.userName ? { slackUserName: actor.userName } : void 0,
|
|
187
|
-
teamId: actor.teamId
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Resolve a Slack resume actor from stored profile data and the active actor.
|
|
192
|
-
*
|
|
193
|
-
* TODO(dcramer): Require Actor and remove ID-only construction after no
|
|
194
|
-
* deployed Turn cursor can omit Actor.
|
|
195
|
-
*/
|
|
196
|
-
function createSlackResumeActor(args) {
|
|
197
|
-
if (args.actor) {
|
|
198
|
-
if (args.actor.platform !== "slack" || args.actor.teamId !== args.teamId || args.actor.userId !== args.userId) throw new Error("Stored Slack actor did not match resume actor");
|
|
199
|
-
}
|
|
200
|
-
const actor = createActor(args.actor, {
|
|
201
|
-
platform: "slack",
|
|
202
|
-
teamId: args.teamId,
|
|
203
|
-
userId: args.userId
|
|
204
|
-
});
|
|
205
|
-
if (!actor || actor.platform !== "slack") throw new Error("Slack actor requires team and user ids");
|
|
206
|
-
return actor;
|
|
207
|
-
}
|
|
208
|
-
export { slackUserIdSchema as _, isSlackUserId as a, slackMessageTsSchema as b, parseStoredSlackActor as c, parseSlackChannelReferenceId as d, parseSlackTeamId as f, slackTeamIdSchema as g, slackChannelIdSchema as h, isActorUserId as i, toStoredSlackActor as l, slackBotIdSchema as m, createSlackActor as n, isUserActor as o, parseSlackUserId as p, createSlackResumeActor as r, parseActorUserId as s, createActor as t, parseSlackChannelId as u, parseSlackMessageTs as v, slackMessageTsFromMs as y };
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { s as getSqlExecutor } from "./db-LAyyX8tk.js";
|
|
2
|
-
import { un as readInboundMessageSender } from "./thread-state-DhPndWi1.js";
|
|
3
|
-
import { x as juniorAgentInvocations } from "./executor-SCub-fAq.js";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
import { inArray } from "drizzle-orm";
|
|
6
|
-
// src/chat/agent-invocations/ids.ts
|
|
7
|
-
const CREATE_LOCK_PREFIX = "junior:agent_invocation:create";
|
|
8
|
-
/**
|
|
9
|
-
* Return the SQL lock that one parent Conversation takes to start, message,
|
|
10
|
-
* or stop its child agents.
|
|
11
|
-
*/
|
|
12
|
-
function getChildAgentLockName(parentConversationId) {
|
|
13
|
-
return `${CREATE_LOCK_PREFIX}:${parentConversationId}`;
|
|
14
|
-
}
|
|
15
|
-
function stableId(prefix, ...parts) {
|
|
16
|
-
return `${prefix}:${createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 32)}`;
|
|
17
|
-
}
|
|
18
|
-
/** Return the stable identity for one retry-safe delegated task. */
|
|
19
|
-
function getAgentInvocationId(parentConversationId, idempotencyKey) {
|
|
20
|
-
return stableId("agent-invocation", parentConversationId, idempotencyKey);
|
|
21
|
-
}
|
|
22
|
-
/** Return the stable child identity for one invocation without a named binding. */
|
|
23
|
-
function getUnnamedAgentConversationId(invocationId) {
|
|
24
|
-
return stableId("agent", invocationId);
|
|
25
|
-
}
|
|
26
|
-
/** Return the stable child identity for one named binding. */
|
|
27
|
-
function getNamedAgentConversationId(parentConversationId, name) {
|
|
28
|
-
return stableId("agent", parentConversationId, name);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Return the stable identity of the agent invocation that gives one child
|
|
32
|
-
* agent result to the child Conversation that started that child agent.
|
|
33
|
-
*/
|
|
34
|
-
function getAgentInvocationIdForResult(resultInvocationId) {
|
|
35
|
-
return stableId("agent-invocation", "result", resultInvocationId);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Return the stable identity of the agent invocation that gives one message
|
|
39
|
-
* from a child agent to the child Conversation that started that child agent.
|
|
40
|
-
*/
|
|
41
|
-
function getAgentInvocationIdForMessage(messageId) {
|
|
42
|
-
return stableId("agent-invocation", "message", messageId);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Return the stable identity of the agent invocation that gives one batch of
|
|
46
|
-
* watch events to a child Conversation. The first message of the batch names
|
|
47
|
-
* it.
|
|
48
|
-
*/
|
|
49
|
-
function getAgentInvocationIdForEvents(messageId) {
|
|
50
|
-
return stableId("agent-invocation", "events", messageId);
|
|
51
|
-
}
|
|
52
|
-
/** Return the stable turn identity advanced by one agent invocation. */
|
|
53
|
-
function getAgentInvocationTurnId(invocationId) {
|
|
54
|
-
return `agent-invocation:${invocationId}`;
|
|
55
|
-
}
|
|
56
|
-
/** Return the stable mailbox identity for one agent invocation. */
|
|
57
|
-
function getAgentInvocationMessageId(invocationId) {
|
|
58
|
-
return `agent-invocation:${invocationId}:input`;
|
|
59
|
-
}
|
|
60
|
-
const REPLY_MESSAGE_PREFIX = "agent-reply:";
|
|
61
|
-
/**
|
|
62
|
-
* Return the parent mailbox identity of one child agent `reply` call.
|
|
63
|
-
* `senderId` is the Agent invocation that sent it, or the child Conversation
|
|
64
|
-
* when no Agent invocation names the child.
|
|
65
|
-
*/
|
|
66
|
-
function getAgentReplyMessageId(senderId, toolCallId) {
|
|
67
|
-
return `${REPLY_MESSAGE_PREFIX}${senderId}:${toolCallId}`;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Return the key of the `reply` of one Turn on a child's Conversation loop.
|
|
71
|
-
* Readers take the sender from the message's sender fields, not this key.
|
|
72
|
-
*/
|
|
73
|
-
function getTurnReplyKey(turnId, toolCallId) {
|
|
74
|
-
return `${turnId}:${toolCallId}`;
|
|
75
|
-
}
|
|
76
|
-
/** Return the stable parent mailbox identity for one terminal result. */
|
|
77
|
-
function getAgentInvocationResultMessageId(invocationId) {
|
|
78
|
-
return `agent-invocation:${invocationId}:result`;
|
|
79
|
-
}
|
|
80
|
-
// src/chat/agent-invocations/child-message.ts
|
|
81
|
-
/** Mailbox metadata that stores who sent one child reply or result. */
|
|
82
|
-
function childMessageSenderMetadata(sender) {
|
|
83
|
-
return { sender };
|
|
84
|
-
}
|
|
85
|
-
/** Read who sent one child reply or result in a parent's mailbox. */
|
|
86
|
-
async function readChildMessageSender(message) {
|
|
87
|
-
return readInboundMessageSender(message) ?? (await readLegacyChildMessageSenders([message.inboundMessageId])).get(message.inboundMessageId);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Read who sent each child reply or result, in message order. Messages
|
|
91
|
-
* without stored sender fields share one legacy read.
|
|
92
|
-
*/
|
|
93
|
-
async function readChildMessageSenders(messages) {
|
|
94
|
-
const stored = messages.map((message) => readInboundMessageSender(message));
|
|
95
|
-
const legacy = await readLegacyChildMessageSenders(messages.flatMap((message, index) => stored[index] ? [] : [message.inboundMessageId]));
|
|
96
|
-
return messages.map((message, index) => stored[index] ?? legacy.get(message.inboundMessageId));
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* List the child replies and results among the ids that reached one
|
|
100
|
-
* mailbox, oldest first, with the sender fields that the mailbox keeps.
|
|
101
|
-
*/
|
|
102
|
-
async function listChildMessages(inboundMessageIds, messageSenders) {
|
|
103
|
-
const legacy = await readLegacyChildMessageSenders(inboundMessageIds.filter((id) => !messageSenders[id]));
|
|
104
|
-
return inboundMessageIds.flatMap((inboundMessageId) => {
|
|
105
|
-
const sender = messageSenders[inboundMessageId] ?? legacy.get(inboundMessageId);
|
|
106
|
-
return sender ? [{
|
|
107
|
-
inboundMessageId,
|
|
108
|
-
sender
|
|
109
|
-
}] : [];
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Return the Agent invocation whose own Turn sent the message. A Turn on the
|
|
114
|
-
* child's Conversation loop has none, even when the message names the
|
|
115
|
-
* child's newest Agent invocation.
|
|
116
|
-
*
|
|
117
|
-
* TODO(dcramer): Remove with Agent invocation rows (#3060 step 7).
|
|
118
|
-
*/
|
|
119
|
-
function ownAgentInvocation(sender) {
|
|
120
|
-
const { agentInvocationId } = sender;
|
|
121
|
-
return agentInvocationId && sender.turnId === getAgentInvocationTurnId(agentInvocationId) ? agentInvocationId : void 0;
|
|
122
|
-
}
|
|
123
|
-
/** Return whether the message is the result of an Agent invocation. */
|
|
124
|
-
function isAgentInvocationResult(message) {
|
|
125
|
-
const agentInvocationId = ownAgentInvocation(message.sender);
|
|
126
|
-
return agentInvocationId !== void 0 && message.inboundMessageId === getAgentInvocationResultMessageId(agentInvocationId);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Return whether one Agent invocation sent a reply to its parent: a message
|
|
130
|
-
* names it as sender and is not its own result.
|
|
131
|
-
*/
|
|
132
|
-
function hasAgentInvocationReply(messages, agentInvocationId) {
|
|
133
|
-
return messages.some((message) => message.sender.agentInvocationId === agentInvocationId && !isAgentInvocationResult(message));
|
|
134
|
-
}
|
|
135
|
-
const LEGACY_REPLY_ID = /^agent-reply:(agent(?:-invocation)?:[0-9a-f]{32}):(?:(turn_[A-Za-z0-9_-]+)(?::|$))?/;
|
|
136
|
-
const LEGACY_RESULT_ID = /^agent-invocation:(agent-invocation:[0-9a-f]{32}):result$/;
|
|
137
|
-
/**
|
|
138
|
-
* Read the sender of child messages that reached a mailbox before senders
|
|
139
|
-
* stored their fields, from their ids.
|
|
140
|
-
*
|
|
141
|
-
* TODO: remove one release after this ships. Step 7 of #3060 deletes it and
|
|
142
|
-
* makes the id a plain generated key.
|
|
143
|
-
*/
|
|
144
|
-
async function readLegacyChildMessageSenders(inboundMessageIds) {
|
|
145
|
-
const senders = /* @__PURE__ */ new Map();
|
|
146
|
-
const byAgentInvocation = /* @__PURE__ */ new Map();
|
|
147
|
-
for (const id of inboundMessageIds) {
|
|
148
|
-
const result = LEGACY_RESULT_ID.exec(id);
|
|
149
|
-
const reply = result ? void 0 : LEGACY_REPLY_ID.exec(id);
|
|
150
|
-
const senderId = result?.[1] ?? reply?.[1];
|
|
151
|
-
if (!senderId) continue;
|
|
152
|
-
const turnId = reply?.[2];
|
|
153
|
-
if (senderId.startsWith("agent-invocation:")) byAgentInvocation.set(id, {
|
|
154
|
-
agentInvocationId: senderId,
|
|
155
|
-
turnId
|
|
156
|
-
});
|
|
157
|
-
else if (turnId) senders.set(id, {
|
|
158
|
-
conversationId: senderId,
|
|
159
|
-
turnId
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (byAgentInvocation.size === 0) return senders;
|
|
163
|
-
const rows = await getSqlExecutor().db().select({
|
|
164
|
-
childConversationId: juniorAgentInvocations.childConversationId,
|
|
165
|
-
invocationId: juniorAgentInvocations.invocationId
|
|
166
|
-
}).from(juniorAgentInvocations).where(inArray(juniorAgentInvocations.invocationId, [...new Set([...byAgentInvocation.values()].map((s) => s.agentInvocationId))]));
|
|
167
|
-
const childOf = new Map(rows.map((row) => [row.invocationId, row.childConversationId]));
|
|
168
|
-
for (const [id, { agentInvocationId, turnId }] of byAgentInvocation) {
|
|
169
|
-
const conversationId = childOf.get(agentInvocationId);
|
|
170
|
-
if (!conversationId) continue;
|
|
171
|
-
senders.set(id, {
|
|
172
|
-
agentInvocationId,
|
|
173
|
-
conversationId,
|
|
174
|
-
turnId: turnId ?? getAgentInvocationTurnId(agentInvocationId)
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
return senders;
|
|
178
|
-
}
|
|
179
|
-
export { getNamedAgentConversationId as _, ownAgentInvocation as a, getAgentInvocationId as c, getAgentInvocationIdForResult as d, getAgentInvocationMessageId as f, getChildAgentLockName as g, getAgentReplyMessageId as h, listChildMessages as i, getAgentInvocationIdForEvents as l, getAgentInvocationTurnId as m, hasAgentInvocationReply as n, readChildMessageSender as o, getAgentInvocationResultMessageId as p, isAgentInvocationResult as r, readChildMessageSenders as s, childMessageSenderMetadata as t, getAgentInvocationIdForMessage as u, getTurnReplyKey as v, getUnnamedAgentConversationId as y };
|