stitchkit 0.70.0 → 0.70.2

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 (67) hide show
  1. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
  2. package/dist/agent-runtime/coding-tool-paths.d.ts +0 -1
  3. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  4. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  5. package/dist/agent-runtime/contained-files.d.ts +30 -7
  6. package/dist/agent-runtime/contained-files.d.ts.map +1 -1
  7. package/dist/agent-runtime/harness-control.d.ts +2 -0
  8. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  9. package/dist/agent-runtime/history-chronology.d.ts +19 -0
  10. package/dist/agent-runtime/history-chronology.d.ts.map +1 -0
  11. package/dist/agent-runtime/history.d.ts.map +1 -1
  12. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  13. package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
  14. package/dist/agent-runtime-browser.js +51 -51
  15. package/dist/agent-runtime-coding-tools.js +31 -34
  16. package/dist/agent-runtime-harness.js +61 -17
  17. package/dist/agent-runtime-openrouter.js +2 -2
  18. package/dist/agent-runtime-sqlite-bun.js +5 -5
  19. package/dist/agent-runtime-sqlite-node.js +5 -5
  20. package/dist/agent-runtime.js +110 -110
  21. package/dist/application/server-resource.d.ts +1 -0
  22. package/dist/application/server-resource.d.ts.map +1 -1
  23. package/dist/application-grammy.js +2 -2
  24. package/dist/application.js +68 -65
  25. package/dist/browser/live-state.d.ts +126 -0
  26. package/dist/browser/live-state.d.ts.map +1 -0
  27. package/dist/cli.js +5 -5
  28. package/dist/contract/index.js +20 -20
  29. package/dist/declaration.d.ts +4 -0
  30. package/dist/declaration.d.ts.map +1 -1
  31. package/dist/declaration.js +22 -22
  32. package/dist/files.js +3 -3
  33. package/dist/index-1z5xxfst.js +397 -0
  34. package/dist/{index-vy5bjy07.js → index-4qfqy0m6.js} +21 -31
  35. package/dist/{index-dk6e56g0.js → index-7wpgrqa8.js} +37 -2
  36. package/dist/{index-10gbbbaa.js → index-9sx8tbz2.js} +1 -1
  37. package/dist/{index-38hs3a58.js → index-a01jky8m.js} +73 -8
  38. package/dist/{index-hsabxjz0.js → index-jw81xr75.js} +1 -1
  39. package/dist/{index-6wzr93cg.js → index-w0445741.js} +1 -1
  40. package/dist/index-y2s6h5bf.js +83 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +667 -56
  44. package/dist/node.js +47 -27
  45. package/dist/observability/index.js +22 -22
  46. package/dist/react.js +2 -2
  47. package/dist/realtime/contract.d.ts +30 -11
  48. package/dist/realtime/contract.d.ts.map +1 -1
  49. package/dist/realtime/index.d.ts +1 -1
  50. package/dist/realtime/index.d.ts.map +1 -1
  51. package/dist/server/bun.d.ts.map +1 -1
  52. package/dist/server/index.js +88 -80
  53. package/dist/server/multipart.d.ts.map +1 -1
  54. package/dist/server/node.d.ts.map +1 -1
  55. package/dist/server/process-signals.d.ts.map +1 -1
  56. package/dist/server/shutdown.d.ts +2 -0
  57. package/dist/server/shutdown.d.ts.map +1 -1
  58. package/dist/testing/surface-conformance.d.ts +4 -2
  59. package/dist/testing/surface-conformance.d.ts.map +1 -1
  60. package/dist/testing.js +124 -113
  61. package/dist/tools.js +57 -57
  62. package/llms-full.txt +246 -17
  63. package/native/darwin-arm64.node +0 -0
  64. package/native/darwin-x64.node +0 -0
  65. package/package.json +3 -1
  66. package/dist/index-es0h4w26.js +0 -63
  67. package/dist/index-xbtcszs7.js +0 -202
