typeclaw 0.48.7 → 0.48.9

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 (108) hide show
  1. package/auth.schema.json +15 -1
  2. package/package.json +1 -1
  3. package/secrets.schema.json +15 -1
  4. package/src/agent/guard-types.ts +25 -0
  5. package/src/agent/guards.ts +102 -0
  6. package/src/agent/index.ts +33 -3
  7. package/src/agent/multimodal/read-redirect.ts +8 -9
  8. package/src/agent/plugin-tools.ts +283 -148
  9. package/src/agent/provider-error.ts +6 -1
  10. package/src/agent/reload-tool.ts +12 -5
  11. package/src/agent/retry-same-ref.ts +95 -36
  12. package/src/agent/session-origin.ts +13 -1
  13. package/src/agent/system-prompt.ts +14 -3
  14. package/src/agent/todo/continuation-policy.ts +3 -4
  15. package/src/agent/tool-file-safety.ts +36 -13
  16. package/src/agent/tools/channel-reply.ts +39 -2
  17. package/src/agent/tools/channel-send.ts +45 -2
  18. package/src/agent/tools/post-github-review.ts +31 -13
  19. package/src/agent/tools/spawn-subagent.ts +15 -0
  20. package/src/agent/tools/webfetch/inline-style-visibility.ts +2 -2
  21. package/src/agent/tools/webfetch/strategies/readability.ts +109 -10
  22. package/src/agent/turn-runner.ts +23 -19
  23. package/src/bundled-plugins/backup/git-auth.ts +7 -4
  24. package/src/bundled-plugins/backup/subagents.ts +1 -1
  25. package/src/bundled-plugins/bun-hygiene/README.md +23 -20
  26. package/src/bundled-plugins/bun-hygiene/index.ts +1 -7
  27. package/src/bundled-plugins/bun-hygiene/policy.ts +111 -35
  28. package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +44 -2
  29. package/src/bundled-plugins/github-cli-auth/gh-store.ts +733 -0
  30. package/src/bundled-plugins/github-cli-auth/git-askpass.ts +25 -0
  31. package/src/bundled-plugins/github-cli-auth/git-command.ts +209 -31
  32. package/src/bundled-plugins/github-cli-auth/git-credential-env.ts +151 -0
  33. package/src/bundled-plugins/github-cli-auth/index.ts +236 -38
  34. package/src/bundled-plugins/github-cli-auth/review-recorder.ts +5 -0
  35. package/src/bundled-plugins/guard/index.ts +2 -25
  36. package/src/bundled-plugins/guard/keys.ts +8 -0
  37. package/src/bundled-plugins/guard/policies/non-workspace-write.ts +7 -8
  38. package/src/bundled-plugins/guard/policy.ts +1 -7
  39. package/src/bundled-plugins/security/policies/git-exfil.ts +22 -30
  40. package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +2 -4
  41. package/src/bundled-plugins/security/policies/private-surface-read.ts +8 -6
  42. package/src/bundled-plugins/security/policies/secret-exfil-bash.ts +2 -5
  43. package/src/bundled-plugins/security/policies/secret-exfil-read.ts +2 -4
  44. package/src/bundled-plugins/security/policies/session-search-secrets.ts +2 -4
  45. package/src/bundled-plugins/security/policies/system-prompt-leak.ts +2 -4
  46. package/src/bundled-plugins/security/policy.ts +0 -8
  47. package/src/channels/adapters/discord-bot-slash-commands.ts +22 -0
  48. package/src/channels/adapters/discord-bot.ts +2 -1
  49. package/src/channels/adapters/discord-classify.ts +16 -4
  50. package/src/channels/adapters/discord.ts +20 -8
  51. package/src/channels/adapters/github/dedup.ts +37 -8
  52. package/src/channels/adapters/github/inbound.ts +241 -46
  53. package/src/channels/adapters/github/review-state.ts +13 -9
  54. package/src/channels/adapters/github/review-thread-resolver.ts +52 -20
  55. package/src/channels/adapters/slack-bot.ts +13 -3
  56. package/src/channels/adapters/slack-classify.ts +40 -5
  57. package/src/channels/adapters/slack.ts +3 -9
  58. package/src/channels/adapters/teams.ts +8 -6
  59. package/src/channels/adapters/webex-bot-classify.ts +4 -33
  60. package/src/channels/adapters/webex-bot.ts +2 -4
  61. package/src/channels/adapters/webex-classify.ts +4 -33
  62. package/src/channels/adapters/webex-format.ts +36 -0
  63. package/src/channels/adapters/webex.ts +2 -4
  64. package/src/channels/continuation-willingness.ts +64 -39
  65. package/src/channels/github-rereview-guard.ts +20 -0
  66. package/src/channels/github-review-turn-ledger.ts +11 -1
  67. package/src/channels/github-review-verdict-coordinator.ts +475 -41
  68. package/src/channels/github-verdict-activity.ts +14 -5
  69. package/src/channels/manager.ts +17 -1
  70. package/src/channels/persistence.ts +89 -5
  71. package/src/channels/router.ts +1187 -254
  72. package/src/channels/types.ts +21 -5
  73. package/src/cli/compose-stats.ts +6 -7
  74. package/src/cli/compose-status.ts +6 -7
  75. package/src/cli/compose-usage.ts +6 -7
  76. package/src/cli/stats.ts +6 -7
  77. package/src/cli/status.ts +7 -8
  78. package/src/cli/ui.ts +4 -4
  79. package/src/container/start.ts +41 -1
  80. package/src/container/stop.ts +2 -1
  81. package/src/cron/consumer.ts +30 -9
  82. package/src/cron/scheduler.ts +24 -9
  83. package/src/doctor/channel-checks.ts +64 -0
  84. package/src/doctor/report.ts +8 -8
  85. package/src/dreams/render.ts +2 -2
  86. package/src/init/dockerfile.ts +8 -1
  87. package/src/inspect/render.ts +2 -2
  88. package/src/path-safety/real-intended-path.ts +14 -1
  89. package/src/permissions/permissions.ts +10 -2
  90. package/src/permissions/resolve.ts +8 -2
  91. package/src/plugin/core-tool-names.ts +15 -0
  92. package/src/plugin/hooks.ts +37 -3
  93. package/src/plugin/registry.ts +7 -3
  94. package/src/run/index.ts +33 -7
  95. package/src/sandbox/build.ts +39 -10
  96. package/src/sandbox/policy.ts +6 -2
  97. package/src/secrets/export-github-cli-store.ts +158 -0
  98. package/src/secrets/index.ts +19 -1
  99. package/src/secrets/provision-github-cli-store.ts +322 -0
  100. package/src/secrets/schema.ts +13 -7
  101. package/src/secrets/storage.ts +30 -0
  102. package/src/shared/index.ts +2 -0
  103. package/src/shared/style-text.ts +13 -0
  104. package/src/skills/typeclaw-channel-github/SKILL.md +24 -12
  105. package/src/skills/typeclaw-config/SKILL.md +3 -1
  106. package/src/skills/typeclaw-github-contributing/SKILL.md +6 -2
  107. package/src/skills/typeclaw-permissions/SKILL.md +11 -22
  108. package/src/usage/report.ts +3 -3
