@sentry/junior 0.169.0 → 0.171.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-YGKANST4.js → agent-hooks-UXIRPATC.js} +16 -11
- package/dist/api.js +33 -32
- package/dist/app.js +35 -35
- package/dist/catalog-runtime-PQCGQUXA.js +16 -0
- package/dist/chat/conversations/sql/store.d.ts +7 -0
- package/dist/chat/conversations/store.d.ts +14 -0
- package/dist/chat/sandbox/snapshot/store.d.ts +28 -0
- package/dist/chat/slack/channel.d.ts +0 -13
- package/dist/chat/slack/ids.d.ts +7 -1
- package/dist/chat/slack/tool-support/channel-target.d.ts +6 -5
- package/dist/chat/workspaces/store.d.ts +1 -10
- package/dist/chat/workspaces/types.d.ts +14 -1
- package/dist/{chunk-Q62IHFIH.js → chunk-2AYWP7PZ.js} +6 -270
- package/dist/{chunk-VRMPMOAT.js → chunk-3AX2WCFV.js} +2 -2
- package/dist/{chunk-OU2DMDUI.js → chunk-4TKPTFSO.js} +1 -1
- package/dist/{chunk-MKEHLCSM.js → chunk-5GF7HQOP.js} +70 -11
- package/dist/{chunk-S6JDUILF.js → chunk-5ML752HJ.js} +8 -8
- package/dist/{chunk-2VK3CYSL.js → chunk-5TZ2DKVU.js} +1 -1
- package/dist/{chunk-EEKFF74Y.js → chunk-62WK6FLT.js} +183 -69
- package/dist/{chunk-FSH6HT5C.js → chunk-6RRTVWAD.js} +1 -1
- package/dist/{chunk-7MA4HV4W.js → chunk-6ZWRNC4D.js} +1 -1
- package/dist/{chunk-ELOZI777.js → chunk-AOAOBZJQ.js} +18 -18
- package/dist/{chunk-BDUENQD3.js → chunk-CGA4ERJ5.js} +1 -1
- package/dist/chunk-CVHKLS7B.js +399 -0
- package/dist/{chunk-HWXQZCKV.js → chunk-CWTWZKWH.js} +7 -7
- package/dist/{chunk-23IKSW3E.js → chunk-FI5A2RF6.js} +1 -1
- package/dist/{chunk-FIMO3IDW.js → chunk-HKWEMKK4.js} +32 -4
- package/dist/{chunk-65QX23BY.js → chunk-HWXXFINO.js} +13 -13
- package/dist/{chunk-7RIHHVFN.js → chunk-IZSMYLCS.js} +11 -11
- package/dist/{chunk-URM4KBIU.js → chunk-JNYIJHFF.js} +1 -1
- package/dist/{chunk-JNK444WM.js → chunk-KUYIW4BD.js} +2 -2
- package/dist/{chunk-WYNLAO2K.js → chunk-M5QJJMFK.js} +4 -4
- package/dist/{chunk-V7YE4WCP.js → chunk-M63DETLL.js} +7 -4
- package/dist/{chunk-BOZCSRAR.js → chunk-MFFU45QO.js} +1 -1
- package/dist/{chunk-73XNLM4O.js → chunk-O2SUZKWU.js} +5 -5
- package/dist/{chunk-WF3WTELH.js → chunk-POF7HORW.js} +6 -6
- package/dist/{chunk-5Z7QQYHV.js → chunk-QHBHUCDS.js} +7 -7
- package/dist/{chunk-TMZOUVEP.js → chunk-SIOO3CCL.js} +1 -1
- package/dist/{chunk-MPLBAWGP.js → chunk-UC35XHGT.js} +2 -2
- package/dist/{chunk-VVQYG2GD.js → chunk-UTG3IY2C.js} +63 -100
- package/dist/{chunk-JJUZK6P2.js → chunk-VGWC4KG2.js} +5 -9
- package/dist/{chunk-YTVYU5IF.js → chunk-WCWPRFHZ.js} +1 -1
- package/dist/{chunk-ECBD46QI.js → chunk-WIUGVE66.js} +6 -6
- package/dist/{chunk-EPXPE5Y5.js → chunk-XHBYNJNZ.js} +2 -2
- package/dist/{chunk-ZXCVYSTS.js → chunk-Y5RRKS67.js} +5 -5
- package/dist/{chunk-5OUQCD2J.js → chunk-Y6DW6AVG.js} +1 -1
- package/dist/{chunk-N7V2WPZV.js → chunk-YURMXTZF.js} +1 -1
- package/dist/cli/chat.js +34 -34
- package/dist/cli/check.js +8 -8
- package/dist/cli/plugins.js +15 -15
- package/dist/cli/snapshot-create.js +14 -13
- package/dist/cli/upgrade.js +9 -9
- package/dist/db/schema/snapshots.d.ts +254 -0
- package/dist/db/schema/workspaces.d.ts +0 -68
- package/dist/db/schema.d.ts +251 -69
- package/dist/{db-CA3AJ2BU.js → db-EHCO5WGL.js} +8 -8
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-JVWWSDT5.js → oauth-callback-server-O7CH6FOJ.js} +25 -25
- package/dist/{runner-CMDQJDCH.js → runner-3D5AGGUD.js} +19 -15
- package/dist/{sandbox-egress-signals-U3ZX7C5W.js → sandbox-egress-signals-DXOOBSBI.js} +3 -3
- package/dist/{skills-GYJ4MBNQ.js → skills-6IW3DDW2.js} +8 -8
- package/dist/spawn-5LKOLABU.js +37 -0
- package/dist/{validation-55EBPZHH.js → validation-RCLP4EU4.js} +8 -8
- package/dist/version.js +1 -1
- package/dist/{work-N7CBTARL.js → work-L54N7O65.js} +21 -21
- package/dist/worker-VJCSXI5L.js +24 -0
- package/migrations/0032_workspace_snapshots_table.sql +69 -0
- package/migrations/meta/0032_snapshot.json +2892 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +5 -5
- package/dist/catalog-runtime-BFDMFZV4.js +0 -16
- package/dist/chunk-BVREIWBD.js +0 -131
- package/dist/spawn-KSP4DKK6.js +0 -37
- package/dist/worker-CGMUVQ2Q.js +0 -24
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pluginCatalogRuntime
|
|
3
|
+
} from "./chunk-SIOO3CCL.js";
|
|
4
|
+
|
|
5
|
+
// src/chat/sandbox/paths.ts
|
|
6
|
+
function normalizeWorkspaceRoot(input) {
|
|
7
|
+
const candidate = (input ?? "").trim();
|
|
8
|
+
if (!candidate) {
|
|
9
|
+
return "/vercel/sandbox";
|
|
10
|
+
}
|
|
11
|
+
const normalized = candidate.replace(/\/+$/, "");
|
|
12
|
+
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
13
|
+
}
|
|
14
|
+
var SANDBOX_WORKSPACE_ROOT = normalizeWorkspaceRoot(
|
|
15
|
+
process.env.VERCEL_SANDBOX_WORKSPACE_DIR
|
|
16
|
+
);
|
|
17
|
+
var SANDBOX_REPOS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/repos`;
|
|
18
|
+
var SANDBOX_SKILLS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/skills`;
|
|
19
|
+
var SANDBOX_DATA_ROOT = `${SANDBOX_WORKSPACE_ROOT}/data`;
|
|
20
|
+
function sandboxSkillDir(skillName) {
|
|
21
|
+
return `${SANDBOX_SKILLS_ROOT}/${skillName}`;
|
|
22
|
+
}
|
|
23
|
+
function sandboxSkillFile(skillName) {
|
|
24
|
+
return `${sandboxSkillDir(skillName)}/SKILL.md`;
|
|
25
|
+
}
|
|
26
|
+
function sandboxSkillPathResolution(skillName) {
|
|
27
|
+
const skillDir = sandboxSkillDir(skillName);
|
|
28
|
+
return `Resolve relative paths in this skill against ${skillDir}. For bash commands from this skill, cd to ${skillDir} first or use absolute paths.`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/chat/sandbox/noninteractive-command.ts
|
|
32
|
+
var NON_INTERACTIVE_ENV = {
|
|
33
|
+
CI: "1",
|
|
34
|
+
TERM: "dumb",
|
|
35
|
+
NO_COLOR: "1",
|
|
36
|
+
PAGER: "cat",
|
|
37
|
+
GIT_PAGER: "cat",
|
|
38
|
+
GH_PROMPT_DISABLED: "1",
|
|
39
|
+
GH_NO_UPDATE_NOTIFIER: "1",
|
|
40
|
+
GH_NO_EXTENSION_UPDATE_NOTIFIER: "1",
|
|
41
|
+
GH_SPINNER_DISABLED: "1",
|
|
42
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
43
|
+
GCM_INTERACTIVE: "never",
|
|
44
|
+
DEBIAN_FRONTEND: "noninteractive",
|
|
45
|
+
// Git credential isolation: prevent git from sending its own auth so the
|
|
46
|
+
// sandbox egress proxy's header transforms are the sole credential source.
|
|
47
|
+
GIT_ASKPASS: "/bin/true",
|
|
48
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
49
|
+
GIT_CONFIG_COUNT: "2",
|
|
50
|
+
GIT_CONFIG_KEY_0: "credential.helper",
|
|
51
|
+
GIT_CONFIG_VALUE_0: "",
|
|
52
|
+
GIT_CONFIG_KEY_1: "http.emptyAuth",
|
|
53
|
+
GIT_CONFIG_VALUE_1: "true"
|
|
54
|
+
};
|
|
55
|
+
function shellQuote(value) {
|
|
56
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
57
|
+
}
|
|
58
|
+
function buildEnvExports(options) {
|
|
59
|
+
const lines = [];
|
|
60
|
+
if (options.pathPrefix) {
|
|
61
|
+
lines.push(`export PATH="${options.pathPrefix}"`);
|
|
62
|
+
}
|
|
63
|
+
for (const [key, value] of Object.entries(NON_INTERACTIVE_ENV)) {
|
|
64
|
+
lines.push(`export ${key}=${shellQuote(value)}`);
|
|
65
|
+
}
|
|
66
|
+
for (const [key, value] of Object.entries(options.env ?? {})) {
|
|
67
|
+
lines.push(`export ${key}=${shellQuote(value)}`);
|
|
68
|
+
}
|
|
69
|
+
return lines;
|
|
70
|
+
}
|
|
71
|
+
function buildCommandScript(input) {
|
|
72
|
+
return [shellQuote(input.cmd), ...(input.args ?? []).map(shellQuote)].join(
|
|
73
|
+
" "
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
function buildNonInteractiveShellScript(script, options = {}) {
|
|
77
|
+
return [...buildEnvExports(options), "exec </dev/null", script].join(" && ");
|
|
78
|
+
}
|
|
79
|
+
function buildNonInteractiveCommand(input) {
|
|
80
|
+
return {
|
|
81
|
+
cmd: "bash",
|
|
82
|
+
args: [
|
|
83
|
+
input.login ? "-lc" : "-c",
|
|
84
|
+
buildNonInteractiveShellScript(buildCommandScript(input), {
|
|
85
|
+
env: input.env,
|
|
86
|
+
pathPrefix: input.pathPrefix
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async function runNonInteractiveCommand(sandbox, input) {
|
|
92
|
+
const command = {
|
|
93
|
+
...buildNonInteractiveCommand(input),
|
|
94
|
+
...input.cwd ? { cwd: input.cwd } : {},
|
|
95
|
+
...input.signal ? { signal: input.signal } : {},
|
|
96
|
+
...input.sudo !== void 0 ? { sudo: input.sudo } : {}
|
|
97
|
+
};
|
|
98
|
+
return await sandbox.runCommand(command);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/chat/sandbox/snapshot/profile.ts
|
|
102
|
+
import { createHash } from "crypto";
|
|
103
|
+
|
|
104
|
+
// src/chat/sandbox/docker.ts
|
|
105
|
+
var DOCKER_DAEMON_JSON = `{
|
|
106
|
+
"storage-driver": "overlay2",
|
|
107
|
+
"live-restore": false
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
var DOCKER_ENSURE_SCRIPT = `#!/bin/sh
|
|
111
|
+
set -eu
|
|
112
|
+
|
|
113
|
+
if [ "$(id -u)" -ne 0 ]; then
|
|
114
|
+
exec sudo -n "$0" "$@"
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
SOCK=/var/run/docker.sock
|
|
118
|
+
PIDFILE=/var/run/docker.pid
|
|
119
|
+
LOG=/var/log/junior-dockerd.log
|
|
120
|
+
|
|
121
|
+
is_ready() {
|
|
122
|
+
[ -S "$SOCK" ] && /usr/bin/docker info >/dev/null 2>&1
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if is_ready; then
|
|
126
|
+
chmod 666 "$SOCK" 2>/dev/null || true
|
|
127
|
+
exit 0
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
mkdir -p /etc/docker /var/lib/docker /var/run /var/log
|
|
131
|
+
if [ ! -f /etc/docker/daemon.json ]; then
|
|
132
|
+
cat > /etc/docker/daemon.json <<'EOF'
|
|
133
|
+
{
|
|
134
|
+
"storage-driver": "overlay2",
|
|
135
|
+
"live-restore": false
|
|
136
|
+
}
|
|
137
|
+
EOF
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
if [ -f "$PIDFILE" ]; then
|
|
141
|
+
oldpid="$(cat "$PIDFILE" 2>/dev/null || true)"
|
|
142
|
+
if [ -n "\${oldpid:-}" ] && ! kill -0 "$oldpid" 2>/dev/null; then
|
|
143
|
+
rm -f "$PIDFILE"
|
|
144
|
+
fi
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
if [ ! -f "$PIDFILE" ] || ! kill -0 "$(cat "$PIDFILE" 2>/dev/null)" 2>/dev/null; then
|
|
148
|
+
# dockerd must outlive this helper; nohup + background is intentional.
|
|
149
|
+
nohup dockerd --host="unix://$SOCK" --pidfile="$PIDFILE" >"$LOG" 2>&1 &
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
i=0
|
|
153
|
+
while [ "$i" -lt 50 ]; do
|
|
154
|
+
if is_ready; then
|
|
155
|
+
chmod 666 "$SOCK" 2>/dev/null || true
|
|
156
|
+
exit 0
|
|
157
|
+
fi
|
|
158
|
+
i=$((i + 1))
|
|
159
|
+
sleep 0.1
|
|
160
|
+
done
|
|
161
|
+
|
|
162
|
+
echo "junior-ensure-docker: dockerd failed to become ready" >&2
|
|
163
|
+
if [ -f "$LOG" ]; then
|
|
164
|
+
tail -n 50 "$LOG" >&2 || true
|
|
165
|
+
fi
|
|
166
|
+
exit 1
|
|
167
|
+
`;
|
|
168
|
+
var DOCKER_CLI_WRAPPER_SCRIPT = `#!/bin/sh
|
|
169
|
+
set -eu
|
|
170
|
+
if command -v junior-ensure-docker >/dev/null 2>&1; then
|
|
171
|
+
junior-ensure-docker
|
|
172
|
+
fi
|
|
173
|
+
exec /usr/bin/docker "$@"
|
|
174
|
+
`;
|
|
175
|
+
var DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT = `#!/bin/sh
|
|
176
|
+
set -eu
|
|
177
|
+
if command -v junior-ensure-docker >/dev/null 2>&1; then
|
|
178
|
+
junior-ensure-docker
|
|
179
|
+
fi
|
|
180
|
+
exec /usr/local/libexec/junior-docker-compose "$@"
|
|
181
|
+
`;
|
|
182
|
+
async function ensureDockerDaemon(sandbox, signal) {
|
|
183
|
+
await runNonInteractiveCommand(sandbox, {
|
|
184
|
+
cmd: "sh",
|
|
185
|
+
args: [
|
|
186
|
+
"-c",
|
|
187
|
+
"command -v junior-ensure-docker >/dev/null 2>&1 && junior-ensure-docker || true"
|
|
188
|
+
],
|
|
189
|
+
signal
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/chat/sandbox/runtime-dependencies.ts
|
|
194
|
+
var GLOBAL_RUNTIME_DEPENDENCIES = [
|
|
195
|
+
{ type: "system", package: "docker" },
|
|
196
|
+
{ type: "system", package: "spal-release" },
|
|
197
|
+
{ type: "system", package: "ripgrep" }
|
|
198
|
+
];
|
|
199
|
+
function writeFileCommand(path, contents, mode = "0644") {
|
|
200
|
+
const payload = Buffer.from(contents, "utf8").toString("base64");
|
|
201
|
+
return [
|
|
202
|
+
`printf '%s' '${payload}' | base64 -d > ${path}`,
|
|
203
|
+
`chmod ${mode} ${path}`
|
|
204
|
+
].join("\n");
|
|
205
|
+
}
|
|
206
|
+
function writeExecutableCommand(path, contents) {
|
|
207
|
+
return writeFileCommand(path, contents, "0755");
|
|
208
|
+
}
|
|
209
|
+
var GLOBAL_RUNTIME_POSTINSTALL = [
|
|
210
|
+
{
|
|
211
|
+
cmd: "sh",
|
|
212
|
+
args: [
|
|
213
|
+
"-c",
|
|
214
|
+
[
|
|
215
|
+
"set -eu",
|
|
216
|
+
'case "$(uname -m)" in',
|
|
217
|
+
' x86_64) asset="x86_64"; sha256="7af95166a730b87e172d4fc9aefea8725d3c6c7327d59149267b452114ddb7d4" ;;',
|
|
218
|
+
' aarch64) asset="aarch64"; sha256="49082844b87f03cdcd5f5bbef1ba8c9c897b7a2dfb80cea18d61ec8ca6117e0c" ;;',
|
|
219
|
+
' *) echo "unsupported Docker Compose architecture: $(uname -m)" >&2; exit 1 ;;',
|
|
220
|
+
"esac",
|
|
221
|
+
'tmp="$(mktemp)"',
|
|
222
|
+
`trap 'rm -f "$tmp"' EXIT`,
|
|
223
|
+
'curl --fail --location --silent --show-error "https://github.com/docker/compose/releases/download/v2.39.4/docker-compose-linux-${asset}" --output "$tmp"',
|
|
224
|
+
'echo "${sha256} ${tmp}" | sha256sum --check --status',
|
|
225
|
+
// Keep the real Compose binary off PATH; the wrapper below starts dockerd.
|
|
226
|
+
'install -D -m 0755 "$tmp" /usr/local/libexec/junior-docker-compose',
|
|
227
|
+
"mkdir -p /usr/local/lib/docker/cli-plugins /usr/local/libexec /etc/docker /usr/local/bin",
|
|
228
|
+
`mkdir -p ${SANDBOX_WORKSPACE_ROOT}/.junior/bin`,
|
|
229
|
+
writeFileCommand("/etc/docker/daemon.json", DOCKER_DAEMON_JSON),
|
|
230
|
+
writeExecutableCommand(
|
|
231
|
+
"/usr/local/bin/junior-ensure-docker",
|
|
232
|
+
DOCKER_ENSURE_SCRIPT
|
|
233
|
+
),
|
|
234
|
+
// docker compose plugin delegates to the real Compose binary.
|
|
235
|
+
"ln -sfn /usr/local/libexec/junior-docker-compose /usr/local/lib/docker/cli-plugins/docker-compose",
|
|
236
|
+
// PATH wrappers auto-start dockerd for both CLI entrypoints.
|
|
237
|
+
writeExecutableCommand(
|
|
238
|
+
"/usr/local/bin/docker-compose",
|
|
239
|
+
DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT
|
|
240
|
+
),
|
|
241
|
+
writeExecutableCommand(
|
|
242
|
+
`${SANDBOX_WORKSPACE_ROOT}/.junior/bin/docker`,
|
|
243
|
+
DOCKER_CLI_WRAPPER_SCRIPT
|
|
244
|
+
),
|
|
245
|
+
writeExecutableCommand(
|
|
246
|
+
`${SANDBOX_WORKSPACE_ROOT}/.junior/bin/docker-compose`,
|
|
247
|
+
DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT
|
|
248
|
+
),
|
|
249
|
+
// Prefer the wrapper over /usr/bin/docker for non-login shells too.
|
|
250
|
+
writeExecutableCommand(
|
|
251
|
+
"/usr/local/bin/docker",
|
|
252
|
+
DOCKER_CLI_WRAPPER_SCRIPT
|
|
253
|
+
)
|
|
254
|
+
].join("\n")
|
|
255
|
+
],
|
|
256
|
+
sudo: true
|
|
257
|
+
}
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
// src/chat/sandbox/snapshot/profile.ts
|
|
261
|
+
var VERSION = 1;
|
|
262
|
+
var DEFAULT_FLOATING_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
263
|
+
function isExactNpmVersion(version) {
|
|
264
|
+
return /^\d+\.\d+\.\d+(?:[-+][a-z0-9.]+)?$/i.test(version.trim());
|
|
265
|
+
}
|
|
266
|
+
function isFloating(dep) {
|
|
267
|
+
return dep.type === "npm" && !isExactNpmVersion(dep.version);
|
|
268
|
+
}
|
|
269
|
+
function mergeDependencies(dependencies) {
|
|
270
|
+
const seen = /* @__PURE__ */ new Set();
|
|
271
|
+
const npmVersions = /* @__PURE__ */ new Map();
|
|
272
|
+
const merged = [];
|
|
273
|
+
for (const dependency of dependencies) {
|
|
274
|
+
const key = dependency.type === "npm" ? `${dependency.type}:${dependency.package}:${dependency.version}` : "package" in dependency ? `${dependency.type}:package:${dependency.package}` : `${dependency.type}:url:${dependency.url}:${dependency.sha256}`;
|
|
275
|
+
if (seen.has(key)) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
seen.add(key);
|
|
279
|
+
if (dependency.type === "npm") {
|
|
280
|
+
const version = npmVersions.get(dependency.package);
|
|
281
|
+
if (version !== void 0 && version !== dependency.version) {
|
|
282
|
+
throw new Error(
|
|
283
|
+
`Conflicting runtime dependency versions for ${dependency.package}: ${version} and ${dependency.version}`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
npmVersions.set(dependency.package, dependency.version);
|
|
287
|
+
}
|
|
288
|
+
merged.push(dependency);
|
|
289
|
+
}
|
|
290
|
+
return merged;
|
|
291
|
+
}
|
|
292
|
+
function floatingMaxAgeMs() {
|
|
293
|
+
const raw = process.env.SANDBOX_SNAPSHOT_FLOATING_MAX_AGE_MS;
|
|
294
|
+
if (!raw?.trim()) {
|
|
295
|
+
return DEFAULT_FLOATING_MAX_AGE_MS;
|
|
296
|
+
}
|
|
297
|
+
const parsed = Number.parseInt(raw, 10);
|
|
298
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_FLOATING_MAX_AGE_MS;
|
|
299
|
+
}
|
|
300
|
+
function compareCodePoints(left, right) {
|
|
301
|
+
if (left < right) return -1;
|
|
302
|
+
if (left > right) return 1;
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
function workspaceRecipe(workspace) {
|
|
306
|
+
const repos = [...workspace.repos].map(({ provider, repo }) => ({
|
|
307
|
+
provider,
|
|
308
|
+
repo
|
|
309
|
+
})).sort((left, right) => {
|
|
310
|
+
const provider = compareCodePoints(left.provider, right.provider);
|
|
311
|
+
if (provider !== 0) return provider;
|
|
312
|
+
return compareCodePoints(left.repo, right.repo);
|
|
313
|
+
});
|
|
314
|
+
return {
|
|
315
|
+
id: workspace.id,
|
|
316
|
+
repos,
|
|
317
|
+
setupScript: workspace.setupScript
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function create(runtime, workspace) {
|
|
321
|
+
const dependencies = mergeDependencies([
|
|
322
|
+
...GLOBAL_RUNTIME_DEPENDENCIES,
|
|
323
|
+
...pluginCatalogRuntime.getRuntimeDependencies()
|
|
324
|
+
]);
|
|
325
|
+
const pluginPostinstall = pluginCatalogRuntime.getRuntimePostinstall();
|
|
326
|
+
const postinstall = [...GLOBAL_RUNTIME_POSTINSTALL, ...pluginPostinstall];
|
|
327
|
+
if (dependencies.length === 0 && postinstall.length === 0 && !workspace) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
const rebuildEpoch = process.env.SANDBOX_SNAPSHOT_REBUILD_EPOCH?.trim() ?? "";
|
|
331
|
+
const floating = dependencies.some((dependency) => isFloating(dependency)) || pluginPostinstall.length > 0 || Boolean(workspace);
|
|
332
|
+
const hash2 = createHash("sha256").update(
|
|
333
|
+
JSON.stringify({
|
|
334
|
+
version: VERSION,
|
|
335
|
+
runtime,
|
|
336
|
+
rebuildEpoch,
|
|
337
|
+
dependencies,
|
|
338
|
+
postinstall,
|
|
339
|
+
...workspace ? { workspace: workspaceRecipe(workspace) } : {}
|
|
340
|
+
})
|
|
341
|
+
).digest("hex");
|
|
342
|
+
return {
|
|
343
|
+
hash: hash2,
|
|
344
|
+
dependencyCount: dependencies.length,
|
|
345
|
+
floating,
|
|
346
|
+
dependencies,
|
|
347
|
+
postinstall
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function hash(runtime, workspace) {
|
|
351
|
+
return create(runtime, workspace)?.hash;
|
|
352
|
+
}
|
|
353
|
+
function isStale(profile, createdAtMs) {
|
|
354
|
+
if (!profile.floating) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
const maxAgeMs = floatingMaxAgeMs();
|
|
358
|
+
return maxAgeMs === 0 || Date.now() - createdAtMs > maxAgeMs;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/chat/sleep.ts
|
|
362
|
+
function sleep(ms, signal) {
|
|
363
|
+
if (!signal) {
|
|
364
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
365
|
+
}
|
|
366
|
+
return new Promise((resolve, reject) => {
|
|
367
|
+
if (signal.aborted) {
|
|
368
|
+
reject(signal.reason);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const timeoutId = setTimeout(() => {
|
|
372
|
+
signal.removeEventListener("abort", onAbort);
|
|
373
|
+
resolve();
|
|
374
|
+
}, ms);
|
|
375
|
+
const onAbort = () => {
|
|
376
|
+
clearTimeout(timeoutId);
|
|
377
|
+
reject(signal.reason);
|
|
378
|
+
};
|
|
379
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export {
|
|
384
|
+
SANDBOX_WORKSPACE_ROOT,
|
|
385
|
+
SANDBOX_REPOS_ROOT,
|
|
386
|
+
SANDBOX_SKILLS_ROOT,
|
|
387
|
+
SANDBOX_DATA_ROOT,
|
|
388
|
+
sandboxSkillDir,
|
|
389
|
+
sandboxSkillFile,
|
|
390
|
+
sandboxSkillPathResolution,
|
|
391
|
+
sleep,
|
|
392
|
+
buildCommandScript,
|
|
393
|
+
buildNonInteractiveShellScript,
|
|
394
|
+
runNonInteractiveCommand,
|
|
395
|
+
ensureDockerDaemon,
|
|
396
|
+
create,
|
|
397
|
+
hash,
|
|
398
|
+
isStale
|
|
399
|
+
};
|
|
@@ -5,28 +5,28 @@ import {
|
|
|
5
5
|
isDmChannel,
|
|
6
6
|
normalizeSlackConversationId,
|
|
7
7
|
withSlackRetries
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-62WK6FLT.js";
|
|
9
9
|
import {
|
|
10
10
|
parseDestination
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HKWEMKK4.js";
|
|
12
12
|
import {
|
|
13
13
|
getStateAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YURMXTZF.js";
|
|
15
15
|
import {
|
|
16
16
|
normalizeSlackEmojiName
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UC35XHGT.js";
|
|
18
18
|
import {
|
|
19
19
|
pluginCatalogRuntime
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-SIOO3CCL.js";
|
|
21
21
|
import {
|
|
22
22
|
parseSlackMessageTs,
|
|
23
23
|
parseSlackUserId
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-M63DETLL.js";
|
|
25
25
|
import {
|
|
26
26
|
isRecord,
|
|
27
27
|
logInfo,
|
|
28
28
|
logWarn
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6RRTVWAD.js";
|
|
30
30
|
|
|
31
31
|
// src/chat/slack/outbound.ts
|
|
32
32
|
var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
juniorConversations,
|
|
8
8
|
juniorIdentities,
|
|
9
9
|
juniorUsers
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-5GF7HQOP.js";
|
|
11
11
|
import {
|
|
12
12
|
TURN_REASONING_LEVELS,
|
|
13
13
|
getChatConfig,
|
|
14
14
|
modelProfileSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UC35XHGT.js";
|
|
16
16
|
import {
|
|
17
17
|
juniorDestinations
|
|
18
18
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
parseActorUserId,
|
|
21
21
|
parseSlackChannelReferenceId,
|
|
22
22
|
parseSlackTeamId
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-M63DETLL.js";
|
|
24
24
|
import {
|
|
25
25
|
normalizeIdentityEmail
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-6RRTVWAD.js";
|
|
27
27
|
|
|
28
28
|
// src/chat/conversations/sql/store.ts
|
|
29
29
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -858,6 +858,34 @@ var SqlStore = class {
|
|
|
858
858
|
}
|
|
859
859
|
return void 0;
|
|
860
860
|
}
|
|
861
|
+
async findSlackDestinationByName(args) {
|
|
862
|
+
const normalized = args.channelName.trim().replace(/^#/, "").toLowerCase();
|
|
863
|
+
if (!normalized) {
|
|
864
|
+
return void 0;
|
|
865
|
+
}
|
|
866
|
+
const rows = await this.executor.db().select({
|
|
867
|
+
channelId: juniorDestinations.providerDestinationId,
|
|
868
|
+
channelName: juniorDestinations.displayName
|
|
869
|
+
}).from(juniorDestinations).where(
|
|
870
|
+
and4(
|
|
871
|
+
eq4(juniorDestinations.provider, "slack"),
|
|
872
|
+
eq4(juniorDestinations.providerTenantId, tenantId2(args.teamId)),
|
|
873
|
+
eq4(juniorDestinations.kind, "channel"),
|
|
874
|
+
sql3`lower(ltrim(${juniorDestinations.displayName}, '#')) = ${normalized}`
|
|
875
|
+
)
|
|
876
|
+
).limit(2);
|
|
877
|
+
if (rows.length !== 1) {
|
|
878
|
+
return void 0;
|
|
879
|
+
}
|
|
880
|
+
const row = rows[0];
|
|
881
|
+
if (!row?.channelId) {
|
|
882
|
+
return void 0;
|
|
883
|
+
}
|
|
884
|
+
return {
|
|
885
|
+
channelId: row.channelId,
|
|
886
|
+
...row.channelName ? { channelName: row.channelName } : {}
|
|
887
|
+
};
|
|
888
|
+
}
|
|
861
889
|
/** Serialize all durable mutations for one conversation inside a SQL transaction. */
|
|
862
890
|
async withConversationMutation(conversationId, callback) {
|
|
863
891
|
return await withConversationMutationLock(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createWebAuthorization,
|
|
3
3
|
deleteWebAuthorization
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MFFU45QO.js";
|
|
5
5
|
import {
|
|
6
6
|
appendAndEnqueueInboundMessage
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y5RRKS67.js";
|
|
8
8
|
import {
|
|
9
9
|
buildDeliveredTurnStatePatch,
|
|
10
10
|
completeAuthPauseTurn,
|
|
@@ -12,20 +12,20 @@ import {
|
|
|
12
12
|
getTurnUserMessage,
|
|
13
13
|
processPluginTask,
|
|
14
14
|
scheduleSessionCompletedPluginTasks
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-IZSMYLCS.js";
|
|
16
16
|
import {
|
|
17
17
|
ConversationTurnLifecycleService,
|
|
18
18
|
coerceThreadConversationState,
|
|
19
19
|
getPersistedSandboxState,
|
|
20
20
|
getPersistedThreadState,
|
|
21
21
|
persistThreadStateById
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-O2SUZKWU.js";
|
|
23
23
|
import {
|
|
24
24
|
healthReportSchema
|
|
25
25
|
} from "./chunk-UTL3MHPC.js";
|
|
26
26
|
import {
|
|
27
27
|
parseSlackThreadId
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-XHBYNJNZ.js";
|
|
29
29
|
import {
|
|
30
30
|
TurnInputCommitLostError,
|
|
31
31
|
abandonTurnRecord,
|
|
@@ -49,40 +49,40 @@ import {
|
|
|
49
49
|
saveTurnCheckpoint,
|
|
50
50
|
startActiveTurn,
|
|
51
51
|
upsertConversationMessage
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-WIUGVE66.js";
|
|
53
53
|
import {
|
|
54
54
|
normalizeSlackConversationId
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-62WK6FLT.js";
|
|
56
56
|
import {
|
|
57
57
|
getConversationEventStore,
|
|
58
58
|
getConversationStore,
|
|
59
59
|
getDb
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-HKWEMKK4.js";
|
|
61
61
|
import {
|
|
62
62
|
juniorApiTokens,
|
|
63
63
|
juniorConversationParticipants,
|
|
64
64
|
juniorConversations,
|
|
65
65
|
juniorIdentities,
|
|
66
66
|
juniorUsers
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-5GF7HQOP.js";
|
|
68
68
|
import {
|
|
69
69
|
getSlackBotToken
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-UC35XHGT.js";
|
|
71
71
|
import {
|
|
72
72
|
juniorDestinations
|
|
73
73
|
} from "./chunk-VFUK3X5B.js";
|
|
74
74
|
import {
|
|
75
75
|
canExposeConversationPayload
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-FI5A2RF6.js";
|
|
77
77
|
import {
|
|
78
78
|
credentialContextForActor
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-CGA4ERJ5.js";
|
|
80
80
|
import {
|
|
81
81
|
logException,
|
|
82
82
|
logWarn,
|
|
83
83
|
setTags,
|
|
84
84
|
withLogContext
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-6RRTVWAD.js";
|
|
86
86
|
|
|
87
87
|
// src/handlers/health.ts
|
|
88
88
|
function readHealthReport() {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState,
|
|
4
4
|
persistThreadStateById
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-O2SUZKWU.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-WIUGVE66.js";
|
|
26
26
|
import {
|
|
27
27
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
28
28
|
} from "./chunk-3Y47VMHV.js";
|
|
@@ -33,35 +33,35 @@ import {
|
|
|
33
33
|
createPluginModel,
|
|
34
34
|
createPluginState,
|
|
35
35
|
getPlugins
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-62WK6FLT.js";
|
|
37
37
|
import {
|
|
38
38
|
getConversationStore,
|
|
39
39
|
getDb,
|
|
40
40
|
sameActorIdentity
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-HKWEMKK4.js";
|
|
42
42
|
import {
|
|
43
43
|
juniorConversations,
|
|
44
44
|
juniorTaskExecutions
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-5GF7HQOP.js";
|
|
46
46
|
import {
|
|
47
47
|
getStateAdapter
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-YURMXTZF.js";
|
|
49
49
|
import {
|
|
50
50
|
ProviderError,
|
|
51
51
|
findProviderError,
|
|
52
52
|
getProviderErrorAttributes,
|
|
53
53
|
getProviderErrorUserMessage
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-UC35XHGT.js";
|
|
55
55
|
import {
|
|
56
56
|
credentialSubjectSchema
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-CGA4ERJ5.js";
|
|
58
58
|
import {
|
|
59
59
|
parseSlackMessageTs
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-M63DETLL.js";
|
|
61
61
|
import {
|
|
62
62
|
buildTurnFailureResponse,
|
|
63
63
|
logWarn
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-6RRTVWAD.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-EHCO5WGL.js")).getConversationStore();
|
|
91
91
|
const conversation = await conversationStore.get({
|
|
92
92
|
conversationId: args.conversationId
|
|
93
93
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
credentialUserSubjectId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CGA4ERJ5.js";
|
|
4
4
|
import {
|
|
5
5
|
logInfo,
|
|
6
6
|
logWarn,
|
|
7
7
|
setSpanAttributes
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6RRTVWAD.js";
|
|
9
9
|
import {
|
|
10
10
|
discoverInstalledPluginPackageContent,
|
|
11
11
|
normalizePluginPackageNames
|