@cortexkit/pi-magic-context 0.44.4 → 0.46.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.
Files changed (41) hide show
  1. package/dist/embedding-worker.js +47 -0
  2. package/dist/emscripten-module-0g8f45e6.js +602 -0
  3. package/dist/emscripten-module-0pekdjxz.js +1532 -0
  4. package/dist/emscripten-module-e67xwsp3.js +503 -0
  5. package/dist/emscripten-module-pj1vyb44.js +4559 -0
  6. package/dist/ffi-3cx1cxpk.js +78 -0
  7. package/dist/ffi-7bqqe4cd.js +91 -0
  8. package/dist/ffi-7e6gryj5.js +91 -0
  9. package/dist/ffi-bpvkebwr.js +78 -0
  10. package/dist/historian-calibration-extension.js +7 -4
  11. package/dist/index-266qrgss.js +417 -0
  12. package/dist/index-2p1e8706.js +30 -0
  13. package/dist/index-4vfrjwf6.js +7737 -0
  14. package/dist/{index-59dmj4zs.js → index-7n8gb6j3.js} +165 -3
  15. package/dist/index-901ekbga.js +244 -0
  16. package/dist/{module-asyncify-2EFITU5U-rkqjhjxd.js → index-g20jdh0p.js} +114 -105
  17. package/dist/{index-5fw91enm.js → index-n3g5mwa8.js} +1 -1
  18. package/dist/index-phh7e055.js +290 -0
  19. package/dist/index-q1yc6bs0.js +104 -0
  20. package/dist/index-sg8zbjs0.js +8937 -0
  21. package/dist/index-td885aah.js +576 -0
  22. package/dist/index-vf38qhee.js +150 -0
  23. package/dist/{index-5am7amy4.js → index-vhzmjpsk.js} +10220 -25155
  24. package/dist/{index-n8kg008j.js → index-w76x3af7.js} +28 -18
  25. package/dist/index-wv28nczk.js +464 -0
  26. package/dist/{index-npagr1cy.js → index-xvw8zptx.js} +4021 -3973
  27. package/dist/index.js +6942 -2942
  28. package/dist/{message-time-backfill-5yrp95cx.js → message-time-backfill-4688z1k2.js} +19 -4
  29. package/dist/migration-worker.js +56 -0
  30. package/dist/module-ES6BEMUI-3cet1pyp.js +12 -0
  31. package/dist/module-asyncify-2EFITU5U-c2razzd9.js +6 -0
  32. package/dist/{read-session-chunk-w493f72c.js → read-session-chunk-tc6yn2pe.js} +32 -5
  33. package/dist/rpc-notifications-gm1mdpwh.js +16 -0
  34. package/dist/{safe-notification-target-y3hg2m7p.js → safe-notification-target-6cn3z99t.js} +2 -2
  35. package/dist/subagent-entry.js +15 -6
  36. package/package.json +7 -6
  37. package/dist/index-97e5fzy3.js +0 -16
  38. package/dist/index-b3eqj1g6.js +0 -51
  39. package/dist/index-rn7gafjr.js +0 -8
  40. package/dist/index-v6t0tg85.js +0 -13
  41. package/dist/rpc-notifications-jxy30tgz.js +0 -8