@@ -1,202 +0,0 @@
1
- // src/agent-runtime/contained-files.ts
2
- import { constants } from "node:fs";
3
- import { open, readdir, realpath } from "node:fs/promises";
4
- import path from "node:path";
5
- function descriptorPath(handle) {
6
- if (process.platform === "linux")
7
- return `/proc/self/fd/${handle.fd}`;
8
- if (process.platform === "darwin" || process.platform === "freebsd") {
9
- return `/dev/fd/${handle.fd}`;
10
- }
11
- throw new Error("Contained filesystem operations require descriptor paths on this platform");
12
- }
13
- async function openPinnedDirectory(absolute) {
14
- const expected = await realpath(absolute);
15
- const handle = await open(expected, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
16
- try {
17
- if (await realpath(descriptorPath(handle)) !== expected) {
18
- throw new Error("Contained directory identity changed while opening");
19
- }
20
- return handle;
21
- } catch (error) {
22
- await handle.close();
23
- throw error;
24
- }
25
- }
26
- function safeSegments(relative) {
27
- if (path.isAbsolute(relative))
28
- throw new Error("Contained paths must be relative");
29
- const segments = relative.split(/[\\/]/u);
30
- if (segments.length === 0 || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
31
- throw new Error("Contained path has invalid segments");
32
- }
33
- return segments;
34
- }
35
- async function openContainedParent(root, relative) {
36
- const segments = safeSegments(relative);
37
- const basename = segments.pop();
38
- if (!basename)
39
- throw new Error("Contained path is missing a basename");
40
- let current = await openPinnedDirectory(root);
41
- try {
42
- for (const segment of segments) {
43
- const next = await open(path.join(descriptorPath(current), segment), constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
44
- const metadata = await next.stat();
45
- if (!metadata.isDirectory()) {
46
- await next.close();
47
- throw new Error("Contained ancestor is not a directory");
48
- }
49
- await current.close();
50
- current = next;
51
- }
52
- return { handle: current, path: descriptorPath(current), basename };
53
- } catch (error) {
54
- await current.close();
55
- throw error;
56
- }
57
- }
58
- async function openContainedFile(root, relative) {
59
- const parent = await openContainedParent(root, relative);
60
- try {
61
- const handle = await open(path.join(parent.path, parent.basename), constants.O_RDONLY | constants.O_NOFOLLOW);
62
- const metadata = await handle.stat();
63
- if (!metadata.isFile()) {
64
- await handle.close();
65
- throw new Error("Contained path is not a regular file");
66
- }
67
- return handle;
68
- } finally {
69
- await parent.handle.close();
70
- }
71
- }
72
- function sameIdentity(left, right) {
73
- return left.dev === right.dev && left.ino === right.ino;
74
- }
75
- async function assertContainedFileCurrent(root, relative, expected) {
76
- const current = await openContainedFile(root, relative);
77
- try {
78
- if (!sameIdentity(await expected.stat(), await current.stat())) {
79
- throw new Error("Contained file identity changed during authorization");
80
- }
81
- } finally {
82
- await current.close();
83
- }
84
- }
85
- async function assertContainedParentCurrent(root, relative, expected) {
86
- const current = await openContainedParent(root, relative);
87
- try {
88
- if (!sameIdentity(await expected.stat(), await current.handle.stat())) {
89
- throw new Error("Contained parent identity changed during authorization");
90
- }
91
- } finally {
92
- await current.handle.close();
93
- }
94
- }
95
- async function readContainedUtf8Handle(handle, maxBytes) {
96
- const metadata = await handle.stat();
97
- if (!metadata.isFile())
98
- throw new Error("Contained path is not a regular file");
99
- if (metadata.size > maxBytes)
100
- throw new Error("Contained file exceeds byte budget");
101
- const buffer = Buffer.alloc(metadata.size);
102
- let offset = 0;
103
- while (offset < buffer.byteLength) {
104
- const { bytesRead } = await handle.read(buffer, offset, buffer.byteLength - offset, offset);
105
- if (bytesRead === 0)
106
- break;
107
- offset += bytesRead;
108
- }
109
- if (offset !== metadata.size)
110
- throw new Error("Contained file changed while being read");
111
- return {
112
- text: new TextDecoder("utf-8", { fatal: true }).decode(buffer),
113
- bytes: offset,
114
- mode: metadata.mode
115
- };
116
- }
117
- async function walkContainedFiles(input) {
118
- const scan = await scanContainedFiles({ ...input, symlinks: "refuse" });
119
- if (scan.truncated)
120
- throw new Error("Contained file traversal exceeded its bounds");
121
- return scan.files;
122
- }
123
- async function scanContainedFiles(input) {
124
- const files = [];
125
- let truncated = false;
126
- let skippedDirectories = 0;
127
- let skippedSymlinks = 0;
128
- const root = await openPinnedDirectory(input.root);
129
- const visit = async (directory, relativeDirectory, depth) => {
130
- if (truncated)
131
- return;
132
- if (depth > input.maxDepth) {
133
- truncated = true;
134
- return;
135
- }
136
- const entries = await readdir(descriptorPath(directory), { withFileTypes: true });
137
- entries.sort((left, right) => left.name.localeCompare(right.name));
138
- for (const entry of entries) {
139
- const relative = relativeDirectory ? path.join(relativeDirectory, entry.name) : entry.name;
140
- const anchored = path.join(descriptorPath(directory), entry.name);
141
- if (entry.isSymbolicLink()) {
142
- if (input.symlinks === "refuse") {
143
- throw new Error(`Contained file traversal refuses symlink: ${relative}`);
144
- }
145
- skippedSymlinks += 1;
146
- continue;
147
- }
148
- if (entry.isDirectory()) {
149
- if (input.excludeDirectory?.(relative)) {
150
- skippedDirectories += 1;
151
- continue;
152
- }
153
- let child;
154
- try {
155
- child = await open(anchored, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
156
- } catch (error) {
157
- if (input.symlinks === "skip") {
158
- skippedSymlinks += 1;
159
- continue;
160
- }
161
- throw error;
162
- }
163
- try {
164
- await visit(child, relative, depth + 1);
165
- } finally {
166
- await child.close();
167
- }
168
- continue;
169
- }
170
- if (!entry.isFile())
171
- continue;
172
- if (files.length >= input.maxFiles) {
173
- truncated = true;
174
- return;
175
- }
176
- let content;
177
- if (input.readMaxBytes !== undefined) {
178
- try {
179
- const handle = await open(anchored, constants.O_RDONLY | constants.O_NOFOLLOW);
180
- try {
181
- content = await readContainedUtf8Handle(handle, input.readMaxBytes);
182
- } finally {
183
- await handle.close();
184
- }
185
- } catch (error) {
186
- if (input.skipUnreadable)
187
- continue;
188
- throw error;
189
- }
190
- }
191
- files.push({ absolute: relative, relative, ...content && { content } });
192
- }
193
- };
194
- try {
195
- await visit(root, "", 0);
196
- } finally {
197
- await root.close();
198
- }
199
- return { files, truncated, skippedDirectories, skippedSymlinks };
200
- }
201
-
202
- export { openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };