Commit 5694e18
committed
feat(nodejs): add includeNodeShims option to opt out of globalThis polyfills
Fixes #63 — adds ability to disable Node.js polyfill shims (fs, http,
process, Buffer, etc.) on globalThis.
When includeNodeShims: false is passed to createNodeRuntime():
- globalThis.fs, globalThis.http, globalThis.process, globalThis.Buffer
are NOT injected into the isolate
- Useful for AI agents that need a clean globalThis scope
- fs/http are still accessible via require('fs') / await import('fs')
when host filesystem is permitted via permissions
API:
createNodeRuntime({ includeNodeShims: false })
Default: true (existing behavior unchanged).
Changes:
- packages/nodejs/src/kernel-runtime.ts: Added includeNodeShims to NodeRuntimeOptions
- packages/nodejs/src/driver.ts: Added includeNodeShims to NodeDriverOptions, pass to runtime config
- packages/nodejs/src/execution-driver.ts: buildFullBridgeCode() now keyed by includeNodeShims
in a Map<boolean,string> cache; per-driver bridge code built in constructor
- packages/nodejs/test/kernel-runtime.test.ts: 3 new tests for includeNodeShims=false/true1 parent 6a7652a commit 5694e18
4 files changed
Lines changed: 106 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
143 | 147 | | |
144 | 148 | | |
145 | 149 | | |
| |||
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
154 | | - | |
155 | | - | |
| 158 | + | |
| 159 | + | |
156 | 160 | | |
157 | 161 | | |
158 | 162 | | |
| |||
765 | 769 | | |
766 | 770 | | |
767 | 771 | | |
768 | | - | |
| 772 | + | |
| 773 | + | |
769 | 774 | | |
770 | | - | |
771 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
772 | 778 | | |
773 | 779 | | |
774 | 780 | | |
| |||
778 | 784 | | |
779 | 785 | | |
780 | 786 | | |
781 | | - | |
782 | | - | |
783 | 787 | | |
784 | 788 | | |
785 | | - | |
786 | | - | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
787 | 799 | | |
788 | 800 | | |
789 | 801 | | |
| |||
853 | 865 | | |
854 | 866 | | |
855 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
856 | 873 | | |
857 | 874 | | |
858 | 875 | | |
| |||
893 | 910 | | |
894 | 911 | | |
895 | 912 | | |
| 913 | + | |
| 914 | + | |
896 | 915 | | |
897 | 916 | | |
898 | 917 | | |
| |||
1284 | 1303 | | |
1285 | 1304 | | |
1286 | 1305 | | |
1287 | | - | |
1288 | | - | |
| 1306 | + | |
| 1307 | + | |
1289 | 1308 | | |
1290 | 1309 | | |
1291 | 1310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
75 | 87 | | |
76 | 88 | | |
77 | 89 | | |
| |||
409 | 421 | | |
410 | 422 | | |
411 | 423 | | |
| 424 | + | |
412 | 425 | | |
413 | 426 | | |
414 | 427 | | |
| |||
417 | 430 | | |
418 | 431 | | |
419 | 432 | | |
| 433 | + | |
420 | 434 | | |
421 | 435 | | |
422 | 436 | | |
| |||
724 | 738 | | |
725 | 739 | | |
726 | 740 | | |
| 741 | + | |
727 | 742 | | |
728 | 743 | | |
729 | 744 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
969 | 969 | | |
970 | 970 | | |
971 | 971 | | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
0 commit comments