zames_pro 2.4.7 → 2.5.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.
package/README.md CHANGED
@@ -9,14 +9,21 @@ directory, reads and edits files, runs commands, and commits to git.
9
9
  ## Requirements
10
10
 
11
11
  - Node.js >= 18
12
- - Google Chrome or Chromium (used through Playwright)
13
12
  - A DeepSeek account (you log in manually in the browser window that opens on first launch)
14
13
 
15
14
  ## Installation
16
15
 
17
16
  ```bash
18
17
  npm install -g zames_pro
18
+ ```
19
+
20
+ Chromium for Playwright is downloaded automatically on install. On Linux/WSL
21
+ the required system libraries are installed too when passwordless `sudo` is
22
+ available; otherwise run once by hand:
23
+
24
+ ```bash
19
25
  npx playwright install chromium
26
+ sudo npx playwright install-deps chromium
20
27
  ```
21
28
 
22
29
  ## Usage
@@ -79,7 +79,14 @@ export async function runAgentLoop({ browser, tools, task, workdir, maxIteration
79
79
  }
80
80
  }
81
81
  if (!parsed) {
82
- const looksLikeToolCall = /("tool"\s*:|\btool_calls?\b|\binvoke\b|\bparameter\b|DSML|function_call)/i.test(rawResponse) || /\{\s*"?(tool|name)"?\s*:/.test(rawResponse);
82
+ // Ответ похож на (возможно, обрезанный) вызов инструмента. Ловим не
83
+ // только явный JSON, но и XML/DSML-формы, «грязные» варианты и
84
+ // незакрытые фрагменты: если такой ответ молча принять за финальный,
85
+ // агент встанет, хотя модель пыталась позвать инструмент.
86
+ const looksLikeToolCall = /("tool"\s*:|\btool_calls?\b|\binvoke\b|\bparameter\b|DSML|function_call)/i.test(rawResponse) ||
87
+ /\{\s*"?(tool|name|args)"?\s*:/.test(rawResponse) ||
88
+ /<\s*\|?\s*(DSML|invoke|parameter)/i.test(rawResponse) ||
89
+ /^\s*\[?\s*\{[^}]*$/.test(rawResponse.trim());
83
90
  if (looksLikeToolCall && malformedRetries < MAX_MALFORMED_RETRIES) {
84
91
  malformedRetries++;
85
92
  transcript?.log('malformed_toolcall', {
@@ -134,6 +141,25 @@ export async function runAgentLoop({ browser, tools, task, workdir, maxIteration
134
141
  const msg = typeof respondCall.args.message === 'string'
135
142
  ? respondCall.args.message
136
143
  : String(respondCall.args.message ?? '');
144
+ // Пустой respond — не финал: модель позвала respond, но не написала
145
+ // итог. Если так завершить, оператор не увидит ничего, а задача
146
+ // «зависнет». Просим продолжить (в пределах stallRetries).
147
+ if (!msg.trim() && stallRetries < MAX_STALL_RETRIES) {
148
+ stallRetries++;
149
+ transcript?.log('empty_respond', { attempt: stallRetries });
150
+ if (debugLog) {
151
+ console.error('внимание: пустой respond, прошу продолжить (попытка ' +
152
+ stallRetries +
153
+ '/' +
154
+ MAX_STALL_RETRIES +
155
+ ')');
156
+ }
157
+ message =
158
+ 'Ты вызвал respond с пустым message. Если задача выполнена — ' +
159
+ 'вызови respond с итоговым сообщением оператору. Если нет — ' +
160
+ 'продолжи работу вызовом инструмента.';
161
+ continue;
162
+ }
137
163
  onAssistantMessage(msg);
138
164
  transcript?.log('assistant_final', { message: msg });
139
165
  return msg;
package/dist/tools.js CHANGED
@@ -115,7 +115,7 @@ export function createTools(workdir, { undo } = {}) {
115
115
  await undo.backup(file);
116
116
  await fs.mkdir(path.dirname(file), { recursive: true });
117
117
  await fs.writeFile(file, text, 'utf-8');
118
- return `Файл записан: {p}`;
118
+ return `Файл записан: ${p}`;
119
119
  },
120
120
  },
121
121
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zames_pro",
3
- "version": "2.4.7",
3
+ "version": "2.5.0",
4
4
  "description": "Terminal coding agent over chat.deepseek.com via Playwright",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
+ "scripts",
11
12
  "README.md",
12
13
  "LICENSE",
13
14
  "logo.png"
@@ -20,6 +21,7 @@
20
21
  "prepublishOnly": "npm run build",
21
22
  "test": "tsx --test test/*.test.ts",
22
23
  "test:watch": "tsx --test --watch test/*.test.ts",
24
+ "postinstall": "node scripts/postinstall.mjs",
23
25
  "prepare": "husky"
24
26
  },
25
27
  "keywords": [
@@ -0,0 +1,67 @@
1
+ // Automatically install the Chromium build and system dependencies
2
+ // that Playwright needs.
3
+ //
4
+ // Runs when the zames package is installed so the user does not have to run
5
+ // "npx playwright install chromium" / "install-deps chromium" by hand.
6
+ //
7
+ // On Linux (including WSL) the browser binary also needs system libraries.
8
+ // They are installed via "install-deps", which requires root (sudo).
9
+ // If we are not root and sudo is not passwordless, we skip it and tell the
10
+ // user the exact command to run.
11
+ //
12
+ // Install failure is NOT fatal: without network access (or in CI) the
13
+ // package install must still succeed.
14
+
15
+ import { spawnSync } from 'node:child_process'
16
+
17
+ const isWin = process.platform === 'win32'
18
+
19
+ // npm puts node_modules/.bin on PATH for lifecycle scripts, so the local
20
+ // playwright CLI is resolvable. On Windows npm runs scripts through cmd.exe,
21
+ // so shell: true is needed for the .cmd shim to be found.
22
+ function run(cmd, args) {
23
+ return spawnSync(cmd, args, {
24
+ stdio: 'inherit',
25
+ shell: isWin,
26
+ })
27
+ }
28
+
29
+ function canSudo() {
30
+ // Already root? No sudo needed.
31
+ if (typeof process.getuid === 'function' && process.getuid() === 0) return true
32
+ // Passwordless sudo (common in WSL / CI images).
33
+ const r = run('sudo', ['-n', 'true'])
34
+ return !r.error && r.status === 0
35
+ }
36
+
37
+ // 1) Browser binary for this Playwright version.
38
+ const browser = run('playwright', ['install', 'chromium'])
39
+ if (browser.error || browser.status !== 0) {
40
+ console.warn(
41
+ '\nzames: could not install Chromium for Playwright automatically.\n' +
42
+ ' Run it manually: npx playwright install chromium\n',
43
+ )
44
+ process.exit(0)
45
+ }
46
+
47
+ // 2) System libraries (Linux / WSL only). Without them Chromium fails
48
+ // to launch with "error while loading shared libraries".
49
+ if (!isWin) {
50
+ if (canSudo()) {
51
+ const deps = run('playwright', ['install-deps', 'chromium'])
52
+ if (deps.error || deps.status !== 0) {
53
+ console.warn(
54
+ '\nzames: could not install Chromium system dependencies automatically.\n' +
55
+ ' Run it manually: sudo npx playwright install-deps chromium\n',
56
+ )
57
+ }
58
+ } else {
59
+ console.warn(
60
+ '\nzames: on Linux/WSL Chromium needs system libraries (sudo required).\n' +
61
+ ' Run it once manually: sudo npx playwright install-deps chromium\n',
62
+ )
63
+ }
64
+ }
65
+
66
+ // Never fail the package install because of a browser download.
67
+ process.exit(0)