@@ -101,7 +101,7 @@ The security plugin classifies each guard on a two-axis policy:
101
101
  - **high — direct audience-leak.** Bypass sends data to a third-party audience outside the operator's control loop with NO operator-visible intermediate step. Inhabitants: `outboundSecret`, `systemPromptLeak`, `gitRemoteTainted`. **`owner` bypasses by default; `trusted`, `member`, `guest` do not.** The canonical case is **owner-in-public-channel**: an owner-permissioned operator asking the agent to "post deploy status to #general" can silently leak a `Bearer ghp_…` line. The defense lives in `roles.owner.match[]` discipline — the default is TUI-only, where a human is present. Configs that widen owner to a channel author should narrow the match or strip `security.bypass.high` (and the wildcard sentinel) from `roles.owner.permissions[]` for those origins.
102
102
  - **medium — silent-attack OR operator-reviewable state.** Two sub-shapes share this tier because they share a defense story (operator review catches it before the privileged effect escapes). (a) _silent-attack_: `secretExfilBash`, `secretExfilRead`, `ssrf`, and `sessionSearchSecrets` are heuristic/plugin defenses for non-canonical surfaces; bypassing them still cannot expose canonical credential stores or reusable child auth. For `ssrf`, a bypass skips only the heuristic plugin pre-check—the safe `web_fetch`/URL-backed `look_at` transport still enforces its independent policy below. (b) _operator-reviewable state_: bypass writes to a file the operator force-commits and reviews before the privileged effect takes hold — `gitExfil` (push to a clean operator-configured remote; the retarget-and-push path stays blocked by `gitRemoteTainted` at high), `rolePromotion` (`roles` is restart-required so the operator has wall-clock time), `cronPromotion` (deferred execution gives wall-clock time to revert). **`owner` and `trusted` bypass these plugin guards; `member`, `guest` do not.**
103
103
 
