lcagent-cli 0.1.4 → 0.1.5

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
@@ -165,4 +165,4 @@ npm run start -- doctor
165
165
  npm run start -- doctor
166
166
  ```
167
167
 
168
- `doctor` 会额外探测多个端点(如 `/v1`、`/v1/models`、`/v1/chat/completions`),并尽量打印底层网络错误,方便区分 DNS、TCP 超时、HTTP 返回和认证问题。
168
+ `doctor` 会额外探测多个端点(如 `/v1`、`/v1/models`、`/v1/chat/completions`),并尽量打印底层网络错误;对于 OpenAI-compatible 服务,还会额外检查 tool calling 是否真的返回 `tool_calls`。
package/dist/bin/cli.js CHANGED
@@ -7,6 +7,7 @@ import { fetch } from '../core/http.js';
7
7
  import { agentConfigSchema } from '../config/schema.js';
8
8
  import { getConfigPath, loadConfig, updateConfig } from '../config/store.js';
9
9
  import { getDefaultTools } from '../tools/registry.js';
10
+ import { toOpenAICompatibleTool } from '../tools/types.js';
10
11
  function trimTrailingSlash(value) {
11
12
  return value.replace(/\/+$/, '');
12
13
  }
@@ -80,6 +81,55 @@ async function runJsonProbe(params) {
80
81
  console.log(` failed: ${formatError(error)}`);
81
82
  }
82
83
  }
84
+ async function runOpenAIToolCallingProbe(params) {
85
+ const tool = toOpenAICompatibleTool(getDefaultTools()[0]);
86
+ console.log(`- POST /v1/chat/completions (tool calling): ${params.url}`);
87
+ try {
88
+ const response = await fetchWithTimeout(params.url, {
89
+ method: 'POST',
90
+ headers: {
91
+ 'content-type': 'application/json',
92
+ ...(params.apiKey ? { Authorization: `Bearer ${params.apiKey}` } : {}),
93
+ },
94
+ body: JSON.stringify({
95
+ model: params.model,
96
+ messages: [
97
+ {
98
+ role: 'user',
99
+ content: 'Call the read_file tool with path set to README.md. Do not answer with plain text only.',
100
+ },
101
+ ],
102
+ tools: [tool],
103
+ tool_choice: 'auto',
104
+ max_tokens: 128,
105
+ }),
106
+ }, 8000);
107
+ const text = await response.text();
108
+ console.log(` HTTP ${response.status}`);
109
+ console.log(` preview: ${text.slice(0, 300) || '(empty body)'}`);
110
+ try {
111
+ const parsed = JSON.parse(text);
112
+ const toolCalls = parsed.choices?.[0]?.message?.tool_calls;
113
+ if (Array.isArray(toolCalls) && toolCalls.length > 0) {
114
+ console.log(` tool calling: supported (${toolCalls.length} tool call returned)`);
115
+ }
116
+ else {
117
+ const finishReason = parsed.choices?.[0]?.finish_reason ?? 'unknown';
118
+ const content = parsed.choices?.[0]?.message?.content ?? '';
119
+ console.log(` tool calling: no tool_calls returned (finish_reason=${finishReason})`);
120
+ if (content) {
121
+ console.log(` assistant content: ${String(content).slice(0, 160)}`);
122
+ }
123
+ }
124
+ }
125
+ catch {
126
+ console.log(' tool calling: unable to parse JSON response body');
127
+ }
128
+ }
129
+ catch (error) {
130
+ console.log(` failed: ${formatError(error)}`);
131
+ }
132
+ }
83
133
  async function runDoctor() {
84
134
  const config = await loadConfig();
85
135
  const apiKey = config.apiKey ??
@@ -124,6 +174,11 @@ async function runDoctor() {
124
174
  max_tokens: 8,
125
175
  }),
126
176
  });
177
+ await runOpenAIToolCallingProbe({
178
+ url: `${trimmedBaseUrl}/chat/completions`,
179
+ apiKey,
180
+ model: config.model,
181
+ });
127
182
  return;
128
183
  }
129
184
  await runJsonProbe({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lcagent-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "A minimal coding agent CLI for terminal-based coding workflows.",
5
5
  "type": "module",
6
6
  "publishConfig": {