@ycodium-ai/agent-kimi 0.2.3484 → 0.2.3506

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.
Files changed (2) hide show
  1. package/dist/index.js +50 -97
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -27676,75 +27676,11 @@ function toAcpMcpServers(entries) {
27676
27676
  }
27677
27677
 
27678
27678
  // ../../packages/ycodium-acp-executor/src/probe.ts
27679
- function withProbeTimeout(promise2, timeoutMs, what) {
27680
- return new Promise((resolve3, reject) => {
27681
- const timer = setTimeout(() => {
27682
- reject(new Error(`${what} timed out after ${timeoutMs}ms`));
27683
- }, timeoutMs);
27684
- timer.unref?.();
27685
- promise2.then(
27686
- (value) => {
27687
- clearTimeout(timer);
27688
- resolve3(value);
27689
- },
27690
- (error62) => {
27691
- clearTimeout(timer);
27692
- reject(error62 instanceof Error ? error62 : new Error(String(error62)));
27693
- }
27694
- );
27695
- });
27696
- }
27697
27679
  var CLI_VERSION_PATTERN = /(?<![\d.])(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)/;
27698
27680
  function parseCliVersion(output2) {
27699
27681
  return CLI_VERSION_PATTERN.exec(output2)?.[1] ?? null;
27700
27682
  }
27701
- async function collectCappedText(stream, maxBytes) {
27702
- const decoder = new TextDecoder();
27703
- let text = "";
27704
- let total = 0;
27705
- for await (const chunk of stream) {
27706
- total += chunk.byteLength;
27707
- if (total <= maxBytes) text += decoder.decode(chunk, { stream: true });
27708
- }
27709
- return { text: text + decoder.decode(), overflowed: total > maxBytes };
27710
- }
27711
- async function collectProbeProcess(child, input2) {
27712
- try {
27713
- await child.closeStdin().catch(() => void 0);
27714
- const [stdout, stderr, exitCode] = await withProbeTimeout(
27715
- Promise.all([
27716
- collectCappedText(child.stdout, input2.maxOutputBytes),
27717
- collectCappedText(child.stderr, input2.maxOutputBytes),
27718
- child.exited
27719
- ]),
27720
- input2.timeoutMs,
27721
- input2.what
27722
- );
27723
- return { stdout: stdout.overflowed ? void 0 : stdout.text, stderr: stderr.text, exitCode };
27724
- } finally {
27725
- await child.kill("SIGTERM").catch(() => void 0);
27726
- }
27727
- }
27728
27683
  var MAX_VERSION_OUTPUT_BYTES = 64 * 1024;
27729
- async function probeCliVersion(input2) {
27730
- let child;
27731
- try {
27732
- child = await input2.spawn();
27733
- } catch {
27734
- return null;
27735
- }
27736
- try {
27737
- const run = await collectProbeProcess(child, {
27738
- timeoutMs: input2.timeoutMs,
27739
- maxOutputBytes: MAX_VERSION_OUTPUT_BYTES,
27740
- what: "--version"
27741
- });
27742
- if (run.exitCode !== 0) return null;
27743
- return parseCliVersion(run.stdout ?? "") ?? parseCliVersion(run.stderr);
27744
- } catch {
27745
- return null;
27746
- }
27747
- }
27748
27684
 
27749
27685
  // src/config.ts
