@ai-sdk/harness-claude-code 1.0.201 → 1.0.203
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/CHANGELOG.md +18 -0
- package/dist/bridge/index.mjs +57 -8
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
- package/src/claude-code-harness.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/harness-claude-code
|
|
2
2
|
|
|
3
|
+
## 1.0.203
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8c87146: chore(harness): move utility functions incorrectly included in `harness/v1` layer into appropriate `harness/utils` layer
|
|
8
|
+
- Updated dependencies [f958ef0]
|
|
9
|
+
- Updated dependencies [8c87146]
|
|
10
|
+
- @ai-sdk/provider@4.0.40
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.87
|
|
12
|
+
- @ai-sdk/harness@1.0.199
|
|
13
|
+
|
|
14
|
+
## 1.0.202
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [0f4f233]
|
|
19
|
+
- @ai-sdk/harness@1.0.198
|
|
20
|
+
|
|
3
21
|
## 1.0.201
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/bridge/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendFile, lstat, mkdir, readdir, realpath, writeFile } from "node:fs/promises";
|
|
1
|
+
import { appendFile, lstat, mkdir, readdir, realpath, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { createPublicKey, randomBytes, randomUUID, verify } from "node:crypto";
|
|
4
4
|
import { argv, env, pid, stdout } from "node:process";
|
|
@@ -91,17 +91,44 @@ var HarnessBridgeCapabilityUnsupportedError = class extends Error {
|
|
|
91
91
|
function assertWriteProtectedPathEntries(entries) {
|
|
92
92
|
for (const entry of entries) if (typeof entry !== "string" || entry.length === 0 || path.posix.isAbsolute(entry) || entry.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) throw new TypeError(`Write-protected path entries must be relative paths without empty, "." or ".." segments; received ${JSON.stringify(entry)}.`);
|
|
93
93
|
}
|
|
94
|
-
function isInsideWriteProtectionPath({ parent, candidate }) {
|
|
95
|
-
const
|
|
96
|
-
|
|
94
|
+
function isInsideWriteProtectionPath({ parent, candidate, pathIdentities }) {
|
|
95
|
+
const parentSegments = path.posix.normalize(parent).split("/").filter(Boolean);
|
|
96
|
+
const candidateSegments = path.posix.normalize(candidate).split("/").filter(Boolean);
|
|
97
|
+
if (parentSegments.length > candidateSegments.length) return false;
|
|
98
|
+
let parentPrefix = "";
|
|
99
|
+
let candidatePrefix = "";
|
|
100
|
+
for (let index = 0; index < parentSegments.length; index++) {
|
|
101
|
+
const parentSegment = parentSegments[index];
|
|
102
|
+
const candidateSegment = candidateSegments[index];
|
|
103
|
+
parentPrefix += `/${parentSegment}`;
|
|
104
|
+
candidatePrefix += `/${candidateSegment}`;
|
|
105
|
+
if (parentSegment === candidateSegment) continue;
|
|
106
|
+
if (pathIdentities != null) {
|
|
107
|
+
const parentIdentity = pathIdentities.get(parentPrefix);
|
|
108
|
+
const candidateIdentity = pathIdentities.get(candidatePrefix);
|
|
109
|
+
if (parentIdentity === void 0 || candidateIdentity === void 0) return true;
|
|
110
|
+
if (parentIdentity !== null && candidateIdentity !== null) {
|
|
111
|
+
if (parentIdentity !== candidateIdentity) return false;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (isAsciiSegment(parentSegment) && isAsciiSegment(candidateSegment) && parentSegment.toLowerCase() !== candidateSegment.toLowerCase()) return false;
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
function isAsciiSegment(segment) {
|
|
120
|
+
for (const character of segment) if (character.charCodeAt(0) > 127) return false;
|
|
121
|
+
return true;
|
|
97
122
|
}
|
|
98
|
-
function matchesWriteProtectedPath({ targets, protectedPaths, anyProtectedPathExists }) {
|
|
123
|
+
function matchesWriteProtectedPath({ targets, protectedPaths, anyProtectedPathExists, pathIdentities }) {
|
|
99
124
|
return targets.some((target) => protectedPaths.some((protectedPath) => isInsideWriteProtectionPath({
|
|
100
125
|
parent: protectedPath,
|
|
101
|
-
candidate: target.path
|
|
126
|
+
candidate: target.path,
|
|
127
|
+
pathIdentities
|
|
102
128
|
}) || isInsideWriteProtectionPath({
|
|
103
129
|
parent: target.path,
|
|
104
|
-
candidate: protectedPath
|
|
130
|
+
candidate: protectedPath,
|
|
131
|
+
pathIdentities
|
|
105
132
|
})) || anyProtectedPathExists && target.isMultiLinkFile);
|
|
106
133
|
}
|
|
107
134
|
/**
|
|
@@ -125,6 +152,9 @@ function matchesWriteProtectedPath({ targets, protectedPaths, anyProtectedPathEx
|
|
|
125
152
|
* written through an unprotected alias. While any protected path exists,
|
|
126
153
|
* writes to files with more than one link match too. Any resolution failure,
|
|
127
154
|
* including dangling or looping symlinks, reports the write as protected.
|
|
155
|
+
* Existing path components are compared by filesystem identity. Missing names
|
|
156
|
+
* are matched conservatively, including ASCII case variants and ambiguous
|
|
157
|
+
* Unicode spellings, even on case-sensitive filesystems.
|
|
128
158
|
*/
|
|
129
159
|
async function isWriteProtectedPath({ workDir, cwd = workDir, paths, writeProtectedPaths }) {
|
|
130
160
|
assertWriteProtectedPathEntries(writeProtectedPaths);
|
|
@@ -150,9 +180,28 @@ async function isWriteProtectedPath({ workDir, cwd = workDir, paths, writeProtec
|
|
|
150
180
|
});
|
|
151
181
|
}
|
|
152
182
|
}
|
|
183
|
+
const protectedPaths = [...writeProtectedPaths.map((entry) => path.posix.join(canonicalWorkDir, entry)), ...protection.paths];
|
|
184
|
+
const pathIdentities = /* @__PURE__ */ new Map();
|
|
185
|
+
for (const filePath of [...protectedPaths, ...targets.map((target) => target.path)]) {
|
|
186
|
+
let prefix = filePath;
|
|
187
|
+
while (!pathIdentities.has(prefix)) {
|
|
188
|
+
try {
|
|
189
|
+
const stats = await stat(prefix, { bigint: true });
|
|
190
|
+
if (stats.ino === 0n) return true;
|
|
191
|
+
pathIdentities.set(prefix, `${stats.dev}:${stats.ino}`);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error == null || typeof error !== "object" || !("code" in error) || error.code !== "ENOENT") throw error;
|
|
194
|
+
pathIdentities.set(prefix, null);
|
|
195
|
+
}
|
|
196
|
+
const parent = path.posix.dirname(prefix);
|
|
197
|
+
if (parent === prefix) break;
|
|
198
|
+
prefix = parent;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
153
201
|
return matchesWriteProtectedPath({
|
|
154
202
|
targets,
|
|
155
|
-
protectedPaths
|
|
203
|
+
protectedPaths,
|
|
204
|
+
pathIdentities,
|
|
156
205
|
anyProtectedPathExists: protection.anyRootExists
|
|
157
206
|
});
|
|
158
207
|
} catch {
|