clanka 0.8.3 → 0.8.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 (40) hide show
  1. package/dist/AgentExecutor.d.ts.map +1 -1
  2. package/dist/AgentExecutor.js +1 -1
  3. package/dist/AgentExecutor.js.map +1 -1
  4. package/dist/AgentExecutor.test.d.ts +2 -0
  5. package/dist/AgentExecutor.test.d.ts.map +1 -0
  6. package/dist/AgentExecutor.test.js +87 -0
  7. package/dist/AgentExecutor.test.js.map +1 -0
  8. package/dist/AgentSkills.test.js +1 -0
  9. package/dist/AgentSkills.test.js.map +1 -1
  10. package/dist/AgentTools.d.ts.map +1 -1
  11. package/dist/AgentTools.js +2 -1
  12. package/dist/AgentTools.js.map +1 -1
  13. package/dist/Compaction.test.js +1 -0
  14. package/dist/Compaction.test.js.map +1 -1
  15. package/dist/bin/{Effect-BCeySOy1.mjs → Effect-BEUn4I5E.mjs} +339 -288
  16. package/dist/bin/Effect-BEUn4I5E.mjs.map +1 -0
  17. package/dist/bin/{McpClient-DP4jlaD1.mjs → McpClient-C0FVuDj2.mjs} +218 -62
  18. package/dist/bin/McpClient-C0FVuDj2.mjs.map +1 -0
  19. package/dist/bin/{OutputFormatter-Ch8yFytV.mjs → OutputFormatter-DffD5oxX.mjs} +8 -8
  20. package/dist/bin/OutputFormatter-DffD5oxX.mjs.map +1 -0
  21. package/dist/bin/{Schema-C9JQ5hI0.mjs → Schema-CjUGw2Xh.mjs} +480 -384
  22. package/dist/bin/Schema-CjUGw2Xh.mjs.map +1 -0
  23. package/dist/bin/{SemanticSearch-BJGnYhFt.mjs → SemanticSearch-CFB73IPb.mjs} +321 -268
  24. package/dist/bin/SemanticSearch-CFB73IPb.mjs.map +1 -0
  25. package/dist/bin/{Stream-CgH3SuLu.mjs → Stream-Cu6P7ZHo.mjs} +180 -172
  26. package/dist/bin/Stream-Cu6P7ZHo.mjs.map +1 -0
  27. package/dist/bin/cli.mjs +306 -259
  28. package/dist/bin/cli.mjs.map +1 -1
  29. package/package.json +20 -20
  30. package/src/AgentExecutor.test.ts +133 -0
  31. package/src/AgentExecutor.ts +1 -2
  32. package/src/AgentSkills.test.ts +1 -0
  33. package/src/AgentTools.ts +2 -1
  34. package/src/Compaction.test.ts +1 -0
  35. package/dist/bin/Effect-BCeySOy1.mjs.map +0 -1
  36. package/dist/bin/McpClient-DP4jlaD1.mjs.map +0 -1
  37. package/dist/bin/OutputFormatter-Ch8yFytV.mjs.map +0 -1
  38. package/dist/bin/Schema-C9JQ5hI0.mjs.map +0 -1
  39. package/dist/bin/SemanticSearch-BJGnYhFt.mjs.map +0 -1
  40. 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.3",
4
+ "version": "0.8.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,10 +25,10 @@
25
25
  "url": "https://github.com/Effectful-Tech/clanka.git"
26
26
  },
27
27
  "dependencies": {
28
- "@modelcontextprotocol/sdk": "^1.30.0",
28
+ "@modelcontextprotocol/sdk": "^1.32.0",
29
29
  "@silvia-odwyer/photon-node": "^0.3.4",
30
30
  "@vscode/ripgrep": "^1.18.0",
31
- "chalk": "^6.0.0",
31
+ "chalk": "^6.0.1",
32
32
  "glob": "^13.0.6",
33
33
  "sqlite-vec": "0.1.9",
34
34
  "tree-sitter": "^0.21.1",
@@ -37,31 +37,31 @@
37
37
  "turndown": "^7.2.4"
38
38
  },
