clanka 0.7.7 → 0.8.1
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 +4 -4
- package/dist/Acp.d.ts.map +1 -1
- package/dist/Acp.js +8 -6
- package/dist/Acp.js.map +1 -1
- package/dist/Acp.test.js +66 -4
- package/dist/Acp.test.js.map +1 -1
- package/dist/AcpImage.test.js +7 -7
- package/dist/AcpImage.test.js.map +1 -1
- package/dist/Agent.d.ts +8 -8
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +17 -7
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +53 -8
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentExecutor.d.ts +9 -9
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +5 -5
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutorImage.test.js +6 -6
- package/dist/AgentExecutorImage.test.js.map +1 -1
- package/dist/AgentImage.test.js +3 -3
- package/dist/AgentImage.test.js.map +1 -1
- package/dist/AgentOutput.d.ts +10 -2
- package/dist/AgentOutput.d.ts.map +1 -1
- package/dist/AgentOutput.js +10 -2
- package/dist/AgentOutput.js.map +1 -1
- package/dist/AgentSkills.d.ts.map +1 -1
- package/dist/AgentSkills.js +6 -1
- package/dist/AgentSkills.js.map +1 -1
- package/dist/AgentSkills.test.js +21 -4
- package/dist/AgentSkills.test.js.map +1 -1
- package/dist/AgentTools.d.ts +4 -4
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +4 -4
- package/dist/AgentTools.js.map +1 -1
- package/dist/AgentToolsImage.test.js +2 -2
- package/dist/AgentToolsImage.test.js.map +1 -1
- package/dist/ChunkRepo.d.ts +10 -10
- package/dist/ChunkRepo.d.ts.map +1 -1
- package/dist/ChunkRepo.js +7 -7
- package/dist/ChunkRepo.js.map +1 -1
- package/dist/ChunkRepo.test.js +2 -2
- package/dist/ChunkRepo.test.js.map +1 -1
- package/dist/CodeChunker.d.ts +1 -1
- package/dist/CodeChunker.d.ts.map +1 -1
- package/dist/CodeChunker.js +2 -2
- package/dist/CodeChunker.js.map +1 -1
- package/dist/Codex.d.ts +5 -5
- package/dist/Codex.d.ts.map +1 -1
- package/dist/Codex.js +1 -1
- package/dist/Codex.js.map +1 -1
- package/dist/CodexAuth.d.ts +2 -2
- package/dist/CodexAuth.d.ts.map +1 -1
- package/dist/CodexAuth.js +6 -6
- package/dist/CodexAuth.js.map +1 -1
- package/dist/CodexAuth.test.js +3 -3
- package/dist/CodexAuth.test.js.map +1 -1
- package/dist/Compaction.d.ts +3 -3
- package/dist/Compaction.d.ts.map +1 -1
- package/dist/Compaction.js +3 -3
- package/dist/Compaction.js.map +1 -1
- package/dist/Compaction.test.js +3 -3
- package/dist/Compaction.test.js.map +1 -1
- package/dist/CompactionImage.test.js +4 -4
- package/dist/CompactionImage.test.js.map +1 -1
- package/dist/CompactionTokens.test.js +3 -3
- package/dist/CompactionTokens.test.js.map +1 -1
- package/dist/CompactionTransport.test.js +5 -5
- package/dist/CompactionTransport.test.js.map +1 -1
- package/dist/Copilot.d.ts +3 -3
- package/dist/Copilot.d.ts.map +1 -1
- package/dist/Copilot.js +1 -1
- package/dist/Copilot.js.map +1 -1
- package/dist/CopilotAuth.d.ts +2 -2
- package/dist/CopilotAuth.d.ts.map +1 -1
- package/dist/CopilotAuth.js +4 -4
- package/dist/CopilotAuth.js.map +1 -1
- package/dist/CopilotAuth.test.js +2 -2
- package/dist/CopilotAuth.test.js.map +1 -1
- package/dist/GlobalWebSocket.d.ts +1 -1
- package/dist/GlobalWebSocket.d.ts.map +1 -1
- package/dist/GlobalWebSocket.js +1 -1
- package/dist/GlobalWebSocket.js.map +1 -1
- package/dist/Image.d.ts +2 -2
- package/dist/Image.d.ts.map +1 -1
- package/dist/Image.js +3 -3
- package/dist/Image.js.map +1 -1
- package/dist/Image.test.js +2 -2
- package/dist/Image.test.js.map +1 -1
- package/dist/SemanticSearch.d.ts +3 -3
- package/dist/SemanticSearch.d.ts.map +1 -1
- package/dist/SemanticSearch.js +1 -1
- package/dist/SemanticSearch.js.map +1 -1
- package/dist/Sqlite.d.ts +2 -2
- package/dist/Sqlite.d.ts.map +1 -1
- package/dist/Sqlite.js +1 -1
- package/dist/Sqlite.js.map +1 -1
- package/dist/ToolkitRenderer.d.ts +2 -2
- package/dist/ToolkitRenderer.d.ts.map +1 -1
- package/dist/WebToMarkdown.d.ts +2 -2
- package/dist/WebToMarkdown.d.ts.map +1 -1
- package/dist/WebToMarkdown.js +1 -1
- package/dist/WebToMarkdown.js.map +1 -1
- package/dist/WebToMarkdown.test.js +1 -1
- package/dist/WebToMarkdown.test.js.map +1 -1
- package/dist/Xai.d.ts +10 -3
- package/dist/Xai.d.ts.map +1 -1
- package/dist/Xai.js +26 -2
- package/dist/Xai.js.map +1 -1
- package/dist/Xai.test.js +38 -4
- package/dist/Xai.test.js.map +1 -1
- package/dist/XaiAuth.d.ts +2 -2
- package/dist/XaiAuth.d.ts.map +1 -1
- package/dist/XaiAuth.js +4 -4
- package/dist/XaiAuth.js.map +1 -1
- package/dist/XaiAuth.test.js +2 -2
- package/dist/XaiAuth.test.js.map +1 -1
- package/dist/bin/{Effect-CeAMoJlg.mjs → Effect-DvI8YVcR.mjs} +81 -387
- package/dist/bin/Effect-DvI8YVcR.mjs.map +1 -0
- package/dist/bin/{McpClient-zQibhsnA.mjs → McpClient-CM7u8ZVd.mjs} +3 -3
- package/dist/bin/{McpClient-zQibhsnA.mjs.map → McpClient-CM7u8ZVd.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-C7Awn0DS.mjs → OutputFormatter-BpggeGvI.mjs} +3 -3
- package/dist/bin/{OutputFormatter-C7Awn0DS.mjs.map → OutputFormatter-BpggeGvI.mjs.map} +1 -1
- package/dist/bin/{Schema-Bc06DxcV.mjs → Schema-DyJ738Wp.mjs} +1979 -1663
- package/dist/bin/Schema-DyJ738Wp.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-BPxQoRSC.mjs → SemanticSearch-BHUGFT1y.mjs} +46 -42
- package/dist/bin/SemanticSearch-BHUGFT1y.mjs.map +1 -0
- package/dist/bin/{Stream-DlGXvw0L.mjs → Stream-Dg7AGCgJ.mjs} +60 -61
- package/dist/bin/Stream-Dg7AGCgJ.mjs.map +1 -0
- package/dist/bin/cli.mjs +614 -371
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/cli.js +7 -5
- package/dist/cli.js.map +1 -1
- package/dist/fixtures/TestImages.js +2 -2
- package/dist/fixtures/TestImages.js.map +1 -1
- package/package.json +7 -7
- package/src/Acp.test.ts +107 -5
- package/src/Acp.ts +10 -8
- package/src/AcpImage.test.ts +9 -9
- package/src/Agent.test.ts +61 -9
- package/src/Agent.ts +20 -10
- package/src/AgentExecutor.ts +8 -8
- package/src/AgentExecutorImage.test.ts +6 -6
- package/src/AgentImage.test.ts +5 -5
- package/src/AgentOutput.ts +10 -2
- package/src/AgentSkills.test.ts +81 -37
- package/src/AgentSkills.ts +5 -1
- package/src/AgentTools.ts +5 -5
- package/src/AgentToolsImage.test.ts +4 -4
- package/src/ChunkRepo.test.ts +2 -2
- package/src/ChunkRepo.ts +7 -7
- package/src/CodeChunker.ts +2 -2
- package/src/Codex.ts +4 -4
- package/src/CodexAuth.test.ts +3 -3
- package/src/CodexAuth.ts +6 -6
- package/src/Compaction.test.ts +3 -3
- package/src/Compaction.ts +3 -3
- package/src/CompactionImage.test.ts +4 -4
- package/src/CompactionTokens.test.ts +3 -3
- package/src/CompactionTransport.test.ts +6 -6
- package/src/Copilot.ts +2 -2
- package/src/CopilotAuth.test.ts +2 -6
- package/src/CopilotAuth.ts +4 -4
- package/src/GlobalWebSocket.ts +1 -1
- package/src/Image.test.ts +2 -2
- package/src/Image.ts +4 -4
- package/src/OutputFormatter.ts +1 -1
- package/src/SemanticSearch.test.ts +1 -1
- package/src/SemanticSearch.ts +3 -3
- package/src/Sqlite.ts +1 -1
- package/src/ToolkitRenderer.ts +2 -2
- package/src/WebToMarkdown.test.ts +1 -1
- package/src/WebToMarkdown.ts +2 -2
- package/src/Xai.test.ts +67 -8
- package/src/Xai.ts +52 -3
- package/src/XaiAuth.test.ts +2 -2
- package/src/XaiAuth.ts +4 -4
- package/src/cli.ts +9 -7
- package/src/fixtures/TestImages.ts +2 -2
- package/src/fixtures/patch13-broken.txt +4 -4
- package/src/fixtures/patch13-fixed.txt +4 -4
- package/dist/bin/Effect-CeAMoJlg.mjs.map +0 -1
- package/dist/bin/Schema-Bc06DxcV.mjs.map +0 -1
- package/dist/bin/SemanticSearch-BPxQoRSC.mjs.map +0 -1
- package/dist/bin/Stream-DlGXvw0L.mjs.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --optimize-for-size
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Prompt from "effect/
|
|
3
|
+
import * as Prompt from "effect/cli/Prompt";
|
|
4
4
|
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
|
|
5
|
-
import * as Command from "effect/
|
|
6
|
-
import * as Flag from "effect/
|
|
5
|
+
import * as Command from "effect/cli/Command";
|
|
6
|
+
import * as Flag from "effect/cli/Flag";
|
|
7
7
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
8
8
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
9
9
|
import * as GlobalWebSocket from "./GlobalWebSocket.js";
|
|
@@ -22,7 +22,7 @@ import * as Logger from "effect/Logger";
|
|
|
22
22
|
import * as Path from "effect/Path";
|
|
23
23
|
import * as Schema from "effect/Schema";
|
|
24
24
|
import * as Config from "effect/Config";
|
|
25
|
-
import * as KeyValueStore from "effect/
|
|
25
|
+
import * as KeyValueStore from "effect/persistence/KeyValueStore";
|
|
26
26
|
import * as Option from "effect/Option";
|
|
27
27
|
import { OpenAiClient, OpenAiEmbeddingModel } from "@effect/ai-openai";
|
|
28
28
|
import * as DeviceCodeHandler from "./DeviceCodeHandler.js";
|
|
@@ -37,7 +37,9 @@ const withSubagentModel = (model) => Layer.merge(model, Agent.layerSubagentModel
|
|
|
37
37
|
const modelLayer = (provider, model, effort) => provider === "openai"
|
|
38
38
|
? withSubagentModel(Codex.modelWebSocket(model, { reasoning: { effort: effort } })).pipe(Layer.provide(Codex.layerClient))
|
|
39
39
|
: provider === "xai"
|
|
40
|
-
? withSubagentModel(Xai.
|
|
40
|
+
? withSubagentModel(Xai.modelWebSocket(model, {
|
|
41
|
+
reasoning: { effort: effort },
|
|
42
|
+
})).pipe(Layer.provide(Xai.layerClient))
|
|
41
43
|
: withSubagentModel(Copilot.model(model, { reasoning: { effort } })).pipe(Layer.provide(Copilot.layerClient));
|
|
42
44
|
const isProvider = (provider) => providers.includes(provider);
|
|
43
45
|
// `<provider>/<model>/<effort>` as accepted by the `acp` --model flag.
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,KAAK,WAAW,MAAM,mCAAmC,CAAA;AAChE,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAA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2
2
|
import * as Zlib from "node:zlib";
|
|
3
|
-
import * as
|
|
3
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
4
4
|
export const encodePng = (options) => {
|
|
5
5
|
const { width, height } = options;
|
|
6
6
|
const pixels = new Uint8Array(width * height * 4);
|
|
@@ -254,7 +254,7 @@ export const bytesOf = (data) => {
|
|
|
254
254
|
const base64 = data.startsWith("data:")
|
|
255
255
|
? data.slice(data.indexOf(",") + 1)
|
|
256
256
|
: data;
|
|
257
|
-
const decoded =
|
|
257
|
+
const decoded = Base64.decode(base64);
|
|
258
258
|
if (decoded._tag === "Failure")
|
|
259
259
|
throw new Error("Invalid base64 image data");
|
|
260
260
|
return decoded.success;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestImages.js","sourceRoot":"","sources":["../../src/fixtures/TestImages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAA;AACpD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"TestImages.js","sourceRoot":"","sources":["../../src/fixtures/TestImages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAA;AACpD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAEhD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAIzB,EAAc,EAAE;IACf,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IACjC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,CAAA;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,E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CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACrC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC5E,OAAO,OAAO,CAAC,OAAO,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAa,EAAE,CAAa,EAAW,EAAE,CAClE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clanka",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -46,15 +46,15 @@
|
|
|
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": "https://pkg.pr.new/Effect-TS/effect/@effect/ai-openai@24fa0ab",
|
|
50
|
+
"@effect/ai-openai-compat": "https://pkg.pr.new/Effect-TS/effect/@effect/ai-openai-compat@24fa0ab",
|
|
51
|
+
"@effect/platform-node": "https://pkg.pr.new/Effect-TS/effect/@effect/platform-node@24fa0ab",
|
|
52
|
+
"@effect/sql-sqlite-node": "https://pkg.pr.new/Effect-TS/effect/@effect/sql-sqlite-node@24fa0ab",
|
|
53
53
|
"@effect/tsgo": "0.45.0",
|
|
54
|
-
"@effect/vitest": "
|
|
54
|
+
"@effect/vitest": "https://pkg.pr.new/Effect-TS/effect/@effect/vitest@24fa0ab",
|
|
55
55
|
"@types/node": "^26.1.1",
|
|
56
56
|
"@types/turndown": "^5.0.6",
|
|
57
|
-
"effect": "
|
|
57
|
+
"effect": "https://pkg.pr.new/Effect-TS/effect/effect@24fa0ab",
|
|
58
58
|
"husky": "^9.1.7",
|
|
59
59
|
"lint-staged": "^17.5.1",
|
|
60
60
|
"oxlint": "^1.83.0",
|
package/src/Acp.test.ts
CHANGED
|
@@ -4,11 +4,11 @@ import * as Fiber from "effect/Fiber"
|
|
|
4
4
|
import * as Layer from "effect/Layer"
|
|
5
5
|
import * as Option from "effect/Option"
|
|
6
6
|
import * as Stream from "effect/Stream"
|
|
7
|
-
import * as Prompt from "effect/
|
|
8
|
-
import * as KeyValueStore from "effect/
|
|
9
|
-
import * as LanguageModel from "effect/
|
|
10
|
-
import * as Model from "effect/
|
|
11
|
-
import type * as Response from "effect/
|
|
7
|
+
import * as Prompt from "effect/ai/Prompt"
|
|
8
|
+
import * as KeyValueStore from "effect/persistence/KeyValueStore"
|
|
9
|
+
import * as LanguageModel from "effect/ai/LanguageModel"
|
|
10
|
+
import * as Model from "effect/ai/Model"
|
|
11
|
+
import type * as Response from "effect/ai/Response"
|
|
12
12
|
import * as Acp from "./Acp.ts"
|
|
13
13
|
import * as Agent from "./Agent.ts"
|
|
14
14
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
@@ -154,6 +154,108 @@ describe("Acp", () => {
|
|
|
154
154
|
),
|
|
155
155
|
)
|
|
156
156
|
|
|
157
|
+
it.effect("reports cache usage in the ACP usage extension", () =>
|
|
158
|
+
withStore(
|
|
159
|
+
Effect.scoped(
|
|
160
|
+
Effect.gen(function* () {
|
|
161
|
+
const server = yield* makeServer(() =>
|
|
162
|
+
parts(
|
|
163
|
+
{ type: "text-start", id: "1" },
|
|
164
|
+
{ type: "text-delta", id: "1", delta: "done" },
|
|
165
|
+
{ type: "text-end", id: "1" },
|
|
166
|
+
{
|
|
167
|
+
type: "finish",
|
|
168
|
+
reason: "stop",
|
|
169
|
+
usage: {
|
|
170
|
+
inputTokens: {
|
|
171
|
+
total: 120,
|
|
172
|
+
cacheRead: 30,
|
|
173
|
+
cacheWrite: 6,
|
|
174
|
+
},
|
|
175
|
+
outputTokens: { total: 12 },
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
),
|
|
179
|
+
)
|
|
180
|
+
const created = yield* server.request(1, "session/new", {
|
|
181
|
+
cwd: "/tmp",
|
|
182
|
+
})
|
|
183
|
+
const sessionId: string = created.result.sessionId
|
|
184
|
+
|
|
185
|
+
yield* server.request(2, "session/prompt", {
|
|
186
|
+
sessionId,
|
|
187
|
+
prompt: [{ type: "text", text: "hello" }],
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
assert.deepStrictEqual(
|
|
191
|
+
server
|
|
192
|
+
.updates(sessionId)
|
|
193
|
+
.find((update) => update.sessionUpdate === "usage_update"),
|
|
194
|
+
{
|
|
195
|
+
sessionUpdate: "usage_update",
|
|
196
|
+
usage: {
|
|
197
|
+
inputTokens: 120,
|
|
198
|
+
outputTokens: 12,
|
|
199
|
+
cacheRead: 30,
|
|
200
|
+
cacheWrite: 6,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
)
|
|
204
|
+
}),
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
it.effect(
|
|
210
|
+
"reports zero cache usage when the provider omits cache fields",
|
|
211
|
+
() =>
|
|
212
|
+
withStore(
|
|
213
|
+
Effect.scoped(
|
|
214
|
+
Effect.gen(function* () {
|
|
215
|
+
const server = yield* makeServer(() =>
|
|
216
|
+
parts(
|
|
217
|
+
{ type: "text-start", id: "1" },
|
|
218
|
+
{ type: "text-delta", id: "1", delta: "done" },
|
|
219
|
+
{ type: "text-end", id: "1" },
|
|
220
|
+
{
|
|
221
|
+
type: "finish",
|
|
222
|
+
reason: "stop",
|
|
223
|
+
usage: {
|
|
224
|
+
inputTokens: { total: 120 },
|
|
225
|
+
outputTokens: { total: 12 },
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
const created = yield* server.request(1, "session/new", {
|
|
231
|
+
cwd: "/tmp",
|
|
232
|
+
})
|
|
233
|
+
const sessionId: string = created.result.sessionId
|
|
234
|
+
|
|
235
|
+
yield* server.request(2, "session/prompt", {
|
|
236
|
+
sessionId,
|
|
237
|
+
prompt: [{ type: "text", text: "hello" }],
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
assert.deepStrictEqual(
|
|
241
|
+
server
|
|
242
|
+
.updates(sessionId)
|
|
243
|
+
.find((update) => update.sessionUpdate === "usage_update"),
|
|
244
|
+
{
|
|
245
|
+
sessionUpdate: "usage_update",
|
|
246
|
+
usage: {
|
|
247
|
+
inputTokens: 120,
|
|
248
|
+
outputTokens: 12,
|
|
249
|
+
cacheRead: 0,
|
|
250
|
+
cacheWrite: 0,
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
)
|
|
254
|
+
}),
|
|
255
|
+
),
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
|
|
157
259
|
it.effect("applies model and thought-level changes to the next turn", () =>
|
|
158
260
|
withStore(
|
|
159
261
|
Effect.scoped(
|
package/src/Acp.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import * as Cause from "effect/Cause"
|
|
12
12
|
import * as Effect from "effect/Effect"
|
|
13
|
-
import * as
|
|
13
|
+
import * as Base64 from "effect/encoding/Base64"
|
|
14
14
|
import * as Exit from "effect/Exit"
|
|
15
15
|
import * as Fiber from "effect/Fiber"
|
|
16
16
|
import * as FileSystem from "effect/FileSystem"
|
|
@@ -24,11 +24,11 @@ import * as Schema from "effect/Schema"
|
|
|
24
24
|
import * as Scope from "effect/Scope"
|
|
25
25
|
import * as Stdio from "effect/Stdio"
|
|
26
26
|
import * as Stream from "effect/Stream"
|
|
27
|
-
import type * as LanguageModel from "effect/
|
|
28
|
-
import type * as Model from "effect/
|
|
29
|
-
import * as Prompt from "effect/
|
|
30
|
-
import * as HttpClient from "effect/
|
|
31
|
-
import * as KeyValueStore from "effect/
|
|
27
|
+
import type * as LanguageModel from "effect/ai/LanguageModel"
|
|
28
|
+
import type * as Model from "effect/ai/Model"
|
|
29
|
+
import * as Prompt from "effect/ai/Prompt"
|
|
30
|
+
import * as HttpClient from "effect/http/HttpClient"
|
|
31
|
+
import * as KeyValueStore from "effect/persistence/KeyValueStore"
|
|
32
32
|
import type * as Agent from "./Agent.ts"
|
|
33
33
|
import type * as AgentOutput from "./AgentOutput.ts"
|
|
34
34
|
import * as Compaction from "./Compaction.ts"
|
|
@@ -248,7 +248,7 @@ const decodeBase64 = (data: string, what: string) => {
|
|
|
248
248
|
),
|
|
249
249
|
)
|
|
250
250
|
}
|
|
251
|
-
const decoded =
|
|
251
|
+
const decoded = Base64.decode(data)
|
|
252
252
|
return decoded._tag === "Success"
|
|
253
253
|
? Effect.succeed(decoded.success)
|
|
254
254
|
: Effect.fail(invalidParams(`Invalid base64 image data in ${what}`))
|
|
@@ -264,7 +264,7 @@ const textContent = (text: string) => ({ type: "text", text })
|
|
|
264
264
|
const imageContent = (part: Prompt.FilePart) =>
|
|
265
265
|
Option.map(Image.partBytes(part), (bytes) => ({
|
|
266
266
|
type: "image",
|
|
267
|
-
data:
|
|
267
|
+
data: Base64.encode(bytes),
|
|
268
268
|
mimeType: part.mediaType,
|
|
269
269
|
}))
|
|
270
270
|
|
|
@@ -655,6 +655,8 @@ export const make = Effect.fnUntraced(function* <RAgent, RModel>(
|
|
|
655
655
|
usage: {
|
|
656
656
|
inputTokens: part.inputTokens,
|
|
657
657
|
outputTokens: part.outputTokens,
|
|
658
|
+
cacheRead: part.cacheRead,
|
|
659
|
+
cacheWrite: part.cacheWrite,
|
|
658
660
|
},
|
|
659
661
|
})
|
|
660
662
|
case "ErrorRetry":
|
package/src/AcpImage.test.ts
CHANGED
|
@@ -6,19 +6,19 @@ import * as NodePath from "@effect/platform-node/NodePath"
|
|
|
6
6
|
import * as Effect from "effect/Effect"
|
|
7
7
|
import * as Fiber from "effect/Fiber"
|
|
8
8
|
import { TestClock } from "effect/testing"
|
|
9
|
-
import * as
|
|
9
|
+
import * as Base64 from "effect/encoding/Base64"
|
|
10
10
|
import * as FileSystem from "effect/FileSystem"
|
|
11
11
|
import * as Layer from "effect/Layer"
|
|
12
12
|
import * as Option from "effect/Option"
|
|
13
13
|
import * as Path from "effect/Path"
|
|
14
14
|
import * as Stream from "effect/Stream"
|
|
15
|
-
import * as LanguageModel from "effect/
|
|
16
|
-
import * as Model from "effect/
|
|
17
|
-
import type * as Prompt from "effect/
|
|
18
|
-
import type * as AiResponse from "effect/
|
|
19
|
-
import * as HttpClient from "effect/
|
|
20
|
-
import * as HttpClientResponse from "effect/
|
|
21
|
-
import * as KeyValueStore from "effect/
|
|
15
|
+
import * as LanguageModel from "effect/ai/LanguageModel"
|
|
16
|
+
import * as Model from "effect/ai/Model"
|
|
17
|
+
import type * as Prompt from "effect/ai/Prompt"
|
|
18
|
+
import type * as AiResponse from "effect/ai/Response"
|
|
19
|
+
import * as HttpClient from "effect/http/HttpClient"
|
|
20
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse"
|
|
21
|
+
import * as KeyValueStore from "effect/persistence/KeyValueStore"
|
|
22
22
|
import * as Acp from "./Acp.ts"
|
|
23
23
|
import * as Agent from "./Agent.ts"
|
|
24
24
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
@@ -167,7 +167,7 @@ const withTempDir = <A, E, R>(f: (cwd: string) => Effect.Effect<A, E, R>) =>
|
|
|
167
167
|
return yield* f(cwd)
|
|
168
168
|
})
|
|
169
169
|
|
|
170
|
-
const base64 = (bytes: Uint8Array) =>
|
|
170
|
+
const base64 = (bytes: Uint8Array) => Base64.encode(bytes)
|
|
171
171
|
|
|
172
172
|
describe("Acp images", () => {
|
|
173
173
|
it.effect("maps an image block onto a file part instead of text", () =>
|
package/src/Agent.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assert, describe, it } from "@effect/vitest"
|
|
2
2
|
import * as NodeServices from "@effect/platform-node/NodeServices"
|
|
3
3
|
import * as FileSystem from "effect/FileSystem"
|
|
4
|
-
import * as FetchHttpClient from "effect/
|
|
4
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient"
|
|
5
5
|
import * as Effect from "effect/Effect"
|
|
6
6
|
import * as Duration from "effect/Duration"
|
|
7
7
|
import * as Exit from "effect/Exit"
|
|
@@ -10,15 +10,15 @@ import * as MutableRef from "effect/MutableRef"
|
|
|
10
10
|
import * as Option from "effect/Option"
|
|
11
11
|
import * as Schema from "effect/Schema"
|
|
12
12
|
import * as Stream from "effect/Stream"
|
|
13
|
-
import * as AiError from "effect/
|
|
14
|
-
import * as LanguageModel from "effect/
|
|
15
|
-
import * as Model from "effect/
|
|
16
|
-
import * as Prompt from "effect/
|
|
17
|
-
import type * as Response from "effect/
|
|
18
|
-
import * as ResponseIdTracker from "effect/
|
|
13
|
+
import * as AiError from "effect/ai/AiError"
|
|
14
|
+
import * as LanguageModel from "effect/ai/LanguageModel"
|
|
15
|
+
import * as Model from "effect/ai/Model"
|
|
16
|
+
import * as Prompt from "effect/ai/Prompt"
|
|
17
|
+
import type * as Response from "effect/ai/Response"
|
|
18
|
+
import * as ResponseIdTracker from "effect/ai/ResponseIdTracker"
|
|
19
19
|
import * as Agent from "./Agent.ts"
|
|
20
20
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
21
|
-
import
|
|
21
|
+
import * as AgentOutput from "./AgentOutput.ts"
|
|
22
22
|
import * as Compaction from "./Compaction.ts"
|
|
23
23
|
|
|
24
24
|
const capabilities = new AgentExecutor.Capabilities({
|
|
@@ -310,11 +310,19 @@ const toolCall = (id: string, script: string): Response.StreamPartEncoded => ({
|
|
|
310
310
|
const finish = (
|
|
311
311
|
contextTokens: number,
|
|
312
312
|
reason: "stop" | "tool-calls" = "tool-calls",
|
|
313
|
+
cache: {
|
|
314
|
+
readonly read?: number | undefined
|
|
315
|
+
readonly write?: number | undefined
|
|
316
|
+
} = {},
|
|
313
317
|
): Response.StreamPartEncoded => ({
|
|
314
318
|
type: "finish",
|
|
315
319
|
reason,
|
|
316
320
|
usage: {
|
|
317
|
-
inputTokens: {
|
|
321
|
+
inputTokens: {
|
|
322
|
+
total: contextTokens,
|
|
323
|
+
cacheRead: cache.read,
|
|
324
|
+
cacheWrite: cache.write,
|
|
325
|
+
},
|
|
318
326
|
outputTokens: { total: 10 },
|
|
319
327
|
},
|
|
320
328
|
})
|
|
@@ -524,6 +532,50 @@ it.layer(localExecutorLayer, { excludeTestServices: true })(
|
|
|
524
532
|
|
|
525
533
|
// --- tests -------------------------------------------------------------------
|
|
526
534
|
|
|
535
|
+
describe("Agent usage", () => {
|
|
536
|
+
it.effect("accumulates provider cache reads and writes", () =>
|
|
537
|
+
Effect.gen(function* () {
|
|
538
|
+
const { exit, outputs } = yield* runAgentCollect({
|
|
539
|
+
executor: makeExecutor(() => Stream.succeed("done")),
|
|
540
|
+
respond: (_call, index) => {
|
|
541
|
+
switch (index) {
|
|
542
|
+
case 0:
|
|
543
|
+
return Stream.fromIterable([
|
|
544
|
+
toolCall("call-1", "console.log('done')"),
|
|
545
|
+
finish(100, "tool-calls", { read: 25, write: 5 }),
|
|
546
|
+
])
|
|
547
|
+
case 1:
|
|
548
|
+
return Stream.fromIterable([
|
|
549
|
+
...text("complete"),
|
|
550
|
+
finish(60, "stop", { read: 15, write: 3 }),
|
|
551
|
+
])
|
|
552
|
+
default:
|
|
553
|
+
return Stream.die(`unexpected model call #${index}`)
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
})
|
|
557
|
+
|
|
558
|
+
assert.deepStrictEqual(exit, Exit.succeed("complete"))
|
|
559
|
+
assert.deepStrictEqual(outputsOfTag(outputs, "Usage"), [
|
|
560
|
+
new AgentOutput.Usage({
|
|
561
|
+
contextTokens: 100,
|
|
562
|
+
inputTokens: 100,
|
|
563
|
+
outputTokens: 10,
|
|
564
|
+
cacheRead: 25,
|
|
565
|
+
cacheWrite: 5,
|
|
566
|
+
}),
|
|
567
|
+
new AgentOutput.Usage({
|
|
568
|
+
contextTokens: 60,
|
|
569
|
+
inputTokens: 160,
|
|
570
|
+
outputTokens: 20,
|
|
571
|
+
cacheRead: 40,
|
|
572
|
+
cacheWrite: 8,
|
|
573
|
+
}),
|
|
574
|
+
])
|
|
575
|
+
}),
|
|
576
|
+
)
|
|
577
|
+
})
|
|
578
|
+
|
|
527
579
|
describe("Agent execute output cap", () => {
|
|
528
580
|
const dump = "DUMP-HEAD " + filler("log", 40_000) + " DUMP-TAIL"
|
|
529
581
|
|
package/src/Agent.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as Model from "effect/
|
|
5
|
-
import type * as Response from "effect/
|
|
4
|
+
import * as Model from "effect/ai/Model"
|
|
5
|
+
import type * as Response from "effect/ai/Response"
|
|
6
6
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
7
7
|
import * as AgentSkills from "./AgentSkills.ts"
|
|
8
8
|
import { stripWrappingCodeFence } from "./ScriptExtraction.ts"
|
|
9
9
|
import type * as Path from "effect/Path"
|
|
10
|
-
import type * as ChildProcessSpawner from "effect/
|
|
11
|
-
import type * as HttpClient from "effect/
|
|
10
|
+
import type * as ChildProcessSpawner from "effect/process/ChildProcessSpawner"
|
|
11
|
+
import type * as HttpClient from "effect/http/HttpClient"
|
|
12
12
|
import type {
|
|
13
13
|
CurrentDirectory,
|
|
14
14
|
DirectoryChanger,
|
|
@@ -19,12 +19,12 @@ import type {
|
|
|
19
19
|
} from "./AgentTools.ts"
|
|
20
20
|
import * as Image from "./Image.ts"
|
|
21
21
|
import type * as FileSystem from "effect/FileSystem"
|
|
22
|
-
import * as Prompt from "effect/
|
|
22
|
+
import * as Prompt from "effect/ai/Prompt"
|
|
23
23
|
import * as Effect from "effect/Effect"
|
|
24
24
|
import * as Stream from "effect/Stream"
|
|
25
25
|
import type * as Scope from "effect/Scope"
|
|
26
|
-
import * as LanguageModel from "effect/
|
|
27
|
-
import * as AiError from "effect/
|
|
26
|
+
import * as LanguageModel from "effect/ai/LanguageModel"
|
|
27
|
+
import * as AiError from "effect/ai/AiError"
|
|
28
28
|
import * as Context from "effect/Context"
|
|
29
29
|
import * as Option from "effect/Option"
|
|
30
30
|
import { identity, pipe } from "effect/Function"
|
|
@@ -33,8 +33,8 @@ import * as Queue from "effect/Queue"
|
|
|
33
33
|
import * as Array from "effect/Array"
|
|
34
34
|
import * as Schema from "effect/Schema"
|
|
35
35
|
import * as Layer from "effect/Layer"
|
|
36
|
-
import * as Tool from "effect/
|
|
37
|
-
import * as Toolkit from "effect/
|
|
36
|
+
import * as Tool from "effect/ai/Tool"
|
|
37
|
+
import * as Toolkit from "effect/ai/Toolkit"
|
|
38
38
|
import * as Semaphore from "effect/Semaphore"
|
|
39
39
|
import * as Schedule from "effect/Schedule"
|
|
40
40
|
import * as Duration from "effect/Duration"
|
|
@@ -211,6 +211,8 @@ ${content}
|
|
|
211
211
|
const output = yield* Queue.make<Output, AgentFinished | AiError.AiError>()
|
|
212
212
|
let inputTokens = 0
|
|
213
213
|
let outputTokens = 0
|
|
214
|
+
let cacheRead = 0
|
|
215
|
+
let cacheWrite = 0
|
|
214
216
|
const prompt = opts.disableHistory ? MutableRef.make(Prompt.empty) : history
|
|
215
217
|
|
|
216
218
|
MutableRef.update(prompt, Prompt.concat(opts.prompt))
|
|
@@ -536,6 +538,12 @@ ${content}
|
|
|
536
538
|
if (usage.outputTokens.total !== undefined) {
|
|
537
539
|
outputTokens += usage.outputTokens.total
|
|
538
540
|
}
|
|
541
|
+
if (usage.inputTokens.cacheRead !== undefined) {
|
|
542
|
+
cacheRead += usage.inputTokens.cacheRead
|
|
543
|
+
}
|
|
544
|
+
if (usage.inputTokens.cacheWrite !== undefined) {
|
|
545
|
+
cacheWrite += usage.inputTokens.cacheWrite
|
|
546
|
+
}
|
|
539
547
|
if (usage.inputTokens.total !== undefined) {
|
|
540
548
|
lastContextTokens = usage.inputTokens.total
|
|
541
549
|
inputTokens += usage.inputTokens.total
|
|
@@ -545,6 +553,8 @@ ${content}
|
|
|
545
553
|
contextTokens: usage.inputTokens.total,
|
|
546
554
|
inputTokens,
|
|
547
555
|
outputTokens,
|
|
556
|
+
cacheRead,
|
|
557
|
+
cacheWrite,
|
|
548
558
|
}),
|
|
549
559
|
})
|
|
550
560
|
}
|
|
@@ -564,7 +574,7 @@ ${content}
|
|
|
564
574
|
runModel,
|
|
565
575
|
Effect.raceFirst(turnTimeoutEffect),
|
|
566
576
|
Effect.retry({
|
|
567
|
-
while
|
|
577
|
+
while(err) {
|
|
568
578
|
if (err._tag === "TimeoutError") {
|
|
569
579
|
maybeSend({
|
|
570
580
|
agentId,
|
package/src/AgentExecutor.ts
CHANGED
|
@@ -19,16 +19,16 @@ import {
|
|
|
19
19
|
import * as Image from "./Image.ts"
|
|
20
20
|
import { ToolkitRenderer } from "./ToolkitRenderer.ts"
|
|
21
21
|
import * as AgentSkills from "./AgentSkills.ts"
|
|
22
|
-
import type * as ChildProcessSpawner from "effect/
|
|
23
|
-
import type * as HttpClient from "effect/
|
|
22
|
+
import type * as ChildProcessSpawner from "effect/process/ChildProcessSpawner"
|
|
23
|
+
import type * as HttpClient from "effect/http/HttpClient"
|
|
24
24
|
import * as Context from "effect/Context"
|
|
25
25
|
import * as Effect from "effect/Effect"
|
|
26
26
|
import * as Option from "effect/Option"
|
|
27
27
|
import * as Stream from "effect/Stream"
|
|
28
28
|
import * as FileSystem from "effect/FileSystem"
|
|
29
|
-
import * as Toolkit from "effect/
|
|
29
|
+
import * as Toolkit from "effect/ai/Toolkit"
|
|
30
30
|
import * as Path from "effect/Path"
|
|
31
|
-
import type * as Tool from "effect/
|
|
31
|
+
import type * as Tool from "effect/ai/Tool"
|
|
32
32
|
import * as Queue from "effect/Queue"
|
|
33
33
|
import * as Cause from "effect/Cause"
|
|
34
34
|
import * as Scope from "effect/Scope"
|
|
@@ -36,12 +36,12 @@ import * as Fiber from "effect/Fiber"
|
|
|
36
36
|
import * as Console from "effect/Console"
|
|
37
37
|
import * as Exit from "effect/Exit"
|
|
38
38
|
import { pipe, identity } from "effect/Function"
|
|
39
|
-
import * as RpcClient from "effect/
|
|
39
|
+
import * as RpcClient from "effect/rpc/RpcClient"
|
|
40
40
|
import * as Layer from "effect/Layer"
|
|
41
|
-
import * as RpcServer from "effect/
|
|
41
|
+
import * as RpcServer from "effect/rpc/RpcServer"
|
|
42
42
|
import * as Schema from "effect/Schema"
|
|
43
|
-
import * as RpcGroup from "effect/
|
|
44
|
-
import * as Rpc from "effect/
|
|
43
|
+
import * as RpcGroup from "effect/rpc/RpcGroup"
|
|
44
|
+
import * as Rpc from "effect/rpc/Rpc"
|
|
45
45
|
import * as Result from "effect/Result"
|
|
46
46
|
import { SemanticSearch } from "./SemanticSearch/Service.ts"
|
|
47
47
|
import { preprocessScript } from "./ScriptPreprocessing.ts"
|
|
@@ -2,15 +2,15 @@ import { assert, describe, it } from "@effect/vitest"
|
|
|
2
2
|
import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer"
|
|
3
3
|
import * as NodeServices from "@effect/platform-node/NodeServices"
|
|
4
4
|
import * as Effect from "effect/Effect"
|
|
5
|
-
import * as
|
|
5
|
+
import * as Base64 from "effect/encoding/Base64"
|
|
6
6
|
import * as FileSystem from "effect/FileSystem"
|
|
7
7
|
import * as Layer from "effect/Layer"
|
|
8
8
|
import * as Path from "effect/Path"
|
|
9
9
|
import * as Stream from "effect/Stream"
|
|
10
|
-
import * as HttpServer from "effect/
|
|
11
|
-
import * as RpcClient from "effect/
|
|
12
|
-
import * as RpcSerialization from "effect/
|
|
13
|
-
import * as RpcServer from "effect/
|
|
10
|
+
import * as HttpServer from "effect/http/HttpServer"
|
|
11
|
+
import * as RpcClient from "effect/rpc/RpcClient"
|
|
12
|
+
import * as RpcSerialization from "effect/rpc/RpcSerialization"
|
|
13
|
+
import * as RpcServer from "effect/rpc/RpcServer"
|
|
14
14
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
15
15
|
import type { ImageAttachment } from "./AgentTools.ts"
|
|
16
16
|
import { equalBytes, supportedImages } from "./fixtures/TestImages.ts"
|
|
@@ -94,7 +94,7 @@ describe("RPC image executor", () => {
|
|
|
94
94
|
assert.instanceOf(image.data, Uint8Array)
|
|
95
95
|
assert.isTrue(equalBytes(image.data, bytes))
|
|
96
96
|
assert.include(output.join(""), "Image attached: " + name)
|
|
97
|
-
assert.notInclude(output.join(""),
|
|
97
|
+
assert.notInclude(output.join(""), Base64.encode(bytes))
|
|
98
98
|
}
|
|
99
99
|
assert.notInclude(output.join(""), "data:image/")
|
|
100
100
|
}),
|