@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.
Files changed (139) hide show
  1. package/dist/{admin-5jUYY46p.js → admin-CAugg87B.js} +1 -1
  2. package/dist/{agent-runner-C7GNLRB6.js → agent-runner-AjrEV6Qe.js} +13532 -12811
  3. package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
  4. package/dist/{agent-update-delivery-BNEYQsAf.js → agent-update-delivery-B_YIZcgf.js} +10 -37
  5. package/dist/api/schema.d.ts +609 -104
  6. package/dist/api/schema.js +6 -6
  7. package/dist/api.js +373 -469
  8. package/dist/{app-D_bAXRDe.d.ts → app-MoNAsVV5.d.ts} +52 -28
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +177 -132
  11. package/dist/catalog-runtime-DfSpJZdY.js +6 -0
  12. package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
  13. package/dist/{adapter-context-BlSGE44V.js → channel-access-j-YAVYK4.js} +2 -42
  14. package/dist/{chat-core-engine-CxkwRpn9.js → chat-core-engine-aH85nEHv.js} +4 -3
  15. package/dist/{child-message--2G3Ft26.js → child-message-DHjQLEd1.js} +1 -1
  16. package/dist/cli/chat.js +23 -23
  17. package/dist/cli/check.js +5 -5
  18. package/dist/cli/main.js +2 -2
  19. package/dist/cli/plugins.js +5 -4
  20. package/dist/cli/snapshot-create.js +5 -2
  21. package/dist/cli/upgrade.js +27 -5
  22. package/dist/config-CHQ8X251.js +2422 -0
  23. package/dist/{continue-in-slack-BGKjIdFp.js → continue-in-slack-D-FZ8Fin.js} +2 -3
  24. package/dist/{conversation-feed-Sl8lKKmR.js → conversation-feed--9S0_PXL.js} +9 -4
  25. package/dist/{proxy-path-Dc-0jXGi.js → conversation-privacy-B1uXn5sf.js} +2 -16
  26. package/dist/{conversation-turn-BoLK9i6g.js → conversation-turn-BUE_7xaN.js} +102 -172
  27. package/dist/{create-BOycVH9h.js → create-DoDIYgtZ.js} +12 -10
  28. package/dist/{credential-sync-Mn4OdkEh.js → credential-sync-BJOqGnjV.js} +17 -12
  29. package/dist/{db-DXTOYRzR.js → db-BFmyYZtJ.js} +20276 -27398
  30. package/dist/{deployment-CG3TchWh.js → deployment-DXq9ZLU4.js} +17 -15
  31. package/dist/{engine-context-dyWlfNdD.js → engine-context-CgQ7mlHt.js} +264 -50
  32. package/dist/{html-CfXEwl_h.js → html-B3VKTGbJ.js} +6 -2
  33. package/dist/instrumentation.js +15 -7
  34. package/dist/{job-runner-CySgpi9v.js → job-runner-A1lCkybD.js} +397 -22
  35. package/dist/{lineage-tRTOcrsL.js → lineage-Bktb0UcV.js} +1 -1
  36. package/dist/{list-DXBz8SYL.js → list-Bxvg5wXf.js} +260 -698
  37. package/dist/{logging-czs0nqLC.js → logging--smS7XRK.js} +2 -2
  38. package/dist/{mailbox-turn-79Nv1JXv.js → mailbox-turn-uSXhUFc9.js} +648 -2957
  39. package/dist/{message-BTox2Cmb.js → message-BNenhsmB.js} +12 -22
  40. package/dist/{model-input-IRGa98V7.js → model-input-BReSnwHp.js} +3 -3
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +20 -6
  43. package/dist/{oauth-callback-server-NXK7AlBp.js → oauth-callback-server-CE4soEIY.js} +2 -2
  44. package/dist/{oauth-relay-6NBPSpFE.js → oauth-relay-C36gX1gH.js} +2 -2
  45. package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
  46. package/dist/{parent-result-Dg6P6roR.js → parent-result-Ck1rFYRQ.js} +93 -106
  47. package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
  48. package/dist/profile-BQ-iBDsZ.js +4657 -0
  49. package/dist/{transcript-BHhJVY0P.js → prompt-Dv7gkpD6.js} +97 -103
  50. package/dist/proxy-path-BHYoKZdq.js +15 -0
  51. package/dist/registry-iXMT5Jmh.js +3279 -0
  52. package/dist/reports-WKHfGTsU.js +195 -0
  53. package/dist/{resolve-BUFkmxkT.js → resolve-tony4ibz.js} +9 -29
  54. package/dist/{result-DfATzX77.js → result-Bta_dlWa.js} +42 -117
  55. package/dist/run-conversation-DL6ru7iW.js +336 -0
  56. package/dist/{runner-CmKP3inb.js → runner-BstDRbD9.js} +7 -7
  57. package/dist/{sandbox-egress-signals-DYo5BsM7.js → sandbox-egress-signals-oSJMJOnn.js} +1 -1
  58. package/dist/{schema-DrBMdPmv.js → schema-DfqrHACA.js} +67 -84
  59. package/dist/sender-actors-CPglLd5R.js +83 -0
  60. package/dist/{service-account-CxTX7nnR.js → service-account-CTV_jaNu.js} +3 -1
  61. package/dist/{skills-BlHUDj7k.js → skills-BCEU41zM.js} +4 -4
  62. package/dist/{slack-conversation-unfurl-Dhe3lB1U.js → slack-conversation-unfurl-DxVmhbGP.js} +7 -6
  63. package/dist/{spawn-CfvlFdfz.js → spawn-frczVPIr.js} +11 -8
  64. package/dist/{system-prompt-table-CDCYVwqN.js → system-prompt-table-CiXy0eNR.js} +91 -70
  65. package/dist/{task-runner-DcdQJd9e.js → task-runner-C9Yc2_ae.js} +35 -49
  66. package/dist/{thread-context-DF5uDcWN.js → thread-context-CqZDKErp.js} +6 -6
  67. package/dist/topics-SRN7IVX-.js +24 -0
  68. package/dist/turn-membership-CENFf3kI.js +856 -0
  69. package/dist/{turn-wake-um5Ubd4m.js → turn-wake-BhloiI2h.js} +4 -5
  70. package/dist/{media-Cr9pGkzr.js → types-C4iC-IMC.js} +819 -777
  71. package/dist/user-customization-CvfuY9Eo.js +93 -0
  72. package/dist/users-ByG5RCEJ.js +181 -0
  73. package/dist/{validation-CJyuOPD2.js → validation-8gjfR91V.js} +1 -1
  74. package/dist/{version-Bhe7RPIe.js → version-BeZhWWBE.js} +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/{worker-D8PRgUqr.js → worker-BqMQQNRk.js} +5 -4
  77. package/migrations/20261125171254_conversation_visibility/migration.sql +4 -0
  78. package/migrations/20261125171254_conversation_visibility/snapshot.json +67 -0
  79. package/migrations/20261125171257_conversation_visibility_backfill/migration.sql +25 -0
  80. package/migrations/20261125171257_conversation_visibility_backfill/snapshot.json +9 -0
  81. package/migrations/20261125213232_drop_versions_notify/migration.sql +19 -0
  82. package/migrations/20261125213232_drop_versions_notify/snapshot.json +9 -0
  83. package/migrations/20261125225138_conversation_kind_root_thread/migration.sql +23 -0
  84. package/migrations/20261125225138_conversation_kind_root_thread/snapshot.json +55 -0
  85. package/migrations/20261125225142_conversation_kind_root_thread_backfill/migration.sql +7 -0
  86. package/migrations/20261125225142_conversation_kind_root_thread_backfill/snapshot.json +9 -0
  87. package/migrations/20261126000151_conversation_event_message_role_seq_index/migration.sql +1 -0
  88. package/migrations/20261126000151_conversation_event_message_role_seq_index/snapshot.json +69 -0
  89. package/migrations/20261126012917_merge_leaves/migration.sql +2 -0
  90. package/migrations/20261126012917_merge_leaves/snapshot.json +12 -0
  91. package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
  92. package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
  93. package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
  94. package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
  95. package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
  96. package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
  97. package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
  98. package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
  99. package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
  100. package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
  101. package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
  102. package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
  103. package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
  104. package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
  105. package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
  106. package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
  107. package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
  108. package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
  109. package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
  110. package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
  111. package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
  112. package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
  113. package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
  114. package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
  115. package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
  116. package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
  117. package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
  118. package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
  119. package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
  120. package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
  121. package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
  122. package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
  123. package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
  124. package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
  125. package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
  126. package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
  127. package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
  128. package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
  129. package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
  130. package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
  131. package/package.json +5 -5
  132. package/skills/jr-rpc/SKILL.md +3 -5
  133. package/dist/direct-url-BYgYfuIy.js +0 -22
  134. package/dist/markers-CE0HMXWT.js +0 -67
  135. package/dist/people-Cegp1Iwq.js +0 -81
  136. package/dist/start-conversation-Uh8Sk1EF.js +0 -162
  137. package/dist/turn-session-routing-GtetHsdO.js +0 -1309
  138. package/dist/user-customization-B27StpVQ.js +0 -9
  139. package/dist/web-message-id-C6P83ans.js +0 -10
