typeclaw 0.42.0 → 0.42.1
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 +3 -3
- package/src/agent/adaptive-thinking-compat.ts +79 -0
- package/src/agent/index.ts +79 -101
- package/src/agent/plugin-tools.ts +77 -130
- package/src/agent/provider-error.ts +37 -0
- package/src/agent/reload-tool.ts +1 -1
- package/src/agent/subagents.ts +2 -2
- package/src/agent/system-prompt.ts +19 -5
- package/src/agent/tool-result-budget.ts +1 -1
- package/src/agent/tools/stream-snapshot.ts +8 -3
- package/src/bundled-plugins/agent-browser/index.ts +18 -8
- package/src/bundled-plugins/memory/README.md +4 -1
- package/src/bundled-plugins/memory/belief-sentence.ts +50 -0
- package/src/bundled-plugins/memory/dreaming.ts +13 -6
- package/src/bundled-plugins/memory/load-memory.ts +22 -2
- package/src/bundled-plugins/memory/memory-logger.ts +1 -1
- package/src/capabilities/control-plane.ts +24 -0
- package/src/capabilities/index.ts +2 -0
- package/src/capabilities/runtime.ts +30 -0
- package/src/channels/manager.ts +41 -47
- package/src/channels/router.ts +11 -2
- package/src/cli/channel.ts +49 -12
- package/src/cli/hostd.ts +4 -3
- package/src/cli/logs.ts +2 -2
- package/src/cli/restart.ts +5 -3
- package/src/cli/shell.ts +2 -2
- package/src/cli/start.ts +2 -2
- package/src/cli/status.ts +2 -2
- package/src/cli/stop.ts +2 -2
- package/src/compose/restart.ts +4 -3
- package/src/compose/start.ts +2 -2
- package/src/compose/stop.ts +2 -2
- package/src/config/config.ts +10 -1
- package/src/config/providers.ts +61 -9
- package/src/container/controller.ts +104 -0
- package/src/container/index.ts +9 -0
- package/src/init/index.ts +1 -1
- package/src/init/instagram-auth.ts +189 -34
- package/src/inspect/logs-item.ts +2 -2
- package/src/mcp/client.ts +1 -1
- package/src/run/index.ts +21 -9
- package/src/run/{codex-fetch-observer.ts → llm-fetch-observer.ts} +182 -82
- package/src/sandbox/availability.ts +2 -2
- package/src/sandbox/build.ts +1 -1
- package/src/sandbox/policy.ts +2 -2
- package/src/secrets/discord-store.ts +4 -13
- package/src/secrets/instagram-store.ts +4 -13
- package/src/secrets/kakao-store.ts +4 -13
- package/src/secrets/line-store.ts +4 -13
- package/src/secrets/secrets-provider.ts +86 -0
- package/src/secrets/slack-store.ts +4 -13
- package/src/secrets/webex-store.ts +4 -13
- package/src/server/index.ts +2 -2
- package/src/skills/typeclaw-channel-instagram/SKILL.md +1 -1
- package/src/skills/typeclaw-config/SKILL.md +5 -3
- package/src/skills/typeclaw-plugins/SKILL.md +1 -1
- package/src/stream/broker.ts +4 -3
- package/src/stream/types.ts +1 -0
- package/typeclaw.schema.json +14 -0
package/src/cli/restart.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { confirm, isCancel } from '@clack/prompts'
|
|
|
2
2
|
import { defineCommand } from 'citty'
|
|
3
3
|
|
|
4
4
|
import { config, validateConfig } from '@/config'
|
|
5
|
-
import {
|
|
5
|
+
import { resolveController } from '@/container'
|
|
6
6
|
import { findAgentDir, isInitialized } from '@/init'
|
|
7
7
|
|
|
8
8
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
@@ -70,9 +70,11 @@ export const restartCommand = defineCommand({
|
|
|
70
70
|
process.exit(1)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const controller = resolveController()
|
|
74
|
+
|
|
73
75
|
const stopSpin = spinner()
|
|
74
76
|
stopSpin.start('Stopping container...')
|
|
75
|
-
const stopped = await stop({ cwd })
|
|
77
|
+
const stopped = await controller.stop({ cwd })
|
|
76
78
|
if (!stopped.ok) {
|
|
77
79
|
stopSpin.error(stopped.reason)
|
|
78
80
|
process.exit(1)
|
|
@@ -81,7 +83,7 @@ export const restartCommand = defineCommand({
|
|
|
81
83
|
|
|
82
84
|
const startSpin = spinner()
|
|
83
85
|
startSpin.start('Starting container...')
|
|
84
|
-
const started = await start({
|
|
86
|
+
const started = await controller.start({
|
|
85
87
|
cwd,
|
|
86
88
|
preferredHostPort: Number(args.port),
|
|
87
89
|
forceBuild: args.build,
|
package/src/cli/shell.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from 'citty'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { resolveController } from '@/container'
|
|
4
4
|
|
|
5
5
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
6
6
|
import { requireAgentDir } from './require-agent-dir'
|
|
@@ -29,7 +29,7 @@ export const shellCommand = defineCommand({
|
|
|
29
29
|
|
|
30
30
|
console.log(c.cyan(`Attaching ${args.shell} inside the container...`))
|
|
31
31
|
|
|
32
|
-
const result = await shell({ cwd, shell: args.shell })
|
|
32
|
+
const result = await resolveController().shell({ cwd, shell: args.shell })
|
|
33
33
|
if (!result.ok) {
|
|
34
34
|
console.error(errorLine(result.reason))
|
|
35
35
|
process.exit(1)
|
package/src/cli/start.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { confirm, isCancel } from '@clack/prompts'
|
|
|
2
2
|
import { defineCommand } from 'citty'
|
|
3
3
|
|
|
4
4
|
import { config, validateConfig } from '@/config'
|
|
5
|
-
import {
|
|
5
|
+
import { resolveController } from '@/container'
|
|
6
6
|
import { findAgentDir, isInitialized } from '@/init'
|
|
7
7
|
|
|
8
8
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
@@ -72,7 +72,7 @@ export const startCommand = defineCommand({
|
|
|
72
72
|
|
|
73
73
|
const s = spinner()
|
|
74
74
|
s.start('Starting container...')
|
|
75
|
-
const result = await start({
|
|
75
|
+
const result = await resolveController().start({
|
|
76
76
|
cwd,
|
|
77
77
|
preferredHostPort: Number(args.port),
|
|
78
78
|
forceBuild: args.build,
|
package/src/cli/status.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { styleText } from 'node:util'
|
|
|
2
2
|
|
|
3
3
|
import { defineCommand } from 'citty'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type ContainerStatus, type DockerExec, resolveController } from '@/container'
|
|
6
6
|
import { isDaemonReachable, send } from '@/hostd'
|
|
7
7
|
import type { StatusResult } from '@/hostd'
|
|
8
8
|
import { findAgentDir } from '@/init'
|
|
@@ -52,7 +52,7 @@ export async function runStatus(deps: RunStatusDeps = {}): Promise<void> {
|
|
|
52
52
|
return
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const container = await
|
|
55
|
+
const container = await resolveController().status({ cwd, exec: deps.exec })
|
|
56
56
|
const hostd = await (deps.fetchHostd ?? fetchHostdStatus)(container.containerName)
|
|
57
57
|
|
|
58
58
|
const useColor = Boolean(process.stdout.isTTY) && process.env.NO_COLOR === undefined
|
package/src/cli/stop.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from 'citty'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { resolveController } from '@/container'
|
|
4
4
|
|
|
5
5
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
6
6
|
import { requireAgentDir } from './require-agent-dir'
|
|
@@ -22,7 +22,7 @@ export const stopCommand = defineCommand({
|
|
|
22
22
|
|
|
23
23
|
const s = spinner()
|
|
24
24
|
s.start('Stopping container...')
|
|
25
|
-
const result = await stop({ cwd })
|
|
25
|
+
const result = await resolveController().stop({ cwd })
|
|
26
26
|
|
|
27
27
|
if (!result.ok) {
|
|
28
28
|
s.error(result.reason)
|
package/src/compose/restart.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { validateConfig } from '@/config'
|
|
2
|
-
import {
|
|
2
|
+
import { resolveController } from '@/container'
|
|
3
3
|
|
|
4
4
|
import { discoverAgents, type AgentEntry } from './discover'
|
|
5
5
|
import type { AgentResult, StartSuccess } from './start'
|
|
@@ -57,10 +57,11 @@ async function runOne(
|
|
|
57
57
|
const validated = validateConfig(cwd)
|
|
58
58
|
if (!validated.ok) return { name, ok: false, reason: validated.reason }
|
|
59
59
|
try {
|
|
60
|
-
const
|
|
60
|
+
const controller = resolveController()
|
|
61
|
+
const stopped = await controller.stop({ cwd })
|
|
61
62
|
if (!stopped.ok) return { name, ok: false, reason: stopped.reason }
|
|
62
63
|
onStopped()
|
|
63
|
-
const started = await start({ cwd, preferredHostPort, forceBuild, cliEntry })
|
|
64
|
+
const started = await controller.start({ cwd, preferredHostPort, forceBuild, cliEntry })
|
|
64
65
|
if (!started.ok) return { name, ok: false, reason: started.reason }
|
|
65
66
|
return { name, ok: true, data: { stop: stopped, start: started }, warnings: validated.warnings }
|
|
66
67
|
} catch (error) {
|
package/src/compose/start.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { validateConfig } from '@/config'
|
|
2
|
-
import {
|
|
2
|
+
import { resolveController, type StartResult } from '@/container'
|
|
3
3
|
|
|
4
4
|
import { discoverAgents, type AgentEntry } from './discover'
|
|
5
5
|
|
|
@@ -55,7 +55,7 @@ async function runOne(
|
|
|
55
55
|
const validated = validateConfig(cwd)
|
|
56
56
|
if (!validated.ok) return { name, ok: false, reason: validated.reason }
|
|
57
57
|
try {
|
|
58
|
-
const data = await start({ cwd, preferredHostPort, forceBuild, cliEntry })
|
|
58
|
+
const data = await resolveController().start({ cwd, preferredHostPort, forceBuild, cliEntry })
|
|
59
59
|
if (!data.ok) return { name, ok: false, reason: data.reason }
|
|
60
60
|
return { name, ok: true, data, warnings: validated.warnings }
|
|
61
61
|
} catch (error) {
|
package/src/compose/stop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveController, type StopResult } from '@/container'
|
|
2
2
|
|
|
3
3
|
import { discoverAgents, type AgentEntry } from './discover'
|
|
4
4
|
import type { AgentResult } from './start'
|
|
@@ -34,7 +34,7 @@ export async function composeStop({ rootCwd, onProgress }: ComposeStopOptions):
|
|
|
34
34
|
|
|
35
35
|
async function runOne(name: string, cwd: string): Promise<AgentResult<StopSuccess>> {
|
|
36
36
|
try {
|
|
37
|
-
const data = await stop({ cwd })
|
|
37
|
+
const data = await resolveController().stop({ cwd })
|
|
38
38
|
if (!data.ok) return { name, ok: false, reason: data.reason }
|
|
39
39
|
return { name, ok: true, data }
|
|
40
40
|
} catch (error) {
|
package/src/config/config.ts
CHANGED
|
@@ -373,7 +373,7 @@ export type NetworkConfig = z.infer<typeof networkSchema>
|
|
|
373
373
|
// the default 'proc-bind' strategy `--ro-bind`s the container's already-real
|
|
374
374
|
// procfs into the sandbox with NO CAP_SYS_ADMIN, giving the runner's child a
|
|
375
375
|
// working /proc/self/{fd,maps} so it stops aborting with Bun's "NotDir". The
|
|
376
|
-
// agent runtime's /proc/N/environ (
|
|
376
|
+
// agent runtime's /proc/N/environ (OPENAI_API_KEY) stays unreadable because
|
|
377
377
|
// bwrap's --unshare-user puts the sandbox in a child user namespace the kernel
|
|
378
378
|
// won't let read a parent-userns process's environ — verified at runtime by a
|
|
379
379
|
// probe before the strategy is selected (src/sandbox/availability.ts). Avoiding
|
|
@@ -786,6 +786,14 @@ export const configSchema = z
|
|
|
786
786
|
git: gitSchema,
|
|
787
787
|
roles: rolesConfigSchema.optional(),
|
|
788
788
|
tunnels: tunnelsArraySchema,
|
|
789
|
+
// When `true` (default), the system prompt tells the agent it runs on
|
|
790
|
+
// TypeClaw and stamps the runtime version. Set `false` to strip every
|
|
791
|
+
// TypeClaw-identifying clue from the system prompt: the base prompt's
|
|
792
|
+
// opening lines are phrased generically ("a general-purpose AI agent"
|
|
793
|
+
// instead of "…running inside TypeClaw") and the `## Runtime` version
|
|
794
|
+
// block is omitted entirely. Read fresh per session via `getConfig()`, so
|
|
795
|
+
// it applies on reload without a restart.
|
|
796
|
+
branding: z.boolean().default(true),
|
|
789
797
|
})
|
|
790
798
|
.catchall(z.unknown())
|
|
791
799
|
|
|
@@ -1012,6 +1020,7 @@ export const FIELD_EFFECTS: Record<string, FieldEffect> = {
|
|
|
1012
1020
|
// the corresponding projections of the whole `roles` block.
|
|
1013
1021
|
'roles.match': 'applied',
|
|
1014
1022
|
'roles.permissions': 'restart-required',
|
|
1023
|
+
branding: 'applied',
|
|
1015
1024
|
}
|
|
1016
1025
|
|
|
1017
1026
|
// Stable JSON for value comparison. Fields are small JSON-shaped objects, so
|
package/src/config/providers.ts
CHANGED
|
@@ -120,9 +120,8 @@ export const KNOWN_PROVIDERS = {
|
|
|
120
120
|
// ChatGPT Plus/Pro subscription via the OAuth Codex backend. No API key
|
|
121
121
|
// path here on purpose — the Codex backend is OAuth-only upstream.
|
|
122
122
|
//
|
|
123
|
-
// pi-ai
|
|
124
|
-
// chatgpt.com/backend-api. We
|
|
125
|
-
// ships pi-ai 0.67.3 and lacks those entries — but we hand pi-ai a
|
|
123
|
+
// pi-ai's `openai-codex` bucket carries gpt-5.5 (and 5.4) against
|
|
124
|
+
// chatgpt.com/backend-api. We don't rely on that catalog: we hand pi-ai a
|
|
126
125
|
// freshly-constructed `Model<>` literal via resolveModel(), bypassing its
|
|
127
126
|
// built-in catalog entirely (same trick we use for kimi-k2p6-turbo). So
|
|
128
127
|
// these ids work end-to-end as long as the Codex backend itself accepts
|
|
@@ -205,14 +204,18 @@ export const KNOWN_PROVIDERS = {
|
|
|
205
204
|
// anthropic`) before relying on the env-var path. Same rule applies to any
|
|
206
205
|
// future dual-auth provider — keep the surprise in mind when expanding.
|
|
207
206
|
//
|
|
208
|
-
// Model lineup is the current GA tier as of 2026-
|
|
209
|
-
// released
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
207
|
+
// Model lineup is the current GA tier as of 2026-07-02: Fable 5 (top,
|
|
208
|
+
// released Jun 2026 — a tier above Opus), Sonnet 5 (mid, Jul 1 2026),
|
|
209
|
+
// Opus 4.8 (May 2026), Opus 4.7 (Apr 16 2026), Sonnet 4.6 (Feb 5 2026),
|
|
210
|
+
// Haiku 4.5 (fast, Oct 1 2025). Anthropic's own model overview lists the
|
|
211
|
+
// latest Fable/Opus/Sonnet/Haiku as the current recommended set and flags
|
|
212
|
+
// earlier Opus/Sonnet variants with
|
|
213
213
|
// "Consider migrating to current models." Opus 4 / Sonnet 4 are deprecated
|
|
214
214
|
// (retirement: Jun 15 2026); the 4.5/4.6 alternates remain Active but are
|
|
215
|
-
// not the recommended path.
|
|
215
|
+
// not the recommended path. Claude Mythos 5 (Fable 5's classifier-free
|
|
216
|
+
// sibling, limited availability via Project Glasswing) is intentionally
|
|
217
|
+
// NOT listed — access is gated per-org and a registry entry would fail for
|
|
218
|
+
// everyone else.
|
|
216
219
|
//
|
|
217
220
|
// ID semantics differ across the lineup and matter for forward-compat:
|
|
218
221
|
// - `claude-haiku-4-5` is a 4.5-generation CONVENIENCE ALIAS that
|
|
@@ -273,6 +276,35 @@ export const KNOWN_PROVIDERS = {
|
|
|
273
276
|
contextWindow: 1000000,
|
|
274
277
|
maxTokens: 64000,
|
|
275
278
|
},
|
|
279
|
+
// Sonnet 5 (Jul 1 2026) is the drop-in successor to Sonnet 4.6 with a
|
|
280
|
+
// caveat set that affects consumers of this record:
|
|
281
|
+
// - New tokenizer: ~30% more tokens for the same text vs Sonnet 4.6.
|
|
282
|
+
// Per-token price is unchanged, so equivalent requests cost more.
|
|
283
|
+
// - Adaptive thinking only: manual extended thinking
|
|
284
|
+
// (`thinking: {type: "enabled"}` with `budget_tokens`) returns a
|
|
285
|
+
// 400. The pinned pi-ai 0.73.x DOES send that payload for this id
|
|
286
|
+
// (its supportsAdaptiveThinking() only matches 4.6-generation ids,
|
|
287
|
+
// and thinking defaults to "medium"), so registering this record
|
|
288
|
+
// with `reasoning: true` depends on the rewrite shim in
|
|
289
|
+
// src/agent/adaptive-thinking-compat.ts. Don't wire a
|
|
290
|
+
// thinking-budget knob to this id.
|
|
291
|
+
// - Cost encodes the STANDARD rate (in effect Sep 1 2026+).
|
|
292
|
+
// Introductory pricing ($2/$10, cacheRead 0.2, cacheWrite 2.5) runs
|
|
293
|
+
// through Aug 31 2026, so `typeclaw usage` over-reports Sonnet 5
|
|
294
|
+
// spend until then. Chosen so the record doesn't silently go stale
|
|
295
|
+
// two months after landing.
|
|
296
|
+
'claude-sonnet-5': {
|
|
297
|
+
id: 'claude-sonnet-5',
|
|
298
|
+
name: 'Claude Sonnet 5',
|
|
299
|
+
api: 'anthropic-messages',
|
|
300
|
+
provider: 'anthropic',
|
|
301
|
+
baseUrl: 'https://api.anthropic.com',
|
|
302
|
+
reasoning: true,
|
|
303
|
+
input: ['text', 'image'],
|
|
304
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
305
|
+
contextWindow: 1000000,
|
|
306
|
+
maxTokens: 128000,
|
|
307
|
+
},
|
|
276
308
|
'claude-opus-4-7': {
|
|
277
309
|
id: 'claude-opus-4-7',
|
|
278
310
|
name: 'Claude Opus 4.7',
|
|
@@ -297,6 +329,26 @@ export const KNOWN_PROVIDERS = {
|
|
|
297
329
|
contextWindow: 1000000,
|
|
298
330
|
maxTokens: 128000,
|
|
299
331
|
},
|
|
332
|
+
// Fable 5 (Jun 2026) is a NEW TIER above Opus — Anthropic's most
|
|
333
|
+
// capable widely released model, aimed at long-horizon agentic work.
|
|
334
|
+
// Ships the 5-generation tokenizer: ~1.3x token counts for the same
|
|
335
|
+
// text vs pre-5 models, so equivalent requests cost more than the
|
|
336
|
+
// per-token rates alone suggest. Adaptive thinking only, same as
|
|
337
|
+
// Sonnet 5 above: `reasoning: true` here depends on the rewrite shim
|
|
338
|
+
// in src/agent/adaptive-thinking-compat.ts (pinned pi-ai 0.73.x would
|
|
339
|
+
// otherwise send budget-based `thinking`, a hard 400 on this id).
|
|
340
|
+
'claude-fable-5': {
|
|
341
|
+
id: 'claude-fable-5',
|
|
342
|
+
name: 'Claude Fable 5',
|
|
343
|
+
api: 'anthropic-messages',
|
|
344
|
+
provider: 'anthropic',
|
|
345
|
+
baseUrl: 'https://api.anthropic.com',
|
|
346
|
+
reasoning: true,
|
|
347
|
+
input: ['text', 'image'],
|
|
348
|
+
cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 },
|
|
349
|
+
contextWindow: 1000000,
|
|
350
|
+
maxTokens: 128000,
|
|
351
|
+
},
|
|
300
352
|
},
|
|
301
353
|
},
|
|
302
354
|
fireworks: {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { logs, type LogsOptions, type LogsResult } from './logs'
|
|
2
|
+
import { containerNameFromCwd, imageTagFromCwd } from './shared'
|
|
3
|
+
import { shell, type ShellResult } from './shell'
|
|
4
|
+
import { start, type StartOptions, type StartResult } from './start'
|
|
5
|
+
import { status, type ContainerStatus, type StatusOptions } from './status'
|
|
6
|
+
import { stop, type StopOptions, type StopResult } from './stop'
|
|
7
|
+
|
|
8
|
+
// The controller role: the external actuator that acts ON a container's
|
|
9
|
+
// lifecycle (start/stop/status/logs/shell). Distinct from the host role
|
|
10
|
+
// (RuntimeSecretsProvider), which the container reaches INTO for durable state.
|
|
11
|
+
//
|
|
12
|
+
// In the `host` profile typeclaw owns this loop (LocalDockerController shells
|
|
13
|
+
// out to Docker). In a `managed` profile a platform (ECS/K8s/…) owns it, so
|
|
14
|
+
// typeclaw carries no controller — NoopController makes that absence explicit
|
|
15
|
+
// and fail-loud instead of silently shelling out to a Docker that isn't there.
|
|
16
|
+
export interface Controller {
|
|
17
|
+
start(options: StartOptions): Promise<StartResult>
|
|
18
|
+
stop(options: StopOptions): Promise<StopResult>
|
|
19
|
+
status(options: StatusOptions): Promise<ContainerStatus>
|
|
20
|
+
logs(options: LogsOptions): Promise<LogsResult>
|
|
21
|
+
shell(options: { cwd: string; shell?: string }): Promise<ShellResult>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Thin adapter over the existing lifecycle functions — no behavior change, it
|
|
25
|
+
// just names the actuation surface as an interface so a managed profile can
|
|
26
|
+
// substitute a no-op controller. Factory (not class) to match the repo's
|
|
27
|
+
// functional DI convention.
|
|
28
|
+
export function createLocalDockerController(): Controller {
|
|
29
|
+
return {
|
|
30
|
+
start: (options) => start(options),
|
|
31
|
+
stop: (options) => stop(options),
|
|
32
|
+
status: (options) => status(options),
|
|
33
|
+
logs: (options) => logs(options),
|
|
34
|
+
shell: (options) => shell(options),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const CONTROLLER_UNSUPPORTED_REASON =
|
|
39
|
+
'container lifecycle is managed by the platform; typeclaw has no controller in this profile'
|
|
40
|
+
|
|
41
|
+
// The `managed`-profile controller: the platform owns start/stop/restart, so
|
|
42
|
+
// every lifecycle verb is a fail-loud no-op rather than a Docker shell-out.
|
|
43
|
+
// status() reports `missing` because typeclaw cannot introspect a container it
|
|
44
|
+
// does not orchestrate.
|
|
45
|
+
export function createNoopController(): Controller {
|
|
46
|
+
return {
|
|
47
|
+
async start({ cwd }) {
|
|
48
|
+
return { ok: false, reason: unsupported('start', cwd) }
|
|
49
|
+
},
|
|
50
|
+
async stop({ cwd }) {
|
|
51
|
+
return { ok: false, reason: unsupported('stop', cwd) }
|
|
52
|
+
},
|
|
53
|
+
async status({ cwd }) {
|
|
54
|
+
return { kind: 'missing', containerName: containerNameFromCwd(cwd), imageTag: imageTagFromCwd(cwd) }
|
|
55
|
+
},
|
|
56
|
+
async logs({ cwd }) {
|
|
57
|
+
return { ok: false, reason: unsupported('logs', cwd) }
|
|
58
|
+
},
|
|
59
|
+
async shell({ cwd }) {
|
|
60
|
+
return { ok: false, reason: unsupported('shell', cwd) }
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function unsupported(verb: string, cwd: string): string {
|
|
66
|
+
return `${verb} unsupported for ${cwd}: ${CONTROLLER_UNSUPPORTED_REASON}`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Which side owns the container control loop. `host` = typeclaw orchestrates
|
|
70
|
+
// via local Docker (the only reachable value today). `managed` = an external
|
|
71
|
+
// platform (ECS/K8s/…) owns it. The distinction is a deployer concern, not an
|
|
72
|
+
// agent-runtime one; see docs/internals for the host/controller split.
|
|
73
|
+
export type DeploymentProfile = 'host' | 'managed'
|
|
74
|
+
|
|
75
|
+
// Single source of truth for the deployment profile. There is no `managed`
|
|
76
|
+
// runtime yet, so this always resolves to `host`. When a managed platform
|
|
77
|
+
// lands, the trigger (a platform-injected env var, or a config field) is wired
|
|
78
|
+
// HERE — one place, not per call site.
|
|
79
|
+
export function resolveDeploymentProfile(): DeploymentProfile {
|
|
80
|
+
return 'host'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The controller-axis resolver: maps the deployment profile to its actuator.
|
|
84
|
+
// Callers construct their Controller through this instead of `new
|
|
85
|
+
// LocalDockerController()` directly. `profile` is injectable for tests;
|
|
86
|
+
// production omits it and gets `resolveDeploymentProfile()`.
|
|
87
|
+
//
|
|
88
|
+
// SCOPE (do not overclaim): this centralizes only the *direct controller
|
|
89
|
+
// construction* — the lifecycle CALLS that previously did `new
|
|
90
|
+
// LocalDockerController()`. It is NOT yet the single deployment boundary. Two
|
|
91
|
+
// host-Docker escape hatches still sit outside it, to be routed when the
|
|
92
|
+
// managed controller is actually built:
|
|
93
|
+
// 1. Docker preflight (`preflightDocker()`) runs BEFORE the resolver in
|
|
94
|
+
// start/stop/logs/shell/restart and compose, so a managed profile would
|
|
95
|
+
// exit on the host-only check before reaching a managed controller.
|
|
96
|
+
// Fix: resolve profile first, move availability checks inside the host
|
|
97
|
+
// controller path.
|
|
98
|
+
// 2. Fleet/status/init paths still use host primitives directly
|
|
99
|
+
// (`resolveDockerBinary` in compose/logs, `inspectContainer` in
|
|
100
|
+
// compose/status, `start`/`stop` deps in init) — probes not on the
|
|
101
|
+
// Controller surface. Route or narrow when managed lands.
|
|
102
|
+
export function resolveController(profile: DeploymentProfile = resolveDeploymentProfile()): Controller {
|
|
103
|
+
return profile === 'managed' ? createNoopController() : createLocalDockerController()
|
|
104
|
+
}
|
package/src/container/index.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CONTROLLER_UNSUPPORTED_REASON,
|
|
3
|
+
type Controller,
|
|
4
|
+
createLocalDockerController,
|
|
5
|
+
createNoopController,
|
|
6
|
+
type DeploymentProfile,
|
|
7
|
+
resolveController,
|
|
8
|
+
resolveDeploymentProfile,
|
|
9
|
+
} from './controller'
|
|
1
10
|
export {
|
|
2
11
|
classifyConfiguredRuntime,
|
|
3
12
|
detectInstalledDockerApps,
|
package/src/init/index.ts
CHANGED
|
@@ -373,7 +373,7 @@ export async function runInit({
|
|
|
373
373
|
})
|
|
374
374
|
// Only write the LLM API key on the api-key path. OAuth providers persist
|
|
375
375
|
// their credentials to secrets.json (via the OAuth login step above); writing
|
|
376
|
-
// an empty
|
|
376
|
+
// an empty OPENAI_API_KEY would just confuse users.
|
|
377
377
|
await writeSecrets(cwd, {
|
|
378
378
|
model,
|
|
379
379
|
apiKey: resolvedAuth.kind === 'api-key' ? resolvedAuth.apiKey : undefined,
|