@cmodjs/core 5.5.4 → 5.7.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/docs/commands.md +7 -5
- package/docs/dependencies.md +2 -2
- package/docs/mod.md +1 -1
- package/docs/testing.md +7 -0
- package/docs/ui.md +7 -3
- package/package.json +2 -2
- package/records.d.ts +3 -1
- package/records.d.ts.map +1 -1
- package/records.js +7 -1
- package/runtime/before.d.ts +3 -0
- package/runtime/before.d.ts.map +1 -1
- package/runtime/before.js +66 -31
- package/runtime/conversations.d.ts.map +1 -1
- package/runtime/conversations.js +29 -9
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +23 -22
- package/runtime/programs.d.ts +1 -0
- package/runtime/programs.d.ts.map +1 -1
- package/runtime/programs.js +8 -1
- package/runtime/router.d.ts +4 -2
- package/runtime/router.d.ts.map +1 -1
- package/runtime/router.js +10 -8
- package/runtime/toaster.d.ts.map +1 -1
- package/runtime/toaster.js +15 -7
- package/runtime/ui.d.ts +3 -0
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +12 -1
- package/src/records.ts +9 -1
- package/src/runtime/before.ts +71 -34
- package/src/runtime/conversations.ts +26 -8
- package/src/runtime/lifecycle.ts +31 -35
- package/src/runtime/programs.ts +12 -1
- package/src/runtime/router.ts +11 -9
- package/src/runtime/toaster.ts +15 -7
- package/src/runtime/ui.ts +11 -1
- package/src/testing/fake-elements.ts +22 -3
- package/src/testing.ts +67 -8
- package/src/ui/elements.ts +11 -0
- package/src/ui/panes.ts +2 -0
- package/testing/fake-elements.d.ts +1 -0
- package/testing/fake-elements.d.ts.map +1 -1
- package/testing/fake-elements.js +22 -3
- package/testing.d.ts +1 -0
- package/testing.d.ts.map +1 -1
- package/testing.js +76 -8
- package/ui/elements.d.ts +1 -0
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +12 -0
- package/ui/panes.d.ts +2 -0
- package/ui/panes.d.ts.map +1 -1
- package/vendor-markdown.js +4 -8698
- package/vendor.js +7 -3384
package/src/runtime/before.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { Skill } from '../session/context/turn/message/skill.js'
|
|
|
13
13
|
import { ToolCall } from '../session/context/turn/message/tool-call.js'
|
|
14
14
|
import { ToolResult } from '../session/context/turn/message/tool-result.js'
|
|
15
15
|
import { TurnEnd } from '../session/context/turn/turn.js'
|
|
16
|
-
import { ownerOfSpawn, type ContextData, type ConversationState, type RunningTask, type SessionChange, type
|
|
16
|
+
import { ownerOfSpawn, type ContextData, type ConversationState, type RunningTask, type SessionChange, type TurnData } from '../session/conversation.js'
|
|
17
17
|
import { Task, TaskStart } from '../session/goal/task.js'
|
|
18
18
|
import { sessionEvents, type BeforeEvent, type SessionEvent } from '../session/session.js'
|
|
19
19
|
import type { Claude } from './claude.js'
|
|
@@ -41,7 +41,12 @@ export type Answers = {
|
|
|
41
41
|
readonly summary: string
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export type BeforeHooks = {
|
|
44
|
+
export type BeforeHooks = {
|
|
45
|
+
readonly place: () => Promise<Place>
|
|
46
|
+
readonly wants: (event: BeforeEvent) => Promise<boolean>
|
|
47
|
+
readonly fold: (cancel: AbortSignal) => Decide
|
|
48
|
+
readonly failedBefore: (event: BeforeEvent, change: (where: Place) => SessionChange | undefined, error: Error) => { readonly refuse: string } | undefined
|
|
49
|
+
}
|
|
45
50
|
|
|
46
51
|
const appended: readonly BeforeEvent[] = [Note, Reply, Notice]
|
|
47
52
|
|
|
@@ -63,7 +68,7 @@ export function relayOf(e: Frozen<Args<'session.receive'>>): string | undefined
|
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
export function installBefore({ claude, router, hooks }: { readonly claude: Claude; readonly router: Router; readonly hooks: BeforeHooks }): Subscription {
|
|
66
|
-
const { place, wants, fold } = hooks
|
|
71
|
+
const { place, wants, fold, failedBefore } = hooks
|
|
67
72
|
const now = () => new Date().toISOString()
|
|
68
73
|
const asked = async (event: BeforeEvent, change: SessionChange, decide: Decide) => (await decide(event, change)) ?? {}
|
|
69
74
|
const message = (where: Place, unplaced: Unplaced, task: string | undefined, isInTurn = true): SessionChange => {
|
|
@@ -72,6 +77,22 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
72
77
|
const call = unplaced.type === ToolResult ? where.openCalls?.[unplaced.callId] : undefined
|
|
73
78
|
return { type: Message, message: { ...unplaced, ...call, session: where.session, context, ...(turn === undefined ? {} : { turn: turn.prompt.id }), ...(task === undefined ? {} : { task }) } as Message }
|
|
74
79
|
}
|
|
80
|
+
const submitted = (e: Frozen<Args<'prompt.submit'>>) => (where: Place) => message(where, { id: '', at: now(), type: Prompt, text: e.text, from: senderOf(e.origin, false) }, undefined, false)
|
|
81
|
+
const received = (e: Frozen<Args<'session.receive'>>) => (where: Place) => message(where, { id: '', at: now(), type: Prompt, text: e.text, from: { type: 'session' } }, e.agentId, false)
|
|
82
|
+
const refusedOnFailure = (event: BeforeEvent, change: (where: Place) => SessionChange | undefined, error: Error, next: { readonly called: boolean }) => (next.called ? undefined : failedBefore(event, change, error)?.refuse)
|
|
83
|
+
const toolCalled = (e: Frozen<Args<'tool.call'>>, cwd: string) => (where: Place) => message(where, { id: e.tool_use_id, at: now(), type: ToolCall, callId: e.tool_use_id, name: e.tool, input: toolInputOf(e), cwd, files: noFiles }, e.agentId)
|
|
84
|
+
const cwdOf = async (agentId: string | undefined) => (agentId === undefined ? undefined : agentFolders.get(agentId)) ?? (await claude.session.cwd())
|
|
85
|
+
const startedTask = (e: Frozen<Args<'agent.spawn'>>, where: Place): RunningTask => ({ id: '', title: e.description, ...ownerOfSpawn(e.subagentType, where.session), model: e.model ?? e.parentModel, openedBy: e.tool_use_id, openedAt: now(), ...(e.parentAgentId === undefined ? {} : { parent: e.parentAgentId }), context: where.context })
|
|
86
|
+
const attachmentOf = (e: Frozen<Args<'prompt.attachment'>>): { readonly event: BeforeEvent; readonly found: Unplaced } | undefined => {
|
|
87
|
+
if (e.type === 'nested_memory') return { event: InstructionFile, found: { id: '', at: now(), type: InstructionFile, path: instructionPathOf(e.text), text: e.text, isRule: isRulePath(instructionPathOf(e.text)) } }
|
|
88
|
+
const attachmentType = attachmentTypeOf(e.type)
|
|
89
|
+
return attachmentType === undefined ? undefined : { event: AttachedFile, found: { id: '', at: now(), type: AttachedFile, path: attachedPathOf(e.text), attachmentType, text: e.text } }
|
|
90
|
+
}
|
|
91
|
+
const contextClosed = (e: Frozen<Args<'session.compact'>>) => (where: Place): SessionChange | undefined => {
|
|
92
|
+
const task = e.agentId === undefined ? undefined : where.tasks[e.agentId]
|
|
93
|
+
return e.agentId !== undefined && task === undefined ? undefined : { type: ContextEnd, context: closingContext(where, task, now()) }
|
|
94
|
+
}
|
|
95
|
+
const turnEnded = (turn: TurnData | undefined): SessionChange | undefined => (turn === undefined ? undefined : { type: TurnEnd, turn: { ...turn, closedAt: now() } })
|
|
75
96
|
const titles = new Map<string, string>()
|
|
76
97
|
const spawned = new Map<string, { readonly prompt: string; readonly agentType: string }>()
|
|
77
98
|
const startedBy = new Map<string, string>()
|
|
@@ -82,12 +103,12 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
82
103
|
return waiting.length === 1 ? waiting[0]?.[0] : undefined
|
|
83
104
|
}
|
|
84
105
|
const agentFolders = new Map<string, string>()
|
|
85
|
-
const askedAtStop = (
|
|
106
|
+
const askedAtStop = (change: SessionChange, signal: AbortSignal) =>
|
|
86
107
|
new Promise<Partial<Answers>>((resolve, reject) => {
|
|
87
108
|
if (signal.aborted) return resolve({})
|
|
88
109
|
const cancelled = () => resolve({})
|
|
89
110
|
signal.addEventListener('abort', cancelled, { once: true })
|
|
90
|
-
asked(TurnEnd,
|
|
111
|
+
asked(TurnEnd, change, fold(signal))
|
|
91
112
|
.then(resolve, reject)
|
|
92
113
|
.finally(() => signal.removeEventListener('abort', cancelled))
|
|
93
114
|
})
|
|
@@ -112,8 +133,7 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
112
133
|
const added: Subscription[] = [
|
|
113
134
|
router.add('prompt.submit', async (e, next) => {
|
|
114
135
|
if (!(await wants(Prompt))) return next(e)
|
|
115
|
-
const
|
|
116
|
-
const answer = await asked(Prompt, message(where, { id: '', at: now(), type: Prompt, text: e.text, from: senderOf(e.origin, false) }, undefined, false), fold(next.signal))
|
|
136
|
+
const answer = await asked(Prompt, submitted(e)(await place()), fold(next.signal))
|
|
117
137
|
if (answer.refuse !== undefined) return { drop: answer.refuse }
|
|
118
138
|
const text = answer.text ?? e.text
|
|
119
139
|
if (answer.title !== undefined) titles.set(text, answer.title)
|
|
@@ -125,6 +145,9 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
125
145
|
if (!('drop' in ran) && typeof ran.text === 'string') titles.set(ran.text, passed)
|
|
126
146
|
}
|
|
127
147
|
return ran
|
|
148
|
+
}, (e, error, next) => {
|
|
149
|
+
const refusal = refusedOnFailure(Prompt, submitted(e), error, next)
|
|
150
|
+
return refusal === undefined ? undefined : { drop: refusal }
|
|
128
151
|
}),
|
|
129
152
|
router.add('classic.UserPromptSubmit', async (e, next) => {
|
|
130
153
|
const named = titles.get(e.prompt)
|
|
@@ -136,10 +159,12 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
136
159
|
router.add('classic.PostToolUseFailure', toolResultHook(true) as never),
|
|
137
160
|
router.add('session.receive', async (e, next) => {
|
|
138
161
|
if (!(await wants(Prompt)) || relayOf(e) !== undefined) return next(e)
|
|
139
|
-
const
|
|
140
|
-
const answer = await asked(Prompt, message(where, { id: '', at: now(), type: Prompt, text: e.text, from: { type: 'session' } }, e.agentId, false), fold(next.signal))
|
|
162
|
+
const answer = await asked(Prompt, received(e)(await place()), fold(next.signal))
|
|
141
163
|
if (answer.refuse !== undefined) return { consumed: answer.refuse }
|
|
142
164
|
return next(answer.text === undefined ? e : { ...e, text: answer.text })
|
|
165
|
+
}, (e, error, next) => {
|
|
166
|
+
const refusal = relayOf(e) === undefined ? refusedOnFailure(Prompt, received(e), error, next) : undefined
|
|
167
|
+
return refusal === undefined ? undefined : { consumed: refusal }
|
|
143
168
|
}),
|
|
144
169
|
router.add('skill.prompt', async (e, next) => {
|
|
145
170
|
if (!(await wants(Skill))) return next(e)
|
|
@@ -148,17 +173,15 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
148
173
|
return answer.text === undefined ? next(e) : { text: answer.text }
|
|
149
174
|
}),
|
|
150
175
|
router.add('prompt.attachment', async (e, next) => {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const where = await place()
|
|
155
|
-
const found: Unplaced =
|
|
156
|
-
attachmentType === undefined
|
|
157
|
-
? { id: '', at: now(), type: InstructionFile, path: instructionPathOf(e.text), text: e.text, isRule: isRulePath(instructionPathOf(e.text)) }
|
|
158
|
-
: { id: '', at: now(), type: AttachedFile, path: attachedPathOf(e.text), attachmentType, text: e.text }
|
|
159
|
-
const answer = await asked(event, message(where, found, e.agentId), fold(next.signal))
|
|
176
|
+
const attachment = attachmentOf(e)
|
|
177
|
+
if (attachment === undefined || !(await wants(attachment.event))) return next(e)
|
|
178
|
+
const answer = await asked(attachment.event, message(await place(), attachment.found, e.agentId), fold(next.signal))
|
|
160
179
|
if (answer.refuse !== undefined) return { text: null }
|
|
161
180
|
return answer.text === undefined ? next(e) : { text: answer.text }
|
|
181
|
+
}, (e, error, next) => {
|
|
182
|
+
const attachment = attachmentOf(e)
|
|
183
|
+
const refusal = attachment === undefined ? undefined : refusedOnFailure(attachment.event, (where) => message(where, attachment.found, e.agentId), error, next)
|
|
184
|
+
return refusal === undefined ? undefined : { text: null }
|
|
162
185
|
}),
|
|
163
186
|
router.add('session.append', async (e, next) => {
|
|
164
187
|
const wanted = new Set((await Promise.all(appended.map(async (event) => ((await wants(event)) ? [event] : [])))).flat())
|
|
@@ -179,14 +202,16 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
179
202
|
router.add('tool.call', async (e, next) => {
|
|
180
203
|
if (!(await wants(ToolCall))) return next(e)
|
|
181
204
|
const where = await place()
|
|
182
|
-
const
|
|
183
|
-
const cwd = (e.agentId === undefined ? undefined : agentFolders.get(e.agentId)) ?? (await claude.session.cwd())
|
|
184
|
-
const answer = await asked(ToolCall, message(where, { id: e.tool_use_id, at: now(), type: ToolCall, callId: e.tool_use_id, name: e.tool, input, cwd, files: noFiles }, e.agentId), fold(next.signal))
|
|
205
|
+
const answer = await asked(ToolCall, toolCalled(e, await cwdOf(e.agentId))(where), fold(next.signal))
|
|
185
206
|
if (answer.refuse !== undefined) return { deny: answer.refuse }
|
|
186
207
|
if (answer.result !== undefined) return withContext({ result: answer.result }, answer.note)
|
|
187
208
|
if (answer.input === undefined) return withContext(await next(e), answer.note)
|
|
209
|
+
const input = toolInputOf(e)
|
|
188
210
|
const reserved = Object.fromEntries(Object.entries(e).filter(([key]) => !(key in input)))
|
|
189
211
|
return withContext(await next({ ...reserved, ...answer.input } as Frozen<Args<'tool.call'>>), answer.note)
|
|
212
|
+
}, async (e, error, next) => {
|
|
213
|
+
const refusal = refusedOnFailure(ToolCall, toolCalled(e, await cwdOf(e.agentId)), error, next)
|
|
214
|
+
return refusal === undefined ? undefined : { deny: refusal }
|
|
190
215
|
}),
|
|
191
216
|
router.add('agent.spawn', async (e, next) => {
|
|
192
217
|
spawned.set(e.tool_use_id, { prompt: e.prompt, agentType: e.subagentType })
|
|
@@ -199,9 +224,8 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
199
224
|
return started
|
|
200
225
|
}
|
|
201
226
|
if (!(await wants(TaskStart))) return start(e)
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
const answer = await asked(TaskStart, { type: TaskStart, task: { ...task, context: where.context } }, fold(next.signal))
|
|
227
|
+
const task = startedTask(e, await place())
|
|
228
|
+
const answer = await asked(TaskStart, { type: TaskStart, task }, fold(next.signal))
|
|
205
229
|
if (answer.refuse !== undefined) {
|
|
206
230
|
spawned.delete(e.tool_use_id)
|
|
207
231
|
return { deny: answer.refuse }
|
|
@@ -221,6 +245,11 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
221
245
|
}
|
|
222
246
|
spawned.set(e.tool_use_id, { prompt: answered.prompt, agentType: answered.subagentType })
|
|
223
247
|
return start(answered)
|
|
248
|
+
}, (e, error, next) => {
|
|
249
|
+
const refusal = refusedOnFailure(TaskStart, (where) => ({ type: TaskStart, task: startedTask(e, where) }), error, next)
|
|
250
|
+
if (refusal === undefined) return undefined
|
|
251
|
+
spawned.delete(e.tool_use_id)
|
|
252
|
+
return { deny: refusal }
|
|
224
253
|
}),
|
|
225
254
|
router.add('classic.SubagentStart', async (e, next) => {
|
|
226
255
|
const where = await place()
|
|
@@ -241,26 +270,34 @@ export function installBefore({ claude, router, hooks }: { readonly claude: Clau
|
|
|
241
270
|
return answer
|
|
242
271
|
}
|
|
243
272
|
if (next.signal.aborted || !(await wants(TurnEnd))) return stopped(await next(e))
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
const answer = await askedAtStop(
|
|
273
|
+
const change = turnEnded((await place()).taskTurns[e.agent_id])
|
|
274
|
+
if (change === undefined) return stopped(await next(e))
|
|
275
|
+
const answer = await askedAtStop(change, next.signal)
|
|
247
276
|
return stopped(answeredStop(await next(e), answer, next.signal))
|
|
277
|
+
}, async (e, error, next) => {
|
|
278
|
+
const refusal = refusedOnFailure(TurnEnd, (where) => turnEnded(where.taskTurns[e.agent_id]), error, next)
|
|
279
|
+
return refusal === undefined ? undefined : { ...(await next(e)), block: refusal }
|
|
248
280
|
}),
|
|
249
281
|
router.add('classic.Stop', async (e, next) => {
|
|
250
282
|
if (next.signal.aborted || !(await wants(TurnEnd))) return next(e)
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
const answer = await askedAtStop(
|
|
283
|
+
const change = turnEnded((await place()).turn)
|
|
284
|
+
if (change === undefined) return next(e)
|
|
285
|
+
const answer = await askedAtStop(change, next.signal)
|
|
254
286
|
return answeredStop(await next(e), answer, next.signal)
|
|
287
|
+
}, async (e, error, next) => {
|
|
288
|
+
const refusal = refusedOnFailure(TurnEnd, (where) => turnEnded(where.turn), error, next)
|
|
289
|
+
return refusal === undefined ? undefined : { ...(await next(e)), block: refusal }
|
|
255
290
|
}),
|
|
256
291
|
router.add('session.compact', async (e, next) => {
|
|
257
292
|
if (!(await wants(ContextEnd)) || e.trigger === 'precompute') return next(e)
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const answer = await asked(ContextEnd, { type: ContextEnd, context: closingContext(where, task, now()) }, fold(next.signal))
|
|
293
|
+
const change = contextClosed(e)(await place())
|
|
294
|
+
if (change === undefined) return next(e)
|
|
295
|
+
const answer = await asked(ContextEnd, change, fold(next.signal))
|
|
262
296
|
if (answer.refuse !== undefined) return { skip: answer.refuse }
|
|
263
297
|
return answer.summary === undefined ? next(e) : { messages: [{ role: 'user', text: answer.summary, toolUses: [] }] }
|
|
298
|
+
}, (e, error, next) => {
|
|
299
|
+
const refusal = e.trigger === 'precompute' ? undefined : refusedOnFailure(ContextEnd, contextClosed(e), error, next)
|
|
300
|
+
return refusal === undefined ? undefined : { skip: refusal }
|
|
264
301
|
}),
|
|
265
302
|
]
|
|
266
303
|
return { remove: () => added.forEach((each) => each.remove()) }
|
|
@@ -15,7 +15,7 @@ import { formatExit, messageOf } from '../utils/text.js'
|
|
|
15
15
|
import { beforeAnswerKeys, foldBefore, installBefore, relayOf, type Decide, type Place } from './before.js'
|
|
16
16
|
import type { Claude } from './claude.js'
|
|
17
17
|
import { cmodPluginName, isNotInstalled } from './dependencies.js'
|
|
18
|
-
import { readLines, runCmod, spawnCmod } from './programs.js'
|
|
18
|
+
import { newestCmodVersion, readLines, runCmod, spawnCmod } from './programs.js'
|
|
19
19
|
import type { RoutedHook, Router } from './router.js'
|
|
20
20
|
import { PassedTimeout } from './deadline.js'
|
|
21
21
|
import { conversationMethods, everySession, isAct, isHeardBy, isInScope, pickedColor, resultOf, spawnTask, usageOf, type Act, type Listened, type SessionColor } from './sessions.js'
|
|
@@ -98,6 +98,7 @@ export function serveConversations({
|
|
|
98
98
|
const ownWatches = new Map<string, Watch>()
|
|
99
99
|
let watchers: readonly Watcher[] = []
|
|
100
100
|
let watching: Promise<void> = Promise.resolve()
|
|
101
|
+
let hasReadWatchers = false
|
|
101
102
|
let published = new Set<string>()
|
|
102
103
|
let publishing: Promise<unknown> = Promise.resolve()
|
|
103
104
|
let session = ''
|
|
@@ -190,22 +191,27 @@ export function serveConversations({
|
|
|
190
191
|
follower?.stop()
|
|
191
192
|
follower = undefined
|
|
192
193
|
if (args.length === 0) return
|
|
194
|
+
const version = newestCmodVersion(claude)
|
|
193
195
|
const stream = spawnCmod(claude, ['history', 'follow', ...args, '--json', '--project', project()], session)
|
|
194
196
|
const started = { sessions: wanted, stop: () => void stream.return(undefined as never) }
|
|
195
197
|
follower = started
|
|
196
|
-
|
|
198
|
+
const followed = readLines(stream, (line) => {
|
|
197
199
|
if (line.trim() === '') return
|
|
198
200
|
const parsed = JSON.parse(line) as { readonly session: string; readonly isInProject: boolean; readonly change: SessionChange }
|
|
199
201
|
dispatch(parsed.session, [parsed.change], parsed.isInProject)
|
|
200
202
|
})
|
|
201
|
-
|
|
203
|
+
void Promise.all([version, followed])
|
|
204
|
+
.then(([, { code, lastError }]) => {
|
|
202
205
|
if (follower === started) throw new Error(`cmod history follow ${formatExit(code, lastError)}`)
|
|
203
206
|
})
|
|
204
|
-
.catch((error: unknown) => {
|
|
207
|
+
.catch(async (error: unknown) => {
|
|
205
208
|
if (follower !== started) return
|
|
206
209
|
follower = undefined
|
|
207
|
-
|
|
210
|
+
started.stop()
|
|
211
|
+
if ((await newestCmodVersion(claude)) === (await version)) throw error
|
|
212
|
+
follow()
|
|
208
213
|
})
|
|
214
|
+
.catch((error: unknown) => report('follow', 'Stopped hearing the other sessions', error))
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
const follow = () => void restartFollower().catch((error: unknown) => report('follow', 'Stopped hearing the other sessions', error))
|
|
@@ -391,8 +397,8 @@ export function serveConversations({
|
|
|
391
397
|
return false
|
|
392
398
|
}
|
|
393
399
|
|
|
394
|
-
const refuses = (watcher: Watcher, event: BeforeEvent, change: SessionChange) =>
|
|
395
|
-
beforeAnswerKeys[event].includes('refuse') && (watcher.refusing ?? []).some(({ event: heard, matcher, scope }) => isInScope(scope ?? {}, session, change, isUnderHere) && isHeardBy(heard, matcher === undefined ? undefined : receivedMatcher(matcher), change))
|
|
400
|
+
const refuses = (watcher: Watcher, event: BeforeEvent, change: SessionChange | undefined) =>
|
|
401
|
+
beforeAnswerKeys[event].includes('refuse') && (watcher.refusing ?? []).some(({ event: heard, matcher, scope }) => (change === undefined ? heard === event : isInScope(scope ?? {}, session, change, isUnderHere) && isHeardBy(heard, matcher === undefined ? undefined : receivedMatcher(matcher), change)))
|
|
396
402
|
|
|
397
403
|
const askAway = async (watcher: Watcher, event: BeforeEvent, change: SessionChange, endsAt: number) => {
|
|
398
404
|
try {
|
|
@@ -416,10 +422,17 @@ export function serveConversations({
|
|
|
416
422
|
}
|
|
417
423
|
|
|
418
424
|
const wants = async (event: BeforeEvent) => {
|
|
419
|
-
await
|
|
425
|
+
await watching
|
|
420
426
|
return deciders(event).length > 0
|
|
421
427
|
}
|
|
422
428
|
|
|
429
|
+
const failedBefore = (event: BeforeEvent, change: (where: Place) => SessionChange | undefined, error: Error) => {
|
|
430
|
+
if (!hasReadWatchers) return { refuse: `${cmodPluginName}: ${error.message}` }
|
|
431
|
+
const changed = change(place())
|
|
432
|
+
const refusing = deciders(event).find((watcher) => refuses(watcher, event, changed))
|
|
433
|
+
return refusing === undefined ? undefined : { refuse: `${refusing.mod}: ${error.message}` }
|
|
434
|
+
}
|
|
435
|
+
|
|
423
436
|
const decide = (cancel?: AbortSignal): Decide => {
|
|
424
437
|
let endsAt: Promise<number> | undefined
|
|
425
438
|
return (event, change) =>
|
|
@@ -458,6 +471,7 @@ export function serveConversations({
|
|
|
458
471
|
},
|
|
459
472
|
wants,
|
|
460
473
|
fold: decide,
|
|
474
|
+
failedBefore,
|
|
461
475
|
},
|
|
462
476
|
})
|
|
463
477
|
|
|
@@ -487,6 +501,10 @@ export function serveConversations({
|
|
|
487
501
|
.then(follow)
|
|
488
502
|
starting = Promise.all([starting, restored]).then(() => undefined)
|
|
489
503
|
reloadWatchers()
|
|
504
|
+
hasReadWatchers = false
|
|
505
|
+
void watching.then(() => {
|
|
506
|
+
if (session === id) hasReadWatchers = true
|
|
507
|
+
})
|
|
490
508
|
if (subscribed.size > 0) void Promise.all([previous === '' ? undefined : clearListeners(previous), saveListeners()]).catch((error: unknown) => report('follow', 'Kept telling the mods about the session from before', error))
|
|
491
509
|
if (ownWatches.size === 0) return
|
|
492
510
|
void Promise.all([previous === '' ? undefined : clearWatches(previous), publishWatches()]).catch((error: unknown) => report('before', 'Kept its before listeners on the session from before', error))
|
package/src/runtime/lifecycle.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Step } from '../installer.js'
|
|
|
3
3
|
|
|
4
4
|
import type { Imports, Mod, ModDefinition, Reservation, SettingsFile, SettingsFileChange, SettingsFileChangeListener, Subscription, Timer as ModTimer } from '../mod.js'
|
|
5
5
|
import type { Options, OptionValues } from '../options.js'
|
|
6
|
-
import { dataFolder, finishStepsMethod, isAtLeast, isProgramNewer, oldestCmodVersion, pendingStepsMethod, parseEvent, programPath,
|
|
6
|
+
import { dataFolder, finishStepsMethod, isAtLeast, isProgramNewer, oldestCmodVersion, pendingStepsMethod, parseEvent, programPath, readRecord, readSteps, recordPath, scriptsSha256, storeFolder, type ReadFile, type RunnerEvent, type Steps } from '../records.js'
|
|
7
7
|
import { homePrefix, ifMissing, relativePath } from '../utils/paths.js'
|
|
8
8
|
import { firstLine, formatExit, messageOf } from '../utils/text.js'
|
|
9
9
|
import type { Claude } from './claude.js'
|
|
@@ -16,7 +16,7 @@ import type { Device } from '../session/context/turn/device.js'
|
|
|
16
16
|
import { keepEngine } from './engine.js'
|
|
17
17
|
import { classicFailure, classicHook, userSkillHook, type Hook, type HookFields, type HookListener, type RoutedEvent } from './hooks.js'
|
|
18
18
|
import type { PermissionRoutes } from './permission-check.js'
|
|
19
|
-
import { cmodError, locatingPrograms, readLines, spawnCmod, type Programs } from './programs.js'
|
|
19
|
+
import { cmodError, locatingPrograms, newestCmodVersion, readLines, spawnCmod, type Programs } from './programs.js'
|
|
20
20
|
import { createModFiles, resolvedPath, type Places } from './metadata.js'
|
|
21
21
|
import { fitsOption } from '../options.js'
|
|
22
22
|
import { createInstaller } from './installer.js'
|
|
@@ -128,7 +128,7 @@ export async function readPlugin(claude: Claude): Promise<Plugin> {
|
|
|
128
128
|
const store = storeFolder({ HOME: await claude.env.home(), XDG_DATA_HOME: await claude.env.dataHome() })
|
|
129
129
|
const steps = readSteps(await readJson(read, `${root}/package.json`)) ?? {}
|
|
130
130
|
if (name === cmodPluginName) {
|
|
131
|
-
const installed = await
|
|
131
|
+
const installed = await newestCmodVersion(claude)
|
|
132
132
|
return { name, root, version, store, steps, isInstalled: version !== undefined && installed !== undefined && isAtLeast(installed, version), shouldRecord: false }
|
|
133
133
|
}
|
|
134
134
|
const plugin = { name, root, version, store, steps }
|
|
@@ -166,17 +166,6 @@ async function readJson(read: ReadFile, path: string): Promise<unknown> {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
async function cmodVersion(claude: Claude): Promise<string | undefined> {
|
|
170
|
-
const store = storeFolder({ HOME: await claude.env.home(), XDG_DATA_HOME: await claude.env.dataHome() })
|
|
171
|
-
return readCmodVersion(
|
|
172
|
-
{
|
|
173
|
-
list: async (folder) => (await claude.fs.list(folder).catch(ifMissing([]))).map((entry) => entry.name),
|
|
174
|
-
exists: async (path) => (await claude.fs.stat(path).catch(ifMissing(undefined))) !== undefined,
|
|
175
|
-
},
|
|
176
|
-
store,
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
169
|
export function createLifecycle<State extends object, Declared extends Options = Options>(
|
|
181
170
|
definition: ModDefinition<State, string, Declared>,
|
|
182
171
|
permissionRoutes: () => PermissionRoutes | undefined = () => undefined,
|
|
@@ -184,6 +173,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
184
173
|
asksPerson = true,
|
|
185
174
|
): Lifecycle<State> {
|
|
186
175
|
let router: Router = createRouter()
|
|
176
|
+
let startingRouter: Router | undefined
|
|
187
177
|
let phase: Phase = 'starting'
|
|
188
178
|
let runtime: Pick<ModRuntime, 'claude' | 'toaster'> | undefined
|
|
189
179
|
let programs: Programs | undefined
|
|
@@ -286,7 +276,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
286
276
|
}
|
|
287
277
|
|
|
288
278
|
const recordThroughCmod = async () => {
|
|
289
|
-
if (plugin === undefined || (await
|
|
279
|
+
if (plugin === undefined || (await newestCmodVersion(claude())) === undefined) return
|
|
290
280
|
let failed: string | undefined
|
|
291
281
|
const { code, lastError } = await readLines(claude().process.spawn({ argv: ['cmod', 'setup', plugin.root, '--events'] }), (text) => {
|
|
292
282
|
const event = parseEvent(text)
|
|
@@ -372,12 +362,17 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
372
362
|
const activate = async (): Promise<void> => {
|
|
373
363
|
if (runtime === undefined || plugin === undefined) return
|
|
374
364
|
const activeRouter = createRouter()
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
365
|
+
startingRouter = activeRouter
|
|
366
|
+
const active = await createMod(definition, { ...runtime, router: activeRouter, dataFolder: dataFolder(plugin.store, plugin.name), store: plugin.store, permissionRoutes, options: pluginOptions, nextDraw })
|
|
367
|
+
.catch(async (error: unknown) => {
|
|
368
|
+
if (error instanceof MissingOptions && (await askOptions(error))) return undefined
|
|
369
|
+
await installer.close()
|
|
370
|
+
fail(messageOf(error), error instanceof MissingOptions ? `Retry asks for ${error.keys.length === 1 ? 'it' : 'them'}.` : undefined, begin, error)
|
|
371
|
+
throw error
|
|
372
|
+
})
|
|
373
|
+
.finally(() => {
|
|
374
|
+
startingRouter = undefined
|
|
375
|
+
})
|
|
381
376
|
if (active === undefined) return activate()
|
|
382
377
|
const { added } = active
|
|
383
378
|
mod = active.mod
|
|
@@ -429,7 +424,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
429
424
|
if (plugin === undefined) return
|
|
430
425
|
if (plugin.name === cmodPluginName) return bootstrap(plugin.root)
|
|
431
426
|
phase = 'installing'
|
|
432
|
-
const found = await
|
|
427
|
+
const found = await newestCmodVersion(claude())
|
|
433
428
|
if (!fits(found)) return waitForcmod(found)
|
|
434
429
|
if (!isQuiet) installing()
|
|
435
430
|
let outcome: RunnerEvent | undefined
|
|
@@ -460,7 +455,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
460
455
|
}
|
|
461
456
|
const poll = (ms: number) =>
|
|
462
457
|
claude().clock.every(ms, () => {
|
|
463
|
-
check ??=
|
|
458
|
+
check ??= newestCmodVersion(claude())
|
|
464
459
|
.then((version) => {
|
|
465
460
|
check = undefined
|
|
466
461
|
latest = version
|
|
@@ -575,24 +570,24 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
575
570
|
if (activation !== undefined && phase !== 'active') await activation
|
|
576
571
|
}
|
|
577
572
|
|
|
578
|
-
const held = (work: Promise<void>, signal: AbortSignal | undefined): Promise<
|
|
573
|
+
const held = (work: Promise<void>, signal: AbortSignal | undefined): Promise<boolean> =>
|
|
579
574
|
runtime === undefined
|
|
580
|
-
? work
|
|
581
|
-
: new Promise<
|
|
582
|
-
const limit = claude().clock.after(startHoldMs, resolve)
|
|
583
|
-
if (signal?.aborted === true) resolve()
|
|
584
|
-
signal?.addEventListener('abort', () => resolve(), { once: true })
|
|
575
|
+
? work.then(() => false)
|
|
576
|
+
: new Promise<boolean>((resolve) => {
|
|
577
|
+
const limit = claude().clock.after(startHoldMs, () => resolve(true))
|
|
578
|
+
if (signal?.aborted === true) resolve(false)
|
|
579
|
+
signal?.addEventListener('abort', () => resolve(false), { once: true })
|
|
585
580
|
void work.then(() => {
|
|
586
581
|
limit.cancel()
|
|
587
|
-
resolve()
|
|
582
|
+
resolve(false)
|
|
588
583
|
})
|
|
589
584
|
})
|
|
590
585
|
|
|
591
|
-
const holdUntilStarted = (signal?: AbortSignal): Promise<
|
|
586
|
+
const holdUntilStarted = (signal?: AbortSignal): Promise<boolean> => held(startSettled.then(whenActive), signal)
|
|
592
587
|
|
|
593
|
-
const holdUntilActive = (signal: AbortSignal | undefined): Promise<
|
|
588
|
+
const holdUntilActive = (signal: AbortSignal | undefined): Promise<boolean> => {
|
|
594
589
|
const activating = whenActive()
|
|
595
|
-
return activation !== undefined && phase !== 'active' ? held(activating, signal) : activating
|
|
590
|
+
return activation !== undefined && phase !== 'active' ? held(activating, signal) : activating.then(() => false)
|
|
596
591
|
}
|
|
597
592
|
|
|
598
593
|
const routed = async <N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, next: RouterNext<N>, signal?: AbortSignal): Promise<EventResult<N>> => {
|
|
@@ -617,7 +612,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
617
612
|
const tool = (e as { readonly tool?: unknown }).tool
|
|
618
613
|
const isCallToThisMod = (event === 'cmod.call' && (e as Frozen<Args<'cmod.call'>>).to === definition.name) || (event === 'tool.call' && typeof tool === 'string' && tool.startsWith(`mcp__${definition.name}__`))
|
|
619
614
|
if (event === 'cmod.call' && !isCallToThisMod) return next(e)
|
|
620
|
-
await (event === 'classic.SessionStart' || event === 'session.append' || isCallToThisMod ? holdUntilStarted(signal) : holdUntilActive(signal))
|
|
615
|
+
const isLate = await (event === 'classic.SessionStart' || event === 'session.append' || isCallToThisMod ? holdUntilStarted(signal) : holdUntilActive(signal))
|
|
621
616
|
if (event === 'classic.SessionStart' && phase !== 'active') {
|
|
622
617
|
missedSessionStart = e as Frozen<Args<'classic.SessionStart'>>
|
|
623
618
|
return next(e)
|
|
@@ -629,6 +624,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
629
624
|
}
|
|
630
625
|
return { deny: phase === 'failed' ? notSetUp() : `${definition.name} is installing. Try again when it's ready.` } as EventResult<N>
|
|
631
626
|
}
|
|
627
|
+
if (isLate && phase !== 'active') return (startingRouter ?? router).dispatchFailure(event, e, new Error(`it was still starting after ${startHoldMs / 1000} s`), next, false)
|
|
632
628
|
const call = e as Frozen<Args<'cmod.call'>>
|
|
633
629
|
if (event === 'cmod.call' && call.to === definition.name && mod !== undefined) {
|
|
634
630
|
if (call.method === pendingStepsMethod) return { value: await pendingSteps(mod) } as EventResult<N>
|
|
@@ -712,7 +708,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
712
708
|
const error = new Error(reason)
|
|
713
709
|
const failedBeneath = called && kind === 'throw' ? await next(e).then(() => undefined, messageOf) : undefined
|
|
714
710
|
if (failedBeneath === undefined || failedBeneath !== message) toastFailure({ id: `stopped:${event}`, message: `Claude Code stopped its ${event.replace(/^classic\./, '')} hook`, error })
|
|
715
|
-
return router.dispatchFailure(event, e, error, next)
|
|
711
|
+
return (startingRouter ?? router).dispatchFailure(event, e, error, next, called)
|
|
716
712
|
},
|
|
717
713
|
}
|
|
718
714
|
}
|
package/src/runtime/programs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HookStream, ProcessSpawnChunk, ProcessSpawnResult } from 'claude-code'
|
|
2
|
-
import { storeFolder } from '../records.js'
|
|
2
|
+
import { readCmodVersion, storeFolder } from '../records.js'
|
|
3
3
|
import { ifMissing } from '../utils/paths.js'
|
|
4
4
|
import { formatExit } from '../utils/text.js'
|
|
5
5
|
import type { Claude } from './claude.js'
|
|
@@ -46,6 +46,17 @@ export async function isHeld(claude: Claude, lock: string, staleMs: number): Pro
|
|
|
46
46
|
return touched.some((at) => now - at < staleMs)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export async function newestCmodVersion(claude: Claude): Promise<string | undefined> {
|
|
50
|
+
const store = storeFolder({ HOME: await claude.env.home(), XDG_DATA_HOME: await claude.env.dataHome() })
|
|
51
|
+
return readCmodVersion(
|
|
52
|
+
{
|
|
53
|
+
list: async (folder) => (await claude.fs.list(folder).catch(ifMissing([]))).map((entry) => entry.name),
|
|
54
|
+
exists: async (path) => (await claude.fs.stat(path).catch(ifMissing(undefined))) !== undefined,
|
|
55
|
+
},
|
|
56
|
+
store,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
49
60
|
export async function runCmod(claude: Claude, args: readonly string[], session: string): Promise<string> {
|
|
50
61
|
const lines: string[] = []
|
|
51
62
|
const { code, lastError } = await readLines(spawnCmod(claude, args, session), (line) => void lines.push(line))
|
package/src/runtime/router.ts
CHANGED
|
@@ -8,17 +8,17 @@ export type RoutedNext<N extends RoutedEvent> = RouterNext<N> & { readonly signa
|
|
|
8
8
|
|
|
9
9
|
export type RoutedHook<N extends RoutedEvent> = (e: Frozen<Args<N>>, next: RoutedNext<N>) => EventResult<N> | Promise<EventResult<N>>
|
|
10
10
|
|
|
11
|
-
export type RoutedFailure<N extends RoutedEvent> = (e: Frozen<Args<N>>, error: Error, next: RoutedNext<N>) => EventResult<N> | undefined | Promise<EventResult<N> | undefined>
|
|
11
|
+
export type RoutedFailure<N extends RoutedEvent> = (e: Frozen<Args<N>>, error: Error, next: RoutedNext<N> & { readonly called: boolean }) => EventResult<N> | undefined | Promise<EventResult<N> | undefined>
|
|
12
12
|
|
|
13
13
|
export type Router = {
|
|
14
14
|
add<N extends RoutedEvent>(event: N, hook: RoutedHook<N>, failed?: RoutedFailure<N>): Subscription
|
|
15
15
|
dispatch<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, next: RouterNext<N>, signal?: AbortSignal): Promise<EventResult<N>>
|
|
16
|
-
dispatchFailure<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, error: Error, next: RouterNext<N
|
|
16
|
+
dispatchFailure<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, error: Error, next: RouterNext<N>, called: boolean): Promise<EventResult<N>>
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
type Next = ((e: unknown) => Promise<unknown>) & { readonly signal: AbortSignal }
|
|
20
20
|
|
|
21
|
-
type Route = { readonly hook: (e: unknown, next: Next) => unknown; readonly failed?: (e: unknown, error: Error, next: Next) => unknown }
|
|
21
|
+
type Route = { readonly hook: (e: unknown, next: Next) => unknown; readonly failed?: (e: unknown, error: Error, next: Next & { readonly called: boolean }) => unknown }
|
|
22
22
|
|
|
23
23
|
export const unaborted = new AbortController().signal
|
|
24
24
|
|
|
@@ -46,13 +46,15 @@ export function createRouter(): Router {
|
|
|
46
46
|
}
|
|
47
47
|
return call(0, e) as Promise<EventResult<N>>
|
|
48
48
|
},
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
49
|
+
dispatchFailure<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, error: Error, next: RouterNext<N>, called: boolean): Promise<EventResult<N>> {
|
|
50
|
+
const chain = routes.get(event)
|
|
51
|
+
const fail = async (index: number, current: unknown): Promise<unknown> => {
|
|
52
|
+
const route = chain?.[index]
|
|
53
|
+
if (route === undefined) return next(current as Frozen<Args<N>>)
|
|
54
|
+
const answer = await route.failed?.(current, error, Object.assign((passed: unknown) => fail(index + 1, passed), { signal: unaborted, called }))
|
|
55
|
+
return answer === undefined ? fail(index + 1, current) : answer
|
|
54
56
|
}
|
|
55
|
-
return
|
|
57
|
+
return fail(0, e) as Promise<EventResult<N>>
|
|
56
58
|
},
|
|
57
59
|
}
|
|
58
60
|
}
|
package/src/runtime/toaster.ts
CHANGED
|
@@ -314,7 +314,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
|
|
|
314
314
|
changed()
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
const row = (entry: Entry): RenderElement => {
|
|
317
|
+
const row = (entry: Entry, columns: number): RenderElement => {
|
|
318
318
|
const { description } = entry.options
|
|
319
319
|
const isText = typeof description === 'string'
|
|
320
320
|
const icon = entry.type === 'loading' || entry.trying !== undefined ? { glyph: isSpinning(entry) ? (spinner[frame % spinner.length] as string) : still, color: 'claude' } : icons[entry.type]
|
|
@@ -323,17 +323,25 @@ export function createToaster(claude: Claude, name: string, version: () => strin
|
|
|
323
323
|
const fixed = (child: RenderElement) => Box({ flexShrink: 0, children: child })
|
|
324
324
|
const close = Button({ plain: true, dimColor: true, key: `toast:${entry.id}:close`, label: entry.hides === undefined ? '✕' : 'Hide', onPress: () => hide(entry) })
|
|
325
325
|
const actions = entry.actions.map((action, index) => Button({ plain: true, key: `toast:${entry.id}:${index === 0 ? 'action' : `action-${index}`}`, label: action.label, onPress: press(entry, action.onClick) }))
|
|
326
|
-
const buttons = Box({ gap: 2, flexWrap: 'wrap', children: [...actions,
|
|
326
|
+
const buttons = Box({ gap: 2, flexWrap: 'wrap', children: [...actions, Text({ dimColor: true, children: clockTime(entry.at) })].map(fixed) })
|
|
327
327
|
const trying = entry.trying === undefined ? undefined : Box({ gap: 1, children: [Text({ dimColor: true, children: 'Trying again:' }), typeof entry.trying === 'string' ? Text({ dimColor: true, wrap: 'truncate-end', children: entry.trying }) : entry.trying] })
|
|
328
328
|
const text = details === undefined ? [message] : [message, trying ?? details]
|
|
329
329
|
const under = trying !== undefined && details === undefined ? [trying] : entry.reporting === undefined ? [buttons] : reportChoices(entry, entry.reporting)
|
|
330
330
|
return Box({
|
|
331
|
+
width: columns,
|
|
331
332
|
gap: 2,
|
|
333
|
+
justifyContent: 'space-between',
|
|
332
334
|
children: [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
Box({
|
|
336
|
+
gap: 2,
|
|
337
|
+
flexShrink: 1,
|
|
338
|
+
children: [
|
|
339
|
+
fixed(Text({ ...(icon.color === undefined ? {} : { color: icon.color }), children: icon.glyph })),
|
|
340
|
+
fixed(Text({ dimColor: true, children: name })),
|
|
341
|
+
Box({ flexDirection: 'column', flexShrink: 1, children: entry.hides === undefined ? text : [...text, ...under] }),
|
|
342
|
+
],
|
|
343
|
+
}),
|
|
344
|
+
Box({ gap: 2, flexShrink: 0, alignSelf: 'flex-end', children: entry.hides === undefined ? [...actions, close] : [close] }),
|
|
337
345
|
],
|
|
338
346
|
})
|
|
339
347
|
}
|
|
@@ -397,7 +405,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
|
|
|
397
405
|
changed()
|
|
398
406
|
},
|
|
399
407
|
})
|
|
400
|
-
return drawWith(table, () => Box({ flexDirection: 'column', children: [drawn, ...(hidden > 0 ? [more] : []), ...all.slice(hidden).map(row)] }))
|
|
408
|
+
return drawWith(table, () => Box({ flexDirection: 'column', children: [drawn, ...(hidden > 0 ? [more] : []), ...all.slice(hidden).map((entry) => row(entry, band.bodyColumns))] }))
|
|
401
409
|
},
|
|
402
410
|
}
|
|
403
411
|
}
|