104
- **Important:** `cronPromotion`, `rolePromotion`, and `pluginAddition` no longer honor `acknowledgeGuards`. For these three guards the bypass is **permission-only** — an actor bypasses them automatically by holding `security.bypass.medium` (owner and trusted have it by default) or the per-guard `security.bypass.<guard>` string. No per-call ack is accepted or possible. Additionally, `cronPromotion` is **caller-role-aware**: it only blocks changes that schedule deferred work above the caller's own resolved role (see `typeclaw-cron` for the full model). The `gitExfil` guard and all other guards still accept `acknowledgeGuards` per-call acks at the plugin layer, but an `ssrf` acknowledgement never bypasses the safe HTTP transport.
104
+ **Important:** security guards do not honor `acknowledgeGuards`. Their bypass is **permission-only**: an actor bypasses one by holding its tier permission or the per-guard `security.bypass.<guard>` string. Additionally, `cronPromotion` is caller-role-aware: it only blocks changes that schedule deferred work above the caller's resolved role.
105
105
 
106
106
  - **low — noisy, immediately recoverable.** No inhabitants today. Forward-compat for future guards. **`owner`, `trusted`, `member` all carry `bypass.low`; `guest` does not.**
107
107
 
@@ -111,7 +111,7 @@ At `tool.before` time, an actor bypasses a guard if they hold **either** the tie
111
111
 
112
112
  ### SSRF has a non-bypassable transport layer
113
113
 
114
- `security.bypass.ssrf`, `security.bypass.medium`, `owner`, `trusted`, and `acknowledgeGuards.ssrf` can skip the heuristic `tool.before` warning only. They cannot make the safe transports behind `web_fetch` and URL-backed `look_at` connect to a destination that transport policy rejects.
114
+ `security.bypass.ssrf`, `security.bypass.medium`, `owner`, and `trusted` can skip the heuristic `tool.before` warning only. They cannot make the safe transports behind `web_fetch` and URL-backed `look_at` connect to a destination that transport policy rejects.
115
115
 
116
116
  Intentional internal access is operator-configured in raw-masked `.env`, not in `roles` or tool arguments:
117
117
 
@@ -148,31 +148,20 @@ See `typeclaw-plugins` for the authoring side of this — declaring and gating o
148
148
 
149
149
  ## When a tool is blocked
150
150
 
151
- The security plugin's `tool.before` hook produces block messages. For most guards the message is:
151
+ The security plugin's `tool.before` hook produces block messages:
152
152
 
153
153
  ```
154
- Guard `<guardName>` blocked <what>. If this is genuinely intentional and the user
155
- explicitly asked for it, retry with `acknowledgeGuards.<guardName>: true` in the
156
- <tool> arguments. Or run as a role carrying `<per-guard-permission>` (...role hint...)
157
- or the tier permission `security.bypass.<low|medium|high>`; see the
158
- `typeclaw-permissions` skill.
154
+ Guard `<guardName>` blocked <what>. Run as a role carrying `<per-guard-permission>`
155
+ or the tier permission `security.bypass.<low|medium|high>`.
159
156
  ```
160
157
 
161
- For `cronPromotion`, `rolePromotion`, and `pluginAddition` the message omits the ack path entirely, because those guards no longer accept acks:
158
+ Security-guard bypasses are permission-based. If the block concerns a canonical credential path, reusable authentication, or the safe HTTP transport's SSRF floor, there is no role escape hatch; direct the operator to the appropriate host-side workflow instead.
162
159
 
163
- ```
164
- Guard `<guardName>` blocked <what>. To proceed, make this change from a session that
165
- already resolves to a role carrying `<per-guard-permission>` or
166
- `security.bypass.medium` — the TUI is always `owner`, or claim the role out-of-band
167
- via `typeclaw role claim` from the host CLI.
168
- ```
169
-
170
- Four escape hatches for **bypassable plugin guards**, ordered from least to most invasive. If the block concerns a canonical credential path, reusable authentication, or the safe HTTP transport's SSRF floor, there is no role/ack escape hatch; direct the operator to the appropriate host-side workflow instead.
160
+ 1. **Run as a role with the per-guard bypass permission.** Add the exact `security.bypass.<guardName>` string when the operator wants only that capability.
161
+ 2. **Run as a role with the tier bypass permission.** Granting `security.bypass.low|medium|high` opens every security guard in that tier.
162
+ 3. **Use a session that already resolves to a role with the bypass.** The TUI is always `owner`; role claims happen out-of-band through the host CLI.
171
163
 
