@aiti-ai/aiti-codebuddy-agent 0.1.8 → 0.1.10

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 CHANGED
@@ -1,39 +1,31 @@
1
1
  # @aiti-ai/aiti-codebuddy-agent
2
2
 
3
- > 腾讯 CodeBuddy Code CLI(cbc)驱动 —— stream 长连接(默认)+ exec 兜底双模式 + --resume 接入 All Sessions,control_request 三通道,API-key env 登录
3
+ > Tencent CodeBuddy Code CLI (cbc) driver — stream long connection (default) + exec fallback dual mode + --resume into All Sessions, control_request three channels, API-key env login
4
4
 
5
- ## 来源 · Origin
5
+ English · [简体中文](./README.zh-CN.md)
6
6
 
7
- 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
7
+ ## About aiti
8
8
 
9
- This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
9
+ This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/aiti-ai)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
10
10
 
11
- - 工作台 / workbench: <https://github.com/aiti-ai/pi-web>
12
- - 生态仓库 / monorepo: <https://github.com/aiti-ai/aiti-ai>
13
- - 官网 / site: <https://aiti.pw>
11
+ - Workbench & monorepo: <https://github.com/aiti-ai/aiti-ai>
12
+ - Site: <https://aiti.pw>
14
13
 
15
- ## 功能定位(中文)
14
+ Category: Multi-agent backends · Tags: `codebuddy` · `tencent` · `cbc` · `workbuddy` · `cli` · `session` · `multi-agent` · `glm` · `kimi`
16
15
 
17
- 腾讯 CodeBuddy Code CLI(cbc)驱动 —— stream 长连接(默认)+ exec 兜底双模式 + --resume 接入 All Sessions,control_request 三通道,API-key env 登录
16
+ ## Install
18
17
 
19
- 多 agent 后端 · tags: `codebuddy` · `tencent` · `cbc` · `workbuddy` · `cli` · `session` · `multi-agent` · `glm` · `kimi`
18
+ Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
20
19
 
21
- ## Positioning (English)
20
+ Manual install: place this package at `~/.pi/web/extensions/aiti-codebuddy-agent/` and reload pi-web.
22
21
 
23
- Tencent CodeBuddy Code CLI (cbc) driver — stream long connection (default) + exec fallback dual mode + --resume into All Sessions, control_request three channels, API-key env login
22
+ Requires the cbc CLI on the machine: `npm i -g @tencent-ai/codebuddy-code` (or rely on the npx fallback).
24
23
 
25
- ## 安装 / 部署
24
+ ## Documentation
26
25
 
27
- ```bash
28
- # 部署到 ~/.pi/web/extensions/aiti-codebuddy-agent/ 后 reload
29
- # 需要本机可用 cbc:npm i -g @tencent-ai/codebuddy-code(或依赖 npx 兜底)
30
- ```
31
-
32
- ## 文档 · Documentation
33
-
34
- - 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-codebuddy-agent.html>
35
- - English docs: <https://aiti.pw/en/extensions/aiti-codebuddy-agent.html>
36
- - 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
26
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-codebuddy-agent.html>
27
+ - 文档(中文): <https://aiti.pw/extensions/aiti-codebuddy-agent.html>
28
+ - Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
37
29
 
38
30
  ## License
39
31
 
