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.
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +24 -11
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +137 -0
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentTools.d.ts +88 -88
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/OutputFormatter.d.ts +1 -1
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +42 -2
- package/dist/OutputFormatter.js.map +1 -1
- package/dist/OutputFormatter.test.d.ts +2 -0
- package/dist/OutputFormatter.test.d.ts.map +1 -0
- package/dist/OutputFormatter.test.js +93 -0
- package/dist/OutputFormatter.test.js.map +1 -0
- package/dist/bin/{Stream-C51usiew.mjs → AiError-CsvdOsKR.mjs} +533 -74
- package/dist/bin/Latch-B3e9629m.mjs +5 -0
- package/dist/bin/{McpClient-DoPNaNzW.mjs → McpClient-BCxZZgnA.mjs} +2 -3
- package/dist/bin/{OutputFormatter-U02YKTfy.mjs → OutputFormatter-ByMjyBhe.mjs} +40 -4
- package/dist/bin/{Schema-Box_9VZG.mjs → Schema-BfUmMefy.mjs} +5602 -360
- package/dist/bin/{SemanticSearch-CH125AHH.mjs → SemanticSearch-DMzIsoZb.mjs} +80 -68
- package/dist/bin/cli.mjs +849 -1163
- package/dist/bin/{helpers-CljL9OKa.mjs → helpers-Bb68A2Sv.mjs} +2 -2
- package/dist/bin/{index.min-ClUfQ5ji.mjs → index.min-CuA3AuA-.mjs} +1448 -1348
- package/dist/bin/{rolldown-runtime-5zChB7MF.mjs → rolldown-runtime-CXhmmSW5.mjs} +4 -4
- package/dist/bin/{server-HlLriZxF.mjs → server-D4nrvZHH.mjs} +2 -2
- package/dist/bin/{turndown.cjs-C2WBxeA-.mjs → turndown.cjs-CwE2EFNQ.mjs} +15 -10
- package/dist/bin/{types-LcwjLVkt.mjs → types-N9Z-HYP0.mjs} +1 -1
- package/dist/bin/{upgrade-HMRGSqq8.mjs → upgrade-t590zYhO.mjs} +5 -6
- package/package.json +15 -15
- package/src/Agent.test.ts +198 -0
- package/src/Agent.ts +28 -11
- package/src/OutputFormatter.test.ts +158 -0
- package/src/OutputFormatter.ts +56 -1
- package/dist/bin/Effect-5XYMLOiB.mjs +0 -5183
- package/dist/bin/Latch-BnrpWMd1.mjs +0 -5
package/src/OutputFormatter.ts
CHANGED
|
@@ -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
|
|
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) {
|