typeclaw 0.48.10 → 0.48.12
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 +2 -2
- package/scripts/apparmor/typeclaw-bwrap +43 -0
- package/scripts/verify-apparmor-signals.sh +161 -0
- package/scripts/verify-mask-fd-sandbox.sh +86 -16
- package/src/agent/index.ts +11 -1
- package/src/agent/live-subagents.ts +98 -0
- package/src/agent/session-origin.ts +5 -1
- package/src/agent/tools/channel-reply.ts +30 -2
- package/src/agent/tools/channel-send.ts +19 -2
- package/src/agent/tools/spawn-subagent.ts +37 -1
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +7 -1
- package/src/bundled-plugins/github-cli-auth/index.ts +2 -1
- package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -1
- package/src/bundled-plugins/memory/dreaming.ts +21 -6
- package/src/channels/adapters/github/inbound.ts +195 -25
- package/src/channels/adapters/github/index.ts +16 -18
- package/src/channels/adapters/github/reconcile-cooldown-store.ts +15 -1
- package/src/channels/adapters/github/recover-failed-deliveries.ts +7 -2
- package/src/channels/adapters/github/review-submitter.ts +28 -0
- package/src/channels/adapters/kakaotalk-channel-resolver.ts +86 -16
- package/src/channels/adapters/kakaotalk.ts +7 -8
- package/src/channels/adapters/teams-classify.ts +21 -0
- package/src/channels/adapters/teams-edit.ts +2 -1
- package/src/channels/adapters/teams-format.ts +16 -0
- package/src/channels/adapters/teams.ts +12 -5
- package/src/channels/github-repo.ts +11 -0
- package/src/channels/github-review-verdict-coordinator.ts +179 -29
- package/src/channels/github-verdict-activity.ts +10 -6
- package/src/channels/manager.ts +9 -0
- package/src/channels/persistence.ts +28 -2
- package/src/channels/router.ts +284 -61
- package/src/channels/schema.ts +18 -0
- package/src/channels/types.ts +1 -0
- package/src/cli/compose.ts +3 -3
- package/src/cli/docker-preflight.ts +8 -4
- package/src/cli/restart.ts +89 -23
- package/src/cli/start.ts +68 -16
- package/src/cli/status.ts +38 -6
- package/src/cli/stop.ts +5 -2
- package/src/compose/stop.ts +5 -4
- package/src/config/config.ts +9 -1
- package/src/container/build-cache.ts +807 -0
- package/src/container/compose-project.ts +4 -0
- package/src/container/docker-app.ts +74 -0
- package/src/container/log-archive.ts +33 -5
- package/src/container/memory-limit.ts +80 -0
- package/src/container/memory-oversubscription.ts +125 -0
- package/src/container/restart.ts +6 -1
- package/src/container/shared.ts +43 -16
- package/src/container/start.ts +313 -77
- package/src/container/stop.ts +19 -13
- package/src/container/verify-running.ts +12 -0
- package/src/cron/scheduler.ts +12 -4
- package/src/doctor/apparmor.ts +101 -0
- package/src/doctor/bounded-exec.ts +14 -0
- package/src/doctor/checks.ts +42 -15
- package/src/doctor/index.ts +14 -2
- package/src/doctor/plugin-bridge.ts +15 -3
- package/src/hostd/paths.ts +4 -0
- package/src/init/dockerfile.ts +7 -6
- package/src/init/windows-dev-link.ts +34 -2
- package/src/run/index.ts +17 -0
- package/src/run/resource-sample.ts +171 -0
- package/src/sandbox/availability.ts +7 -5
- package/src/sandbox/index.ts +8 -1
- package/src/sandbox/session-tmp.ts +26 -1
- package/src/skills/typeclaw-channel-github/SKILL.md +4 -2
- package/typeclaw.schema.json +7 -0
package/src/channels/schema.ts
CHANGED
|
@@ -185,6 +185,7 @@ export const DEFAULT_GITHUB_EVENT_ALLOWLIST = [
|
|
|
185
185
|
'discussion_comment.created',
|
|
186
186
|
'issues.opened',
|
|
187
187
|
'pull_request.opened',
|
|
188
|
+
'pull_request.converted_to_draft',
|
|
188
189
|
'pull_request.ready_for_review',
|
|
189
190
|
'pull_request.review_requested',
|
|
190
191
|
'pull_request.review_request_removed',
|
|
@@ -234,6 +235,22 @@ const GITHUB_EVENT_ALLOWLIST_V3 = [
|
|
|
234
235
|
'discussion.created',
|
|
235
236
|
'pull_request_review.submitted',
|
|
236
237
|
] as const
|
|
238
|
+
// - v4: added synchronize (the default just before converted_to_draft was
|
|
239
|
+
// added). Snapshotted here so configs seeded with the pre-draft-abort
|
|
240
|
+
// default unfreeze and re-track the new default.
|
|
241
|
+
const GITHUB_EVENT_ALLOWLIST_V4 = [
|
|
242
|
+
'issue_comment.created',
|
|
243
|
+
'pull_request_review_comment.created',
|
|
244
|
+
'discussion_comment.created',
|
|
245
|
+
'issues.opened',
|
|
246
|
+
'pull_request.opened',
|
|
247
|
+
'pull_request.ready_for_review',
|
|
248
|
+
'pull_request.review_requested',
|
|
249
|
+
'pull_request.review_request_removed',
|
|
250
|
+
'pull_request.synchronize',
|
|
251
|
+
'discussion.created',
|
|
252
|
+
'pull_request_review.submitted',
|
|
253
|
+
] as const
|
|
237
254
|
|
|
238
255
|
// Every event-allowlist that `channel add` / `init` has ever seeded verbatim
|
|
239
256
|
// into typeclaw.json, oldest first, current default last. The legacy-shape
|
|
@@ -246,6 +263,7 @@ export const SEEDED_GITHUB_EVENT_ALLOWLISTS: readonly (readonly string[])[] = [
|
|
|
246
263
|
GITHUB_EVENT_ALLOWLIST_V1,
|
|
247
264
|
GITHUB_EVENT_ALLOWLIST_V2,
|
|
248
265
|
GITHUB_EVENT_ALLOWLIST_V3,
|
|
266
|
+
GITHUB_EVENT_ALLOWLIST_V4,
|
|
249
267
|
DEFAULT_GITHUB_EVENT_ALLOWLIST,
|
|
250
268
|
]
|
|
251
269
|
|
package/src/channels/types.ts
CHANGED
package/src/cli/compose.ts
CHANGED
|
@@ -366,9 +366,9 @@ function formatStartDone<T extends { alreadyRunning?: boolean; hostPort: number
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
function formatStopDone<T extends { running: boolean }>(result: AgentResult<T>): string {
|
|
369
|
-
if (!result.ok) return `${c.red('✖')} ${c.red('failed:')} ${result.reason}
|
|
370
|
-
|
|
371
|
-
return
|
|
369
|
+
if (!result.ok) return appendWarnings(`${c.red('✖')} ${c.red('failed:')} ${result.reason}`, result.warnings)
|
|
370
|
+
const head = result.data.running ? `${c.green('✔')} stopped` : `${c.dim('○')} ${c.dim('not running')}`
|
|
371
|
+
return appendWarnings(head, result.warnings)
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
function formatRestartDone<T extends { start: { hostPort: number } }>(result: AgentResult<T>): string {
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
detectInstalledDockerApps,
|
|
4
4
|
pickRuntimeToNudge,
|
|
5
5
|
renderDockerUnavailableGuidance,
|
|
6
|
+
type DockerAppProbes,
|
|
6
7
|
type DockerExec,
|
|
7
8
|
} from '@/container'
|
|
8
9
|
|
|
@@ -16,15 +17,18 @@ export type DockerPreflightResult = { ok: true } | { ok: false; summary: string;
|
|
|
16
17
|
// then hands the friendly, runtime-specific guidance back to the caller so each
|
|
17
18
|
// command renders it in its own style (spinner vs console) — no process.exit
|
|
18
19
|
// here, that belongs to the command.
|
|
19
|
-
export async function preflightDocker(exec?: DockerExec): Promise<DockerPreflightResult> {
|
|
20
|
+
export async function preflightDocker(exec?: DockerExec, probes?: DockerAppProbes): Promise<DockerPreflightResult> {
|
|
20
21
|
const availability = exec ? await checkDockerAvailable(exec) : await checkDockerAvailable()
|
|
21
22
|
if (availability.ok) return { ok: true }
|
|
22
23
|
|
|
23
24
|
const detail = availability.reason === 'daemon-down' ? availability.detail : undefined
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
// Probes are injectable so tests do not depend on which Docker runtimes
|
|
26
|
+
// happen to be installed on the machine running them.
|
|
27
|
+
const installed = detectInstalledDockerApps(probes)
|
|
28
|
+
const env = probes?.env ?? process.env
|
|
29
|
+
const nudge = pickRuntimeToNudge(env, detail, installed)
|
|
26
30
|
const { summary, lines } = renderDockerUnavailableGuidance(availability, {
|
|
27
|
-
platform: process.platform,
|
|
31
|
+
platform: probes?.platform ?? process.platform,
|
|
28
32
|
nudge,
|
|
29
33
|
installed,
|
|
30
34
|
})
|
package/src/cli/restart.ts
CHANGED
|
@@ -2,13 +2,60 @@ import { confirm, isCancel } from '@clack/prompts'
|
|
|
2
2
|
import { defineCommand } from 'citty'
|
|
3
3
|
|
|
4
4
|
import { config, validateConfig } from '@/config'
|
|
5
|
-
import { resolveController } from '@/container'
|
|
5
|
+
import { type Controller, resolveController } from '@/container'
|
|
6
6
|
import { findAgentDir, isInitialized } from '@/init'
|
|
7
7
|
|
|
8
8
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
9
9
|
import { guardIncompleteInit } from './incomplete-init'
|
|
10
10
|
import { c, errorLine, renderStartSuccess, reportConfigWarnings, spinner } from './ui'
|
|
11
11
|
|
|
12
|
+
export type RestartCommandEvent =
|
|
13
|
+
| { kind: 'stop-spinner-start'; message: string }
|
|
14
|
+
| { kind: 'stop-spinner-stop'; message: string }
|
|
15
|
+
| { kind: 'stop-spinner-error'; message: string }
|
|
16
|
+
| { kind: 'start-spinner-start'; message: string }
|
|
17
|
+
| { kind: 'start-spinner-stop'; message: string }
|
|
18
|
+
| { kind: 'start-spinner-error'; message: string }
|
|
19
|
+
| { kind: 'warnings'; warnings: string[] }
|
|
20
|
+
| { kind: 'success'; output: string }
|
|
21
|
+
|
|
22
|
+
export type RestartCommandDeps = {
|
|
23
|
+
restart: Controller['restart']
|
|
24
|
+
onEvent: (event: RestartCommandEvent) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function runRestartCommand(
|
|
28
|
+
options: { cwd: string; preferredHostPort: number; forceBuild: boolean; cliEntry?: string },
|
|
29
|
+
deps: RestartCommandDeps,
|
|
30
|
+
): Promise<{ ok: boolean }> {
|
|
31
|
+
deps.onEvent({ kind: 'stop-spinner-start', message: 'Stopping container...' })
|
|
32
|
+
let stopped = false
|
|
33
|
+
const warnings: string[] = []
|
|
34
|
+
const result = await deps.restart({
|
|
35
|
+
...options,
|
|
36
|
+
onWarning: (warning) => warnings.push(warning),
|
|
37
|
+
onStopped: (stopResult) => {
|
|
38
|
+
stopped = true
|
|
39
|
+
deps.onEvent({
|
|
40
|
+
kind: 'stop-spinner-stop',
|
|
41
|
+
message: stopResult.running ? `Stopped ${c.cyan(stopResult.containerName)}.` : 'Already stopped.',
|
|
42
|
+
})
|
|
43
|
+
deps.onEvent({ kind: 'start-spinner-start', message: 'Starting container...' })
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
if (!result.ok) {
|
|
47
|
+
deps.onEvent({ kind: stopped ? 'start-spinner-error' : 'stop-spinner-error', message: result.reason })
|
|
48
|
+
deps.onEvent({ kind: 'warnings', warnings })
|
|
49
|
+
return { ok: false }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
deps.onEvent({ kind: 'start-spinner-stop', message: 'Started.' })
|
|
53
|
+
deps.onEvent({ kind: 'warnings', warnings })
|
|
54
|
+
deps.onEvent({ kind: 'warnings', warnings: result.start.dockerfileWarnings })
|
|
55
|
+
deps.onEvent({ kind: 'success', output: renderStartSuccess(result.start) })
|
|
56
|
+
return { ok: true }
|
|
57
|
+
}
|
|
58
|
+
|
|
12
59
|
export const restartCommand = defineCommand({
|
|
13
60
|
meta: {
|
|
14
61
|
name: 'restart',
|
|
@@ -70,30 +117,49 @@ export const restartCommand = defineCommand({
|
|
|
70
117
|
process.exit(1)
|
|
71
118
|
}
|
|
72
119
|
|
|
73
|
-
const controller = resolveController()
|
|
74
|
-
|
|
75
120
|
const stopSpin = spinner()
|
|
76
|
-
|
|
121
|
+
const controller = resolveController()
|
|
77
122
|
let startSpin: ReturnType<typeof spinner> | undefined
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
stopSpin.stop(stopped.running ? `Stopped ${c.cyan(stopped.containerName)}.` : 'Already stopped.')
|
|
85
|
-
startSpin = spinner()
|
|
86
|
-
startSpin.start('Starting container...')
|
|
123
|
+
const result = await runRestartCommand(
|
|
124
|
+
{
|
|
125
|
+
cwd,
|
|
126
|
+
preferredHostPort: Number(args.port),
|
|
127
|
+
forceBuild: args.build,
|
|
128
|
+
cliEntry: process.argv[1],
|
|
87
129
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
{
|
|
131
|
+
restart: (restartOptions) => controller.restart(restartOptions),
|
|
132
|
+
onEvent: (event) => {
|
|
133
|
+
switch (event.kind) {
|
|
134
|
+
case 'stop-spinner-start':
|
|
135
|
+
stopSpin.start(event.message)
|
|
136
|
+
break
|
|
137
|
+
case 'stop-spinner-stop':
|
|
138
|
+
stopSpin.stop(event.message)
|
|
139
|
+
break
|
|
140
|
+
case 'stop-spinner-error':
|
|
141
|
+
stopSpin.error(event.message)
|
|
142
|
+
break
|
|
143
|
+
case 'start-spinner-start':
|
|
144
|
+
startSpin = spinner()
|
|
145
|
+
startSpin.start(event.message)
|
|
146
|
+
break
|
|
147
|
+
case 'start-spinner-stop':
|
|
148
|
+
startSpin?.stop(event.message)
|
|
149
|
+
break
|
|
150
|
+
case 'start-spinner-error':
|
|
151
|
+
startSpin?.error(event.message)
|
|
152
|
+
break
|
|
153
|
+
case 'warnings':
|
|
154
|
+
reportConfigWarnings(event.warnings)
|
|
155
|
+
break
|
|
156
|
+
case 'success':
|
|
157
|
+
console.log(event.output)
|
|
158
|
+
break
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
)
|
|
163
|
+
if (!result.ok) process.exit(1)
|
|
98
164
|
},
|
|
99
165
|
})
|
package/src/cli/start.ts
CHANGED
|
@@ -2,13 +2,48 @@ import { confirm, isCancel } from '@clack/prompts'
|
|
|
2
2
|
import { defineCommand } from 'citty'
|
|
3
3
|
|
|
4
4
|
import { config, validateConfig } from '@/config'
|
|
5
|
-
import { resolveController } from '@/container'
|
|
5
|
+
import { type Controller, resolveController } from '@/container'
|
|
6
6
|
import { findAgentDir, isInitialized } from '@/init'
|
|
7
7
|
|
|
8
8
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
9
9
|
import { guardIncompleteInit } from './incomplete-init'
|
|
10
10
|
import { errorLine, renderStartSuccess, reportConfigWarnings, spinner } from './ui'
|
|
11
11
|
|
|
12
|
+
export type StartCommandEvent =
|
|
13
|
+
| { kind: 'spinner-start'; message: string }
|
|
14
|
+
| { kind: 'spinner-stop'; message: string }
|
|
15
|
+
| { kind: 'spinner-error'; message: string }
|
|
16
|
+
| { kind: 'warnings'; warnings: string[] }
|
|
17
|
+
| { kind: 'success'; output: string }
|
|
18
|
+
|
|
19
|
+
export type StartCommandDeps = {
|
|
20
|
+
start: Controller['start']
|
|
21
|
+
onEvent: (event: StartCommandEvent) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function runStartCommand(
|
|
25
|
+
options: { cwd: string; preferredHostPort: number; forceBuild: boolean; cliEntry?: string },
|
|
26
|
+
deps: StartCommandDeps,
|
|
27
|
+
): Promise<{ ok: boolean }> {
|
|
28
|
+
deps.onEvent({ kind: 'spinner-start', message: 'Starting container...' })
|
|
29
|
+
const warnings: string[] = []
|
|
30
|
+
const result = await deps.start({
|
|
31
|
+
...options,
|
|
32
|
+
onWarning: (warning) => warnings.push(warning),
|
|
33
|
+
})
|
|
34
|
+
if (!result.ok) {
|
|
35
|
+
deps.onEvent({ kind: 'spinner-error', message: result.reason })
|
|
36
|
+
deps.onEvent({ kind: 'warnings', warnings })
|
|
37
|
+
return { ok: false }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
deps.onEvent({ kind: 'spinner-stop', message: result.alreadyRunning ? 'Already running.' : 'Started.' })
|
|
41
|
+
deps.onEvent({ kind: 'warnings', warnings })
|
|
42
|
+
deps.onEvent({ kind: 'warnings', warnings: result.dockerfileWarnings })
|
|
43
|
+
deps.onEvent({ kind: 'success', output: renderStartSuccess(result) })
|
|
44
|
+
return { ok: true }
|
|
45
|
+
}
|
|
46
|
+
|
|
12
47
|
export const startCommand = defineCommand({
|
|
13
48
|
meta: {
|
|
14
49
|
name: 'start',
|
|
@@ -71,20 +106,37 @@ export const startCommand = defineCommand({
|
|
|
71
106
|
}
|
|
72
107
|
|
|
73
108
|
const s = spinner()
|
|
74
|
-
|
|
75
|
-
const result = await
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
const controller = resolveController()
|
|
110
|
+
const result = await runStartCommand(
|
|
111
|
+
{
|
|
112
|
+
cwd,
|
|
113
|
+
preferredHostPort: Number(args.port),
|
|
114
|
+
forceBuild: args.build,
|
|
115
|
+
cliEntry: process.argv[1],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
start: (startOptions) => controller.start(startOptions),
|
|
119
|
+
onEvent: (event) => {
|
|
120
|
+
switch (event.kind) {
|
|
121
|
+
case 'spinner-start':
|
|
122
|
+
s.start(event.message)
|
|
123
|
+
break
|
|
124
|
+
case 'spinner-stop':
|
|
125
|
+
s.stop(event.message)
|
|
126
|
+
break
|
|
127
|
+
case 'spinner-error':
|
|
128
|
+
s.error(event.message)
|
|
129
|
+
break
|
|
130
|
+
case 'warnings':
|
|
131
|
+
reportConfigWarnings(event.warnings)
|
|
132
|
+
break
|
|
133
|
+
case 'success':
|
|
134
|
+
console.log(event.output)
|
|
135
|
+
break
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
if (!result.ok) process.exit(1)
|
|
89
141
|
},
|
|
90
142
|
})
|
package/src/cli/status.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from 'citty'
|
|
2
2
|
|
|
3
|
-
import { type ContainerStatus, type DockerExec, resolveController } from '@/container'
|
|
3
|
+
import { containerNameFromCwd, type ContainerStatus, type DockerExec, resolveController } from '@/container'
|
|
4
4
|
import { isDaemonReachable, send } from '@/hostd'
|
|
5
5
|
import type { StatusResult } from '@/hostd'
|
|
6
6
|
import { findAgentDir } from '@/init'
|
|
@@ -13,9 +13,16 @@ export type HostdStatus =
|
|
|
13
13
|
| { kind: 'not-registered'; reason: string }
|
|
14
14
|
| { kind: 'registered'; cwd: string; forwardedPorts: number[] }
|
|
15
15
|
|
|
16
|
+
// `docker-unavailable` is not a container state — it is the absence of an
|
|
17
|
+
// answer. It exists so `status` can still report everything that does NOT
|
|
18
|
+
// depend on Docker (agent dir, container name, host daemon, forwarded ports)
|
|
19
|
+
// when the daemon is wedged. A diagnostic command that reports nothing at all
|
|
20
|
+
// because the thing it diagnoses is broken is the least useful moment to lose.
|
|
21
|
+
export type DockerUnavailableStatus = { kind: 'docker-unavailable'; containerName: string; summary: string }
|
|
22
|
+
|
|
16
23
|
export type StatusReport = {
|
|
17
24
|
cwd: string
|
|
18
|
-
container: ContainerStatus
|
|
25
|
+
container: ContainerStatus | DockerUnavailableStatus
|
|
19
26
|
hostd: HostdStatus
|
|
20
27
|
}
|
|
21
28
|
|
|
@@ -46,7 +53,22 @@ export async function runStatus(deps: RunStatusDeps = {}): Promise<void> {
|
|
|
46
53
|
const cwd = deps.cwd ?? findAgentDir(process.cwd()) ?? process.cwd()
|
|
47
54
|
|
|
48
55
|
const preflight = await (deps.preflight ?? preflightDocker)()
|
|
56
|
+
const useColor = Boolean(process.stdout.isTTY) && process.env.NO_COLOR === undefined
|
|
57
|
+
const write = deps.write ?? ((text: string) => process.stdout.write(text))
|
|
58
|
+
|
|
59
|
+
// Docker is unreachable: report what we can still learn without it rather
|
|
60
|
+
// than dying on the guidance alone. hostd is a separate process reached over
|
|
61
|
+
// its own socket, so its registration and forwarded ports stay readable — and
|
|
62
|
+
// during a wedged-daemon incident that is exactly the state worth seeing.
|
|
49
63
|
if (!preflight.ok) {
|
|
64
|
+
const containerName = containerNameFromCwd(cwd)
|
|
65
|
+
const hostd = await (deps.fetchHostd ?? fetchHostdStatus)(containerName)
|
|
66
|
+
const container: DockerUnavailableStatus = {
|
|
67
|
+
kind: 'docker-unavailable',
|
|
68
|
+
containerName,
|
|
69
|
+
summary: preflight.summary,
|
|
70
|
+
}
|
|
71
|
+
write(`${formatStatus({ cwd, container, hostd }, { useColor })}\n`)
|
|
50
72
|
;(deps.onDockerUnavailable ?? defaultOnDockerUnavailable)(preflight)
|
|
51
73
|
return
|
|
52
74
|
}
|
|
@@ -54,14 +76,17 @@ export async function runStatus(deps: RunStatusDeps = {}): Promise<void> {
|
|
|
54
76
|
const container = await resolveController().status({ cwd, exec: deps.exec })
|
|
55
77
|
const hostd = await (deps.fetchHostd ?? fetchHostdStatus)(container.containerName)
|
|
56
78
|
|
|
57
|
-
const useColor = Boolean(process.stdout.isTTY) && process.env.NO_COLOR === undefined
|
|
58
|
-
const write = deps.write ?? ((text: string) => process.stdout.write(text))
|
|
59
79
|
write(`${formatStatus({ cwd, container, hostd }, { useColor })}\n`)
|
|
60
80
|
}
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
// Sets `process.exitCode` instead of calling `process.exit()`: the degraded
|
|
83
|
+
// report is written immediately before this, and an immediate exit can
|
|
84
|
+
// terminate the process before a redirected or piped stdout has drained —
|
|
85
|
+
// truncating the very output this path exists to produce. Letting runStatus
|
|
86
|
+
// return lets the runtime flush and still exit non-zero.
|
|
87
|
+
function defaultOnDockerUnavailable(failure: Extract<DockerPreflightResult, { ok: false }>): void {
|
|
63
88
|
printDockerGuidance(failure)
|
|
64
|
-
process.
|
|
89
|
+
process.exitCode = 1
|
|
65
90
|
}
|
|
66
91
|
|
|
67
92
|
async function fetchHostdStatus(containerName: string): Promise<HostdStatus> {
|
|
@@ -138,6 +163,13 @@ function appendContainerSection(lines: string[], report: StatusReport, p: Palett
|
|
|
138
163
|
const container = report.container
|
|
139
164
|
lines.push(`${p.bold('Container')} ${container.containerName}`)
|
|
140
165
|
lines.push(row('cwd', report.cwd))
|
|
166
|
+
|
|
167
|
+
if (container.kind === 'docker-unavailable') {
|
|
168
|
+
lines.push(row('state', p.red('unknown')))
|
|
169
|
+
lines.push(` ${p.dim(container.summary)}`)
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
141
173
|
lines.push(row('image', container.imageTag))
|
|
142
174
|
|
|
143
175
|
if (container.kind === 'missing') {
|
package/src/cli/stop.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { resolveController } from '@/container'
|
|
|
4
4
|
|
|
5
5
|
import { preflightDocker, printDockerGuidance } from './docker-preflight'
|
|
6
6
|
import { requireAgentDir } from './require-agent-dir'
|
|
7
|
-
import { c, spinner } from './ui'
|
|
7
|
+
import { c, reportConfigWarnings, spinner } from './ui'
|
|
8
8
|
|
|
9
9
|
export const stopCommand = defineCommand({
|
|
10
10
|
meta: {
|
|
@@ -22,10 +22,12 @@ export const stopCommand = defineCommand({
|
|
|
22
22
|
|
|
23
23
|
const s = spinner()
|
|
24
24
|
s.start('Stopping container...')
|
|
25
|
-
const
|
|
25
|
+
const warnings: string[] = []
|
|
26
|
+
const result = await resolveController().stop({ cwd, onWarning: (warning) => warnings.push(warning) })
|
|
26
27
|
|
|
27
28
|
if (!result.ok) {
|
|
28
29
|
s.error(result.reason)
|
|
30
|
+
reportConfigWarnings(warnings)
|
|
29
31
|
process.exit(1)
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -34,5 +36,6 @@ export const stopCommand = defineCommand({
|
|
|
34
36
|
} else {
|
|
35
37
|
s.stop(c.dim(`Container ${result.containerName} is not running.`))
|
|
36
38
|
}
|
|
39
|
+
reportConfigWarnings(warnings)
|
|
37
40
|
},
|
|
38
41
|
})
|
package/src/compose/stop.ts
CHANGED
|
@@ -45,11 +45,12 @@ export async function composeStop(
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async function runOne(name: string, cwd: string, stop: Controller['stop']): Promise<AgentResult<StopSuccess>> {
|
|
48
|
+
const warnings: string[] = []
|
|
48
49
|
try {
|
|
49
|
-
const data = await stop({ cwd })
|
|
50
|
-
if (!data.ok) return { name, ok: false, reason: data.reason }
|
|
51
|
-
return { name, ok: true, data }
|
|
50
|
+
const data = await stop({ cwd, onWarning: (warning) => warnings.push(warning) })
|
|
51
|
+
if (!data.ok) return { name, ok: false, reason: data.reason, warnings }
|
|
52
|
+
return { name, ok: true, data, warnings }
|
|
52
53
|
} catch (error) {
|
|
53
|
-
return { name, ok: false, reason: error instanceof Error ? error.message : String(error) }
|
|
54
|
+
return { name, ok: false, reason: error instanceof Error ? error.message : String(error), warnings }
|
|
54
55
|
}
|
|
55
56
|
}
|
package/src/config/config.ts
CHANGED
|
@@ -480,13 +480,21 @@ export const symlinkSchema = z.object({
|
|
|
480
480
|
|
|
481
481
|
export type SandboxSymlink = z.infer<typeof symlinkSchema>
|
|
482
482
|
|
|
483
|
+
// Docker treats the profile as one argument, but keeping the value to the
|
|
484
|
+
// kernel profile-name alphabet prevents whitespace or option-like text from
|
|
485
|
+
// turning a hand-edited config into ambiguous docker argv.
|
|
486
|
+
const apparmorProfileSchema = z
|
|
487
|
+
.string()
|
|
488
|
+
.regex(/^[A-Za-z0-9_.-]+$/, 'AppArmor profile must be non-empty and contain only letters, digits, _, ., or -')
|
|
489
|
+
|
|
483
490
|
export const sandboxSchema = z
|
|
484
491
|
.object({
|
|
492
|
+
apparmorProfile: apparmorProfileSchema.default('unconfined'),
|
|
485
493
|
realProc: z.boolean().default(false),
|
|
486
494
|
writablePaths: z.array(relativeAgentPathSchema).default([]),
|
|
487
495
|
symlinks: z.array(symlinkSchema).default([]),
|
|
488
496
|
})
|
|
489
|
-
.default({ realProc: false, writablePaths: [], symlinks: [] })
|
|
497
|
+
.default({ apparmorProfile: 'unconfined', realProc: false, writablePaths: [], symlinks: [] })
|
|
490
498
|
|
|
491
499
|
export type SandboxConfig = z.infer<typeof sandboxSchema>
|
|
492
500
|
|