clanka 0.24.3 → 0.24.5

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 (36) hide show
  1. package/dist/Agent.d.ts.map +1 -1
  2. package/dist/Agent.js +24 -11
  3. package/dist/Agent.js.map +1 -1
  4. package/dist/Agent.test.js +137 -0
  5. package/dist/Agent.test.js.map +1 -1
  6. package/dist/AgentTools.d.ts +88 -88
  7. package/dist/AgentTools.d.ts.map +1 -1
  8. package/dist/OutputFormatter.d.ts +1 -1
  9. package/dist/OutputFormatter.d.ts.map +1 -1
  10. package/dist/OutputFormatter.js +42 -2
  11. package/dist/OutputFormatter.js.map +1 -1
  12. package/dist/OutputFormatter.test.d.ts +2 -0
  13. package/dist/OutputFormatter.test.d.ts.map +1 -0
  14. package/dist/OutputFormatter.test.js +93 -0
  15. package/dist/OutputFormatter.test.js.map +1 -0
  16. package/dist/bin/{Stream-C51usiew.mjs → AiError-CsvdOsKR.mjs} +533 -74
  17. package/dist/bin/Latch-B3e9629m.mjs +5 -0
  18. package/dist/bin/{McpClient-DoPNaNzW.mjs → McpClient-BCxZZgnA.mjs} +2 -3
  19. package/dist/bin/{OutputFormatter-U02YKTfy.mjs → OutputFormatter-ByMjyBhe.mjs} +40 -4
  20. package/dist/bin/{Schema-Box_9VZG.mjs → Schema-BfUmMefy.mjs} +5602 -360
  21. package/dist/bin/{SemanticSearch-CH125AHH.mjs → SemanticSearch-DMzIsoZb.mjs} +80 -68
  22. package/dist/bin/cli.mjs +849 -1163
  23. package/dist/bin/{helpers-CljL9OKa.mjs → helpers-Bb68A2Sv.mjs} +2 -2
  24. package/dist/bin/{index.min-ClUfQ5ji.mjs → index.min-CuA3AuA-.mjs} +1448 -1348
  25. package/dist/bin/{rolldown-runtime-5zChB7MF.mjs → rolldown-runtime-CXhmmSW5.mjs} +4 -4
  26. package/dist/bin/{server-HlLriZxF.mjs → server-D4nrvZHH.mjs} +2 -2
  27. package/dist/bin/{turndown.cjs-C2WBxeA-.mjs → turndown.cjs-CwE2EFNQ.mjs} +15 -10
  28. package/dist/bin/{types-LcwjLVkt.mjs → types-N9Z-HYP0.mjs} +1 -1
  29. package/dist/bin/{upgrade-HMRGSqq8.mjs → upgrade-t590zYhO.mjs} +5 -6
  30. package/package.json +15 -15
  31. package/src/Agent.test.ts +198 -0
  32. package/src/Agent.ts +28 -11
  33. package/src/OutputFormatter.test.ts +158 -0
  34. package/src/OutputFormatter.ts +56 -1
  35. package/dist/bin/Effect-5XYMLOiB.mjs +0 -5183
  36. package/dist/bin/Latch-BnrpWMd1.mjs +0 -5
@@ -7,7 +7,12 @@ import * as PubSub from "effect/PubSub"
7
7
  import * as Semaphore from "effect/Semaphore"
8
8
  import * as Context from "effect/Context"
9
9
  import * as Stream from "effect/Stream"
10
- import type { AgentFinished, Output } from "./AgentOutput.ts"
10
+ import {
11
+ type AgentFinished,
12
+ type Output,
13
+ ReasoningEnd,
14
+ ScriptEnd,
15
+ } from "./AgentOutput.ts"
11
16
  import chalk from "chalk"
12
17
  import type * as Prompt from "effect/ai/Prompt"
13
18
  import * as Cause from "effect/Cause"
@@ -49,6 +54,7 @@ export const pretty = (options?: {
49
54
  : identity
50
55
  return (stream) =>
51
56
  stream.pipe(
57
+ deferBlockOutput,
52
58
  Stream.map((output) => {
53
59
  let prefix = ""
54
60
  if (output._tag === "SubagentPart") {
@@ -147,6 +153,54 @@ ${chalk.dim(output.summary)}\n\n`
147
153
  )
148
154
  }
149
155
 
156
+ // Out-of-band updates stay live upstream; presentation waits for an open block.
157
+ const deferBlockOutput = <E, R>(stream: Stream.Stream<Output, E, R>) =>
158
+ Stream.suspend(() => {
159
+ let end: ReasoningEnd | ScriptEnd | undefined
160
+ let pending: Array<Output> = []
161
+ const flush = () => {
162
+ const parts = pending
163
+ pending = []
164
+ return parts
165
+ }
166
+ const finish = () => {
167
+ const parts = pending.length > 0 && end ? [end, ...flush()] : flush()
168
+ end = undefined
169
+ return Stream.fromIterable(parts)
170
+ }
171
+ return stream.pipe(
172
+ Stream.map((output): Array<Output> => {
173
+ const part = output._tag === "SubagentPart" ? output.part : output
174
+ switch (part._tag) {
175
+ case "ReasoningStart":
176
+ end = new ReasoningEnd()
177
+ break
178
+ case "ScriptStart":
179
+ end = new ScriptEnd()
180
+ break
181
+ case "ReasoningEnd":
182
+ case "ScriptEnd":
183
+ end = undefined
184
+ return [output, ...flush()]
185
+ case "ReasoningDelta":
186
+ case "ScriptDelta":
187
+ break
188
+ default:
189
+ if (end) {
190
+ pending.push(output)
191
+ return []
192
+ }
193
+ }
194
+ return [output]
195
+ }),
196
+ Stream.flattenIterable,
197
+ Stream.catchCause((cause) =>
198
+ finish().pipe(Stream.concat(Stream.failCause(cause))),
199
+ ),
200
+ Stream.concat(Stream.suspend(finish)),
201
+ )
202
+ })
203
+
150
204
  const promptToString = (prompt: Prompt.Prompt): string => {
151
205
  let textParts: Array<string> = []
152
206
  for (const message of prompt.content) {
@@ -206,6 +260,7 @@ export const layerMuxer = (formatter: OutputFormatter) =>
206
260
  add(stream) {
207
261
  const id = ++agentCount
208
262
  return stream.pipe(
263
+ deferBlockOutput,
209
264
  Stream.tap(
210
265
  Effect.fnUntraced(function* (part_) {
211
266
  if (currentAgentId === null || id !== currentAgentId) {