typeclaw 0.48.6 → 0.48.8

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 (105) 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/live-subagents.ts +14 -0
  8. package/src/agent/multimodal/read-redirect.ts +8 -9
  9. package/src/agent/plugin-tools.ts +283 -148
  10. package/src/agent/provider-error.ts +6 -1
  11. package/src/agent/reload-tool.ts +12 -5
  12. package/src/agent/retry-same-ref.ts +95 -36
  13. package/src/agent/session-origin.ts +13 -1
  14. package/src/agent/system-prompt.ts +14 -3
  15. package/src/agent/todo/continuation-policy.ts +3 -4
  16. package/src/agent/tool-file-safety.ts +36 -13
  17. package/src/agent/tools/channel-reply.ts +39 -2
  18. package/src/agent/tools/channel-send.ts +45 -2
  19. package/src/agent/tools/post-github-review.ts +31 -13
  20. package/src/agent/tools/spawn-subagent.ts +15 -0
  21. package/src/agent/tools/webfetch/inline-style-visibility.ts +2 -2
  22. package/src/agent/tools/webfetch/strategies/readability.ts +109 -10
  23. package/src/agent/turn-runner.ts +23 -19
  24. package/src/bundled-plugins/backup/git-auth.ts +7 -4
  25. package/src/bundled-plugins/backup/subagents.ts +1 -1
  26. package/src/bundled-plugins/bun-hygiene/README.md +23 -20
  27. package/src/bundled-plugins/bun-hygiene/index.ts +1 -7
  28. package/src/bundled-plugins/bun-hygiene/policy.ts +111 -35
  29. package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +44 -2
  30. package/src/bundled-plugins/github-cli-auth/gh-store.ts +733 -0
  31. package/src/bundled-plugins/github-cli-auth/git-askpass.ts +25 -0
  32. package/src/bundled-plugins/github-cli-auth/git-command.ts +231 -30
  33. package/src/bundled-plugins/github-cli-auth/git-credential-env.ts +151 -0
  34. package/src/bundled-plugins/github-cli-auth/index.ts +249 -42
  35. package/src/bundled-plugins/github-cli-auth/review-recorder.ts +5 -0
  36. package/src/bundled-plugins/guard/index.ts +2 -25
  37. package/src/bundled-plugins/guard/keys.ts +8 -0
  38. package/src/bundled-plugins/guard/policies/non-workspace-write.ts +7 -8
  39. package/src/bundled-plugins/guard/policy.ts +1 -7
  40. package/src/bundled-plugins/security/policies/git-exfil.ts +22 -30
  41. package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +2 -4
  42. package/src/bundled-plugins/security/policies/private-surface-read.ts +8 -6
  43. package/src/bundled-plugins/security/policies/secret-exfil-bash.ts +2 -5
  44. package/src/bundled-plugins/security/policies/secret-exfil-read.ts +2 -4
  45. package/src/bundled-plugins/security/policies/session-search-secrets.ts +2 -4
  46. package/src/bundled-plugins/security/policies/system-prompt-leak.ts +2 -4
  47. package/src/bundled-plugins/security/policy.ts +0 -8
  48. package/src/channels/adapters/discord-bot-slash-commands.ts +22 -0
  49. package/src/channels/adapters/discord-bot.ts +2 -1
  50. package/src/channels/adapters/discord-classify.ts +16 -4
  51. package/src/channels/adapters/discord.ts +20 -8
  52. package/src/channels/adapters/github/dedup.ts +37 -8
  53. package/src/channels/adapters/github/inbound.ts +241 -46
  54. package/src/channels/adapters/github/review-state.ts +13 -9
  55. package/src/channels/adapters/github/review-thread-resolver.ts +52 -20
  56. package/src/channels/adapters/slack-classify.ts +40 -5
  57. package/src/channels/adapters/slack.ts +3 -9
  58. package/src/channels/adapters/webex-bot-classify.ts +4 -33
  59. package/src/channels/adapters/webex-bot.ts +2 -4
  60. package/src/channels/adapters/webex-classify.ts +4 -33
  61. package/src/channels/adapters/webex-format.ts +36 -0
  62. package/src/channels/adapters/webex.ts +2 -4
  63. package/src/channels/continuation-willingness.ts +64 -39
  64. package/src/channels/github-rereview-guard.ts +20 -0
  65. package/src/channels/github-review-turn-ledger.ts +11 -1
  66. package/src/channels/github-review-verdict-coordinator.ts +475 -41
  67. package/src/channels/github-verdict-activity.ts +14 -5
  68. package/src/channels/persistence.ts +89 -5
  69. package/src/channels/router.ts +1223 -225
  70. package/src/channels/types.ts +21 -5
  71. package/src/cli/compose-stats.ts +6 -7
  72. package/src/cli/compose-status.ts +6 -7
  73. package/src/cli/compose-usage.ts +6 -7
  74. package/src/cli/stats.ts +6 -7
  75. package/src/cli/status.ts +7 -8
  76. package/src/cli/ui.ts +4 -4
  77. package/src/container/start.ts +41 -1
  78. package/src/cron/consumer.ts +30 -9
  79. package/src/cron/scheduler.ts +24 -9
  80. package/src/doctor/channel-checks.ts +64 -0
  81. package/src/doctor/report.ts +8 -8
  82. package/src/dreams/render.ts +2 -2
  83. package/src/init/dockerfile.ts +8 -1
  84. package/src/inspect/render.ts +2 -2
  85. package/src/path-safety/real-intended-path.ts +14 -1
  86. package/src/permissions/permissions.ts +10 -2
  87. package/src/permissions/resolve.ts +8 -2
  88. package/src/plugin/core-tool-names.ts +15 -0
  89. package/src/plugin/hooks.ts +37 -3
  90. package/src/plugin/registry.ts +7 -3
  91. package/src/run/index.ts +35 -15
  92. package/src/sandbox/build.ts +19 -3
  93. package/src/sandbox/policy.ts +1 -0
  94. package/src/secrets/export-github-cli-store.ts +158 -0
  95. package/src/secrets/index.ts +19 -1
  96. package/src/secrets/provision-github-cli-store.ts +322 -0
  97. package/src/secrets/schema.ts +13 -7
  98. package/src/secrets/storage.ts +30 -0
  99. package/src/shared/index.ts +2 -0
  100. package/src/shared/style-text.ts +13 -0
  101. package/src/skills/typeclaw-channel-github/SKILL.md +24 -12
  102. package/src/skills/typeclaw-config/SKILL.md +3 -1
  103. package/src/skills/typeclaw-github-contributing/SKILL.md +6 -2
  104. package/src/skills/typeclaw-permissions/SKILL.md +11 -22
  105. package/src/usage/report.ts +3 -3
