@sentry/junior 0.313.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-CYAvJzZS.js → adapter-JARQvoLw.js} +1 -2
- package/dist/{adapter-context-CVsHoVSf.js → adapter-context-B4BrJZuS.js} +2 -2
- package/dist/{admin-Cyhb4TwZ.js → admin-BXGAySz0.js} +1 -1
- package/dist/{agent-runner-B5y9MsT-.js → agent-runner-qZU5TR8i.js} +797 -118
- 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 +334 -100
- package/dist/{app-DA8-hCMj.d.ts → app-D7tKnw9a.d.ts} +4 -21
- package/dist/app.d.ts +2 -2
- package/dist/app.js +80 -169
- package/dist/{background-compaction-queue-iZXadLV3.js → background-compaction-queue-C_uIBUvS.js} +6 -67
- package/dist/callback-C8SdXCwr.js +68 -0
- package/dist/{catalog-runtime-kkE3hvCX.js → catalog-runtime-BLKtnUL3.js} +1 -1
- package/dist/{channel-access-mt7K6dPh.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-CWbwKj0j.js → config-BIfHKNXN.js} +40 -35
- package/dist/{continue-in-slack-CxyFzdlF.js → continue-in-slack-fnmD2Ifb.js} +5 -7
- package/dist/{conversation-feed-BEXLD3Me.js → conversation-feed-DdFQuQDR.js} +1 -1
- package/dist/{logging-DNt-qOIO.js → conversation-privacy-DtZhI91r.js} +188 -2
- package/dist/{conversation-turn-B35eu0uz.js → conversation-turn-DScuDYmN.js} +418 -33
- package/dist/create-CrNt4Ewu.js +212 -0
- package/dist/{credential-sync-DWTOEQrm.js → credential-sync-CtqsGjj1.js} +14 -17
- package/dist/{credentialed-Dyv8b-lu.js → credentialed-dWRA3-oJ.js} +910 -426
- package/dist/{db-PwSRzWWn.js → db-BTmLKZrp.js} +2235 -38
- package/dist/{db-DYGcXYl3.d.ts → db-DcmzbA55.d.ts} +2 -2
- package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
- package/dist/{html-DidUcRhI.js → html-B8rBt7F4.js} +5 -7
- package/dist/{install-2urLLXNt.js → install-OtFboxOM.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-BXplQAVH.js → lineage-EULJkGO1.js} +1 -2
- package/dist/{list-DyIyReSV.js → list-C5400AlJ.js} +235 -77
- package/dist/{turn-membership-DTR3SaKD.js → mailbox-turn-DL3Lvsm0.js} +4698 -587
- package/dist/markers-DUP8aBOp.js +323 -0
- package/dist/{media-B0pZJ0bG.js → media-FYM-Bl3H.js} +33 -8
- package/dist/{message-Z5YKC-Af.js → message-DuDelZFr.js} +16 -29
- package/dist/{model-input-BhPJYdSV.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-ByvDdcdY.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
- package/dist/{oauth-relay-D-kK0yoN.js → oauth-relay-PwPMdZJv.js} +1 -1
- package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
- package/dist/{registry-POH4bZC4.js → registry-D6kS6xYH.js} +1402 -64
- package/dist/{resolve-CWtBNSKP.js → resolve-D8CPJcNK.js} +3 -3
- package/dist/result-D090hxr5.js +402 -0
- package/dist/{runner-CsZ_VRxp.js → runner-BU7fgrm-.js} +7 -8
- package/dist/{sandbox-egress-signals-FbCk1FkN.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
- package/dist/{schema-DojR2uCL.js → schema-7gW9vBpJ.js} +90 -9
- package/dist/{schema-DBf18QPS.d.ts → schema-BB6E0wyV.d.ts} +138 -5
- package/dist/{service-account-CDYb9hfX.js → service-account-plA-uzIB.js} +6 -5
- package/dist/{skills-B0jP4whm.js → skills-CIosT6bS.js} +3 -3
- package/dist/{slack-conversation-unfurl-D26t9kBC.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
- package/dist/{spawn-BjljgExZ.js → spawn-DRjdzh3R.js} +9 -17
- package/dist/{start-conversation-DbVujrwO.js → start-conversation-a4NXH4X9.js} +12 -15
- package/dist/{store-CjXrp-Up.js → store-BuhF1QDm.js} +2 -4
- package/dist/{task-queue-Cwlatjz3.js → task-queue-CrRjFzOh.js} +5 -16
- package/dist/{task-runner--Ke8KSMf.js → task-runner-C-pXsgHM.js} +104 -50
- package/dist/{thread-context-B8exINEe.js → thread-context-CDX4dSZd.js} +8 -9
- 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-Ce0qbMlT.js → validation-bTq88sya.js} +1 -1
- package/dist/{vercel-queue-q4z8w5QO.js → vercel-queue-nL0Hq3hr.js} +32 -147
- package/dist/{version-DFh4n9nr.js → version-DGUa1dZK.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-D5hzqTcp.js → warmup-CCOuIwAS.js} +639 -137
- package/dist/{worker-CDg9Lbpg.js → worker-AkZg7Dg1.js} +5 -6
- 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/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 +70 -0
- package/package.json +9 -18
- package/skills/design-automation-skill/SKILL.md +2 -3
- package/dist/actor-BsBdxDXQ.js +0 -208
- package/dist/conversation-privacy-BrMiDN61.js +0 -189
- package/dist/executor-CgWyWfYz.js +0 -1858
- package/dist/fan-out-Cod-yEHG.js +0 -10
- package/dist/ingest-B0AggUEC.js +0 -7931
- package/dist/request-deadline-BUiRYQYj.js +0 -24
- package/dist/service-account-o15pZWcJ.js +0 -931
- package/dist/state-BTawTCme.js +0 -161
- package/dist/statuses-BKwqCPhj.js +0 -69
|
@@ -1121,6 +1121,76 @@
|
|
|
1121
1121
|
"when": 1795374840076,
|
|
1122
1122
|
"tag": "0159_conversation_embeddings_fk_validate",
|
|
1123
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
|
|
1124
1194
|
}
|
|
1125
1195
|
]
|
|
1126
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,189 +0,0 @@
|
|
|
1
|
-
import { h as logWarn } from "./logging-DNt-qOIO.js";
|
|
2
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
|
|
4
|
-
// src/chat/conversation-privacy.ts
|
|
5
|
-
const SAFE_METADATA_KEY_LIMIT = 20;
|
|
6
|
-
const conversationPrivacyStorage = new AsyncLocalStorage();
|
|
7
|
-
/**
|
|
8
|
-
* Resolve whether a Conversation may expose full transcript and tool data.
|
|
9
|
-
*
|
|
10
|
-
* Read visibility from the stored Conversation. If it is missing, warn and
|
|
11
|
-
* treat the Conversation as private. Do not infer visibility from identifiers.
|
|
12
|
-
*/
|
|
13
|
-
function resolveConversationPrivacy(input) {
|
|
14
|
-
if (input.visibility === void 0) logWarn("conversation.visibility.defaulted");
|
|
15
|
-
return input.visibility === "public" ? "public" : "private";
|
|
16
|
-
}
|
|
17
|
-
/** Return whether a public Conversation may expose transcript and tool data. */
|
|
18
|
-
function canExposeConversationPayload(input) {
|
|
19
|
-
return resolveConversationPrivacy(input) === "public";
|
|
20
|
-
}
|
|
21
|
-
/** Return privacy for the current agent Turn. */
|
|
22
|
-
function getCurrentConversationPrivacy() {
|
|
23
|
-
return conversationPrivacyStorage.getStore();
|
|
24
|
-
}
|
|
25
|
-
/** Bind one conversation privacy mode to all async work in a turn. */
|
|
26
|
-
function runWithConversationPrivacy(privacy, callback) {
|
|
27
|
-
return conversationPrivacyStorage.run(privacy, callback);
|
|
28
|
-
}
|
|
29
|
-
function payloadType(payload) {
|
|
30
|
-
return Array.isArray(payload) ? "array" : typeof payload;
|
|
31
|
-
}
|
|
32
|
-
function payloadKeys(payload) {
|
|
33
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return;
|
|
34
|
-
const keys = Object.keys(payload).slice(0, SAFE_METADATA_KEY_LIMIT);
|
|
35
|
-
return keys.length > 0 ? keys : void 0;
|
|
36
|
-
}
|
|
37
|
-
function serializedLength(payload) {
|
|
38
|
-
return (typeof payload === "string" ? payload : JSON.stringify(payload))?.length ?? 0;
|
|
39
|
-
}
|
|
40
|
-
/** Convert an arbitrary payload into safe structured metadata for trace data fields. */
|
|
41
|
-
function toGenAiPayloadMetadata(payload) {
|
|
42
|
-
const base = {
|
|
43
|
-
type: payloadType(payload),
|
|
44
|
-
chars: serializedLength(payload)
|
|
45
|
-
};
|
|
46
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return base;
|
|
47
|
-
const keys = payloadKeys(payload);
|
|
48
|
-
return {
|
|
49
|
-
...base,
|
|
50
|
-
...keys ? { keys } : void 0
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/** Convert an arbitrary payload into safe flattened trace attributes. */
|
|
54
|
-
function toGenAiPayloadTraceAttributes(prefix, payload) {
|
|
55
|
-
const size = serializedLength(payload);
|
|
56
|
-
const attributes = {
|
|
57
|
-
[`${prefix}.type`]: payloadType(payload),
|
|
58
|
-
[`${prefix}.size_chars`]: size,
|
|
59
|
-
[`${prefix}.size`]: size
|
|
60
|
-
};
|
|
61
|
-
const keys = payloadKeys(payload);
|
|
62
|
-
if (keys) attributes[`${prefix}.keys`] = keys;
|
|
63
|
-
return attributes;
|
|
64
|
-
}
|
|
65
|
-
function summarizeContent(content) {
|
|
66
|
-
if (typeof content === "string") return {
|
|
67
|
-
chars: content.length,
|
|
68
|
-
partTypes: ["text"]
|
|
69
|
-
};
|
|
70
|
-
if (!Array.isArray(content)) return {
|
|
71
|
-
chars: serializedLength(content),
|
|
72
|
-
partTypes: [payloadType(content)]
|
|
73
|
-
};
|
|
74
|
-
let chars = 0;
|
|
75
|
-
const partTypes = /* @__PURE__ */ new Set();
|
|
76
|
-
for (const part of content) {
|
|
77
|
-
if (!part || typeof part !== "object") {
|
|
78
|
-
chars += serializedLength(part);
|
|
79
|
-
partTypes.add(payloadType(part));
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const record = part;
|
|
83
|
-
const type = canonicalContentPartType(typeof record["type"] === "string" ? record["type"] : "unknown");
|
|
84
|
-
partTypes.add(type);
|
|
85
|
-
if (typeof record["text"] === "string") chars += record["text"].length;
|
|
86
|
-
else if (typeof record["thinking"] === "string") chars += record["thinking"].length;
|
|
87
|
-
else if (typeof record["data"] === "string") chars += record["data"].length;
|
|
88
|
-
else chars += serializedLength(part);
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
chars,
|
|
92
|
-
partTypes: [...partTypes]
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function normalizeFinishReason(reason) {
|
|
96
|
-
return reason === "toolUse" ? "tool_call" : reason;
|
|
97
|
-
}
|
|
98
|
-
function canonicalContentPartType(type) {
|
|
99
|
-
if (type === "thinking") return "reasoning";
|
|
100
|
-
if (type === "toolCall") return "tool_call";
|
|
101
|
-
return type;
|
|
102
|
-
}
|
|
103
|
-
function toCanonicalPart(part) {
|
|
104
|
-
if (part.type === "text") return {
|
|
105
|
-
type: "text",
|
|
106
|
-
content: part.text
|
|
107
|
-
};
|
|
108
|
-
if (part.type === "thinking") {
|
|
109
|
-
if (part.redacted) return;
|
|
110
|
-
return {
|
|
111
|
-
type: "reasoning",
|
|
112
|
-
content: part.thinking
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (part.type === "toolCall") return {
|
|
116
|
-
type: "tool_call",
|
|
117
|
-
id: part.id,
|
|
118
|
-
name: part.name,
|
|
119
|
-
arguments: part.arguments
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function toCanonicalParts(parts) {
|
|
123
|
-
return parts.map(toCanonicalPart).filter((part) => part !== void 0);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Map a pi-ai AssistantMessage to the canonical gen_ai.output.messages shape:
|
|
127
|
-
* `{ role, parts: [...], finish_reason }` — drops provider noise fields.
|
|
128
|
-
*/
|
|
129
|
-
function toCanonicalOutputMessage(message) {
|
|
130
|
-
return {
|
|
131
|
-
role: "assistant",
|
|
132
|
-
parts: toCanonicalParts(message.content),
|
|
133
|
-
finish_reason: normalizeFinishReason(message.stopReason)
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Map a pi-ai Message (system/user/assistant/toolResult) to the canonical
|
|
138
|
-
* gen_ai.input.messages shape: `{ role, parts: [...] }`.
|
|
139
|
-
*/
|
|
140
|
-
function toCanonicalInputMessage(message) {
|
|
141
|
-
if (message.role === "system") return {
|
|
142
|
-
role: "system",
|
|
143
|
-
parts: [{
|
|
144
|
-
type: "text",
|
|
145
|
-
content: renderSystemMessageUpdate(message)
|
|
146
|
-
}]
|
|
147
|
-
};
|
|
148
|
-
if (message.role === "user") return {
|
|
149
|
-
role: "user",
|
|
150
|
-
parts: typeof message.content === "string" ? [{
|
|
151
|
-
type: "text",
|
|
152
|
-
content: message.content
|
|
153
|
-
}] : toCanonicalParts(message.content)
|
|
154
|
-
};
|
|
155
|
-
if (message.role === "toolResult") return {
|
|
156
|
-
role: "tool",
|
|
157
|
-
parts: [{
|
|
158
|
-
type: "tool_call_response",
|
|
159
|
-
id: message.toolCallId,
|
|
160
|
-
response: toCanonicalParts(message.content)
|
|
161
|
-
}]
|
|
162
|
-
};
|
|
163
|
-
return toCanonicalOutputMessage(message);
|
|
164
|
-
}
|
|
165
|
-
/** Summarize a message list without exposing raw message content. */
|
|
166
|
-
function toGenAiMessagesTraceAttributes(prefix, messages) {
|
|
167
|
-
let contentChars = 0;
|
|
168
|
-
const roles = /* @__PURE__ */ new Set();
|
|
169
|
-
const partTypes = /* @__PURE__ */ new Set();
|
|
170
|
-
for (const message of messages) {
|
|
171
|
-
if (!message || typeof message !== "object") {
|
|
172
|
-
contentChars += serializedLength(message);
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
const record = message;
|
|
176
|
-
if (typeof record["role"] === "string") roles.add(record["role"]);
|
|
177
|
-
const summary = summarizeContent(record["content"]);
|
|
178
|
-
contentChars += summary.chars;
|
|
179
|
-
for (const partType of summary.partTypes) partTypes.add(partType);
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
[`${prefix}.message_count`]: messages.length,
|
|
183
|
-
[`${prefix}.content_chars`]: contentChars,
|
|
184
|
-
[`${prefix}.messages.size`]: contentChars,
|
|
185
|
-
...roles.size > 0 ? { [`${prefix}.roles`]: [...roles] } : void 0,
|
|
186
|
-
...partTypes.size > 0 ? { [`${prefix}.part_types`]: [...partTypes] } : void 0
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
export { toCanonicalInputMessage as a, toGenAiPayloadMetadata as c, runWithConversationPrivacy as i, toGenAiPayloadTraceAttributes as l, getCurrentConversationPrivacy as n, toCanonicalOutputMessage as o, resolveConversationPrivacy as r, toGenAiMessagesTraceAttributes as s, canExposeConversationPayload as t };
|