27750
27686
  function isRecord6(value) {
@@ -28389,6 +28325,10 @@ var createKimiTokenReader = (input2) => {
28389
28325
  };
28390
28326
 
28391
28327
  // src/kimiModels.ts
28328
+ import {
28329
+ runProcessOperation,
28330
+ OperationCleanupError
28331
+ } from "@ycodium-ai/plugin-api/process-operation";
28392
28332
  import {
28393
28333
  describeExecutorSpawnFailure,
28394
28334
  ExecutorSpawnAbortedError,
@@ -28463,31 +28403,31 @@ function kimiProbeModels(stdout) {
28463
28403
  }
28464
28404
  async function probeKimiModels(input2) {
28465
28405
  const { recipe, host, env } = input2;
28466
- let handle;
28406
+ let spawned = false;
28467
28407
  try {
28468
- handle = await host.process.spawn({
28469
- program: recipe.binaryPath,
28470
- // 实例信封里的启动参数(Kimi 那行预填 `acp`)在这一栏用不上:读配置要换成
28471
- // `provider list --json`,留着 `acp` 就等于让它起 ACP 服务然后什么都不问。
28472
- args: KIMI_MODEL_LIST_ARGS,
28473
- cwd: process.cwd(),
28474
- owner: { bindingId: host.bindingId },
28475
- ...Object.keys(env).length > 0 ? { env } : {},
28476
- ...input2.signal === void 0 ? {} : { signal: input2.signal }
28477
- });
28478
- } catch (error62) {
28479
- if (error62 instanceof ExecutorSpawnRefusedError || error62 instanceof ExecutorSpawnAbortedError) {
28480
- throw error62;
28481
- }
28482
- return { kind: "not-started", ...describeExecutorSpawnFailure(error62) };
28483
- }
28484
- try {
28485
- const run = await collectProbeProcess(handle, {
28486
- timeoutMs: input2.timeoutMs ?? PROBE_TIMEOUT_MS,
28487
- // 这份 JSON 实测 1.7KB;封顶是防 CLI 抽风刷日志把内存吃掉。
28488
- maxOutputBytes: MAX_OUTPUT_BYTES,
28489
- what: "kimi provider list"
28490
- });
28408
+ const run = await runProcessOperation(
28409
+ {
28410
+ ...host,
28411
+ process: {
28412
+ spawn: async (request) => {
28413
+ const handle = await host.process.spawn(request);
28414
+ spawned = true;
28415
+ return handle;
28416
+ }
28417
+ }
28418
+ },
28419
+ {
28420
+ program: recipe.binaryPath,
28421
+ args: KIMI_MODEL_LIST_ARGS,
28422
+ cwd: process.cwd(),
28423
+ owner: { bindingId: host.bindingId },
28424
+ ...Object.keys(env).length > 0 ? { env } : {},
28425
+ signal: input2.signal,
28426
+ timeoutMs: input2.timeoutMs ?? PROBE_TIMEOUT_MS,
28427
+ timeoutMessage: `kimi provider list timed out after ${input2.timeoutMs ?? PROBE_TIMEOUT_MS}ms`,
28428
+ maxOutputBytes: MAX_OUTPUT_BYTES
28429
+ }
28430
+ );
28491
28431
  if (run.exitCode !== 0) {
28492
28432
  const stderr = run.stderr.trim();
28493
28433
  return {
@@ -28500,22 +28440,30 @@ async function probeKimiModels(input2) {
28500
28440
  models: run.stdout === void 0 ? void 0 : kimiProbeModels(run.stdout)
28501
28441
  };
28502
28442
  } catch (error62) {
28443
+ if (error62 instanceof ExecutorSpawnRefusedError || error62 instanceof ExecutorSpawnAbortedError || error62 instanceof OperationCleanupError || input2.signal?.aborted)
28444
+ throw error62;
28445
+ if (!spawned) return { kind: "not-started", ...describeExecutorSpawnFailure(error62) };
28503
28446
  return { kind: "failed", detail: probeFailureDetail(error62) };
28504
28447
  }
28505
28448
  }
28506
28449
  async function probeKimiVersion(input2) {
28507
28450
  const { recipe, host, env, signal } = input2;
28508
- return probeCliVersion({
28509
- spawn: () => host.process.spawn({
28451
+ try {
28452
+ const run = await runProcessOperation(host, {
28510
28453
  program: recipe.binaryPath,
28511
28454
  args: ["--version"],
28512
- cwd: process.cwd(),
28513
28455
  owner: { bindingId: host.bindingId },
28514
28456
  ...Object.keys(env).length > 0 ? { env } : {},
28515
- ...signal === void 0 ? {} : { signal }
28516
- }),
28517
- timeoutMs: PROBE_TIMEOUT_MS
28518
- });
28457
+ signal,
28458
+ timeoutMs: PROBE_TIMEOUT_MS,
28459
+ maxOutputBytes: 64 * 1024
28460
+ });
28461
+ if (run.exitCode !== 0) return null;
28462
+ return parseCliVersion(run.stdout) ?? parseCliVersion(run.stderr);
28463
+ } catch (error62) {
28464
+ if (error62 instanceof OperationCleanupError || signal?.aborted) throw error62;
28465
+ return null;
28466
+ }
28519
28467
  }
28520
28468
  async function probeKimi(input2) {
28521
28469
  const [listed, version2] = await Promise.all([probeKimiModels(input2), probeKimiVersion(input2)]);
@@ -28763,7 +28711,12 @@ var createKimiInstance = (config2, host) => {
28763
28711
  };
28764
28712
  }
28765
28713
  },
28766
- readCliVersion: () => recipe.binaryPath.length === 0 ? Promise.resolve(null) : probeKimiVersion({ recipe, host, env: buildSpawnEnv(recipe, recipe.homePath) }),
28714
+ readCliVersion: (signal) => recipe.binaryPath.length === 0 ? Promise.resolve(null) : probeKimiVersion({
28715
+ recipe,
28716
+ host,
28717
+ env: buildSpawnEnv(recipe, recipe.homePath),
28718
+ ...signal === void 0 ? {} : { signal }
28719
+ }),
28767
28720
  // 暂不处理 input.readOnlyDirectories(有意为之):kimi 经共享的 ycodium-acp-executor 起会话,
28768
28721
  // 还没用真机确认这家 CLI 对 cwd 之外的读怎么处理、要不要放行。确认之后再接这一栏。
28769
28722
  startSession: async (input2, signal) => {
@@ -29005,7 +28958,7 @@ var executors = [
29005
28958
  ];
29006
28959
  var index_default = definePlugin({
29007
28960
  id: "agent-kimi",
29008
- apiVersion: 39,
28961
+ apiVersion: 42,
29009
28962
  executors,
29010
28963
  activate(ctx) {
29011
28964
  ctx.log.info("Kimi Code executor ready");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-kimi",
3
- "version": "0.2.3484",
3
+ "version": "0.2.3506",
4
4
  "description": "Kimi Code executor: runs `kimi acp` over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,9 +21,9 @@
21
21
  "@types/node": "24.12.4",
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
- "@ycodium-ai/plugin-api": "0.2.3484",
24
+ "@ycodium-ai/plugin-api": "0.2.3506",
25
25
  "ycodium-executor-testing": "0.0.0",
26
- "ycodium-acp-executor": "0.2.3484"
26
+ "ycodium-acp-executor": "0.2.0"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",