@yitom/acp-client 0.1.0 → 0.1.3

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.
@@ -75,7 +75,8 @@ export interface AcpClientCallbacks {
75
75
  sessionId?: string
76
76
  toolCall?: { id?: string; title?: string; kind?: string }
77
77
  params: Record<string, unknown>
78
- }) => Promise<{ outcome: 'approved' | 'cancelled' }>
78
+ }) => Promise<{ outcome: 'selected'; optionId: string } | { outcome: 'cancelled' }>
79
+ // 允许放行统一用 pickAllowOptionId(params) 挑 Agent 给定的允许项(协议层无 'approved')
79
80
 
80
81
  /** 会话状态与内容流式更新 */
81
82
  onSessionUpdate?: (params: Record<string, unknown>) => void
@@ -25,7 +25,7 @@ npm install @inkdown/acp
25
25
  ```typescript
26
26
  import readline from 'node:readline/promises'
27
27
  import { stdin, stdout } from 'node:process'
28
- import { AcpClient } from '@inkdown/acp'
28
+ import { AcpClient, pickAllowOptionId } from '@yitom/acp-client'
29
29
 
30
30
  async function runCli() {
31
31
  const rl = readline.createInterface({ input: stdin, output: stdout })
@@ -41,13 +41,16 @@ async function runCli() {
41
41
  onStatusChange: (status, detail) => {
42
42
  console.log(`[连接状态] ${status} ${detail ? `(${detail})` : ''}`)
43
43
  },
44
- // 敏感权限交互式审批
45
- onPermissionRequest: async ({ toolCall }) => {
44
+ // 敏感权限交互式审批(协议层只有 selected/cancelled,用 pickAllowOptionId 挑允许项)
45
+ onPermissionRequest: async ({ toolCall, params }) => {
46
46
  const answer = await rl.question(
47
47
  `\n[权限确认] Agent 请求执行工具 "${toolCall?.title || '未知'}",是否允许?(y/N): `
48
48
  )
49
- const approved = answer.trim().toLowerCase() === 'y'
50
- return { outcome: approved ? 'approved' : 'cancelled' }
49
+ if (answer.trim().toLowerCase() !== 'y') return { outcome: 'cancelled' as const }
50
+ const optionId = pickAllowOptionId(params as Record<string, unknown>)
51
+ return optionId
52
+ ? { outcome: 'selected' as const, optionId }
53
+ : { outcome: 'cancelled' as const }
51
54
  },
52
55
  // 实时流式响应
53
56
  onSessionUpdate: (update) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yitom/acp-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "Headless ACP (Agent Client Protocol) SDK for connecting to Codex, Claude, Cursor, DeepSeek and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -17,6 +17,7 @@
17
17
  "import": "./dist/index.js",
18
18
  "require": "./dist/index.cjs"
19
19
  },
20
+ "./sidecar": "./dist/sidecar.cjs",
20
21
  "./package.json": "./package.json"
21
22
  },
22
23
  "publishConfig": {
@@ -30,7 +31,7 @@
30
31
  },
31
32
  "homepage": "https://github.com/yitom486/acp-client#readme",
32
33
  "scripts": {
33
- "build": "bun build ./src/index.ts --outdir ./dist --format esm --target node --external @agentclientprotocol/sdk && bun build ./src/index.ts --outfile ./dist/index.cjs --format cjs --target node --external @agentclientprotocol/sdk && tsc -p tsconfig.json",
34
+ "build": "bun build ./src/index.ts --outdir ./dist --format esm --target node --external @agentclientprotocol/sdk && bun build ./src/index.ts --outfile ./dist/index.cjs --format cjs --target node --external @agentclientprotocol/sdk && bun build ./src/sidecar/main.ts --outfile ./dist/sidecar.cjs --format cjs --target node && tsc -p tsconfig.json",
34
35
  "test": "bun test",
35
36
  "prepublishOnly": "bun run build"
36
37
  },
@@ -40,5 +41,8 @@
40
41
  "devDependencies": {
41
42
  "@types/node": "^26.6.3",
42
43
  "typescript": "^7.0.2"
44
+ },
45
+ "bin": {
46
+ "acp-engine": "./dist/sidecar.cjs"
43
47
  }
44
48
  }