typeclaw 0.48.12 → 0.49.0
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 +6 -3
- package/scripts/dump-system-prompt.ts +52 -110
- package/src/agent/attention-escalation.ts +8 -5
- package/src/agent/auth-reloadable.ts +2 -3
- package/src/agent/auth.ts +59 -79
- package/src/agent/compaction.ts +2 -2
- package/src/agent/index.ts +173 -85
- package/src/agent/live-sessions.ts +2 -2
- package/src/agent/live-subagents.ts +1 -0
- package/src/agent/llm-replay-sanitizer.ts +1 -1
- package/src/agent/model-overrides.ts +1 -1
- package/src/agent/multimodal/look-at.ts +3 -3
- package/src/agent/multimodal/read-redirect.ts +1 -1
- package/src/agent/plugin-tools.ts +76 -39
- package/src/agent/prompt-cache-key.ts +42 -0
- package/src/agent/provider-error.ts +179 -10
- package/src/agent/reload-tool.ts +1 -1
- package/src/agent/restart-handoff/index.ts +7 -14
- package/src/agent/reviewer-activity.ts +68 -0
- package/src/agent/session-origin.ts +33 -0
- package/src/agent/subagents.ts +14 -2
- package/src/agent/system-prompt.ts +68 -202
- package/src/agent/todo/continuation-policy.ts +12 -4
- package/src/agent/tool-error-remediation.ts +1 -1
- package/src/agent/tool-file-safety.ts +113 -14
- package/src/agent/tool-not-found-nudge.ts +1 -1
- package/src/agent/tool-result-budget.ts +2 -2
- package/src/agent/tools/channel-disengage.ts +2 -2
- package/src/agent/tools/channel-edit.ts +2 -2
- package/src/agent/tools/channel-fetch-attachment.ts +2 -2
- package/src/agent/tools/channel-history-render.ts +2 -1
- package/src/agent/tools/channel-history.ts +2 -2
- package/src/agent/tools/channel-react.ts +2 -2
- package/src/agent/tools/channel-read.ts +2 -2
- package/src/agent/tools/channel-reply.ts +25 -7
- package/src/agent/tools/channel-send.ts +51 -9
- package/src/agent/tools/curl-impersonate.ts +11 -2
- package/src/agent/tools/grant-role.ts +2 -2
- package/src/agent/tools/post-github-review.ts +79 -17
- package/src/agent/tools/restart.ts +2 -2
- package/src/agent/tools/skip-response.ts +4 -4
- package/src/agent/tools/spawn-subagent.ts +165 -14
- package/src/agent/tools/stream-snapshot.ts +2 -2
- package/src/agent/tools/subagent-cancel.ts +2 -2
- package/src/agent/tools/subagent-output.ts +10 -2
- package/src/agent/tools/todo/index.ts +2 -2
- package/src/agent/tools/webfetch/tool.ts +2 -2
- package/src/agent/tools/websearch.ts +2 -2
- package/src/bundled-plugins/backup/README.md +10 -9
- package/src/bundled-plugins/backup/runner.ts +140 -58
- package/src/bundled-plugins/backup/subagents.ts +58 -26
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +34 -2
- package/src/bundled-plugins/github-cli-auth/granted-push.ts +135 -0
- package/src/bundled-plugins/github-cli-auth/index.ts +83 -11
- package/src/bundled-plugins/github-cli-auth/review-account.ts +23 -0
- package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -2
- package/src/bundled-plugins/github-cli-auth/review-recorder.ts +45 -7
- package/src/bundled-plugins/operator/operator.ts +15 -4
- package/src/bundled-plugins/reviewer/skills/code-review.ts +1 -1
- package/src/bundled-plugins/security/index.ts +50 -2
- package/src/bundled-plugins/security/policies/git-exfil.ts +24 -12
- package/src/channels/adapters/discord-bot-reactions.ts +18 -0
- package/src/channels/adapters/discord-bot.ts +122 -67
- package/src/channels/adapters/discord-reactions.ts +18 -0
- package/src/channels/adapters/discord.ts +114 -8
- package/src/channels/adapters/github/inbound.ts +103 -8
- package/src/channels/adapters/github/index.ts +251 -19
- package/src/channels/adapters/github/last-alive.ts +27 -0
- package/src/channels/adapters/github/outbound.ts +54 -18
- package/src/channels/adapters/github/pending-review-store.ts +141 -0
- package/src/channels/adapters/github/permission-guidance.ts +1 -0
- package/src/channels/adapters/github/reactions.ts +100 -0
- package/src/channels/adapters/github/reconcile-cooldown-store.ts +197 -67
- package/src/channels/adapters/github/reconcile-open-prs.ts +418 -33
- package/src/channels/adapters/github/recovery.ts +106 -0
- package/src/channels/adapters/github/review-check.ts +510 -0
- package/src/channels/adapters/github/review-submitter.ts +34 -2
- package/src/channels/adapters/instagram.ts +32 -14
- package/src/channels/adapters/kakaotalk.ts +22 -7
- package/src/channels/adapters/line.ts +18 -3
- package/src/channels/adapters/outbound-account.ts +20 -0
- package/src/channels/adapters/own-reactions.ts +66 -0
- package/src/channels/adapters/recovery-correlation.ts +214 -0
- package/src/channels/adapters/slack-bot-classify.ts +18 -11
- package/src/channels/adapters/slack-bot-dedupe.ts +111 -28
- package/src/channels/adapters/slack-bot-reactions.ts +18 -0
- package/src/channels/adapters/slack-bot.ts +125 -57
- package/src/channels/adapters/slack-classify.ts +25 -4
- package/src/channels/adapters/slack-inbound-revision.ts +96 -0
- package/src/channels/adapters/slack-reactions.ts +18 -0
- package/src/channels/adapters/slack-thread-ts.ts +6 -0
- package/src/channels/adapters/slack.ts +48 -3
- package/src/channels/adapters/teams.ts +14 -4
- package/src/channels/adapters/telegram-bot.ts +56 -10
- package/src/channels/adapters/webex-bot.ts +12 -2
- package/src/channels/adapters/webex.ts +12 -2
- package/src/channels/background-handoff.ts +434 -0
- package/src/channels/background-obligations.ts +893 -0
- package/src/channels/continuity-types.ts +271 -0
- package/src/channels/github-review-check.ts +598 -0
- package/src/channels/github-review-turn-ledger.ts +102 -28
- package/src/channels/github-review-verdict-coordinator.ts +96 -13
- package/src/channels/github-token-bridge.ts +11 -5
- package/src/channels/inbound-journal.ts +1738 -0
- package/src/channels/index.ts +6 -1
- package/src/channels/manager.ts +17 -7
- package/src/channels/recovery-dispatcher.ts +264 -0
- package/src/channels/recovery-notice.ts +94 -0
- package/src/channels/recovery-outbox.ts +459 -0
- package/src/channels/router.ts +2582 -633
- package/src/channels/schema.ts +8 -1
- package/src/channels/subagent-completion-bridge.ts +17 -14
- package/src/channels/types.ts +121 -16
- package/src/channels/waiting-reactions.ts +664 -0
- package/src/cli/compose.ts +7 -4
- package/src/cli/hostd.ts +49 -3
- package/src/cli/inspect.ts +11 -14
- package/src/cli/model.ts +7 -5
- package/src/cli/oauth-callbacks.ts +38 -23
- package/src/coding-agent/broker-body.ts +38 -0
- package/src/coding-agent/broker.ts +290 -0
- package/src/coding-agent/claude.ts +95 -0
- package/src/coding-agent/codex.ts +104 -0
- package/src/coding-agent/index.ts +506 -0
- package/src/coding-agent/omo-state.ts +69 -0
- package/src/coding-agent/omo-stream.ts +98 -0
- package/src/coding-agent/omo.ts +192 -0
- package/src/coding-agent/runner.ts +263 -0
- package/src/coding-agent/tool.ts +62 -0
- package/src/coding-agent/worktree.ts +355 -0
- package/src/compose/restart.ts +10 -3
- package/src/compose/start.ts +20 -3
- package/src/config/config.ts +70 -26
- package/src/config/providers.ts +278 -50
- package/src/container/exit-reason.ts +44 -0
- package/src/container/index.ts +5 -0
- package/src/container/log-archive.ts +51 -13
- package/src/container/memory-limit.ts +1 -1
- package/src/container/memory-oversubscription.ts +36 -6
- package/src/container/oom-events.ts +86 -0
- package/src/container/restart.ts +2 -0
- package/src/container/shared.ts +8 -1
- package/src/container/start.ts +25 -13
- package/src/container/stop.ts +6 -2
- package/src/container/tool-oom-priority.ts +32 -0
- package/src/cron/consumer.ts +10 -4
- package/src/cron/reloadable.ts +23 -2
- package/src/doctor/checks.ts +14 -2
- package/src/hostd/daemon.ts +20 -10
- package/src/hostd/spawn.ts +106 -5
- package/src/hostd/version.ts +20 -0
- package/src/hostd/watchdog.ts +241 -0
- package/src/init/dockerfile.ts +57 -592
- package/src/init/index.ts +6 -7
- package/src/init/oauth-login.ts +57 -17
- package/src/inspect/transcript-view.ts +6 -3
- package/src/mcp/client.ts +3 -1
- package/src/operations/classify-tool-outcome.ts +45 -1
- package/src/operations/incidents.ts +10 -5
- package/src/plugin/core-tool-names.ts +1 -1
- package/src/plugin/define.ts +1 -0
- package/src/plugin/index.ts +1 -0
- package/src/plugin/types.ts +6 -1
- package/src/run/background-handoff-boot.ts +86 -0
- package/src/run/channel-session-factory.ts +5 -4
- package/src/run/index.ts +93 -93
- package/src/run/resource-sample.ts +19 -0
- package/src/sandbox/build.ts +4 -0
- package/src/sandbox/coding-agent.ts +214 -0
- package/src/sandbox/policy.ts +1 -0
- package/src/sandbox/runtime-private.ts +4 -1
- package/src/secrets/coding-agent-auth.ts +97 -0
- package/src/secrets/index.ts +0 -16
- package/src/secrets/refresh-provider-oauth.ts +30 -76
- package/src/secrets/schema.ts +3 -4
- package/src/secrets/storage.ts +133 -234
- package/src/server/command-runner.ts +6 -2
- package/src/server/index.ts +102 -41
- package/src/sessions/index.ts +1 -1
- package/src/skills/typeclaw-channel-github/SKILL.md +7 -5
- package/src/skills/typeclaw-claude-code/SKILL.md +25 -260
- package/src/skills/typeclaw-claude-code/references/auth-flow.md +7 -23
- package/src/skills/typeclaw-claude-code/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-claude-code/references/results-and-worktrees.md +13 -0
- package/src/skills/typeclaw-codex-cli/SKILL.md +35 -270
- package/src/skills/typeclaw-codex-cli/references/auth-flow.md +13 -20
- package/src/skills/typeclaw-codex-cli/references/headless-sessions.md +26 -0
- package/src/skills/typeclaw-codex-cli/references/results-and-worktrees.md +28 -0
- package/src/skills/typeclaw-config/SKILL.md +24 -24
- package/src/skills/typeclaw-config/references/dockerfile.md +14 -13
- package/src/skills/typeclaw-cron/SKILL.md +1 -1
- package/src/skills/typeclaw-github-contributing/SKILL.md +2 -2
- package/src/skills/typeclaw-memory/SKILL.md +3 -3
- package/src/skills/typeclaw-omo-cli/SKILL.md +52 -0
- package/src/skills/typeclaw-omo-cli/references/auth-flow.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/headless-sessions.md +11 -0
- package/src/skills/typeclaw-omo-cli/references/results-and-worktrees.md +23 -0
- package/src/skills/typeclaw-plugins/SKILL.md +20 -20
- package/src/skills/typeclaw-skills/SKILL.md +19 -2
- package/src/skills/typeclaw-troubleshooting/SKILL.md +15 -2
- package/src/tui/index.ts +5 -3
- package/src/tui/theme.ts +1 -1
- package/typeclaw.schema.json +44 -2
- package/src/agent/adaptive-thinking-compat.ts +0 -79
- package/src/secrets/claude-credentials-json.ts +0 -129
- package/src/secrets/codex-auth-json.ts +0 -102
- package/src/secrets/export-claude-credentials-file.ts +0 -270
- package/src/secrets/export-codex-auth-file.ts +0 -250
- package/src/secrets/oauth-xai.ts +0 -348
- package/src/skills/typeclaw-claude-code/references/stop-hook.md +0 -101
- package/src/skills/typeclaw-claude-code/references/tmux-driving.md +0 -243
- package/src/skills/typeclaw-codex-cli/references/stop-hook.md +0 -92
- package/src/skills/typeclaw-codex-cli/references/tmux-driving.md +0 -239
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const CLAUDE_CODE_VERSION = '2.1.299'
|
|
4
|
+
// Explicit compatibility set, not an open-ended provider allowlist.
|
|
5
|
+
export const CLAUDE_AUXILIARY_MODELS = ['claude-haiku-4-5-20251001', 'claude-sonnet-4-6', 'claude-opus-4-7'] as const
|
|
6
|
+
export type CodingMode = 'code' | 'plan'
|
|
7
|
+
|
|
8
|
+
export function claudeArguments(options: {
|
|
9
|
+
model: string
|
|
10
|
+
mode: CodingMode
|
|
11
|
+
sessionId: string
|
|
12
|
+
resume: boolean
|
|
13
|
+
}): string[] {
|
|
14
|
+
return [
|
|
15
|
+
'claude',
|
|
16
|
+
'-p',
|
|
17
|
+
'--output-format',
|
|
18
|
+
'stream-json',
|
|
19
|
+
'--verbose',
|
|
20
|
+
'--model',
|
|
21
|
+
options.model,
|
|
22
|
+
'--permission-mode',
|
|
23
|
+
options.mode === 'plan' ? 'plan' : 'dontAsk',
|
|
24
|
+
'--allowedTools',
|
|
25
|
+
'Read,Edit,Write,Bash,Agent,Glob,Grep',
|
|
26
|
+
'--settings',
|
|
27
|
+
JSON.stringify({ sandbox: { enabled: false } }),
|
|
28
|
+
options.resume ? '--resume' : '--session-id',
|
|
29
|
+
options.sessionId,
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function claudeEnvironment(configDir: string, baseUrl: string, capability: string): Record<string, string> {
|
|
34
|
+
return {
|
|
35
|
+
CLAUDE_CONFIG_DIR: configDir,
|
|
36
|
+
ANTHROPIC_BASE_URL: baseUrl,
|
|
37
|
+
ANTHROPIC_AUTH_TOKEN: capability,
|
|
38
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
|
|
39
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: CLAUDE_AUXILIARY_MODELS[0],
|
|
40
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: CLAUDE_AUXILIARY_MODELS[1],
|
|
41
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: CLAUDE_AUXILIARY_MODELS[2],
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const eventSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
type: z.string(),
|
|
48
|
+
session_id: z.string().uuid().optional(),
|
|
49
|
+
subtype: z.string().optional(),
|
|
50
|
+
is_error: z.boolean().optional(),
|
|
51
|
+
result: z.string().optional(),
|
|
52
|
+
permission_denials: z.array(z.unknown()).optional(),
|
|
53
|
+
})
|
|
54
|
+
.passthrough()
|
|
55
|
+
|
|
56
|
+
export class ClaudeStreamParser {
|
|
57
|
+
sessionId: string | undefined
|
|
58
|
+
finalMessage = ''
|
|
59
|
+
terminal = false
|
|
60
|
+
failed = false
|
|
61
|
+
permissionDenied = false
|
|
62
|
+
malformed = false
|
|
63
|
+
private pending = ''
|
|
64
|
+
|
|
65
|
+
push(text: string): void {
|
|
66
|
+
this.pending += text
|
|
67
|
+
if (this.pending.length > 4 * 1024 * 1024) throw new Error('Claude event exceeds the 4 MiB event limit.')
|
|
68
|
+
let newline: number
|
|
69
|
+
while ((newline = this.pending.indexOf('\n')) !== -1) {
|
|
70
|
+
const line = this.pending.slice(0, newline)
|
|
71
|
+
this.pending = this.pending.slice(newline + 1)
|
|
72
|
+
this.line(line)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
finish(): void {
|
|
77
|
+
if (this.pending.trim()) this.line(this.pending)
|
|
78
|
+
this.pending = ''
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private line(line: string): void {
|
|
82
|
+
if (!line.trim()) return
|
|
83
|
+
try {
|
|
84
|
+
const event = eventSchema.parse(JSON.parse(line))
|
|
85
|
+
if (event.session_id) this.sessionId = event.session_id
|
|
86
|
+
if (event.type !== 'result') return
|
|
87
|
+
this.terminal = true
|
|
88
|
+
this.failed = event.is_error === true || event.subtype !== 'success'
|
|
89
|
+
this.permissionDenied = (event.permission_denials?.length ?? 0) > 0
|
|
90
|
+
this.finalMessage = event.result ?? ''
|
|
91
|
+
} catch {
|
|
92
|
+
this.malformed = true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const CODEX_CLI_VERSION = '0.162.1'
|
|
4
|
+
|
|
5
|
+
export function codexArguments(options: { readonly sessionId: string; readonly resume: boolean }): string[] {
|
|
6
|
+
// The runner must establish outer bwrap confinement before executing this argv.
|
|
7
|
+
return [
|
|
8
|
+
'codex',
|
|
9
|
+
'exec',
|
|
10
|
+
'--json',
|
|
11
|
+
'--dangerously-bypass-approvals-and-sandbox',
|
|
12
|
+
...(options.resume ? ['resume', options.sessionId] : []),
|
|
13
|
+
'-',
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function codexEnvironment(configDir: string, capability: string): Record<string, string> {
|
|
18
|
+
return { CODEX_HOME: configDir, TYPECLAW_CODING_AGENT_CAPABILITY: capability }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function codexConfig(model: string, baseUrl: string): string {
|
|
22
|
+
return `model_provider = "typeclaw"
|
|
23
|
+
model = ${JSON.stringify(model)}
|
|
24
|
+
approval_policy = "never"
|
|
25
|
+
check_for_update_on_startup = false
|
|
26
|
+
cli_auth_credentials_store = "ephemeral"
|
|
27
|
+
|
|
28
|
+
[model_providers.typeclaw]
|
|
29
|
+
name = "TypeClaw coding broker"
|
|
30
|
+
base_url = ${JSON.stringify(`${baseUrl}/v1`)}
|
|
31
|
+
wire_api = "responses"
|
|
32
|
+
requires_openai_auth = false
|
|
33
|
+
env_key = "TYPECLAW_CODING_AGENT_CAPABILITY"
|
|
34
|
+
supports_websockets = false
|
|
35
|
+
supports_standalone_web_search = false
|
|
36
|
+
|
|
37
|
+
[model_providers.typeclaw.capabilities]
|
|
38
|
+
remote_compaction = "unsupported"
|
|
39
|
+
`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const eventSchema = z.object({ type: z.string() }).passthrough()
|
|
43
|
+
const threadSchema = z.object({ thread_id: z.string().uuid() })
|
|
44
|
+
const itemSchema = z.object({
|
|
45
|
+
item: z.object({ type: z.string(), text: z.string().optional(), status: z.string().optional() }),
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
export class CodexStreamParser {
|
|
49
|
+
sessionId: string | undefined
|
|
50
|
+
finalMessage = ''
|
|
51
|
+
terminal = false
|
|
52
|
+
failed = false
|
|
53
|
+
permissionDenied = false
|
|
54
|
+
malformed = false
|
|
55
|
+
private pending = ''
|
|
56
|
+
|
|
57
|
+
push(text: string): void {
|
|
58
|
+
this.pending += text
|
|
59
|
+
if (this.pending.length > 4 * 1024 * 1024) throw new Error('Codex event exceeds the 4 MiB event limit.')
|
|
60
|
+
let newline: number
|
|
61
|
+
while ((newline = this.pending.indexOf('\n')) !== -1) {
|
|
62
|
+
const line = this.pending.slice(0, newline)
|
|
63
|
+
this.pending = this.pending.slice(newline + 1)
|
|
64
|
+
this.line(line)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
finish(): void {
|
|
69
|
+
if (this.pending.trim()) this.line(this.pending)
|
|
70
|
+
this.pending = ''
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private line(line: string): void {
|
|
74
|
+
if (!line.trim()) return
|
|
75
|
+
try {
|
|
76
|
+
const event = eventSchema.parse(JSON.parse(line))
|
|
77
|
+
switch (event.type) {
|
|
78
|
+
case 'thread.started':
|
|
79
|
+
this.sessionId = threadSchema.parse(event).thread_id
|
|
80
|
+
break
|
|
81
|
+
case 'turn.started':
|
|
82
|
+
this.terminal = false
|
|
83
|
+
this.finalMessage = ''
|
|
84
|
+
break
|
|
85
|
+
case 'item.completed': {
|
|
86
|
+
const { item } = itemSchema.parse(event)
|
|
87
|
+
if (item.type === 'agent_message') this.finalMessage = z.string().parse(item.text)
|
|
88
|
+
if (item.type === 'command_execution' && item.status === 'declined') this.permissionDenied = true
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
case 'turn.completed':
|
|
92
|
+
this.terminal = true
|
|
93
|
+
break
|
|
94
|
+
case 'turn.failed':
|
|
95
|
+
case 'error':
|
|
96
|
+
this.terminal = true
|
|
97
|
+
this.failed = true
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
this.malformed = true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|