@sentry/junior 0.119.0 → 0.121.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-NZSV4QQR.js → agent-hooks-CQDGDBCP.js} +7 -7
- package/dist/api.js +58 -79
- package/dist/app.js +21 -21
- package/dist/build/copy-build-content.d.ts +2 -2
- package/dist/{catalog-runtime-TAOYIZIZ.js → catalog-runtime-AD3YNTTM.js} +7 -7
- package/dist/chat/discovery.d.ts +2 -0
- package/dist/chat/mcp/tool-manager.d.ts +14 -1
- package/dist/chat/plugins/types.d.ts +3 -9
- package/dist/chat/plugins/user-pages.d.ts +2 -1
- package/dist/chat/sandbox/noninteractive-command.d.ts +1 -0
- package/dist/chat/sandbox/session.d.ts +2 -2
- package/dist/chat/sandbox/snapshot/install.d.ts +2 -2
- package/dist/chat/sandbox/snapshot/resolve.d.ts +1 -0
- package/dist/chat/sandbox/workspace.d.ts +3 -1
- package/dist/{chunk-D3N4BPSL.js → chunk-254MFDOF.js} +2 -2
- package/dist/{chunk-4UIUDOOV.js → chunk-3DBMANUI.js} +7 -7
- package/dist/{chunk-BLQZACHV.js → chunk-7HYV7KFM.js} +92 -6
- package/dist/{chunk-JLJLZS2N.js → chunk-D2EMOH3N.js} +4 -3
- package/dist/{chunk-R53UT2OI.js → chunk-ET2SDCNV.js} +9 -5
- package/dist/chunk-H4HBKISO.js +417 -0
- package/dist/{chunk-VLTWQQKH.js → chunk-IDXLBKPS.js} +1 -1
- package/dist/{chunk-NUENIPQL.js → chunk-IK4QSS5H.js} +1 -1
- package/dist/{chunk-GKFDU3ZI.js → chunk-ITMEXX5H.js} +44 -23
- package/dist/{chunk-ZFX4M743.js → chunk-JYDIBXFY.js} +6 -6
- package/dist/{chunk-ZJ6IVZVO.js → chunk-JZ47AFSH.js} +1 -1
- package/dist/{chunk-YLYJIQRX.js → chunk-KLUMVJRQ.js} +12 -12
- package/dist/{chunk-TAGV4Z3J.js → chunk-LE77HHF3.js} +1 -1
- package/dist/{chunk-B3IT5END.js → chunk-OOUNJNMR.js} +16 -152
- package/dist/{chunk-QZ7XRJDB.js → chunk-TRECK7RV.js} +3 -3
- package/dist/{chunk-VJTWKJWQ.js → chunk-UURFXX66.js} +1 -1
- package/dist/{chunk-6ZR455DC.js → chunk-UXQ5XSA2.js} +1 -1
- package/dist/{chunk-TGIQN7QW.js → chunk-VWBKDPMQ.js} +242 -69
- package/dist/{chunk-JSTGI7TX.js → chunk-WUP7NWMP.js} +1 -1
- package/dist/{chunk-JXRAOOXQ.js → chunk-XDRGYDED.js} +1 -1
- package/dist/{chunk-BNJEPYTC.js → chunk-Z2XXPUZG.js} +4 -4
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +8 -8
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +10 -10
- package/dist/cli/upgrade.js +7 -7
- package/dist/{db-FWGP5CKY.js → db-7HQT2SXQ.js} +5 -5
- package/dist/{discovery-RMHYSRL7.js → discovery-GUFTFBTL.js} +3 -1
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +24 -7
- package/dist/{oauth-callback-server-PM3QNXJQ.js → oauth-callback-server-VHTUCNHK.js} +16 -16
- package/dist/{runner-DV55N6ZB.js → runner-3ONPZRED.js} +9 -9
- package/dist/{skills-MANV5ZK6.js → skills-WGAYGGPA.js} +8 -8
- package/dist/{validation-QGB4INTI.js → validation-ZIWNBG4D.js} +8 -8
- package/dist/version.js +1 -1
- package/package.json +8 -7
- package/skills/jr-rpc/SKILL.md +40 -0
- package/dist/chunk-3V7OFJZC.js +0 -264
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
SANDBOX_WORKSPACE_ROOT,
|
|
3
3
|
getStateAdapter,
|
|
4
4
|
sleep
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UURFXX66.js";
|
|
6
6
|
import {
|
|
7
7
|
toOptionalTrimmed
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IDXLBKPS.js";
|
|
9
9
|
import {
|
|
10
10
|
pluginCatalogRuntime
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WUP7NWMP.js";
|
|
12
12
|
import {
|
|
13
13
|
setSpanAttributes,
|
|
14
14
|
setSpanStatus,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JZ47AFSH.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/snapshot/profile.ts
|
|
19
19
|
import { createHash } from "crypto";
|
|
@@ -196,6 +196,7 @@ async function runNonInteractiveCommand(sandbox, input) {
|
|
|
196
196
|
const command = {
|
|
197
197
|
...buildNonInteractiveCommand(input),
|
|
198
198
|
...input.cwd ? { cwd: input.cwd } : {},
|
|
199
|
+
...input.signal ? { signal: input.signal } : {},
|
|
199
200
|
...input.sudo !== void 0 ? { sudo: input.sudo } : {}
|
|
200
201
|
};
|
|
201
202
|
return await sandbox.runCommand(command);
|
|
@@ -219,10 +220,11 @@ async function tryRun(sandbox, params) {
|
|
|
219
220
|
const result = await runNonInteractiveCommand(sandbox, params);
|
|
220
221
|
return result.exitCode === 0;
|
|
221
222
|
}
|
|
222
|
-
async function installGh(sandbox) {
|
|
223
|
+
async function installGh(sandbox, signal) {
|
|
223
224
|
const installed = await tryRun(sandbox, {
|
|
224
225
|
cmd: "dnf",
|
|
225
226
|
args: ["install", "-y", "gh"],
|
|
227
|
+
signal,
|
|
226
228
|
sudo: true
|
|
227
229
|
});
|
|
228
230
|
if (installed) {
|
|
@@ -235,6 +237,7 @@ async function installGh(sandbox) {
|
|
|
235
237
|
"addrepo",
|
|
236
238
|
"--from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo"
|
|
237
239
|
],
|
|
240
|
+
signal,
|
|
238
241
|
sudo: true
|
|
239
242
|
});
|
|
240
243
|
if (!repoAdded) {
|
|
@@ -243,6 +246,7 @@ async function installGh(sandbox) {
|
|
|
243
246
|
{
|
|
244
247
|
cmd: "dnf",
|
|
245
248
|
args: ["install", "-y", "dnf-command(config-manager)"],
|
|
249
|
+
signal,
|
|
246
250
|
sudo: true
|
|
247
251
|
},
|
|
248
252
|
"dnf install dnf-command(config-manager)"
|
|
@@ -256,6 +260,7 @@ async function installGh(sandbox) {
|
|
|
256
260
|
"--add-repo",
|
|
257
261
|
"https://cli.github.com/packages/rpm/gh-cli.repo"
|
|
258
262
|
],
|
|
263
|
+
signal,
|
|
259
264
|
sudo: true
|
|
260
265
|
},
|
|
261
266
|
"dnf config-manager --add-repo gh-cli.repo"
|
|
@@ -266,6 +271,7 @@ async function installGh(sandbox) {
|
|
|
266
271
|
{
|
|
267
272
|
cmd: "dnf",
|
|
268
273
|
args: ["install", "-y", "gh", "--repo", "gh-cli"],
|
|
274
|
+
signal,
|
|
269
275
|
sudo: true
|
|
270
276
|
},
|
|
271
277
|
"dnf install gh --repo gh-cli"
|
|
@@ -283,19 +289,21 @@ function filePath(url, sha256) {
|
|
|
283
289
|
const sanitized = basename.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
284
290
|
return `/tmp/junior-runtime-${sha256.slice(0, 12)}-${sanitized}`;
|
|
285
291
|
}
|
|
286
|
-
async function installUrl(sandbox, dependency) {
|
|
292
|
+
async function installUrl(sandbox, dependency, signal) {
|
|
287
293
|
const rpmPath = filePath(dependency.url, dependency.sha256);
|
|
288
294
|
await runOrThrow(
|
|
289
295
|
sandbox,
|
|
290
296
|
{
|
|
291
297
|
cmd: "curl",
|
|
292
|
-
args: ["-fsSL", dependency.url, "-o", rpmPath]
|
|
298
|
+
args: ["-fsSL", dependency.url, "-o", rpmPath],
|
|
299
|
+
signal
|
|
293
300
|
},
|
|
294
301
|
`curl download ${dependency.url}`
|
|
295
302
|
);
|
|
296
303
|
const checksum = await runNonInteractiveCommand(sandbox, {
|
|
297
304
|
cmd: "sha256sum",
|
|
298
|
-
args: [rpmPath]
|
|
305
|
+
args: [rpmPath],
|
|
306
|
+
signal
|
|
299
307
|
});
|
|
300
308
|
const expected = dependency.sha256;
|
|
301
309
|
const actual = checksum.stdout.trim().split(/\s+/)[0]?.toLowerCase();
|
|
@@ -316,12 +324,13 @@ async function installUrl(sandbox, dependency) {
|
|
|
316
324
|
{
|
|
317
325
|
cmd: "dnf",
|
|
318
326
|
args: ["install", "-y", rpmPath],
|
|
327
|
+
signal,
|
|
319
328
|
sudo: true
|
|
320
329
|
},
|
|
321
330
|
`dnf install ${dependency.url}`
|
|
322
331
|
);
|
|
323
332
|
}
|
|
324
|
-
async function dependencies(sandbox, values) {
|
|
333
|
+
async function dependencies(sandbox, values, signal) {
|
|
325
334
|
const system = values.filter(
|
|
326
335
|
(dependency) => dependency.type === "system"
|
|
327
336
|
);
|
|
@@ -337,16 +346,18 @@ async function dependencies(sandbox, values) {
|
|
|
337
346
|
},
|
|
338
347
|
async () => {
|
|
339
348
|
for (const dependency of system) {
|
|
349
|
+
signal?.throwIfAborted();
|
|
340
350
|
if ("url" in dependency) {
|
|
341
|
-
await installUrl(sandbox, dependency);
|
|
351
|
+
await installUrl(sandbox, dependency, signal);
|
|
342
352
|
} else if (dependency.package === "gh") {
|
|
343
|
-
await installGh(sandbox);
|
|
353
|
+
await installGh(sandbox, signal);
|
|
344
354
|
} else {
|
|
345
355
|
await runOrThrow(
|
|
346
356
|
sandbox,
|
|
347
357
|
{
|
|
348
358
|
cmd: "dnf",
|
|
349
359
|
args: ["install", "-y", dependency.package],
|
|
360
|
+
signal,
|
|
350
361
|
sudo: true
|
|
351
362
|
},
|
|
352
363
|
`dnf install ${dependency.package}`
|
|
@@ -374,7 +385,8 @@ async function dependencies(sandbox, values) {
|
|
|
374
385
|
"--prefix",
|
|
375
386
|
`${SANDBOX_WORKSPACE_ROOT}/.junior`,
|
|
376
387
|
...npm
|
|
377
|
-
]
|
|
388
|
+
],
|
|
389
|
+
signal
|
|
378
390
|
},
|
|
379
391
|
"npm install"
|
|
380
392
|
);
|
|
@@ -382,7 +394,7 @@ async function dependencies(sandbox, values) {
|
|
|
382
394
|
);
|
|
383
395
|
}
|
|
384
396
|
}
|
|
385
|
-
async function postinstall(sandbox, commands) {
|
|
397
|
+
async function postinstall(sandbox, commands, signal) {
|
|
386
398
|
if (commands.length === 0) {
|
|
387
399
|
return;
|
|
388
400
|
}
|
|
@@ -394,11 +406,13 @@ async function postinstall(sandbox, commands) {
|
|
|
394
406
|
},
|
|
395
407
|
async () => {
|
|
396
408
|
for (const command of commands) {
|
|
409
|
+
signal?.throwIfAborted();
|
|
397
410
|
const result = await runNonInteractiveCommand(sandbox, {
|
|
398
411
|
cmd: command.cmd,
|
|
399
412
|
args: command.args,
|
|
400
413
|
login: true,
|
|
401
414
|
pathPrefix: `${SANDBOX_WORKSPACE_ROOT}/.junior/bin:$PATH`,
|
|
415
|
+
signal,
|
|
402
416
|
...command.sudo !== void 0 ? { sudo: command.sudo } : {}
|
|
403
417
|
});
|
|
404
418
|
if (result.exitCode !== 0) {
|
|
@@ -719,9 +733,9 @@ function createSandboxSession(sandbox, options) {
|
|
|
719
733
|
stderr
|
|
720
734
|
};
|
|
721
735
|
},
|
|
722
|
-
snapshot() {
|
|
736
|
+
snapshot(options2) {
|
|
723
737
|
return run(async () => {
|
|
724
|
-
const snapshot = await session.snapshot();
|
|
738
|
+
const snapshot = await session.snapshot(options2);
|
|
725
739
|
return { snapshotId: snapshot.snapshotId };
|
|
726
740
|
});
|
|
727
741
|
},
|
|
@@ -784,7 +798,7 @@ async function setCachedSnapshot(entry) {
|
|
|
784
798
|
SNAPSHOT_CACHE_TTL_MS
|
|
785
799
|
);
|
|
786
800
|
}
|
|
787
|
-
async function build(value, runtime, timeoutMs) {
|
|
801
|
+
async function build(value, runtime, timeoutMs, signal) {
|
|
788
802
|
return await trace(
|
|
789
803
|
"sandbox.snapshot.build",
|
|
790
804
|
"sandbox.snapshot.build",
|
|
@@ -799,13 +813,14 @@ async function build(value, runtime, timeoutMs) {
|
|
|
799
813
|
await Sandbox.create({
|
|
800
814
|
timeout: timeoutMs,
|
|
801
815
|
runtime,
|
|
816
|
+
signal,
|
|
802
817
|
...sandboxCredentials ?? {},
|
|
803
818
|
...resources ? { resources } : {}
|
|
804
819
|
})
|
|
805
820
|
);
|
|
806
821
|
try {
|
|
807
|
-
await dependencies(sandbox, value.dependencies);
|
|
808
|
-
await postinstall(sandbox, value.postinstall);
|
|
822
|
+
await dependencies(sandbox, value.dependencies, signal);
|
|
823
|
+
await postinstall(sandbox, value.postinstall, signal);
|
|
809
824
|
return await trace(
|
|
810
825
|
"sandbox.snapshot.capture",
|
|
811
826
|
"sandbox.snapshot.capture",
|
|
@@ -813,7 +828,7 @@ async function build(value, runtime, timeoutMs) {
|
|
|
813
828
|
"app.sandbox.snapshot.dependency_count": value.dependencyCount
|
|
814
829
|
},
|
|
815
830
|
async () => {
|
|
816
|
-
const snapshot = await sandbox.snapshot();
|
|
831
|
+
const snapshot = await sandbox.snapshot({ signal });
|
|
817
832
|
return snapshot.snapshotId;
|
|
818
833
|
}
|
|
819
834
|
);
|
|
@@ -826,7 +841,8 @@ async function build(value, runtime, timeoutMs) {
|
|
|
826
841
|
}
|
|
827
842
|
);
|
|
828
843
|
}
|
|
829
|
-
async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnapshot, onWaitingForLock) {
|
|
844
|
+
async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnapshot, onWaitingForLock, signal) {
|
|
845
|
+
signal?.throwIfAborted();
|
|
830
846
|
const state = getStateAdapter();
|
|
831
847
|
await state.connect();
|
|
832
848
|
const lockKey = profileLockKey(profileHash);
|
|
@@ -850,6 +866,7 @@ async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnaps
|
|
|
850
866
|
await onWaitingForLock?.();
|
|
851
867
|
const waitUntil = Date.now() + lockTtlMs + SNAPSHOT_WAIT_FOR_LOCK_BUFFER_MS;
|
|
852
868
|
while (Date.now() < waitUntil) {
|
|
869
|
+
signal?.throwIfAborted();
|
|
853
870
|
const cached2 = await getCachedSnapshot(profileHash);
|
|
854
871
|
if (cached2?.snapshotId && canUseCachedSnapshot(cached2)) {
|
|
855
872
|
return {
|
|
@@ -869,8 +886,9 @@ async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnaps
|
|
|
869
886
|
await state.releaseLock(lock);
|
|
870
887
|
}
|
|
871
888
|
}
|
|
872
|
-
await sleep(500);
|
|
889
|
+
await sleep(500, signal);
|
|
873
890
|
}
|
|
891
|
+
signal?.throwIfAborted();
|
|
874
892
|
const cached = await getCachedSnapshot(profileHash);
|
|
875
893
|
if (cached?.snapshotId && canUseCachedSnapshot(cached)) {
|
|
876
894
|
return {
|
|
@@ -909,6 +927,7 @@ async function resolve(params) {
|
|
|
909
927
|
"app.sandbox.snapshot.force_rebuild": Boolean(params.forceRebuild)
|
|
910
928
|
},
|
|
911
929
|
async () => {
|
|
930
|
+
params.signal?.throwIfAborted();
|
|
912
931
|
await params.onProgress?.("resolve_start");
|
|
913
932
|
const currentProfile = create(params.runtime);
|
|
914
933
|
if (!currentProfile) {
|
|
@@ -963,7 +982,8 @@ async function resolve(params) {
|
|
|
963
982
|
const nextSnapshotId = await build(
|
|
964
983
|
currentProfile,
|
|
965
984
|
params.runtime,
|
|
966
|
-
params.timeoutMs
|
|
985
|
+
params.timeoutMs,
|
|
986
|
+
params.signal
|
|
967
987
|
);
|
|
968
988
|
await setCachedSnapshot({
|
|
969
989
|
profileHash: currentProfile.hash,
|
|
@@ -978,7 +998,8 @@ async function resolve(params) {
|
|
|
978
998
|
canUseCachedSnapshot,
|
|
979
999
|
async () => {
|
|
980
1000
|
await params.onProgress?.("waiting_for_lock");
|
|
981
|
-
}
|
|
1001
|
+
},
|
|
1002
|
+
params.signal
|
|
982
1003
|
);
|
|
983
1004
|
return {
|
|
984
1005
|
snapshotId: lockResult.snapshotId,
|
|
@@ -22,28 +22,28 @@ import {
|
|
|
22
22
|
persistThreadStateById,
|
|
23
23
|
stripRuntimeTurnContext,
|
|
24
24
|
updateConversationStats
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-Z2XXPUZG.js";
|
|
26
26
|
import {
|
|
27
27
|
createPluginEmbedder,
|
|
28
28
|
createPluginLogger,
|
|
29
29
|
createPluginModel,
|
|
30
30
|
createPluginState,
|
|
31
31
|
getPlugins
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-7HYV7KFM.js";
|
|
33
33
|
import {
|
|
34
34
|
getDb
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-254MFDOF.js";
|
|
36
36
|
import {
|
|
37
37
|
getStateAdapter
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-UURFXX66.js";
|
|
39
39
|
import {
|
|
40
40
|
ProviderError,
|
|
41
41
|
getProviderErrorAttributes,
|
|
42
42
|
getProviderErrorUserMessage
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-IDXLBKPS.js";
|
|
44
44
|
import {
|
|
45
45
|
buildTurnFailureResponse
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-JZ47AFSH.js";
|
|
47
47
|
import {
|
|
48
48
|
parseSlackMessageTs
|
|
49
49
|
} from "./chunk-F3B2YJ76.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
persistAuthPauseTurnState,
|
|
14
14
|
requireTurnFailureEventId,
|
|
15
15
|
scheduleSessionCompletedPluginTasks
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JYDIBXFY.js";
|
|
17
17
|
import {
|
|
18
18
|
buildSentryConversationUrl
|
|
19
19
|
} from "./chunk-4CODA7P5.js";
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
resolveBaseUrl,
|
|
41
41
|
resolvePluginOAuthAccount,
|
|
42
42
|
truncateStatusText
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-3DBMANUI.js";
|
|
44
44
|
import {
|
|
45
45
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
46
46
|
TurnSliceLimitExceededError,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
recordDeliveredAssistantMessage,
|
|
71
71
|
turnHasReply,
|
|
72
72
|
updateConversationStats
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-Z2XXPUZG.js";
|
|
74
74
|
import {
|
|
75
75
|
SlackActionError,
|
|
76
76
|
getDashboardConversationLink,
|
|
@@ -79,19 +79,19 @@ import {
|
|
|
79
79
|
getSlackClient,
|
|
80
80
|
isDmChannel,
|
|
81
81
|
normalizeSlackConversationId
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-7HYV7KFM.js";
|
|
83
83
|
import {
|
|
84
84
|
getConversationEventStore,
|
|
85
85
|
getConversationStore,
|
|
86
86
|
parseDestination,
|
|
87
87
|
requireSlackDestination,
|
|
88
88
|
sameDestination
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-254MFDOF.js";
|
|
90
90
|
import {
|
|
91
91
|
acquireActiveLock,
|
|
92
92
|
getDefaultRedisStateAdapterFor,
|
|
93
93
|
getStateAdapter
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-UURFXX66.js";
|
|
95
95
|
import {
|
|
96
96
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
97
97
|
botConfig,
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
getRuntimeMetadata,
|
|
101
101
|
normalizeSlackEmojiName,
|
|
102
102
|
standardModelId
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-IDXLBKPS.js";
|
|
104
104
|
import {
|
|
105
105
|
parseSlackThreadId,
|
|
106
106
|
readSlackRawMessageContext,
|
|
@@ -109,15 +109,15 @@ import {
|
|
|
109
109
|
} from "./chunk-HDFGNU5E.js";
|
|
110
110
|
import {
|
|
111
111
|
discoverSkills
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-TRECK7RV.js";
|
|
113
113
|
import {
|
|
114
114
|
pluginCatalogRuntime
|
|
115
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-WUP7NWMP.js";
|
|
116
116
|
import {
|
|
117
117
|
buildOAuthTokenRequest,
|
|
118
118
|
hasRequiredOAuthScope,
|
|
119
119
|
parseOAuthTokenResponse
|
|
120
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-ET2SDCNV.js";
|
|
121
121
|
import {
|
|
122
122
|
createSlackResumeActor,
|
|
123
123
|
isUserActor,
|
|
@@ -128,7 +128,7 @@ import {
|
|
|
128
128
|
logException,
|
|
129
129
|
logInfo,
|
|
130
130
|
logWarn
|
|
131
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-JZ47AFSH.js";
|
|
132
132
|
import {
|
|
133
133
|
isRecord,
|
|
134
134
|
toOptionalNumber,
|
|
@@ -139,7 +139,7 @@ import {
|
|
|
139
139
|
} from "./chunk-F3B2YJ76.js";
|
|
140
140
|
import {
|
|
141
141
|
homeDir
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-H4HBKISO.js";
|
|
143
143
|
|
|
144
144
|
// src/chat/slack/assistant-thread/status-render.ts
|
|
145
145
|
var DEFAULT_STATUS_CONTEXTS = {
|
|
@@ -1,149 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverNodeModulesDirs,
|
|
3
3
|
isDirectory,
|
|
4
|
-
isFile
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { statSync } from "fs";
|
|
9
|
-
import { createRequire } from "module";
|
|
10
|
-
import path from "path";
|
|
11
|
-
function isDirectory2(targetPath) {
|
|
12
|
-
try {
|
|
13
|
-
return statSync(targetPath).isDirectory();
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function isFile2(targetPath) {
|
|
19
|
-
try {
|
|
20
|
-
return statSync(targetPath).isFile();
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function uniqueResolvedPathsInOrder(values) {
|
|
26
|
-
const seen = /* @__PURE__ */ new Set();
|
|
27
|
-
const resolved = [];
|
|
28
|
-
for (const value of values) {
|
|
29
|
-
const normalized = path.resolve(value);
|
|
30
|
-
if (seen.has(normalized)) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
seen.add(normalized);
|
|
34
|
-
resolved.push(normalized);
|
|
35
|
-
}
|
|
36
|
-
return resolved;
|
|
37
|
-
}
|
|
38
|
-
function ancestorNodeModulesDirs(cwd) {
|
|
39
|
-
const dirs = [];
|
|
40
|
-
let current = path.resolve(cwd);
|
|
41
|
-
while (true) {
|
|
42
|
-
const nodeModulesDir = path.join(current, "node_modules");
|
|
43
|
-
if (isDirectory2(nodeModulesDir)) {
|
|
44
|
-
dirs.push(nodeModulesDir);
|
|
45
|
-
}
|
|
46
|
-
const parent = path.dirname(current);
|
|
47
|
-
if (parent === current) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
current = parent;
|
|
51
|
-
}
|
|
52
|
-
return dirs;
|
|
53
|
-
}
|
|
54
|
-
function packageDirInNodeModules(nodeModulesDir, packageName) {
|
|
55
|
-
const packageDir = path.join(nodeModulesDir, ...packageName.split("/"));
|
|
56
|
-
return isDirectory2(packageDir) ? path.resolve(packageDir) : void 0;
|
|
57
|
-
}
|
|
58
|
-
function isValidPackageSegment(segment) {
|
|
59
|
-
return Boolean(segment) && segment !== "." && segment !== ".." && !segment.startsWith(".") && /^[A-Za-z0-9._~-]+$/.test(segment);
|
|
60
|
-
}
|
|
61
|
-
function isValidPackageName(packageName) {
|
|
62
|
-
if (!packageName || packageName.includes("\\") || path.isAbsolute(packageName)) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const parts = packageName.split("/");
|
|
66
|
-
if (parts[0].startsWith("@")) {
|
|
67
|
-
return parts.length === 2 && parts[0].length > 1 && isValidPackageSegment(parts[0].slice(1)) && isValidPackageSegment(parts[1]);
|
|
68
|
-
}
|
|
69
|
-
return parts.length === 1 && isValidPackageSegment(parts[0]);
|
|
70
|
-
}
|
|
71
|
-
function findPackageRoot(entryPath) {
|
|
72
|
-
let dir = path.dirname(entryPath);
|
|
73
|
-
while (dir !== path.dirname(dir)) {
|
|
74
|
-
if (isFile2(path.join(dir, "package.json"))) {
|
|
75
|
-
return path.resolve(dir);
|
|
76
|
-
}
|
|
77
|
-
dir = path.dirname(dir);
|
|
78
|
-
}
|
|
79
|
-
return void 0;
|
|
80
|
-
}
|
|
81
|
-
function findPackageNodeModulesDir(packageDir, packageName) {
|
|
82
|
-
const parts = path.resolve(packageDir).split(path.sep);
|
|
83
|
-
const packageParts = packageName.split("/");
|
|
84
|
-
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
85
|
-
if (parts[index] !== "node_modules") {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const candidatePackageParts = parts.slice(
|
|
89
|
-
index + 1,
|
|
90
|
-
index + 1 + packageParts.length
|
|
91
|
-
);
|
|
92
|
-
if (candidatePackageParts.join("/") !== packageParts.join("/")) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
return path.resolve(parts.slice(0, index + 1).join(path.sep) || path.sep);
|
|
96
|
-
}
|
|
97
|
-
return void 0;
|
|
98
|
-
}
|
|
99
|
-
function resolvePackageWithNode(cwd, packageName) {
|
|
100
|
-
let requireFromCwd;
|
|
101
|
-
try {
|
|
102
|
-
requireFromCwd = createRequire(path.join(cwd, "package.json"));
|
|
103
|
-
} catch {
|
|
104
|
-
return void 0;
|
|
105
|
-
}
|
|
106
|
-
for (const specifier of [`${packageName}/package.json`, packageName]) {
|
|
107
|
-
try {
|
|
108
|
-
const resolved = requireFromCwd.resolve(specifier);
|
|
109
|
-
const dir = specifier.endsWith("/package.json") ? path.dirname(resolved) : findPackageRoot(resolved);
|
|
110
|
-
if (!dir) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
|
|
114
|
-
return {
|
|
115
|
-
dir,
|
|
116
|
-
...nodeModulesDir ? { nodeModulesDir } : {}
|
|
117
|
-
};
|
|
118
|
-
} catch {
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return void 0;
|
|
122
|
-
}
|
|
123
|
-
function resolvePackageLocation(cwd, packageName, options) {
|
|
124
|
-
if (!isValidPackageName(packageName)) {
|
|
125
|
-
return void 0;
|
|
126
|
-
}
|
|
127
|
-
const nodeModulesDirs = uniqueResolvedPathsInOrder([
|
|
128
|
-
...options?.nodeModulesDirs ?? [],
|
|
129
|
-
...ancestorNodeModulesDirs(cwd)
|
|
130
|
-
]);
|
|
131
|
-
for (const nodeModulesDir of nodeModulesDirs) {
|
|
132
|
-
const dir = packageDirInNodeModules(nodeModulesDir, packageName);
|
|
133
|
-
if (dir) {
|
|
134
|
-
return { dir, nodeModulesDir };
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return resolvePackageWithNode(cwd, packageName);
|
|
138
|
-
}
|
|
139
|
-
function resolvePackageDir(cwd, packageName) {
|
|
140
|
-
return resolvePackageLocation(cwd, packageName)?.dir;
|
|
141
|
-
}
|
|
4
|
+
isFile,
|
|
5
|
+
isValidPackageName,
|
|
6
|
+
resolvePackageLocation
|
|
7
|
+
} from "./chunk-H4HBKISO.js";
|
|
142
8
|
|
|
143
9
|
// src/chat/plugins/package-discovery.ts
|
|
144
|
-
import
|
|
10
|
+
import path from "path";
|
|
145
11
|
function normalizeForGlob(targetPath) {
|
|
146
|
-
return targetPath.split(
|
|
12
|
+
return targetPath.split(path.sep).join("/");
|
|
147
13
|
}
|
|
148
14
|
function uniqueStringsInOrder(values) {
|
|
149
15
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -158,8 +24,8 @@ function uniqueStringsInOrder(values) {
|
|
|
158
24
|
return resolved;
|
|
159
25
|
}
|
|
160
26
|
function pathForTracingInclude(cwd, targetPath) {
|
|
161
|
-
const relative =
|
|
162
|
-
if (!relative ||
|
|
27
|
+
const relative = path.relative(cwd, targetPath);
|
|
28
|
+
if (!relative || path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`)) {
|
|
163
29
|
return null;
|
|
164
30
|
}
|
|
165
31
|
const normalized = normalizeForGlob(relative);
|
|
@@ -196,10 +62,10 @@ function resolvePackageDirFromName(cwd, packageName, candidateNodeModulesDirs) {
|
|
|
196
62
|
}) ?? null;
|
|
197
63
|
}
|
|
198
64
|
function readPluginPackageFlags(dir) {
|
|
199
|
-
const hasRootPluginManifest = isFile(
|
|
200
|
-
const hasMigrationsDir = isDirectory(
|
|
201
|
-
const hasPluginsDir = isDirectory(
|
|
202
|
-
const hasSkillsDir = isDirectory(
|
|
65
|
+
const hasRootPluginManifest = isFile(path.join(dir, "plugin.yaml"));
|
|
66
|
+
const hasMigrationsDir = isDirectory(path.join(dir, "migrations"));
|
|
67
|
+
const hasPluginsDir = isDirectory(path.join(dir, "plugins"));
|
|
68
|
+
const hasSkillsDir = isDirectory(path.join(dir, "skills"));
|
|
203
69
|
if (!hasRootPluginManifest && !hasMigrationsDir && !hasPluginsDir && !hasSkillsDir) {
|
|
204
70
|
return null;
|
|
205
71
|
}
|
|
@@ -244,7 +110,7 @@ function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs, cwd) {
|
|
|
244
110
|
return discovered;
|
|
245
111
|
}
|
|
246
112
|
function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
247
|
-
const resolvedCwd =
|
|
113
|
+
const resolvedCwd = path.resolve(cwd);
|
|
248
114
|
const packageNames = normalizePluginPackageNames(options?.packageNames);
|
|
249
115
|
const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
|
|
250
116
|
const discoveredPackages = discoverDeclaredPackages(
|
|
@@ -258,7 +124,7 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
258
124
|
for (const pkg of discoveredPackages) {
|
|
259
125
|
const tracingBasePath = pkg.nodeModulesDir ? pathForTracingInclude(
|
|
260
126
|
resolvedCwd,
|
|
261
|
-
|
|
127
|
+
path.join(pkg.nodeModulesDir, ...pkg.packageName.split("/"))
|
|
262
128
|
) : pathForTracingInclude(resolvedCwd, pkg.dir);
|
|
263
129
|
if (pkg.hasRootPluginManifest) {
|
|
264
130
|
manifestRoots.push(pkg.dir);
|
|
@@ -272,13 +138,13 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
272
138
|
}
|
|
273
139
|
}
|
|
274
140
|
if (pkg.hasPluginsDir) {
|
|
275
|
-
manifestRoots.push(
|
|
141
|
+
manifestRoots.push(path.join(pkg.dir, "plugins"));
|
|
276
142
|
if (tracingBasePath) {
|
|
277
143
|
tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
|
|
278
144
|
}
|
|
279
145
|
}
|
|
280
146
|
if (pkg.hasSkillsDir) {
|
|
281
|
-
skillRoots.push(
|
|
147
|
+
skillRoots.push(path.join(pkg.dir, "skills"));
|
|
282
148
|
if (tracingBasePath) {
|
|
283
149
|
tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
|
|
284
150
|
}
|
|
@@ -301,8 +167,6 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
301
167
|
}
|
|
302
168
|
|
|
303
169
|
export {
|
|
304
|
-
isValidPackageName,
|
|
305
|
-
resolvePackageDir,
|
|
306
170
|
normalizePluginPackageNames,
|
|
307
171
|
discoverInstalledPluginPackageContent
|
|
308
172
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pluginCatalogRuntime
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WUP7NWMP.js";
|
|
4
4
|
import {
|
|
5
5
|
logWarn
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JZ47AFSH.js";
|
|
7
7
|
import {
|
|
8
8
|
skillRoots
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H4HBKISO.js";
|
|
10
10
|
|
|
11
11
|
// src/chat/skills.ts
|
|
12
12
|
import fs from "fs/promises";
|