typeclaw 0.39.4 → 0.39.6
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 +1 -1
- package/src/agent/attention-escalation.ts +11 -1
- package/src/agent/subagents.ts +6 -2
- package/src/agent/tools/channel-reply.ts +48 -3
- package/src/agent/tools/ddg.ts +40 -5
- package/src/agent/tools/keyed-semaphore.ts +114 -0
- package/src/agent/tools/search-retry.ts +82 -0
- package/src/bundled-plugins/explorer/explorer.ts +5 -0
- package/src/bundled-plugins/memory/README.md +2 -2
- package/src/bundled-plugins/memory/append-tool.ts +42 -4
- package/src/bundled-plugins/memory/memory-logger.ts +7 -3
- package/src/bundled-plugins/reviewer/reviewer.ts +3 -1
- package/src/bundled-plugins/scout/scout.ts +5 -0
- package/src/channels/adapters/github/permission-guidance.ts +18 -0
- package/src/channels/engagement.ts +17 -2
- package/src/cli/channel.ts +7 -11
- package/src/cli/init.ts +2 -2
- package/src/cli/plugin-commands-dispatch.ts +7 -1
- package/src/cli/ui.ts +32 -22
- package/src/inspect/index.ts +2 -3
- package/src/run/codex-fetch-observer.ts +26 -10
- package/src/run/fatal-guard.ts +230 -0
- package/src/run/index.ts +90 -26
- package/src/secrets/oauth-xai.ts +8 -2
- package/src/secrets/webex-renewal.ts +3 -0
- package/src/skills/typeclaw-channel-github/SKILL.md +59 -13
package/src/secrets/oauth-xai.ts
CHANGED
|
@@ -221,9 +221,15 @@ async function exchangeAuthorizationCode(
|
|
|
221
221
|
return toCredentials(token)
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
type StartCallbackServerFn = (expectedState: string) => Promise<CallbackServer | null>
|
|
225
|
+
|
|
226
|
+
export async function loginXai(
|
|
227
|
+
callbacks: OAuthLoginCallbacks,
|
|
228
|
+
fetchImpl: FetchFn = fetch,
|
|
229
|
+
startServer: StartCallbackServerFn = startCallbackServer,
|
|
230
|
+
): Promise<OAuthCredentials> {
|
|
225
231
|
const { verifier, challenge } = await generatePkce()
|
|
226
|
-
const server = await
|
|
232
|
+
const server = await startServer(verifier)
|
|
227
233
|
let code: string | undefined
|
|
228
234
|
try {
|
|
229
235
|
const authParams = new URLSearchParams({
|
|
@@ -83,6 +83,9 @@ export async function decideRenewal(block: WebexChannelBlock, ctx: WebexRenewalC
|
|
|
83
83
|
plaintextPassword = decrypt(account.encryptedPassword, key, {
|
|
84
84
|
containerName: ctx.containerName,
|
|
85
85
|
accountId: account.account_id,
|
|
86
|
+
// Must match the AAD `runWebexBootstrap` seals with (init/webex-auth.ts);
|
|
87
|
+
// the default 'kakaotalk-password' never authenticates a webex blob.
|
|
88
|
+
purpose: 'webex-password',
|
|
86
89
|
})
|
|
87
90
|
} catch (err) {
|
|
88
91
|
return classifyDecryptFailure(err, accountId)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: typeclaw-channel-github
|
|
3
|
-
description: Use this skill BEFORE every `channel_reply` or `channel_send` call whose adapter is `github`, AND before composing replies to GitHub-originated inbounds, AND before opening new issues or PRs with `gh`, AND ALWAYS when you are asked to review a PR — whether the inbound says "requested your review on PR #N" / "requested a review from team @… on PR #N", or a human asks for a review in plain language in an issue/PR body or comment ("@bot review this", "can you take a look at #123"). On a review request you delegate the analysis to the `reviewer` subagent, which produces line-anchored findings, then you post them as an inline review via `gh api`. GitHub renders **real markdown** — `**bold**`, `## headings`, `| tables |`, fenced code blocks, and `inline code` all render natively. Use rich markdown freely. GitHub cannot send file attachments via API — do not call `channel_send` with attachments on github chats. GitHub has no typing indicator. PR review threads use `thread` keyed on the root comment id; reply to a thread to stay in it, or omit `thread` to post a top-level issue/PR comment. When a review comment **you authored** gets addressed — the author pushed a fix or replied that resolves it — verify the fix at the PR's head SHA and then resolve the thread by acknowledging with `channel_reply({ …, resolve_review_thread: true })`, which resolves the thread before posting the reply (see "Resolving review threads you authored" below); resolving is the close-out that tells the author the concern is settled. To open new issues or PRs use the `gh` CLI — `GH_TOKEN` is pre-set by the adapter. Read this skill before composing anything on GitHub.
|
|
3
|
+
description: Use this skill BEFORE every `channel_reply` or `channel_send` call whose adapter is `github`, AND before composing replies to GitHub-originated inbounds, AND before opening new issues or PRs with `gh`, AND ALWAYS when you are asked to review a PR — whether the inbound says "requested your review on PR #N" / "requested a review from team @… on PR #N", or a human asks for a review in plain language in an issue/PR body or comment ("@bot review this", "can you take a look at #123"). On a review request you delegate the analysis to the `reviewer` subagent, which produces line-anchored findings, then you post them as an inline review via `gh api`. ALWAYS settle PR authorship first (triage #0): on a PR **you** opened you are the CONTRIBUTOR/author, not its reviewer — "address the review" / "리뷰 반영" / "fix the feedback" / a `CHANGES_REQUESTED` on your own PR means change the code, push, and reply, NOT spawn the reviewer or post a formal verdict; you never review your own PR. The reviewer persona is for other people's PRs only. GitHub renders **real markdown** — `**bold**`, `## headings`, `| tables |`, fenced code blocks, and `inline code` all render natively. Use rich markdown freely. GitHub cannot send file attachments via API — do not call `channel_send` with attachments on github chats. GitHub has no typing indicator. PR review threads use `thread` keyed on the root comment id; reply to a thread to stay in it, or omit `thread` to post a top-level issue/PR comment. When a review comment **you authored** gets addressed — the author pushed a fix or replied that resolves it — verify the fix at the PR's head SHA and then resolve the thread by acknowledging with `channel_reply({ …, resolve_review_thread: true })`, which resolves the thread before posting the reply (see "Resolving review threads you authored" below); resolving is the close-out that tells the author the concern is settled. To open new issues or PRs use the `gh` CLI — `GH_TOKEN` is pre-set by the adapter. Read this skill before composing anything on GitHub.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
GitHub renders normal Markdown in issues, PRs, discussions, and review comments. Use headings, lists, tables, fenced code blocks, links, and inline code when they improve clarity.
|
|
@@ -18,33 +18,79 @@ A successful `channel_reply` ends your turn by default — the runtime stops the
|
|
|
18
18
|
|
|
19
19
|
Before you pick an action, classify the inbound. Skipping this step is how a PR ends up with a "looks good" comment but no approval: the model pattern-matches on the prose ("they fixed it → resolve the thread") and never asks whether it owes the PR a formal review. Answer these in order; the **first** that matches decides your path. Do not skip ahead.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
0. **Whose PR is this — mine or someone else's?** On any `pr:N` inbound, **before** you ask anything about reviewing, settle authorship. Fetch the author and compare it to your own login (`<your-login>`, your GitHub App login — typically `name[bot]`):
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
gh pr view <N> --repo owner/repo --json author --jq '.author.login'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- **The PR author is you (`<your-login>`).** You are the **contributor/author** on this PR, not its reviewer. Feedback on it — a review, a "리뷰 반영 부탁드려요" / "address the review" / "please apply the feedback" / "fixed?" comment, a `CHANGES_REQUESTED` someone else left — is yours to **address as the author**: read it, change the code, push, and reply. Go to the **contributor flow** ("When the PR is yours"). **You never review your own PR**, and you never spawn the `reviewer` subagent on it — GitHub does not even let an author formally review their own PR, so an attempt produces a self-addressed "review" comment, which is the exact persona-confusion bug to avoid. Gates 1–2 below (review obligations / review requests) describe the _reviewer_ persona and **do not apply when the PR is yours** — skip straight to the contributor flow.
|
|
28
|
+
- **The PR author is someone else.** You may be its reviewer. Continue to gate 1.
|
|
29
|
+
|
|
30
|
+
This gate is first because everything after it assumes the reviewer persona. "Address the review" sounds identical whether you wrote the PR or someone else did; only the author check disambiguates, and getting it wrong is what makes the agent review its own work.
|
|
31
|
+
|
|
32
|
+
1. **(Someone else's PR.) Do I have an unresolved blocking obligation on it?** On any `pr:N` inbound, before anything else, check whether you owe this PR a verdict you have not yet landed. Check **both** signals below — checking only formal review state misses the very failure this gate exists to catch, because a prior block may never have become formal state:
|
|
22
33
|
- **Formal review state.** Run the step-1 re-review query in the PR review flow (`gh api --paginate --slurp /repos/owner/repo/pulls/<N>/reviews --jq '…'` filtered to `{CHANGES_REQUESTED, APPROVED}`). If your latest **blocking decision** is `CHANGES_REQUESTED`, you have a live sticky block.
|
|
23
34
|
- **Flat-comment blockers you authored.** A prior "request changes" may have been posted as a plain PR/issue comment instead of a formal review — in which case **no `CHANGES_REQUESTED` row exists** and the query above returns empty even though you blocked the PR in prose. So also scan your own recent comments (`gh api /repos/owner/repo/issues/<N>/comments --jq '[.[] | select(.user.login == "<your-login>")]'`) for one that requested changes / raised blockers and has not since been superseded by a formal review or a clear retraction. For routing, a blocking comment you wrote is as binding as a formal `CHANGES_REQUESTED`. **A courtesy acknowledgement is not a retraction.** A reply you posted like "nice, that closes the hole" / "thanks, looks good" / "✅" does **not** supersede or retract a blocker you raised — it is a chat ack, not a verdict, and it carries no review state. The blocker stays binding until you land a **formal** `APPROVE`/`REQUEST_CHANGES` (or dismiss your prior review). So when an earlier "✅ thanks" of yours is the only thing between your blocker and the author's address-comment, the blocker is **still live** and this inbound is a re-review — do not let your own ack downgrade it.
|
|
24
35
|
|
|
25
36
|
If **either** signal shows an unresolved blocker you raised, this inbound is a **re-review** — go to the **PR review flow** regardless of how it is phrased. An author commenting "fixed both issues" / "addressed your feedback" / "pushed a fix" is a re-review trigger, **not** a thread-resolve trigger. A re-review is closed by re-deciding the verdict and landing a **formal** review via `POST /pulls/<N>/reviews`: `APPROVE` clears a sticky `CHANGES_REQUESTED`; a comment or a flat reply clears neither a formal block nor a flat-comment blocker — it just strands the verdict again, which is the original bug.
|
|
26
37
|
|
|
27
|
-
2. **Am I being asked to review (first-time)?** Explicit `review_requested` inbound, or a human asking in plain language ("review this", "take a look at #N"). → **PR review flow** (see "When you are being asked to review").
|
|
38
|
+
2. **(Someone else's PR.) Am I being asked to review (first-time)?** Explicit `review_requested` inbound, or a human asking in plain language ("review this", "take a look at #N"). → **PR review flow** (see "When you are being asked to review").
|
|
28
39
|
|
|
29
40
|
3. **Is this a reply inside an inline review thread I authored** (`pr:N` with `thread` set, on a thread whose root comment is mine)? → verify the fix at head SHA and **resolve the thread** (see "Resolving review threads you authored"). `resolve_review_thread` only works when `thread` is set on the origin; if there is **no** `thread`, this branch does not apply — do not attempt it, fall through to the table below.
|
|
30
41
|
|
|
31
42
|
4. **None of the above** → use the routing table below.
|
|
32
43
|
|
|
33
|
-
> The decisive
|
|
44
|
+
> The decisive questions are **#0 then #1**. First settle authorship (#0): if the PR is yours you are the contributor and gates 1–2 do not apply — address the feedback, never review your own work. Only on someone else's PR does #1 govern: a blocking verdict you owe a PR is never discharged by a `channel_reply` or an `issue_comment` — neither carries review state, and neither clears a sticky `CHANGES_REQUESTED`. This applies to an **unresolved blocking obligation** (a live `CHANGES_REQUESTED`, or an unretracted blocker you raised in a flat comment), not to a stale `APPROVED` or a past non-blocking comment — those impose no closeout duty. When you do owe a block, the close-out is always a formal review via `POST /pulls/<N>/reviews`.
|
|
34
45
|
|
|
35
46
|
## What to do, by inbound type
|
|
36
47
|
|
|
37
48
|
Every GitHub inbound lands on a `chat` keyed by its subject: `issue:N`, `pr:N`, or `discussion:N`. **Run the triage above first.** Only if no triage branch matched do you pick an action from this table. The default action for anything addressed to you is a normal `channel_reply` in that thread; the **PR review flow** is the exception that requires delegation.
|
|
38
49
|
|
|
39
|
-
| Inbound
|
|
40
|
-
|
|
|
41
|
-
| **New issue** (`issue:N`)
|
|
42
|
-
| **Issue comment** (`issue:N`)
|
|
43
|
-
| **PR conversation comment** (`pr:N`, no `thread`)
|
|
44
|
-
| **PR review-thread reply** (`pr:N`, `thread` set)
|
|
45
|
-
| **A submitted review** (`pr:N`)
|
|
46
|
-
| **
|
|
47
|
-
| **
|
|
50
|
+
| Inbound | Looks like | What to do |
|
|
51
|
+
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| **New issue** (`issue:N`) | A freshly opened issue body. | Triage or answer it. `channel_reply` on `issue:N`. Open follow-up issues/PRs with `gh` if needed. |
|
|
53
|
+
| **Issue comment** (`issue:N`) | A comment on an issue. | Reply in the issue thread with `channel_reply`. |
|
|
54
|
+
| **PR conversation comment** (`pr:N`, no `thread`) | A comment on a PR's main conversation (GitHub models PR comments as issue comments). | Reply on the PR with `channel_reply`. **If the text asks you to review → go to the PR review flow.** |
|
|
55
|
+
| **PR review-thread reply** (`pr:N`, `thread` set) | A reply on an existing inline review comment thread. | Stay in the thread: `channel_reply` with `thread` kept as-is. **If it addresses a comment you authored → verify and resolve the thread (below).** |
|
|
56
|
+
| **A submitted review** (`pr:N`) | Someone submitted a formal review (approve / changes / comment) on a PR. | **If the PR is yours (triage #0) → contributor flow:** address the feedback, then reply. Otherwise react if a response is warranted. `channel_reply` on `pr:N`. |
|
|
57
|
+
| **Feedback on your own PR** (`pr:N`, author = `<your-login>`) | A review, a `CHANGES_REQUESTED`, or an "address the review / fixed?" comment on a PR **you** opened. | **Contributor flow** ("When the PR is yours"). Address the feedback as the author — never review or formally approve your own PR. |
|
|
58
|
+
| **New discussion / discussion comment** (`discussion:N`) | A discussion thread or a comment in one. | Reply with `channel_reply` on `discussion:N`. |
|
|
59
|
+
| **Review requested** (`pr:N`) | See "When you are being asked to review" below. | **PR review flow.** |
|
|
60
|
+
|
|
61
|
+
### When the PR is yours — addressing review feedback (contributor)
|
|
62
|
+
|
|
63
|
+
Triage #0 sends you here whenever the `pr:N` was opened by **you** (`<your-login>`). On your own PR you wear the **author/contributor** hat, which is the mirror image of the reviewer flow below:
|
|
64
|
+
|
|
65
|
+
- **You do not review it.** Do **not** spawn the `reviewer` subagent, do **not** run `gh pr diff` to form a verdict, and do **not** call `POST /pulls/<N>/reviews` — GitHub forbids an author from formally reviewing their own PR, so the attempt degrades into a self-addressed "## Review … Concern 1/2" comment on your own work. That self-review is the precise bug this branch exists to prevent. The reviewer persona (spawn → `<review>` → formal verdict) is for **other people's** PRs only.
|
|
66
|
+
- **You address the feedback.** Read what the reviewer (human or bot) actually said. For each point: either change the code to fix it, or reply explaining why no change is needed. This is ordinary contributor work, not a review.
|
|
67
|
+
|
|
68
|
+
The flow:
|
|
69
|
+
|
|
70
|
+
1. **Read the feedback at the current head.** Pull the review comments and any `CHANGES_REQUESTED` summary so you know exactly what is being asked.
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
gh pr view <N> --repo owner/repo --json reviews,comments,headRefOid \
|
|
74
|
+
--jq '{reviews: [.reviews[] | {author: .author.login, state, body}], head: .headRefOid}'
|
|
75
|
+
gh api /repos/owner/repo/pulls/<N>/comments --jq '[.[] | {path, line, user: .user.login, body}]'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
2. **Make the changes on the PR's branch.** Check out the PR's head branch, make the minimal fixes the feedback calls for, and push. Committing and pushing to your own branch is `typeclaw-git` territory — follow it for commit hygiene. Do **not** open a _new_ PR to fix your existing one; push to the same branch so the open PR updates in place.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
gh pr checkout <N> --repo owner/repo
|
|
82
|
+
# …edit files, then commit + push per typeclaw-git…
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If a point is a genuine disagreement (the reviewer is mistaken, or the behavior is intentional), don't silently change it — reply in the thread with your reasoning instead.
|
|
86
|
+
|
|
87
|
+
3. **Reply to the feedback as the author.** After pushing, acknowledge each addressed thread with a normal `channel_reply` (keep `thread` set to stay in the inline thread; omit it for the PR conversation). Say what you changed ("Fixed — switched to the wiki-link form in `abc1234`") or why you didn't ("Left as-is — this path can't be null because …"). Keep it short.
|
|
88
|
+
- **Do not resolve the threads.** On your own PR the open inline threads were authored by your **reviewer**, not by you — and the base principle is _whoever opened the thread closes it_. Resolving is the reviewer's call once they're satisfied; the runtime enforces this (it only lets you resolve threads whose root comment **you** authored). Push the fix, reply, and leave the thread for the reviewer to close.
|
|
89
|
+
- **Do not post a verdict.** "LGTM", "Approved", "Request changes" are reviewer words. As the author you reply in plain prose; you never emit a review verdict on your own PR.
|
|
90
|
+
|
|
91
|
+
4. **If CI is failing on your PR**, that's also contributor work: read the failing check, fix the cause on the branch, and push. You can't always read another system's CI logs — if you can't, say so and ask for the error rather than guessing.
|
|
92
|
+
|
|
93
|
+
That's the whole contributor loop: read feedback → fix on the branch → push → reply. No subagent, no formal review, no thread resolution.
|
|
48
94
|
|
|
49
95
|
### When you are being asked to review
|
|
50
96
|
|