typeclaw 0.46.1 → 0.46.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.
- package/package.json +2 -2
- package/src/agent/tool-file-safety.ts +18 -9
- package/src/agent/tools/webfetch/strategies/jq.ts +1 -2
- package/src/agent/tools/webfetch/strategies/readability.ts +39 -16
- package/src/agent/tools/webfetch/strategies/selector.ts +4 -2
- package/src/agent/tools/webfetch/strategies/snapshot.ts +3 -2
- package/src/agent/tools/webfetch/tool.ts +3 -3
- package/src/bundled-plugins/backup/index.ts +21 -4
- package/src/bundled-plugins/backup/runner.ts +19 -5
- package/src/bundled-plugins/memory/vector/hybrid.ts +10 -2
- package/src/bundled-plugins/memory/vector/store.ts +21 -9
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +8 -3
- package/src/bundled-plugins/security/policies/private-surface-read.ts +6 -0
- package/src/cli/inspect.ts +16 -0
- package/src/container/shared.ts +19 -6
- package/src/init/checkpoint.ts +4 -4
- package/src/init/dockerfile.ts +87 -88
- package/src/init/gitignore.ts +5 -6
- package/src/init/run-bun-install.ts +16 -2
- package/src/init/validate-api-key.ts +1 -0
- package/src/inspect/item-list.ts +12 -6
- package/src/permissions/permissions.ts +93 -2
- package/src/role-claim/code.ts +9 -5
- package/src/run/index.ts +45 -36
- package/src/sandbox/canonical-secrets.ts +6 -0
- package/src/sandbox/index.ts +1 -0
- package/src/sandbox/symlinks.ts +1 -1
- package/src/secrets/export-claude-credentials-file.ts +13 -22
- package/src/secrets/export-codex-auth-file.ts +12 -28
|
@@ -43,11 +43,9 @@ export type ExportClaudeCredentialsFileOptions = {
|
|
|
43
43
|
|
|
44
44
|
// Writes typeclaw's anthropic OAuth credential to
|
|
45
45
|
// $CLAUDE_CONFIG_DIR/.credentials.json (or $HOME/.claude/.credentials.json
|
|
46
|
-
// by default) when it's safe to do so.
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// write follows the symlink and lands on the persistent host-side path —
|
|
50
|
-
// same contract as exportCodexAuthFile.
|
|
46
|
+
// by default) when it's safe to do so. Container HOME is /home/agent and
|
|
47
|
+
// ephemeral; this boot-time export reconstructs the CLI file from secrets.json
|
|
48
|
+
// after provider OAuth refresh has updated the canonical credential.
|
|
51
49
|
//
|
|
52
50
|
// Three guards, cheapest first. The first two return without ever touching
|
|
53
51
|
// the filesystem, which keeps the 90% case (users who don't enable
|
|
@@ -192,16 +190,11 @@ function resolveClaudeConfigDir(configDir: string | undefined): string | null {
|
|
|
192
190
|
// rename is belt-and-suspenders: writeFileSync's `mode` is applied at
|
|
193
191
|
// create time, but umask can mask it down on some filesystems.
|
|
194
192
|
//
|
|
195
|
-
// Symlink preservation
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
// would replace the symlink with a regular file, leaving the persistent
|
|
201
|
-
// path empty and Claude Code's in-place token refresh silently lost on
|
|
202
|
-
// every restart. Resolve the symlink target with readlinkSync and rename
|
|
203
|
-
// against the real path so the symlink itself is preserved. The temp
|
|
204
|
-
// file MUST live alongside the real target (same filesystem) because
|
|
193
|
+
// Symlink preservation remains a safety property even though TypeClaw no longer
|
|
194
|
+
// plants one here. An operator or external tool may preconfigure the credentials
|
|
195
|
+
// path as a symlink; POSIX rename(2) replaces that directory entry instead of
|
|
196
|
+
// following it. Resolve the target and rename there so the caller's symlink
|
|
197
|
+
// survives. The temp file MUST live alongside the real target because
|
|
205
198
|
// renameSync across filesystems fails with EXDEV.
|
|
206
199
|
function writeAtomic(targetPath: string, contents: string): void {
|
|
207
200
|
const realTarget = resolveSymlinkTarget(targetPath)
|
|
@@ -227,13 +220,11 @@ function writeAtomic(targetPath: string, contents: string): void {
|
|
|
227
220
|
}
|
|
228
221
|
}
|
|
229
222
|
|
|
230
|
-
// Returns the absolute path renameSync should target. When `path` is a
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
// throws EINVAL when the path exists but isn't a symlink and ENOENT
|
|
236
|
-
// when nothing is there — both cases fall through to the original path.
|
|
223
|
+
// Returns the absolute path renameSync should target. When `path` is a symlink,
|
|
224
|
+
// returns the resolved absolute target so we write through the link instead of
|
|
225
|
+
// replacing it. Otherwise returns the path unchanged. readlinkSync throws EINVAL
|
|
226
|
+
// when the path exists but isn't a symlink and ENOENT when nothing is there —
|
|
227
|
+
// both cases fall through to the original path.
|
|
237
228
|
function resolveSymlinkTarget(path: string): string {
|
|
238
229
|
let link: string
|
|
239
230
|
try {
|
|
@@ -38,12 +38,9 @@ export type ExportCodexAuthFileOptions = {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Writes typeclaw's openai-codex OAuth credential to $HOME/.codex/auth.json
|
|
41
|
-
// when it's safe to do so.
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
// host-side path — that's the stable contract from src/init/dockerfile.ts
|
|
45
|
-
// "link_persistent_home_files" and we MUST use it instead of writing to
|
|
46
|
-
// /agent/.typeclaw/home/ directly.
|
|
41
|
+
// when it's safe to do so. Container HOME is /home/agent and ephemeral; this
|
|
42
|
+
// boot-time export reconstructs the CLI file from secrets.json after provider
|
|
43
|
+
// OAuth refresh has had a chance to update the canonical credential.
|
|
47
44
|
//
|
|
48
45
|
// Three guards, cheapest first. The first two return without ever touching
|
|
49
46
|
// the filesystem, which keeps the 90% case (users who don't enable Codex
|
|
@@ -170,22 +167,12 @@ function readCredentialExpiry(credential: { expires?: unknown; access?: unknown
|
|
|
170
167
|
// belt-and-suspenders: writeFileSync's `mode` is applied at create time,
|
|
171
168
|
// but umask can mask it down on some filesystems.
|
|
172
169
|
//
|
|
173
|
-
// Symlink preservation
|
|
174
|
-
//
|
|
175
|
-
// $HOME/.codex/auth.json as a symlink
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
// would replace the symlink with a regular file, leaving the persistent
|
|
180
|
-
// path empty. Next boot the shim recreates the symlink (force-removing
|
|
181
|
-
// our file), the persistent path is still empty, and Codex's in-place
|
|
182
|
-
// token refresh is silently lost on every restart.
|
|
183
|
-
//
|
|
184
|
-
// Fix: resolve the symlink target with readlinkSync and rename against
|
|
185
|
-
// the real path so the symlink itself is preserved. The temp file MUST
|
|
186
|
-
// live alongside the real target (same filesystem) because renameSync
|
|
187
|
-
// across filesystems fails with EXDEV — $HOME is the container's
|
|
188
|
-
// overlayfs, but the symlink target is a bind-mounted host path.
|
|
170
|
+
// Symlink preservation is still a safety property even though TypeClaw no
|
|
171
|
+
// longer plants one here. An operator or external tool may preconfigure
|
|
172
|
+
// $HOME/.codex/auth.json as a symlink; POSIX rename(2) replaces that directory
|
|
173
|
+
// entry instead of following it. Resolve the target and rename there so the
|
|
174
|
+
// caller's symlink survives. The temp file MUST live alongside the real target
|
|
175
|
+
// because renameSync across filesystems fails with EXDEV.
|
|
189
176
|
function writeAtomic(targetPath: string, contents: string): void {
|
|
190
177
|
const realTarget = resolveSymlinkTarget(targetPath)
|
|
191
178
|
const dir = dirname(realTarget)
|
|
@@ -213,12 +200,9 @@ function writeAtomic(targetPath: string, contents: string): void {
|
|
|
213
200
|
}
|
|
214
201
|
}
|
|
215
202
|
|
|
216
|
-
// Returns the absolute path renameSync should target. When `path` is a
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
// instead of replacing it. Otherwise (tests, or first boot before the
|
|
220
|
-
// shim installs the symlink — though the shim runs before the agent in
|
|
221
|
-
// production), returns the path unchanged.
|
|
203
|
+
// Returns the absolute path renameSync should target. When `path` is a symlink,
|
|
204
|
+
// returns the resolved absolute target so we write through the link instead of
|
|
205
|
+
// replacing it. Otherwise returns the path unchanged.
|
|
222
206
|
//
|
|
223
207
|
// readlinkSync throws EINVAL when the path exists but isn't a symlink,
|
|
224
208
|
// and ENOENT when nothing is there. Either case → write to the original
|