@sentry/junior 0.316.0 → 0.318.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-QYiDMnsu.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-Cr5Fhjf-.js → agent-runner-DeYymwh2.js} +13494 -13135
- package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
- package/dist/{agent-update-delivery-BY13DPSD.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +600 -130
- package/dist/api/schema.js +6 -6
- package/dist/api.js +228 -214
- package/dist/{app-BhvzRD__.d.ts → app-DKAOuaoC.d.ts} +33 -18
- package/dist/app.d.ts +1 -1
- package/dist/app.js +193 -177
- package/dist/{thread-context-fiMNylbg.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/catalog-runtime-BfdAnztW.js +6 -0
- package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
- package/dist/{adapter-context-Bref7aPI.js → channel-access-A0de5lRv.js} +2 -42
- package/dist/{chat-core-engine-3dtlMku3.js → chat-core-engine-D3Wd7f5n.js} +6 -5
- package/dist/{child-message--2G3Ft26.js → child-message-peFWLcCZ.js} +2 -6
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -4
- package/dist/cli/snapshot-create.js +4 -2
- package/dist/cli/upgrade.js +5 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-DbQUFe_F.js → continue-in-slack-YxwMQVeR.js} +3 -3
- package/dist/{conversation-feed-B84pMjHo.js → conversation-feed-Cj7IuBtM.js} +3 -3
- package/dist/{proxy-path-BTmXDjfx.js → conversation-privacy-Cr_dNW1p.js} +2 -16
- package/dist/{conversation-turn-DzEpTIaf.js → conversation-turn-Bru4w_FD.js} +196 -80
- package/dist/{create-DUJBXr6E.js → create-Btl1y1rq.js} +12 -11
- package/dist/{credential-sync-JH_K9Adg.js → credential-sync-DTarZ63K.js} +20 -15
- package/dist/{db-DhzvUY23.js → db-of6e3sGt.js} +20724 -27256
- package/dist/{deployment-BhvrhQeh.js → deployment-C0qXa0FD.js} +17 -15
- package/dist/{engine-context-C9Nal48K.js → engine-context-C_QL_bMQ.js} +304 -56
- package/dist/{html-B_12WjKT.js → html-9_pS9SjY.js} +6 -2
- package/dist/instrumentation.js +15 -7
- package/dist/{job-runner-DO8nslyY.js → job-runner-B2XEvpif.js} +392 -26
- package/dist/{lineage-D3AZAJVe.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-B0zsb5Cp.js → list-HRP3TIRl.js} +238 -550
- package/dist/{logging-B8KEJegM.js → logging-BnOG0qz2.js} +4 -50
- package/dist/{session-stop-DponjDUZ.js → mailbox-turn-Byrry9o1.js} +4807 -7102
- package/dist/{list-mkB_GU8R.js → markers-CTTtJqYn.js} +171 -124
- package/dist/{message-B5fKDYzz.js → message-BRUuLgrY.js} +13 -24
- package/dist/{model-input-CuMWy37l.js → model-input-CFC62mf-.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +21 -7
- package/dist/{oauth-callback-server-B3Vvlydo.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-6ERrGPbA.js → oauth-relay-BvHFH0fV.js} +2 -2
- package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
- package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
- package/dist/profile-iHw1uu32.js +4657 -0
- package/dist/{transcript-CCi7323k.js → prompt-DEkStuxG.js} +92 -98
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/registry-Cl7Labpe.js +3279 -0
- package/dist/reports-C1d9azyV.js +195 -0
- package/dist/{resolve-D5JVvv6A.js → resolve-DC6zBuDV.js} +9 -29
- package/dist/{result-CS_7mo8a.js → result-DxewDuXb.js} +27 -118
- package/dist/run-conversation-Cz2ubZK-.js +337 -0
- package/dist/{runner-BzAES5W3.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-Dwhk2Q5F.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-z5-wA6N4.js → schema-BTojNBr5.js} +48 -86
- package/dist/sender-actors-77zTQbSG.js +84 -0
- package/dist/{service-account-D6AsAtc1.js → service-account-YDCPSByj.js} +3 -1
- package/dist/{skills-DgJ9GBPR.js → skills-CleC0Hze.js} +6 -5
- package/dist/{slack-conversation-unfurl-Dq71EkhM.js → slack-conversation-unfurl-BNQLC12R.js} +7 -6
- package/dist/{spawn-BJWpdwhQ.js → spawn-DuZfodPa.js} +5 -5
- package/dist/{system-prompt-table-iIgpmslr.js → system-prompt-table-Ci6Ck4gk.js} +88 -69
- package/dist/{task-runner-BJae4JwE.js → task-runner-BJ9Up3bG.js} +30 -53
- package/dist/topics-BoCkoPJJ.js +21 -0
- package/dist/turn-membership-VT7XZh-L.js +856 -0
- package/dist/{turn-wake-BjDW7x-5.js → turn-wake-C7HeLHAM.js} +3 -4
- package/dist/{media-BebquhET.js → types-DCzTAA63.js} +629 -593
- package/dist/user-customization-CvfuY9Eo.js +93 -0
- package/dist/users-Cb9c1k9q.js +181 -0
- package/dist/{validation-D5WmmmhX.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-CBQoanXb.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-Cyb4kF17.js → worker-ChWYQdhm.js} +5 -4
- package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
- package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
- package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
- package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
- package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
- package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
- package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
- package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
- package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
- package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
- package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
- package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
- package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
- package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
- package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
- package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
- package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
- package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
- package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
- package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
- package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
- package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
- package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
- package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
- package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
- package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
- package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
- package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
- package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
- package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/package.json +5 -5
- package/dist/people-CUtFApfL.js +0 -81
- package/dist/start-conversation-B-LIqqNi.js +0 -162
- package/dist/turn-session-routing-D15orfwy.js +0 -1309
- package/dist/user-customization-B27StpVQ.js +0 -9
- package/dist/web-message-id-C6P83ans.js +0 -10
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Bi as createPluginState, fr as createPluginConversationEventStats, qi as basePluginContext, wt as getRegistrations } from "./db-of6e3sGt.js";
|
|
2
|
+
import { h as createPluginLogger, r as runPluginHooksAtOnce } from "./prompt-DEkStuxG.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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { R as getChatConfig, y as getStateAdapter } from "./context-BKF_5zzI.js";
|
|
2
|
+
import { $i as runNonInteractiveCommand, Vs as sleep } from "./db-of6e3sGt.js";
|
|
3
|
+
import { a as SANDBOX_COMMAND_PATH, d as SANDBOX_WORKSPACE_ROOT } from "./prompt-DEkStuxG.js";
|
|
4
|
+
import { i as CURL_DOWNLOAD_ARGS, o as getSandboxProvider, r as isStale, t as create } from "./profile-iHw1uu32.js";
|
|
5
|
+
import { T as withSpan, y as setSpanAttributes } from "./logging-BnOG0qz2.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
|
|
10
|
+
* which wins over `SANDBOX_VCPUS`.
|
|
32
11
|
*/
|
|
33
12
|
function getSandboxResources(workspace) {
|
|
34
13
|
if (workspace?.vcpus) return { vcpus: workspace.vcpus };
|
|
35
|
-
|
|
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,
|
|
427
|
+
export { setSnapshotSpanAttributes as a, postinstall as i, resolve as n, getSandboxResources as o, dependencies as r, getCachedSnapshot as t };
|
|
@@ -1,87 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
// src/chat/agent-invocations/result-actors.ts
|
|
11
|
-
const senderActorMetadataSchema = z.object({ actor: actorSchema });
|
|
12
|
-
/**
|
|
13
|
-
* Return the Inbound message author id for results sent by one Actor.
|
|
14
|
-
* `selectContiguousTurnBatch` in `task-execution/worker.ts` puts messages in
|
|
15
|
-
* one attempt only when their author ids and sources match. Mid-Turn drains
|
|
16
|
-
* take only `interrupt` messages, and results are `defer`. So results never
|
|
17
|
-
* share a Turn and its credentials with another Actor or with watch Events.
|
|
18
|
-
* Keep this id unique per Actor if either rule changes.
|
|
19
|
-
*/
|
|
20
|
-
function resultAuthorId(actor) {
|
|
21
|
-
switch (actor.platform) {
|
|
22
|
-
case "system": return `agent-invocation:system:${actor.name}`;
|
|
23
|
-
case "slack": return `agent-invocation:slack:${actor.teamId}:${actor.userId}`;
|
|
24
|
-
default: return `agent-invocation:${actor.platform}:${actor.userId}`;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/** Read the Actor of the child Turn that a reply or message carries. */
|
|
28
|
-
function senderActorFromMetadata(metadata) {
|
|
29
|
-
const parsed = senderActorMetadataSchema.safeParse(metadata);
|
|
30
|
-
return parsed.success ? parsed.data.actor : void 0;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Run each child reply or message as the Actor of the child Turn that sent
|
|
34
|
-
* it, which the input carries, so the parent never gets more authority than
|
|
35
|
-
* that Turn. A parent message from the stored parent runs as the Actor of the
|
|
36
|
-
* parent's Turn, with its grants and text. Input that a Turn with another
|
|
37
|
-
* Actor sent, or that names no child of this Conversation, runs as the Event
|
|
38
|
-
* system Actor. Input that `isDroppedChildInput` drops is left out. Returns
|
|
39
|
-
* undefined when no input is left.
|
|
40
|
-
*/
|
|
41
|
-
async function withAgentInvocationResultActors(work) {
|
|
42
|
-
if (work.kind !== "mailbox") return work;
|
|
43
|
-
const kept = (await mapBounded(work.batch, async (entry) => {
|
|
44
|
-
const parentMessage = readParentMessage(entry.message);
|
|
45
|
-
if (parentMessage) {
|
|
46
|
-
if (await isDroppedChildInput(entry.message)) {
|
|
47
|
-
logDroppedParentMessage(entry.message, parentMessage);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const text = await parentMessageText(entry.message, parentMessage);
|
|
51
|
-
return {
|
|
52
|
-
...entry,
|
|
53
|
-
actor: parentMessage.actor,
|
|
54
|
-
requestText: entry.message.input.text.trim(),
|
|
55
|
-
...parentMessage.credentialContext ? { credentialContext: parentMessage.credentialContext } : void 0,
|
|
56
|
-
message: {
|
|
57
|
-
...entry.message,
|
|
58
|
-
input: {
|
|
59
|
-
...entry.message.input,
|
|
60
|
-
text
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const input = childAgentInput(entry.message);
|
|
66
|
-
if (!input) return entry;
|
|
67
|
-
if (await isDroppedChildInput(entry.message)) return;
|
|
68
|
-
const sender = await getChildAgentInputSender(entry.message, input);
|
|
69
|
-
const actor = senderActorFromMetadata(entry.message.input.metadata);
|
|
70
|
-
if (!sender || !actor || entry.message.input.authorId !== resultAuthorId(actor)) return {
|
|
71
|
-
...entry,
|
|
72
|
-
actor: EVENT_SYSTEM_ACTOR
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
...entry,
|
|
76
|
-
actor
|
|
77
|
-
};
|
|
78
|
-
})).filter((entry) => entry !== void 0);
|
|
79
|
-
return kept.length > 0 ? {
|
|
80
|
-
kind: "mailbox",
|
|
81
|
-
batch: kept
|
|
82
|
-
} : void 0;
|
|
83
|
-
}
|
|
84
|
-
// src/chat/agent-invocations/store.ts
|
|
1
|
+
import { $s as SYSTEM_IDENTITY_ID, Fn as readInboundMessageSender, Hl as EVENT_SYSTEM_ACTOR, Kl as CORE_EVENT_NAMESPACE, Ll as remindsNoReplyForChildStatus, Pl as parentResultActor, an as getConversationWorkState, i as getConversationStore, xo as publishAgentUpdate } from "./db-of6e3sGt.js";
|
|
2
|
+
import { H as enqueueAutomatedInput, O as EVENT_WAIT_MS, S as getAgentReplyMessageId, U as getConversationStoppedAtMs, Vt as buildDeterministicTurnId, b as readAgentConfig, i as listActiveMailboxTurns, x as getAgentMessageId } from "./mailbox-turn-Byrry9o1.js";
|
|
3
|
+
import { o as listOpenChildAgents, p as readChildConversationSender, s as listUnreportedSiblingAgents, t as recordChildAgentEnded } from "./markers-CTTtJqYn.js";
|
|
4
|
+
import { t as resultAuthorId } from "./sender-actors-77zTQbSG.js";
|
|
5
|
+
import { t as listChildMessages } from "./child-message-peFWLcCZ.js";
|
|
6
|
+
import { H as renderDataTag } from "./prompt-DEkStuxG.js";
|
|
7
|
+
import { _ as NO_REPLY_TOOL_NAME } from "./system-prompt-table-Ci6Ck4gk.js";
|
|
8
|
+
import { Rn as AGENT_MESSAGE_EVENT_TYPE, zn as AGENT_UPDATE_EVENT_TYPE } from "./types-DCzTAA63.js";
|
|
9
|
+
// src/chat/child-agents/store.ts
|
|
85
10
|
/**
|
|
86
11
|
* Read the name, agent type, fork flag, and title of one child Conversation,
|
|
87
12
|
* for labels, from its binding, title, and agent config.
|
|
@@ -105,7 +30,7 @@ async function childAgentStillWorks(conversationId) {
|
|
|
105
30
|
if ((await listOpenChildAgents(conversationId)).length > 0) return true;
|
|
106
31
|
return ((await getConversationWorkState({ conversationId }))?.messages ?? []).some((message) => readInboundMessageSender(message) !== void 0);
|
|
107
32
|
}
|
|
108
|
-
// src/chat/
|
|
33
|
+
// src/chat/child-agents/agent-update.ts
|
|
109
34
|
/**
|
|
110
35
|
* Agent update: what one Conversation reports to the agents that wait on
|
|
111
36
|
* it. Every kind of Conversation reports with the same update. A parent gets
|
|
@@ -129,16 +54,15 @@ function renderAgentResult(args) {
|
|
|
129
54
|
waiting_on: args.waitingOn
|
|
130
55
|
}, "An agent", text || "(empty)");
|
|
131
56
|
}
|
|
132
|
-
// src/chat/
|
|
133
|
-
var result_exports = /* @__PURE__ */ __exportAll({ createChildConversationWorker: () => createChildConversationWorker });
|
|
57
|
+
// src/chat/child-agents/result.ts
|
|
134
58
|
/**
|
|
135
59
|
* Render the parent agent input for one child agent result as one
|
|
136
60
|
* `<agent-result>`, the agent update that a Watch on the child also gets.
|
|
137
|
-
* The system prompt says what to do for each status
|
|
138
|
-
*
|
|
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.
|
|
139
63
|
*/
|
|
140
64
|
function renderResultInput(sender, result, openSiblings) {
|
|
141
|
-
|
|
65
|
+
const agentResult = renderAgentResult({
|
|
142
66
|
conversationId: sender.childConversationId,
|
|
143
67
|
name: sender.agentName,
|
|
144
68
|
source: "child_agent",
|
|
@@ -149,6 +73,11 @@ function renderResultInput(sender, result, openSiblings) {
|
|
|
149
73
|
},
|
|
150
74
|
waitingOn: openSiblings.length ? openSiblings.map(siblingLabel).join(", ") : void 0
|
|
151
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;
|
|
152
81
|
}
|
|
153
82
|
function siblingLabel(sibling) {
|
|
154
83
|
return sibling.agentName ?? sibling.title ?? sibling.childConversationId;
|
|
@@ -188,12 +117,12 @@ function senderEventMetadata(actor, event) {
|
|
|
188
117
|
};
|
|
189
118
|
}
|
|
190
119
|
function renderMessageInput(sender, text) {
|
|
191
|
-
return renderDataTag("agent-message", {
|
|
120
|
+
return withNoReplyReminder(sender, renderDataTag("agent-message", {
|
|
192
121
|
conversation_id: sender.childConversationId,
|
|
193
122
|
name: sender.agentName,
|
|
194
123
|
source: "child_agent",
|
|
195
124
|
title: sender.title
|
|
196
|
-
}, "A child agent that you started", text.trim());
|
|
125
|
+
}, "A child agent that you started", text.trim()));
|
|
197
126
|
}
|
|
198
127
|
/**
|
|
199
128
|
* Append one message from a child agent to its parent mailbox and wake the
|
|
@@ -204,13 +133,13 @@ function renderMessageInput(sender, text) {
|
|
|
204
133
|
async function enqueueAgentMessageToParent(args) {
|
|
205
134
|
const nowMs = args.nowMs ?? Date.now();
|
|
206
135
|
const senderId = args.sender.childConversationId;
|
|
207
|
-
const inboundMessageId =
|
|
136
|
+
const inboundMessageId = getAgentMessageId(senderId, args.messageKey);
|
|
208
137
|
const summary = `${childAgentLabel(args.sender)} sent a message.`;
|
|
209
138
|
const metadata = senderEventMetadata(args.actor, {
|
|
210
139
|
eventKey: inboundMessageId,
|
|
211
140
|
eventType: AGENT_MESSAGE_EVENT_TYPE,
|
|
212
141
|
identifier: senderId,
|
|
213
|
-
namespace:
|
|
142
|
+
namespace: CORE_EVENT_NAMESPACE,
|
|
214
143
|
trustedSummary: summary
|
|
215
144
|
});
|
|
216
145
|
await enqueueAutomatedInput({
|
|
@@ -271,14 +200,14 @@ async function enqueueStarterUpdate(args) {
|
|
|
271
200
|
eventKey: inboundMessageId,
|
|
272
201
|
eventType: AGENT_UPDATE_EVENT_TYPE,
|
|
273
202
|
identifier: senderId,
|
|
274
|
-
namespace:
|
|
203
|
+
namespace: CORE_EVENT_NAMESPACE,
|
|
275
204
|
...stillWorks ? void 0 : { status },
|
|
276
205
|
trustedSummary: `${childAgentLabel(args.sender)} ${stillWorks ? "sent a message." : RESULT_SUMMARIES[status]}`
|
|
277
206
|
}),
|
|
278
|
-
|
|
207
|
+
sender: {
|
|
279
208
|
conversationId: senderId,
|
|
280
209
|
turnId: args.turnId
|
|
281
|
-
}
|
|
210
|
+
}
|
|
282
211
|
};
|
|
283
212
|
await enqueueAutomatedInput({
|
|
284
213
|
message: {
|
|
@@ -330,24 +259,4 @@ function createEndStoppedChildWork(options) {
|
|
|
330
259
|
});
|
|
331
260
|
};
|
|
332
261
|
}
|
|
333
|
-
|
|
334
|
-
* Build the worker for all work of a child Conversation. The caller selects
|
|
335
|
-
* it from the stored kind of the Conversation, never from a Turn Source.
|
|
336
|
-
* Every input, such as a parent task or message, a person's Message in a
|
|
337
|
-
* Thread, a Watch Event, or a reply of the child's own child agent, runs on
|
|
338
|
-
* the Conversation loop, like input to a root.
|
|
339
|
-
*/
|
|
340
|
-
function createChildConversationWorker(options) {
|
|
341
|
-
return async (context) => {
|
|
342
|
-
const work = await resolveMailboxTurnWork(context);
|
|
343
|
-
const kept = work ? await withAgentInvocationResultActors(work) : void 0;
|
|
344
|
-
if (!kept) {
|
|
345
|
-
await context.attempt.ack();
|
|
346
|
-
return { status: "completed" };
|
|
347
|
-
}
|
|
348
|
-
const result = await options.runTurn(context, kept);
|
|
349
|
-
if (result.status === "completed") await recordChildAgentEnded(context.conversationId, "success", options);
|
|
350
|
-
return result;
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
export { result_exports as a, withAgentInvocationResultActors as c, enqueueStarterUpdate as i, createEndStoppedChildWork as n, renderAgentResult as o, enqueueAgentMessageToParent as r, getChildAgentLabel as s, createChildConversationWorker as t };
|
|
262
|
+
export { getChildAgentLabel as a, renderAgentResult as i, enqueueAgentMessageToParent as n, enqueueStarterUpdate as r, createEndStoppedChildWork as t };
|