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.
- package/auth.schema.json +15 -1
- package/package.json +1 -1
- package/secrets.schema.json +15 -1
- package/src/agent/guard-types.ts +25 -0
- package/src/agent/guards.ts +102 -0
- package/src/agent/index.ts +33 -3
- package/src/agent/multimodal/read-redirect.ts +8 -9
- package/src/agent/plugin-tools.ts +283 -148
- package/src/agent/provider-error.ts +6 -1
- package/src/agent/reload-tool.ts +12 -5
- package/src/agent/retry-same-ref.ts +95 -36
- package/src/agent/session-origin.ts +13 -1
- package/src/agent/system-prompt.ts +14 -3
- package/src/agent/todo/continuation-policy.ts +3 -4
- package/src/agent/tool-file-safety.ts +36 -13
- package/src/agent/tools/channel-reply.ts +39 -2
- package/src/agent/tools/channel-send.ts +45 -2
- package/src/agent/tools/post-github-review.ts +31 -13
- package/src/agent/tools/spawn-subagent.ts +15 -0
- package/src/agent/tools/webfetch/inline-style-visibility.ts +2 -2
- package/src/agent/tools/webfetch/strategies/readability.ts +109 -10
- package/src/agent/turn-runner.ts +23 -19
- package/src/bundled-plugins/backup/git-auth.ts +7 -4
- package/src/bundled-plugins/backup/subagents.ts +1 -1
- package/src/bundled-plugins/bun-hygiene/README.md +23 -20
- package/src/bundled-plugins/bun-hygiene/index.ts +1 -7
- package/src/bundled-plugins/bun-hygiene/policy.ts +111 -35
- package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +44 -2
- package/src/bundled-plugins/github-cli-auth/gh-store.ts +733 -0
- package/src/bundled-plugins/github-cli-auth/git-askpass.ts +25 -0
- package/src/bundled-plugins/github-cli-auth/git-command.ts +209 -31
- package/src/bundled-plugins/github-cli-auth/git-credential-env.ts +151 -0
- package/src/bundled-plugins/github-cli-auth/index.ts +236 -38
- package/src/bundled-plugins/github-cli-auth/review-recorder.ts +5 -0
- package/src/bundled-plugins/guard/index.ts +2 -25
- package/src/bundled-plugins/guard/keys.ts +8 -0
- package/src/bundled-plugins/guard/policies/non-workspace-write.ts +7 -8
- package/src/bundled-plugins/guard/policy.ts +1 -7
- package/src/bundled-plugins/security/policies/git-exfil.ts +22 -30
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +2 -4
- package/src/bundled-plugins/security/policies/private-surface-read.ts +8 -6
- package/src/bundled-plugins/security/policies/secret-exfil-bash.ts +2 -5
- package/src/bundled-plugins/security/policies/secret-exfil-read.ts +2 -4
- package/src/bundled-plugins/security/policies/session-search-secrets.ts +2 -4
- package/src/bundled-plugins/security/policies/system-prompt-leak.ts +2 -4
- package/src/bundled-plugins/security/policy.ts +0 -8
- package/src/channels/adapters/discord-bot-slash-commands.ts +22 -0
- package/src/channels/adapters/discord-bot.ts +2 -1
- package/src/channels/adapters/discord-classify.ts +16 -4
- package/src/channels/adapters/discord.ts +20 -8
- package/src/channels/adapters/github/dedup.ts +37 -8
- package/src/channels/adapters/github/inbound.ts +241 -46
- package/src/channels/adapters/github/review-state.ts +13 -9
- package/src/channels/adapters/github/review-thread-resolver.ts +52 -20
- package/src/channels/adapters/slack-bot.ts +13 -3
- package/src/channels/adapters/slack-classify.ts +40 -5
- package/src/channels/adapters/slack.ts +3 -9
- package/src/channels/adapters/teams.ts +8 -6
- package/src/channels/adapters/webex-bot-classify.ts +4 -33
- package/src/channels/adapters/webex-bot.ts +2 -4
- package/src/channels/adapters/webex-classify.ts +4 -33
- package/src/channels/adapters/webex-format.ts +36 -0
- package/src/channels/adapters/webex.ts +2 -4
- package/src/channels/continuation-willingness.ts +64 -39
- package/src/channels/github-rereview-guard.ts +20 -0
- package/src/channels/github-review-turn-ledger.ts +11 -1
- package/src/channels/github-review-verdict-coordinator.ts +475 -41
- package/src/channels/github-verdict-activity.ts +14 -5
- package/src/channels/manager.ts +17 -1
- package/src/channels/persistence.ts +89 -5
- package/src/channels/router.ts +1187 -254
- package/src/channels/types.ts +21 -5
- package/src/cli/compose-stats.ts +6 -7
- package/src/cli/compose-status.ts +6 -7
- package/src/cli/compose-usage.ts +6 -7
- package/src/cli/stats.ts +6 -7
- package/src/cli/status.ts +7 -8
- package/src/cli/ui.ts +4 -4
- package/src/container/start.ts +41 -1
- package/src/container/stop.ts +2 -1
- package/src/cron/consumer.ts +30 -9
- package/src/cron/scheduler.ts +24 -9
- package/src/doctor/channel-checks.ts +64 -0
- package/src/doctor/report.ts +8 -8
- package/src/dreams/render.ts +2 -2
- package/src/init/dockerfile.ts +8 -1
- package/src/inspect/render.ts +2 -2
- package/src/path-safety/real-intended-path.ts +14 -1
- package/src/permissions/permissions.ts +10 -2
- package/src/permissions/resolve.ts +8 -2
- package/src/plugin/core-tool-names.ts +15 -0
- package/src/plugin/hooks.ts +37 -3
- package/src/plugin/registry.ts +7 -3
- package/src/run/index.ts +33 -7
- package/src/sandbox/build.ts +39 -10
- package/src/sandbox/policy.ts +6 -2
- package/src/secrets/export-github-cli-store.ts +158 -0
- package/src/secrets/index.ts +19 -1
- package/src/secrets/provision-github-cli-store.ts +322 -0
- package/src/secrets/schema.ts +13 -7
- package/src/secrets/storage.ts +30 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/style-text.ts +13 -0
- package/src/skills/typeclaw-channel-github/SKILL.md +24 -12
- package/src/skills/typeclaw-config/SKILL.md +3 -1
- package/src/skills/typeclaw-github-contributing/SKILL.md +6 -2
- package/src/skills/typeclaw-permissions/SKILL.md +11 -22
- package/src/usage/report.ts +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
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:
|
|
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):
|
|
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:
|
|
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}. ` +
|
package/src/channels/manager.ts
CHANGED
|
@@ -192,6 +192,8 @@ type AdapterEntry = {
|
|
|
192
192
|
adapter: AnyAdapter
|
|
193
193
|
credentialSignature: string
|
|
194
194
|
disconnectedSinceMs: number | null
|
|
195
|
+
nextRecoveryRestartAtMs: number | null
|
|
196
|
+
recoveryRestartAttempts: number
|
|
195
197
|
recoveryRestartQueued: boolean
|
|
196
198
|
}
|
|
197
199
|
|
|
@@ -512,6 +514,8 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
|
|
|
512
514
|
adapter,
|
|
513
515
|
credentialSignature: signature,
|
|
514
516
|
disconnectedSinceMs: adapter.isConnected() ? null : recoveryNow(),
|
|
517
|
+
nextRecoveryRestartAtMs: null,
|
|
518
|
+
recoveryRestartAttempts: 0,
|
|
515
519
|
recoveryRestartQueued: false,
|
|
516
520
|
})
|
|
517
521
|
return { status: 'started' }
|
|
@@ -722,6 +726,8 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
|
|
|
722
726
|
for (const [name, entry] of live) {
|
|
723
727
|
if (entry.adapter.isConnected()) {
|
|
724
728
|
entry.disconnectedSinceMs = null
|
|
729
|
+
entry.nextRecoveryRestartAtMs = null
|
|
730
|
+
entry.recoveryRestartAttempts = 0
|
|
725
731
|
entry.recoveryRestartQueued = false
|
|
726
732
|
continue
|
|
727
733
|
}
|
|
@@ -731,7 +737,11 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
|
|
|
731
737
|
continue
|
|
732
738
|
}
|
|
733
739
|
const disconnectedForMs = now - entry.disconnectedSinceMs
|
|
734
|
-
|
|
740
|
+
const nextRestartAtMs = Math.max(
|
|
741
|
+
entry.disconnectedSinceMs + recoveryDisconnectedGraceMs,
|
|
742
|
+
entry.nextRecoveryRestartAtMs ?? Number.NEGATIVE_INFINITY,
|
|
743
|
+
)
|
|
744
|
+
if (now < nextRestartAtMs || entry.recoveryRestartQueued) continue
|
|
735
745
|
entry.recoveryRestartQueued = true
|
|
736
746
|
logger.warn(
|
|
737
747
|
`[channels] adapter "${name}" disconnected for ${Math.round(disconnectedForMs)}ms; restarting adapter`,
|
|
@@ -756,6 +766,12 @@ export function createChannelManager(options: ChannelManagerOptions): ChannelMan
|
|
|
756
766
|
return running && queuedEpoch === lifecycleEpoch && cfg !== undefined && cfg.enabled !== false
|
|
757
767
|
})
|
|
758
768
|
applyStartResult(name, latestCfg, result)
|
|
769
|
+
const replacement = live.get(name)
|
|
770
|
+
if (replacement !== undefined && !replacement.adapter.isConnected()) {
|
|
771
|
+
const attempts = entry.recoveryRestartAttempts + 1
|
|
772
|
+
replacement.recoveryRestartAttempts = attempts
|
|
773
|
+
replacement.nextRecoveryRestartAtMs = recoveryNow() + retryDelayMs(attempts)
|
|
774
|
+
}
|
|
759
775
|
} catch (err) {
|
|
760
776
|
const cfg = options.channelsConfigRef()[name]
|
|
761
777
|
if (running && queuedEpoch === lifecycleEpoch && cfg !== undefined && cfg.enabled !== false) {
|
|
@@ -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 =
|
|
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:
|
|
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
|
}
|