@jsonstudio/rcc 0.89.935 → 0.89.1083
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 +1 -42
- package/dist/build-info.js +2 -2
- package/dist/build-info.js.map +1 -1
- package/dist/cli.js +120 -16
- package/dist/cli.js.map +1 -1
- package/dist/commands/quota-daemon.d.ts +2 -0
- package/dist/commands/quota-daemon.js +89 -0
- package/dist/commands/quota-daemon.js.map +1 -0
- package/dist/commands/token-daemon.js +1 -1
- package/dist/commands/token-daemon.js.map +1 -1
- package/dist/docs/daemon-admin-ui.html +958 -0
- package/dist/index.js +54 -4
- package/dist/index.js.map +1 -1
- package/dist/manager/modules/quota/index.d.ts +34 -0
- package/dist/manager/modules/quota/index.js +291 -0
- package/dist/manager/modules/quota/index.js.map +1 -1
- package/dist/manager/modules/token/index.js +14 -3
- package/dist/manager/modules/token/index.js.map +1 -1
- package/dist/manager/quota/provider-quota-center.d.ts +48 -0
- package/dist/manager/quota/provider-quota-center.js +239 -0
- package/dist/manager/quota/provider-quota-center.js.map +1 -0
- package/dist/manager/quota/provider-quota-store.d.ts +17 -0
- package/dist/manager/quota/provider-quota-store.js +88 -0
- package/dist/manager/quota/provider-quota-store.js.map +1 -0
- package/dist/providers/auth/token-scanner/index.js +11 -3
- package/dist/providers/auth/token-scanner/index.js.map +1 -1
- package/dist/providers/core/runtime/http-request-executor.js +24 -7
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
- package/dist/providers/core/runtime/http-transport-provider.js +11 -3
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/responses-provider.js +9 -3
- package/dist/providers/core/runtime/responses-provider.js.map +1 -1
- package/dist/providers/core/utils/http-client.d.ts +1 -0
- package/dist/providers/core/utils/http-client.js +139 -4
- package/dist/providers/core/utils/http-client.js.map +1 -1
- package/dist/providers/core/utils/snapshot-writer.d.ts +12 -0
- package/dist/providers/core/utils/snapshot-writer.js +99 -18
- package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
- package/dist/providers/mock/mock-provider-runtime.d.ts +3 -0
- package/dist/providers/mock/mock-provider-runtime.js +176 -4
- package/dist/providers/mock/mock-provider-runtime.js.map +1 -1
- package/dist/server/handlers/chat-handler.js +13 -1
- package/dist/server/handlers/chat-handler.js.map +1 -1
- package/dist/server/handlers/handler-utils.js +5 -0
- package/dist/server/handlers/handler-utils.js.map +1 -1
- package/dist/server/handlers/messages-handler.js +13 -1
- package/dist/server/handlers/messages-handler.js.map +1 -1
- package/dist/server/handlers/responses-handler.js +73 -1
- package/dist/server/handlers/responses-handler.js.map +1 -1
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js +174 -2
- package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js.map +1 -1
- package/dist/server/runtime/http-server/daemon-admin/providers-handler.js +519 -0
- package/dist/server/runtime/http-server/daemon-admin/providers-handler.js.map +1 -1
- package/dist/server/runtime/http-server/executor-response.js +6 -0
- package/dist/server/runtime/http-server/executor-response.js.map +1 -1
- package/dist/server/runtime/http-server/index.d.ts +5 -0
- package/dist/server/runtime/http-server/index.js +205 -4
- package/dist/server/runtime/http-server/index.js.map +1 -1
- package/dist/server/runtime/http-server/middleware.d.ts +2 -0
- package/dist/server/runtime/http-server/middleware.js +63 -0
- package/dist/server/runtime/http-server/middleware.js.map +1 -1
- package/dist/server/runtime/http-server/request-executor.d.ts +2 -0
- package/dist/server/runtime/http-server/request-executor.js +57 -10
- package/dist/server/runtime/http-server/request-executor.js.map +1 -1
- package/dist/server/runtime/http-server/routes.js +38 -1
- package/dist/server/runtime/http-server/routes.js.map +1 -1
- package/dist/server/runtime/http-server/stats-manager.d.ts +55 -0
- package/dist/server/runtime/http-server/stats-manager.js +462 -4
- package/dist/server/runtime/http-server/stats-manager.js.map +1 -1
- package/dist/server/runtime/http-server/types.d.ts +1 -0
- package/dist/token-daemon/token-daemon.d.ts +3 -1
- package/dist/token-daemon/token-daemon.js +130 -8
- package/dist/token-daemon/token-daemon.js.map +1 -1
- package/dist/token-daemon/token-utils.d.ts +1 -0
- package/dist/token-daemon/token-utils.js +9 -1
- package/dist/token-daemon/token-utils.js.map +1 -1
- package/dist/tools/semantic-replay.js +29 -0
- package/dist/tools/semantic-replay.js.map +1 -1
- package/dist/utils/snapshot-writer.d.ts +2 -0
- package/dist/utils/snapshot-writer.js +47 -4
- package/dist/utils/snapshot-writer.js.map +1 -1
- package/package.json +2 -3
- package/scripts/analyze-apply-patch-exec-failures.mjs +153 -0
- package/scripts/analyze-apply-patch-samples.mjs +242 -0
- package/scripts/analyze-codex-error-failures.mjs +24 -14
- package/scripts/classify-codex-samples.mjs +0 -35
- package/scripts/copy-modules-config.mjs +17 -1
- package/scripts/generate-snapshot-data.mjs +41 -11
- package/scripts/mock-provider/extract.mjs +254 -21
- package/scripts/mock-provider/run-regressions.mjs +97 -16
- package/scripts/quota-dryrun.mjs +124 -0
- package/scripts/tests/apply-patch-loop.mjs +5 -1
- package/scripts/tests/exec-command-loop.mjs +16 -19
- package/scripts/verify-apply-patch.mjs +335 -5
- package/scripts/verify-e2e-toolcall.mjs +49 -10
- package/scripts/toon-suite.mjs +0 -141
package/scripts/toon-suite.mjs
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// TOON tool-call probe: sends Chat requests that require arguments.toon, decodes via @toon-format/cli, and summarizes results.
|
|
3
|
-
|
|
4
|
-
import fetch from 'node-fetch';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
|
|
7
|
-
function arg(k, d){ const i=process.argv.indexOf(k); return (i>0 && process.argv[i+1]) ? process.argv[i+1] : d; }
|
|
8
|
-
function flag(k){ return process.argv.includes(k); }
|
|
9
|
-
|
|
10
|
-
const server = arg('--server', 'http://127.0.0.1:5520');
|
|
11
|
-
const endpoint = arg('--endpoint', '/v1/chat/completions');
|
|
12
|
-
const url = `${server.replace(/\/$/,'')}${endpoint}`;
|
|
13
|
-
const model = arg('--model', 'glm.glm-4.6');
|
|
14
|
-
const doExec = flag('--exec'); // optional local execution (unsafe; whitelist only)
|
|
15
|
-
|
|
16
|
-
const systemMsg = (
|
|
17
|
-
'当你使用工具 (tool_calls) 时,将 function.arguments 设为 JSON 字符串,且只包含字段 toon(字符串,多行 TOON)。' +
|
|
18
|
-
'不要输出其它字段、不要解释。' +
|
|
19
|
-
'示例:{"toon": "command: bash -lc \'echo ok\'\\nworkdir: .\\n"}。' +
|
|
20
|
-
'务必返回 tool_calls,并仅填充 arguments.toon。'
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const tools = [
|
|
24
|
-
{
|
|
25
|
-
type: 'function',
|
|
26
|
-
function: {
|
|
27
|
-
name: 'shell_toon',
|
|
28
|
-
description: 'TOON 参数承载:将所有参数用 TOON 字符串放入 arguments.toon',
|
|
29
|
-
parameters: {
|
|
30
|
-
type: 'object',
|
|
31
|
-
properties: { toon: { type: 'string', description: 'TOON-encoded arguments' } },
|
|
32
|
-
required: ['toon'],
|
|
33
|
-
additionalProperties: false
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
const cases = [
|
|
40
|
-
{
|
|
41
|
-
title: 'find_parens_exec',
|
|
42
|
-
user: "请使用 shell_toon:bash -lc 执行:find . -type f \\( -name '*.md' -o -name '*.txt' \\) -exec basename {} \\; | sort -u | head -n 5。只返回 tool_calls。"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
title: 'awk_regex',
|
|
46
|
-
user: "请用 shell_toon:bash -lc 执行:printf 'alpha,error\\nbeta,ok\\n' | awk -F, '{ if (\\$2 ~ /error/) print \\$1 }'。只返回 tool_calls。"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
title: 'sed_replace',
|
|
50
|
-
user: "请用 shell_toon:bash -lc 执行:printf 'a=1\\nb=2\\n' | sed -E 's/([ab])=(\\\\d+)/\\\\1: \\\\2/g'。只返回 tool_calls。"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
title: 'python_heredoc',
|
|
54
|
-
user: `请用 shell_toon:构造“单行” bash -lc 命令来执行多行 Python。禁止在命令中出现真实换行符;改用 ANSI-C 风格 $'...' 在“一行内”嵌入换行(\\n)。示例(仅示意):bash -lc $'python3 - <<\'PY\'\\nprint(1)\\nPY'。实际请输出:用 $'...' 方式在一行内执行 python3 - <<'PY' 的多行脚本:\nimport json\nprint(json.dumps({"ok": true, "sum": 1+2+3}))\n并保持整条命令为一行。只返回 tool_calls。`
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
title: 'xargs_space',
|
|
58
|
-
user: "请用 shell_toon:bash -lc 执行:printf 'A B.md\\nC D.md\\n' | xargs -I{} bash -lc 'echo \"{}\" | tr \" \" _'。只返回 tool_calls。"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
title: 'grep_sort_uniq',
|
|
62
|
-
user: "请用 shell_toon:bash -lc 执行:printf 'a\\nb\\na\\nc\\n' | grep -E '[a-c]' | sort | uniq -c | sort -nr。只返回 tool_calls。"
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
function decodeToon(toonStr){
|
|
67
|
-
const res = spawnSync('npx', ['-y','@toon-format/cli','--decode'], { input: toonStr, encoding: 'utf-8' });
|
|
68
|
-
if ((res.status ?? 0) !== 0) return { ok: false, error: res.stderr || 'decode failed' };
|
|
69
|
-
try { const obj = JSON.parse(res.stdout || '{}'); return { ok: true, value: obj }; } catch (e){ return { ok: false, error: 'json parse failed', raw: res.stdout }; }
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function safeExec(cmd){
|
|
73
|
-
const allow = /^(bash\s+-lc\s+).*/s.test(cmd) && /(find|printf|awk|sed|python3|ls|sort|head|uniq|tr)/.test(cmd);
|
|
74
|
-
if (!allow) return { ok: false, skipped: true };
|
|
75
|
-
const res = spawnSync('bash', ['-lc', cmd], { encoding: 'utf-8' });
|
|
76
|
-
return {
|
|
77
|
-
ok: true,
|
|
78
|
-
code: res.status ?? 0,
|
|
79
|
-
stdout: (res.stdout || '').split('\n').slice(0, 20).join('\n'),
|
|
80
|
-
stderr: (res.stderr || '').split('\n').slice(0, 20).join('\n')
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async function runCase(c){
|
|
85
|
-
const payload = {
|
|
86
|
-
model,
|
|
87
|
-
stream: false,
|
|
88
|
-
tool_choice: { type: 'function', function: { name: 'shell_toon' } },
|
|
89
|
-
messages: [ { role: 'system', content: systemMsg }, { role: 'user', content: c.user } ],
|
|
90
|
-
tools
|
|
91
|
-
};
|
|
92
|
-
const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
|
93
|
-
let body; try { body = await res.json(); } catch { return { title: c.title, status: 'http_error', note: res.statusText }; }
|
|
94
|
-
const msg = body?.choices?.[0]?.message;
|
|
95
|
-
const argStr = msg?.tool_calls?.[0]?.function?.arguments;
|
|
96
|
-
if (typeof argStr !== 'string') return { title: c.title, status: 'no_arguments' };
|
|
97
|
-
let argumentsObj; try { argumentsObj = JSON.parse(argStr); } catch { return { title: c.title, status: 'arguments_not_json' }; }
|
|
98
|
-
const toon = argumentsObj?.toon;
|
|
99
|
-
if (typeof toon !== 'string' || !toon.trim()) return { title: c.title, status: 'no_toon' };
|
|
100
|
-
const decoded = decodeToon(toon);
|
|
101
|
-
if (!decoded.ok) return { title: c.title, status: 'toon_decode_fail', note: decoded.error };
|
|
102
|
-
const cmd = decoded.value?.command;
|
|
103
|
-
let execRes = undefined;
|
|
104
|
-
if (doExec && typeof cmd === 'string' && cmd.trim()) execRes = safeExec(cmd);
|
|
105
|
-
return { title: c.title, status: 'ok', toon, decoded: decoded.value, exec: execRes };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function main(){
|
|
109
|
-
console.log(`TOON probe → ${url} model=${model} exec=${doExec?'on':'off'}`);
|
|
110
|
-
const results = [];
|
|
111
|
-
for (const c of cases) {
|
|
112
|
-
try {
|
|
113
|
-
const r = await runCase(c);
|
|
114
|
-
results.push(r);
|
|
115
|
-
console.log(`\n=== ${c.title} ===`);
|
|
116
|
-
console.log(`status: ${r.status}`);
|
|
117
|
-
if (r.status === 'ok') {
|
|
118
|
-
const preview = String(r.toon).split('\n').slice(0,4).join('\n');
|
|
119
|
-
console.log('toon:\n' + preview);
|
|
120
|
-
console.log('decoded:', JSON.stringify(r.decoded));
|
|
121
|
-
if (r.exec && r.exec.ok) {
|
|
122
|
-
console.log('exec code:', r.exec.code);
|
|
123
|
-
console.log('stdout:\n' + r.exec.stdout);
|
|
124
|
-
if (r.exec.stderr) console.log('stderr:\n' + r.exec.stderr);
|
|
125
|
-
}
|
|
126
|
-
} else if (r.note) {
|
|
127
|
-
console.log('note:', r.note);
|
|
128
|
-
}
|
|
129
|
-
} catch (e) {
|
|
130
|
-
results.push({ title: c.title, status: 'exception', note: e?.message || String(e) });
|
|
131
|
-
console.log(`\n=== ${c.title} ===`);
|
|
132
|
-
console.log('status: exception');
|
|
133
|
-
console.log('note:', e?.message || String(e));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const ok = results.filter(x=>x.status==='ok').length;
|
|
137
|
-
console.log('\nSUMMARY:', `${ok}/${results.length} ok`);
|
|
138
|
-
for (const r of results) console.log(`- ${r.title}: ${r.status}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
main().catch(e=>{ console.error('fatal:', e?.message || e); process.exit(1); });
|