clanka 0.8.5 → 0.9.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/dist/Acp.d.ts.map +1 -1
- package/dist/Acp.js +9 -3
- package/dist/Acp.js.map +1 -1
- package/dist/Acp.test.js +72 -1
- package/dist/Acp.test.js.map +1 -1
- package/dist/AcpImage.test.js +1 -0
- package/dist/AcpImage.test.js.map +1 -1
- package/dist/Agent.d.ts +65 -8
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +481 -113
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +77 -4
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentCallerConfig.test.d.ts +2 -0
- package/dist/AgentCallerConfig.test.d.ts.map +1 -0
- package/dist/AgentCallerConfig.test.js +327 -0
- package/dist/AgentCallerConfig.test.js.map +1 -0
- package/dist/AgentExecutor.d.ts +254 -54
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +416 -99
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.js +201 -31
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentExecutorImage.test.js +2 -1
- package/dist/AgentExecutorImage.test.js.map +1 -1
- package/dist/AgentImage.test.js +5 -1
- package/dist/AgentImage.test.js.map +1 -1
- package/dist/AgentOutput.d.ts +54 -2
- package/dist/AgentOutput.d.ts.map +1 -1
- package/dist/AgentOutput.js +52 -0
- package/dist/AgentOutput.js.map +1 -1
- package/dist/AgentSkills.d.ts +22 -0
- package/dist/AgentSkills.d.ts.map +1 -1
- package/dist/AgentSkills.js +36 -0
- package/dist/AgentSkills.js.map +1 -1
- package/dist/AgentSkills.test.js +2 -0
- package/dist/AgentSkills.test.js.map +1 -1
- package/dist/AgentSubagents.test.d.ts +2 -0
- package/dist/AgentSubagents.test.d.ts.map +1 -0
- package/dist/AgentSubagents.test.js +452 -0
- package/dist/AgentSubagents.test.js.map +1 -0
- package/dist/AgentTools.d.ts +356 -14
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +213 -34
- package/dist/AgentTools.js.map +1 -1
- package/dist/CompactionTransport.test.js +1 -1
- package/dist/CompactionTransport.test.js.map +1 -1
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +16 -2
- package/dist/OutputFormatter.js.map +1 -1
- package/dist/ToolkitRenderer.d.ts.map +1 -1
- package/dist/ToolkitRenderer.js +6 -1
- package/dist/ToolkitRenderer.js.map +1 -1
- package/dist/bin/{Effect-BEUn4I5E.mjs → Effect-2jPlJ8eu.mjs} +399 -207
- package/dist/bin/Effect-2jPlJ8eu.mjs.map +1 -0
- package/dist/bin/{McpClient-C0FVuDj2.mjs → McpClient-1W508adc.mjs} +4 -4
- package/dist/bin/{McpClient-C0FVuDj2.mjs.map → McpClient-1W508adc.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-DffD5oxX.mjs → OutputFormatter-DXXKo4E8.mjs} +16 -5
- package/dist/bin/{OutputFormatter-DffD5oxX.mjs.map → OutputFormatter-DXXKo4E8.mjs.map} +1 -1
- package/dist/bin/{Schema-CjUGw2Xh.mjs → Schema-D-7VuCiC.mjs} +640 -87
- package/dist/bin/Schema-D-7VuCiC.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-CFB73IPb.mjs → SemanticSearch-Cb8aqvGv.mjs} +89 -56
- package/dist/bin/SemanticSearch-Cb8aqvGv.mjs.map +1 -0
- package/dist/bin/{Stream-Cu6P7ZHo.mjs → Stream-DEu2tfCV.mjs} +81 -51
- package/dist/bin/Stream-DEu2tfCV.mjs.map +1 -0
- package/dist/bin/cli.mjs +3632 -5538
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/{turndown.cjs-usmCKZ4b.mjs → turndown.cjs-DK29wZw3.mjs} +2 -2
- package/dist/bin/{turndown.cjs-usmCKZ4b.mjs.map → turndown.cjs-DK29wZw3.mjs.map} +1 -1
- package/package.json +7 -7
- package/src/Acp.test.ts +121 -2
- package/src/Acp.ts +10 -3
- package/src/AcpImage.test.ts +1 -0
- package/src/Agent.test.ts +100 -3
- package/src/Agent.ts +752 -142
- package/src/AgentCallerConfig.test.ts +514 -0
- package/src/AgentExecutor.test.ts +297 -37
- package/src/AgentExecutor.ts +707 -159
- package/src/AgentExecutorImage.test.ts +2 -1
- package/src/AgentImage.test.ts +11 -2
- package/src/AgentOutput.ts +74 -1
- package/src/AgentSkills.test.ts +2 -0
- package/src/AgentSkills.ts +43 -0
- package/src/AgentSubagents.test.ts +758 -0
- package/src/AgentTools.ts +376 -52
- package/src/CompactionTransport.test.ts +1 -1
- package/src/OutputFormatter.ts +16 -2
- package/src/ToolkitRenderer.ts +7 -1
- package/dist/bin/Effect-BEUn4I5E.mjs.map +0 -1
- package/dist/bin/Schema-CjUGw2Xh.mjs.map +0 -1
- package/dist/bin/SemanticSearch-CFB73IPb.mjs.map +0 -1
- package/dist/bin/Stream-Cu6P7ZHo.mjs.map +0 -1
|
@@ -12,6 +12,7 @@ import * as RpcClient from "effect/rpc/RpcClient"
|
|
|
12
12
|
import * as RpcSerialization from "effect/rpc/RpcSerialization"
|
|
13
13
|
import * as RpcServer from "effect/rpc/RpcServer"
|
|
14
14
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
15
|
+
import { subagentsUnavailable } from "./AgentTools.ts"
|
|
15
16
|
import type { ImageAttachment } from "./AgentTools.ts"
|
|
16
17
|
import { equalBytes, supportedImages } from "./fixtures/TestImages.ts"
|
|
17
18
|
|
|
@@ -83,7 +84,7 @@ describe("RPC image executor", () => {
|
|
|
83
84
|
images.push(image)
|
|
84
85
|
}),
|
|
85
86
|
onTaskComplete: () => Effect.void,
|
|
86
|
-
|
|
87
|
+
subagents: subagentsUnavailable,
|
|
87
88
|
})
|
|
88
89
|
.pipe(Stream.runCollect, Effect.timeout("5 seconds"))
|
|
89
90
|
assert.strictEqual(images.length, fixtures.length)
|
package/src/AgentImage.test.ts
CHANGED
|
@@ -19,6 +19,7 @@ const capabilities = new AgentExecutor.Capabilities({
|
|
|
19
19
|
toolsDts: "",
|
|
20
20
|
agentsMd: Option.none(),
|
|
21
21
|
supportsSearch: false,
|
|
22
|
+
tools: [],
|
|
22
23
|
skills: [],
|
|
23
24
|
})
|
|
24
25
|
|
|
@@ -264,8 +265,16 @@ describe("Agent images", () => {
|
|
|
264
265
|
|
|
265
266
|
it.effect("does not copy image bytes into a delegate prompt", () =>
|
|
266
267
|
Effect.gen(function* () {
|
|
267
|
-
const executor = makeExecutor(({
|
|
268
|
-
Stream.fromEffect(
|
|
268
|
+
const executor = makeExecutor(({ subagents }) =>
|
|
269
|
+
Stream.fromEffect(
|
|
270
|
+
subagents.delegate({
|
|
271
|
+
prompt: "child task: describe the layout",
|
|
272
|
+
background: false,
|
|
273
|
+
}),
|
|
274
|
+
).pipe(
|
|
275
|
+
Stream.map((result) => result.output ?? ""),
|
|
276
|
+
Stream.orDie,
|
|
277
|
+
),
|
|
269
278
|
)
|
|
270
279
|
const { exit, calls } = yield* runAgent({
|
|
271
280
|
prompt: imagePrompt,
|
package/src/AgentOutput.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
/** @effect-diagnostics schemaNumber:off */
|
|
5
5
|
import * as Prompt from "effect/ai/Prompt"
|
|
6
6
|
import * as AiError from "effect/ai/AiError"
|
|
7
|
+
import * as Effect from "effect/Effect"
|
|
7
8
|
import * as Schema from "effect/Schema"
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -127,6 +128,14 @@ export class SubagentStart extends Schema.TaggedClass<SubagentStart>()(
|
|
|
127
128
|
prompt: Schema.String,
|
|
128
129
|
model: Schema.String,
|
|
129
130
|
provider: Schema.String,
|
|
131
|
+
/**
|
|
132
|
+
* Background agents report only their start and completion; their
|
|
133
|
+
* output is not streamed.
|
|
134
|
+
*/
|
|
135
|
+
background: Schema.Boolean.pipe(
|
|
136
|
+
Schema.withDecodingDefaultKey(Effect.succeed(false)),
|
|
137
|
+
Schema.withConstructorDefault(Effect.succeed(false)),
|
|
138
|
+
),
|
|
130
139
|
},
|
|
131
140
|
) {
|
|
132
141
|
get modelAndProvider() {
|
|
@@ -142,7 +151,14 @@ export class SubagentComplete extends Schema.TaggedClass<SubagentComplete>()(
|
|
|
142
151
|
"SubagentComplete",
|
|
143
152
|
{
|
|
144
153
|
id: Schema.Number,
|
|
154
|
+
/**
|
|
155
|
+
* The agent's final output, or the error message when it failed.
|
|
156
|
+
*/
|
|
145
157
|
summary: Schema.String,
|
|
158
|
+
status: Schema.Literals(["completed", "failed", "cancelled"]).pipe(
|
|
159
|
+
Schema.withDecodingDefaultKey(Effect.succeed("completed" as const)),
|
|
160
|
+
Schema.withConstructorDefault(Effect.succeed("completed" as const)),
|
|
161
|
+
),
|
|
146
162
|
},
|
|
147
163
|
) {}
|
|
148
164
|
|
|
@@ -239,12 +255,51 @@ export class SubagentPart extends Schema.TaggedClass<SubagentPart>()(
|
|
|
239
255
|
},
|
|
240
256
|
) {}
|
|
241
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Emitted when messages are committed to the agent's history: the user
|
|
260
|
+
* prompt, steering messages, and each model step's response and tool
|
|
261
|
+
* results. Applying `HistoryAppended` and `HistoryReplaced` in order to the
|
|
262
|
+
* history the agent started `send` with reproduces `agent.history`, minus
|
|
263
|
+
* the system message, which is rebuilt on every `send`.
|
|
264
|
+
*
|
|
265
|
+
* Only the top-level agent emits history events. Subagents have no history.
|
|
266
|
+
*
|
|
267
|
+
* @since 1.0.0
|
|
268
|
+
* @category Output
|
|
269
|
+
*/
|
|
270
|
+
export class HistoryAppended extends Schema.TaggedClass<HistoryAppended>()(
|
|
271
|
+
"HistoryAppended",
|
|
272
|
+
{
|
|
273
|
+
messages: Schema.Array(Prompt.Message),
|
|
274
|
+
},
|
|
275
|
+
) {}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Emitted when compaction rewrites the agent's history. `messages` is the
|
|
279
|
+
* whole new history, without the system message.
|
|
280
|
+
*
|
|
281
|
+
* @since 1.0.0
|
|
282
|
+
* @category Output
|
|
283
|
+
*/
|
|
284
|
+
export class HistoryReplaced extends Schema.TaggedClass<HistoryReplaced>()(
|
|
285
|
+
"HistoryReplaced",
|
|
286
|
+
{
|
|
287
|
+
messages: Schema.Array(Prompt.Message),
|
|
288
|
+
},
|
|
289
|
+
) {}
|
|
290
|
+
|
|
242
291
|
/**
|
|
243
292
|
* @since 1.0.0
|
|
244
293
|
* @category Output
|
|
245
294
|
*/
|
|
246
295
|
export type Output =
|
|
247
|
-
|
|
296
|
+
| AgentStart
|
|
297
|
+
| ContentPart
|
|
298
|
+
| SubagentStart
|
|
299
|
+
| SubagentComplete
|
|
300
|
+
| SubagentPart
|
|
301
|
+
| HistoryAppended
|
|
302
|
+
| HistoryReplaced
|
|
248
303
|
|
|
249
304
|
/**
|
|
250
305
|
* @since 1.0.0
|
|
@@ -256,6 +311,8 @@ export const Output = Schema.Union([
|
|
|
256
311
|
SubagentStart,
|
|
257
312
|
SubagentComplete,
|
|
258
313
|
SubagentPart,
|
|
314
|
+
HistoryAppended,
|
|
315
|
+
HistoryReplaced,
|
|
259
316
|
])
|
|
260
317
|
|
|
261
318
|
/**
|
|
@@ -268,3 +325,19 @@ export class AgentFinished extends Schema.TaggedError<AgentFinished>()(
|
|
|
268
325
|
summary: Schema.String,
|
|
269
326
|
},
|
|
270
327
|
) {}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The `send` stream fails with this error when a model call, or a turn that
|
|
331
|
+
* hit `TurnTimeout`, was retried `MaxRetries` times in a row and still failed.
|
|
332
|
+
* `error` is the last failure.
|
|
333
|
+
*
|
|
334
|
+
* @since 1.0.0
|
|
335
|
+
* @category Output
|
|
336
|
+
*/
|
|
337
|
+
export class RetriesExhausted extends Schema.TaggedError<RetriesExhausted>()(
|
|
338
|
+
"RetriesExhausted",
|
|
339
|
+
{
|
|
340
|
+
retries: Schema.Number,
|
|
341
|
+
error: AiError.AiError,
|
|
342
|
+
},
|
|
343
|
+
) {}
|
package/src/AgentSkills.test.ts
CHANGED
|
@@ -523,6 +523,7 @@ describe("AgentSkills", () => {
|
|
|
523
523
|
toolsDts: "",
|
|
524
524
|
agentsMd: Option.none(),
|
|
525
525
|
supportsSearch: false,
|
|
526
|
+
tools: [],
|
|
526
527
|
})
|
|
527
528
|
assert.deepStrictEqual(capabilities.skills, [])
|
|
528
529
|
})
|
|
@@ -836,6 +837,7 @@ const makeExecutor = (skills: ReadonlyArray<AgentSkills.Skill>) =>
|
|
|
836
837
|
toolsDts: "",
|
|
837
838
|
agentsMd: Option.none(),
|
|
838
839
|
supportsSearch: false,
|
|
840
|
+
tools: [],
|
|
839
841
|
skills,
|
|
840
842
|
}),
|
|
841
843
|
),
|
package/src/AgentSkills.ts
CHANGED
|
@@ -149,6 +149,49 @@ paths when accessing them.
|
|
|
149
149
|
${entries}`)
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* A skill supplied by the caller instead of discovered on the executor. Its
|
|
154
|
+
* content stays on the loop side and is read with `readSkill`.
|
|
155
|
+
*
|
|
156
|
+
* @since 1.0.0
|
|
157
|
+
* @category Models
|
|
158
|
+
*/
|
|
159
|
+
export class ProvidedSkill extends Schema.Class<ProvidedSkill>("ProvidedSkill")(
|
|
160
|
+
{
|
|
161
|
+
name: Schema.String,
|
|
162
|
+
description: Schema.String,
|
|
163
|
+
content: Schema.String,
|
|
164
|
+
},
|
|
165
|
+
) {}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Render the skills prompt section for caller-supplied skills, or `None` for
|
|
169
|
+
* an empty catalog.
|
|
170
|
+
*
|
|
171
|
+
* @since 1.0.0
|
|
172
|
+
* @category Rendering
|
|
173
|
+
*/
|
|
174
|
+
export const renderProvidedCatalog = (
|
|
175
|
+
skills: ReadonlyArray<ProvidedSkill>,
|
|
176
|
+
): Option.Option<string> => {
|
|
177
|
+
if (skills.length === 0) return Option.none()
|
|
178
|
+
const entries = skills
|
|
179
|
+
.map(
|
|
180
|
+
(skill) =>
|
|
181
|
+
`- ${singleLine(skill.name)}: ${singleLine(skill.description)}`,
|
|
182
|
+
)
|
|
183
|
+
.join("\n")
|
|
184
|
+
return Option.some(`# Skills
|
|
185
|
+
|
|
186
|
+
The following skills are available. Each one has instructions for a specific
|
|
187
|
+
kind of task.
|
|
188
|
+
|
|
189
|
+
When a task matches a skill's description, call "readSkill" with its name
|
|
190
|
+
BEFORE proceeding, then follow the instructions it returns.
|
|
191
|
+
|
|
192
|
+
${entries}`)
|
|
193
|
+
}
|
|
194
|
+
|
|
152
195
|
const Frontmatter = Schema.Struct({
|
|
153
196
|
name: Schema.optional(Schema.Unknown),
|
|
154
197
|
description: Schema.String,
|