typeclaw 0.48.11 → 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.
Files changed (40) hide show
  1. package/package.json +2 -2
  2. package/src/agent/index.ts +11 -1
  3. package/src/bundled-plugins/github-cli-auth/gh-command.ts +7 -1
  4. package/src/bundled-plugins/github-cli-auth/index.ts +1 -1
  5. package/src/bundled-plugins/github-cli-auth/review-checkout.ts +9 -1
  6. package/src/bundled-plugins/memory/dreaming.ts +21 -6
  7. package/src/channels/adapters/kakaotalk-channel-resolver.ts +86 -16
  8. package/src/channels/adapters/kakaotalk.ts +7 -8
  9. package/src/channels/adapters/teams-classify.ts +21 -0
  10. package/src/channels/adapters/teams-edit.ts +2 -1
  11. package/src/channels/adapters/teams-format.ts +16 -0
  12. package/src/channels/adapters/teams.ts +12 -5
  13. package/src/cli/compose.ts +3 -3
  14. package/src/cli/docker-preflight.ts +8 -4
  15. package/src/cli/restart.ts +89 -23
  16. package/src/cli/start.ts +68 -16
  17. package/src/cli/status.ts +38 -6
  18. package/src/cli/stop.ts +5 -2
  19. package/src/compose/stop.ts +5 -4
  20. package/src/container/build-cache.ts +807 -0
  21. package/src/container/compose-project.ts +4 -0
  22. package/src/container/docker-app.ts +74 -0
  23. package/src/container/log-archive.ts +33 -5
  24. package/src/container/memory-limit.ts +80 -0
  25. package/src/container/memory-oversubscription.ts +125 -0
  26. package/src/container/restart.ts +6 -1
  27. package/src/container/shared.ts +43 -16
  28. package/src/container/start.ts +280 -53
  29. package/src/container/stop.ts +19 -13
  30. package/src/container/verify-running.ts +12 -0
  31. package/src/cron/scheduler.ts +12 -4
  32. package/src/doctor/bounded-exec.ts +14 -0
  33. package/src/doctor/checks.ts +40 -15
  34. package/src/doctor/index.ts +14 -2
  35. package/src/doctor/plugin-bridge.ts +15 -3
  36. package/src/hostd/paths.ts +4 -0
  37. package/src/run/index.ts +16 -0
  38. package/src/run/resource-sample.ts +171 -0
  39. package/src/sandbox/index.ts +8 -1
  40. package/src/sandbox/session-tmp.ts +26 -1
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
- s.start('Starting container...')
75
- const result = await resolveController().start({
76
- cwd,
77
- preferredHostPort: Number(args.port),
78
- forceBuild: args.build,
79
- cliEntry: process.argv[1],
80
- })
81
- if (!result.ok) {
82
- s.error(result.reason)
83
- process.exit(1)
84
- }
85
- s.stop(result.alreadyRunning ? 'Already running.' : 'Started.')
86
-
87
- reportConfigWarnings(result.dockerfileWarnings)
88
- console.log(renderStartSuccess(result))
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
- function defaultOnDockerUnavailable(failure: Extract<DockerPreflightResult, { ok: false }>): never {
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.exit(1)
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 result = await resolveController().stop({ cwd })
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
  })
@@ -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
  }