39
39
  "peerDependencies": {
40
- "@effect/ai-openai": ">=4.0.0-rc.115 <4.0.1",
41
- "@effect/ai-openai-compat": ">=4.0.0-rc.115 <4.0.1",
42
- "@effect/platform-node": ">=4.0.0-rc.115 <4.0.1",
43
- "@effect/sql-sqlite-node": ">=4.0.0-rc.115 <4.0.1",
44
- "effect": ">=4.0.0-rc.115 <4.0.1"
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": "https://pkg.pr.new/Effect-TS/effect/@effect/ai-openai@b3032f0",
50
- "@effect/ai-openai-compat": "https://pkg.pr.new/Effect-TS/effect/@effect/ai-openai-compat@b3032f0",
51
- "@effect/platform-node": "https://pkg.pr.new/Effect-TS/effect/@effect/platform-node@b3032f0",
52
- "@effect/sql-sqlite-node": "https://pkg.pr.new/Effect-TS/effect/@effect/sql-sqlite-node@b3032f0",
53
- "@effect/tsgo": "0.45.0",
54
- "@effect/vitest": "https://pkg.pr.new/Effect-TS/effect/@effect/vitest@b3032f0",
55
- "@types/node": "^26.1.1",
49
+ "@effect/ai-openai": "4.0.1",
50
+ "@effect/ai-openai-compat": "4.0.1",
51
+ "@effect/platform-node": "4.0.0",
52
+ "@effect/sql-sqlite-node": "4.0.1",
53
+ "@effect/tsgo": "0.48.0",
54
+ "@effect/vitest": "4.0.1",
55
+ "@types/node": "^26.6.4",
56
56
  "@types/turndown": "^5.0.6",
57
- "effect": "https://pkg.pr.new/Effect-TS/effect/effect@b3032f0",
57
+ "effect": "4.0.1",
58
58
  "husky": "^9.1.7",
59
- "lint-staged": "^17.5.1",
60
- "oxlint": "^1.83.0",
61
- "prettier": "^3.9.7",
59
+ "lint-staged": "^17.6.0",
60
+ "oxlint": "^1.86.0",
61
+ "prettier": "^3.9.9",
62
62
  "tsdown": "^0.23.0",
63
63
  "typescript": "^7.0.2",
64
- "vitest": "^5.0.1"
64
+ "vitest": "^5.0.3"
65
65
  },
66
66
  "lint-staged": {
67
67
  "*.{ts,tsx}": [
@@ -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
+ })
@@ -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,
@@ -106,6 +106,7 @@ const withLocalExecutor = <A, E, R>(
106
106
  HERMES_HOME: process.env.HERMES_HOME,
107
107
  }
108
108
  process.env.HOME = roots.home
109
+ // @ts-expect-error
109
110
  if (hermesHome === undefined) delete process.env.HERMES_HOME
110
111
  else process.env.HERMES_HOME = hermesHome
111
112
  return previous
package/src/AgentTools.ts CHANGED
@@ -489,7 +489,7 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
489
489
  )
490
490
  }),
491
491
  bash: Effect.fn("AgentTools.bash")(function* (options) {
492
- const timeoutMs = Math.min(options.timeoutMs ?? 120_000, 240_000)
492
+ const timeoutMs = Math.min(options.timeoutMs ?? 600_000, 600_000)
493
493
  yield* Effect.logInfo(`Calling "bash"`).pipe(
494
494
  Effect.annotateLogs({
495
495
  ...options,
@@ -539,6 +539,7 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
539
539
  applyPatch: Effect.fn("AgentTools.applyPatch")(function* (patchText) {
540
540
  yield* Effect.logInfo(`Calling "applyPatch"`)
541
541
  const cwd = yield* CurrentDirectory
542
+ // oxlint-disable-next-line unicorn/consistent-function-scoping
542
543
  const fail = (path: string, reason: "delete" | "update") =>
543
544
  Effect.fail(
544
545
  new ApplyPatchError({
@@ -454,6 +454,7 @@ describe("Compaction.isContextLengthError", () => {
454
454
 
455
455
  describe("Compaction.split", () => {
456
456
  // Each execute result is ~8k chars => ~2k tokens per tool message.
457
+ // oxlint-disable-next-line unicorn/consistent-function-scoping
457
458
  const dump = (i: number) => filler(`dump${i}`, 8_000)
458
459
  const conversation = [
459
460
  user("first request"),