clanka 0.8.3 → 0.8.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/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +1 -1
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.d.ts +2 -0
- package/dist/AgentExecutor.test.d.ts.map +1 -0
- package/dist/AgentExecutor.test.js +87 -0
- package/dist/AgentExecutor.test.js.map +1 -0
- package/dist/bin/{Effect-BCeySOy1.mjs → Effect-BmOuzEIp.mjs} +243 -215
- package/dist/bin/Effect-BmOuzEIp.mjs.map +1 -0
- package/dist/bin/{McpClient-DP4jlaD1.mjs → McpClient-CLpFJSre.mjs} +3 -3
- package/dist/bin/{McpClient-DP4jlaD1.mjs.map → McpClient-CLpFJSre.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-Ch8yFytV.mjs → OutputFormatter-C_gdNUl1.mjs} +3 -3
- package/dist/bin/{OutputFormatter-Ch8yFytV.mjs.map → OutputFormatter-C_gdNUl1.mjs.map} +1 -1
- package/dist/bin/{Schema-C9JQ5hI0.mjs → Schema-C7W9nQug.mjs} +477 -382
- package/dist/bin/Schema-C7W9nQug.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-BJGnYhFt.mjs → SemanticSearch-cqSnq90g.mjs} +269 -228
- package/dist/bin/SemanticSearch-cqSnq90g.mjs.map +1 -0
- package/dist/bin/{Stream-CgH3SuLu.mjs → Stream-BI6Fx9yq.mjs} +179 -171
- package/dist/bin/Stream-BI6Fx9yq.mjs.map +1 -0
- package/dist/bin/cli.mjs +169 -201
- package/dist/bin/cli.mjs.map +1 -1
- package/package.json +12 -12
- package/src/AgentExecutor.test.ts +133 -0
- package/src/AgentExecutor.ts +1 -2
- package/dist/bin/Effect-BCeySOy1.mjs.map +0 -1
- package/dist/bin/Schema-C9JQ5hI0.mjs.map +0 -1
- package/dist/bin/SemanticSearch-BJGnYhFt.mjs.map +0 -1
- package/dist/bin/Stream-CgH3SuLu.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clanka",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
"turndown": "^7.2.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@effect/ai-openai": "
|
|
41
|
-
"@effect/ai-openai-compat": "
|
|
42
|
-
"@effect/platform-node": "
|
|
43
|
-
"@effect/sql-sqlite-node": "
|
|
44
|
-
"effect": "
|
|
40
|
+
"@effect/ai-openai": "^4.0.0",
|
|
41
|
+
"@effect/ai-openai-compat": "^4.0.0",
|
|
42
|
+
"@effect/platform-node": "^4.0.0",
|
|
43
|
+
"@effect/sql-sqlite-node": "^4.0.0",
|
|
44
|
+
"effect": "^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@changesets/changelog-github": "^1.0.1",
|
|
48
48
|
"@changesets/cli": "^3.0.3",
|
|
49
|
-
"@effect/ai-openai": "
|
|
50
|
-
"@effect/ai-openai-compat": "
|
|
51
|
-
"@effect/platform-node": "
|
|
52
|
-
"@effect/sql-sqlite-node": "
|
|
49
|
+
"@effect/ai-openai": "4.0.0",
|
|
50
|
+
"@effect/ai-openai-compat": "4.0.0",
|
|
51
|
+
"@effect/platform-node": "4.0.0",
|
|
52
|
+
"@effect/sql-sqlite-node": "4.0.0",
|
|
53
53
|
"@effect/tsgo": "0.45.0",
|
|
54
|
-
"@effect/vitest": "
|
|
54
|
+
"@effect/vitest": "4.0.0",
|
|
55
55
|
"@types/node": "^26.1.1",
|
|
56
56
|
"@types/turndown": "^5.0.6",
|
|
57
|
-
"effect": "
|
|
57
|
+
"effect": "4.0.0",
|
|
58
58
|
"husky": "^9.1.7",
|
|
59
59
|
"lint-staged": "^17.5.1",
|
|
60
60
|
"oxlint": "^1.83.0",
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { assert, describe, it } from "@effect/vitest"
|
|
2
|
+
import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer"
|
|
3
|
+
import * as NodeServices from "@effect/platform-node/NodeServices"
|
|
4
|
+
import * as Deferred from "effect/Deferred"
|
|
5
|
+
import * as Effect from "effect/Effect"
|
|
6
|
+
import * as FileSystem from "effect/FileSystem"
|
|
7
|
+
import * as Layer from "effect/Layer"
|
|
8
|
+
import * as Stream from "effect/Stream"
|
|
9
|
+
import * as HttpServer from "effect/http/HttpServer"
|
|
10
|
+
import * as RpcClient from "effect/rpc/RpcClient"
|
|
11
|
+
import * as RpcSerialization from "effect/rpc/RpcSerialization"
|
|
12
|
+
import * as RpcServer from "effect/rpc/RpcServer"
|
|
13
|
+
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
14
|
+
|
|
15
|
+
const withRpc = <A, E, R>(
|
|
16
|
+
f: (
|
|
17
|
+
executor: AgentExecutor.AgentExecutor["Service"],
|
|
18
|
+
) => Effect.Effect<A, E, R>,
|
|
19
|
+
) =>
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
const fs = yield* FileSystem.FileSystem
|
|
22
|
+
const directory = yield* fs.makeTempDirectoryScoped()
|
|
23
|
+
const { protocol, httpEffect } =
|
|
24
|
+
yield* RpcServer.makeProtocolWithHttpEffect()
|
|
25
|
+
yield* Layer.build(
|
|
26
|
+
AgentExecutor.layerRpcServer({ directory }).pipe(
|
|
27
|
+
Layer.provide(Layer.succeed(RpcServer.Protocol, protocol)),
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
yield* HttpServer.serveEffect(httpEffect)
|
|
31
|
+
return yield* Effect.gen(function* () {
|
|
32
|
+
const executor = yield* AgentExecutor.AgentExecutor
|
|
33
|
+
return yield* f(executor).pipe(Effect.timeout("2 seconds"))
|
|
34
|
+
}).pipe(
|
|
35
|
+
Effect.provide(
|
|
36
|
+
AgentExecutor.layerRpc.pipe(
|
|
37
|
+
Layer.provide(RpcClient.layerProtocolHttp({ url: "" })),
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
)
|
|
41
|
+
}).pipe(
|
|
42
|
+
Effect.provide(
|
|
43
|
+
Layer.mergeAll(
|
|
44
|
+
RpcSerialization.layerNdjson,
|
|
45
|
+
NodeHttpServer.layerTest,
|
|
46
|
+
NodeServices.layer,
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
Effect.scoped,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
describe("RPC subagent executor", () => {
|
|
53
|
+
it.live("routes concurrent delegates to their originating scripts", () =>
|
|
54
|
+
withRpc((executor) =>
|
|
55
|
+
Effect.gen(function* () {
|
|
56
|
+
const firstStarted = yield* Deferred.make<void>()
|
|
57
|
+
const secondStarted = yield* Deferred.make<void>()
|
|
58
|
+
const outputs = yield* Effect.all(
|
|
59
|
+
[
|
|
60
|
+
executor
|
|
61
|
+
.execute({
|
|
62
|
+
script: 'console.log("first:" + await delegate("first"))',
|
|
63
|
+
onTaskComplete: () => Effect.void,
|
|
64
|
+
onImage: () => Effect.void,
|
|
65
|
+
onSubagent: (prompt) =>
|
|
66
|
+
Effect.gen(function* () {
|
|
67
|
+
assert.isTrue(prompt.endsWith("\n\nfirst"))
|
|
68
|
+
yield* Deferred.succeed(firstStarted, undefined)
|
|
69
|
+
yield* Deferred.await(secondStarted)
|
|
70
|
+
return "first-output"
|
|
71
|
+
}),
|
|
72
|
+
})
|
|
73
|
+
.pipe(Stream.runCollect),
|
|
74
|
+
executor
|
|
75
|
+
.execute({
|
|
76
|
+
script: 'console.log("second:" + await delegate("second"))',
|
|
77
|
+
onTaskComplete: () => Effect.void,
|
|
78
|
+
onImage: () => Effect.void,
|
|
79
|
+
onSubagent: (prompt) =>
|
|
80
|
+
Effect.gen(function* () {
|
|
81
|
+
assert.isTrue(prompt.endsWith("\n\nsecond"))
|
|
82
|
+
yield* Deferred.succeed(secondStarted, undefined)
|
|
83
|
+
yield* Deferred.await(firstStarted)
|
|
84
|
+
return "second-output"
|
|
85
|
+
}),
|
|
86
|
+
})
|
|
87
|
+
.pipe(Stream.runCollect),
|
|
88
|
+
],
|
|
89
|
+
{ concurrency: "unbounded" },
|
|
90
|
+
)
|
|
91
|
+
assert.isTrue(outputs[0].join("").endsWith("first:first-output\n"))
|
|
92
|
+
assert.isTrue(outputs[1].join("").endsWith("second:second-output\n"))
|
|
93
|
+
}),
|
|
94
|
+
),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
it.live(
|
|
98
|
+
"completes nested delegation while the parent stream is waiting",
|
|
99
|
+
() =>
|
|
100
|
+
withRpc((executor) =>
|
|
101
|
+
Effect.gen(function* () {
|
|
102
|
+
const output = yield* executor
|
|
103
|
+
.execute({
|
|
104
|
+
script: 'console.log("parent:" + await delegate("outer"))',
|
|
105
|
+
onTaskComplete: () => Effect.void,
|
|
106
|
+
onImage: () => Effect.void,
|
|
107
|
+
onSubagent: (prompt) =>
|
|
108
|
+
Effect.gen(function* () {
|
|
109
|
+
assert.isTrue(prompt.endsWith("\n\nouter"))
|
|
110
|
+
const childOutput = yield* executor
|
|
111
|
+
.execute({
|
|
112
|
+
script: 'console.log("child:" + await delegate("inner"))',
|
|
113
|
+
onTaskComplete: () => Effect.void,
|
|
114
|
+
onImage: () => Effect.void,
|
|
115
|
+
onSubagent: (innerPrompt) =>
|
|
116
|
+
Effect.sync(() => {
|
|
117
|
+
assert.isTrue(innerPrompt.endsWith("\n\ninner"))
|
|
118
|
+
return "inner-output"
|
|
119
|
+
}),
|
|
120
|
+
})
|
|
121
|
+
.pipe(Stream.runCollect)
|
|
122
|
+
assert.isTrue(
|
|
123
|
+
childOutput.join("").endsWith("child:inner-output\n"),
|
|
124
|
+
)
|
|
125
|
+
return childOutput.join("").trim().split("\n").at(-1)!
|
|
126
|
+
}),
|
|
127
|
+
})
|
|
128
|
+
.pipe(Stream.runCollect)
|
|
129
|
+
assert.isTrue(output.join("").endsWith("parent:child:inner-output\n"))
|
|
130
|
+
}),
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
})
|
package/src/AgentExecutor.ts
CHANGED
|
@@ -422,6 +422,7 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(options: {
|
|
|
422
422
|
number,
|
|
423
423
|
(effect: Effect.Effect<string>) => void
|
|
424
424
|
>()
|
|
425
|
+
let subagentId = 0
|
|
425
426
|
|
|
426
427
|
return Rpcs.of({
|
|
427
428
|
capabilities: () => local.capabilities,
|
|
@@ -438,8 +439,6 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(options: {
|
|
|
438
439
|
typeof ExecuteOutput.Type,
|
|
439
440
|
Cause.Done
|
|
440
441
|
>()
|
|
441
|
-
let subagentId = 0
|
|
442
|
-
|
|
443
442
|
yield* pipe(
|
|
444
443
|
local.execute({
|
|
445
444
|
script,
|