clanka 0.0.3 → 0.0.4
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 +37 -14
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +157 -43
- package/dist/Agent.js.map +1 -1
- package/dist/AgentTools.d.ts +1 -1
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +3 -4
- package/dist/AgentTools.js.map +1 -1
- package/dist/Codex.d.ts +1 -1
- package/dist/CodexAuth.d.ts +4 -4
- package/dist/Executor.d.ts.map +1 -1
- package/dist/Executor.js +1 -1
- package/dist/Executor.js.map +1 -1
- package/dist/OutputFormatter.d.ts +3 -3
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +43 -54
- package/dist/OutputFormatter.js.map +1 -1
- package/package.json +2 -2
- package/src/Agent.ts +213 -79
- package/src/AgentTools.ts +3 -4
- package/src/Executor.ts +0 -1
- package/src/OutputFormatter.ts +44 -68
package/src/OutputFormatter.ts
CHANGED
|
@@ -1,101 +1,77 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import type
|
|
4
|
+
import { Stream } from "effect"
|
|
5
|
+
import { type Output, AgentFinished } from "./Agent.ts"
|
|
6
6
|
import chalk from "chalk"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @since 1.0.0
|
|
10
10
|
* @category Models
|
|
11
11
|
*/
|
|
12
|
-
export type OutputFormatter<E = never, R = never> =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
never,
|
|
16
|
-
E,
|
|
17
|
-
R
|
|
18
|
-
>
|
|
12
|
+
export type OutputFormatter<E = never, R = never> = (
|
|
13
|
+
stream: Stream.Stream<Output, AgentFinished>,
|
|
14
|
+
) => Stream.Stream<string, E, R>
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
* @category Pretty
|
|
19
|
+
*/
|
|
20
|
+
export const pretty: OutputFormatter = (stream) =>
|
|
21
|
+
stream.pipe(
|
|
22
|
+
Stream.map((output) => {
|
|
23
|
+
let prefix = ""
|
|
24
|
+
if (output._tag === "SubagentPart") {
|
|
25
|
+
prefix = chalk.magenta(`Subagent #${output.id}:`) + " "
|
|
26
|
+
output = output.part
|
|
27
|
+
}
|
|
24
28
|
switch (output._tag) {
|
|
25
|
-
case "
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.log(
|
|
39
|
-
chalkSubagentHeading(
|
|
40
|
-
`${subagentIcon} Subagent #${output.id} complete`,
|
|
41
|
-
),
|
|
42
|
-
)
|
|
43
|
-
console.log("")
|
|
44
|
-
console.log(finished.summary)
|
|
45
|
-
console.log("")
|
|
46
|
-
return Effect.void
|
|
47
|
-
}),
|
|
48
|
-
Effect.forkChild,
|
|
29
|
+
case "SubagentStart": {
|
|
30
|
+
return `${chalkSubagentHeading(`${subagentIcon} Subagent #${output.id} starting (${output.modelAndProvider})`)}
|
|
31
|
+
|
|
32
|
+
${chalk.dim(output.prompt)}\n\n`
|
|
33
|
+
}
|
|
34
|
+
case "SubagentComplete": {
|
|
35
|
+
return `${chalkSubagentHeading(`${subagentIcon} Subagent #${output.id} complete`)}
|
|
36
|
+
|
|
37
|
+
${output.summary}\n\n`
|
|
38
|
+
}
|
|
39
|
+
case "ReasoningStart": {
|
|
40
|
+
return (
|
|
41
|
+
prefix + chalkReasoningHeading(`${thinkingIcon} Thinking:`) + " "
|
|
49
42
|
)
|
|
50
43
|
}
|
|
51
44
|
case "ReasoningDelta": {
|
|
52
|
-
|
|
53
|
-
hadReasoningDelta = true
|
|
54
|
-
break
|
|
45
|
+
return output.delta
|
|
55
46
|
}
|
|
56
47
|
case "ReasoningEnd": {
|
|
57
|
-
|
|
58
|
-
console.log("\n")
|
|
59
|
-
hadReasoningDelta = false
|
|
60
|
-
}
|
|
61
|
-
break
|
|
48
|
+
return "\n\n"
|
|
62
49
|
}
|
|
63
50
|
case "ScriptStart": {
|
|
64
|
-
|
|
65
|
-
prefix + chalkScriptHeading(`${scriptIcon} Executing script`),
|
|
66
|
-
)
|
|
67
|
-
console.log("")
|
|
68
|
-
console.log(chalk.dim(output.script))
|
|
69
|
-
console.log("")
|
|
70
|
-
break
|
|
51
|
+
return `${prefix}${chalkScriptHeading(`${scriptIcon} Executing script`)}\n\n${chalk.dim(output.script)}\n\n`
|
|
71
52
|
}
|
|
72
53
|
case "ScriptEnd": {
|
|
73
|
-
console.log(
|
|
74
|
-
prefix + chalkScriptHeading(`${scriptIcon} Script output`),
|
|
75
|
-
)
|
|
76
|
-
console.log("")
|
|
77
54
|
const lines = output.output.split("\n")
|
|
78
55
|
const truncated =
|
|
79
56
|
lines.length > 20
|
|
80
57
|
? lines.slice(0, 20).join("\n") + "\n... (truncated)"
|
|
81
58
|
: output.output
|
|
82
|
-
|
|
83
|
-
console.log(chalk.reset(""))
|
|
84
|
-
break
|
|
59
|
+
return `${prefix}${chalkScriptHeading(`${scriptIcon} Script output`)}\n\n${chalk.dim(truncated)}\n\n`
|
|
85
60
|
}
|
|
86
61
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*/
|
|
95
|
-
export const pretty: OutputFormatter = prettyPrefixed("")
|
|
62
|
+
}),
|
|
63
|
+
Stream.catch((finished) =>
|
|
64
|
+
Stream.succeed(
|
|
65
|
+
`\n${chalk.bold.green(`${doneIcon} Task complete:`)}\n\n${finished.summary}`,
|
|
66
|
+
),
|
|
67
|
+
),
|
|
68
|
+
)
|
|
96
69
|
|
|
97
70
|
const chalkScriptHeading = chalk.bold.blue
|
|
98
71
|
const chalkSubagentHeading = chalk.bold.magenta
|
|
72
|
+
const chalkReasoningHeading = chalk.bold.yellow
|
|
99
73
|
|
|
100
74
|
const scriptIcon = "\u{f0bc1}"
|
|
101
75
|
const subagentIcon = "\u{ee0d} "
|
|
76
|
+
const thinkingIcon = "\u{f07f6}"
|
|
77
|
+
const doneIcon = "\u{eab2}"
|