@kevisual/cli 0.1.26 → 0.1.27
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/assistant-opencode.js +95 -38
- package/dist/assistant-server.js +95 -38
- package/dist/envision.js +2 -2
- package/package.json +1 -1
|
@@ -103461,6 +103461,47 @@ var getClient = async (opts) => {
|
|
|
103461
103461
|
};
|
|
103462
103462
|
|
|
103463
103463
|
// src/routes/opencode/cnb.ts
|
|
103464
|
+
app.route({
|
|
103465
|
+
path: "opencode-cnb",
|
|
103466
|
+
key: "models",
|
|
103467
|
+
middleware: ["auth-admin"],
|
|
103468
|
+
description: "获取 OpenCode 可用模型列表,返回 providerID 和 modelID",
|
|
103469
|
+
metadata: {
|
|
103470
|
+
args: {
|
|
103471
|
+
baseUrl: exports_external3.string().optional().describe("OpenCode 服务地址,默认为 http://localhost:4096")
|
|
103472
|
+
}
|
|
103473
|
+
}
|
|
103474
|
+
}).define(async (ctx) => {
|
|
103475
|
+
const { baseUrl } = ctx.query;
|
|
103476
|
+
const client3 = await getClient({ baseUrl });
|
|
103477
|
+
if (!client3) {
|
|
103478
|
+
ctx.body = { content: "获取 OpenCode 客户端失败" };
|
|
103479
|
+
return;
|
|
103480
|
+
}
|
|
103481
|
+
const res = await client3.provider.list();
|
|
103482
|
+
const providerData = res?.data ?? res;
|
|
103483
|
+
const all = providerData?.all ?? [];
|
|
103484
|
+
const connected = providerData?.connected ?? [];
|
|
103485
|
+
const defaultModels = providerData?.default ?? {};
|
|
103486
|
+
const models = [];
|
|
103487
|
+
for (const provider2 of all) {
|
|
103488
|
+
const isConnected = connected.includes(provider2.id);
|
|
103489
|
+
for (const [modelKey, model] of Object.entries(provider2.models ?? {})) {
|
|
103490
|
+
models.push({
|
|
103491
|
+
providerID: provider2.id,
|
|
103492
|
+
providerName: provider2.name,
|
|
103493
|
+
modelID: modelKey,
|
|
103494
|
+
modelName: model.name ?? modelKey,
|
|
103495
|
+
isDefault: defaultModels[provider2.id] === modelKey,
|
|
103496
|
+
isConnected
|
|
103497
|
+
});
|
|
103498
|
+
}
|
|
103499
|
+
}
|
|
103500
|
+
ctx.body = {
|
|
103501
|
+
content: `共 ${models.length} 个模型,已连接提供商: ${connected.join(", ") || "无"}`,
|
|
103502
|
+
data: { models, connected, default: defaultModels }
|
|
103503
|
+
};
|
|
103504
|
+
}).addTo(app);
|
|
103464
103505
|
app.route({
|
|
103465
103506
|
path: "opencode-cnb",
|
|
103466
103507
|
key: "question",
|
|
@@ -103471,13 +103512,16 @@ app.route({
|
|
|
103471
103512
|
question: exports_external3.string().describe("问题"),
|
|
103472
103513
|
baseUrl: exports_external3.string().optional().describe("OpenCode 服务地址,默认为 http://localhost:4096"),
|
|
103473
103514
|
directory: exports_external3.string().optional().describe("运行目录,默认为根目录"),
|
|
103474
|
-
|
|
103515
|
+
messageId: exports_external3.string().optional().describe("消息 ID,选填"),
|
|
103475
103516
|
sessionId: exports_external3.string().optional().describe("会话 ID,选填"),
|
|
103476
|
-
|
|
103517
|
+
providerId: exports_external3.string().optional().describe("指定使用的提供商 ID,默认为空,表示使用默认提供商"),
|
|
103518
|
+
modelId: exports_external3.string().optional().describe("指定使用的模型 ID,默认为空,表示使用默认模型"),
|
|
103519
|
+
parts: exports_external3.array(exports_external3.any()).optional().describe("消息内容的分块,优先于 question 参数"),
|
|
103520
|
+
awaitAnswer: exports_external3.boolean().optional().describe("是否等待回答完成,默认为 false,开启后会在回答完成后返回完整回答内容")
|
|
103477
103521
|
}
|
|
103478
103522
|
}
|
|
103479
103523
|
}).define(async (ctx) => {
|
|
103480
|
-
const { question, baseUrl, directory = "/workspace",
|
|
103524
|
+
const { question, baseUrl, directory = "/workspace", messageId, sessionId, parts, awaitAnswer = false, providerId, modelId } = ctx.query;
|
|
103481
103525
|
const client3 = await getClient({ baseUrl });
|
|
103482
103526
|
if (!client3) {
|
|
103483
103527
|
ctx.body = { content: `OpenCode 客户端获取失败` };
|
|
@@ -103503,17 +103547,30 @@ app.route({
|
|
|
103503
103547
|
session = createSession.data;
|
|
103504
103548
|
}
|
|
103505
103549
|
let _parts = parts ?? [{ type: "text", text: question }];
|
|
103506
|
-
|
|
103550
|
+
let data = null;
|
|
103551
|
+
let model = null;
|
|
103552
|
+
if (providerId && modelId) {
|
|
103553
|
+
model = { providerID: providerId, modelID: modelId };
|
|
103554
|
+
}
|
|
103555
|
+
const promptPromise = client3.session.prompt({
|
|
103507
103556
|
body: {
|
|
103508
|
-
messageID,
|
|
103509
|
-
parts: _parts
|
|
103557
|
+
messageID: messageId,
|
|
103558
|
+
parts: _parts,
|
|
103559
|
+
...model ? { model } : {}
|
|
103510
103560
|
},
|
|
103511
103561
|
path: {
|
|
103512
103562
|
id: sessionId || session.id
|
|
103513
103563
|
}
|
|
103514
103564
|
});
|
|
103515
|
-
|
|
103516
|
-
|
|
103565
|
+
if (awaitAnswer) {
|
|
103566
|
+
const message = await promptPromise;
|
|
103567
|
+
data = message.data;
|
|
103568
|
+
} else {
|
|
103569
|
+
promptPromise.then((res) => {
|
|
103570
|
+
console.log(`Prompt completed with response:`, res.data.info.id);
|
|
103571
|
+
}).catch(() => {});
|
|
103572
|
+
}
|
|
103573
|
+
ctx.body = { content: awaitAnswer ? `已经完成` : `运行中`, data, sessionId: session.id };
|
|
103517
103574
|
}).addTo(app);
|
|
103518
103575
|
|
|
103519
103576
|
// src/routes/opencode/session/index.ts
|
|
@@ -103601,20 +103658,20 @@ app.route({
|
|
|
103601
103658
|
title: "列出 Session 消息",
|
|
103602
103659
|
summary: "列出指定 OpenCode 会话的所有消息记录",
|
|
103603
103660
|
args: {
|
|
103604
|
-
|
|
103661
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
103605
103662
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
103606
103663
|
}
|
|
103607
103664
|
})
|
|
103608
103665
|
}
|
|
103609
103666
|
}).define(async (ctx) => {
|
|
103610
|
-
const {
|
|
103611
|
-
if (!
|
|
103667
|
+
const { sessionId, port } = ctx.query;
|
|
103668
|
+
if (!sessionId) {
|
|
103612
103669
|
ctx.throw(400, "Session ID 不能为空");
|
|
103613
103670
|
return;
|
|
103614
103671
|
}
|
|
103615
103672
|
const client3 = await opencodeManager.getClient({ port });
|
|
103616
|
-
const result = await client3.session.messages({ path: { id } });
|
|
103617
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
103673
|
+
const result = await client3.session.messages({ path: { id: sessionId } });
|
|
103674
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 共 ${result.data?.length ?? 0} 条消息` };
|
|
103618
103675
|
}).addTo(app);
|
|
103619
103676
|
app.route({
|
|
103620
103677
|
path: "opencode-session",
|
|
@@ -103651,21 +103708,21 @@ app.route({
|
|
|
103651
103708
|
title: "更新 Session",
|
|
103652
103709
|
summary: "更新指定 OpenCode 会话的属性,如标题",
|
|
103653
103710
|
args: {
|
|
103654
|
-
|
|
103711
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
103655
103712
|
title: tool.schema.string().optional().describe("新的会话标题"),
|
|
103656
103713
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
103657
103714
|
}
|
|
103658
103715
|
})
|
|
103659
103716
|
}
|
|
103660
103717
|
}).define(async (ctx) => {
|
|
103661
|
-
const {
|
|
103662
|
-
if (!
|
|
103718
|
+
const { sessionId, title, port } = ctx.query;
|
|
103719
|
+
if (!sessionId) {
|
|
103663
103720
|
ctx.throw(400, "Session ID 不能为空");
|
|
103664
103721
|
return;
|
|
103665
103722
|
}
|
|
103666
103723
|
const client3 = await opencodeManager.getClient({ port });
|
|
103667
|
-
const result = await client3.session.update({ path: { id }, body: { title } });
|
|
103668
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
103724
|
+
const result = await client3.session.update({ path: { id: sessionId }, body: { title } });
|
|
103725
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 已更新` };
|
|
103669
103726
|
}).addTo(app);
|
|
103670
103727
|
app.route({
|
|
103671
103728
|
path: "opencode-session",
|
|
@@ -103679,20 +103736,20 @@ app.route({
|
|
|
103679
103736
|
title: "删除 Session",
|
|
103680
103737
|
summary: "根据 ID 删除指定的 OpenCode 会话及其所有数据",
|
|
103681
103738
|
args: {
|
|
103682
|
-
|
|
103739
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
103683
103740
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
103684
103741
|
}
|
|
103685
103742
|
})
|
|
103686
103743
|
}
|
|
103687
103744
|
}).define(async (ctx) => {
|
|
103688
|
-
const {
|
|
103689
|
-
if (!
|
|
103745
|
+
const { sessionId, port } = ctx.query;
|
|
103746
|
+
if (!sessionId) {
|
|
103690
103747
|
ctx.throw(400, "Session ID 不能为空");
|
|
103691
103748
|
return;
|
|
103692
103749
|
}
|
|
103693
103750
|
const client3 = await opencodeManager.getClient({ port });
|
|
103694
|
-
await client3.session.delete({ path: { id } });
|
|
103695
|
-
ctx.body = { content: `Session ${
|
|
103751
|
+
await client3.session.delete({ path: { id: sessionId } });
|
|
103752
|
+
ctx.body = { content: `Session ${sessionId} 已删除` };
|
|
103696
103753
|
}).addTo(app);
|
|
103697
103754
|
app.route({
|
|
103698
103755
|
path: "opencode-session",
|
|
@@ -103706,20 +103763,20 @@ app.route({
|
|
|
103706
103763
|
title: "中止 Session",
|
|
103707
103764
|
summary: "中止正在运行的 OpenCode 会话",
|
|
103708
103765
|
args: {
|
|
103709
|
-
|
|
103766
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
103710
103767
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
103711
103768
|
}
|
|
103712
103769
|
})
|
|
103713
103770
|
}
|
|
103714
103771
|
}).define(async (ctx) => {
|
|
103715
|
-
const {
|
|
103716
|
-
if (!
|
|
103772
|
+
const { sessionId, port } = ctx.query;
|
|
103773
|
+
if (!sessionId) {
|
|
103717
103774
|
ctx.throw(400, "Session ID 不能为空");
|
|
103718
103775
|
return;
|
|
103719
103776
|
}
|
|
103720
103777
|
const client3 = await opencodeManager.getClient({ port });
|
|
103721
|
-
await client3.session.abort({ path: { id } });
|
|
103722
|
-
ctx.body = { content: `Session ${
|
|
103778
|
+
await client3.session.abort({ path: { id: sessionId } });
|
|
103779
|
+
ctx.body = { content: `Session ${sessionId} 已中止` };
|
|
103723
103780
|
}).addTo(app);
|
|
103724
103781
|
app.route({
|
|
103725
103782
|
path: "opencode-session",
|
|
@@ -103733,21 +103790,21 @@ app.route({
|
|
|
103733
103790
|
title: "Fork Session",
|
|
103734
103791
|
summary: "从指定消息处 Fork 一个 OpenCode 会话",
|
|
103735
103792
|
args: {
|
|
103736
|
-
|
|
103793
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
103737
103794
|
messageId: tool.schema.string().describe("从该消息处开始 Fork"),
|
|
103738
103795
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
103739
103796
|
}
|
|
103740
103797
|
})
|
|
103741
103798
|
}
|
|
103742
103799
|
}).define(async (ctx) => {
|
|
103743
|
-
const {
|
|
103744
|
-
if (!
|
|
103800
|
+
const { sessionId, messageId, port } = ctx.query;
|
|
103801
|
+
if (!sessionId || !messageId) {
|
|
103745
103802
|
ctx.throw(400, "Session ID 和 messageId 不能为空");
|
|
103746
103803
|
return;
|
|
103747
103804
|
}
|
|
103748
103805
|
const client3 = await opencodeManager.getClient({ port });
|
|
103749
|
-
const result = await client3.session.fork({ path: { id }, body: { messageID: messageId } });
|
|
103750
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
103806
|
+
const result = await client3.session.fork({ path: { id: sessionId }, body: { messageID: messageId } });
|
|
103807
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 已从消息 ${messageId} Fork` };
|
|
103751
103808
|
}).addTo(app);
|
|
103752
103809
|
app.route({
|
|
103753
103810
|
path: "opencode-session",
|
|
@@ -103761,20 +103818,20 @@ app.route({
|
|
|
103761
103818
|
title: "总结 Session",
|
|
103762
103819
|
summary: "对指定的 OpenCode 会话进行内容总结",
|
|
103763
103820
|
args: {
|
|
103764
|
-
|
|
103821
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
103765
103822
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
103766
103823
|
}
|
|
103767
103824
|
})
|
|
103768
103825
|
}
|
|
103769
103826
|
}).define(async (ctx) => {
|
|
103770
|
-
const {
|
|
103771
|
-
if (!
|
|
103827
|
+
const { sessionId, port } = ctx.query;
|
|
103828
|
+
if (!sessionId) {
|
|
103772
103829
|
ctx.throw(400, "Session ID 不能为空");
|
|
103773
103830
|
return;
|
|
103774
103831
|
}
|
|
103775
103832
|
const client3 = await opencodeManager.getClient({ port });
|
|
103776
|
-
const result = await client3.session.summarize({ path: { id } });
|
|
103777
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
103833
|
+
const result = await client3.session.summarize({ path: { id: sessionId } });
|
|
103834
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 总结完成` };
|
|
103778
103835
|
}).addTo(app);
|
|
103779
103836
|
|
|
103780
103837
|
// src/routes/remote/index.ts
|
package/dist/assistant-server.js
CHANGED
|
@@ -127744,6 +127744,47 @@ var getClient = async (opts) => {
|
|
|
127744
127744
|
};
|
|
127745
127745
|
|
|
127746
127746
|
// src/routes/opencode/cnb.ts
|
|
127747
|
+
app.route({
|
|
127748
|
+
path: "opencode-cnb",
|
|
127749
|
+
key: "models",
|
|
127750
|
+
middleware: ["auth-admin"],
|
|
127751
|
+
description: "获取 OpenCode 可用模型列表,返回 providerID 和 modelID",
|
|
127752
|
+
metadata: {
|
|
127753
|
+
args: {
|
|
127754
|
+
baseUrl: exports_external3.string().optional().describe("OpenCode 服务地址,默认为 http://localhost:4096")
|
|
127755
|
+
}
|
|
127756
|
+
}
|
|
127757
|
+
}).define(async (ctx) => {
|
|
127758
|
+
const { baseUrl } = ctx.query;
|
|
127759
|
+
const client3 = await getClient({ baseUrl });
|
|
127760
|
+
if (!client3) {
|
|
127761
|
+
ctx.body = { content: "获取 OpenCode 客户端失败" };
|
|
127762
|
+
return;
|
|
127763
|
+
}
|
|
127764
|
+
const res = await client3.provider.list();
|
|
127765
|
+
const providerData = res?.data ?? res;
|
|
127766
|
+
const all = providerData?.all ?? [];
|
|
127767
|
+
const connected = providerData?.connected ?? [];
|
|
127768
|
+
const defaultModels = providerData?.default ?? {};
|
|
127769
|
+
const models = [];
|
|
127770
|
+
for (const provider2 of all) {
|
|
127771
|
+
const isConnected = connected.includes(provider2.id);
|
|
127772
|
+
for (const [modelKey, model] of Object.entries(provider2.models ?? {})) {
|
|
127773
|
+
models.push({
|
|
127774
|
+
providerID: provider2.id,
|
|
127775
|
+
providerName: provider2.name,
|
|
127776
|
+
modelID: modelKey,
|
|
127777
|
+
modelName: model.name ?? modelKey,
|
|
127778
|
+
isDefault: defaultModels[provider2.id] === modelKey,
|
|
127779
|
+
isConnected
|
|
127780
|
+
});
|
|
127781
|
+
}
|
|
127782
|
+
}
|
|
127783
|
+
ctx.body = {
|
|
127784
|
+
content: `共 ${models.length} 个模型,已连接提供商: ${connected.join(", ") || "无"}`,
|
|
127785
|
+
data: { models, connected, default: defaultModels }
|
|
127786
|
+
};
|
|
127787
|
+
}).addTo(app);
|
|
127747
127788
|
app.route({
|
|
127748
127789
|
path: "opencode-cnb",
|
|
127749
127790
|
key: "question",
|
|
@@ -127754,13 +127795,16 @@ app.route({
|
|
|
127754
127795
|
question: exports_external3.string().describe("问题"),
|
|
127755
127796
|
baseUrl: exports_external3.string().optional().describe("OpenCode 服务地址,默认为 http://localhost:4096"),
|
|
127756
127797
|
directory: exports_external3.string().optional().describe("运行目录,默认为根目录"),
|
|
127757
|
-
|
|
127798
|
+
messageId: exports_external3.string().optional().describe("消息 ID,选填"),
|
|
127758
127799
|
sessionId: exports_external3.string().optional().describe("会话 ID,选填"),
|
|
127759
|
-
|
|
127800
|
+
providerId: exports_external3.string().optional().describe("指定使用的提供商 ID,默认为空,表示使用默认提供商"),
|
|
127801
|
+
modelId: exports_external3.string().optional().describe("指定使用的模型 ID,默认为空,表示使用默认模型"),
|
|
127802
|
+
parts: exports_external3.array(exports_external3.any()).optional().describe("消息内容的分块,优先于 question 参数"),
|
|
127803
|
+
awaitAnswer: exports_external3.boolean().optional().describe("是否等待回答完成,默认为 false,开启后会在回答完成后返回完整回答内容")
|
|
127760
127804
|
}
|
|
127761
127805
|
}
|
|
127762
127806
|
}).define(async (ctx) => {
|
|
127763
|
-
const { question, baseUrl, directory = "/workspace",
|
|
127807
|
+
const { question, baseUrl, directory = "/workspace", messageId, sessionId, parts, awaitAnswer = false, providerId, modelId } = ctx.query;
|
|
127764
127808
|
const client3 = await getClient({ baseUrl });
|
|
127765
127809
|
if (!client3) {
|
|
127766
127810
|
ctx.body = { content: `OpenCode 客户端获取失败` };
|
|
@@ -127786,17 +127830,30 @@ app.route({
|
|
|
127786
127830
|
session = createSession.data;
|
|
127787
127831
|
}
|
|
127788
127832
|
let _parts = parts ?? [{ type: "text", text: question }];
|
|
127789
|
-
|
|
127833
|
+
let data = null;
|
|
127834
|
+
let model = null;
|
|
127835
|
+
if (providerId && modelId) {
|
|
127836
|
+
model = { providerID: providerId, modelID: modelId };
|
|
127837
|
+
}
|
|
127838
|
+
const promptPromise = client3.session.prompt({
|
|
127790
127839
|
body: {
|
|
127791
|
-
messageID,
|
|
127792
|
-
parts: _parts
|
|
127840
|
+
messageID: messageId,
|
|
127841
|
+
parts: _parts,
|
|
127842
|
+
...model ? { model } : {}
|
|
127793
127843
|
},
|
|
127794
127844
|
path: {
|
|
127795
127845
|
id: sessionId || session.id
|
|
127796
127846
|
}
|
|
127797
127847
|
});
|
|
127798
|
-
|
|
127799
|
-
|
|
127848
|
+
if (awaitAnswer) {
|
|
127849
|
+
const message = await promptPromise;
|
|
127850
|
+
data = message.data;
|
|
127851
|
+
} else {
|
|
127852
|
+
promptPromise.then((res) => {
|
|
127853
|
+
console.log(`Prompt completed with response:`, res.data.info.id);
|
|
127854
|
+
}).catch(() => {});
|
|
127855
|
+
}
|
|
127856
|
+
ctx.body = { content: awaitAnswer ? `已经完成` : `运行中`, data, sessionId: session.id };
|
|
127800
127857
|
}).addTo(app);
|
|
127801
127858
|
|
|
127802
127859
|
// src/routes/opencode/session/index.ts
|
|
@@ -127884,20 +127941,20 @@ app.route({
|
|
|
127884
127941
|
title: "列出 Session 消息",
|
|
127885
127942
|
summary: "列出指定 OpenCode 会话的所有消息记录",
|
|
127886
127943
|
args: {
|
|
127887
|
-
|
|
127944
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
127888
127945
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
127889
127946
|
}
|
|
127890
127947
|
})
|
|
127891
127948
|
}
|
|
127892
127949
|
}).define(async (ctx) => {
|
|
127893
|
-
const {
|
|
127894
|
-
if (!
|
|
127950
|
+
const { sessionId, port } = ctx.query;
|
|
127951
|
+
if (!sessionId) {
|
|
127895
127952
|
ctx.throw(400, "Session ID 不能为空");
|
|
127896
127953
|
return;
|
|
127897
127954
|
}
|
|
127898
127955
|
const client3 = await opencodeManager.getClient({ port });
|
|
127899
|
-
const result = await client3.session.messages({ path: { id } });
|
|
127900
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
127956
|
+
const result = await client3.session.messages({ path: { id: sessionId } });
|
|
127957
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 共 ${result.data?.length ?? 0} 条消息` };
|
|
127901
127958
|
}).addTo(app);
|
|
127902
127959
|
app.route({
|
|
127903
127960
|
path: "opencode-session",
|
|
@@ -127934,21 +127991,21 @@ app.route({
|
|
|
127934
127991
|
title: "更新 Session",
|
|
127935
127992
|
summary: "更新指定 OpenCode 会话的属性,如标题",
|
|
127936
127993
|
args: {
|
|
127937
|
-
|
|
127994
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
127938
127995
|
title: tool.schema.string().optional().describe("新的会话标题"),
|
|
127939
127996
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
127940
127997
|
}
|
|
127941
127998
|
})
|
|
127942
127999
|
}
|
|
127943
128000
|
}).define(async (ctx) => {
|
|
127944
|
-
const {
|
|
127945
|
-
if (!
|
|
128001
|
+
const { sessionId, title, port } = ctx.query;
|
|
128002
|
+
if (!sessionId) {
|
|
127946
128003
|
ctx.throw(400, "Session ID 不能为空");
|
|
127947
128004
|
return;
|
|
127948
128005
|
}
|
|
127949
128006
|
const client3 = await opencodeManager.getClient({ port });
|
|
127950
|
-
const result = await client3.session.update({ path: { id }, body: { title } });
|
|
127951
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
128007
|
+
const result = await client3.session.update({ path: { id: sessionId }, body: { title } });
|
|
128008
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 已更新` };
|
|
127952
128009
|
}).addTo(app);
|
|
127953
128010
|
app.route({
|
|
127954
128011
|
path: "opencode-session",
|
|
@@ -127962,20 +128019,20 @@ app.route({
|
|
|
127962
128019
|
title: "删除 Session",
|
|
127963
128020
|
summary: "根据 ID 删除指定的 OpenCode 会话及其所有数据",
|
|
127964
128021
|
args: {
|
|
127965
|
-
|
|
128022
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
127966
128023
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
127967
128024
|
}
|
|
127968
128025
|
})
|
|
127969
128026
|
}
|
|
127970
128027
|
}).define(async (ctx) => {
|
|
127971
|
-
const {
|
|
127972
|
-
if (!
|
|
128028
|
+
const { sessionId, port } = ctx.query;
|
|
128029
|
+
if (!sessionId) {
|
|
127973
128030
|
ctx.throw(400, "Session ID 不能为空");
|
|
127974
128031
|
return;
|
|
127975
128032
|
}
|
|
127976
128033
|
const client3 = await opencodeManager.getClient({ port });
|
|
127977
|
-
await client3.session.delete({ path: { id } });
|
|
127978
|
-
ctx.body = { content: `Session ${
|
|
128034
|
+
await client3.session.delete({ path: { id: sessionId } });
|
|
128035
|
+
ctx.body = { content: `Session ${sessionId} 已删除` };
|
|
127979
128036
|
}).addTo(app);
|
|
127980
128037
|
app.route({
|
|
127981
128038
|
path: "opencode-session",
|
|
@@ -127989,20 +128046,20 @@ app.route({
|
|
|
127989
128046
|
title: "中止 Session",
|
|
127990
128047
|
summary: "中止正在运行的 OpenCode 会话",
|
|
127991
128048
|
args: {
|
|
127992
|
-
|
|
128049
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
127993
128050
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
127994
128051
|
}
|
|
127995
128052
|
})
|
|
127996
128053
|
}
|
|
127997
128054
|
}).define(async (ctx) => {
|
|
127998
|
-
const {
|
|
127999
|
-
if (!
|
|
128055
|
+
const { sessionId, port } = ctx.query;
|
|
128056
|
+
if (!sessionId) {
|
|
128000
128057
|
ctx.throw(400, "Session ID 不能为空");
|
|
128001
128058
|
return;
|
|
128002
128059
|
}
|
|
128003
128060
|
const client3 = await opencodeManager.getClient({ port });
|
|
128004
|
-
await client3.session.abort({ path: { id } });
|
|
128005
|
-
ctx.body = { content: `Session ${
|
|
128061
|
+
await client3.session.abort({ path: { id: sessionId } });
|
|
128062
|
+
ctx.body = { content: `Session ${sessionId} 已中止` };
|
|
128006
128063
|
}).addTo(app);
|
|
128007
128064
|
app.route({
|
|
128008
128065
|
path: "opencode-session",
|
|
@@ -128016,21 +128073,21 @@ app.route({
|
|
|
128016
128073
|
title: "Fork Session",
|
|
128017
128074
|
summary: "从指定消息处 Fork 一个 OpenCode 会话",
|
|
128018
128075
|
args: {
|
|
128019
|
-
|
|
128076
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
128020
128077
|
messageId: tool.schema.string().describe("从该消息处开始 Fork"),
|
|
128021
128078
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
128022
128079
|
}
|
|
128023
128080
|
})
|
|
128024
128081
|
}
|
|
128025
128082
|
}).define(async (ctx) => {
|
|
128026
|
-
const {
|
|
128027
|
-
if (!
|
|
128083
|
+
const { sessionId, messageId, port } = ctx.query;
|
|
128084
|
+
if (!sessionId || !messageId) {
|
|
128028
128085
|
ctx.throw(400, "Session ID 和 messageId 不能为空");
|
|
128029
128086
|
return;
|
|
128030
128087
|
}
|
|
128031
128088
|
const client3 = await opencodeManager.getClient({ port });
|
|
128032
|
-
const result = await client3.session.fork({ path: { id }, body: { messageID: messageId } });
|
|
128033
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
128089
|
+
const result = await client3.session.fork({ path: { id: sessionId }, body: { messageID: messageId } });
|
|
128090
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 已从消息 ${messageId} Fork` };
|
|
128034
128091
|
}).addTo(app);
|
|
128035
128092
|
app.route({
|
|
128036
128093
|
path: "opencode-session",
|
|
@@ -128044,20 +128101,20 @@ app.route({
|
|
|
128044
128101
|
title: "总结 Session",
|
|
128045
128102
|
summary: "对指定的 OpenCode 会话进行内容总结",
|
|
128046
128103
|
args: {
|
|
128047
|
-
|
|
128104
|
+
sessionId: tool.schema.string().describe("Session ID"),
|
|
128048
128105
|
port: tool.schema.number().optional().describe("OpenCode 服务端口,默认为 4096")
|
|
128049
128106
|
}
|
|
128050
128107
|
})
|
|
128051
128108
|
}
|
|
128052
128109
|
}).define(async (ctx) => {
|
|
128053
|
-
const {
|
|
128054
|
-
if (!
|
|
128110
|
+
const { sessionId, port } = ctx.query;
|
|
128111
|
+
if (!sessionId) {
|
|
128055
128112
|
ctx.throw(400, "Session ID 不能为空");
|
|
128056
128113
|
return;
|
|
128057
128114
|
}
|
|
128058
128115
|
const client3 = await opencodeManager.getClient({ port });
|
|
128059
|
-
const result = await client3.session.summarize({ path: { id } });
|
|
128060
|
-
ctx.body = { data: result.data, content: `Session ${
|
|
128116
|
+
const result = await client3.session.summarize({ path: { id: sessionId } });
|
|
128117
|
+
ctx.body = { data: result.data, content: `Session ${sessionId} 总结完成` };
|
|
128061
128118
|
}).addTo(app);
|
|
128062
128119
|
|
|
128063
128120
|
// src/routes/remote/index.ts
|
package/dist/envision.js
CHANGED
|
@@ -22530,8 +22530,8 @@ InitEnv.init();
|
|
|
22530
22530
|
var version = useContextKey("version", () => {
|
|
22531
22531
|
let version2 = "0.0.64";
|
|
22532
22532
|
try {
|
|
22533
|
-
if ("0.1.
|
|
22534
|
-
version2 = "0.1.
|
|
22533
|
+
if ("0.1.26")
|
|
22534
|
+
version2 = "0.1.26";
|
|
22535
22535
|
} catch (e) {}
|
|
22536
22536
|
return version2;
|
|
22537
22537
|
});
|