@ycodium-ai/plugin-session-import 0.2.3122 → 0.2.3158
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/README.md +10 -2
- package/dist/index.js +21 -16
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -25,8 +25,16 @@ A Ycodium server. The plugin asks to:
|
|
|
25
25
|
|
|
26
26
|
- read every provider instance's home, transcript, and config directories
|
|
27
27
|
- spawn Codex binaries the host names
|
|
28
|
-
-
|
|
29
|
-
|
|
28
|
+
- import and append history through `ctx.threads.import` and
|
|
29
|
+
`ctx.threads.externalMessages.append`, declaring `thread.import` and
|
|
30
|
+
`thread.external-messages.append` in `commands.dispatch`
|
|
31
|
+
- declare `thread.session.stop` and `threads.user` to stop idle project sessions on this machine after syncing external history
|
|
32
|
+
|
|
33
|
+
Sync requests a stop through `ctx.threads.session.stop` with `onlyIfNoTurnInFlight: true` and a fresh request id each time.
|
|
34
|
+
The command checks for in-flight work when it decides the stop. Sync returns after acceptance and does not wait for the process to exit.
|
|
35
|
+
|
|
36
|
+
权限说明:插件读取 provider 目录、运行宿主指定的 Codex 程序、导入和追加历史;`threads.user` 允许它在同步外部历史后停止这台机器上的项目会话。
|
|
37
|
+
停止命令一律只在没有在途轮次时生效,每次同步使用新请求号;同步返回表示停止请求已受理,进程退出由宿主异步完成。
|
|
30
38
|
|
|
31
39
|
## Install
|
|
32
40
|
|
package/dist/index.js
CHANGED
|
@@ -2463,21 +2463,24 @@ async function runImportOnce(ctx, input, emit) {
|
|
|
2463
2463
|
if (existing === null && batches.length === 0) batches.push({ messages: [], activities: [] });
|
|
2464
2464
|
try {
|
|
2465
2465
|
for (const batch of batches) {
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2466
|
+
const historyInput = {
|
|
2467
|
+
requestId: historyCommandId(input.threadId, batch),
|
|
2468
|
+
threadId: input.threadId,
|
|
2469
|
+
...batch
|
|
2470
|
+
};
|
|
2471
|
+
if (threadCreated) {
|
|
2472
|
+
await ctx.threads.externalMessages.append(historyInput);
|
|
2473
|
+
} else {
|
|
2474
|
+
await ctx.threads.import({
|
|
2475
|
+
...historyInput,
|
|
2469
2476
|
projectId: input.projectId,
|
|
2470
2477
|
title: resolveImportedTitle(transcript),
|
|
2471
2478
|
modelSelection,
|
|
2472
2479
|
runtimeMode: "full-access",
|
|
2473
2480
|
branch: null,
|
|
2474
2481
|
worktreePath: null
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
|
-
threadId: input.threadId,
|
|
2478
|
-
...batch,
|
|
2479
|
-
createdAt: now
|
|
2480
|
-
});
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2481
2484
|
threadCreated = true;
|
|
2482
2485
|
}
|
|
2483
2486
|
} catch (error) {
|
|
@@ -2630,12 +2633,10 @@ var NativeSessionTail = class {
|
|
|
2630
2633
|
}
|
|
2631
2634
|
try {
|
|
2632
2635
|
for (const batch of batches) {
|
|
2633
|
-
await this.ctx.
|
|
2634
|
-
|
|
2635
|
-
commandId: historyCommandId(threadId, batch),
|
|
2636
|
+
await this.ctx.threads.externalMessages.append({
|
|
2637
|
+
requestId: historyCommandId(threadId, batch),
|
|
2636
2638
|
threadId,
|
|
2637
|
-
...batch
|
|
2638
|
-
createdAt: appendedAt
|
|
2639
|
+
...batch
|
|
2639
2640
|
});
|
|
2640
2641
|
}
|
|
2641
2642
|
} catch (error) {
|
|
@@ -2657,7 +2658,11 @@ var NativeSessionTail = class {
|
|
|
2657
2658
|
const current = await threadOrNull2(this.ctx.threads, threadId);
|
|
2658
2659
|
if (current?.session == null || current.session.status === "stopped" || current.session.activeTurnId !== null || current.session.status === "running" || current.session.status === "starting")
|
|
2659
2660
|
return { status: "synced", appended: history.appendedMessageCount };
|
|
2660
|
-
await this.ctx.
|
|
2661
|
+
await this.ctx.threads.session.stop({
|
|
2662
|
+
threadId,
|
|
2663
|
+
requestId: NodeCrypto4.randomUUID(),
|
|
2664
|
+
onlyIfNoTurnInFlight: true
|
|
2665
|
+
}).catch((error) => {
|
|
2661
2666
|
this.ctx.log.warn("session-import sync could not stop the session", {
|
|
2662
2667
|
threadId,
|
|
2663
2668
|
detail: describeError(error)
|
|
@@ -2670,7 +2675,7 @@ var NativeSessionTail = class {
|
|
|
2670
2675
|
// src/index.ts
|
|
2671
2676
|
var index_default = definePlugin({
|
|
2672
2677
|
id: "session-import",
|
|
2673
|
-
apiVersion:
|
|
2678
|
+
apiVersion: 15,
|
|
2674
2679
|
activate: (ctx) => {
|
|
2675
2680
|
ctx.command({
|
|
2676
2681
|
name: "scan",
|
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.3158",
|
|
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.3158",
|
|
24
24
|
"ycodium-jsonl-stream": "0.0.0"
|
|
25
25
|
},
|
|
26
26
|
"ycodium": {
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"description": "Brings a session you started in a terminal into Ycodium.",
|
|
30
30
|
"icon": "blocks",
|
|
31
31
|
"permissions": [
|
|
32
|
+
{
|
|
33
|
+
"kind": "threads.user"
|
|
34
|
+
},
|
|
32
35
|
{
|
|
33
36
|
"kind": "providers.homes"
|
|
34
37
|
},
|
|
@@ -42,7 +45,8 @@
|
|
|
42
45
|
"kind": "commands.dispatch",
|
|
43
46
|
"commands": [
|
|
44
47
|
"thread.import",
|
|
45
|
-
"thread.external-messages.append"
|
|
48
|
+
"thread.external-messages.append",
|
|
49
|
+
"thread.session.stop"
|
|
46
50
|
]
|
|
47
51
|
}
|
|
48
52
|
]
|