@@ -1,4 +1,4 @@
1
- import type { ReviewVerdict } from './github-review-turn-ledger'
1
+ import type { ReviewRoundOutcome } from './github-review-turn-ledger'
2
2
 
3
3
  // A formal review verdict (APPROVE / REQUEST_CHANGES) that LANDED on a PR, fanned
4
4
  // out over the broadcast bus so the OTHER live sessions reviewing the same PR
@@ -17,7 +17,7 @@ import type { ReviewVerdict } from './github-review-turn-ledger'
17
17
  export type PrVerdictActivityPayload = {
18
18
  workspace: string
19
19
  prNumber: number
20
- verdict: ReviewVerdict
20
+ verdict: ReviewRoundOutcome
21
21
  sessionId: string
22
22
  }
23
23
 
@@ -39,8 +39,8 @@ export function parsePrVerdictActivityPayload(payload: unknown): PrVerdictActivi
39
39
  return { workspace: p.workspace, prNumber: p.prNumber, verdict, sessionId: p.sessionId }
40
40
  }
41
41
 
42
- function parseVerdict(value: unknown): ReviewVerdict | null {
43
- return value === 'APPROVE' || value === 'REQUEST_CHANGES' ? value : null
42
+ function parseVerdict(value: unknown): ReviewRoundOutcome | null {
43
+ return value === 'APPROVE' || value === 'REQUEST_CHANGES' || value === 'DISMISSED' ? value : null
44
44
  }
45
45
 
46
46
  // Advisory and deliberately soft (per the design review): it must not suppress a
@@ -48,7 +48,16 @@ function parseVerdict(value: unknown): ReviewVerdict | null {
48
48
  // only a REDUNDANT same-intent verdict and explicitly preserves inline-thread
49
49
  // replies. The hard guards remain the correctness boundary; this only trims wasted
50
50
  // sibling work before they fire.
51
- export function renderPrVerdictStandDownReminder(args: { prNumber: number; verdict: ReviewVerdict }): string {
51
+ export function renderPrVerdictStandDownReminder(args: { prNumber: number; verdict: ReviewRoundOutcome }): string {
52
+ if (args.verdict === 'DISMISSED') {
53
+ return (
54
+ `<system-reminder>\n` +
55
+ `The designated carrier verified that its blocking review for PR #${args.prNumber} is DISMISSED. ` +
56
+ `Do not submit another formal verdict for this follow-up round. Close out this session's addressed ` +
57
+ `review thread as normal; leave it open if its concern remains unresolved.\n` +
58
+ `</system-reminder>`
59
+ )
60
+ }
52
61
  return (
53
62
  `<system-reminder>\n` +
54
63
  `Another session in this agent has already posted a formal ${args.verdict} review for PR #${args.prNumber}. ` +
@@ -6,9 +6,9 @@ import type { ChannelParticipant } from '@/agent/session-origin'
6
6
  import { toRef } from './adapters/webex-id-ref'
7
7
  import { describeError } from './describe-error'
8
8
  import type { AdapterId } from './schema'
9
- import type { ChannelKey } from './types'
9
+ import type { ChannelKey, GithubReviewFollowupRound } from './types'
10
10
 
11
- const FILE_VERSION = 5
11
+ const FILE_VERSION = 7
12
12
 
13
13
  // `sessionFile` is the basename (not the full path) of the JSONL transcript
14
14
  // for this (adapter, workspace, chat, thread) tuple. pi-coding-agent writes
@@ -29,6 +29,13 @@ export type ChannelSessionRecord = {
29
29
  sessionFile?: string
30
30
  lastInboundAt?: number
31
31
  participants: ChannelParticipant[]
32
+ githubReviewRound?: GithubReviewFollowupRound & {
33
+ status: 'pending' | 'completed'
34
+ createdAt: number
35
+ attemptedCarriers: (string | null)[]
36
+ dismissalAttempted?: true
37
+ requestChangesAttempted?: true
38
+ }
32
39
  }
33
40
 
34
41
  type FileV4 = {
@@ -41,6 +48,16 @@ type FileV5 = {
41
48
  sessions: ChannelSessionRecord[]
42
49
  }
43
50
 
51
+ type FileV6 = {
52
+ version: 6
53
+ sessions: ChannelSessionRecord[]
54
+ }
55
+
56
+ type FileV7 = {
57
+ version: 7
58
+ sessions: ChannelSessionRecord[]
59
+ }
60
+
44
61
  export type ChannelSessionsLogger = {
45
62
  info: (msg: string) => void
46
63
  warn: (msg: string) => void
@@ -81,9 +98,19 @@ export async function loadChannelSessions(
81
98
  }
82
99
  const version = (parsed as { version?: unknown }).version
83
100
  if (version === FILE_VERSION) {
101
+ const file = parsed as FileV7
102
+ if (!Array.isArray(file.sessions)) return []
103
+ return dedupe(file.sessions.filter(isValidRecord).map(normalizeGithubReviewRound))
104
+ }
105
+ if (version === 5) {
84
106
  const file = parsed as FileV5
85
107
  if (!Array.isArray(file.sessions)) return []
86
- return dedupe(file.sessions.filter(isValidRecord))
108
+ return dedupe(file.sessions.filter(isValidRecord).map(normalizeGithubReviewRound))
109
+ }
110
+ if (version === 6) {
111
+ const file = parsed as FileV6
112
+ if (!Array.isArray(file.sessions)) return []
113
+ return dedupe(file.sessions.filter(isValidV6Record).map(dropLegacyGithubReviewRound))
87
114
  }
88
115
  if (version === 4) {
89
116
  const file = parsed as FileV4
@@ -100,7 +127,7 @@ export async function saveChannelSessions(
100
127
  logger: ChannelSessionsLogger = consoleLogger,
101
128
  ): Promise<void> {
102
129
  const path = channelsSessionsPath(agentDir)
103
- const payload: FileV5 = { version: FILE_VERSION, sessions: dedupe(sessions) }
130
+ const payload: FileV7 = { version: FILE_VERSION, sessions: dedupe(sessions) }
104
131
  try {
105
132
  await mkdir(dirname(path), { recursive: true })
106
133
  const tmp = `${path}.tmp`
@@ -165,6 +192,25 @@ function migrateV4Record(record: ChannelSessionRecord): ChannelSessionRecord {
165
192
  }
166
193
  }
167
194
 
195
+ function dropLegacyGithubReviewRound(record: ChannelSessionRecord): ChannelSessionRecord {
196
+ const { githubReviewRound: _expiredLegacyRound, ...rest } = record
197
+ void _expiredLegacyRound
198
+ return rest
199
+ }
200
+
201
+ function normalizeGithubReviewRound(record: ChannelSessionRecord): ChannelSessionRecord {
202
+ const round = record.githubReviewRound
203
+ if (round === undefined || (round.kind !== undefined && round.roundId !== undefined)) return record
204
+ return {
205
+ ...record,
206
+ githubReviewRound: {
207
+ ...round,
208
+ kind: 'push',
209
+ roundId: `legacy:${round.workspace}#${round.prNumber}#${round.headSha}`,
210
+ },
211
+ }
212
+ }
213
+
168
214
  function recordKey(record: ChannelSessionRecord): string {
169
215
  return `${record.adapter}:${record.workspace}:${record.chat}:${record.thread ?? ''}`
170
216
  }
@@ -199,6 +245,44 @@ function isValidRecord(v: unknown): v is ChannelSessionRecord {
199
245
  (r.sessionId === undefined || typeof r.sessionId === 'string') &&
200
246
  (r.sessionFile === undefined || typeof r.sessionFile === 'string') &&
201
247
  (r.lastInboundAt === undefined || typeof r.lastInboundAt === 'number') &&
202
- Array.isArray(r.participants)
248
+ Array.isArray(r.participants) &&
249
+ (r.githubReviewRound === undefined || isValidGithubReviewRound(r.githubReviewRound, r))
250
+ )
251
+ }
252
+
253
+ function isValidV6Record(v: unknown): v is ChannelSessionRecord {
254
+ if (!isObject(v)) return false
255
+ const { githubReviewRound: _legacyRound, ...record } = v
256
+ void _legacyRound
257
+ return isValidRecord(record)
258
+ }
259
+
260
+ function isValidGithubReviewRound(value: unknown, record: Record<string, unknown>): boolean {
261
+ if (!isObject(value)) return false
262
+ const hasLegacyIdentity = value.kind === undefined && value.roundId === undefined
263
+ const hasCurrentIdentity =
264
+ (value.kind === 'push' || value.kind === 'reply') && typeof value.roundId === 'string' && value.roundId.length > 0
265
+ return (
266
+ (value.status === 'pending' || value.status === 'completed') &&
267
+ record.adapter === 'github' &&
268
+ typeof value.workspace === 'string' &&
269
+ value.workspace === record.workspace &&
270
+ typeof value.prNumber === 'number' &&
271
+ Number.isInteger(value.prNumber) &&
272
+ value.prNumber > 0 &&
273
+ record.chat === `pr:${value.prNumber}` &&
274
+ typeof value.headSha === 'string' &&
275
+ value.headSha.length > 0 &&
276
+ typeof value.createdAt === 'number' &&
277
+ Number.isFinite(value.createdAt) &&
278
+ value.createdAt >= 0 &&
279
+ (value.carrierThread === null || typeof value.carrierThread === 'string') &&
280
+ Array.isArray(value.attemptedCarriers) &&
281
+ value.attemptedCarriers.length > 0 &&
282
+ value.attemptedCarriers.every((thread) => thread === null || typeof thread === 'string') &&
283
+ value.attemptedCarriers.some((thread) => thread === value.carrierThread) &&
284
+ (hasLegacyIdentity || hasCurrentIdentity) &&
285
+ (value.dismissalAttempted === undefined || value.dismissalAttempted === true) &&
286
+ (value.requestChangesAttempted === undefined || value.requestChangesAttempted === true)
203
287
  )
204
288
  }