172
- 1. **`acknowledgeGuards.<guardName>: true`** in the tool args. This is a per-call, in-session bypass for guards that support acknowledgements. Never use it without explicit user confirmation. It cannot authorize canonical secret access, credential handling, or a safe-HTTP destination rejected by transport policy. **Exception: this escape hatch also does NOT apply to `cronPromotion`, `rolePromotion`, or `pluginAddition`.** Those three guards ignore the ack flag entirely — they are bypassed only by holding the appropriate permission (see options 2-4 below) or via `typeclaw role claim` from the host CLI.
173
- 2. **Run as a role with the per-guard bypass permission**. If the user wants this pattern to keep working without an ack every time, they edit `roles.<role>.permissions[]` to include the specific `security.bypass.<guardName>` string the block message named. This is the most granular grant — it only opens up that one guard. Use this when the user wants exactly one capability and nothing else.
174
- 3. **Run as a role with the tier bypass permission**. The block message also names the tier permission (`security.bypass.low` / `.medium` / `.high`). Granting the tier opens every bypassable plugin guard of that tier at once — never canonical secrets.
175
- 4. **Run from a session that already resolves to a role with the bypass**. The TUI is always `owner`, so a bypassable plugin guard that blocks a `member` channel author may permit the TUI. Canonical credential denial and safe-HTTP transport validation remain identical in both places. For `cronPromotion`, `rolePromotion`, and `pluginAddition` specifically, use a session carrying `security.bypass.medium` or claim the role out-of-band via `typeclaw role claim` from the host CLI.
164
+ Separate advisory plugins may expose per-call acknowledgements. Those use plugin-nested JSON, for example `acknowledgeGuards: { "guard": { "nonWorkspaceWrite": true } }` or `{ "bun-hygiene": { "nonBunPackageManager": true } }`. The block reason names the exact tuple. These acknowledgements never apply to security guards.
176
165
 
177
166
  When you see a block, tell the user **which permission would skip it** (the block message now names both the per-guard and the tier options) and **which built-in roles have those permissions**. Do not just relay the guard reason — that loses the access-control framing entirely.
178
167
 
@@ -228,7 +217,7 @@ If you see a cron job mysteriously failing every fire with `denied by permission
228
217
  - **Do not promise that `typeclaw reload` applied a `roles` edit.** `roles` is restart-required. The reload tool will return success on the config file change, but the live `PermissionService` was built at boot and is not swapped on reload.
229
218
  - **Do not silently change a built-in role's permission list.** Setting `"permissions": []` on `member` is a wholesale replace, not a merge — you just took `channel.respond` away from every speaker who resolves to `member`. If the user said "give member just `channel.respond` and nothing else", that's fine (it's the same as the default), but say so explicitly: "this matches the default for `member`, no behavior change". If the user said "remove cron from `trusted`", make the change but warn that `trusted` no longer carries `cron.schedule` either.
230
219
  - **Do not write match rules using display names** (`#general`, `@user`, channel/user names). Match rules are platform IDs. Display names change; IDs don't. Always look up the ID before writing the rule.
231
- - **Do not edit `roles` to "fix" a security block** without explaining the alternative. For most guards, the right first move is `acknowledgeGuards.<X>: true` for the specific call. **Exceptions:** `cronPromotion`, `rolePromotion`, and `pluginAddition` do not accept acks; an `ssrf` ack only skips the heuristic plugin pre-check and never changes safe-HTTP transport policy. Intentional internal `web_fetch`/URL-backed `look_at` access is an operator boot-policy change, not a role edit. Editing `roles` to grant a permanent bypass is a heavier change with security implications — get explicit consent.
220
+ - **Do not edit `roles` to "fix" a security block** without explaining the implications. Security guards are permission-only; advisory plugin acknowledgements do not apply. Intentional internal `web_fetch`/URL-backed `look_at` access is an operator boot-policy change, not a role edit.
232
221
  - **Do not interpret a missing `## Session origin` role line as "I have no role".** TUI sessions don't render the line because TUI is always `owner`. If you see no role line and you're not in TUI, something has gone wrong with the system prompt build — flag it, don't fabricate.
233
222
 
234
223
  ## What this skill does not cover
@@ -1,4 +1,4 @@
1
- import { styleText } from 'node:util'
1
+ import { styled, type StyleFormat } from '@/shared'
2
2
 
3
3
  import type { ModelUsage, OriginUsage, UsageTotals } from './aggregate'
4
4
  import { formatCacheHitRate, formatCost, formatTokens, isoDay } from './format'
@@ -448,9 +448,9 @@ function dim(text: string, ctx: RenderCtx): string {
448
448
  return color('dim', text, ctx)
449
449
  }
450
450
 
451
- function color(modifier: Parameters<typeof styleText>[0], text: string, ctx: RenderCtx): string {
451
+ function color(modifier: StyleFormat, text: string, ctx: RenderCtx): string {
452
452
  if (!ctx.useColor) return text
453
- return styleText(modifier, text)
453
+ return styled(modifier, text)
454
454
  }
455
455
 
456
456
  // ANSI escape sequences would inflate column widths and break alignment under