xgen-dex-cli 1.2.0

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.
@@ -0,0 +1,187 @@
1
+ # Dex CLI stdio protocol v1
2
+
3
+ `dex serve --stdio`는 장기 실행 엔진 프로세스를 시작합니다. 전송은 UTF-8 NDJSON이고 각 줄은
4
+ 완전한 JSON-RPC 2.0 객체입니다.
5
+
6
+ ## 전송 규칙
7
+
8
+ - stdin: client request와 notification
9
+ - stdout: server response와 notification
10
+ - stderr: 사람이 읽는 로그와 진단
11
+ - 한 줄에 정확히 하나의 JSON 객체
12
+ - 첫 request는 반드시 `initialize`
13
+ - protocol version은 현재 `1`
14
+ - request ID는 string, number 또는 null
15
+ - 비밀번호를 포함한 request 전체를 로그에 남기지 않음
16
+
17
+ ## 초기화
18
+
19
+ Request:
20
+
21
+ ```json
22
+ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"client":{"name":"xgen-vscode","version":"0.1.0"}}}
23
+ ```
24
+
25
+ Response:
26
+
27
+ ```json
28
+ {
29
+ "jsonrpc": "2.0",
30
+ "id": 1,
31
+ "result": {
32
+ "protocolVersion": 1,
33
+ "server": { "name": "dex-cli", "version": "0.1.0" },
34
+ "capabilities": {
35
+ "profiles": true,
36
+ "authentication": ["password"],
37
+ "agents": true,
38
+ "chatStreaming": true,
39
+ "chatCancellation": true,
40
+ "history": true,
41
+ "localTools": true
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ 초기화 전에 다른 method를 부르면 `-32002` 오류가 반환됩니다.
48
+
49
+ ## Methods
50
+
51
+ ### Process
52
+
53
+ - `initialize({protocolVersion})`
54
+ - `health()`
55
+ - `shutdown()`
56
+ - `exit` notification
57
+
58
+ ### Profiles
59
+
60
+ - `profile/list()`
61
+ - `profile/set({name, serverUrl})`
62
+ - `profile/use({name})`
63
+
64
+ ### Authentication
65
+
66
+ - `auth/login({profile?, email, password})`
67
+ - `auth/status({profile?})`
68
+ - `auth/logout({profile?})`
69
+
70
+ `password`는 stdio frame 안에만 존재하고 저장되지 않습니다. 로그인 결과의 token은 응답에
71
+ 포함하지 않고 엔진이 OS keychain에 저장합니다.
72
+
73
+ ### Agents
74
+
75
+ ```json
76
+ {
77
+ "jsonrpc": "2.0",
78
+ "id": 10,
79
+ "method": "agents/list",
80
+ "params": {
81
+ "profile": "corp",
82
+ "page": 1,
83
+ "pageSize": 24,
84
+ "search": "sales",
85
+ "owner": "personal",
86
+ "includeHarness": true
87
+ }
88
+ }
89
+ ```
90
+
91
+ ### Local tools
92
+
93
+ - `localTools/status()`
94
+ - `localTools/list()`
95
+ - `localTools/configure({profile?, enabled?, cwd?, timeoutMs?, allowedRoots?, blockedCommands?, allowDangerous?})`
96
+ - `localTools/run({tool, args})`
97
+ - `localTools/start({profile?, waitMs?})`
98
+ - `localTools/stop()`
99
+
100
+ Bridge 연결 상태가 바뀌면 다음 notification을 전송합니다.
101
+
102
+ ```json
103
+ {"jsonrpc":"2.0","method":"localTools/status","params":{"running":true,"connected":true,"catalogSynced":true,"advertisedTools":6,"serverTools":6}}
104
+ ```
105
+
106
+ `localTools/configure`의 기본값은 `enabled:false`, `allowDangerous:false`입니다. 활성화된 stdio 엔진은
107
+ `/api/tools/ws/connector-mcp/{userId}`에 인증 WebSocket을 연결하고 `local` 서버의 도구를 광고합니다.
108
+
109
+ ### History
110
+
111
+ - `history/conversations({profile?})`
112
+ - `history/turns({profile?, workflowId, workflowName?, interactionId})`
113
+
114
+ ### Chat
115
+
116
+ Start request:
117
+
118
+ ```json
119
+ {
120
+ "jsonrpc": "2.0",
121
+ "id": 20,
122
+ "method": "chat/start",
123
+ "params": {
124
+ "profile": "corp",
125
+ "workflowId": "wf_abc",
126
+ "workflowName": "Sales Agent",
127
+ "interactionId": "optional-conversation-id",
128
+ "input": "hello"
129
+ }
130
+ }
131
+ ```
132
+
133
+ Start response:
134
+
135
+ ```json
136
+ {
137
+ "jsonrpc": "2.0",
138
+ "id": 20,
139
+ "result": {
140
+ "streamId": "b4df...",
141
+ "interactionId": "6fb9...",
142
+ "workflowId": "wf_abc",
143
+ "workflowName": "Sales Agent"
144
+ }
145
+ }
146
+ ```
147
+
148
+ Stream notification:
149
+
150
+ ```json
151
+ {"jsonrpc":"2.0","method":"chat/event","params":{"streamId":"b4df...","event":{"kind":"text","content":"안녕"}}}
152
+ ```
153
+
154
+ Terminal notifications:
155
+
156
+ ```json
157
+ {"jsonrpc":"2.0","method":"chat/complete","params":{"streamId":"b4df...","interactionId":"6fb9..."}}
158
+ {"jsonrpc":"2.0","method":"chat/error","params":{"streamId":"b4df...","error":{"code":"network_error","message":"..."}}}
159
+ ```
160
+
161
+ Cancel request:
162
+
163
+ ```json
164
+ {"jsonrpc":"2.0","id":21,"method":"chat/cancel","params":{"streamId":"b4df..."}}
165
+ ```
166
+
167
+ ## Errors
168
+
169
+ 표준 JSON-RPC 오류:
170
+
171
+ - `-32700`: parse error
172
+ - `-32600`: invalid request
173
+ - `-32601`: method not found
174
+ - `-32602`: invalid params
175
+ - `-32002`: initialize required
176
+ - `-32000`: engine error
177
+
178
+ Engine error의 안정적인 문자열 code는 `error.data.code`에 들어갑니다.
179
+
180
+ - `auth_required`
181
+ - `auth_invalid`
182
+ - `config_invalid`
183
+ - `credential_store_unavailable`
184
+ - `network_error`
185
+ - `not_found`
186
+ - `protocol_mismatch`
187
+ - `usage_error`
package/docs/TUI.md ADDED
@@ -0,0 +1,46 @@
1
+ # Dex terminal UI
2
+
3
+ ## 실행 조건
4
+
5
+ `dex`와 `dex ui`는 stdin/stdout이 모두 TTY이고 `TERM`이 `dumb`가 아니며 CI가 아닐 때 TUI를
6
+ 실행합니다. pipe, redirect, JSON 출력, `serve --stdio`는 기존 headless 경로를 사용합니다.
7
+
8
+ ## 첫 실행
9
+
10
+ 1. XGEN Gateway URL 입력
11
+ 2. `default` profile 생성
12
+ 3. 이메일과 비밀번호 로그인
13
+ 4. Agent 목록 로드
14
+ 5. 대시보드 진입
15
+
16
+ 비밀번호는 login 호출 직전에 컴포넌트 state에서 지우며 token은 기존과 동일하게 OS
17
+ keychain에만 저장합니다.
18
+
19
+ ## 대시보드
20
+
21
+ - 넓은 터미널: Agent 목록과 채팅을 좌우로 표시
22
+ - 좁은 터미널: `Tab`으로 Agent 목록과 채팅 화면 전환
23
+ - SSE `text` 이벤트는 현재 Assistant 메시지에 누적
24
+ - tool 이벤트는 실행 중/완료/실패 상태로 갱신
25
+ - node/status 이벤트는 채팅 하단 상태 줄에 표시
26
+ - `Esc`는 현재 `AbortController`를 취소
27
+ - 같은 interaction ID를 재사용해 대화를 이어감
28
+ - 로컬 도구가 활성화되어 있으면 첫 채팅 전에 도구 bridge와 카탈로그를 연결
29
+
30
+ ## 명령 팔레트
31
+
32
+ `Ctrl+K`:
33
+
34
+ - 새 대화
35
+ - 대화 기록
36
+ - profile 전환
37
+ - 로그아웃
38
+ - 종료
39
+
40
+ ## 터미널 안전성
41
+
42
+ - TUI 진입점은 dynamic import chunk로 분리
43
+ - 일반 CLI와 stdio RPC는 Ink를 로드하지 않음
44
+ - stdout protocol에 TUI 로그를 기록하지 않음
45
+ - Ctrl+C/Ctrl+Q/오류/unmount 시 cursor와 raw mode 복원
46
+ - `NO_COLOR` 환경은 Ink의 색상 비활성화 동작을 따름
package/docs/VSCODE.md ADDED
@@ -0,0 +1,41 @@
1
+ # VS Code extension architecture
2
+
3
+ `vscode-extension/`은 `dex-cli`를 로컬 엔진으로 사용하는 얇은 VS Code 클라이언트입니다.
4
+
5
+ ```text
6
+ VS Code Webview View
7
+
8
+ │ typed commands and state
9
+
10
+ Extension Host controller
11
+
12
+ │ JSON-RPC 2.0 over UTF-8 NDJSON
13
+
14
+ dex serve --stdio
15
+
16
+
17
+ DexEngine / OS keychain / XGEN
18
+ ```
19
+
20
+ ## 경계
21
+
22
+ - 확장은 XGEN HTTP/SSE endpoint를 직접 호출하지 않습니다.
23
+ - protocol version은 CLI와 동일한 `1`로 고정합니다.
24
+ - stdout은 protocol frame 전용이고 stderr는 `XGEN Dex` Output Channel로 전달합니다.
25
+ - profile, credential, 로컬 도구 설정의 실제 저장과 실행은 CLI가 소유합니다.
26
+ - 채팅 stream은 확장이 생성한 `streamId`로 notification을 라우팅합니다.
27
+
28
+ ## UI
29
+
30
+ - `xgenDex.chat`: Agent 선택, 스트리밍 채팅, 계정·회사/환경·로컬 도구 설정을 전환하는 단일 Webview View
31
+ - Status Bar: 현재 사용자, 로그인 필요, 오프라인, CLI 오류 상태
32
+ - Command Palette: profile, auth, history, engine lifecycle 명령
33
+
34
+ Webview는 서버 문자열을 `innerHTML`로 넣지 않고 `textContent`만 사용합니다. 입력창은 브라우저의
35
+ composition event와 `KeyboardEvent.isComposing`을 확인해 한글 조합 완료 Enter를 메시지 전송으로
36
+ 오인하지 않습니다.
37
+
38
+ 설정 화면의 로컬 도구 카드는 `localTools/status`, `localTools/configure`, `localTools/start` RPC만
39
+ 사용합니다. 활성화, 작업 폴더, 허용 경로, 차단 명령, 실행 제한 시간을 저장할 수 있고
40
+ `localTools/status` notification으로 브리지 연결 상태를 갱신합니다. 위험 명령 허용을 처음 켤 때는
41
+ VS Code의 modal 확인을 한 번 더 요구합니다.
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "xgen-dex-cli",
3
+ "version": "1.2.0",
4
+ "description": "XGEN Dex CLI — 터미널에서 XGEN 에이전트와 대화하고, 이 컴퓨터의 셸·파일·MCP 를 에이전트에게 빌려 줍니다.",
5
+ "type": "module",
6
+ "bin": {
7
+ "dex": "dist/cli.js",
8
+ "xgen-dex": "dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "docs"
14
+ ],
15
+ "scripts": {
16
+ "build": "node build.mjs",
17
+ "check": "tsc --noEmit -p tsconfig.json",
18
+ "test": "tsx --test test/args.test.ts test/config.test.ts test/engine.test.ts test/mode.test.ts test/rpc.test.ts test/tui-state.test.ts test/tui.test.tsx",
19
+ "verify": "npm run check && npm test && npm run build && node dist/cli.js --version",
20
+ "vscode:install": "npm --prefix vscode-extension install",
21
+ "vscode:verify": "npm --prefix vscode-extension run verify",
22
+ "verify:all": "npm run verify && npm run vscode:verify"
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "dependencies": {
28
+ "ink": "^6.8.0",
29
+ "keytar": "^7.9.0",
30
+ "react": "^19.2.0",
31
+ "string-width": "^8.2.2",
32
+ "ws": "^8.21.3"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.0.0",
36
+ "@types/react": "^19.2.0",
37
+ "@types/ws": "^8.18.1",
38
+ "esbuild": "^0.25.0",
39
+ "ink-testing-library": "^4.0.0",
40
+ "tsx": "^4.20.0",
41
+ "typescript": "^5.9.0"
42
+ },
43
+ "license": "Apache-2.0",
44
+ "homepage": "https://github.com/PlateerLab/xgen-dex-core",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/PlateerLab/xgen-dex-core.git",
48
+ "directory": "apps/cli"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/PlateerLab/xgen-dex-core/issues"
52
+ },
53
+ "keywords": [
54
+ "xgen",
55
+ "dex",
56
+ "agent",
57
+ "llm",
58
+ "cli",
59
+ "tui",
60
+ "mcp"
61
+ ],
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }