@cmodjs/core 7.0.0 → 8.0.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.
Files changed (138) hide show
  1. package/docs/commands.md +104 -70
  2. package/docs/dependencies.md +153 -23
  3. package/docs/index.md +54 -10
  4. package/docs/install-steps.md +20 -17
  5. package/docs/jobs.md +42 -17
  6. package/docs/mod.md +37 -30
  7. package/docs/options.md +2 -2
  8. package/docs/session.md +39 -29
  9. package/docs/testing.md +84 -23
  10. package/docs/ui.md +128 -58
  11. package/installer.d.ts +2 -2
  12. package/jobs/context.js +1 -1
  13. package/jobs/program.d.ts +2 -3
  14. package/jobs/program.d.ts.map +1 -1
  15. package/jobs/program.js +72 -23
  16. package/mod.d.ts +23 -8
  17. package/mod.d.ts.map +1 -1
  18. package/mod.js +3 -3
  19. package/package.json +1 -1
  20. package/records.d.ts +5 -3
  21. package/records.d.ts.map +1 -1
  22. package/records.js +18 -9
  23. package/register.d.ts.map +1 -1
  24. package/register.js +7 -15
  25. package/rpc.d.ts +7 -0
  26. package/rpc.d.ts.map +1 -0
  27. package/rpc.js +59 -0
  28. package/runtime/bound.d.ts +1 -0
  29. package/runtime/bound.d.ts.map +1 -1
  30. package/runtime/bound.js +10 -0
  31. package/runtime/bun.d.ts +20 -0
  32. package/runtime/bun.d.ts.map +1 -0
  33. package/runtime/bun.js +20 -0
  34. package/runtime/claude.d.ts +1 -0
  35. package/runtime/claude.d.ts.map +1 -1
  36. package/runtime/conversations.d.ts +9 -2
  37. package/runtime/conversations.d.ts.map +1 -1
  38. package/runtime/conversations.js +244 -185
  39. package/runtime/deadline.d.ts +4 -3
  40. package/runtime/deadline.d.ts.map +1 -1
  41. package/runtime/deadline.js +10 -4
  42. package/runtime/engine.d.ts +4 -4
  43. package/runtime/engine.d.ts.map +1 -1
  44. package/runtime/installer.d.ts +3 -3
  45. package/runtime/installer.d.ts.map +1 -1
  46. package/runtime/installer.js +10 -9
  47. package/runtime/interfaces.d.ts +108 -42
  48. package/runtime/interfaces.d.ts.map +1 -1
  49. package/runtime/interfaces.js +639 -143
  50. package/runtime/lifecycle.d.ts +3 -5
  51. package/runtime/lifecycle.d.ts.map +1 -1
  52. package/runtime/lifecycle.js +74 -63
  53. package/runtime/options.d.ts.map +1 -1
  54. package/runtime/options.js +2 -6
  55. package/runtime/parts.d.ts +64 -1
  56. package/runtime/parts.d.ts.map +1 -1
  57. package/runtime/parts.js +311 -4
  58. package/runtime/programs.d.ts +1 -0
  59. package/runtime/programs.d.ts.map +1 -1
  60. package/runtime/programs.js +5 -3
  61. package/runtime/rpc.d.ts +2 -0
  62. package/runtime/rpc.d.ts.map +1 -1
  63. package/runtime/rpc.js +30 -5
  64. package/runtime/sessions.d.ts +3 -3
  65. package/runtime/sessions.d.ts.map +1 -1
  66. package/runtime/sessions.js +38 -73
  67. package/runtime/toaster.js +1 -1
  68. package/runtime/ui.d.ts +19 -8
  69. package/runtime/ui.d.ts.map +1 -1
  70. package/runtime/ui.js +51 -47
  71. package/runtime/web.d.ts +0 -73
  72. package/runtime/web.d.ts.map +1 -1
  73. package/runtime/web.js +9 -5
  74. package/runtime/widgets.d.ts +4 -2
  75. package/runtime/widgets.d.ts.map +1 -1
  76. package/runtime/widgets.js +17 -16
  77. package/session/conversation.d.ts +6 -2
  78. package/session/conversation.d.ts.map +1 -1
  79. package/session/session.d.ts +22 -6
  80. package/session/session.d.ts.map +1 -1
  81. package/session/session.js +1 -0
  82. package/src/installer.ts +2 -2
  83. package/src/jobs/context.ts +1 -1
  84. package/src/jobs/program.ts +63 -23
  85. package/src/mod.ts +22 -11
  86. package/src/records.ts +21 -9
  87. package/src/register.ts +7 -15
  88. package/src/rpc.ts +67 -0
  89. package/src/runtime/bound.ts +10 -0
  90. package/src/runtime/bun.ts +40 -0
  91. package/src/runtime/claude.ts +1 -0
  92. package/src/runtime/conversations.ts +247 -182
  93. package/src/runtime/deadline.ts +13 -6
  94. package/src/runtime/engine.ts +4 -4
  95. package/src/runtime/installer.ts +13 -12
  96. package/src/runtime/interfaces.ts +753 -172
  97. package/src/runtime/lifecycle.ts +93 -67
  98. package/src/runtime/options.ts +2 -5
  99. package/src/runtime/parts.ts +364 -5
  100. package/src/runtime/programs.ts +6 -3
  101. package/src/runtime/rpc.ts +32 -5
  102. package/src/runtime/sessions.ts +39 -73
  103. package/src/runtime/toaster.ts +1 -1
  104. package/src/runtime/ui.ts +67 -55
  105. package/src/runtime/web.ts +10 -39
  106. package/src/runtime/widgets.ts +20 -18
  107. package/src/session/conversation.ts +7 -2
  108. package/src/session/session.ts +14 -6
  109. package/src/testing/fake-claude.ts +10 -4
  110. package/src/testing/fake-serve.ts +106 -6
  111. package/src/testing/fake-sessions.ts +6 -5
  112. package/src/testing.ts +149 -67
  113. package/src/ui/areas.ts +2 -2
  114. package/src/ui/elements.ts +21 -16
  115. package/src/ui/panes.ts +14 -7
  116. package/testing/fake-claude.d.ts +2 -0
  117. package/testing/fake-claude.d.ts.map +1 -1
  118. package/testing/fake-claude.js +10 -4
  119. package/testing/fake-serve.d.ts +32 -2
  120. package/testing/fake-serve.d.ts.map +1 -1
  121. package/testing/fake-serve.js +81 -6
  122. package/testing/fake-sessions.d.ts.map +1 -1
  123. package/testing/fake-sessions.js +6 -5
  124. package/testing.d.ts +21 -4
  125. package/testing.d.ts.map +1 -1
  126. package/testing.js +131 -55
  127. package/ui/areas.d.ts +3 -1
  128. package/ui/areas.d.ts.map +1 -1
  129. package/ui/elements.d.ts +18 -9
  130. package/ui/elements.d.ts.map +1 -1
  131. package/ui/elements.js +9 -8
  132. package/ui/panes.d.ts +10 -6
  133. package/ui/panes.d.ts.map +1 -1
  134. package/ui/panes.js +5 -3
  135. package/runtime/pages.d.ts +0 -34
  136. package/runtime/pages.d.ts.map +0 -1
  137. package/runtime/pages.js +0 -157
  138. package/src/runtime/pages.ts +0 -198
package/src/testing.ts CHANGED
@@ -20,9 +20,9 @@ import type {
20
20
  UiSelectArgument,
21
21
  } from 'claude-code'
22
22
  import type { CommandReply } from './jobs/slash-command.js'
23
- import type { ModDefinition } from './mod.js'
23
+ import type { InterfaceMethods, InterfaceName, ModDefinition, Provided } from './mod.js'
24
24
  import type { Options, OptionValues } from './options.js'
25
- import { hotkeyCommand, readSteps, storeFolder, type Steps } from './records.js'
25
+ import { hotkeyCommand, readSteps, type Steps } from './records.js'
26
26
  import { heldInput, type Claude } from './runtime/claude.js'
27
27
  import { answerCall, cmodPluginName, loadedMethod, notInstalled } from './runtime/dependencies.js'
28
28
  import { closingContext, foldBefore, installBefore, withAnswer, type Answers, type Decide } from './runtime/before.js'
@@ -32,6 +32,7 @@ import { keepClaudeCode, type ClaudeCode } from './testing/claude-code.js'
32
32
  import { createRouter } from './runtime/router.js'
33
33
  import { toolInputOf } from './runtime/tool-calls.js'
34
34
  import { createLifecycle } from './runtime/lifecycle.js'
35
+ import { cmodStore } from './runtime/programs.js'
35
36
  import { serveCmodPlugin } from './register.js'
36
37
  import { MissingOptions } from './runtime/options.js'
37
38
  import { conversationMethods, pickedColor, type SessionColor } from './runtime/sessions.js'
@@ -53,13 +54,12 @@ import { fakeSessions, type FakeSession, type FakeSessions, type MessageDraft, t
53
54
  import { listed, messageOf } from './utils/text.js'
54
55
  import { componentOf, type KindProps, type Row, type StyledAt } from './ui/styles.js'
55
56
  import { AbovePrompt, areas, BelowPrompt, Dashboard, TurnEnd as TurnEndArea, Working, type Area } from './ui/areas.js'
56
- import { drawWith, elementOf, withLinks, type Press } from './ui/elements.js'
57
- import { drawnParts } from './runtime/parts.js'
57
+ import { drawWith, elementOf, forClaudeCode } from './ui/elements.js'
58
+ import { drawnParts, pagesOf, providedBy, serveParts, viewsOf } from './runtime/parts.js'
58
59
  import { serveWidgets, type Widgets } from './runtime/widgets.js'
59
60
  import { engineOf } from './runtime/engine.js'
60
- import { pagesOf, providedBy, servePages } from './runtime/pages.js'
61
- import { interfaceMethods, styleInterface, type ProviderList } from './runtime/interfaces.js'
62
- import { inheriting, openLink, partMethods, type DrawnPart, type PageRequest, type PartPress, type PartsUpdate } from './runtime/ui.js'
61
+ import { createProviders, interfaceMethods, styleInterface, type Provided as ProvidedHandle, type Providers, type ServedProviders } from './runtime/interfaces.js'
62
+ import { inheriting, openLink, partMethods, type DrawnPart, type PartPress, type PartRequest, type PartsUpdate } from './runtime/ui.js'
63
63
 
64
64
  export type { Fakes, TestCall } from './testing/fake-claude.js'
65
65
  export type { FakeSession, MessageDraft, StartedTask } from './testing/fake-sessions.js'
@@ -76,9 +76,13 @@ export type ShownPart = {
76
76
  focusedKey(): Promise<string | undefined>
77
77
  }
78
78
 
79
- export type Shown = ShownByClaude & { readonly toasts: readonly ShownToast[]; readonly sent: FakeSessions['sent']; readonly pane: ShownPart; readonly page: ShownPart }
79
+ export type Shown = ShownByClaude & { readonly toasts: readonly ShownToast[]; readonly sent: FakeSessions['sent']; readonly pane: ShownPart; readonly view: ShownPart; readonly page: ShownPart }
80
80
 
81
- export type TestOptions<State extends object, Declared extends Options = Options> = {
81
+ export type FakeProvider = {
82
+ readonly [Name in InterfaceName]: { readonly name: Name; readonly mod: string; readonly program?: string; readonly device?: { readonly id: string; readonly name: string }; readonly methods: InterfaceMethods<Name> }
83
+ }[InterfaceName]
84
+
85
+ export type TestOptions<State extends object, Declared extends Options = Options, Given extends readonly FakeProvider[] = readonly FakeProvider[]> = {
82
86
  readonly state?: { readonly [Lifetime in keyof State]?: Partial<State[Lifetime]> }
83
87
  readonly options?: Partial<OptionValues<Declared>>
84
88
  readonly scope?: 'user' | 'project'
@@ -89,6 +93,7 @@ export type TestOptions<State extends object, Declared extends Options = Options
89
93
  readonly links?: Readonly<Record<string, string>>
90
94
  readonly secrets?: Readonly<Record<string, string>>
91
95
  readonly sessions?: readonly FakeSession[]
96
+ readonly providers?: Given
92
97
  }
93
98
 
94
99
  type Placed<Payload> = Omit<Payload, keyof Placement> & Partial<Placement>
@@ -116,7 +121,7 @@ export type Raise = {
116
121
 
117
122
  type FiredEvent = 'ui.render' | 'ui.scroll' | 'ui.close' | 'cmod.call' | 'tool.check' | 'prompt.context'
118
123
 
119
- export type TestedMod<State extends object> = {
124
+ export type TestedMod<State extends object, Given extends readonly FakeProvider[] = readonly FakeProvider[]> = {
120
125
  start(): Promise<void>
121
126
  readonly raise: Raise
122
127
  fire<N extends FiredEvent>(event: N, input: Args<N>, below?: EventResult<N>): Promise<EventResult<N>>
@@ -138,6 +143,7 @@ export type TestedMod<State extends object> = {
138
143
  readonly calls: readonly TestCall[]
139
144
  readonly fakes: Fakes
140
145
  readonly shown: Shown
146
+ readonly providers: { readonly [Index in keyof Given]: Provided<Given[Index]['name']> }
141
147
  }
142
148
 
143
149
  const defaultColumns = 80
@@ -159,9 +165,15 @@ function drawnByStyle(key: string): (drawnKey: string) => boolean {
159
165
  }
160
166
  }
161
167
 
162
- export function testMod<State extends object, Declared extends Options = Options>(definition: ModDefinition<State, string, Declared>, options: TestOptions<State, Declared> = {}): TestedMod<State> {
168
+ export function testMod<State extends object, Declared extends Options = Options, const Given extends readonly FakeProvider[] = readonly FakeProvider[]>(definition: ModDefinition<State, string, Declared>, options: TestOptions<State, Declared, Given> = {}): TestedMod<State, Given> {
163
169
  installJsx()
164
170
  const name = definition.name
171
+ const given: readonly FakeProvider[] = options.providers ?? []
172
+ for (const each of given) {
173
+ if (each.program !== undefined) continue
174
+ if (each.mod === name) throw new Error(`${name} is the tested mod, so its own provide answers ${each.name}. Fake another mod's provider, or a program's with program: '<executable>'.`)
175
+ if (each.device !== undefined) throw new Error(`${each.mod}'s session code provides ${each.name} only in this session, on this computer, so it takes no device. Give the program that provides it on ${each.device.name}, with program: '<executable>'.`)
176
+ }
165
177
  const isProjectPlugin = options.scope === 'project'
166
178
  let projectRoot = options.projectRoot ?? (isProjectPlugin ? '/test/project' : `/test/plugins/${name}`)
167
179
  const root = isProjectPlugin ? `${projectRoot}/.claude/skills/${name}` : `/test/plugins/${name}`
@@ -197,6 +209,7 @@ export function testMod<State extends object, Declared extends Options = Options
197
209
  const held = conversations.color()
198
210
  if (held.color !== undefined) await tellColor(held)
199
211
  }
212
+ let declaredViews: ReturnType<typeof viewsOf> = []
200
213
  let declaredPages: ReturnType<typeof pagesOf> = []
201
214
  let openPages: { readonly id: string; readonly params: unknown }[] = []
202
215
  let shownPage: { readonly id: string; readonly params: unknown; readonly isFocused: boolean } | undefined
@@ -208,10 +221,11 @@ export function testMod<State extends object, Declared extends Options = Options
208
221
  return work
209
222
  }
210
223
  const settle = async () => {
211
- do {
212
- await fake.settle()
224
+ await fake.settle()
225
+ while (modeled.size > 0) {
213
226
  await Promise.allSettled(modeled)
214
- } while (modeled.size > 0)
227
+ await fake.settle()
228
+ }
215
229
  }
216
230
  let focused: { readonly part: string; readonly key: string } | undefined
217
231
  const forgetFocus = (part: string) => {
@@ -221,29 +235,29 @@ export function testMod<State extends object, Declared extends Options = Options
221
235
  const refusedFocus = async (isPane: boolean, id: string, key: string): Promise<string | undefined> => {
222
236
  const pane = isPane ? id : 'sidebar'
223
237
  if (!(await holdsKeyboard(isPane, id))) return `the pane "${pane}" does not hold the keyboard`
224
- const drawn = lifecycle.phase === 'active' ? (isPane ? await drawPane(id) : await drawPage(id)).drawing : undefined
238
+ const drawn = lifecycle.phase === 'active' ? (isPane ? await drawPane(id) : await drawInSidebar(id)).drawing : undefined
225
239
  if (drawn === undefined || focusableKey(drawn, (props) => props['key'] === key) === undefined) return `the pane "${pane}" draws no Button, Input, or Select with the key "${key}"`
226
240
  return undefined
227
241
  }
228
- const applyRequests = async (requests: readonly PageRequest[]) => {
242
+ const applyRequests = async (requests: readonly PartRequest[]) => {
229
243
  for (const request of requests) {
230
244
  if ('open' in request) {
231
- const isSettings = declaredPages.some((page) => page.id === request.open && page.place === 'settings')
245
+ const isSettings = declaredViews.some((view) => view.id === request.open && view.place === 'settings')
232
246
  if (!isSettings) openPages = [...openPages.filter((page) => page.id !== request.open), { id: request.open, params: request.params ?? null }]
233
247
  shownPage = { id: request.open, params: request.params ?? null, isFocused: request.focus === true }
234
- if (request.focus === true) forgetFocus(`page:${request.open}`)
248
+ if (request.focus === true) forgetFocus(`sidebar:${request.open}`)
235
249
  } else if ('close' in request) {
236
250
  openPages = openPages.filter((page) => page.id !== request.close)
237
251
  if (shownPage?.id === request.close) shownPage = undefined
238
252
  } else if ('focus' in request) {
239
253
  const key = `${name}/${request.focus}:${request.key}`
240
254
  const refused = await refusedFocus(false, request.focus, key)
241
- if (refused === undefined) focused = { part: `page:${request.focus}`, key: request.key }
242
- else reportPart(`pages:${name}`, `Could not show the page ${name} asked for`, new Error(`cmod: Claude Code did not focus "${key}" in the Sidebar pane: ${refused}`))
255
+ if (refused === undefined) focused = { part: `sidebar:${request.focus}`, key: request.key }
256
+ else reportPart(`pages:${name}`, `Could not show the view or page ${name} asked for`, new Error(`cmod: Claude Code did not focus "${key}" in the Sidebar pane: ${refused}`))
243
257
  } else if ('settings' in request) {
244
- const first = declaredPages.find((page) => page.place === 'settings')
258
+ const first = declaredViews.find((view) => view.place === 'settings')
245
259
  shownPage = first === undefined ? undefined : { id: first.id, params: null, isFocused: true }
246
- if (first !== undefined) forgetFocus(`page:${first.id}`)
260
+ if (first !== undefined) forgetFocus(`sidebar:${first.id}`)
247
261
  }
248
262
  }
249
263
  await tellShown()
@@ -254,6 +268,7 @@ export function testMod<State extends object, Declared extends Options = Options
254
268
  const missedMarkdown = new Map<string, { readonly markdown: string } & StyledAt>()
255
269
  const updated = async ({ parts, redraw, requests }: PartsUpdate) => {
256
270
  if (parts !== undefined) {
271
+ declaredViews = viewsOf(parts)
257
272
  declaredPages = pagesOf(parts)
258
273
  provides = providedBy(parts)
259
274
  ownMarkdown.clear()
@@ -283,10 +298,10 @@ export function testMod<State extends object, Declared extends Options = Options
283
298
  return draw()
284
299
  }
285
300
  const reportPart = (_id: string, message: string, error: unknown) => fake.claude.ui.log(`cmod: ${message}: ${messageOf(error)}`, { to: 'debug' })
286
- const openFromCmod = (href: string, press: Press) => void openLink(fake.claude, href, press.surface).catch((error: unknown) => reportPart('open-link', 'Could not open the link', error))
301
+ const openFromCmod = (href: string, press: UiPressArgument) => void openLink(fake.claude, href, press.surface).catch((error: unknown) => reportPart('open-link', 'Could not open the link', error))
287
302
  const cmodClaude: Claude = {
288
303
  ...fake.claude,
289
- ui: { ...fake.claude.ui, resolve: (e) => withLinks(fake.claude.ui.resolve(e), e.surface, openFromCmod) },
304
+ ui: { ...fake.claude.ui, resolve: (e) => forClaudeCode(fake.claude.ui.resolve(e), e.surface, openFromCmod) },
290
305
  cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) },
291
306
  }
292
307
  const tellRefusedPress = (_mod: string, error: unknown) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' })
@@ -297,7 +312,7 @@ export function testMod<State extends object, Declared extends Options = Options
297
312
  return serveWidgets({
298
313
  claude: cmodClaude,
299
314
  router: cmodPlugin,
300
- store: storeFolder({ HOME: await fake.claude.env.home(), XDG_DATA_HOME: await fake.claude.env.dataHome() }),
315
+ store: await cmodStore(fake.claude),
301
316
  report: reportPart,
302
317
  turnClosedBy: () => conversations.lastTurn(),
303
318
  parts,
@@ -306,13 +321,63 @@ export function testMod<State extends object, Declared extends Options = Options
306
321
  }
307
322
  const widgetsOf = () => (widgets ??= servedWidgets())
308
323
  const cmodBeneath = createRouter()
309
- const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, tellRefusedPress, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined })
310
- pages.apply((_mod, requests) => applyRequests(requests))
311
- const dependencies = fakeDependencies(name, options.dependencies ?? {}, conversations, () => provides)
324
+ const servedParts = serveParts({ claude: cmodClaude, router: cmodBeneath, report: reportPart, tellRefusedPress, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined, tellUi: () => undefined })
325
+ servedParts.apply((_mod, requests) => applyRequests(requests))
326
+ const after: Claude['clock']['after'] = (ms, run) => fake.claude.clock.after(ms, run)
327
+ const report = (error: unknown) => reportPart('interfaces', 'A provider listener failed', error)
328
+ const sessionMods = new Map<string, Providers>()
329
+ const served = fake.serve.connect({
330
+ tell: (_caller, heard) => new Promise((resolve) => fake.claude.clock.after(0, () => resolve(callMod(interfaceMethods.heard, heard)))),
331
+ sessionCode: (named) => [...(provides.includes(named) ? [name] : []), ...[...sessionMods].filter(([, each]) => each.provided().includes(named)).map(([mod]) => mod)],
332
+ device: async () => {
333
+ const { id, name: deviceName } = await fake.claude.device.read()
334
+ return { id, name: deviceName }
335
+ },
336
+ after,
337
+ report,
338
+ })
339
+ const providedInSession = given.map(({ name: named, mod, program, methods }) => {
340
+ if (program !== undefined) return undefined
341
+ const made = sessionMods.get(mod) ?? createProviders({ name: mod, call: (_to, method, input) => served.answer(method, input, mod) ?? Promise.reject(new Error(`${mod} reaches no ${method} in the test kit.`)), changed: () => undefined, after, report })
342
+ sessionMods.set(mod, made)
343
+ return made.provide(named, methods)
344
+ })
345
+ let fakesReady: Promise<readonly ProvidedHandle[]> | undefined
346
+ const fakeProviders = () =>
347
+ (fakesReady ??= (async () => {
348
+ const programs = await fake.serve.provide(
349
+ given.flatMap(({ name: named, mod, program, device, methods }) => (program === undefined ? [] : [{ name: named, mod, program, ...(device === undefined ? {} : { device }), methods }])),
350
+ { after, report },
351
+ )
352
+ let next = 0
353
+ return providedInSession.map((inSession) => inSession ?? (programs[next++] as ProvidedHandle))
354
+ })())
355
+ const fakeProvider = (index: number): ProvidedHandle => {
356
+ const reached = async () => {
357
+ const each = (await fakeProviders())[index] as ProvidedHandle
358
+ await fake.settle()
359
+ return each
360
+ }
361
+ return {
362
+ remove: () => void modeling(reached().then((each) => each.remove())),
363
+ tell: (event, payload) => void modeling(reached().then((each) => each.tell(event, payload))),
364
+ ask: (event, payload) => modeling(reached().then((each) => each.ask(event, payload))),
365
+ }
366
+ }
367
+ const fakedPrograms = new Set(given.flatMap(({ mod, program }) => (mod === name && program !== undefined ? [program] : [])))
368
+ const spawnUnlessFaked = fake.claude.process.spawn
369
+ fake.claude.process.spawn = (request) => {
370
+ const [, command, mod] = request.argv
371
+ const at = request.argv.indexOf('--')
372
+ const executable = at === -1 ? undefined : request.argv[at + 1]?.split('/').at(-1)
373
+ if (command !== 'program' || mod !== name || request.argv.includes('--remove-service') || executable === undefined || !fakedPrograms.has(executable)) return spawnUnlessFaked(request)
374
+ return { [Symbol.asyncIterator]: () => ({ next: () => new Promise<never>(() => undefined) }) } as never
375
+ }
376
+ const dependencies = fakeDependencies(name, options.dependencies ?? {}, conversations, served, sessionMods)
312
377
  fake.fakes.cmod.call = async (call) => {
313
378
  if (call.to !== cmodPluginName || call.method !== partMethods.changed) return dependencies(call)
314
379
  const { requests, isAsked, ...listing } = call.input as PartsUpdate
315
- const isHeld = isAsked === true && requests !== undefined && pages.update(name, { requests, isAsked })
380
+ const isHeld = isAsked === true && requests !== undefined && servedParts.update(name, { requests, isAsked })
316
381
  await updated(isAsked === true ? listing : (call.input as PartsUpdate))
317
382
  return { isHeld }
318
383
  }
@@ -355,11 +420,11 @@ export function testMod<State extends object, Declared extends Options = Options
355
420
  const runProcess = fake.claude.process.run
356
421
  fake.claude.process.run = async (argv, init) => {
357
422
  const [program, command, action, mod, key] = argv
358
- if (program?.split('/').at(-1) !== 'cmod' || command !== 'secret' || mod !== name || key === undefined) return runProcess(argv, init)
423
+ if (program?.split('/').at(-1) !== 'cmod' || command !== 'secrets' || mod !== name || key === undefined) return runProcess(argv, init)
359
424
  const answer = (stdout: string, stderr = '') => ({ exitCode: stderr === '' ? 0 : 1, stdout, stderr, isStdoutTruncated: false, isStderrTruncated: false })
360
425
  if (action === 'get') return answer(secrets.get(key) ?? '')
361
426
  if (action === 'delete') secrets.delete(key)
362
- else if (init?.stdin === undefined || init.stdin === '') return answer('', `cmod secret: cmod secret store read no value from stdin. cmod secret delete ${name} ${key} deletes the secret.\n`)
427
+ else if (init?.stdin === undefined || init.stdin === '') return answer('', `cmod secrets: cmod secrets store read no value from stdin. cmod secrets delete ${name} ${key} deletes the secret.\n`)
363
428
  else secrets.set(key, init.stdin)
364
429
  return answer('')
365
430
  }
@@ -391,15 +456,17 @@ export function testMod<State extends object, Declared extends Options = Options
391
456
  }
392
457
 
393
458
  const start = async () => {
394
- started ??= lifecycle.start(fake.claude, async (claude) => ({
395
- name,
396
- root,
397
- version: '0.0.0',
398
- store: storeFolder({ HOME: await claude.env.home(), XDG_DATA_HOME: await claude.env.dataHome() }),
399
- isInstalled: true,
400
- shouldRecord: false,
401
- steps: await modSteps(),
402
- }))
459
+ started ??= fakeProviders().then(() =>
460
+ lifecycle.start(fake.claude, async (claude) => ({
461
+ name,
462
+ root,
463
+ version: '0.0.0',
464
+ store: await cmodStore(claude),
465
+ isInstalled: true,
466
+ shouldRecord: false,
467
+ steps: await modSteps(),
468
+ })),
469
+ )
403
470
  await started
404
471
  await fake.settle()
405
472
  const { failure } = lifecycle
@@ -502,35 +569,39 @@ export function testMod<State extends object, Declared extends Options = Options
502
569
  return { drawing, columns }
503
570
  }
504
571
 
505
- const drawPage = async (pageId: string, columns = defaultColumns) => {
572
+ const drawInSidebar = async (id: string, columns = defaultColumns) => {
506
573
  await start()
507
- const page = shownPage
508
- if (page?.id !== pageId) throw new Error(`The page "${pageId}" of ${name} no longer shows, and a user sees a page only while it shows.`)
509
- const drawn = (await callMod(partMethods.draw, { page: pageId, params: page.params, columns, isFocused: page.isFocused })) as DrawnPart | null
574
+ const shown = shownPage
575
+ if (shown?.id !== id) throw new Error(`The view or page "${id}" of ${name} no longer shows, and a user sees one only while it shows.`)
576
+ const drawn = (await callMod(partMethods.draw, { page: id, params: shown.params, columns, isFocused: shown.isFocused, surface: 'terminal' })) as DrawnPart | null
510
577
  await fake.settle()
511
578
  const tree = drawn?.tree ?? null
512
- const table = withLinks(elements, 'terminal', openFromCmod)
513
- const drawing = tree === null || drawn === null ? elements.Box({}) : await withOwnMarkdown(async () => drawWith(table, () => elementOf(tree, `${name}/${pageId}:`, (handler, args) => void modeling(pressPart({ draw: drawn.draw, handler, args }))), markdownIn(table, { surface: 'terminal', columns })) as RenderElement)
579
+ const table = forClaudeCode(elements, 'terminal', openFromCmod)
580
+ const drawing = tree === null || drawn === null ? elements.Box({}) : await withOwnMarkdown(async () => drawWith(table, () => elementOf(tree, `${name}/${id}:`, (handler, args) => void modeling(pressPart({ draw: drawn.draw, handler, args }))), markdownIn(table, { surface: 'terminal', columns })) as RenderElement)
514
581
  checkKeys(drawing, cmodPluginName, 'Pane')
515
582
  return { drawing, columns }
516
583
  }
517
584
 
518
- const shownNow = (isPane: boolean): { readonly id: string; readonly params: unknown } => {
519
- if (isPane) {
585
+ const shownNow = (kind: 'pane' | 'view' | 'page'): { readonly id: string; readonly params: unknown } => {
586
+ if (kind === 'pane') {
520
587
  const id = [...fake.shown.openPanes].at(-1)
521
588
  if (id === undefined) throw new Error(`No pane of ${name} shows. Open one with pane.open(), from a slash command, a hotkey, or setup.`)
522
589
  return { id, params: undefined }
523
590
  }
524
- if (shownPage === undefined) throw new Error(`No page of ${name} shows in the Sidebar. Open one with page.open(), or Settings with mod.settings.open().`)
591
+ const shownKind = shownPage === undefined ? undefined : declaredPages.some((page) => page.id === shownPage?.id) ? 'page' : 'view'
592
+ if (shownPage === undefined || shownKind !== kind) {
593
+ const opening = kind === 'view' ? 'view.open(), or Settings with mod.settings.open()' : 'page.open()'
594
+ throw new Error(`No ${kind} of ${name} shows in the Sidebar${shownPage === undefined ? '' : `, where its ${shownKind} "${shownPage.id}" shows`}. Open one with ${opening}.`)
595
+ }
525
596
  return shownPage
526
597
  }
527
598
 
528
- const shownPart = (isPane: boolean): ShownPart => {
529
- const kind = isPane ? 'pane' : 'page'
599
+ const shownPart = (kind: 'pane' | 'view' | 'page'): ShownPart => {
600
+ const isPane = kind === 'pane'
530
601
  const draw = async (columns?: number) => {
531
602
  await start()
532
- const { id } = shownNow(isPane)
533
- return { id, ...(isPane ? await drawPane(id, columns) : await drawPage(id, columns)) }
603
+ const { id } = shownNow(kind)
604
+ return { id, ...(isPane ? await drawPane(id, columns) : await drawInSidebar(id, columns)) }
534
605
  }
535
606
  const drawnElement = async (type: 'Button' | 'Input' | 'Select' | 'Markdown', key: string) => {
536
607
  const { id, drawing } = await draw()
@@ -542,10 +613,10 @@ export function testMod<State extends object, Declared extends Options = Options
542
613
  const eventIn = (id: string, key: string) => ({ plugin: name, element: key, component: 'Pane' as const, requestId: id, surface: 'terminal' as const })
543
614
  return {
544
615
  get id() {
545
- return shownNow(isPane).id
616
+ return shownNow(kind).id
546
617
  },
547
618
  get params() {
548
- return shownNow(isPane).params
619
+ return shownNow(kind).params
549
620
  },
550
621
  lines: async (lineOptions) => {
551
622
  const { drawing, columns } = await draw(lineOptions?.columns)
@@ -581,9 +652,9 @@ export function testMod<State extends object, Declared extends Options = Options
581
652
  },
582
653
  async focusedKey() {
583
654
  await start()
584
- const { id } = shownNow(isPane)
655
+ const { id } = shownNow(kind)
585
656
  if (!(await holdsKeyboard(isPane, id))) return undefined
586
- if (focused?.part === `${kind}:${id}`) return focused.key
657
+ if (focused?.part === `${isPane ? 'pane' : 'sidebar'}:${id}`) return focused.key
587
658
  const autoFocused = focusableKey((await draw()).drawing, (props) => props['autoFocus'] === true)
588
659
  return isPane || autoFocused === undefined ? autoFocused : autoFocused.slice(`${name}/${id}:`.length)
589
660
  },
@@ -614,6 +685,12 @@ export function testMod<State extends object, Declared extends Options = Options
614
685
  return { drawing, columns: defaultColumns }
615
686
  }
616
687
 
688
+ const loadSettings = async (answer: EventResult<'classic.ConfigChange'>) => {
689
+ if (answer.block === undefined) await lifecycle.settingsLoaded()
690
+ await fake.settle()
691
+ return answer
692
+ }
693
+
617
694
  const fire = ((event: string, input: object, below?: unknown, signal?: AbortSignal) => {
618
695
  if (event.includes('.')) return route(event as RoutedEvent, input, below, signal)
619
696
  if (event === 'SessionStart') {
@@ -638,6 +715,7 @@ export function testMod<State extends object, Declared extends Options = Options
638
715
  const started = routed.then((answer) => ((answeredId = startedAs), answer))
639
716
  return source === 'startup' || source === 'clear' ? started : started.then(async (answer) => (await tellHeldColor(), answer))
640
717
  }
718
+ if (event === 'ConfigChange') return route('classic.ConfigChange', filled, below, signal).then(loadSettings)
641
719
  if (event !== 'PreToolUse') return route(`classic.${event}` as RoutedEvent, filled, below, signal)
642
720
  return firePreToolUse(filled as ClassicHookInputs['PreToolUse'], below as { deny?: string } | undefined)
643
721
  }) as ClaudeCode['fire']
@@ -708,7 +786,7 @@ export function testMod<State extends object, Declared extends Options = Options
708
786
  return value
709
787
  }
710
788
 
711
- const tested: TestedMod<State> = {
789
+ const tested: TestedMod<State, Given> = {
712
790
  start,
713
791
  raise,
714
792
  fire,
@@ -741,7 +819,7 @@ export function testMod<State extends object, Declared extends Options = Options
741
819
  return rowsOf(drawing, columns).map((row) => row.trimEnd())
742
820
  }
743
821
  const component = componentOf(target as Row)
744
- if (props === undefined || component === undefined) throw new Error(`lines takes an area, such as AbovePrompt, or a row kind, such as ToolCall, with its props, and ${target} is neither. Read a pane with tested.shown.pane.lines() and a page with tested.shown.page.lines().`)
822
+ if (props === undefined || component === undefined) throw new Error(`lines takes an area, such as AbovePrompt, or a row kind, such as ToolCall, with its props, and ${target} is neither. Read a pane with tested.shown.pane.lines(), a view with tested.shown.view.lines(), and a page with tested.shown.page.lines().`)
745
823
  const { drawing, columns } = await drawSlot(component, props, requestId)
746
824
  return rowsOf(drawing, columns).map((row) => row.trimEnd())
747
825
  },
@@ -811,27 +889,31 @@ export function testMod<State extends object, Declared extends Options = Options
811
889
  return lifecycle.toasts
812
890
  },
813
891
  sent: conversations.sent,
814
- pane: shownPart(true),
815
- page: shownPart(false),
892
+ pane: shownPart('pane'),
893
+ view: shownPart('view'),
894
+ page: shownPart('page'),
816
895
  },
896
+ providers: given.map((_each, index) => fakeProvider(index)) as never,
817
897
  }
818
898
  keepClaudeCode(tested, { fire })
819
899
  return tested
820
900
  }
821
901
 
822
- function fakeDependencies(caller: string, dependencies: NonNullable<TestOptions<object>['dependencies']>, conversations: FakeSessions, provides: () => readonly string[]): Claude['cmod']['call'] {
902
+ function fakeDependencies(caller: string, dependencies: NonNullable<TestOptions<object>['dependencies']>, conversations: FakeSessions, served: ServedProviders, sessionMods: ReadonlyMap<string, Providers>): Claude['cmod']['call'] {
823
903
  const cmod = {
824
904
  forkParent: () => null,
825
905
  updateSettings: () => null,
826
- [loadedMethod]: ({ name }: { readonly name: string }) => name === caller || name === cmodPluginName || Object.hasOwn(dependencies, name),
827
- [interfaceMethods.providers]: ({ name }: { readonly name: string }): ProviderList => ({ mods: provides().includes(name) ? [caller] : [], programs: [] }),
906
+ [loadedMethod]: ({ name }: { readonly name: string }) => name === caller || name === cmodPluginName || Object.hasOwn(dependencies, name) || sessionMods.has(name),
828
907
  }
829
908
  const apis = { [cmodPluginName]: cmod, ...dependencies } as Readonly<Record<string, Parameters<typeof answerCall>[1] | undefined>>
909
+ const provided = ({ to, method, input }: Parameters<Claude['cmod']['call']>[0]) => (to === cmodPluginName ? served.answer(method, input, caller) : sessionMods.get(to)?.answer(method, input, caller, new AbortController().signal))
830
910
  return async (call) => {
831
- const served = call.to === cmodPluginName ? conversations.answer(caller, call.method, call.input) : undefined
832
- if (served !== undefined) return calledAnswer(caller, served as EventResult<'cmod.call'>)
911
+ const told = call.to === cmodPluginName ? conversations.answer(caller, call.method, call.input) : undefined
912
+ if (told !== undefined) return calledAnswer(caller, told as EventResult<'cmod.call'>)
913
+ const answered = provided(call)
914
+ if (answered !== undefined) return calledAnswer(caller, await answered.then((value): EventResult<'cmod.call'> => ({ value }), (error: unknown) => ({ deny: messageOf(error) })))
833
915
  const api = apis[call.to]
834
- return calledAnswer(caller, api === undefined ? { deny: notInstalled(call.to) } : await answerCall(call.to, api, call))
916
+ return calledAnswer(caller, api === undefined ? { deny: sessionMods.has(call.to) ? `${call.to} has no method ${call.method}.` : notInstalled(call.to) } : await answerCall(call.to, api, call))
835
917
  }
836
918
  }
837
919
 
package/src/ui/areas.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Mod, Turn } from '../mod.js'
1
+ import type { Mod, Surface, Turn } from '../mod.js'
2
2
 
3
3
  export const AbovePrompt = 'abovePrompt'
4
4
  export const BelowPrompt = 'belowPrompt'
@@ -10,7 +10,7 @@ export const areas = [AbovePrompt, BelowPrompt, Working, TurnEnd, Dashboard] as
10
10
 
11
11
  export type Area = (typeof areas)[number]
12
12
 
13
- export type WidgetContext = { readonly area: typeof TurnEnd; readonly columns: number; readonly turn: Turn } | { readonly area: Exclude<Area, typeof TurnEnd>; readonly columns: number }
13
+ export type WidgetContext = { readonly area: typeof TurnEnd; readonly columns: number; readonly surface: Surface; readonly turn: Turn } | { readonly area: Exclude<Area, typeof TurnEnd>; readonly columns: number; readonly surface: Surface }
14
14
 
15
15
  export type WidgetInit<State extends object = Record<never, never>> = {
16
16
  readonly id: string
@@ -19,6 +19,7 @@ import type {
19
19
  TextProps as ClaudeTextProps,
20
20
  UiPressArgument,
21
21
  } from 'claude-code'
22
+ import type { Surface } from '../mod.js'
22
23
 
23
24
  export type BoxProps = ClaudeBoxProps
24
25
  export type TextProps = ClaudeTextProps
@@ -26,12 +27,12 @@ export type CodeProps = ClaudeCodeProps
26
27
  export type MarkdownProps = ClaudeMarkdownProps
27
28
  export type InputProps = ClaudeInputProps
28
29
  export type SelectProps = ClaudeSelectProps
29
- export type ImageProps = ClaudeImageProps
30
- export type SvgProps = ClaudeSvgProps
31
- export type RasterProps = ClaudeRasterProps
30
+ export type ImageProps = Omit<ClaudeImageProps, 'alt'> & { readonly label: string }
31
+ export type SvgProps = Omit<ClaudeSvgProps, 'alt'> & { readonly label: string }
32
+ export type RasterProps = ClaudeRasterProps & { readonly label: string }
32
33
  export type ClientProps = ClaudeClientProps
33
34
  export type Color = ClaudeColor
34
- export type Press = UiPressArgument
35
+ export type Press = Omit<UiPressArgument, 'surface'> & { readonly surface: Surface }
35
36
 
36
37
  export type ButtonProps = Omit<ClaudeButtonProps, 'onPress'> & ({ readonly onPress: (press: Press) => void; readonly href?: never } | { readonly href: string; readonly onPress?: never })
37
38
 
@@ -100,17 +101,17 @@ const handlerKey = '$cmodHandler'
100
101
 
101
102
  export type Handler = (...args: unknown[]) => unknown
102
103
 
103
- export function elementData(value: unknown, handlers: Handler[]): unknown {
104
- if (typeof value === 'function') return { [handlerKey]: handlers.push(value as Handler) - 1 }
105
- if (Array.isArray(value)) return value.map((each: unknown) => elementData(each, handlers))
104
+ export function elementData(value: unknown, numberOf: (run: Handler) => number): unknown {
105
+ if (typeof value === 'function') return { [handlerKey]: numberOf(value as Handler) }
106
+ if (Array.isArray(value)) return value.map((each: unknown) => elementData(each, numberOf))
106
107
  if (typeof value !== 'object' || value === null) return value
107
108
  if (unbuilt in value) {
108
109
  const { name, props } = (value as Unbuilt)[unbuilt]
109
110
  if (name === 'Client') throw new Error('Client draws only in panes and styles.')
110
- return { [elementKey]: name, props: elementData(props, handlers) }
111
+ return { [elementKey]: name, props: elementData(props, numberOf) }
111
112
  }
112
113
  if (Object.getPrototypeOf(value) !== Object.prototype) throw new Error('a widget draws only the elements of ui/elements.js and ui/components.js, text, numbers, and plain objects.')
113
- return Object.fromEntries(Object.entries(value).map(([key, each]) => [key, elementData(each, handlers)]))
114
+ return Object.fromEntries(Object.entries(value).map(([key, each]) => [key, elementData(each, numberOf)]))
114
115
  }
115
116
 
116
117
  export function elementOf(data: unknown, keyPrefix: string, press: (handler: number, args: readonly unknown[]) => void): unknown {
@@ -139,17 +140,21 @@ export function drawsFocusable(data: unknown, key: string): boolean {
139
140
  return Object.values(fields).some((each) => drawsFocusable(each, key))
140
141
  }
141
142
 
142
- export function withLinks(table: ElementTable, surface: RenderSurface, open: (href: string, press: Press) => void): ElementTable {
143
- const { Button: button, Link: link } = table as CompletedTable
143
+ export function forClaudeCode(table: ElementTable, surface: RenderSurface, open: (href: string, press: UiPressArgument) => void): ElementTable {
144
+ const { Button: button, Link: link, Image: image, Svg: svg, Raster: raster } = table as CompletedTable
144
145
  const opening = (props: Readonly<Record<string, unknown>>) => {
145
146
  const { href, ...rest } = props
146
147
  if (typeof href !== 'string') return button(props)
147
148
  const { label, children } = rest
148
149
  const hasChildren = children !== undefined && !(Array.isArray(children) && children.length === 0)
149
150
  if (surface !== 'terminal' && href.startsWith('https:')) return link({ href, ...(typeof label === 'string' ? { label } : {}), ...(hasChildren ? { children } : {}) })
150
- return button({ ...rest, onPress: (press: Press) => open(href, press) })
151
+ return button({ ...rest, onPress: (press: UiPressArgument) => open(href, press) })
151
152
  }
152
- return { ...table, Button: opening }
153
+ const named =
154
+ (draw: (props: object) => RenderElement) =>
155
+ ({ label, ...rest }: Readonly<Record<string, unknown>>) =>
156
+ draw({ alt: label, ...rest })
157
+ return { ...table, Button: opening, Image: named(image), Svg: named(svg), Raster: ({ label, ...rest }: Readonly<Record<string, unknown>>) => raster(rest) }
153
158
  }
154
159
 
155
160
  export const Box = element('Box')
@@ -160,9 +165,9 @@ export const Code = element('Code')
160
165
  export const Markdown = element('Markdown')
161
166
  export const Input = element('Input')
162
167
  export const Select = element('Select')
163
- export const Image = element('Image')
164
- export const Svg = element('Svg')
165
- export const Raster = element('Raster')
168
+ export const Image = element('Image') as unknown as ElementConstructor<ImageProps>
169
+ export const Svg = element('Svg') as unknown as ElementConstructor<SvgProps>
170
+ export const Raster = element('Raster') as unknown as ElementConstructor<RasterProps>
166
171
  export const Client = element('Client')
167
172
 
168
173
  const constructors = { Box, Text, Button, Link, Code, Markdown, Input, Select, Image, Svg, Raster }
package/src/ui/panes.ts CHANGED
@@ -39,15 +39,15 @@ export type Pane<Params = undefined> = {
39
39
  remove(): void
40
40
  }
41
41
 
42
- export type PageProps<Params> = { readonly params: Params; readonly isFocused: boolean; readonly columns: number }
42
+ export type ViewProps<Params> = { readonly params: Params; readonly isFocused: boolean; readonly columns: number; readonly surface: Surface }
43
43
 
44
- export type PageInit<State extends object = Record<never, never>, Params = undefined> = {
44
+ export type ViewInit<State extends object = Record<never, never>, Params = undefined> = {
45
45
  readonly id: string
46
46
  readonly title: string
47
- render(mod: Mod<State>, props: PageProps<Params>): JSX.Element
47
+ render(mod: Mod<State>, props: ViewProps<Params>): JSX.Element
48
48
  }
49
49
 
50
- export type Page<Params = undefined> = {
50
+ export type View<Params = undefined> = {
51
51
  readonly id: string
52
52
  readonly isOpen: boolean
53
53
  readonly isShown: boolean
@@ -61,17 +61,24 @@ export type Page<Params = undefined> = {
61
61
  remove(): void
62
62
  }
63
63
 
64
+ export type PageProps<Params> = ViewProps<Params>
65
+
66
+ export type PageInit<State extends object = Record<never, never>, Params = undefined> = ViewInit<State, Params>
67
+
68
+ export type Page<Params = undefined> = View<Params>
69
+
64
70
  const partId = /^[A-Za-z0-9_-]{1,64}$/
65
71
 
66
72
  export const sizeKeys = ['columns', 'rows'] as const
67
73
 
68
- export function checkPart(name: string, kind: string, id: string, title: string): void {
74
+ export function checkPart(name: string, kind: string, id: string, title: string, takenBy: string | undefined): void {
69
75
  if (!partId.test(id)) throw new Error(`${name}: "${id}" is not a ${kind} id. Use 1 to 64 letters, digits, "_", or "-".`)
70
76
  if (title.trim() === '') throw new Error(`${name}: the ${kind} "${id}" needs a title, the label its tab shows.`)
77
+ if (takenBy !== undefined) throw new Error(`${name}: the ${takenBy} "${id}" is already added. Give the ${kind} another id.`)
71
78
  }
72
79
 
73
- export function checkPane<State extends object, Params>(name: string, pane: PaneInit<State, Params>): void {
74
- checkPart(name, 'pane', pane.id, pane.title)
80
+ export function checkPane<State extends object, Params>(name: string, pane: PaneInit<State, Params>, takenBy: string | undefined): void {
81
+ checkPart(name, 'pane', pane.id, pane.title, takenBy)
75
82
  for (const key of sizeKeys) {
76
83
  const size = pane[key]
77
84
  if (typeof size !== 'function' && size !== undefined && (!Number.isInteger(size) || size <= 0)) throw new Error(`${name}: the pane "${pane.id}" has ${key} ${size}. Use a whole number above 0, or leave it out.`)
@@ -1,5 +1,6 @@
1
1
  import type { EventResult } from 'claude-code';
2
2
  import type { Claude } from '../runtime/claude.js';
3
+ import type { Device } from '../session/context/turn/device.js';
3
4
  import { type FakeServe } from './fake-serve.js';
4
5
  import type { SessionComputer } from '../runtime/interfaces.js';
5
6
  export type TestCall = {
@@ -71,6 +72,7 @@ export type Fakes = {
71
72
  };
72
73
  serve: Partial<SessionComputer>;
73
74
  };
75
+ export declare const testDevice: Device;
74
76
  export type ShownSchedule = {
75
77
  readonly id: string;
76
78
  readonly cron: string;