@@ -0,0 +1,32 @@
1
+ # @aiti-ai/aiti-codebuddy-agent
2
+
3
+ > 腾讯 CodeBuddy Code CLI(cbc)驱动 —— stream 长连接(默认)+ exec 兜底双模式 + --resume 接入 All Sessions,control_request 三通道,API-key env 登录
4
+
5
+ [English](./README.md) · 简体中文
6
+
7
+ ## 关于 aiti
8
+
9
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/aiti-ai) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
+
11
+ - 工作台 / 生态仓库(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/aiti-ai>
12
+ - 官网: <https://aiti.pw>
13
+
14
+ 分类: 多 agent 后端 · tags: `codebuddy` · `tencent` · `cbc` · `workbuddy` · `cli` · `session` · `multi-agent` · `glm` · `kimi`
15
+
16
+ ## 安装
17
+
18
+ 随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
19
+
20
+ 手动安装:把本包放到 `~/.pi/web/extensions/aiti-codebuddy-agent/` 后 reload。
21
+
22
+ 需要本机可用 cbc:`npm i -g @tencent-ai/codebuddy-code`(或依赖 npx 兜底)。
23
+
24
+ ## 文档
25
+
26
+ - 中文文档: <https://aiti.pw/extensions/aiti-codebuddy-agent.html>
27
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-codebuddy-agent.html>
28
+ - 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
29
+
30
+ ## 许可证
31
+
32
+ MIT
@@ -185,7 +185,16 @@ test("resolveCli:显式路径优先 → 不存在 throw;npx 兜底 = node +
185
185
  assert.equal(direct.kind, "direct");
186
186
  assert.equal(direct.cmd, bin);
187
187
  assert.throws(() => resolveCli({ featurePath: "/nonexistent/cbc" }), /路径不存在/);
188
- const npx = resolveCli({});
188
+ // The npx fallback only applies when no cbc/codebuddy sits on PATH: a developer
189
+ // box with the CLI installed must not change this assertion.
190
+ const savedPath = process.env.PATH;
191
+ process.env.PATH = "/nonexistent-bin";
192
+ let npx;
193
+ try {
194
+ npx = resolveCli({});
195
+ } finally {
196
+ process.env.PATH = savedPath;
197
+ }
189
198
  assert.equal(npx.kind, "npx");
190
199
  assert.equal(npx.cmd, process.execPath);
191
200
  assert.equal(npx.baseArgs[1], "-y");
@@ -80,6 +80,37 @@ export interface CodebuddyHandleInit {
80
80
  runtime: CodebuddyRuntime;
81
81
  /** P2 协议委托:成员级启动包装(custom-agent 路径),优先于 extman spawn.* feature。 */
82
82
  launchOverride?: LaunchOverride;
83
+ /** Host-injected process strategy (pi-web core agent-starter); absent = plain spawn. */
84
+ agentStarter?: AgentStarterLike;
85
+ /** Host recovery: adopt a live process instead of spawning (detached sessions). */
86
+ attached?: AttachedChildOptions;
87
+ }
88
+
89
+ /**
90
+ * Injected by the pi-web core (`agent-starter`). Older hosts do not pass it — the
91
+ * extension then keeps its historical `child_process.spawn`. With the detachable
92
+ * variant the long-lived cbc connection outlives pi-web and a reattach adopts it.
93
+ */
94
+ export interface AgentStarterLike {
95
+ readonly kind: "direct" | "wrapper";
96
+ spawn(
97
+ command: string,
98
+ args: string[],
99
+ options?: {
100
+ env?: Record<string, string>;
101
+ cwd?: string;
102
+ shell?: boolean | string;
103
+ agentKey?: string;
104
+ sessionId?: string;
105
+ },
106
+ ): Promise<ChildProcess>;
107
+ }
108
+
109
+ /** Adopt an already-live agent process (core recovery after a pi-web restart). */
110
+ export interface AttachedChildOptions {
111
+ child: ChildProcess;
112
+ sessionId: string;
113
+ agentKey?: string;
83
114
  }
84
115
 
85
116
  /** 能力表(stream:长连接,control 三通道实测可用 → 运行中切换模型/权限、可应答工具授权)。 */
@@ -508,6 +539,10 @@ export abstract class CodebuddyHandleBase {
508
539
 
509
540
  export class CodebuddyStreamHandle extends CodebuddyHandleBase {
510
541
  private child: ChildProcess | null = null;
542
+ /** Host-injected process strategy (undefined = plain spawn, historical behavior). */
543
+ starter?: AgentStarterLike;
544
+ /** Registry key the host records for this session (cbc session id or placeholder). */
545
+ nativeKey = "";
511
546
  private detachReader: (() => void) | null = null;
512
547
  private stdinSeq = 0;
513
548
  /** control_request 应答等待(request_id → resolve)。 */
@@ -535,15 +570,21 @@ export class CodebuddyStreamHandle extends CodebuddyHandleBase {
535
570
  }
536
571
 
537
572
  static async start(init: CodebuddyHandleInit): Promise<CodebuddyStreamHandle> {
573
+ if (init.attached) return CodebuddyStreamHandle.adopt(init, init.attached.child, init.attached.sessionId);
538
574
  const cli = init.runtime.resolveCli();
539
575
  const args = buildStreamArgs({
540
576
  model: init.model?.id && init.model.id !== DEFAULT_MODEL ? init.model.id : undefined,
541
577
  permissionMode: init.runtime.permissionMode(),
542
578
  resumeSid: init.sessionId,
543
579
  });
544
- const provisionalId = init.sessionId ? `codebuddy:${init.sessionId}` : `codebuddy:new-${++counter}-${Date.now()}`;
580
+ // One native key shared by the detached registry and the provisional handle id
581
+ // (cbc's real session id only arrives with the first init frame).
582
+ const nativeKey = init.sessionId ?? `new-${++counter}-${Date.now()}`;
583
+ const provisionalId = `codebuddy:${nativeKey}`;
545
584
  const handle = new CodebuddyStreamHandle(provisionalId, init.cwd, init.runtime);
546
585
  handle.sessId = init.sessionId;
586
+ handle.nativeKey = nativeKey;
587
+ handle.starter = init.agentStarter;
547
588
  if (init.model?.id) handle.model = { id: init.model.id, provider: "codebuddy" };
548
589
 
549
590
  const env = handle.turnEnv();
@@ -560,18 +601,54 @@ export class CodebuddyStreamHandle extends CodebuddyHandleBase {
560
601
  cwd: init.cwd || process.cwd(),
561
602
  warn: (m) => console.log(`[aiti-codebuddy-agent] ${m}`),
562
603
  });
563
- const child = spawn(launch.command, launch.args, {
564
- shell: launch.shell,
565
- cwd: init.cwd || process.cwd(),
566
- stdio: ["pipe", "pipe", "pipe"],
567
- env: launch.env,
568
- });
569
- handle.child = child;
570
- handle.detachReader = lineReader(child.stdout, (line) => handle.onLine(line), {
571
- onOverflow: (size) => handle.markDead(`stdout line overflow (${size} bytes)`),
604
+ const child = init.agentStarter
605
+ ? await init.agentStarter.spawn(launch.command, launch.args, {
606
+ shell: launch.shell,
607
+ cwd: init.cwd || process.cwd(),
608
+ env: launch.env as Record<string, string>,
609
+ agentKey: "codebuddy",
610
+ sessionId: nativeKey,
611
+ })
612
+ : spawn(launch.command, launch.args, {
613
+ shell: launch.shell,
614
+ cwd: init.cwd || process.cwd(),
615
+ stdio: ["pipe", "pipe", "pipe"],
616
+ env: launch.env,
617
+ });
618
+ handle.bindChild(child);
619
+ handle.persistModelState();
620
+ return handle;
621
+ }
622
+
623
+ /**
624
+ * Recovery: adopt the still-open cbc connection the core reattached to. The
625
+ * wrapper replays past frames through the same reader, so live history and any
626
+ * pending tool-authorization requests come back with it.
627
+ */
628
+ static async adopt(
629
+ init: CodebuddyHandleInit,
630
+ child: ChildProcess,
631
+ nativeSessionId: string,
632
+ ): Promise<CodebuddyStreamHandle> {
633
+ const handle = new CodebuddyStreamHandle(`codebuddy:${nativeSessionId}`, init.cwd, init.runtime);
634
+ handle.aliveFlag = true;
635
+ handle.sessId = nativeSessionId;
636
+ handle.nativeKey = nativeSessionId;
637
+ if (init.model?.id) handle.model = { id: init.model.id, provider: "codebuddy" };
638
+ handle.bindChild(child);
639
+ handle.persistModelState();
640
+ return handle;
641
+ }
642
+
643
+ /** Wire one live cbc process to this handle (fresh spawn or adopted facade). */
644
+ private bindChild(child: ChildProcess): void {
645
+ this.child = child;
646
+ this.detachReader?.();
647
+ this.detachReader = lineReader(child.stdout, (line) => this.onLine(line), {
648
+ onOverflow: (size) => this.markDead(`stdout line overflow (${size} bytes)`),
572
649
  });
573
650
  // 三个流必须挂 error 监听(加固 A2):ECONNRESET/EPIPE 无监听器会崩宿主进程。
574
- child.stdout?.on("error", (err) => handle.markDead(`stdout error: ${err.message}`));
651
+ child.stdout?.on("error", (err) => this.markDead(`stdout error: ${err.message}`));
575
652
  child.stderr?.on("error", (err) => console.log(`[aiti-codebuddy-agent] stderr error: ${err.message}`));
576
653
  child.stdin?.on("error", (err) => console.log(`[aiti-codebuddy-agent] stdin error: ${err.message}`));
577
654
  child.stderr?.on("data", (c: Buffer | string) => {
@@ -579,12 +656,10 @@ cwd: init.cwd || process.cwd(),
579
656
  if (text) console.log(`[aiti-codebuddy-agent] ${text.slice(0, 300)}`);
580
657
  });
581
658
  child.once("exit", (code) => {
582
- handle.running = false;
583
- handle.markDead(`process exited (${code ?? "signal"})`);
659
+ this.running = false;
660
+ this.markDead(`process exited (${code ?? "signal"})`);
584
661
  });
585
- child.once("error", (err) => handle.markDead(`process error: ${err.message}`));
586
- handle.persistModelState();
587
- return handle;
662
+ child.once("error", (err) => this.markDead(`process error: ${err.message}`));
588
663
  }
589
664
 
590
665
  protected cleanupOnDead(): void {
@@ -895,6 +970,17 @@ cwd: init.cwd || process.cwd(),
895
970
  this.turn = null;
896
971
  this.q.dispose();
897
972
  const child = this.child;
973
+ // Wrapper-hosted connection: disconnect and leave cbc running (the core decides
974
+ // whether a session should actually be stopped).
975
+ const facade = child as unknown as { detachable?: unknown; release?: () => void } | null;
976
+ if (facade && facade.detachable === true && typeof facade.release === "function") {
977
+ facade.release();
978
+ this.child = null;
979
+ this.detachReader?.();
980
+ this.detachReader = null;
981
+ this.listeners.clear();
982
+ return;
983
+ }
898
984
  if (child && child.exitCode === null) {
899
985
  try { child.kill("SIGTERM"); } catch { /* already dead */ }
900
986
  await new Promise<void>((resolve) => {
package/dev-pack.mjs CHANGED
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
77
77
 
78
78
  /** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
79
79
  function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
80
- const repoHint = "/home/pi/workspace/aiti-ai"; // 现场构建探测源码仓 node_modules 用(三机各不同,缺失时走 npm exec)
80
+ // No hardcoded checkout path: candidates are resolved at run time (see repoCandidates below).
81
81
  return `/**
82
82
  * ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
83
83
  * 用法:node tools/build.mjs
@@ -96,12 +96,25 @@ const entryRel = ${JSON.stringify(entryRel || "")};
96
96
 
97
97
  // esbuild 解析:部署目录 node_modules → 源码仓 node_modules(本机开发场景)→ PATH 上的 esbuild → npm exec 现拉。
98
98
  // 注意:node_modules/esbuild/bin/esbuild 是原生二进制(ELF/Mach-O),必须直接执行(不能当 JS 跑)。
99
+ // Checkout roots are discovered by walking up from the extension dir (a root has node_modules/),
100
+ // plus AITI_REPO_ROOT when set — no machine-specific absolute paths baked into generated files.
101
+ function repoCandidates() {
102
+ const out = [];
103
+ if (process.env.AITI_REPO_ROOT) out.push(process.env.AITI_REPO_ROOT.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
104
+ let d = extRoot;
105
+ for (let i = 0; i < 8; i++) {
106
+ out.push(d.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
107
+ const up = dirname(d);
108
+ if (up === d) break;
109
+ d = up;
110
+ }
111
+ return out;
112
+ }
99
113
  function findEsbuild() {
100
114
  const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
101
115
  const candidates = [
102
116
  extRoot + "/node_modules/esbuild/bin/esbuild",
103
- home + "/workspace/aiti-ai/node_modules/esbuild/bin/esbuild",
104
- "C:/workspace/aiti-ai/node_modules/esbuild/bin/esbuild", // windows dev box(源码在 D 盘)
117
+ ...repoCandidates(),
105
118
  ];
106
119
  for (const c of candidates) {
107
120
  if (!existsSync(c)) continue;
package/index.ts CHANGED
@@ -34,7 +34,7 @@
34
34
  import { mkdirSync, readdirSync } from "node:fs";
35
35
  import { homedir } from "node:os";
36
36
  import { dirname, join } from "node:path";
37
- import { spawnEnvFeature, spawnCommandFeature, spawnArgsPrefixFeature, captureSpawnEnvFeatures } from "@aiti-ai/ext-shared/agent-spawn-env";
37
+ import { spawnEnvFeature, spawnDisplayEnvFeature, spawnCommandFeature, spawnArgsPrefixFeature, captureSpawnEnvFeatures, spawnFeatureI18nEn } from "@aiti-ai/ext-shared/agent-spawn-env";
38
38
  import type { LaunchOverride } from "@aiti-ai/ext-shared/agent-spawn-env";
39
39
  import {
40
40
  readExtModelState, readAgentLastUsedModel, withLastUsedFirst,
@@ -49,6 +49,7 @@ import {
49
49
  // handle 实现(stream 长连接 + exec 单发双模式;能力表/目录/SID_RE 同源)
50
50
  import {
51
51
  CBC_CAPABILITIES, SID_RE, codebuddyCatalog, createCodebuddyHandle, setCodebuddyQueueStateDir,
52
+ type AgentStarterLike, type AttachedChildOptions,
52
53
  type CodebuddyHandleBase, type CodebuddyRuntime,
53
54
  } from "./codebuddy-handles.ts";
54
55
 
@@ -467,11 +468,11 @@ async function recycleApi(req: Request, ctx: { path: string[]; method: string })
467
468
  export default {
468
469
  id: "aiti-codebuddy-agent",
469
470
  name: "CodeBuddy Code (腾讯)",
470
- version: "0.1.0",
471
- icon: "🔵",
471
+ icon: "icons/terminal.svg",
472
472
 
473
473
  features: [
474
474
  spawnEnvFeature("CodeBuddy Code"),
475
+ spawnDisplayEnvFeature("CodeBuddy Code"),
475
476
  spawnCommandFeature("CodeBuddy Code"),
476
477
  spawnArgsPrefixFeature("CodeBuddy Code"),
477
478
  {
@@ -556,6 +557,36 @@ export default {
556
557
  },
557
558
  ],
558
559
 
560
+
561
+ ui: {
562
+ // English manifest-text overrides (name/description/feature labels); zh source lives in the manifest.
563
+ i18n: {
564
+ en: {
565
+ ...spawnFeatureI18nEn(),
566
+ "feat.codebuddy.cliPath.desc": "Path to the cbc executable (absolute path after npm i -g @tencent-ai/codebuddy-code or brew install codebuddy-code). Empty = auto-detect cbc/codebuddy on PATH → npx fallback (first use downloads)",
567
+ "feat.codebuddy.packageSpec.desc": "Package pulled by the npx fallback (default @tencent-ai/codebuddy-code latest cache; pin a version supported by the local Node)",
568
+ "feat.codebuddy.model.desc": "Default model id for new sessions (--model): default-model/fast-model/balanced-model family aliases or a full model id",
569
+ "feat.codebuddy.permissionMode.desc": "--permission-mode: default/acceptEdits/bypassPermissions (maps to the agent tool's permission semantics)",
570
+ "feat.codebuddy.connectionMode.desc": "stream (default, long-lived connection: single process, multi-turn, cwd switching saves cold start) | oneshot (single-shot process per turn, legacy fallback)",
571
+ "feat.codebuddy.apiKey.desc": "CODEBUDDY_API_KEY: personal API key from the Tencent CodeBuddy platform (used by the npx fallback)",
572
+ "feat.codebuddy.authToken.desc": "CODEBUDDY_AUTH_TOKEN: existing OAuth token (preferred by the CLI side; for logged-in desktop users)",
573
+ "feat.codebuddy.baseUrl.desc": "CODEBUDDY_BASE_URL: point to an OpenAI-compatible endpoint (bypassing the Tencent gateway, e.g. a self-hosted proxy)",
574
+ "feat.codebuddy.bridgeUrl.desc": "AITI_BRIDGE_URL: enables aiti_* tools inside cbc sessions connecting to the AITI bridge (MCP tool injection)",
575
+ "ext.displayName": "CodeBuddy Code (Tencent)",
576
+ "feat.codebuddy.cliPath.desc": "Path to the cbc executable (absolute path after npm i -g @tencent-ai/codebuddy-code or brew install codebuddy-code). Empty = auto-detect cbc/codebuddy on PATH → npx fallback (first use downloads).",
577
+ "feat.codebuddy.cliPath": "CLI path",
578
+ "feat.codebuddy.packageSpec": "npx package spec",
579
+ "feat.codebuddy.model": "Default model",
580
+ "feat.codebuddy.permissionMode": "Permission mode",
581
+ "feat.codebuddy.connectionMode": "Connection mode",
582
+ "feat.codebuddy.apiKey": "API key (credential)",
583
+ "feat.codebuddy.authToken": "Auth token (credential)",
584
+ "feat.codebuddy.baseUrl": "Base URL (third-party model gateway)",
585
+ "feat.codebuddy.bridgeUrl": "AITI bridge URL (MCP tool injection)",
586
+ },
587
+ },
588
+ },
589
+
559
590
  server: {
560
591
  startup(ctx: {
561
592
  configDir?: string;
@@ -615,7 +646,15 @@ export default {
615
646
 
616
647
  // createSession 主体(provider 与 P2 launch 服务共用:复活/种子模型/状态文件全链路一致)
617
648
  const createCbcSession = async (
618
- options: { sessionId?: string; cwd?: string; model?: { provider: string; id: string } },
649
+ options: {
650
+ sessionId?: string;
651
+ cwd?: string;
652
+ model?: { provider: string; id: string };
653
+ /** Host-injected process strategy (detachable hosting); absent = plain spawn. */
654
+ agentStarter?: AgentStarterLike;
655
+ /** Host recovery: adopt a live process instead of spawning. */
656
+ attached?: AttachedChildOptions;
657
+ },
619
658
  launchOverride?: LaunchOverride,
620
659
  ) => {
621
660
  const rawSid = options.sessionId ?? "";
@@ -662,6 +701,8 @@ export default {
662
701
  cwd: restoredCwd || options.cwd || process.cwd(),
663
702
  model: seedModel,
664
703
  runtime,
704
+ ...(options.agentStarter ? { agentStarter: options.agentStarter } : {}),
705
+ ...(options.attached ? { attached: options.attached } : {}),
665
706
  });
666
707
  if (isRealSid && restoredParsed?.messages?.length) handle.seedHistory(restoredParsed.messages as never[]);
667
708
  handle.launchOverride = launchOverride;
@@ -681,6 +722,9 @@ export default {
681
722
  await refreshCbcModelCatalog(cacheDir, cli);
682
723
  return codebuddyCatalog();
683
724
  },
725
+ // The core may host this backend's connection in a detachable wrapper; the
726
+ // stream handle adopts the live process on reattach (exec mode stays plain).
727
+ detachable: true,
684
728
  createSession: (options) => createCbcSession(options),
685
729
  });
686
730
  // agent 描述符:agent 管理面(aiti-agent-manager)动态发现用——manager 不写死各家,
package/package.json CHANGED
@@ -1,17 +1,26 @@
1
1
  {
2
2
  "name": "@aiti-ai/aiti-codebuddy-agent",
3
- "version": "0.1.8",
4
- "description": "腾讯 CodeBuddy Code CLI (cbc) session backend driver (-p stream-json + --resume)",
3
+ "version": "0.1.10",
4
+ "description": "Tencent CodeBuddy Code CLI (cbc) driver — stream long connection (default) + exec fallback dual mode + --resume into All Sessions, control_request three channels, API-key env login",
5
+ "displayNameI18n": {
6
+ "en": "CodeBuddy Code (Tencent)"
7
+ },
8
+ "descriptionI18n": {
9
+ "zh-CN": "腾讯 CodeBuddy Code CLI(cbc)驱动 —— stream 长连接(默认)+ exec 兜底双模式 + --resume 接入 All Sessions,control_request 三通道,API-key env 登录"
10
+ },
5
11
  "soul": "腾讯 CodeBuddy 会话,哪儿都能接上聊。",
12
+ "soulI18n": {
13
+ "en": "Tencent CodeBuddy sessions, ready to chat anywhere."
14
+ },
6
15
  "scripts": {
7
16
  "build:client": "true"
8
17
  },
9
18
  "aitiExtProtocol": "1.0",
10
19
  "dependencies": {
11
- "@aiti-ai/ext-shared": "^0.1.7"
20
+ "@aiti-ai/ext-shared": "^0.1.12"
12
21
  },
13
22
  "license": "MIT",
14
- "contentHash": "0be774023bb56156",
23
+ "contentHash": "56d64a11e590257c",
15
24
  "repository": {
16
25
  "type": "git",
17
26
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",