typeclaw 0.39.6 → 0.40.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 +1 -1
- package/scripts/dump-system-prompt.ts +4 -50
- package/src/agent/auth-reloadable.ts +24 -0
- package/src/agent/auth.ts +12 -0
- package/src/agent/index.ts +18 -58
- package/src/agent/todo/continuation-policy.ts +8 -0
- package/src/agent/todo/continuation-state.ts +41 -7
- package/src/agent/todo/continuation-wiring.ts +26 -0
- package/src/bundled-plugins/guard/policies/non-workspace-write.ts +0 -2
- package/src/bundled-plugins/guard/policy.ts +0 -5
- package/src/bundled-plugins/memory/README.md +26 -37
- package/src/bundled-plugins/memory/index.ts +32 -144
- package/src/bundled-plugins/memory/load-memory.ts +7 -121
- package/src/bundled-plugins/memory/memory-logger.ts +12 -6
- package/src/bundled-plugins/memory/search-command.ts +124 -0
- package/src/bundled-plugins/memory/vector/doctor.ts +1 -1
- package/src/bundled-plugins/memory/vector/embedder.ts +4 -5
- package/src/bundled-plugins/memory/vector/hybrid.ts +47 -5
- package/src/bundled-plugins/memory/vector/relevance-gate.ts +11 -7
- package/src/bundled-plugins/memory/vector/script.ts +87 -0
- package/src/channels/adapters/describe-error.ts +40 -0
- package/src/channels/adapters/discord.ts +9 -12
- package/src/channels/adapters/kakaotalk.ts +14 -17
- package/src/channels/adapters/line.ts +11 -14
- package/src/channels/adapters/slack-bot.ts +15 -18
- package/src/channels/adapters/slack.ts +45 -21
- package/src/channels/adapters/telegram-bot.ts +15 -18
- package/src/channels/adapters/webex-bot.ts +13 -14
- package/src/channels/adapters/webex.ts +14 -15
- package/src/channels/router.ts +60 -1
- package/src/cli/command-meta.ts +7 -16
- package/src/cli/compose.ts +21 -1
- package/src/cli/cron.ts +1 -1
- package/src/cli/docker-preflight.ts +42 -0
- package/src/cli/doctor.ts +1 -1
- package/src/cli/dreams.ts +1 -1
- package/src/cli/hostd.ts +12 -3
- package/src/cli/index.ts +1 -1
- package/src/cli/init.ts +24 -22
- package/src/cli/inspect.ts +1 -1
- package/src/cli/logs.ts +7 -0
- package/src/cli/memory.ts +85 -0
- package/src/cli/model.ts +1 -1
- package/src/cli/provider.ts +8 -1
- package/src/cli/reload.ts +6 -0
- package/src/cli/restart.ts +7 -0
- package/src/cli/shell.ts +7 -0
- package/src/cli/start.ts +7 -0
- package/src/cli/status.ts +9 -0
- package/src/cli/stop.ts +7 -0
- package/src/cli/tui.ts +6 -0
- package/src/config/config.ts +31 -8
- package/src/container/docker-app.ts +253 -0
- package/src/container/index.ts +11 -0
- package/src/container/start.ts +85 -41
- package/src/hostd/current-host-daemon.ts +21 -0
- package/src/hostd/daemon.ts +27 -3
- package/src/hostd/supervisor.ts +18 -3
- package/src/plugin/hooks.ts +3 -4
- package/src/plugin/types.ts +1 -1
- package/src/role-claim/client.ts +6 -1
- package/src/run/channel-session-factory.ts +3 -5
- package/src/run/index.ts +50 -17
- package/src/server/command-runner.ts +2 -11
- package/src/server/index.ts +8 -0
- package/src/skills/typeclaw-memory/SKILL.md +2 -2
- package/src/skills/typeclaw-plugins/SKILL.md +1 -1
- package/typeclaw.schema.json +1 -23
- package/src/bundled-plugins/guard/policies/memory-retrieval-cache-write.ts +0 -43
- package/src/bundled-plugins/memory/memory-retrieval.ts +0 -111
- package/src/bundled-plugins/memory/vector/cache-write.ts +0 -19
- package/src/bundled-plugins/memory/vector/config.ts +0 -28
package/src/cli/hostd.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineCommand } from 'citty'
|
|
|
2
2
|
|
|
3
3
|
import { loadConfigSync, validateConfig, type Config, type ValidateConfigResult } from '@/config'
|
|
4
4
|
import { start, stop, type StartOptions, type StartResult, type StopResult } from '@/container'
|
|
5
|
+
import { createCurrentHostDaemonHolder } from '@/hostd/current-host-daemon'
|
|
5
6
|
import { startDaemon, type DaemonLogEvent, type RestartPreflight } from '@/hostd/daemon'
|
|
6
7
|
import { createKakaoRenewalManager } from '@/hostd/kakao-renewal-manager'
|
|
7
8
|
import { createPortbrokerManager } from '@/hostd/portbroker-manager'
|
|
@@ -26,6 +27,10 @@ export const hostdCommand = defineCommand({
|
|
|
26
27
|
})
|
|
27
28
|
|
|
28
29
|
const hostdRestart = buildHostdRestart(cliEntry, defaultRestartDeps, version)
|
|
30
|
+
// Renewal restarts call hostdRestart directly (not via the restart RPC), so
|
|
31
|
+
// they must thread currentHostDaemon themselves to get the in-process
|
|
32
|
+
// registration path. The daemon populates this holder once booted.
|
|
33
|
+
const currentHostDaemonHolder = createCurrentHostDaemonHolder()
|
|
29
34
|
const kakaoRenewal = createKakaoRenewalManager({
|
|
30
35
|
onLog: (event) => writeLogLine(formatLog(event)),
|
|
31
36
|
onRenewalOk: async ({ containerName, cwd }) => {
|
|
@@ -33,7 +38,8 @@ export const hostdCommand = defineCommand({
|
|
|
33
38
|
// up the renewed tokens from secrets.json. Without this, the cron
|
|
34
39
|
// would write fresh tokens but the running adapter would keep using
|
|
35
40
|
// the old token in its closure and still 401 at the ~7-day wall.
|
|
36
|
-
const
|
|
41
|
+
const currentHostDaemon = await currentHostDaemonHolder.ready()
|
|
42
|
+
const result = await hostdRestart({ containerName, cwd, currentHostDaemon })
|
|
37
43
|
if (!result.ok) throw new Error(result.reason)
|
|
38
44
|
},
|
|
39
45
|
shouldRenew: ({ cwd }) => kakaoChannelConfigured(cwd),
|
|
@@ -45,7 +51,8 @@ export const hostdCommand = defineCommand({
|
|
|
45
51
|
// secrets.json. Without this, the cron writes a fresh token but the
|
|
46
52
|
// running adapter keeps the old token in its getToken closure and still
|
|
47
53
|
// 401s on every outbound REST call + KMS key fetch.
|
|
48
|
-
const
|
|
54
|
+
const currentHostDaemon = await currentHostDaemonHolder.ready()
|
|
55
|
+
const result = await hostdRestart({ containerName, cwd, currentHostDaemon })
|
|
49
56
|
if (!result.ok) throw new Error(result.reason)
|
|
50
57
|
},
|
|
51
58
|
shouldRenew: ({ cwd }) => webexChannelConfigured(cwd),
|
|
@@ -58,6 +65,7 @@ export const hostdCommand = defineCommand({
|
|
|
58
65
|
portbroker,
|
|
59
66
|
kakaoRenewal,
|
|
60
67
|
webexRenewal,
|
|
68
|
+
currentHostDaemonHolder,
|
|
61
69
|
restartPreflight: buildHostdRestartPreflight(cliEntry, version, defaultPreflightDeps),
|
|
62
70
|
restart: hostdRestart,
|
|
63
71
|
})
|
|
@@ -96,7 +104,7 @@ export function buildHostdRestart(
|
|
|
96
104
|
deps: HostdRestartDeps = defaultRestartDeps,
|
|
97
105
|
daemonVersion?: string,
|
|
98
106
|
): SupervisorRestart {
|
|
99
|
-
return async ({ containerName, cwd, build = false }) => {
|
|
107
|
+
return async ({ containerName, cwd, build = false, currentHostDaemon }) => {
|
|
100
108
|
const drift = await detectSourceDrift(cliEntry, daemonVersion)
|
|
101
109
|
if (drift) return { ok: false, reason: drift }
|
|
102
110
|
|
|
@@ -114,6 +122,7 @@ export function buildHostdRestart(
|
|
|
114
122
|
forceBuild: build,
|
|
115
123
|
cliEntry,
|
|
116
124
|
reuseCurrentHostDaemon: true,
|
|
125
|
+
...(currentHostDaemon ? { currentHostDaemon } : {}),
|
|
117
126
|
})
|
|
118
127
|
if (!startResult.ok) return { ok: false, reason: `start failed: ${startResult.reason}` }
|
|
119
128
|
return { ok: true }
|
package/src/cli/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ const main = defineCommand({
|
|
|
25
25
|
reload: () => import('./reload').then((m) => m.reload),
|
|
26
26
|
logs: () => import('./logs').then((m) => m.logsCommand),
|
|
27
27
|
inspect: () => import('./inspect').then((m) => m.inspectCommand),
|
|
28
|
-
|
|
28
|
+
memory: () => import('./memory').then((m) => m.memoryCommand),
|
|
29
29
|
shell: () => import('./shell').then((m) => m.shellCommand),
|
|
30
30
|
compose: () => import('./compose').then((m) => m.composeCommand),
|
|
31
31
|
channel: () => import('./channel').then((m) => m.channelCommand),
|
package/src/cli/init.ts
CHANGED
|
@@ -30,7 +30,13 @@ import {
|
|
|
30
30
|
type KnownProviderId,
|
|
31
31
|
type KnownProviderVendorId,
|
|
32
32
|
} from '@/config/providers'
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
checkDockerAvailable,
|
|
35
|
+
detectInstalledDockerApps,
|
|
36
|
+
pickRuntimeToNudge,
|
|
37
|
+
renderDockerUnavailableGuidance,
|
|
38
|
+
type DockerAvailability,
|
|
39
|
+
} from '@/container'
|
|
34
40
|
import {
|
|
35
41
|
appendOrReplaceEnvKey,
|
|
36
42
|
findAgentDir,
|
|
@@ -1928,31 +1934,27 @@ function reportProgress(
|
|
|
1928
1934
|
}
|
|
1929
1935
|
}
|
|
1930
1936
|
|
|
1937
|
+
function renderPreflightFailure(result: Extract<DockerAvailability, { ok: false }>): {
|
|
1938
|
+
summary: string
|
|
1939
|
+
lines: string[]
|
|
1940
|
+
} {
|
|
1941
|
+
const detail = result.reason === 'daemon-down' ? result.detail : undefined
|
|
1942
|
+
const installed = detectInstalledDockerApps()
|
|
1943
|
+
const nudge = pickRuntimeToNudge(process.env, detail, installed)
|
|
1944
|
+
return renderDockerUnavailableGuidance(result, {
|
|
1945
|
+
platform: process.platform,
|
|
1946
|
+
nudge,
|
|
1947
|
+
installed,
|
|
1948
|
+
retryHint: 'Then re-run `typeclaw init`.',
|
|
1949
|
+
})
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1931
1952
|
function preflightFailureSummary(result: Extract<DockerAvailability, { ok: false }>): string {
|
|
1932
|
-
|
|
1933
|
-
return 'Docker is installed but the daemon is not reachable.'
|
|
1953
|
+
return renderPreflightFailure(result).summary
|
|
1934
1954
|
}
|
|
1935
1955
|
|
|
1936
1956
|
function preflightFailureGuidance(result: Extract<DockerAvailability, { ok: false }>): string[] {
|
|
1937
|
-
|
|
1938
|
-
return [
|
|
1939
|
-
'TypeClaw runs every agent inside its own Docker container, so Docker is required.',
|
|
1940
|
-
'',
|
|
1941
|
-
'Install one of:',
|
|
1942
|
-
' • Docker Desktop — https://docs.docker.com/get-docker/',
|
|
1943
|
-
' • OrbStack (macOS, lighter) — https://orbstack.dev',
|
|
1944
|
-
'',
|
|
1945
|
-
'Then re-run `typeclaw init`.',
|
|
1946
|
-
]
|
|
1947
|
-
}
|
|
1948
|
-
return [
|
|
1949
|
-
'The docker CLI is on $PATH, but the daemon refused the connection:',
|
|
1950
|
-
'',
|
|
1951
|
-
` ${result.detail}`,
|
|
1952
|
-
'',
|
|
1953
|
-
'Start Docker Desktop / OrbStack (or `sudo systemctl start docker` on Linux),',
|
|
1954
|
-
'then re-run `typeclaw init`.',
|
|
1955
|
-
]
|
|
1957
|
+
return renderPreflightFailure(result).lines
|
|
1956
1958
|
}
|
|
1957
1959
|
|
|
1958
1960
|
function reportKakaotalkAuth(result: KakaotalkAuthResult): string {
|
package/src/cli/inspect.ts
CHANGED
|
@@ -27,7 +27,7 @@ const ESC_DEBOUNCE_MS = 50
|
|
|
27
27
|
export const inspectCommand = defineCommand({
|
|
28
28
|
meta: {
|
|
29
29
|
name: 'inspect',
|
|
30
|
-
description: 'session viewer:
|
|
30
|
+
description: 'session viewer: a session, the live TUI, or container logs',
|
|
31
31
|
},
|
|
32
32
|
args: {
|
|
33
33
|
session: {
|
package/src/cli/logs.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineCommand } from 'citty'
|
|
|
2
2
|
|
|
3
3
|
import { logs, parseTailValue } from '@/container'
|
|
4
4
|
|
|
5
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
5
6
|
import { runInspectViewer } from './inspect'
|
|
6
7
|
import { requireAgentDir } from './require-agent-dir'
|
|
7
8
|
import { c, errorLine } from './ui'
|
|
@@ -51,6 +52,12 @@ export const logsCommand = defineCommand({
|
|
|
51
52
|
process.exit(exitCode)
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
const preflight = await preflightDocker()
|
|
56
|
+
if (!preflight.ok) {
|
|
57
|
+
printDockerGuidance(preflight)
|
|
58
|
+
process.exit(1)
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
if (args.follow) {
|
|
55
62
|
console.log(c.cyan('Streaming container logs...'))
|
|
56
63
|
} else {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
|
|
3
|
+
import { proxyContainerCommand } from './container-command-client'
|
|
4
|
+
import { dreamsCommand } from './dreams'
|
|
5
|
+
import { requireAgentDir } from './require-agent-dir'
|
|
6
|
+
import { errorLine } from './ui'
|
|
7
|
+
|
|
8
|
+
const MEMORY_SEARCH_COMMAND = 'memory-search'
|
|
9
|
+
|
|
10
|
+
const searchSub = defineCommand({
|
|
11
|
+
meta: {
|
|
12
|
+
name: 'search',
|
|
13
|
+
description: 'vector-search the agent long-term memory inside the running container (host stage)',
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
query: {
|
|
17
|
+
type: 'positional',
|
|
18
|
+
description: 'the search query',
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
topK: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'return at most N ranked results (default 10)',
|
|
24
|
+
},
|
|
25
|
+
json: {
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
description: 'emit raw JSON results instead of formatted text',
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
async run({ args }) {
|
|
32
|
+
const cwd = requireAgentDir()
|
|
33
|
+
const topK = parseTopK(args.topK)
|
|
34
|
+
if (topK === 'invalid') {
|
|
35
|
+
process.stderr.write(`${errorLine('--topK must be a positive integer')}\n`)
|
|
36
|
+
process.exit(2)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const result = await proxyContainerCommand({
|
|
40
|
+
agentDir: cwd,
|
|
41
|
+
commandName: MEMORY_SEARCH_COMMAND,
|
|
42
|
+
args: {
|
|
43
|
+
query: args.query,
|
|
44
|
+
json: args.json === true,
|
|
45
|
+
...(topK !== undefined ? { topK } : {}),
|
|
46
|
+
},
|
|
47
|
+
stdout: nodeWritable(process.stdout),
|
|
48
|
+
stderr: nodeWritable(process.stderr),
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
if (!result.ok) {
|
|
52
|
+
process.stderr.write(`${errorLine(result.message)}\n`)
|
|
53
|
+
process.exit(result.exitCode)
|
|
54
|
+
}
|
|
55
|
+
process.exit(result.exitCode)
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
export const memoryCommand = defineCommand({
|
|
60
|
+
meta: {
|
|
61
|
+
name: 'memory',
|
|
62
|
+
description: "browse and search the agent's long-term memory",
|
|
63
|
+
},
|
|
64
|
+
subCommands: {
|
|
65
|
+
dreams: dreamsCommand,
|
|
66
|
+
search: searchSub,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
function parseTopK(raw: unknown): number | undefined | 'invalid' {
|
|
71
|
+
if (typeof raw !== 'string') return undefined
|
|
72
|
+
// Whole-string match, not Number.parseInt — parseInt silently truncates
|
|
73
|
+
// "1.5" to 1 and "10abc" to 10, proxying invalid input as a valid-looking
|
|
74
|
+
// topK. The container's max-50 zod check stays as the upper-bound guard.
|
|
75
|
+
if (!/^[1-9]\d*$/.test(raw)) return 'invalid'
|
|
76
|
+
return Number(raw)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function nodeWritable(stream: NodeJS.WriteStream): WritableStream<Uint8Array> {
|
|
80
|
+
return new WritableStream<Uint8Array>({
|
|
81
|
+
write(chunk) {
|
|
82
|
+
stream.write(chunk)
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
}
|
package/src/cli/model.ts
CHANGED
|
@@ -277,7 +277,7 @@ const listSub = defineCommand({
|
|
|
277
277
|
export const modelCommand = defineCommand({
|
|
278
278
|
meta: {
|
|
279
279
|
name: 'model',
|
|
280
|
-
description: 'manage model profiles in typeclaw.json (models.default,
|
|
280
|
+
description: 'manage model profiles in typeclaw.json (models.default, ...)',
|
|
281
281
|
},
|
|
282
282
|
subCommands: {
|
|
283
283
|
set: setSub,
|
package/src/cli/provider.ts
CHANGED
|
@@ -438,5 +438,12 @@ function describeSource(source: CredentialSource): string {
|
|
|
438
438
|
|
|
439
439
|
function nextStepHints(opts: { credentialChanged: boolean }): { label: string; command: string }[] {
|
|
440
440
|
if (!opts.credentialChanged) return []
|
|
441
|
-
|
|
441
|
+
// secrets.json is bind-mounted live, so `typeclaw reload` clears the provider
|
|
442
|
+
// auth cache and the next call re-reads this file. Editing a key's value in
|
|
443
|
+
// .env instead still needs a restart — container env is fixed at `docker run`
|
|
444
|
+
// — so surface both paths to the user, not just reload.
|
|
445
|
+
return [
|
|
446
|
+
{ label: 'Apply the secrets.json change:', command: 'typeclaw reload' },
|
|
447
|
+
{ label: 'If you changed a key in .env:', command: 'typeclaw restart' },
|
|
448
|
+
]
|
|
442
449
|
}
|
package/src/cli/reload.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { requireContainerRunning, resolveHostPort, resolveTuiToken } from '@/con
|
|
|
4
4
|
import { findAgentDir } from '@/init'
|
|
5
5
|
import { requestReloadWithFallback, type ReloadResult } from '@/reload'
|
|
6
6
|
|
|
7
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
7
8
|
import { c, errorLine, spinner } from './ui'
|
|
8
9
|
|
|
9
10
|
export const reload = defineCommand({
|
|
@@ -84,6 +85,11 @@ export function printReloadRecoveryHint(recoveredHostError: string | undefined):
|
|
|
84
85
|
|
|
85
86
|
async function defaultTarget(): Promise<{ url: string; cwd: string; token: string | null }> {
|
|
86
87
|
const cwd = findAgentDir(process.cwd()) ?? process.cwd()
|
|
88
|
+
const preflight = await preflightDocker()
|
|
89
|
+
if (!preflight.ok) {
|
|
90
|
+
printDockerGuidance(preflight)
|
|
91
|
+
process.exit(1)
|
|
92
|
+
}
|
|
87
93
|
const precheck = await requireContainerRunning({ cwd })
|
|
88
94
|
if (!precheck.ok) {
|
|
89
95
|
console.error(errorLine(precheck.reason))
|
package/src/cli/restart.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { config, validateConfig } from '@/config'
|
|
|
5
5
|
import { start, stop } from '@/container'
|
|
6
6
|
import { findAgentDir, isInitialized } from '@/init'
|
|
7
7
|
|
|
8
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
8
9
|
import { guardIncompleteInit } from './incomplete-init'
|
|
9
10
|
import { c, errorLine, renderStartSuccess, reportConfigWarnings, spinner } from './ui'
|
|
10
11
|
|
|
@@ -63,6 +64,12 @@ export const restartCommand = defineCommand({
|
|
|
63
64
|
}
|
|
64
65
|
reportConfigWarnings(validated.warnings)
|
|
65
66
|
|
|
67
|
+
const preflight = await preflightDocker()
|
|
68
|
+
if (!preflight.ok) {
|
|
69
|
+
printDockerGuidance(preflight)
|
|
70
|
+
process.exit(1)
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
const stopSpin = spinner()
|
|
67
74
|
stopSpin.start('Stopping container...')
|
|
68
75
|
const stopped = await stop({ cwd })
|
package/src/cli/shell.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineCommand } from 'citty'
|
|
|
2
2
|
|
|
3
3
|
import { shell } from '@/container'
|
|
4
4
|
|
|
5
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
5
6
|
import { requireAgentDir } from './require-agent-dir'
|
|
6
7
|
import { c, errorLine } from './ui'
|
|
7
8
|
|
|
@@ -20,6 +21,12 @@ export const shellCommand = defineCommand({
|
|
|
20
21
|
async run({ args }) {
|
|
21
22
|
const cwd = requireAgentDir()
|
|
22
23
|
|
|
24
|
+
const preflight = await preflightDocker()
|
|
25
|
+
if (!preflight.ok) {
|
|
26
|
+
printDockerGuidance(preflight)
|
|
27
|
+
process.exit(1)
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
console.log(c.cyan(`Attaching ${args.shell} inside the container...`))
|
|
24
31
|
|
|
25
32
|
const result = await shell({ cwd, shell: args.shell })
|
package/src/cli/start.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { config, validateConfig } from '@/config'
|
|
|
5
5
|
import { start } from '@/container'
|
|
6
6
|
import { findAgentDir, isInitialized } from '@/init'
|
|
7
7
|
|
|
8
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
8
9
|
import { guardIncompleteInit } from './incomplete-init'
|
|
9
10
|
import { errorLine, renderStartSuccess, reportConfigWarnings, spinner } from './ui'
|
|
10
11
|
|
|
@@ -63,6 +64,12 @@ export const startCommand = defineCommand({
|
|
|
63
64
|
}
|
|
64
65
|
reportConfigWarnings(validated.warnings)
|
|
65
66
|
|
|
67
|
+
const preflight = await preflightDocker()
|
|
68
|
+
if (!preflight.ok) {
|
|
69
|
+
printDockerGuidance(preflight)
|
|
70
|
+
process.exit(1)
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
const s = spinner()
|
|
67
74
|
s.start('Starting container...')
|
|
68
75
|
const result = await start({
|
package/src/cli/status.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { isDaemonReachable, send } from '@/hostd'
|
|
|
7
7
|
import type { StatusResult } from '@/hostd'
|
|
8
8
|
import { findAgentDir } from '@/init'
|
|
9
9
|
|
|
10
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
11
|
+
|
|
10
12
|
export type HostdStatus =
|
|
11
13
|
| { kind: 'unreachable' }
|
|
12
14
|
| { kind: 'not-registered'; reason: string }
|
|
@@ -25,6 +27,13 @@ export const statusCommand = defineCommand({
|
|
|
25
27
|
},
|
|
26
28
|
async run() {
|
|
27
29
|
const cwd = findAgentDir(process.cwd()) ?? process.cwd()
|
|
30
|
+
|
|
31
|
+
const preflight = await preflightDocker()
|
|
32
|
+
if (!preflight.ok) {
|
|
33
|
+
printDockerGuidance(preflight)
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
const container = await containerStatus({ cwd })
|
|
29
38
|
const hostd = await fetchHostdStatus(container.containerName)
|
|
30
39
|
|
package/src/cli/stop.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineCommand } from 'citty'
|
|
|
2
2
|
|
|
3
3
|
import { stop } from '@/container'
|
|
4
4
|
|
|
5
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
5
6
|
import { requireAgentDir } from './require-agent-dir'
|
|
6
7
|
import { c, spinner } from './ui'
|
|
7
8
|
|
|
@@ -13,6 +14,12 @@ export const stopCommand = defineCommand({
|
|
|
13
14
|
async run() {
|
|
14
15
|
const cwd = requireAgentDir()
|
|
15
16
|
|
|
17
|
+
const preflight = await preflightDocker()
|
|
18
|
+
if (!preflight.ok) {
|
|
19
|
+
printDockerGuidance(preflight)
|
|
20
|
+
process.exit(1)
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
const s = spinner()
|
|
17
24
|
s.start('Stopping container...')
|
|
18
25
|
const result = await stop({ cwd })
|
package/src/cli/tui.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { CLI_VERSION } from '@/init/cli-version'
|
|
|
5
5
|
import { runTuiViewer } from '@/inspect'
|
|
6
6
|
import { formatVersionMismatchWarning } from '@/tui'
|
|
7
7
|
|
|
8
|
+
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
8
9
|
import { runInspectViewer } from './inspect'
|
|
9
10
|
import { requireAgentDir } from './require-agent-dir'
|
|
10
11
|
import { errorLine } from './ui'
|
|
@@ -75,6 +76,11 @@ export const tui = defineCommand({
|
|
|
75
76
|
})
|
|
76
77
|
|
|
77
78
|
async function defaultUrl(cwd: string): Promise<string> {
|
|
79
|
+
const preflight = await preflightDocker()
|
|
80
|
+
if (!preflight.ok) {
|
|
81
|
+
printDockerGuidance(preflight)
|
|
82
|
+
process.exit(1)
|
|
83
|
+
}
|
|
78
84
|
const precheck = await requireContainerRunning({ cwd })
|
|
79
85
|
if (!precheck.ok) throw new Error(precheck.reason)
|
|
80
86
|
const port = await resolveHostPort({ cwd })
|
package/src/config/config.ts
CHANGED
|
@@ -1197,7 +1197,7 @@ export function loadConfigBundleSync(cwd: string): { config: Config; pluginConfi
|
|
|
1197
1197
|
// `changed` is the boolean equivalent of `applied.length > 0` and is preserved
|
|
1198
1198
|
// for back-compat with the many call sites that only care whether ANY rewrite
|
|
1199
1199
|
// happened.
|
|
1200
|
-
export type MigrationStep = { kind: 'drop-github-seeded-event-allowlist' }
|
|
1200
|
+
export type MigrationStep = { kind: 'drop-github-seeded-event-allowlist' } | { kind: 'drop-memory-vector-config' }
|
|
1201
1201
|
|
|
1202
1202
|
export type MigrationResult = { json: unknown; changed: boolean; applied: MigrationStep[] }
|
|
1203
1203
|
|
|
@@ -1207,18 +1207,20 @@ export function migrateLegacyConfigShape(json: unknown): MigrationResult {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
|
|
1209
1209
|
const obj = json as Record<string, unknown>
|
|
1210
|
-
const hasSeededGithubEventAllowlist = isSeededGithubEventAllowlist(obj)
|
|
1211
|
-
if (!hasSeededGithubEventAllowlist) {
|
|
1212
|
-
return { json, changed: false, applied: [] }
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1210
|
const applied: MigrationStep[] = []
|
|
1216
1211
|
const next: Record<string, unknown> = { ...obj }
|
|
1217
|
-
|
|
1212
|
+
|
|
1213
|
+
if (isSeededGithubEventAllowlist(obj)) {
|
|
1218
1214
|
dropSeededGithubEventAllowlist(next)
|
|
1219
1215
|
applied.push({ kind: 'drop-github-seeded-event-allowlist' })
|
|
1220
1216
|
}
|
|
1221
|
-
|
|
1217
|
+
|
|
1218
|
+
if (hasLegacyMemoryVectorConfig(obj)) {
|
|
1219
|
+
dropMemoryVectorConfig(next)
|
|
1220
|
+
applied.push({ kind: 'drop-memory-vector-config' })
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
return { json: applied.length > 0 ? next : json, changed: applied.length > 0, applied }
|
|
1222
1224
|
}
|
|
1223
1225
|
|
|
1224
1226
|
// True when channels.github.eventAllowlist deep-equals an allowlist that
|
|
@@ -1243,6 +1245,23 @@ function dropSeededGithubEventAllowlist(next: Record<string, unknown>): void {
|
|
|
1243
1245
|
next.channels = { ...channels, github: rest }
|
|
1244
1246
|
}
|
|
1245
1247
|
|
|
1248
|
+
function hasLegacyMemoryVectorConfig(obj: Record<string, unknown>): boolean {
|
|
1249
|
+
const memory = obj.memory
|
|
1250
|
+
return isPlainObject(memory) && Object.prototype.hasOwnProperty.call(memory, 'vector')
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function dropMemoryVectorConfig(next: Record<string, unknown>): void {
|
|
1254
|
+
const memory = next.memory
|
|
1255
|
+
if (!isPlainObject(memory)) return
|
|
1256
|
+
const clone = { ...memory }
|
|
1257
|
+
delete clone.vector
|
|
1258
|
+
if (Object.keys(clone).length === 0) {
|
|
1259
|
+
delete next.memory
|
|
1260
|
+
return
|
|
1261
|
+
}
|
|
1262
|
+
next.memory = clone
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1246
1265
|
function arraysEqual(a: readonly unknown[], b: readonly unknown[]): boolean {
|
|
1247
1266
|
if (a.length !== b.length) return false
|
|
1248
1267
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -1267,6 +1286,8 @@ function shortStepLabel(step: MigrationStep): string {
|
|
|
1267
1286
|
switch (step.kind) {
|
|
1268
1287
|
case 'drop-github-seeded-event-allowlist':
|
|
1269
1288
|
return 'drop seeded channels.github.eventAllowlist'
|
|
1289
|
+
case 'drop-memory-vector-config':
|
|
1290
|
+
return 'drop memory.vector config'
|
|
1270
1291
|
}
|
|
1271
1292
|
}
|
|
1272
1293
|
|
|
@@ -1274,6 +1295,8 @@ function describeStep(step: MigrationStep): string {
|
|
|
1274
1295
|
switch (step.kind) {
|
|
1275
1296
|
case 'drop-github-seeded-event-allowlist':
|
|
1276
1297
|
return 'drop seeded channels.github.eventAllowlist so it re-tracks the shipped default'
|
|
1298
|
+
case 'drop-memory-vector-config':
|
|
1299
|
+
return 'drop memory.vector config; vector memory is always on'
|
|
1277
1300
|
}
|
|
1278
1301
|
}
|
|
1279
1302
|
|