@sentry/junior 0.176.2 → 0.178.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-LQZFBXBK.js → agent-hooks-PBT4NNBV.js} +12 -12
- package/dist/api/conversations/archive.d.ts +5 -2
- package/dist/api/conversations/list.d.ts +0 -1
- package/dist/api/conversations/membership.d.ts +14 -0
- package/dist/api/conversations/projection.d.ts +2 -1
- package/dist/api/locations/detail.d.ts +1 -1
- package/dist/api/people/shared.d.ts +2 -2
- package/dist/api/schema/conversation.d.ts +4 -4
- package/dist/api/schema/location.d.ts +1 -1
- package/dist/api/schema/person.d.ts +1 -1
- package/dist/api/schema.js +1 -1
- package/dist/api.js +245 -166
- package/dist/app.js +52 -57
- package/dist/{catalog-runtime-P3DBC3XM.js → catalog-runtime-M7QGKPFZ.js} +5 -5
- package/dist/chat/agent/sandbox.d.ts +2 -0
- package/dist/chat/conversations/sql/participants.d.ts +1 -0
- package/dist/chat/conversations/store.d.ts +0 -1
- package/dist/chat/resource-events/notification.d.ts +6 -1
- package/dist/chat/sandbox/errors.d.ts +4 -0
- package/dist/chat/sandbox/noninteractive-command.d.ts +1 -0
- package/dist/chat/sandbox/prepare-workspace.d.ts +27 -3
- package/dist/chat/sandbox/sandbox.d.ts +2 -0
- package/dist/chat/sandbox/session.d.ts +2 -0
- package/dist/chat/sandbox/snapshot/builder-sandbox.d.ts +5 -0
- package/dist/chat/sandbox/snapshot/install.d.ts +2 -2
- package/dist/chat/sandbox/snapshot/span.d.ts +3 -0
- package/dist/chat/sandbox/snapshot/store.d.ts +20 -17
- package/dist/chat/sandbox/snapshot/waiting-error.d.ts +15 -0
- package/dist/chat/sandbox/snapshot/workspace.d.ts +17 -0
- package/dist/chat/services/workspace-snapshot-wait.d.ts +27 -0
- package/dist/chat/workspaces/types.d.ts +1 -0
- package/dist/{chunk-2PWBS4JK.js → chunk-22T3HB44.js} +1 -1
- package/dist/{chunk-LNV3NNDO.js → chunk-3ZZEPLLB.js} +2 -2
- package/dist/{chunk-DBXTXY2Z.js → chunk-4K6VNP3S.js} +9 -9
- package/dist/{chunk-SZWILPFG.js → chunk-534BO42N.js} +45 -276
- package/dist/{chunk-QWPKRFG6.js → chunk-6OYVH66J.js} +1 -1
- package/dist/{chunk-ESIS6NVJ.js → chunk-ABLODWPO.js} +1 -1
- package/dist/{chunk-LY6QWCJI.js → chunk-AGJ4OQ2V.js} +1 -1
- package/dist/{chunk-KKY2R2QF.js → chunk-AQHSXA3J.js} +331 -2
- package/dist/{chunk-JRDM64UU.js → chunk-AVRWMQ4U.js} +1 -1
- package/dist/{chunk-B2RBW7CX.js → chunk-BFLMRTPD.js} +6 -6
- package/dist/{chunk-HXX3CSGJ.js → chunk-BHHWCNXI.js} +5 -5
- package/dist/{chunk-H5SVUUPE.js → chunk-BUGO42R6.js} +4 -4
- package/dist/{chunk-2XQ45FB2.js → chunk-D3UJTX4U.js} +1 -1
- package/dist/{chunk-V4SBMRZ3.js → chunk-FQ6BMP5P.js} +767 -81
- package/dist/{chunk-AJ6M3LLM.js → chunk-G3CQEUHI.js} +5 -5
- package/dist/{chunk-RHNT2FYF.js → chunk-H6ZXBFGX.js} +1 -1
- package/dist/{chunk-FLBOMXLS.js → chunk-IQRPDKPJ.js} +1 -1
- package/dist/{chunk-OOH45KJS.js → chunk-JVXZ3WDH.js} +6 -6
- package/dist/{chunk-HLEE6JNT.js → chunk-KEQAA42D.js} +1 -1
- package/dist/{chunk-E7MUDWFH.js → chunk-LAOP4EPL.js} +6 -6
- package/dist/{chunk-FIWDSKL2.js → chunk-OGRD5PFM.js} +1 -1
- package/dist/{chunk-MNKXBIIA.js → chunk-PRDKO3QB.js} +124 -13
- package/dist/{chunk-YAB6CALP.js → chunk-QCCLDJHB.js} +8 -8
- package/dist/{chunk-FDA3E627.js → chunk-RE4XWXBV.js} +6 -6
- package/dist/{chunk-WVDCJ26T.js → chunk-RGV6KHDM.js} +4 -4
- package/dist/{chunk-73FXUNOB.js → chunk-RGXOLPWO.js} +1 -1
- package/dist/{chunk-ELEAIRTG.js → chunk-TKB25A3L.js} +2 -2
- package/dist/{chunk-UZM72ORS.js → chunk-U3UDPGZG.js} +2 -2
- package/dist/{chunk-PLJ3UO67.js → chunk-UGWBJAGN.js} +1 -1
- package/dist/{chunk-OJQTYDDD.js → chunk-UMG7M32G.js} +19 -19
- package/dist/{chunk-MOVIDCPX.js → chunk-XCNS3CXE.js} +11 -17
- package/dist/{chunk-TRG4RCTT.js → chunk-XWUJWHFD.js} +204 -100
- package/dist/{chunk-2KSPJ6EE.js → chunk-ZCHHVTMF.js} +14 -5
- package/dist/cli/chat.js +31 -30
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-create.js +10 -10
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/conversation-participants.d.ts +17 -0
- package/dist/db/schema/conversations.d.ts +629 -1
- package/dist/db/schema/snapshots.d.ts +1 -1
- package/dist/db/schema.d.ts +18 -1
- package/dist/{db-ATGRVFSI.js → db-QVYOWATH.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-55TYSRIZ.js → oauth-callback-server-PLPAFXO6.js} +23 -23
- package/dist/{runner-FD4BRECW.js → runner-AGNEIOZS.js} +15 -15
- package/dist/{skills-5YY7QYV6.js → skills-U5KQ66EM.js} +6 -6
- package/dist/spawn-ZRYYZP2B.js +37 -0
- package/dist/{validation-KH5UQUV4.js → validation-QE4U45KS.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-5LWDUEO4.js → work-ATAXAHJJ.js} +18 -18
- package/dist/worker-LIL5AOER.js +24 -0
- package/migrations/0033_workspace_snapshot_active_build.sql +1 -0
- package/migrations/0034_strong_randall.sql +31 -0
- package/migrations/meta/0033_snapshot.json +2914 -0
- package/migrations/meta/0034_snapshot.json +3038 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +5 -5
- package/dist/spawn-6IS46YNW.js +0 -37
- package/dist/worker-XKVLTAI2.js +0 -24
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState,
|
|
4
4
|
persistThreadStateById
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-G3CQEUHI.js";
|
|
6
6
|
import {
|
|
7
7
|
pluginTaskId,
|
|
8
8
|
pluginTaskParamsSchema,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
markTurnCompleted,
|
|
23
23
|
normalizeToolNameFromResult,
|
|
24
24
|
stripRuntimeTurnContext
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BFLMRTPD.js";
|
|
26
26
|
import {
|
|
27
27
|
createPluginConversationEvents,
|
|
28
28
|
createPluginEmbedder,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
createPluginModel,
|
|
31
31
|
createPluginState,
|
|
32
32
|
getPlugins
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-XWUJWHFD.js";
|
|
34
34
|
import {
|
|
35
35
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
36
36
|
} from "./chunk-3Y47VMHV.js";
|
|
@@ -38,20 +38,20 @@ import {
|
|
|
38
38
|
getConversationStore,
|
|
39
39
|
getDb,
|
|
40
40
|
sameActorIdentity
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-XCNS3CXE.js";
|
|
42
42
|
import {
|
|
43
43
|
juniorConversations,
|
|
44
44
|
juniorTaskExecutions
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-ZCHHVTMF.js";
|
|
46
46
|
import {
|
|
47
47
|
getStateAdapter
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-H6ZXBFGX.js";
|
|
49
49
|
import {
|
|
50
50
|
ProviderError,
|
|
51
51
|
findProviderError,
|
|
52
52
|
getProviderErrorAttributes,
|
|
53
53
|
getProviderErrorUserMessage
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-3ZZEPLLB.js";
|
|
55
55
|
import {
|
|
56
56
|
credentialSubjectSchema
|
|
57
57
|
} from "./chunk-CGA4ERJ5.js";
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
import {
|
|
62
62
|
buildTurnFailureResponse,
|
|
63
63
|
logWarn
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-UGWBJAGN.js";
|
|
65
65
|
|
|
66
66
|
// src/chat/runtime/delivered-turn-state.ts
|
|
67
67
|
function buildDeliveredTurnStatePatch(args) {
|
|
@@ -87,7 +87,7 @@ import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
|
|
|
87
87
|
|
|
88
88
|
// src/chat/services/turn-session-routing.ts
|
|
89
89
|
async function resolveTurnSessionRouting(args) {
|
|
90
|
-
const conversationStore = args.conversationStore ?? (await import("./db-
|
|
90
|
+
const conversationStore = args.conversationStore ?? (await import("./db-QVYOWATH.js")).getConversationStore();
|
|
91
91
|
const conversation = await conversationStore.get({
|
|
92
92
|
conversationId: args.conversationId
|
|
93
93
|
});
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SANDBOX_WORKSPACE_ROOT,
|
|
3
3
|
create,
|
|
4
|
+
getVercelSandboxCredentials,
|
|
5
|
+
isSandboxUnavailableError,
|
|
4
6
|
isStale,
|
|
5
7
|
runNonInteractiveCommand,
|
|
6
8
|
sleep
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AQHSXA3J.js";
|
|
8
10
|
import {
|
|
9
11
|
getStateAdapter
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
toOptionalTrimmed
|
|
13
|
-
} from "./chunk-LNV3NNDO.js";
|
|
12
|
+
} from "./chunk-H6ZXBFGX.js";
|
|
14
13
|
import {
|
|
15
14
|
setSpanAttributes,
|
|
16
|
-
setSpanStatus,
|
|
17
15
|
withSpan
|
|
18
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UGWBJAGN.js";
|
|
19
17
|
|
|
20
18
|
// src/chat/sandbox/resources.ts
|
|
21
19
|
var configuredResources;
|
|
@@ -53,18 +51,17 @@ function getSandboxResources() {
|
|
|
53
51
|
import { Sandbox } from "@vercel/sandbox";
|
|
54
52
|
import { z } from "zod";
|
|
55
53
|
|
|
56
|
-
// src/chat/sandbox/credentials.ts
|
|
57
|
-
function getVercelSandboxCredentials() {
|
|
58
|
-
const token = toOptionalTrimmed(process.env.VERCEL_TOKEN);
|
|
59
|
-
const teamId = toOptionalTrimmed(process.env.VERCEL_TEAM_ID);
|
|
60
|
-
const projectId = toOptionalTrimmed(process.env.VERCEL_PROJECT_ID);
|
|
61
|
-
if (token && teamId && projectId) {
|
|
62
|
-
return { token, teamId, projectId };
|
|
63
|
-
}
|
|
64
|
-
return void 0;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
54
|
// src/chat/sandbox/snapshot/span.ts
|
|
55
|
+
function setSnapshotSpanAttributes(snapshot) {
|
|
56
|
+
setSpanAttributes({
|
|
57
|
+
"app.sandbox.source": snapshot.snapshotId ? "snapshot" : "created",
|
|
58
|
+
"app.sandbox.snapshot.cache_hit": snapshot.cacheHit,
|
|
59
|
+
"app.sandbox.snapshot.resolve_outcome": snapshot.resolveOutcome,
|
|
60
|
+
...snapshot.profileHash ? { "app.sandbox.snapshot.profile_hash": snapshot.profileHash } : {},
|
|
61
|
+
"app.sandbox.snapshot.dependency_count": snapshot.dependencyCount,
|
|
62
|
+
...snapshot.rebuildReason ? { "app.sandbox.snapshot.rebuild_reason": snapshot.rebuildReason } : {}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
68
65
|
async function trace(name, op, attributes, callback) {
|
|
69
66
|
return await withSpan(name, op, {}, callback, attributes);
|
|
70
67
|
}
|
|
@@ -82,12 +79,13 @@ async function tryRun(sandbox, params) {
|
|
|
82
79
|
const result = await runNonInteractiveCommand(sandbox, params);
|
|
83
80
|
return result.exitCode === 0;
|
|
84
81
|
}
|
|
85
|
-
async function installGh(sandbox, signal) {
|
|
82
|
+
async function installGh(sandbox, signal, timeoutMs) {
|
|
86
83
|
const installed = await tryRun(sandbox, {
|
|
87
84
|
cmd: "dnf",
|
|
88
85
|
args: ["install", "-y", "gh"],
|
|
89
86
|
signal,
|
|
90
|
-
sudo: true
|
|
87
|
+
sudo: true,
|
|
88
|
+
timeoutMs
|
|
91
89
|
});
|
|
92
90
|
if (installed) {
|
|
93
91
|
return;
|
|
@@ -100,7 +98,8 @@ async function installGh(sandbox, signal) {
|
|
|
100
98
|
"--from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo"
|
|
101
99
|
],
|
|
102
100
|
signal,
|
|
103
|
-
sudo: true
|
|
101
|
+
sudo: true,
|
|
102
|
+
timeoutMs
|
|
104
103
|
});
|
|
105
104
|
if (!repoAdded) {
|
|
106
105
|
await runOrThrow(
|
|
@@ -109,7 +108,8 @@ async function installGh(sandbox, signal) {
|
|
|
109
108
|
cmd: "dnf",
|
|
110
109
|
args: ["install", "-y", "dnf-command(config-manager)"],
|
|
111
110
|
signal,
|
|
112
|
-
sudo: true
|
|
111
|
+
sudo: true,
|
|
112
|
+
timeoutMs
|
|
113
113
|
},
|
|
114
114
|
"dnf install dnf-command(config-manager)"
|
|
115
115
|
);
|
|
@@ -123,7 +123,8 @@ async function installGh(sandbox, signal) {
|
|
|
123
123
|
"https://cli.github.com/packages/rpm/gh-cli.repo"
|
|
124
124
|
],
|
|
125
125
|
signal,
|
|
126
|
-
sudo: true
|
|
126
|
+
sudo: true,
|
|
127
|
+
timeoutMs
|
|
127
128
|
},
|
|
128
129
|
"dnf config-manager --add-repo gh-cli.repo"
|
|
129
130
|
);
|
|
@@ -134,7 +135,8 @@ async function installGh(sandbox, signal) {
|
|
|
134
135
|
cmd: "dnf",
|
|
135
136
|
args: ["install", "-y", "gh", "--repo", "gh-cli"],
|
|
136
137
|
signal,
|
|
137
|
-
sudo: true
|
|
138
|
+
sudo: true,
|
|
139
|
+
timeoutMs
|
|
138
140
|
},
|
|
139
141
|
"dnf install gh --repo gh-cli"
|
|
140
142
|
);
|
|
@@ -151,21 +153,23 @@ function filePath(url, sha256) {
|
|
|
151
153
|
const sanitized = basename.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
152
154
|
return `/tmp/junior-runtime-${sha256.slice(0, 12)}-${sanitized}`;
|
|
153
155
|
}
|
|
154
|
-
async function installUrl(sandbox, dependency, signal) {
|
|
156
|
+
async function installUrl(sandbox, dependency, signal, timeoutMs) {
|
|
155
157
|
const rpmPath = filePath(dependency.url, dependency.sha256);
|
|
156
158
|
await runOrThrow(
|
|
157
159
|
sandbox,
|
|
158
160
|
{
|
|
159
161
|
cmd: "curl",
|
|
160
162
|
args: ["-fsSL", dependency.url, "-o", rpmPath],
|
|
161
|
-
signal
|
|
163
|
+
signal,
|
|
164
|
+
timeoutMs
|
|
162
165
|
},
|
|
163
166
|
`curl download ${dependency.url}`
|
|
164
167
|
);
|
|
165
168
|
const checksum = await runNonInteractiveCommand(sandbox, {
|
|
166
169
|
cmd: "sha256sum",
|
|
167
170
|
args: [rpmPath],
|
|
168
|
-
signal
|
|
171
|
+
signal,
|
|
172
|
+
timeoutMs
|
|
169
173
|
});
|
|
170
174
|
const expected = dependency.sha256;
|
|
171
175
|
const actual = checksum.stdout.trim().split(/\s+/)[0]?.toLowerCase();
|
|
@@ -187,12 +191,13 @@ async function installUrl(sandbox, dependency, signal) {
|
|
|
187
191
|
cmd: "dnf",
|
|
188
192
|
args: ["install", "-y", rpmPath],
|
|
189
193
|
signal,
|
|
190
|
-
sudo: true
|
|
194
|
+
sudo: true,
|
|
195
|
+
timeoutMs
|
|
191
196
|
},
|
|
192
197
|
`dnf install ${dependency.url}`
|
|
193
198
|
);
|
|
194
199
|
}
|
|
195
|
-
async function dependencies(sandbox, values, signal) {
|
|
200
|
+
async function dependencies(sandbox, values, signal, timeoutMs) {
|
|
196
201
|
const system = values.filter(
|
|
197
202
|
(dependency) => dependency.type === "system"
|
|
198
203
|
);
|
|
@@ -210,9 +215,9 @@ async function dependencies(sandbox, values, signal) {
|
|
|
210
215
|
for (const dependency of system) {
|
|
211
216
|
signal?.throwIfAborted();
|
|
212
217
|
if ("url" in dependency) {
|
|
213
|
-
await installUrl(sandbox, dependency, signal);
|
|
218
|
+
await installUrl(sandbox, dependency, signal, timeoutMs);
|
|
214
219
|
} else if (dependency.package === "gh") {
|
|
215
|
-
await installGh(sandbox, signal);
|
|
220
|
+
await installGh(sandbox, signal, timeoutMs);
|
|
216
221
|
} else {
|
|
217
222
|
await runOrThrow(
|
|
218
223
|
sandbox,
|
|
@@ -220,7 +225,8 @@ async function dependencies(sandbox, values, signal) {
|
|
|
220
225
|
cmd: "dnf",
|
|
221
226
|
args: ["install", "-y", dependency.package],
|
|
222
227
|
signal,
|
|
223
|
-
sudo: true
|
|
228
|
+
sudo: true,
|
|
229
|
+
timeoutMs
|
|
224
230
|
},
|
|
225
231
|
`dnf install ${dependency.package}`
|
|
226
232
|
);
|
|
@@ -248,7 +254,8 @@ async function dependencies(sandbox, values, signal) {
|
|
|
248
254
|
`${SANDBOX_WORKSPACE_ROOT}/.junior`,
|
|
249
255
|
...npm
|
|
250
256
|
],
|
|
251
|
-
signal
|
|
257
|
+
signal,
|
|
258
|
+
timeoutMs
|
|
252
259
|
},
|
|
253
260
|
"npm install"
|
|
254
261
|
);
|
|
@@ -256,7 +263,7 @@ async function dependencies(sandbox, values, signal) {
|
|
|
256
263
|
);
|
|
257
264
|
}
|
|
258
265
|
}
|
|
259
|
-
async function postinstall(sandbox, commands, signal) {
|
|
266
|
+
async function postinstall(sandbox, commands, signal, timeoutMs) {
|
|
260
267
|
if (commands.length === 0) {
|
|
261
268
|
return;
|
|
262
269
|
}
|
|
@@ -275,6 +282,7 @@ async function postinstall(sandbox, commands, signal) {
|
|
|
275
282
|
login: true,
|
|
276
283
|
pathPrefix: `${SANDBOX_WORKSPACE_ROOT}/.junior/bin:$PATH`,
|
|
277
284
|
signal,
|
|
285
|
+
timeoutMs,
|
|
278
286
|
...command.sudo !== void 0 ? { sudo: command.sudo } : {}
|
|
279
287
|
});
|
|
280
288
|
if (result.exitCode !== 0) {
|
|
@@ -292,240 +300,6 @@ async function postinstall(sandbox, commands, signal) {
|
|
|
292
300
|
import {
|
|
293
301
|
FileSystem
|
|
294
302
|
} from "@vercel/sandbox";
|
|
295
|
-
|
|
296
|
-
// src/chat/sandbox/http-error-details.ts
|
|
297
|
-
var DEFAULT_PREVIEW_LIMIT = 512;
|
|
298
|
-
function toTrimmedString(value, maxChars) {
|
|
299
|
-
if (typeof value !== "string") {
|
|
300
|
-
return void 0;
|
|
301
|
-
}
|
|
302
|
-
const normalized = value.trim();
|
|
303
|
-
if (!normalized) {
|
|
304
|
-
return void 0;
|
|
305
|
-
}
|
|
306
|
-
return normalized.length > maxChars ? `${normalized.slice(0, maxChars)}\u2026` : normalized;
|
|
307
|
-
}
|
|
308
|
-
function extractHttpErrorDetails(error, options = {}) {
|
|
309
|
-
const prefix = options.attributePrefix ?? "app.http_error";
|
|
310
|
-
const previewLimit = options.previewLimit ?? DEFAULT_PREVIEW_LIMIT;
|
|
311
|
-
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
312
|
-
const err = error ?? {};
|
|
313
|
-
const attributes = {
|
|
314
|
-
"error.type": normalizedError.name || "Error",
|
|
315
|
-
"exception.message": toTrimmedString(normalizedError.message, previewLimit) ?? "HTTP error"
|
|
316
|
-
};
|
|
317
|
-
const response = err.response;
|
|
318
|
-
const statusCode = typeof response?.status === "number" ? response.status : void 0;
|
|
319
|
-
const statusText = toTrimmedString(response?.statusText, previewLimit);
|
|
320
|
-
const responseUrl = toTrimmedString(response?.url, previewLimit);
|
|
321
|
-
const responseText = toTrimmedString(err.text, previewLimit);
|
|
322
|
-
const responseJson = toTrimmedString(
|
|
323
|
-
err.json && typeof err.json === "object" ? JSON.stringify(err.json) : void 0,
|
|
324
|
-
previewLimit
|
|
325
|
-
);
|
|
326
|
-
const contentType = toTrimmedString(
|
|
327
|
-
response?.headers?.get?.("content-type"),
|
|
328
|
-
previewLimit
|
|
329
|
-
);
|
|
330
|
-
const requestIdHeader = toTrimmedString(
|
|
331
|
-
response?.headers?.get?.("x-request-id"),
|
|
332
|
-
previewLimit
|
|
333
|
-
);
|
|
334
|
-
const vercelIdHeader = toTrimmedString(
|
|
335
|
-
response?.headers?.get?.("x-vercel-id"),
|
|
336
|
-
previewLimit
|
|
337
|
-
);
|
|
338
|
-
const requestId = requestIdHeader ?? vercelIdHeader;
|
|
339
|
-
if (statusCode !== void 0) {
|
|
340
|
-
attributes["http.response.status_code"] = statusCode;
|
|
341
|
-
}
|
|
342
|
-
if (statusText) {
|
|
343
|
-
attributes[`${prefix}.status_text`] = statusText;
|
|
344
|
-
}
|
|
345
|
-
if (responseUrl) {
|
|
346
|
-
attributes["url.full"] = responseUrl;
|
|
347
|
-
}
|
|
348
|
-
if (contentType) {
|
|
349
|
-
attributes["http.response.header.content-type"] = [contentType];
|
|
350
|
-
}
|
|
351
|
-
if (requestIdHeader) {
|
|
352
|
-
attributes["http.response.header.x-request-id"] = [requestIdHeader];
|
|
353
|
-
}
|
|
354
|
-
if (vercelIdHeader) {
|
|
355
|
-
attributes["http.response.header.x-vercel-id"] = [vercelIdHeader];
|
|
356
|
-
}
|
|
357
|
-
if (responseText) {
|
|
358
|
-
attributes[`${prefix}.response_text_preview`] = responseText;
|
|
359
|
-
attributes[`${prefix}.response_text_length`] = responseText.length;
|
|
360
|
-
}
|
|
361
|
-
if (responseJson) {
|
|
362
|
-
attributes[`${prefix}.response_json_preview`] = responseJson;
|
|
363
|
-
}
|
|
364
|
-
const summaryParts = [];
|
|
365
|
-
if (statusCode !== void 0) {
|
|
366
|
-
summaryParts.push(`status=${statusCode}`);
|
|
367
|
-
}
|
|
368
|
-
if (statusText) {
|
|
369
|
-
summaryParts.push(`statusText=${statusText}`);
|
|
370
|
-
}
|
|
371
|
-
if (responseUrl) {
|
|
372
|
-
summaryParts.push(`url=${responseUrl}`);
|
|
373
|
-
}
|
|
374
|
-
if (requestId) {
|
|
375
|
-
summaryParts.push(`requestId=${requestId}`);
|
|
376
|
-
}
|
|
377
|
-
for (const field of options.extraFields ?? []) {
|
|
378
|
-
const value = toTrimmedString(err[field.sourceKey], previewLimit);
|
|
379
|
-
if (!value) {
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
attributes[`${prefix}.${field.attributeKey}`] = value;
|
|
383
|
-
summaryParts.push(`${field.summaryKey ?? field.attributeKey}=${value}`);
|
|
384
|
-
}
|
|
385
|
-
if (responseJson) {
|
|
386
|
-
summaryParts.push(`json=${responseJson}`);
|
|
387
|
-
} else if (responseText) {
|
|
388
|
-
summaryParts.push(`text=${responseText}`);
|
|
389
|
-
}
|
|
390
|
-
const searchableText = `${normalizedError.message} ${responseText ?? ""} ${responseJson ?? ""}`.toLowerCase();
|
|
391
|
-
return {
|
|
392
|
-
attributes,
|
|
393
|
-
summary: summaryParts.join(", "),
|
|
394
|
-
searchableText
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/chat/sandbox/errors.ts
|
|
399
|
-
var SANDBOX_ERROR_FIELDS = [
|
|
400
|
-
{
|
|
401
|
-
sourceKey: "sandboxId",
|
|
402
|
-
attributeKey: "sandbox_id",
|
|
403
|
-
summaryKey: "sandboxId"
|
|
404
|
-
}
|
|
405
|
-
];
|
|
406
|
-
function getSandboxErrorDetails(error) {
|
|
407
|
-
return extractHttpErrorDetails(error, {
|
|
408
|
-
attributePrefix: "app.sandbox.api_error",
|
|
409
|
-
extraFields: [...SANDBOX_ERROR_FIELDS]
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
function findInErrorChain(error, predicate) {
|
|
413
|
-
const seen = /* @__PURE__ */ new Set();
|
|
414
|
-
let current = error;
|
|
415
|
-
while (current && !seen.has(current)) {
|
|
416
|
-
if (predicate(current)) {
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
seen.add(current);
|
|
420
|
-
current = typeof current === "object" ? current.cause : void 0;
|
|
421
|
-
}
|
|
422
|
-
return false;
|
|
423
|
-
}
|
|
424
|
-
function isRecord(value) {
|
|
425
|
-
return typeof value === "object" && value !== null;
|
|
426
|
-
}
|
|
427
|
-
function isInvalidSandboxSessionError(error) {
|
|
428
|
-
if (!isRecord(error)) {
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
if (isRecord(error.json) && error.json.invalidToken === true) {
|
|
432
|
-
return true;
|
|
433
|
-
}
|
|
434
|
-
const response = error.response;
|
|
435
|
-
return isRecord(response) && response.status === 403 && typeof response.url === "string" && response.url.includes("/sandboxes/sessions");
|
|
436
|
-
}
|
|
437
|
-
function getFirstErrorMessage(error) {
|
|
438
|
-
const seen = /* @__PURE__ */ new Set();
|
|
439
|
-
let current = error;
|
|
440
|
-
while (current && !seen.has(current)) {
|
|
441
|
-
if (current instanceof Error) {
|
|
442
|
-
const message = current.message.trim();
|
|
443
|
-
if (message) {
|
|
444
|
-
return message;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
seen.add(current);
|
|
448
|
-
current = typeof current === "object" ? current.cause : void 0;
|
|
449
|
-
}
|
|
450
|
-
return void 0;
|
|
451
|
-
}
|
|
452
|
-
function isAlreadyExistsError(error) {
|
|
453
|
-
const details = getSandboxErrorDetails(error);
|
|
454
|
-
return details.searchableText.includes("already exists") || details.searchableText.includes("file exists") || details.searchableText.includes("eexist");
|
|
455
|
-
}
|
|
456
|
-
function isSandboxUnavailableError(error) {
|
|
457
|
-
return findInErrorChain(error, (candidate) => {
|
|
458
|
-
if (isInvalidSandboxSessionError(candidate)) {
|
|
459
|
-
return true;
|
|
460
|
-
}
|
|
461
|
-
const details = getSandboxErrorDetails(candidate);
|
|
462
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
463
|
-
return searchable.includes("sandbox_stopped") || searchable.includes("status=410") || searchable.includes("status code 410") || searchable.includes("no longer available") || searchable.includes("stream was closed and is not accepting commands");
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
function isSandboxMissingError(error) {
|
|
467
|
-
return findInErrorChain(error, (candidate) => {
|
|
468
|
-
const details = getSandboxErrorDetails(candidate);
|
|
469
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
470
|
-
return searchable.includes("status=404") || searchable.includes("status code 404") || searchable.includes("snapshot_not_found");
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
function isSnapshottingError(error) {
|
|
474
|
-
return findInErrorChain(error, (candidate) => {
|
|
475
|
-
const details = getSandboxErrorDetails(candidate);
|
|
476
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
477
|
-
return searchable.includes("sandbox_snapshotting") || searchable.includes("creating a snapshot") || searchable.includes("stopped shortly");
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
function isSandboxCommandStreamInterruptedError(error) {
|
|
481
|
-
return findInErrorChain(error, (candidate) => {
|
|
482
|
-
if (!(candidate instanceof Error)) {
|
|
483
|
-
return false;
|
|
484
|
-
}
|
|
485
|
-
return candidate.name === "StreamError" && candidate.message.toLowerCase().includes("stream ended before command finished");
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
function wrapSandboxSetupError(error) {
|
|
489
|
-
try {
|
|
490
|
-
const details = getSandboxErrorDetails(error);
|
|
491
|
-
if (details.summary) {
|
|
492
|
-
return new Error(`sandbox setup failed (${details.summary})`, {
|
|
493
|
-
cause: error
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
} catch {
|
|
497
|
-
}
|
|
498
|
-
let causeMessage;
|
|
499
|
-
try {
|
|
500
|
-
causeMessage = getFirstErrorMessage(error);
|
|
501
|
-
} catch (cause) {
|
|
502
|
-
causeMessage = cause instanceof Error ? cause.message : void 0;
|
|
503
|
-
}
|
|
504
|
-
if (causeMessage && causeMessage.trim() && causeMessage !== "sandbox setup failed") {
|
|
505
|
-
const oneLine = causeMessage.replace(/\s+/g, " ").trim();
|
|
506
|
-
return new Error(`sandbox setup failed (${oneLine})`, { cause: error });
|
|
507
|
-
}
|
|
508
|
-
return new Error("sandbox setup failed", { cause: error });
|
|
509
|
-
}
|
|
510
|
-
function throwSandboxOperationError(action, error, includeMissingPath = false) {
|
|
511
|
-
const details = getSandboxErrorDetails(error);
|
|
512
|
-
setSpanAttributes({
|
|
513
|
-
...details.attributes,
|
|
514
|
-
...includeMissingPath ? {
|
|
515
|
-
"app.sandbox.api_error.missing_path": details.searchableText.includes("no such file") || details.searchableText.includes("enoent")
|
|
516
|
-
} : {},
|
|
517
|
-
"app.sandbox.success": false
|
|
518
|
-
});
|
|
519
|
-
setSpanStatus("error");
|
|
520
|
-
throw new Error(
|
|
521
|
-
details.summary ? `${action} failed (${details.summary})` : `${action} failed`,
|
|
522
|
-
{
|
|
523
|
-
cause: error
|
|
524
|
-
}
|
|
525
|
-
);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// src/chat/sandbox/workspace.ts
|
|
529
303
|
function bindSandboxFileSystem(fs, signal) {
|
|
530
304
|
if (!signal) {
|
|
531
305
|
return fs;
|
|
@@ -917,17 +691,12 @@ function isMissingError(error) {
|
|
|
917
691
|
}
|
|
918
692
|
|
|
919
693
|
export {
|
|
920
|
-
isAlreadyExistsError,
|
|
921
|
-
isSandboxUnavailableError,
|
|
922
|
-
isSandboxMissingError,
|
|
923
|
-
isSnapshottingError,
|
|
924
|
-
isSandboxCommandStreamInterruptedError,
|
|
925
|
-
wrapSandboxSetupError,
|
|
926
|
-
throwSandboxOperationError,
|
|
927
|
-
getVercelSandboxCredentials,
|
|
928
694
|
getSandboxResourceConfig,
|
|
929
695
|
setSandboxResourceConfig,
|
|
930
696
|
getSandboxResources,
|
|
697
|
+
setSnapshotSpanAttributes,
|
|
698
|
+
dependencies,
|
|
699
|
+
postinstall,
|
|
931
700
|
bindSandboxFileSystem,
|
|
932
701
|
createSandboxSession,
|
|
933
702
|
stopSession,
|