gm-qwen 2.0.1003 → 2.0.1005

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/bin/bootstrap.js CHANGED
@@ -117,29 +117,70 @@ function gmToolsDir() {
117
117
  // through node. Self-update inside the Rust binary keeps gm-tools fresh from
118
118
  // here on. Skipped silently on any error — the next session-start hook will
119
119
  // retry via ensure_tools_current.
120
- function copyToGmTools(finalPath, wrapperDir, version) {
120
+ function killHoldersOfPath(targetPath) {
121
+ if (process.platform !== 'win32') return 0;
121
122
  try {
122
- const dst = gmToolsDir();
123
- fs.mkdirSync(dst, { recursive: true });
124
- const exeName = process.platform === 'win32' ? 'plugkit.exe' : 'plugkit';
125
- const target = path.join(dst, exeName);
126
- const targetTmp = target + '.new';
127
- fs.copyFileSync(finalPath, targetTmp);
128
- try { fs.renameSync(targetTmp, target); }
129
- catch (err) {
130
- if (err.code === 'EEXIST' || err.code === 'EPERM' || err.code === 'EBUSY') {
131
- // target may be locked by a running plugkit; the .new file persists
132
- // and the in-Rust self-update will eventually swap it. Leave it.
133
- } else { throw err; }
123
+ const { spawnSync } = require('child_process');
124
+ const norm = path.resolve(targetPath).replace(/\//g, '\\');
125
+ const r = spawnSync('wmic', ['process', 'where', `ExecutablePath='${norm.replace(/\\/g, '\\\\')}'`, 'get', 'ProcessId', '/format:value'], { encoding: 'utf8', windowsHide: true, timeout: 5000 });
126
+ if (r.status !== 0 || !r.stdout) return 0;
127
+ const pids = [];
128
+ for (const line of r.stdout.split(/\r?\n/)) {
129
+ const m = line.match(/ProcessId=(\d+)/);
130
+ if (m) {
131
+ const pid = parseInt(m[1], 10);
132
+ if (Number.isFinite(pid) && pid !== process.pid) pids.push(pid);
133
+ }
134
134
  }
135
- if (process.platform !== 'win32') {
136
- try { fs.chmodSync(target, 0o755); } catch (_) {}
135
+ for (const pid of pids) {
136
+ try { spawnSync('taskkill', ['/F', '/PID', String(pid)], { windowsHide: true, timeout: 3000 }); } catch (_) {}
137
+ }
138
+ return pids.length;
139
+ } catch (_) { return 0; }
140
+ }
141
+
142
+ function cleanOrphanNewFiles(dst, exeName) {
143
+ try {
144
+ for (const name of fs.readdirSync(dst)) {
145
+ if (name === exeName + '.new') continue;
146
+ if (/^plugkit(\.\d+\.\d+\.\d+)?\.new$/i.test(name)) {
147
+ try { fs.unlinkSync(path.join(dst, name)); } catch (_) {}
148
+ }
137
149
  }
138
- fs.writeFileSync(path.join(dst, 'plugkit.version'), version);
139
- try {
140
- const srcSha = path.join(wrapperDir, 'plugkit.sha256');
141
- if (fs.existsSync(srcSha)) fs.copyFileSync(srcSha, path.join(dst, 'plugkit.sha256'));
142
- } catch (_) {}
150
+ } catch (_) {}
151
+ }
152
+
153
+ function renameWithRetry(src, dst, attempts) {
154
+ for (let i = 0; i < attempts; i++) {
155
+ try { fs.renameSync(src, dst); return true; }
156
+ catch (err) {
157
+ if (err.code !== 'EEXIST' && err.code !== 'EPERM' && err.code !== 'EBUSY' && err.code !== 'EACCES') throw err;
158
+ if (i === Math.floor(attempts / 2)) killHoldersOfPath(dst);
159
+ try { const { spawnSync } = require('child_process'); spawnSync(process.execPath, ['-e', 'setTimeout(()=>{}, 200)'], { timeout: 400, killSignal: 'SIGKILL', stdio: 'ignore', windowsHide: true }); } catch (_) {}
160
+ }
161
+ }
162
+ return false;
163
+ }
164
+
165
+ function copyToGmTools(finalPath, wrapperDir, version) {
166
+ const dst = gmToolsDir();
167
+ fs.mkdirSync(dst, { recursive: true });
168
+ const exeName = process.platform === 'win32' ? 'plugkit.exe' : 'plugkit';
169
+ const target = path.join(dst, exeName);
170
+ const targetTmp = target + '.new';
171
+ cleanOrphanNewFiles(dst, exeName);
172
+ fs.copyFileSync(finalPath, targetTmp);
173
+ if (!renameWithRetry(targetTmp, target, 8)) {
174
+ obsEvent('bootstrap', 'gmtools.rename.failed', { target });
175
+ throw new Error(`gm-tools update blocked: cannot replace ${target} (held open by running plugkit and kill-retry exhausted)`);
176
+ }
177
+ if (process.platform !== 'win32') {
178
+ try { fs.chmodSync(target, 0o755); } catch (_) {}
179
+ }
180
+ fs.writeFileSync(path.join(dst, 'plugkit.version'), version);
181
+ try {
182
+ const srcSha = path.join(wrapperDir, 'plugkit.sha256');
183
+ if (fs.existsSync(srcSha)) fs.copyFileSync(srcSha, path.join(dst, 'plugkit.sha256'));
143
184
  } catch (_) {}
144
185
  }
145
186
 
@@ -804,6 +845,19 @@ if (require.main === module) {
804
845
  } else {
805
846
  bootstrap({ silent: false })
806
847
  .then(p => { process.stdout.write(p + '\n'); process.exit(0); })
807
- .catch(err => { log(`FATAL: ${err.message}`); obsEvent('bootstrap', 'fatal', { err: String(err.message || err) }); process.exit(1); });
848
+ .catch(err => {
849
+ log(`FATAL: ${err.message}`);
850
+ obsEvent('bootstrap', 'fatal', { err: String(err.message || err) });
851
+ try {
852
+ const pinned = (() => { try { return readVersionFile(__dirname); } catch (_) { return null; } })();
853
+ writeBootstrapError({
854
+ expected_version: pinned,
855
+ cached_version: null,
856
+ error_phase: 'fatal',
857
+ error_message: String(err && err.message || err),
858
+ });
859
+ } catch (_) {}
860
+ process.exit(1);
861
+ });
808
862
  }
809
863
  }
@@ -1,6 +1,6 @@
1
- ded2baea3ead59fdb3aeb48da152b91ff952dcf321e6e4cc9e50951ffe8bb0b2 plugkit-win32-x64.exe
2
- 37c30e7579836b087ea6c19ed2ac694bfd9d7bcf95fe8212ced72fc4072b3219 plugkit-win32-arm64.exe
3
- aa331a65ff82a114f0816e87cd5464de657185eacbcccd94706def5eb37bfc59 plugkit-darwin-x64
4
- 3baa75d7d4c888d83da761953528039291595af723daca767da71566ebe5130c plugkit-darwin-arm64
5
- a8bb8a788b041e893dff89b46b2340a64dbfefec46b9a3d98e9608a25b9cff2a plugkit-linux-x64
6
- 9c0173503648395fd60d889bd8302bbfb92eed62425a2646f6a4a87d54d87c68 plugkit-linux-arm64
1
+ 16e6db40c8c253d7e6e6130070f0c1bcc4ae9566b2a12f18214f2284d0a50ba1 plugkit-win32-x64.exe
2
+ cc876baabd7de371c494f8ba2b4d29f20974e31f65dcf1f8303c20e3753187ab plugkit-win32-arm64.exe
3
+ a8dbdb919381a80c1087cb4f3c7ed4fc61fc82a2b501cb55dc8a51caf97d5eab plugkit-darwin-x64
4
+ 5df1ad1f15bbe90c40c8f8897e595812f30253f655a01865cfc1b4a86cd223a8 plugkit-darwin-arm64
5
+ 5c695dc8a51617ad0dfb66c14a6f393de63e53725d637c056a1af891a0a42505 plugkit-linux-x64
6
+ 089c39c517a095a050df5c27ab053ccf4045064557d9e484e2948f46e05e37ea plugkit-linux-arm64
@@ -1 +1 @@
1
- 0.1.349
1
+ 0.1.350
package/bin/rtk.sha256 CHANGED
@@ -1,5 +1,5 @@
1
- 33bd74c9f35b2a42f97241efb53de527316ba156fd036b2f4c6206b63c84efe2 rtk-win32-x64.exe
2
- 54691a2b1729c40507d87a123c0c17a86c2de0e1f5ae6b18b666bbaaa072065c rtk-win32-arm64.exe
1
+ 945cb97379ce6df270f31cb4a9ff8e27af8671b187929edcd6892770a13e8467 rtk-win32-x64.exe
2
+ 7e848a986e8638ee005fe6f3b767eeca922d2fe09f5e28f024a729214e2266d6 rtk-win32-arm64.exe
3
3
  1b1e792767ed0e1e6ca0e2f0a8de02e77b06dea2f5ae667278b94baf239fcdc3 rtk-darwin-x64
4
4
  9717978d9d6216ea50c94444e00e359479b6315a17bd48c16064b267c8b0b60d rtk-darwin-arm64
5
5
  a100d3defac54194144e5723aec57e6f286b42298c67145c8428815246c9ee56 rtk-linux-x64
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1003",
3
+ "version": "2.0.1005",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -23,5 +23,5 @@
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
26
- "plugkitVersion": "0.1.349"
26
+ "plugkitVersion": "0.1.350"
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-qwen",
3
- "version": "2.0.1003",
3
+ "version": "2.0.1005",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",