@sentry/junior 0.102.3 → 0.104.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/{agent-hooks-I4I2DHSW.js → agent-hooks-EOFSY2PD.js} +5 -5
- package/dist/api/conversations/archive.d.ts +7 -0
- package/dist/api/conversations/detail.d.ts +7 -0
- package/dist/api/conversations/list.d.ts +109 -0
- package/dist/api/conversations/routes.d.ts +3 -0
- package/dist/api/conversations/schema.d.ts +88 -69
- package/dist/api/conversations/stats.d.ts +7 -0
- package/dist/api/conversations/subagent.d.ts +7 -0
- package/dist/api/http.d.ts +5 -0
- package/dist/api/locations/detail.d.ts +10 -2
- package/dist/api/locations/list.d.ts +7 -0
- package/dist/api/locations/routes.d.ts +3 -0
- package/dist/api/locations/schema.d.ts +4 -3
- package/dist/api/people/list.d.ts +7 -0
- package/dist/api/people/profile.d.ts +7 -0
- package/dist/api/people/routes.d.ts +3 -0
- package/dist/api/people/schema.d.ts +35 -33
- package/dist/api/people/shared.d.ts +4 -4
- package/dist/api/route.d.ts +7 -0
- package/dist/api/schema.js +11 -17
- package/dist/api.js +2184 -88
- package/dist/app.js +120 -162
- package/dist/chat/conversations/history.d.ts +6 -6
- package/dist/chat/conversations/store.d.ts +1 -0
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/resource-events/store.d.ts +2 -2
- package/dist/chat/sandbox/runtime-dependencies.d.ts +2 -0
- package/dist/chat/sandbox/sandbox.d.ts +1 -0
- package/dist/chat/services/provider-retry.d.ts +1 -2
- package/dist/chat/slack/tools/conversation-search.d.ts +2 -2
- package/dist/chat/state/session-log.d.ts +2 -2
- package/dist/chat/task-execution/store.d.ts +2 -2
- package/dist/chat/tools/search-tools.d.ts +2 -2
- package/dist/{chunk-ZSHL44IQ.js → chunk-4PDVOHXP.js} +1 -1
- package/dist/{chunk-3OABPOHR.js → chunk-7G4J3CR7.js} +11 -2
- package/dist/chunk-AIRE7Q2W.js +362 -0
- package/dist/{chunk-QZGVPPIJ.js → chunk-BCULHGZK.js} +24 -4
- package/dist/{chunk-IQ36I3DF.js → chunk-CCTCIISK.js} +1 -1
- package/dist/{chunk-SHBPSE7A.js → chunk-M3UAVLEN.js} +2 -3
- package/dist/{chunk-EMUZSROX.js → chunk-O7ILGCMJ.js} +78 -1
- package/dist/{chunk-EOB77KME.js → chunk-QDKRE3LS.js} +340 -9
- package/dist/{chunk-DTUSCR2Y.js → chunk-QVTVCJR4.js} +7 -7
- package/dist/{chunk-5K4N73TP.js → chunk-RMZ65YAA.js} +3 -3
- package/dist/{chunk-VSAFV2GI.js → chunk-RYDF4GOX.js} +3 -3
- package/dist/{chunk-ZIX4PNBI.js → chunk-TMWUGGSA.js} +37 -35
- package/dist/{chunk-3UK5DFKW.js → chunk-U26ZWZCN.js} +1 -1
- package/dist/{chunk-X2IPNCB5.js → chunk-VDHMFCDY.js} +65 -12
- package/dist/cli/chat.js +13 -14
- package/dist/cli/plugins.js +6 -6
- package/dist/cli/snapshot-warmup.js +7 -3
- package/dist/cli/upgrade.js +6 -7
- package/dist/db/schema/conversations.d.ts +17 -0
- package/dist/db/schema.d.ts +17 -0
- package/dist/{db-6QP6HY7U.js → db-PDMC67T3.js} +2 -2
- package/dist/{legacy-import-R3BMM2GH.js → legacy-import-G333RHJZ.js} +3 -3
- package/dist/reporting-schema.d.ts +4 -4
- package/dist/{runner-C2ZTIOUD.js → runner-6A7MQRUE.js} +9 -10
- package/migrations/0004_useful_magus.sql +1 -0
- package/migrations/meta/0004_snapshot.json +1041 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -6
- package/dist/api/conversations/list.query.d.ts +0 -103
- package/dist/chunk-2RNOB32R.js +0 -17
- package/dist/chunk-4XNQSJAX.js +0 -331
- package/dist/chunk-4YN2ZXKB.js +0 -66
- package/dist/chunk-B5QS4AVO.js +0 -319
- package/dist/chunk-F4CQEUTP.js +0 -77
- package/dist/chunk-HYDQULR2.js +0 -214
- package/dist/chunk-KFP3TZOS.js +0 -102
- package/dist/chunk-LJB2TLVT.js +0 -273
- package/dist/chunk-LVUKF5CE.js +0 -63
- package/dist/chunk-NSP6OGL2.js +0 -671
- package/dist/chunk-QNVHH5PU.js +0 -20
- package/dist/chunk-QOZOJNSE.js +0 -96
- package/dist/chunk-WPHCUGN7.js +0 -84
- package/dist/detail-OEIVZYXS.js +0 -68
- package/dist/detail-V37NTVBN.js +0 -29
- package/dist/list-AJ6RWBOG.js +0 -30
- package/dist/list-FWLIZHSW.js +0 -30
- package/dist/list-NTUT6A5M.js +0 -121
- package/dist/plugin-conversations-F3IBVNFX.js +0 -37
- package/dist/profile-3FRQP4HP.js +0 -212
- package/dist/reporting/plugin-conversations.d.ts +0 -3
- package/dist/stats-7UFY6FPE.js +0 -174
- package/dist/subagent-X3ZWJHR4.js +0 -49
|
@@ -1,22 +1,322 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-B5QS4AVO.js";
|
|
2
|
+
ensureLegacyConversationImport
|
|
3
|
+
} from "./chunk-RYDF4GOX.js";
|
|
5
4
|
import {
|
|
6
5
|
usageSchema
|
|
7
6
|
} from "./chunk-PDO5BLNM.js";
|
|
8
7
|
import {
|
|
8
|
+
contextProvenance,
|
|
9
|
+
getAgentStepStore,
|
|
9
10
|
getConversationStore,
|
|
10
11
|
instructionActors,
|
|
11
12
|
instructionProvenanceFor
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BCULHGZK.js";
|
|
13
14
|
import {
|
|
14
15
|
getStateAdapter
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-M3UAVLEN.js";
|
|
16
17
|
import {
|
|
18
|
+
logWarn,
|
|
17
19
|
toStoredSlackActor
|
|
18
20
|
} from "./chunk-AEWZ7F65.js";
|
|
19
21
|
|
|
22
|
+
// src/chat/conversations/projection.ts
|
|
23
|
+
import { isDeepStrictEqual } from "util";
|
|
24
|
+
function authorizationObservationMessage(entry, createdAtMs) {
|
|
25
|
+
const label = entry.kind === "mcp" ? "MCP authorization" : "Authorization";
|
|
26
|
+
return {
|
|
27
|
+
role: "user",
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: `${label} completed for provider "${entry.provider}". Continue the blocked request and retry the provider operation if needed.`
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
timestamp: createdAtMs
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function piEntryProvenance(entry) {
|
|
38
|
+
return entry.provenance ?? contextProvenance;
|
|
39
|
+
}
|
|
40
|
+
function projectSteps(steps, opts) {
|
|
41
|
+
const messages = [];
|
|
42
|
+
const provenance = [];
|
|
43
|
+
const seqs = [];
|
|
44
|
+
let modelProfile = "standard";
|
|
45
|
+
let modelId;
|
|
46
|
+
for (const step of steps) {
|
|
47
|
+
if (opts?.maxSeq !== void 0 && step.seq > opts.maxSeq) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (step.entry.type === "context_epoch_started") {
|
|
51
|
+
modelProfile = step.entry.modelProfile ?? "standard";
|
|
52
|
+
modelId = step.entry.modelId;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (step.entry.type === "pi_message") {
|
|
56
|
+
messages.push(step.entry.message);
|
|
57
|
+
provenance.push(piEntryProvenance(step.entry));
|
|
58
|
+
seqs.push(step.seq);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (step.entry.type === "authorization_completed") {
|
|
62
|
+
messages.push(
|
|
63
|
+
authorizationObservationMessage(step.entry, step.createdAtMs)
|
|
64
|
+
);
|
|
65
|
+
provenance.push(contextProvenance);
|
|
66
|
+
seqs.push(step.seq);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { messages, provenance, seqs, modelProfile, modelId };
|
|
70
|
+
}
|
|
71
|
+
function connectedMcpProvidersFromSteps(steps) {
|
|
72
|
+
const providers = /* @__PURE__ */ new Set();
|
|
73
|
+
for (const step of steps) {
|
|
74
|
+
if (step.entry.type === "mcp_provider_connected") {
|
|
75
|
+
providers.add(step.entry.provider);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return [...providers].sort((left, right) => left.localeCompare(right));
|
|
79
|
+
}
|
|
80
|
+
function isUserMessage(message) {
|
|
81
|
+
return message.role === "user";
|
|
82
|
+
}
|
|
83
|
+
function countMatchingPrefix(left, right) {
|
|
84
|
+
const limit = Math.min(left.length, right.length);
|
|
85
|
+
for (let index = 0; index < limit; index += 1) {
|
|
86
|
+
if (!isDeepStrictEqual(left[index], right[index])) {
|
|
87
|
+
return index;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return limit;
|
|
91
|
+
}
|
|
92
|
+
function resolveCommitProvenance(args) {
|
|
93
|
+
if (args.explicitProvenance) {
|
|
94
|
+
if (args.explicitProvenance.length !== args.nextMessages.length) {
|
|
95
|
+
throw new Error("commit provenance must align one-to-one with messages");
|
|
96
|
+
}
|
|
97
|
+
return args.explicitProvenance;
|
|
98
|
+
}
|
|
99
|
+
const matchingPrefix = args.matchingPrefix;
|
|
100
|
+
const provenance = args.nextMessages.map(
|
|
101
|
+
(_, index) => index < matchingPrefix ? args.existing.provenance[index] ?? contextProvenance : contextProvenance
|
|
102
|
+
);
|
|
103
|
+
if (args.newMessageProvenance) {
|
|
104
|
+
for (let index = args.nextMessages.length - 1; index >= matchingPrefix; index -= 1) {
|
|
105
|
+
if (isUserMessage(args.nextMessages[index])) {
|
|
106
|
+
provenance[index] = args.newMessageProvenance;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (args.trailingMessageProvenance) {
|
|
112
|
+
if (args.trailingMessageProvenance.length > provenance.length) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
"trailing commit provenance cannot exceed committed messages"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const newMessageCount = args.nextMessages.length - matchingPrefix;
|
|
118
|
+
if (args.trailingMessageProvenance.length > newMessageCount) {
|
|
119
|
+
throw new Error(
|
|
120
|
+
"trailing commit provenance must align to newly committed messages"
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const start = provenance.length - args.trailingMessageProvenance.length;
|
|
124
|
+
args.trailingMessageProvenance.forEach((entry, offset) => {
|
|
125
|
+
provenance[start + offset] = entry;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return provenance;
|
|
129
|
+
}
|
|
130
|
+
async function importLegacyIfNeeded(args) {
|
|
131
|
+
await ensureLegacyConversationImport({ conversationId: args.conversationId });
|
|
132
|
+
}
|
|
133
|
+
async function loadProjection(args) {
|
|
134
|
+
await importLegacyIfNeeded(args);
|
|
135
|
+
const steps = await getAgentStepStore().loadCurrentEpoch(args.conversationId);
|
|
136
|
+
return projectSteps(steps).messages;
|
|
137
|
+
}
|
|
138
|
+
async function loadConversationProjection(args) {
|
|
139
|
+
await importLegacyIfNeeded(args);
|
|
140
|
+
const steps = await getAgentStepStore().loadCurrentEpoch(args.conversationId);
|
|
141
|
+
const { messages, provenance, modelProfile, modelId } = projectSteps(steps);
|
|
142
|
+
return { messages, provenance, modelProfile, modelId };
|
|
143
|
+
}
|
|
144
|
+
async function openConversationProjection(args) {
|
|
145
|
+
await importLegacyIfNeeded(args);
|
|
146
|
+
const stepStore = getAgentStepStore();
|
|
147
|
+
const steps = await stepStore.loadCurrentEpoch(args.conversationId);
|
|
148
|
+
const projection = projectSteps(steps);
|
|
149
|
+
if (steps.some(
|
|
150
|
+
(step) => step.entry.type === "context_epoch_started" || step.entry.type === "pi_message"
|
|
151
|
+
)) {
|
|
152
|
+
return projection;
|
|
153
|
+
}
|
|
154
|
+
await stepStore.startEpoch(args.conversationId, {
|
|
155
|
+
reason: "initial",
|
|
156
|
+
modelProfile: "standard",
|
|
157
|
+
modelId: args.modelId,
|
|
158
|
+
messages: []
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
messages: projection.messages,
|
|
162
|
+
provenance: projection.provenance,
|
|
163
|
+
modelProfile: "standard",
|
|
164
|
+
modelId: args.modelId
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
async function loadTurnProjection(args) {
|
|
168
|
+
await importLegacyIfNeeded(args);
|
|
169
|
+
const stepStore = getAgentStepStore();
|
|
170
|
+
if (args.committedSeq < 0) {
|
|
171
|
+
return projectSteps(await stepStore.loadCurrentEpoch(args.conversationId));
|
|
172
|
+
}
|
|
173
|
+
const history = await stepStore.loadHistory(args.conversationId);
|
|
174
|
+
const committedStep = history.find((step) => step.seq === args.committedSeq);
|
|
175
|
+
if (!committedStep) {
|
|
176
|
+
return void 0;
|
|
177
|
+
}
|
|
178
|
+
const epochSteps = history.filter(
|
|
179
|
+
(step) => step.contextEpoch === committedStep.contextEpoch
|
|
180
|
+
);
|
|
181
|
+
return args.includeTail ? projectSteps(epochSteps) : projectSteps(epochSteps, { maxSeq: args.committedSeq });
|
|
182
|
+
}
|
|
183
|
+
async function loadConnectedMcpProviders(args) {
|
|
184
|
+
await importLegacyIfNeeded(args);
|
|
185
|
+
const steps = await getAgentStepStore().loadCurrentEpoch(args.conversationId);
|
|
186
|
+
return connectedMcpProvidersFromSteps(steps);
|
|
187
|
+
}
|
|
188
|
+
function messageTimestamp(message) {
|
|
189
|
+
const timestamp = message.timestamp;
|
|
190
|
+
return typeof timestamp === "number" ? timestamp : Date.now();
|
|
191
|
+
}
|
|
192
|
+
async function commitMessages(args) {
|
|
193
|
+
const stepStore = getAgentStepStore();
|
|
194
|
+
const currentSteps = await stepStore.loadCurrentEpoch(args.conversationId);
|
|
195
|
+
const existing = projectSteps(currentSteps);
|
|
196
|
+
const matchingPrefix = countMatchingPrefix(existing.messages, args.messages);
|
|
197
|
+
const nextProvenance = resolveCommitProvenance({
|
|
198
|
+
existing,
|
|
199
|
+
nextMessages: args.messages,
|
|
200
|
+
matchingPrefix,
|
|
201
|
+
...args.provenance ? { explicitProvenance: args.provenance } : {},
|
|
202
|
+
...args.trailingMessageProvenance ? { trailingMessageProvenance: args.trailingMessageProvenance } : {},
|
|
203
|
+
...args.newMessageProvenance ? { newMessageProvenance: args.newMessageProvenance } : {}
|
|
204
|
+
});
|
|
205
|
+
if (currentSteps.length === 0) {
|
|
206
|
+
await stepStore.startEpoch(args.conversationId, {
|
|
207
|
+
reason: "initial",
|
|
208
|
+
modelProfile: "standard",
|
|
209
|
+
modelId: args.modelId,
|
|
210
|
+
messages: args.messages.map((message, index) => ({
|
|
211
|
+
message,
|
|
212
|
+
createdAtMs: messageTimestamp(message),
|
|
213
|
+
provenance: nextProvenance[index]
|
|
214
|
+
}))
|
|
215
|
+
});
|
|
216
|
+
} else if (matchingPrefix === existing.messages.length) {
|
|
217
|
+
const newMessages = args.messages.slice(matchingPrefix);
|
|
218
|
+
await stepStore.append(
|
|
219
|
+
args.conversationId,
|
|
220
|
+
newMessages.map((message, index) => ({
|
|
221
|
+
entry: {
|
|
222
|
+
type: "pi_message",
|
|
223
|
+
message,
|
|
224
|
+
provenance: nextProvenance[matchingPrefix + index]
|
|
225
|
+
},
|
|
226
|
+
createdAtMs: messageTimestamp(message)
|
|
227
|
+
}))
|
|
228
|
+
);
|
|
229
|
+
} else {
|
|
230
|
+
await stepStore.startEpoch(args.conversationId, {
|
|
231
|
+
reason: "rollback",
|
|
232
|
+
modelProfile: existing.modelProfile,
|
|
233
|
+
modelId: args.modelId,
|
|
234
|
+
messages: args.messages.map((message, index) => ({
|
|
235
|
+
message,
|
|
236
|
+
createdAtMs: messageTimestamp(message),
|
|
237
|
+
provenance: nextProvenance[index]
|
|
238
|
+
}))
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const committed = projectSteps(
|
|
242
|
+
await stepStore.loadCurrentEpoch(args.conversationId)
|
|
243
|
+
);
|
|
244
|
+
return {
|
|
245
|
+
committedSeq: committed.seqs.at(-1) ?? -1,
|
|
246
|
+
messageSeqs: committed.seqs,
|
|
247
|
+
provenance: nextProvenance
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
async function recordMcpProviderConnected(args) {
|
|
251
|
+
const stepStore = getAgentStepStore();
|
|
252
|
+
const steps = await stepStore.loadCurrentEpoch(args.conversationId);
|
|
253
|
+
if (connectedMcpProvidersFromSteps(steps).includes(args.provider)) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
await stepStore.append(args.conversationId, [
|
|
257
|
+
{
|
|
258
|
+
entry: { type: "mcp_provider_connected", provider: args.provider },
|
|
259
|
+
createdAtMs: Date.now()
|
|
260
|
+
}
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
async function recordAuthorizationRequested(args) {
|
|
264
|
+
const stepStore = getAgentStepStore();
|
|
265
|
+
const steps = await stepStore.loadCurrentEpoch(args.conversationId);
|
|
266
|
+
if (steps.some(
|
|
267
|
+
(step) => step.entry.type === "authorization_requested" && step.entry.authorizationId === args.authorizationId
|
|
268
|
+
)) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
await stepStore.append(args.conversationId, [
|
|
272
|
+
{
|
|
273
|
+
entry: {
|
|
274
|
+
type: "authorization_requested",
|
|
275
|
+
kind: args.kind,
|
|
276
|
+
provider: args.provider,
|
|
277
|
+
actorId: args.actorId,
|
|
278
|
+
authorizationId: args.authorizationId,
|
|
279
|
+
delivery: args.delivery
|
|
280
|
+
},
|
|
281
|
+
createdAtMs: Date.now()
|
|
282
|
+
}
|
|
283
|
+
]);
|
|
284
|
+
}
|
|
285
|
+
async function recordAuthorizationCompleted(args) {
|
|
286
|
+
const stepStore = getAgentStepStore();
|
|
287
|
+
const steps = await stepStore.loadCurrentEpoch(args.conversationId);
|
|
288
|
+
if (steps.some(
|
|
289
|
+
(step) => step.entry.type === "authorization_completed" && step.entry.authorizationId === args.authorizationId
|
|
290
|
+
)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
await stepStore.append(args.conversationId, [
|
|
294
|
+
{
|
|
295
|
+
entry: {
|
|
296
|
+
type: "authorization_completed",
|
|
297
|
+
kind: args.kind,
|
|
298
|
+
provider: args.provider,
|
|
299
|
+
actorId: args.actorId,
|
|
300
|
+
authorizationId: args.authorizationId
|
|
301
|
+
},
|
|
302
|
+
createdAtMs: Date.now()
|
|
303
|
+
}
|
|
304
|
+
]);
|
|
305
|
+
}
|
|
306
|
+
async function recordToolExecutionStarted(args) {
|
|
307
|
+
await getAgentStepStore().append(args.conversationId, [
|
|
308
|
+
{
|
|
309
|
+
entry: {
|
|
310
|
+
type: "tool_execution_started",
|
|
311
|
+
toolCallId: args.toolCallId,
|
|
312
|
+
toolName: args.toolName,
|
|
313
|
+
...args.args !== void 0 ? { args: args.args } : {}
|
|
314
|
+
},
|
|
315
|
+
createdAtMs: args.createdAtMs ?? Date.now()
|
|
316
|
+
}
|
|
317
|
+
]);
|
|
318
|
+
}
|
|
319
|
+
|
|
20
320
|
// src/chat/usage.ts
|
|
21
321
|
var agentTurnUsageSchema = usageSchema;
|
|
22
322
|
var COMPONENT_USAGE_FIELDS = [
|
|
@@ -190,6 +490,13 @@ function parseAgentTurnSessionRecord(value) {
|
|
|
190
490
|
return storedAgentTurnSessionRecordSchema.parse(value);
|
|
191
491
|
}
|
|
192
492
|
function parseAgentTurnSessionSummary(value) {
|
|
493
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && "requester" in value) {
|
|
494
|
+
const { requester, ...summary } = value;
|
|
495
|
+
return agentTurnSessionSummarySchema.parse({
|
|
496
|
+
...summary,
|
|
497
|
+
...summary.actor === void 0 ? { actor: requester } : {}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
193
500
|
return agentTurnSessionSummarySchema.parse(value);
|
|
194
501
|
}
|
|
195
502
|
async function appendAgentTurnSessionSummary(summary, ttlMs) {
|
|
@@ -500,10 +807,24 @@ async function readAgentTurnSessionSummariesFromIndex(key, stateAdapter) {
|
|
|
500
807
|
const values = await stateAdapter.getList(key);
|
|
501
808
|
const summaries = /* @__PURE__ */ new Map();
|
|
502
809
|
for (const value of [...values].reverse()) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
810
|
+
let summary;
|
|
811
|
+
try {
|
|
812
|
+
summary = parseAgentTurnSessionSummary(value);
|
|
813
|
+
} catch (error) {
|
|
814
|
+
logWarn(
|
|
815
|
+
"agent_turn_session_summary_parse_failed",
|
|
816
|
+
{},
|
|
817
|
+
{
|
|
818
|
+
"app.state.key": key,
|
|
819
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
820
|
+
},
|
|
821
|
+
"Skipping an invalid turn-session summary index entry"
|
|
822
|
+
);
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
const summaryKey = `${summary.conversationId}:${summary.sessionId}`;
|
|
826
|
+
if (!summaries.has(summaryKey)) {
|
|
827
|
+
summaries.set(summaryKey, summary);
|
|
507
828
|
}
|
|
508
829
|
}
|
|
509
830
|
return [...summaries.values()].sort(
|
|
@@ -597,6 +918,16 @@ async function failAgentTurnSessionRecord(args) {
|
|
|
597
918
|
}
|
|
598
919
|
|
|
599
920
|
export {
|
|
921
|
+
projectSteps,
|
|
922
|
+
loadProjection,
|
|
923
|
+
loadConversationProjection,
|
|
924
|
+
openConversationProjection,
|
|
925
|
+
loadConnectedMcpProviders,
|
|
926
|
+
commitMessages,
|
|
927
|
+
recordMcpProviderConnected,
|
|
928
|
+
recordAuthorizationRequested,
|
|
929
|
+
recordAuthorizationCompleted,
|
|
930
|
+
recordToolExecutionStarted,
|
|
600
931
|
hasAgentTurnUsage,
|
|
601
932
|
addAgentTurnUsage,
|
|
602
933
|
getAgentTurnSessionRecord,
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
getPersistedThreadState,
|
|
10
10
|
markTurnCompleted,
|
|
11
11
|
mergeArtifactsState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RMZ65YAA.js";
|
|
13
13
|
import {
|
|
14
14
|
coerceThreadConversationState
|
|
15
15
|
} from "./chunk-XIMUQ4IU.js";
|
|
16
16
|
import {
|
|
17
17
|
getAgentTurnSessionRecord
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-QDKRE3LS.js";
|
|
19
19
|
import {
|
|
20
20
|
generateConversationId,
|
|
21
21
|
hydrateConversationMessages,
|
|
@@ -23,19 +23,19 @@ import {
|
|
|
23
23
|
normalizeConversationText,
|
|
24
24
|
updateConversationStats,
|
|
25
25
|
upsertConversationMessage
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RYDF4GOX.js";
|
|
27
27
|
import {
|
|
28
28
|
createPluginEmbedder,
|
|
29
29
|
createPluginModel,
|
|
30
30
|
getPlugins
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-VDHMFCDY.js";
|
|
32
32
|
import {
|
|
33
33
|
createPluginLogger,
|
|
34
34
|
createPluginState
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-4PDVOHXP.js";
|
|
36
36
|
import {
|
|
37
37
|
getDb
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-BCULHGZK.js";
|
|
39
39
|
import {
|
|
40
40
|
botConfig,
|
|
41
41
|
getPiMessageRole,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
isToolResultMessage,
|
|
46
46
|
normalizeToolNameFromResult,
|
|
47
47
|
stripRuntimeTurnContext
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-M3UAVLEN.js";
|
|
49
49
|
import {
|
|
50
50
|
buildTurnFailureResponse
|
|
51
51
|
} from "./chunk-AEWZ7F65.js";
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
addAgentTurnUsage,
|
|
8
8
|
getAgentTurnSessionRecord,
|
|
9
9
|
upsertAgentTurnSessionRecord
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QDKRE3LS.js";
|
|
11
11
|
import {
|
|
12
12
|
persistConversationMessages
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RYDF4GOX.js";
|
|
14
14
|
import {
|
|
15
15
|
sleep
|
|
16
16
|
} from "./chunk-4ZNGQH7C.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getPiMessageRole,
|
|
19
19
|
getStateAdapter,
|
|
20
20
|
trimTrailingAssistantMessages
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-M3UAVLEN.js";
|
|
22
22
|
import {
|
|
23
23
|
getActiveTraceId,
|
|
24
24
|
logException
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
piMessageSchema,
|
|
13
13
|
readSessionLogEntries,
|
|
14
14
|
sanitizePostgresJson
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BCULHGZK.js";
|
|
16
16
|
import {
|
|
17
17
|
botConfig,
|
|
18
18
|
escapeXml,
|
|
19
19
|
getStateAdapter,
|
|
20
20
|
resolveGatewayModel,
|
|
21
21
|
unescapeXml
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-M3UAVLEN.js";
|
|
23
23
|
import {
|
|
24
24
|
logWarn,
|
|
25
25
|
setSpanAttributes
|
|
@@ -465,7 +465,7 @@ async function hydrateConversationMessages(args) {
|
|
|
465
465
|
args.conversation.messages = [];
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
|
-
const { ensureLegacyConversationImport: ensureLegacyConversationImport2 } = await import("./legacy-import-
|
|
468
|
+
const { ensureLegacyConversationImport: ensureLegacyConversationImport2 } = await import("./legacy-import-G333RHJZ.js");
|
|
469
469
|
await ensureLegacyConversationImport2({ conversationId: args.conversationId });
|
|
470
470
|
await hydrateConversationCompactions({
|
|
471
471
|
conversation: args.conversation,
|
|
@@ -11,37 +11,35 @@ import {
|
|
|
11
11
|
persistRunningSessionRecord,
|
|
12
12
|
persistTimeoutSessionRecord,
|
|
13
13
|
persistYieldSessionRecord
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-RMZ65YAA.js";
|
|
15
15
|
import {
|
|
16
16
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
17
17
|
} from "./chunk-XIMUQ4IU.js";
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
buildNonInteractiveShellScript,
|
|
20
|
+
createSandboxInstance,
|
|
21
|
+
getRuntimeDependencyProfileHash,
|
|
22
|
+
getSandboxResources,
|
|
23
|
+
getVercelSandboxCredentials,
|
|
24
|
+
isSnapshotMissingError,
|
|
25
|
+
resolveRuntimeDependencySnapshot,
|
|
26
|
+
runNonInteractiveCommand
|
|
27
|
+
} from "./chunk-7G4J3CR7.js";
|
|
22
28
|
import {
|
|
29
|
+
addAgentTurnUsage,
|
|
30
|
+
hasAgentTurnUsage,
|
|
23
31
|
loadConnectedMcpProviders,
|
|
24
32
|
loadConversationProjection,
|
|
25
33
|
openConversationProjection,
|
|
26
34
|
recordAuthorizationRequested,
|
|
27
35
|
recordMcpProviderConnected,
|
|
28
36
|
recordToolExecutionStarted
|
|
29
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-QDKRE3LS.js";
|
|
30
38
|
import {
|
|
31
39
|
estimateTextTokens,
|
|
32
40
|
getAgentContextCompactionTriggerTokens,
|
|
33
41
|
updateConversationStats
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import {
|
|
36
|
-
buildNonInteractiveShellScript,
|
|
37
|
-
createSandboxInstance,
|
|
38
|
-
getRuntimeDependencyProfileHash,
|
|
39
|
-
getSandboxResources,
|
|
40
|
-
getVercelSandboxCredentials,
|
|
41
|
-
isSnapshotMissingError,
|
|
42
|
-
resolveRuntimeDependencySnapshot,
|
|
43
|
-
runNonInteractiveCommand
|
|
44
|
-
} from "./chunk-3OABPOHR.js";
|
|
42
|
+
} from "./chunk-RYDF4GOX.js";
|
|
45
43
|
import {
|
|
46
44
|
privateTraceResultAttributes
|
|
47
45
|
} from "./chunk-UIE3R5XU.js";
|
|
@@ -53,7 +51,17 @@ import {
|
|
|
53
51
|
getPlugins,
|
|
54
52
|
getSlackToolContext,
|
|
55
53
|
resolveChannelCapabilities
|
|
56
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-VDHMFCDY.js";
|
|
55
|
+
import {
|
|
56
|
+
createPluginLogger
|
|
57
|
+
} from "./chunk-4PDVOHXP.js";
|
|
58
|
+
import {
|
|
59
|
+
SANDBOX_DATA_ROOT,
|
|
60
|
+
SANDBOX_SKILLS_ROOT,
|
|
61
|
+
SANDBOX_WORKSPACE_ROOT,
|
|
62
|
+
sandboxSkillDir,
|
|
63
|
+
sandboxSkillFile
|
|
64
|
+
} from "./chunk-G3E7SCME.js";
|
|
57
65
|
import {
|
|
58
66
|
SlackActionError,
|
|
59
67
|
downloadPrivateSlackFile,
|
|
@@ -63,10 +71,7 @@ import {
|
|
|
63
71
|
isDmChannel,
|
|
64
72
|
normalizeSlackConversationId,
|
|
65
73
|
withSlackRetries
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import {
|
|
68
|
-
createPluginLogger
|
|
69
|
-
} from "./chunk-ZSHL44IQ.js";
|
|
74
|
+
} from "./chunk-CCTCIISK.js";
|
|
70
75
|
import {
|
|
71
76
|
contextProvenance,
|
|
72
77
|
getAgentStepStore,
|
|
@@ -75,14 +80,7 @@ import {
|
|
|
75
80
|
getDb,
|
|
76
81
|
instructionActors,
|
|
77
82
|
instructionProvenanceFor
|
|
78
|
-
} from "./chunk-
|
|
79
|
-
import {
|
|
80
|
-
SANDBOX_DATA_ROOT,
|
|
81
|
-
SANDBOX_SKILLS_ROOT,
|
|
82
|
-
SANDBOX_WORKSPACE_ROOT,
|
|
83
|
-
sandboxSkillDir,
|
|
84
|
-
sandboxSkillFile
|
|
85
|
-
} from "./chunk-G3E7SCME.js";
|
|
83
|
+
} from "./chunk-BCULHGZK.js";
|
|
86
84
|
import {
|
|
87
85
|
sleep
|
|
88
86
|
} from "./chunk-4ZNGQH7C.js";
|
|
@@ -125,7 +123,7 @@ import {
|
|
|
125
123
|
stripRuntimeTurnContext,
|
|
126
124
|
trimTrailingAssistantMessages,
|
|
127
125
|
unwrapCurrentInstruction
|
|
128
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-M3UAVLEN.js";
|
|
129
127
|
import {
|
|
130
128
|
parseSlackThreadId,
|
|
131
129
|
resolveConversationPrivacy,
|
|
@@ -271,6 +269,7 @@ function shouldPropagateSandboxEgressTrace(host, config = {}) {
|
|
|
271
269
|
|
|
272
270
|
// src/chat/agent/index.ts
|
|
273
271
|
import { Agent } from "@earendil-works/pi-agent-core";
|
|
272
|
+
import { isRetryableAssistantError } from "@earendil-works/pi-ai";
|
|
274
273
|
|
|
275
274
|
// src/chat/sandbox/skill-sandbox.ts
|
|
276
275
|
import fs from "fs/promises";
|
|
@@ -12265,6 +12264,7 @@ function bashToolResult(params) {
|
|
|
12265
12264
|
exit_code: params.exit_code,
|
|
12266
12265
|
signal: params.signal,
|
|
12267
12266
|
timed_out: params.timed_out,
|
|
12267
|
+
aborted: Boolean(params.aborted),
|
|
12268
12268
|
stdout: params.stdout,
|
|
12269
12269
|
stderr: params.stderr,
|
|
12270
12270
|
stdout_truncated: params.stdout_truncated,
|
|
@@ -12273,8 +12273,8 @@ function bashToolResult(params) {
|
|
|
12273
12273
|
truncated: params.stdout_truncated || params.stderr_truncated,
|
|
12274
12274
|
...!params.ok ? {
|
|
12275
12275
|
error: {
|
|
12276
|
-
kind: params.timed_out ? "timeout" : "nonzero_exit",
|
|
12277
|
-
message: params.stderr.trim() || `Command exited with code ${params.exit_code}`,
|
|
12276
|
+
kind: params.aborted ? "outcome_unknown" : params.timed_out ? "timeout" : "nonzero_exit",
|
|
12277
|
+
message: params.aborted ? "Command was interrupted before its outcome was confirmed. It may have produced side effects; reconcile external state before retrying or reporting failure." : params.stderr.trim() || `Command exited with code ${params.exit_code}`,
|
|
12278
12278
|
retryable: params.timed_out
|
|
12279
12279
|
}
|
|
12280
12280
|
} : {},
|
|
@@ -12283,6 +12283,7 @@ function bashToolResult(params) {
|
|
|
12283
12283
|
exit_code: params.exit_code,
|
|
12284
12284
|
signal: params.signal,
|
|
12285
12285
|
timed_out: params.timed_out,
|
|
12286
|
+
aborted: Boolean(params.aborted),
|
|
12286
12287
|
stdout: params.stdout,
|
|
12287
12288
|
stderr: params.stderr,
|
|
12288
12289
|
stdout_truncated: params.stdout_truncated,
|
|
@@ -12393,7 +12394,7 @@ function createSandboxExecutor(options) {
|
|
|
12393
12394
|
response.stderr ?? "",
|
|
12394
12395
|
"utf8"
|
|
12395
12396
|
),
|
|
12396
|
-
...response.exitCode !== 0 ? { "error.type": "nonzero_exit" } : {}
|
|
12397
|
+
...response.aborted ? { "error.type": "outcome_unknown" } : response.exitCode !== 0 ? { "error.type": "nonzero_exit" } : {}
|
|
12397
12398
|
});
|
|
12398
12399
|
setSpanStatus(response.exitCode === 0 ? "ok" : "error");
|
|
12399
12400
|
return response;
|
|
@@ -12416,6 +12417,7 @@ function createSandboxExecutor(options) {
|
|
|
12416
12417
|
exit_code: result.exitCode,
|
|
12417
12418
|
signal: null,
|
|
12418
12419
|
timed_out: Boolean(result.timedOut),
|
|
12420
|
+
aborted: Boolean(result.aborted),
|
|
12419
12421
|
stdout: result.stdout,
|
|
12420
12422
|
stderr: result.stderr,
|
|
12421
12423
|
stdout_truncated: result.stdoutTruncated,
|
|
@@ -16056,8 +16058,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
16056
16058
|
}
|
|
16057
16059
|
const providerRetry = nextProviderRetry({
|
|
16058
16060
|
attempt,
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
+
messages: agent.state.messages,
|
|
16062
|
+
retryableFailure: lastAssistant !== void 0 && isRetryableAssistantError(lastAssistant)
|
|
16061
16063
|
});
|
|
16062
16064
|
if (!providerRetry) {
|
|
16063
16065
|
break;
|