@@ -0,0 +1,195 @@
1
+ import { Pi as createPluginState, St as getRegistrations, Vi as basePluginContext, ur as createPluginConversationEventStats } from "./db-BFmyYZtJ.js";
2
+ import { h as createPluginLogger, r as runPluginHooksAtOnce } from "./prompt-Dv7gkpD6.js";
3
+ // src/chat/plugins/hooks/reports.ts
4
+ const OPERATIONAL_REPORT_MAX_METRICS = 8;
5
+ const OPERATIONAL_REPORT_MAX_WIDGETS = 12;
6
+ const OPERATIONAL_REPORT_MAX_CHART_SERIES = 8;
7
+ const OPERATIONAL_REPORT_MAX_RECORD_SETS = 8;
8
+ const OPERATIONAL_REPORT_MAX_FIELDS = 8;
9
+ const OPERATIONAL_REPORT_MAX_RECORDS = 25;
10
+ const OPERATIONAL_REPORT_MAX_LABEL_LENGTH = 80;
11
+ const OPERATIONAL_REPORT_MAX_VALUE_LENGTH = 160;
12
+ function pluginReadState(state) {
13
+ return { get: state.get };
14
+ }
15
+ function operationalReportText(value, maxLength) {
16
+ if (typeof value !== "string") return;
17
+ const trimmed = value.trim();
18
+ if (!trimmed) return;
19
+ return trimmed.length <= maxLength ? trimmed : `${trimmed.slice(0, Math.max(0, maxLength - 3))}...`;
20
+ }
21
+ function operationalReportTone(tone) {
22
+ return tone === "danger" || tone === "good" || tone === "neutral" || tone === "warning" ? tone : void 0;
23
+ }
24
+ function sanitizeOperationalReport(args) {
25
+ const metrics = args.report.metrics?.slice(0, OPERATIONAL_REPORT_MAX_METRICS).map((metric) => {
26
+ const label = operationalReportText(metric.label, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
27
+ const value = operationalReportText(metric.value, OPERATIONAL_REPORT_MAX_VALUE_LENGTH);
28
+ if (!label || !value) return;
29
+ const sanitizedMetric = {
30
+ label,
31
+ value
32
+ };
33
+ const tone = operationalReportTone(metric.tone);
34
+ if (tone) sanitizedMetric.tone = tone;
35
+ return sanitizedMetric;
36
+ }).filter((metric) => Boolean(metric));
37
+ const recordSets = args.report.recordSets?.slice(0, OPERATIONAL_REPORT_MAX_RECORD_SETS).map((recordSet, recordSetIndex) => {
38
+ const title = operationalReportText(recordSet.title, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
39
+ if (!title) return;
40
+ const fields = recordSet.fields?.slice(0, OPERATIONAL_REPORT_MAX_FIELDS).map((field) => {
41
+ const key = operationalReportText(field.key, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
42
+ const label = operationalReportText(field.label, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
43
+ return key && label ? {
44
+ key,
45
+ label
46
+ } : void 0;
47
+ }).filter((field) => Boolean(field));
48
+ const records = recordSet.records?.slice(0, OPERATIONAL_REPORT_MAX_RECORDS).map((record, recordIndex) => {
49
+ const sanitizedRecord = {
50
+ id: operationalReportText(record.id, OPERATIONAL_REPORT_MAX_LABEL_LENGTH) ?? `${recordSetIndex}:${recordIndex}`,
51
+ values: Object.fromEntries((fields ?? []).map((field) => [field.key, operationalReportText(record.values[field.key], OPERATIONAL_REPORT_MAX_VALUE_LENGTH) ?? ""]))
52
+ };
53
+ const tone = operationalReportTone(record.tone);
54
+ if (tone) sanitizedRecord.tone = tone;
55
+ return sanitizedRecord;
56
+ });
57
+ const sanitizedRecordSet = { title };
58
+ if (fields?.length) sanitizedRecordSet.fields = fields;
59
+ const emptyText = operationalReportText(recordSet.emptyText, OPERATIONAL_REPORT_MAX_VALUE_LENGTH);
60
+ if (emptyText) sanitizedRecordSet.emptyText = emptyText;
61
+ if (records?.length) sanitizedRecordSet.records = records;
62
+ return sanitizedRecordSet;
63
+ }).filter((recordSet) => Boolean(recordSet));
64
+ const widgets = args.report.widgets?.slice(0, OPERATIONAL_REPORT_MAX_WIDGETS).map((widget, widgetIndex) => {
65
+ const id = operationalReportText(widget.id, OPERATIONAL_REPORT_MAX_LABEL_LENGTH) ?? String(widgetIndex);
66
+ const title = operationalReportText(widget.title, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
67
+ if (!title) return;
68
+ const seriesEntries = widget.series.slice(0, OPERATIONAL_REPORT_MAX_CHART_SERIES).map((item) => {
69
+ const key = operationalReportText(item.key, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
70
+ const label = operationalReportText(item.label, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
71
+ if (!key || !label) return;
72
+ const sanitizedSeries = {
73
+ key,
74
+ label
75
+ };
76
+ if (item.format === "usd") sanitizedSeries.format = "usd";
77
+ const tone = operationalReportTone(item.tone);
78
+ if (tone) sanitizedSeries.tone = tone;
79
+ return {
80
+ sanitizedSeries,
81
+ sourceKey: item.key
82
+ };
83
+ }).filter((item) => Boolean(item));
84
+ if (!seriesEntries.length) return;
85
+ const series = seriesEntries.map((item) => item.sanitizedSeries);
86
+ const sanitizedWidget = {
87
+ categories: widget.categories.slice(-100).map((category, categoryIndex) => ({
88
+ id: operationalReportText(category.id, OPERATIONAL_REPORT_MAX_LABEL_LENGTH) ?? `${widgetIndex}:${categoryIndex}`,
89
+ label: operationalReportText(category.label, OPERATIONAL_REPORT_MAX_LABEL_LENGTH) ?? String(categoryIndex + 1),
90
+ values: Object.fromEntries(seriesEntries.map(({ sanitizedSeries, sourceKey }) => {
91
+ const value = category.values[sourceKey];
92
+ return [sanitizedSeries.key, value !== void 0 && Number.isFinite(value) ? value : 0];
93
+ }))
94
+ })),
95
+ id,
96
+ series,
97
+ title,
98
+ type: "bar_chart"
99
+ };
100
+ const description = operationalReportText(widget.description, OPERATIONAL_REPORT_MAX_VALUE_LENGTH);
101
+ if (description) sanitizedWidget.description = description;
102
+ const emptyText = operationalReportText(widget.emptyText, OPERATIONAL_REPORT_MAX_VALUE_LENGTH);
103
+ if (emptyText) sanitizedWidget.emptyText = emptyText;
104
+ const timeRangeDays = widget.timeRangeDays?.filter((days) => days === 1 || days === 7 || days === 30 || days === 90);
105
+ if (timeRangeDays?.length) sanitizedWidget.timeRangeDays = [...new Set(timeRangeDays)];
106
+ return sanitizedWidget;
107
+ }).filter((widget) => Boolean(widget));
108
+ const sanitized = { pluginName: args.pluginName };
109
+ const generatedAt = operationalReportText(args.report.generatedAt, OPERATIONAL_REPORT_MAX_VALUE_LENGTH);
110
+ if (generatedAt) sanitized.generatedAt = generatedAt;
111
+ if (recordSets?.length) sanitized.recordSets = recordSets;
112
+ if (metrics?.length) sanitized.metrics = metrics;
113
+ if (widgets?.length) sanitized.widgets = widgets;
114
+ const title = operationalReportText(args.report.title, OPERATIONAL_REPORT_MAX_LABEL_LENGTH);
115
+ if (title) sanitized.title = title;
116
+ return sanitized;
117
+ }
118
+ function failedOperationalReport(args) {
119
+ return {
120
+ generatedAt: new Date(args.nowMs).toISOString(),
121
+ pluginName: args.pluginName,
122
+ metrics: [{
123
+ label: "report",
124
+ tone: "danger",
125
+ value: "failed"
126
+ }],
127
+ title: args.pluginName,
128
+ recordSets: [{
129
+ emptyText: "This plugin report failed to load.",
130
+ title: "Error"
131
+ }]
132
+ };
133
+ }
134
+ /** Collect read-only operational summaries exposed by plugins. */
135
+ async function getPluginOperationalReports(nowMs) {
136
+ const reports = [];
137
+ const outcomes = await runPluginHooksAtOnce(getRegistrations(), (plugin) => {
138
+ const hook = plugin.hooks?.operationalReport;
139
+ return hook && (() => hook({
140
+ ...basePluginContext(plugin),
141
+ eventStats: createPluginConversationEventStats(plugin, () => nowMs),
142
+ nowMs,
143
+ state: pluginReadState(createPluginState(plugin.manifest.name))
144
+ }));
145
+ });
146
+ for (const outcome of outcomes) {
147
+ const pluginName = outcome.plugin.manifest.name;
148
+ try {
149
+ if ("error" in outcome) throw outcome.error;
150
+ const report = outcome.value;
151
+ if (!report) continue;
152
+ reports.push(sanitizeOperationalReport({
153
+ pluginName,
154
+ report
155
+ }));
156
+ } catch (error) {
157
+ createPluginLogger(pluginName).error("Plugin operational report failed", { error: error instanceof Error ? error.message : String(error) });
158
+ reports.push(failedOperationalReport({
159
+ nowMs,
160
+ pluginName
161
+ }));
162
+ }
163
+ }
164
+ return reports;
165
+ }
166
+ /** Collect person-scoped plugin reports for one profile subject. */
167
+ async function getPluginProfileReports(args) {
168
+ const reports = [];
169
+ const outcomes = await runPluginHooksAtOnce(getRegistrations(), (plugin) => {
170
+ const hook = plugin.hooks?.profileReport;
171
+ return hook && (() => hook({
172
+ ...basePluginContext(plugin),
173
+ nowMs: args.nowMs,
174
+ state: pluginReadState(createPluginState(plugin.manifest.name)),
175
+ subject: args.subject,
176
+ viewer: args.viewer
177
+ }));
178
+ });
179
+ for (const outcome of outcomes) {
180
+ const pluginName = outcome.plugin.manifest.name;
181
+ try {
182
+ if ("error" in outcome) throw outcome.error;
183
+ const report = outcome.value;
184
+ if (!report) continue;
185
+ reports.push(sanitizeOperationalReport({
186
+ pluginName,
187
+ report
188
+ }));
189
+ } catch (error) {
190
+ createPluginLogger(pluginName).error("Plugin profile report failed", { error: error instanceof Error ? error.message : String(error) });
191
+ }
192
+ }
193
+ return reports;
194
+ }
195
+ export { getPluginOperationalReports, getPluginProfileReports };
@@ -1,38 +1,18 @@
1
- import { Ad as sleep, Kn as isStale, Oa as runNonInteractiveCommand, Qd as getStateAdapter, Wn as create, Yn as getSandboxProvider, qn as CURL_DOWNLOAD_ARGS } from "./db-DXTOYRzR.js";
2
- import { E as SANDBOX_COMMAND_PATH, M as SANDBOX_WORKSPACE_ROOT } from "./transcript-BHhJVY0P.js";
3
- import { E as withSpan, b as setSpanAttributes } from "./logging-czs0nqLC.js";
1
+ import { n as getChatConfig } from "./config-CHQ8X251.js";
2
+ import { Js as sleep, Ku as getStateAdapter, qi as runNonInteractiveCommand } from "./db-BFmyYZtJ.js";
3
+ import { a as SANDBOX_COMMAND_PATH, d as SANDBOX_WORKSPACE_ROOT } from "./prompt-Dv7gkpD6.js";
4
+ import { i as CURL_DOWNLOAD_ARGS, o as getSandboxProvider, r as isStale, t as create } from "./profile-BQ-iBDsZ.js";
5
+ import { E as withSpan, b as setSpanAttributes } from "./logging--smS7XRK.js";
4
6
  import * as z from "zod";
5
7
  // src/chat/sandbox/resources.ts
6
- let configuredResources;
7
- function resourcesFromEnv() {
8
- const value = process.env["SANDBOX_VCPUS"]?.trim();
9
- if (!value || !/^\d+$/.test(value)) return;
10
- const vcpus = Number(value);
11
- if (!Number.isSafeInteger(vcpus) || vcpus <= 0) return;
12
- return { vcpus };
13
- }
14
- /** Return the app-level sandbox sizing override. */
15
- function getSandboxResourceConfig() {
16
- return configuredResources;
17
- }
18
- /** Replace app-level sandbox sizing and return the previous setting. */
19
- function setSandboxResourceConfig(config) {
20
- const previous = configuredResources;
21
- if (config?.vcpus === void 0) {
22
- configuredResources = void 0;
23
- return previous;
24
- }
25
- if (!Number.isSafeInteger(config.vcpus) || config.vcpus <= 0) throw new Error("sandbox.vcpus must be a positive integer");
26
- configuredResources = { vcpus: config.vcpus };
27
- return previous;
28
- }
29
8
  /**
30
9
  * Resolve sandbox sizing. A Workspace vCPU setting wins over the app setting,
31
- * which wins over the legacy environment setting.
10
+ * which wins over `SANDBOX_VCPUS`.
32
11
  */
33
12
  function getSandboxResources(workspace) {
34
13
  if (workspace?.vcpus) return { vcpus: workspace.vcpus };
35
- return configuredResources ?? resourcesFromEnv();
14
+ const { vcpus } = getChatConfig().sandbox;
15
+ return vcpus === void 0 ? void 0 : { vcpus };
36
16
  }
37
17
  // src/chat/sandbox/snapshot/span.ts
38
18
  /** Record the reusable snapshot selected for a new Sandbox. */
@@ -444,4 +424,4 @@ async function resolve(params) {
444
424
  };
445
425
  });
446
426
  }
447
- export { setSnapshotSpanAttributes as a, setSandboxResourceConfig as c, postinstall as i, resolve as n, getSandboxResourceConfig as o, dependencies as r, getSandboxResources as s, getCachedSnapshot as t };
427
+ export { setSnapshotSpanAttributes as a, postinstall as i, resolve as n, getSandboxResources as o, dependencies as r, getCachedSnapshot as t };
@@ -1,88 +1,36 @@
1
- import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { Gu as publishAgentUpdate, Ku as starterWatchId, i as getConversationStore, qu as updateEventKey, ul as SYSTEM_IDENTITY_ID } from "./db-DXTOYRzR.js";
3
- import { An as hasConversationNote, Ci as readParentMessage, G as enqueueAutomatedInput, K as getConversationStoppedAtMs, Mn as buildDeterministicTurnId, O as EVENT_WAIT_MS, P as quietEventNoteKey, a as resolveMailboxTurnWork, dn as getConversationWorkState, g as parentMessageText, h as logDroppedParentMessage, i as listActiveMailboxTurns, jr as EVENT_SYSTEM_ACTOR, x as getAgentReplyMessageId } from "./mailbox-turn-79Nv1JXv.js";
4
- import { G as mapBounded, H as renderDataTag } from "./transcript-BHhJVY0P.js";
5
- import { _ as getChildAgentInputSender, b as readChildConversationSender, g as childAgentInput, l as listUnreportedSiblingAgents, r as childAgentStillWorks, t as parentResultActor, y as isDroppedChildInput } from "./parent-result-Dg6P6roR.js";
6
- import { n as listChildMessages, t as childMessageSenderMetadata } from "./child-message--2G3Ft26.js";
7
- import { t as recordChildAgentEnded } from "./markers-CE0HMXWT.js";
8
- import { Dn as AGENT_MESSAGE_EVENT_TYPE, En as AGENT_INVOCATION_EVENT_NAMESPACE, On as AGENT_UPDATE_EVENT_TYPE } from "./media-Cr9pGkzr.js";
9
- import * as z from "zod";
10
- import { actorSchema } from "@sentry/junior-plugin-api";
11
- // src/chat/agent-invocations/result-actors.ts
12
- const senderActorMetadataSchema = z.object({ actor: actorSchema });
1
+ import { Nn as readInboundMessageSender, i as getConversationStore, lu as remindsNoReplyForChildStatus, mo as publishAgentUpdate, oc as SYSTEM_IDENTITY_ID, rn as getConversationWorkState } from "./db-BFmyYZtJ.js";
2
+ import { O as EVENT_WAIT_MS, Rt as buildDeterministicTurnId, S as getAgentReplyMessageId, U as enqueueAutomatedInput, W as getConversationStoppedAtMs, Xn as EVENT_SYSTEM_ACTOR, b as readAgentConfig, i as listActiveMailboxTurns, x as getAgentMessageId } from "./mailbox-turn-uSXhUFc9.js";
3
+ import { c as listUnreportedSiblingAgents, m as readChildConversationSender, n as recordChildAgentEnded, s as listOpenChildAgents, t as parentResultActor } from "./parent-result-Ck1rFYRQ.js";
4
+ import { t as resultAuthorId } from "./sender-actors-CPglLd5R.js";
5
+ import { n as listChildMessages, t as childMessageSenderMetadata } from "./child-message-DHjQLEd1.js";
6
+ import { U as renderDataTag } from "./prompt-Dv7gkpD6.js";
7
+ import { _ as NO_REPLY_TOOL_NAME } from "./system-prompt-table-CiXy0eNR.js";
8
+ import { En as AGENT_UPDATE_EVENT_TYPE, Tn as AGENT_MESSAGE_EVENT_TYPE, wn as AGENT_EVENT_NAMESPACE } from "./types-C4iC-IMC.js";
9
+ // src/chat/child-agents/store.ts
13
10
  /**
14
- * Return the Inbound message author id for results sent by one Actor.
15
- * `selectContiguousTurnBatch` in `task-execution/worker.ts` puts messages in
16
- * one attempt only when their author ids and sources match. Mid-Turn drains
17
- * take only `interrupt` messages, and results are `defer`. So results never
18
- * share a Turn and its credentials with another Actor or with watch Events.
19
- * Keep this id unique per Actor if either rule changes.
11
+ * Read the name, agent type, fork flag, and title of one child Conversation,
12
+ * for labels, from its binding, title, and agent config.
20
13
  */
21
- function resultAuthorId(actor) {
22
- switch (actor.platform) {
23
- case "system": return `agent-invocation:system:${actor.name}`;
24
- case "slack": return `agent-invocation:slack:${actor.teamId}:${actor.userId}`;
25
- default: return `agent-invocation:${actor.platform}:${actor.userId}`;
26
- }
27
- }
28
- /** Read the Actor of the child Turn that a reply or message carries. */
29
- function senderActorFromMetadata(metadata) {
30
- const parsed = senderActorMetadataSchema.safeParse(metadata);
31
- return parsed.success ? parsed.data.actor : void 0;
14
+ async function getChildAgentLabel(childConversationId) {
15
+ const [sender, options] = await Promise.all([readChildConversationSender(childConversationId), readAgentConfig(childConversationId)]);
16
+ return sender && options ? {
17
+ agentName: sender.agentName ?? null,
18
+ agentType: options.agentType ?? null,
19
+ fork: options.fork ?? false,
20
+ title: sender.title ?? null
21
+ } : void 0;
32
22
  }
33
23
  /**
34
- * Run each child reply or message as the Actor of the child Turn that sent
35
- * it, which the input carries, so the parent never gets more authority than
36
- * that Turn. A parent message from the stored parent runs as the Actor of the
37
- * parent's Turn, with its grants and text. Input that a Turn with another
38
- * Actor sent, or that names no child of this Conversation, runs as the Event
39
- * system Actor. Input that `isDroppedChildInput` drops is left out. Returns
40
- * undefined when no input is left.
24
+ * Return whether a child agent still works when its Turn ends with final
25
+ * text: one of its own child agents has open work, or a result or message
26
+ * from one of them waits in its mailbox. That final text then goes to the
27
+ * parent as a message, not as the child's result.
41
28
  */
42
- async function withAgentInvocationResultActors(work) {
43
- if (work.kind !== "mailbox") return work;
44
- const kept = (await mapBounded(work.batch, async (entry) => {
45
- const parentMessage = readParentMessage(entry.message);
46
- if (parentMessage) {
47
- if (await isDroppedChildInput(entry.message)) {
48
- logDroppedParentMessage(entry.message, parentMessage);
49
- return;
50
- }
51
- const text = await parentMessageText(entry.message, parentMessage);
52
- return {
53
- ...entry,
54
- actor: parentMessage.actor,
55
- requestText: entry.message.input.text.trim(),
56
- ...parentMessage.credentialContext ? { credentialContext: parentMessage.credentialContext } : void 0,
57
- message: {
58
- ...entry.message,
59
- input: {
60
- ...entry.message.input,
61
- text
62
- }
63
- }
64
- };
65
- }
66
- const input = childAgentInput(entry.message);
67
- if (!input) return entry;
68
- if (await isDroppedChildInput(entry.message)) return;
69
- const sender = await getChildAgentInputSender(entry.message, input);
70
- const actor = senderActorFromMetadata(entry.message.input.metadata);
71
- if (!sender || !actor || entry.message.input.authorId !== resultAuthorId(actor)) return {
72
- ...entry,
73
- actor: EVENT_SYSTEM_ACTOR
74
- };
75
- return {
76
- ...entry,
77
- actor
78
- };
79
- })).filter((entry) => entry !== void 0);
80
- return kept.length > 0 ? {
81
- kind: "mailbox",
82
- batch: kept
83
- } : void 0;
29
+ async function childAgentStillWorks(conversationId) {
30
+ if ((await listOpenChildAgents(conversationId)).length > 0) return true;
31
+ return ((await getConversationWorkState({ conversationId }))?.messages ?? []).some((message) => readInboundMessageSender(message) !== void 0);
84
32
  }
85
- // src/chat/agent-invocations/agent-update.ts
33
+ // src/chat/child-agents/agent-update.ts
86
34
  /**
87
35
  * Agent update: what one Conversation reports to the agents that wait on
88
36
  * it. Every kind of Conversation reports with the same update. A parent gets
@@ -106,16 +54,15 @@ function renderAgentResult(args) {
106
54
  waiting_on: args.waitingOn
107
55
  }, "An agent", text || "(empty)");
108
56
  }
109
- // src/chat/agent-invocations/result.ts
110
- var result_exports = /* @__PURE__ */ __exportAll({ createChildConversationWorker: () => createChildConversationWorker });
57
+ // src/chat/child-agents/result.ts
111
58
  /**
112
59
  * Render the parent agent input for one child agent result as one
113
60
  * `<agent-result>`, the agent update that a Watch on the child also gets.
114
- * The system prompt says what to do for each status, so the input repeats no
115
- * guidance.
61
+ * The system prompt says what to do for each status. A Lead's done result
62
+ * also reminds it that a status update needs no reply.
116
63
  */
117
64
  function renderResultInput(sender, result, openSiblings) {
118
- return renderAgentResult({
65
+ const agentResult = renderAgentResult({
119
66
  conversationId: sender.childConversationId,
120
67
  name: sender.agentName,
121
68
  source: "child_agent",
@@ -126,6 +73,11 @@ function renderResultInput(sender, result, openSiblings) {
126
73
  },
127
74
  waitingOn: openSiblings.length ? openSiblings.map(siblingLabel).join(", ") : void 0
128
75
  });
76
+ return result.status === "done" ? withNoReplyReminder(sender, agentResult) : agentResult;
77
+ }
78
+ const NO_REPLY_REMINDER = `If this is only a status update with nothing a member needs, end with \`${NO_REPLY_TOOL_NAME}\`.`;
79
+ function withNoReplyReminder(sender, input) {
80
+ return remindsNoReplyForChildStatus(sender.parentKind) ? `${input}\n${NO_REPLY_REMINDER}` : input;
129
81
  }
130
82
  function siblingLabel(sibling) {
131
83
  return sibling.agentName ?? sibling.title ?? sibling.childConversationId;
@@ -165,12 +117,12 @@ function senderEventMetadata(actor, event) {
165
117
  };
166
118
  }
167
119
  function renderMessageInput(sender, text) {
168
- return renderDataTag("agent-message", {
120
+ return withNoReplyReminder(sender, renderDataTag("agent-message", {
169
121
  conversation_id: sender.childConversationId,
170
122
  name: sender.agentName,
171
123
  source: "child_agent",
172
124
  title: sender.title
173
- }, "A child agent that you started", text.trim());
125
+ }, "A child agent that you started", text.trim()));
174
126
  }
175
127
  /**
176
128
  * Append one message from a child agent to its parent mailbox and wake the
@@ -181,13 +133,13 @@ function renderMessageInput(sender, text) {
181
133
  async function enqueueAgentMessageToParent(args) {
182
134
  const nowMs = args.nowMs ?? Date.now();
183
135
  const senderId = args.sender.childConversationId;
184
- const inboundMessageId = `agent-invocation:${senderId}:message:${args.messageKey}`;
136
+ const inboundMessageId = getAgentMessageId(senderId, args.messageKey);
185
137
  const summary = `${childAgentLabel(args.sender)} sent a message.`;
186
138
  const metadata = senderEventMetadata(args.actor, {
187
139
  eventKey: inboundMessageId,
188
140
  eventType: AGENT_MESSAGE_EVENT_TYPE,
189
141
  identifier: senderId,
190
- namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
142
+ namespace: AGENT_EVENT_NAMESPACE,
191
143
  trustedSummary: summary
192
144
  });
193
145
  await enqueueAutomatedInput({
@@ -248,7 +200,7 @@ async function enqueueStarterUpdate(args) {
248
200
  eventKey: inboundMessageId,
249
201
  eventType: AGENT_UPDATE_EVENT_TYPE,
250
202
  identifier: senderId,
251
- namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
203
+ namespace: AGENT_EVENT_NAMESPACE,
252
204
  ...stillWorks ? void 0 : { status },
253
205
  trustedSummary: `${childAgentLabel(args.sender)} ${stillWorks ? "sent a message." : RESULT_SUMMARIES[status]}`
254
206
  }),
@@ -293,13 +245,6 @@ function createEndStoppedChildWork(options) {
293
245
  const pending = (await getConversationWorkState({ conversationId }))?.execution.pendingMessages ?? [];
294
246
  const turnIds = /* @__PURE__ */ new Set([...turns.map((turn) => turn.turnId), ...pending.map((message) => buildDeterministicTurnId(message.inboundMessageId))]);
295
247
  if ((await readParentChildMessages(sender.parentConversationId, void 0)).some((message) => message.sender.conversationId === conversationId && turnIds.has(message.sender.turnId))) return;
296
- if ((await mapBounded([...turnIds], (turnId) => hasConversationNote({
297
- conversationId: sender.parentConversationId,
298
- key: quietEventNoteKey(starterWatchId(conversationId), updateEventKey(conversationId, {
299
- type: "turn",
300
- turnId
301
- }))
302
- }))).some(Boolean)) return;
303
248
  const [turn] = turns;
304
249
  await publishAgentUpdate(conversationId, {
305
250
  type: "turn_failed",
@@ -314,24 +259,4 @@ function createEndStoppedChildWork(options) {
314
259
  });
315
260
  };
316
261
  }
317
- /**
318
- * Build the worker for all work of a child Conversation. The caller selects
319
- * it from the stored kind of the Conversation, never from a Turn Source.
320
- * Every input, such as a parent task or message, a person's Message in a
321
- * Thread, a Watch Event, or a reply of the child's own child agent, runs on
322
- * the Conversation loop, like input to a root.
323
- */
324
- function createChildConversationWorker(options) {
325
- return async (context) => {
326
- const work = await resolveMailboxTurnWork(context);
327
- const kept = work ? await withAgentInvocationResultActors(work) : void 0;
328
- if (!kept) {
329
- await context.attempt.ack();
330
- return { status: "completed" };
331
- }
332
- const result = await options.runTurn(context, kept);
333
- if (result.status === "completed") await recordChildAgentEnded(context.conversationId, "success", options);
334
- return result;
335
- };
336
- }
337
- export { result_exports as a, enqueueStarterUpdate as i, createEndStoppedChildWork as n, renderAgentResult as o, enqueueAgentMessageToParent as r, withAgentInvocationResultActors as s, createChildConversationWorker as t };
262
+ export { getChildAgentLabel as a, renderAgentResult as i, enqueueAgentMessageToParent as n, enqueueStarterUpdate as r, createEndStoppedChildWork as t };