@lythos/agent-adapter 0.15.6 → 0.15.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lythos/agent-adapter",
3
- "version": "0.15.6",
3
+ "version": "0.15.7",
4
4
  "main": "./src/index.ts",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -1,12 +1,20 @@
1
1
  import { describe, expect, it } from 'bun:test'
2
- import { buildKimiCommand, parseKimiStreamJson } from './kimi'
2
+ import { detectKimiBinary, buildKimiCommand, parseKimiStreamJson } from './kimi'
3
+
4
+ describe('detectKimiBinary', () => {
5
+ it('returns a non-empty string when a kimi binary is available', () => {
6
+ const binary = detectKimiBinary()
7
+ // In CI or environments without kimi, this may be empty — skip assert
8
+ if (!binary) return
9
+ expect(binary === 'kimi-cli' || binary === 'kimi').toBe(true)
10
+ })
11
+ })
3
12
 
4
13
  describe('buildKimiCommand', () => {
5
14
  it('builds kimi CLI args without shell wrapper', () => {
6
15
  const cmd = buildKimiCommand()
7
- expect(cmd[0]).toBe('kimi')
16
+ expect(cmd[0]).toBeOneOf(['kimi-cli', 'kimi'])
8
17
  expect(cmd).toContain('--print')
9
- expect(cmd).toContain('--afk')
10
18
  expect(cmd).toContain('--output-format')
11
19
  expect(cmd).toContain('stream-json')
12
20
  })
@@ -7,12 +7,27 @@ import { registerAgent } from '../registry'
7
7
 
8
8
  // ── Pure functions (testable without CLI) ────────────────────────────────────
9
9
 
10
- /** Build kimi --print command args (no shell wrapper — safe from injection). */
10
+ /** Detect which kimi binary to use. Prefers kimi-cli (legacy, v1.x) over kimi (kimi-code, v0.5+). */
11
+ export function detectKimiBinary(): string {
12
+ // kimi-cli v1.x supports --print --output-format stream-json
13
+ // kimi v0.5.0 (kimi-code) does NOT support --print; it uses --prompt with different semantics
14
+ if (Bun.which('kimi-cli')) {
15
+ return 'kimi-cli'
16
+ }
17
+ if (Bun.which('kimi')) {
18
+ return 'kimi'
19
+ }
20
+ return ''
21
+ }
22
+
23
+ /** Build kimi CLI command args (no shell wrapper — safe from injection). */
11
24
  export function buildKimiCommand(_modelTier?: 'fast' | 'balanced' | 'deep'): string[] {
12
- // Kimi CLI has no --model flag; model selection is via /model slash command,
13
- // config.toml, or KIMI_MODEL_NAME env var. modelTier is accepted but unused
14
- // — Kimi effectively provides one tier via coding plan.
15
- return ['kimi', '--print', '--afk', '--output-format', 'stream-json']
25
+ const binary = detectKimiBinary()
26
+ if (!binary) {
27
+ throw new Error('No kimi binary found in PATH. Install: https://github.com/MoonshotAI/kimi-cli')
28
+ }
29
+ // Both kimi-cli and kimi (if it ever gains --print support) use the same flag set
30
+ return [binary, '--print', '--output-format', 'stream-json']
16
31
  }
17
32
 
18
33
  /**
@@ -127,7 +142,8 @@ const kimiAdapter: AgentAdapter = {
127
142
  name: 'kimi',
128
143
 
129
144
  async spawn(opts): Promise<AgentRunResult> {
130
- if (!Bun.which('kimi')) {
145
+ const binary = detectKimiBinary()
146
+ if (!binary) {
131
147
  throw new Error('kimi not found in PATH. Install: https://github.com/MoonshotAI/kimi-cli')
132
148
  }
133
149
  return spawnKimi(opts)