@trim21/personal-pi-extensions 0.1.659 → 0.1.661

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.1.659",
3
+ "version": "0.1.661",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -104,10 +104,15 @@ export const PRELUDE_SOURCE = String.raw`(function (bridge, toolsJson, storeJson
104
104
  Object.freeze(allTools);
105
105
 
106
106
  // key -> JSON 文本;容量按 key 与 JSON 的字符数计
107
- const stored = new Map(Object.entries(parse(storeJson)));
107
+ const stored = new Map();
108
108
  const writes = new Map();
109
109
  let storedChars = 0;
110
- for (const [key, json] of stored) storedChars += key.length + json.length;
110
+ for (const [key, value] of Object.entries(parse(storeJson))) {
111
+ const json = stringify(value);
112
+ if (json === undefined) continue;
113
+ stored.set(key, json);
114
+ storedChars += key.length + json.length;
115
+ }
111
116
 
112
117
  function checkKey(name, key) {
113
118
  if (typeof key !== "string") throw new TypeErrorCtor(name + "() key must be a string");
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * 沙箱就是 QuickJS VM 本身(VM 里没有 node、文件、网络、timer),脚本唯一的出口是
5
5
  * 注入的工具,而这些工具由主线程执行——所以这里只做三件事:把注册时编译好的 wasm
6
- * 与脚本交给 worker、转发脚本的嵌套调用与输出、在结束/超时/中止时 `terminate()`。
6
+ * 与脚本交给 worker、转发脚本的嵌套调用与输出、在结束或中止时 `terminate()`。
7
7
  *
8
- * worker 一次执行一个:死循环脚本由主线程 terminate 掉,连同它那份 VM 一起丢弃,
9
- * 不会污染后续执行,也不需要取消协议。
8
+ * worker 一次执行一个:脚本没有超时,死循环由调用方中止后 terminate 掉,连同它那份
9
+ * VM 一起丢弃,不会污染后续执行,也不需要取消协议。
10
10
  */
11
11
 
12
12
  import { Worker } from "node:worker_threads";
@@ -89,10 +89,15 @@ var PRELUDE_SOURCE = String.raw`(function (bridge, toolsJson, storeJson) {
89
89
  Object.freeze(allTools);
90
90
 
91
91
  // key -> JSON 文本;容量按 key 与 JSON 的字符数计
92
- const stored = new Map(Object.entries(parse(storeJson)));
92
+ const stored = new Map();
93
93
  const writes = new Map();
94
94
  let storedChars = 0;
95
- for (const [key, json] of stored) storedChars += key.length + json.length;
95
+ for (const [key, value] of Object.entries(parse(storeJson))) {
96
+ const json = stringify(value);
97
+ if (json === undefined) continue;
98
+ stored.set(key, json);
99
+ storedChars += key.length + json.length;
100
+ }
96
101
 
97
102
  function checkKey(name, key) {
98
103
  if (typeof key !== "string") throw new TypeErrorCtor(name + "() key must be a string");