@@ -0,0 +1,150 @@
1
+ // ../plugin/src/shared/storage-permissions.ts
2
+ import { randomBytes } from "node:crypto";
3
+ import {
4
+ chmodSync,
5
+ closeSync,
6
+ createWriteStream,
7
+ lstatSync,
8
+ mkdirSync,
9
+ openSync,
10
+ readdirSync,
11
+ readlinkSync,
12
+ readSync,
13
+ renameSync,
14
+ rmSync,
15
+ symlinkSync,
16
+ writeFileSync,
17
+ writeSync
18
+ } from "node:fs";
19
+ import { open as openAsync, writeFile as writeFileAsync } from "node:fs/promises";
20
+ import { dirname, join } from "node:path";
21
+ var enforcePrivateStoragePermissions = true;
22
+ function setStoragePrivatePermissionEnforcement(enforce) {
23
+ enforcePrivateStoragePermissions = enforce;
24
+ }
25
+ function shouldEnforcePrivateStoragePermissions() {
26
+ return enforcePrivateStoragePermissions;
27
+ }
28
+ function ensureStorageDirectorySync(directory, forcePrivate = false, recursive = true) {
29
+ const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
30
+ mkdirSync(directory, {
31
+ recursive,
32
+ ...privateMode ? { mode: 448 } : {}
33
+ });
34
+ }
35
+ function writeStorageFileSync(filePath, content, options = {}) {
36
+ const { forcePrivate = false, ...writeOptions } = options;
37
+ const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
38
+ writeFileSync(filePath, content, {
39
+ ...writeOptions,
40
+ ...privateMode ? { mode: 384 } : {}
41
+ });
42
+ }
43
+ function writeStorageFileAtomicSync(filePath, content, forcePrivate = false) {
44
+ ensureStorageDirectorySync(dirname(filePath), forcePrivate);
45
+ const tempPath = `${filePath}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
46
+ try {
47
+ writeStorageFileSync(tempPath, content, { flag: "wx", forcePrivate });
48
+ renameSync(tempPath, filePath);
49
+ } catch (error) {
50
+ rmSync(tempPath, { force: true });
51
+ throw error;
52
+ }
53
+ }
54
+ function copyStorageFileSync(sourcePath, destinationPath, forcePrivate = false) {
55
+ ensureStorageDirectorySync(dirname(destinationPath), forcePrivate);
56
+ const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
57
+ const sourceFd = openSync(sourcePath, "r");
58
+ let destinationFd;
59
+ try {
60
+ destinationFd = openSync(destinationPath, "wx", privateMode ? 384 : 438);
61
+ const buffer = Buffer.allocUnsafe(1024 * 1024);
62
+ for (;; ) {
63
+ const bytesRead = readSync(sourceFd, buffer, 0, buffer.length, null);
64
+ if (bytesRead === 0)
65
+ break;
66
+ let offset = 0;
67
+ while (offset < bytesRead) {
68
+ offset += writeSync(destinationFd, buffer, offset, bytesRead - offset);
69
+ }
70
+ }
71
+ } catch (error) {
72
+ if (destinationFd !== undefined)
73
+ rmSync(destinationPath, { force: true });
74
+ throw error;
75
+ } finally {
76
+ closeSync(sourceFd);
77
+ if (destinationFd !== undefined)
78
+ closeSync(destinationFd);
79
+ }
80
+ }
81
+ function copyStorageTreeSync(sourcePath, destinationPath, forcePrivate = false) {
82
+ const stat = lstatSync(sourcePath);
83
+ if (stat.isSymbolicLink()) {
84
+ ensureStorageDirectorySync(dirname(destinationPath), forcePrivate);
85
+ symlinkSync(readlinkSync(sourcePath), destinationPath);
86
+ return;
87
+ }
88
+ if (!stat.isDirectory()) {
89
+ copyStorageFileSync(sourcePath, destinationPath, forcePrivate);
90
+ return;
91
+ }
92
+ ensureStorageDirectorySync(destinationPath, forcePrivate);
93
+ for (const entry of readdirSync(sourcePath)) {
94
+ copyStorageTreeSync(join(sourcePath, entry), join(destinationPath, entry), forcePrivate);
95
+ }
96
+ }
97
+ async function writeStorageFileAsync(filePath, content, forcePrivate = false) {
98
+ const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
99
+ ensureStorageDirectorySync(dirname(filePath), privateMode);
100
+ await writeFileAsync(filePath, content, privateMode ? { mode: 384 } : undefined);
101
+ }
102
+ async function writeStorageFileHandleAsync(handle, content) {
103
+ await handle.writeFile(content);
104
+ }
105
+ async function createStorageFileHandleAsync(filePath, flags, forcePrivate = false) {
106
+ const privateMode = forcePrivate || shouldEnforcePrivateStoragePermissions();
107
+ return openAsync(filePath, flags, privateMode ? 384 : undefined);
108
+ }
109
+ function tightenStorageTreeSync(root) {
110
+ if (!shouldEnforcePrivateStoragePermissions() || process.platform === "win32") {
111
+ return { tightened: 0, failures: 0 };
112
+ }
113
+ let tightened = 0;
114
+ let failures = 0;
115
+ const visit = (entryPath) => {
116
+ let stat;
117
+ try {
118
+ stat = lstatSync(entryPath);
119
+ } catch {
120
+ failures++;
121
+ return;
122
+ }
123
+ if (stat.isSymbolicLink())
124
+ return;
125
+ const mode = stat.isDirectory() ? 448 : 384;
126
+ if ((stat.mode & 63) !== 0 || (stat.mode & 511) !== mode) {
127
+ try {
128
+ chmodSync(entryPath, mode);
129
+ tightened++;
130
+ } catch {
131
+ failures++;
132
+ }
133
+ }
134
+ if (!stat.isDirectory())
135
+ return;
136
+ let entries;
137
+ try {
138
+ entries = readdirSync(entryPath);
139
+ } catch {
140
+ failures++;
141
+ return;
142
+ }
143
+ for (const entry of entries)
144
+ visit(join(entryPath, entry));
145
+ };
146
+ visit(root);
147
+ return { tightened, failures };
148
+ }
149
+
150
+ export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, ensureStorageDirectorySync, writeStorageFileSync, writeStorageFileAtomicSync, copyStorageFileSync, copyStorageTreeSync, writeStorageFileAsync, writeStorageFileHandleAsync, createStorageFileHandleAsync, tightenStorageTreeSync };