typeclaw 0.45.1 → 0.46.1
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/README.md +1 -1
- package/package.json +3 -2
- package/src/agent/git-nudge.ts +2 -1
- package/src/agent/index.ts +44 -30
- package/src/agent/live-subagents.ts +18 -0
- package/src/agent/multimodal/index.ts +1 -1
- package/src/agent/multimodal/look-at.ts +78 -44
- package/src/agent/multimodal/looker.ts +161 -39
- package/src/agent/network/response-body.ts +26 -0
- package/src/agent/network/safe-http.ts +207 -0
- package/src/agent/plugin-tools.ts +377 -157
- package/src/agent/provider-error.ts +52 -1
- package/src/agent/restart/index.ts +61 -40
- package/src/agent/restart-handoff/index.ts +73 -4
- package/src/agent/reviewer-bash-policy.ts +42 -1
- package/src/agent/session-origin.ts +2 -0
- package/src/agent/subagent-drain.ts +117 -7
- package/src/agent/subagents.ts +49 -16
- package/src/agent/throttle-circuit.ts +25 -5
- package/src/agent/tool-error-remediation.ts +72 -0
- package/src/agent/tool-file-safety.ts +1310 -0
- package/src/agent/tools/channel-fetch-attachment.ts +10 -3
- package/src/agent/tools/ddg.ts +16 -2
- package/src/agent/tools/post-github-review.ts +199 -0
- package/src/agent/tools/spawn-subagent.ts +21 -18
- package/src/agent/tools/webfetch/fetch.ts +163 -183
- package/src/agent/tools/webfetch/tool.ts +2 -3
- package/src/agent/tools/websearch.ts +23 -2
- package/src/agent/tools-without-local-file-operands.ts +30 -0
- package/src/agent/turn-runner.ts +86 -6
- package/src/bundled-plugins/backup/README.md +23 -10
- package/src/bundled-plugins/backup/git-auth.ts +6 -4
- package/src/bundled-plugins/backup/index.ts +85 -44
- package/src/bundled-plugins/backup/runner.ts +85 -1
- package/src/bundled-plugins/doc-render/render.ts +93 -12
- package/src/bundled-plugins/doc-render/skills/typeclaw-render-pdf/SKILL.md +13 -13
- package/src/bundled-plugins/github-cli-auth/effective-approval.ts +16 -6
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +555 -15
- package/src/bundled-plugins/github-cli-auth/git-askpass.ts +74 -26
- package/src/bundled-plugins/github-cli-auth/git-command.ts +224 -36
- package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +9 -9
- package/src/bundled-plugins/github-cli-auth/index.ts +207 -132
- package/src/bundled-plugins/github-cli-auth/review-checkout.ts +138 -0
- package/src/bundled-plugins/github-cli-auth/token-class.ts +4 -6
- package/src/bundled-plugins/guard/policies/uncommitted-changes.ts +2 -1
- package/src/bundled-plugins/memory/README.md +32 -11
- package/src/bundled-plugins/memory/append-tool.ts +15 -8
- package/src/bundled-plugins/memory/citations.ts +22 -9
- package/src/bundled-plugins/memory/dreaming.ts +13 -8
- package/src/bundled-plugins/memory/find-entry-tool.ts +4 -0
- package/src/bundled-plugins/memory/index.ts +0 -4
- package/src/bundled-plugins/memory/load-memory.ts +8 -3
- package/src/bundled-plugins/memory/provenance-index.ts +717 -0
- package/src/bundled-plugins/memory/provenance-sanitize.ts +40 -0
- package/src/bundled-plugins/memory/references/store-reference-tool.ts +4 -0
- package/src/bundled-plugins/memory/search-tool.ts +163 -60
- package/src/bundled-plugins/memory/stream-events.ts +2 -0
- package/src/bundled-plugins/memory/vector/embed-threads.ts +36 -0
- package/src/bundled-plugins/memory/vector/embedder.ts +19 -1
- package/src/bundled-plugins/memory/vector/hybrid.ts +126 -13
- package/src/bundled-plugins/researcher/write-report.ts +8 -5
- package/src/bundled-plugins/reviewer/index.ts +2 -2
- package/src/bundled-plugins/reviewer/reviewer.ts +10 -3
- package/src/bundled-plugins/reviewer/skills/code-review.ts +19 -9
- package/src/bundled-plugins/scout/scout.ts +8 -0
- package/src/bundled-plugins/security/index.ts +4 -4
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
- package/src/bundled-plugins/security/policies/private-surface-read.ts +787 -36
- package/src/bundled-plugins/security/policies/secret-exfil-read.ts +1 -0
- package/src/bundled-plugins/security/policies/ssrf.ts +147 -42
- package/src/channels/adapters/discord-bot-channel-resolver.ts +26 -14
- package/src/channels/adapters/discord-bot-thread-room.ts +44 -12
- package/src/channels/adapters/discord-bot.ts +66 -6
- package/src/channels/adapters/discord-channel-resolver.ts +91 -23
- package/src/channels/adapters/discord-id.ts +4 -0
- package/src/channels/adapters/discord-resolver-cache.ts +41 -0
- package/src/channels/adapters/discord.ts +57 -7
- package/src/channels/adapters/github/auth-app.ts +41 -12
- package/src/channels/adapters/github/inbound.ts +11 -0
- package/src/channels/adapters/github/index.ts +71 -65
- package/src/channels/adapters/github/reconcile-cooldown-store.ts +178 -0
- package/src/channels/adapters/github/reconcile-open-prs.ts +31 -0
- package/src/channels/adapters/github/review-submitter.ts +302 -0
- package/src/channels/adapters/kakaotalk-channel-resolver.ts +5 -3
- package/src/channels/adapters/kakaotalk-fetch-attachment.ts +8 -4
- package/src/channels/adapters/kakaotalk-typing.ts +17 -15
- package/src/channels/adapters/slack-attachment-download.ts +71 -0
- package/src/channels/adapters/slack-bot-edit.ts +85 -20
- package/src/channels/adapters/slack-bot.ts +26 -10
- package/src/channels/adapters/slack-classify.ts +21 -2
- package/src/channels/adapters/slack-format.ts +245 -0
- package/src/channels/adapters/slack.ts +59 -7
- package/src/channels/adapters/telegram-bot.ts +18 -5
- package/src/channels/adapters/webex-bot.ts +8 -3
- package/src/channels/adapters/webex.ts +8 -3
- package/src/channels/fetch-attachment.ts +43 -0
- package/src/{bundled-plugins/github-cli-auth/approve-idempotency.ts → channels/github-review-verdict-coordinator.ts} +25 -1
- package/src/channels/github-token-bridge.ts +12 -6
- package/src/channels/manager.ts +9 -0
- package/src/channels/router.ts +248 -6
- package/src/channels/types.ts +28 -1
- package/src/cli/channel.ts +1 -1
- package/src/cli/init.ts +1 -1
- package/src/cli/model.ts +57 -7
- package/src/compose/stop.ts +17 -5
- package/src/config/config.ts +6 -6
- package/src/config/models-mutation.ts +13 -1
- package/src/config/providers.ts +176 -0
- package/src/container/docker-app.ts +42 -13
- package/src/container/start.ts +62 -10
- package/src/cron/bridge.ts +9 -2
- package/src/doctor/checks.ts +8 -3
- package/src/doctor/commit.ts +2 -1
- package/src/doctor/file-ownership.ts +52 -0
- package/src/dreams/git.ts +2 -1
- package/src/git/bound-gc-config.ts +82 -0
- package/src/git/hookless.ts +5 -0
- package/src/git/reconcile-ignored.ts +18 -5
- package/src/git/system-commit.ts +12 -6
- package/src/hostd/spawn.ts +133 -47
- package/src/init/dockerfile.ts +99 -5
- package/src/init/index.ts +17 -5
- package/src/init/models-dev.ts +4 -0
- package/src/init/validate-api-key.ts +2 -0
- package/src/inspect/replay.ts +21 -9
- package/src/inspect/session-list.ts +71 -33
- package/src/mcp/tools.ts +17 -3
- package/src/network/internal-destinations.ts +267 -0
- package/src/permissions/builtins.ts +3 -1
- package/src/plugin/context.ts +2 -0
- package/src/plugin/index.ts +1 -0
- package/src/plugin/manager.ts +4 -0
- package/src/plugin/types.ts +22 -0
- package/src/run/index.ts +40 -0
- package/src/run/llm-fetch-observer.ts +41 -4
- package/src/sandbox/build.ts +37 -15
- package/src/sandbox/canonical-secrets.ts +18 -0
- package/src/sandbox/env-exposure.ts +83 -0
- package/src/sandbox/errors.ts +13 -6
- package/src/sandbox/hidden-paths.ts +102 -44
- package/src/sandbox/index.ts +22 -4
- package/src/sandbox/package-install.ts +3 -27
- package/src/sandbox/policy.ts +16 -28
- package/src/sandbox/privileged-runtime.ts +256 -0
- package/src/sandbox/session-tmp.ts +8 -2
- package/src/sandbox/writable-zones.ts +204 -140
- package/src/secrets/index.ts +8 -0
- package/src/secrets/refresh-provider-oauth.ts +128 -0
- package/src/server/command-runner.ts +48 -4
- package/src/server/index.ts +4 -0
- package/src/skills/typeclaw-channel-github/SKILL.md +49 -56
- package/src/skills/typeclaw-claude-code/SKILL.md +24 -60
- package/src/skills/typeclaw-claude-code/references/auth-flow.md +17 -158
- package/src/skills/typeclaw-codex-cli/SKILL.md +19 -49
- package/src/skills/typeclaw-codex-cli/references/auth-flow.md +17 -154
- package/src/skills/typeclaw-config/SKILL.md +27 -11
- package/src/skills/typeclaw-config/references/recommended-mounts.md +24 -24
- package/src/skills/typeclaw-github-contributing/SKILL.md +23 -26
- package/src/skills/typeclaw-memory/SKILL.md +9 -3
- package/src/skills/typeclaw-permissions/SKILL.md +36 -19
- package/src/skills/typeclaw-plugins/SKILL.md +37 -0
- package/src/usage/scan.ts +11 -2
- package/typeclaw.schema.json +25 -0
package/src/agent/subagents.ts
CHANGED
|
@@ -381,6 +381,7 @@ export async function invokeSubagent(name: string, options: InvokeSubagentOption
|
|
|
381
381
|
throwIfLoopGuardAborted(session)
|
|
382
382
|
},
|
|
383
383
|
cancelled: () => aborted,
|
|
384
|
+
maxChildWaitMs: DRAIN_MAX_CHILD_WAIT_MS,
|
|
384
385
|
})
|
|
385
386
|
}
|
|
386
387
|
throwIfLoopGuardAborted(session)
|
|
@@ -630,16 +631,25 @@ function lastTaggedBlock(text: string, tag: FinalBlockTag): string | null {
|
|
|
630
631
|
}
|
|
631
632
|
|
|
632
633
|
// Subagents whose result IS a REQUIRED tagged block — the parent must receive
|
|
633
|
-
// that block or a
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
//
|
|
637
|
-
//
|
|
638
|
-
//
|
|
639
|
-
//
|
|
640
|
-
//
|
|
641
|
-
//
|
|
642
|
-
|
|
634
|
+
// that block or a structured "could not complete" fallback, never a stale
|
|
635
|
+
// earlier turn and never a silent empty completion. Keyed by registry name.
|
|
636
|
+
//
|
|
637
|
+
// Both entries share one failure mode on the `deep`/openai-codex profile: a run
|
|
638
|
+
// that ends on tool-call-only turns emits no closing block, so `finalMessage`
|
|
639
|
+
// stays undefined and `spawn_subagent`/`subagent_output` synthesize "completed …
|
|
640
|
+
// with no final message" as an `ok: true` success. For the researcher that
|
|
641
|
+
// surfaced the earlier `<analysis>` preamble as findings (guarded by ae5014e5);
|
|
642
|
+
// for the reviewer the GitHub flow has no `<review>` to post and silently
|
|
643
|
+
// `skip_response`s — the stranded-review bug. This gate gives both a bounded
|
|
644
|
+
// re-prompt then an honest low-confidence fallback instead of the silent drop.
|
|
645
|
+
// Backstop ceiling for the background drain: a running child that never settles
|
|
646
|
+
// is abandoned after this so the parent can synthesize partial results instead
|
|
647
|
+
// of hanging forever. Deliberately larger than the per-child `timeoutMs`
|
|
648
|
+
// (scout = 5 min) so that a child's own timeout is the primary release and this
|
|
649
|
+
// only catches children that declare none.
|
|
650
|
+
const DRAIN_MAX_CHILD_WAIT_MS = 600_000
|
|
651
|
+
|
|
652
|
+
const REQUIRED_FINAL_BLOCK: Readonly<Record<string, FinalBlockTag>> = { researcher: 'report', reviewer: 'review' }
|
|
643
653
|
|
|
644
654
|
// Bounded re-prompt budget for the required-block guard, mirroring the channel
|
|
645
655
|
// empty-response guard's MAX_EMPTY_TURN_RETRIES. A subagent that owes a result
|
|
@@ -648,24 +658,37 @@ const REQUIRED_FINAL_BLOCK: Readonly<Record<string, FinalBlockTag>> = { research
|
|
|
648
658
|
const MAX_REQUIRED_BLOCK_RETRIES = 2
|
|
649
659
|
|
|
650
660
|
// The recovery nudge. It MUST forbid tools: the known failure mode is a provider
|
|
651
|
-
// retry loop on
|
|
661
|
+
// retry loop on a block-producing tool call, so re-driving the tool path would
|
|
652
662
|
// just re-trigger the loop. Asking for the block as plain text is the repair.
|
|
663
|
+
// The tail is tag-specific: each block has different mandatory child fields.
|
|
653
664
|
function renderRequiredBlockRetryNudge(tag: FinalBlockTag): string {
|
|
665
|
+
const tail =
|
|
666
|
+
tag === 'report'
|
|
667
|
+
? 'in particular do NOT call write_report. Do NOT continue researching or spawn more subagents.\n\nIf the report file was not successfully written, still emit the block: set <report_file>none</report_file>, <confidence>low</confidence> (explain the report artifact was not completed), and note in <open_questions> that the run should be retried.'
|
|
668
|
+
: `Do NOT re-run gh, diff reads, or spawn more subagents.\n\nEmit the block from the analysis you have already done: include your <summary>, whatever <finding> items you can support with evidence, and a <verdict> (approve | request-changes | comment). Only use a real verdict if you actually reached one. If you could NOT analyze enough to decide, do NOT invent a verdict — set <verdict>${INCOMPLETE_REVIEW_VERDICT}</verdict> exactly (this signals an incomplete review; the parent will not treat it as approve/request-changes/comment, even on a re-review).`
|
|
654
669
|
return `---
|
|
655
670
|
**[SYSTEM MESSAGE — not from a human]**
|
|
656
671
|
|
|
657
672
|
Your previous turn ended without the required <${tag}> block. This is an automated runtime recovery signal, not a human message.
|
|
658
673
|
|
|
659
|
-
Emit the final <${tag}>...</${tag}> block NOW as plain assistant text. Do NOT call any tools —
|
|
660
|
-
|
|
661
|
-
If the report file was not successfully written, still emit the block: set <report_file>none</report_file>, <confidence>low</confidence> (explain the report artifact was not completed), and note in <open_questions> that the run should be retried.
|
|
674
|
+
Emit the final <${tag}>...</${tag}> block NOW as plain assistant text. Do NOT call any tools — ${tail}
|
|
662
675
|
|
|
663
676
|
Output exactly one <${tag}> block and nothing else.`
|
|
664
677
|
}
|
|
665
678
|
|
|
679
|
+
// Unambiguous marker on a synthesized incomplete-review fallback. The parent's
|
|
680
|
+
// GitHub re-review flow overrides a `comment` verdict into a decisive APPROVE /
|
|
681
|
+
// REQUEST_CHANGES when prior blockers look resolved — which would let a review
|
|
682
|
+
// that NEVER RAN post a formal verdict. So the fallback carries no real verdict:
|
|
683
|
+
// it uses this sentinel in place of approve|request-changes|comment, and the
|
|
684
|
+
// GitHub skill keys off it to post only an honest failure comment and leave
|
|
685
|
+
// review state untouched. Kept in sync with the exemption in
|
|
686
|
+
// src/skills/typeclaw-channel-github/SKILL.md.
|
|
687
|
+
export const INCOMPLETE_REVIEW_VERDICT = 'incomplete-review-not-a-verdict'
|
|
688
|
+
|
|
666
689
|
// The terminal graceful fallback when the nudges are exhausted. It fabricates NO
|
|
667
|
-
// findings — only a structured
|
|
668
|
-
//
|
|
690
|
+
// findings — only a structured "could not complete" notice — so the parent gets
|
|
691
|
+
// a usable result instead of stale `<analysis>` or a hard error.
|
|
669
692
|
function renderMissingRequiredBlockFallback(name: string, tag: FinalBlockTag): string {
|
|
670
693
|
if (tag === 'report') {
|
|
671
694
|
return `<report>
|
|
@@ -682,6 +705,16 @@ low — no complete research report artifact was produced.
|
|
|
682
705
|
The original research request remains unresolved; rerun the ${name} subagent or gather the sources directly.
|
|
683
706
|
</open_questions>
|
|
684
707
|
</report>`
|
|
708
|
+
}
|
|
709
|
+
if (tag === 'review') {
|
|
710
|
+
return `<review>
|
|
711
|
+
<summary>
|
|
712
|
+
INCOMPLETE REVIEW — NOT A VERDICT. The ${name} subagent could not complete a review in this run: it ended without emitting the required <review> block. No findings were produced and no verdict was reached — do not treat any earlier text as a verdict, and do NOT map this to APPROVE/REQUEST_CHANGES/COMMENT (including on a re-review). Re-request the review; if it still cannot complete, post an honest "review could not be completed" note and leave existing review state unchanged.
|
|
713
|
+
</summary>
|
|
714
|
+
<findings>
|
|
715
|
+
</findings>
|
|
716
|
+
<verdict>${INCOMPLETE_REVIEW_VERDICT}</verdict>
|
|
717
|
+
</review>`
|
|
685
718
|
}
|
|
686
719
|
return `<${tag}>\nThe ${name} subagent ended without emitting the required <${tag}> block and could not recover; rerun it or inspect the transcript.\n</${tag}>`
|
|
687
720
|
}
|
|
@@ -23,13 +23,33 @@ export class ThrottleCircuit {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
isOpen(key: ThrottleCircuitKey): boolean {
|
|
26
|
-
|
|
26
|
+
return this.isEntryOpen(this.keyId(key))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
isProviderOpen(key: ThrottleCircuitKey): boolean {
|
|
30
|
+
return this.isEntryOpen(this.providerKeyId(key))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
recordThrottle(key: ThrottleCircuitKey): void {
|
|
34
|
+
this.recordFailure(this.keyId(key))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
recordProviderTrip(key: ThrottleCircuitKey): void {
|
|
38
|
+
this.recordFailure(this.providerKeyId(key))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
recordSuccess(key: ThrottleCircuitKey): void {
|
|
42
|
+
this.entries.delete(this.keyId(key))
|
|
43
|
+
this.entries.delete(this.providerKeyId(key))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private isEntryOpen(id: string): boolean {
|
|
47
|
+
const entry = this.entries.get(id)
|
|
27
48
|
if (entry === undefined) return false
|
|
28
49
|
return this.now() < entry.openUntil
|
|
29
50
|
}
|
|
30
51
|
|
|
31
|
-
|
|
32
|
-
const id = this.keyId(key)
|
|
52
|
+
private recordFailure(id: string): void {
|
|
33
53
|
const now = this.now()
|
|
34
54
|
const entry = this.entries.get(id) ?? { failures: [], openUntil: 0 }
|
|
35
55
|
entry.failures = entry.failures.filter((ts) => now - ts <= THROTTLE_WINDOW_MS)
|
|
@@ -38,8 +58,8 @@ export class ThrottleCircuit {
|
|
|
38
58
|
this.entries.set(id, entry)
|
|
39
59
|
}
|
|
40
60
|
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
private providerKeyId(key: ThrottleCircuitKey): string {
|
|
62
|
+
return `${key.profile ?? 'default'}:${providerForModelRef(key.ref)}`
|
|
43
63
|
}
|
|
44
64
|
|
|
45
65
|
private keyId(key: ThrottleCircuitKey): string {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// SECURITY/CORRECTNESS: rules are gated on BOTH the emitting tool name and a
|
|
2
|
+
// verbatim upstream pi-coding-agent error substring. `bash` (the only tool that
|
|
3
|
+
// raises sandbox/subagent-policy errors) is never in a rule's tool set, and
|
|
4
|
+
// abort/cleanup/guard failures never match any pattern, so internal control
|
|
5
|
+
// errors are never decorated with a nonsensical "read the file first" hint. A
|
|
6
|
+
// wording drift upstream simply stops decorating (fails safe) rather than
|
|
7
|
+
// mis-firing on the wrong error class.
|
|
8
|
+
|
|
9
|
+
const HINT_PREFIX = 'Hint:'
|
|
10
|
+
|
|
11
|
+
type RemediationRule = {
|
|
12
|
+
// Built-in tool names whose thrown errors this rule may decorate.
|
|
13
|
+
tools: readonly string[]
|
|
14
|
+
// `upstream` is the exact substring the matching pi tool emits, kept next to
|
|
15
|
+
// the pattern so the regex can be re-verified against the dependency on bumps.
|
|
16
|
+
upstream: string
|
|
17
|
+
test: RegExp
|
|
18
|
+
hint: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// First matching rule wins; keep the most specific patterns first. Upstream
|
|
22
|
+
// sources: node_modules/@mariozechner/pi-coding-agent/dist/core/tools/{edit,read,ls,grep}.js
|
|
23
|
+
const RULES: readonly RemediationRule[] = [
|
|
24
|
+
{
|
|
25
|
+
tools: ['edit'],
|
|
26
|
+
upstream: 'Could not find edits[0] in <path>. / Could not find the exact text in <path>.',
|
|
27
|
+
test: /Could not find (the exact text|edits\[\d+\]) in /i,
|
|
28
|
+
hint: `${HINT_PREFIX} the oldText must match the file byte-for-byte. Re-read the file with the \`read\` tool to copy the exact current text — including all whitespace, indentation, and newlines — then retry \`edit\` with that exact oldText. Do not hand-type or reformat it.`,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
tools: ['edit'],
|
|
32
|
+
upstream: 'No changes made to <path>. The replacement(s) produced identical content',
|
|
33
|
+
test: /No changes made to .+\. The replacements? produced identical content/i,
|
|
34
|
+
hint: `${HINT_PREFIX} the newText is identical to the oldText, so the edit is a no-op. If you intended a change, make oldText and newText differ; if the file is already correct, do not retry this edit.`,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
tools: ['read'],
|
|
38
|
+
upstream: 'Offset N is beyond end of file (M lines total)',
|
|
39
|
+
test: /Offset \d+ is beyond end of file/i,
|
|
40
|
+
hint: `${HINT_PREFIX} the file has fewer lines than the offset you requested. Read from a smaller offset, or read the whole file without an offset first to see its length.`,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
// typeclaw-owned: enforceAndPinToolFiles (src/agent/tool-file-safety.ts,
|
|
44
|
+
// throws at :95 and :451) runs BEFORE tool.execute inside the builtin
|
|
45
|
+
// wrapper, so a missing input path surfaces THIS string — not the upstream
|
|
46
|
+
// `File not found:` — for every input-pinning tool. This is the common
|
|
47
|
+
// missing-path case for read/grep/find/ls.
|
|
48
|
+
tools: ['read', 'ls', 'grep', 'find'],
|
|
49
|
+
upstream: 'tool input did not exist while being authorized: <path>',
|
|
50
|
+
test: /tool input did not exist while being authorized: /i,
|
|
51
|
+
hint: `${HINT_PREFIX} the path does not exist. Verify it before retrying — use \`ls\` on the parent directory or \`find\` to locate the file. Paths are relative to the agent root unless absolute.`,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
// Fallback for the raw upstream not-found strings some tools still emit when
|
|
55
|
+
// a path resolves at pin time but disappears before the tool reads it.
|
|
56
|
+
tools: ['read', 'ls', 'grep', 'find'],
|
|
57
|
+
upstream: 'File not found: <path> / Path not found: <path>',
|
|
58
|
+
test: /(File|Path) not found: /i,
|
|
59
|
+
hint: `${HINT_PREFIX} verify the path before retrying — use \`ls\` on the parent directory or \`find\` to locate the file. Paths are relative to the agent root unless absolute.`,
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
export function remediateToolErrorMessage(toolName: string, message: string): string {
|
|
64
|
+
if (typeof message !== 'string' || message.length === 0) return message
|
|
65
|
+
for (const rule of RULES) {
|
|
66
|
+
if (!rule.tools.includes(toolName)) continue
|
|
67
|
+
if (!rule.test.test(message)) continue
|
|
68
|
+
if (message.includes(rule.hint)) return message
|
|
69
|
+
return `${message}\n\n${rule.hint}`
|
|
70
|
+
}
|
|
71
|
+
return message
|
|
72
|
+
}
|