@ycodium-ai/plugin-session-import 0.2.2106 → 0.2.2143
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/index.js +69 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -509,10 +509,18 @@ async function openCodexAppServer(input) {
|
|
|
509
509
|
const settled = new Promise((resolve, reject) => {
|
|
510
510
|
pending.set(id, { resolve, reject, method });
|
|
511
511
|
});
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
try {
|
|
513
|
+
await Promise.race([
|
|
514
|
+
handle.writeStdin(
|
|
515
|
+
`${JSON.stringify({ id, method, ...params === void 0 ? {} : { params } })}
|
|
514
516
|
`
|
|
515
|
-
|
|
517
|
+
),
|
|
518
|
+
settled
|
|
519
|
+
]);
|
|
520
|
+
} catch (error) {
|
|
521
|
+
pending.delete(id);
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
516
524
|
let timer;
|
|
517
525
|
try {
|
|
518
526
|
return await Promise.race([
|
|
@@ -553,7 +561,7 @@ async function openCodexAppServer(input) {
|
|
|
553
561
|
await close();
|
|
554
562
|
throw error;
|
|
555
563
|
}
|
|
556
|
-
return { request, notify, close };
|
|
564
|
+
return { request, notify, close, pendingCountForTests: () => pending.size };
|
|
557
565
|
}
|
|
558
566
|
|
|
559
567
|
// src/codexSessionScan.ts
|
|
@@ -1419,6 +1427,19 @@ async function withCodex(ctx, instance, use) {
|
|
|
1419
1427
|
await client.close();
|
|
1420
1428
|
}
|
|
1421
1429
|
}
|
|
1430
|
+
async function nativeSessionsOf(ctx, instanceId) {
|
|
1431
|
+
const resolve = ctx.providers.nativeSessions;
|
|
1432
|
+
if (typeof resolve !== "function") return null;
|
|
1433
|
+
try {
|
|
1434
|
+
return await resolve(instanceId);
|
|
1435
|
+
} catch (error) {
|
|
1436
|
+
ctx.log.warn("session-import could not reach the executor's own session scan", {
|
|
1437
|
+
instanceId,
|
|
1438
|
+
detail: describeError(error)
|
|
1439
|
+
});
|
|
1440
|
+
return null;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1422
1443
|
async function listSessions(ctx, input) {
|
|
1423
1444
|
const project = await ctx.projections.getProject(input.projectId);
|
|
1424
1445
|
if (project === null) {
|
|
@@ -1432,6 +1453,50 @@ async function listSessions(ctx, input) {
|
|
|
1432
1453
|
const scannedKeys = /* @__PURE__ */ new Set();
|
|
1433
1454
|
for (const instance of instances) {
|
|
1434
1455
|
if (!instance.enabled) continue;
|
|
1456
|
+
const provider = providerKindOfDriver(instance.driver);
|
|
1457
|
+
if (provider === void 0) continue;
|
|
1458
|
+
const hand = await nativeSessionsOf(ctx, instance.instanceId);
|
|
1459
|
+
if (hand !== null) {
|
|
1460
|
+
const scanKey2 = `hand:${instance.driver}:${instance.homePath ?? instance.instanceId}`;
|
|
1461
|
+
if (scannedKeys.has(scanKey2)) continue;
|
|
1462
|
+
scannedKeys.add(scanKey2);
|
|
1463
|
+
try {
|
|
1464
|
+
const scanned = await hand.scan({ projectId: input.projectId, directory });
|
|
1465
|
+
sources.push({
|
|
1466
|
+
instanceId: instance.instanceId,
|
|
1467
|
+
provider,
|
|
1468
|
+
candidates: scanned.candidates.map(
|
|
1469
|
+
(row) => candidateOf({
|
|
1470
|
+
provider,
|
|
1471
|
+
instanceId: instance.instanceId,
|
|
1472
|
+
nativeSessionId: row.nativeSessionId,
|
|
1473
|
+
cwd: row.cwd,
|
|
1474
|
+
title: row.title,
|
|
1475
|
+
preview: row.preview,
|
|
1476
|
+
model: row.model,
|
|
1477
|
+
turnCount: row.turnCount,
|
|
1478
|
+
updatedAt: row.updatedAt,
|
|
1479
|
+
openElsewhere: row.openElsewhere,
|
|
1480
|
+
// 「已经有 thread 绑着它」是宿主的账,手报不出来,一律盖上去。
|
|
1481
|
+
importedThreadId: imported.get(importedThreadKey(provider, row.nativeSessionId))
|
|
1482
|
+
})
|
|
1483
|
+
),
|
|
1484
|
+
unavailableReason: null
|
|
1485
|
+
});
|
|
1486
|
+
} catch (error) {
|
|
1487
|
+
ctx.log.warn("session-import could not read sessions from the executor", {
|
|
1488
|
+
instanceId: instance.instanceId,
|
|
1489
|
+
detail: describeError(error)
|
|
1490
|
+
});
|
|
1491
|
+
sources.push({
|
|
1492
|
+
instanceId: instance.instanceId,
|
|
1493
|
+
provider,
|
|
1494
|
+
candidates: [],
|
|
1495
|
+
unavailableReason: provider === "codex" ? "Codex sessions could not be read." : "Claude sessions could not be read."
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1435
1500
|
if (instance.driver === CODEX_DRIVER) {
|
|
1436
1501
|
const binaryPath = ctx.config.codexBinaries?.[instance.instanceId];
|
|
1437
1502
|
if (binaryPath === void 0) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/plugin-session-import",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2143",
|
|
4
4
|
"description": "Brings a session you started in a terminal into Ycodium.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"session-import",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"effect": "4.0.0-beta.103",
|
|
21
21
|
"esbuild": "0.28.1",
|
|
22
22
|
"vite-plus": "0.2.2",
|
|
23
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
23
|
+
"@ycodium-ai/plugin-api": "0.2.2143"
|
|
24
24
|
},
|
|
25
25
|
"ycodium": {
|
|
26
26
|
"plugin": "./dist/index.js",
|