clanka 0.1.4 → 0.1.6
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 +20 -11
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +30 -9
- package/dist/Agent.js.map +1 -1
- package/dist/AgentExecutor.d.ts +19 -10
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +20 -3
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentTools.d.ts +11 -8
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +15 -4
- package/dist/AgentTools.js.map +1 -1
- package/dist/ApplyPatch.js +1 -1
- package/dist/ApplyPatch.js.map +1 -1
- package/dist/Codex.d.ts +7 -7
- package/dist/Codex.d.ts.map +1 -1
- package/dist/Codex.js +8 -3
- package/dist/Codex.js.map +1 -1
- package/dist/CodexAuth.d.ts +7 -6
- package/dist/CodexAuth.d.ts.map +1 -1
- package/dist/CodexAuth.js +16 -4
- package/dist/CodexAuth.js.map +1 -1
- package/dist/CodexAuth.test.js +8 -3
- package/dist/CodexAuth.test.js.map +1 -1
- package/dist/Copilot.d.ts +7 -7
- package/dist/Copilot.d.ts.map +1 -1
- package/dist/Copilot.js +7 -3
- package/dist/Copilot.js.map +1 -1
- package/dist/CopilotAuth.d.ts +6 -6
- package/dist/CopilotAuth.d.ts.map +1 -1
- package/dist/CopilotAuth.js +14 -4
- package/dist/CopilotAuth.js.map +1 -1
- package/dist/CopilotAuth.test.js +6 -2
- package/dist/CopilotAuth.test.js.map +1 -1
- package/dist/ExaSearch.d.ts +4 -1
- package/dist/ExaSearch.d.ts.map +1 -1
- package/dist/ExaSearch.js +5 -1
- package/dist/ExaSearch.js.map +1 -1
- package/dist/McpClient.d.ts +4 -1
- package/dist/McpClient.d.ts.map +1 -1
- package/dist/McpClient.js +4 -1
- package/dist/McpClient.js.map +1 -1
- package/dist/OutputFormatter.d.ts +5 -2
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +6 -2
- package/dist/OutputFormatter.js.map +1 -1
- package/dist/ToolkitRenderer.d.ts +4 -5
- package/dist/ToolkitRenderer.d.ts.map +1 -1
- package/dist/ToolkitRenderer.js +6 -4
- package/dist/ToolkitRenderer.js.map +1 -1
- package/dist/TypeBuilder.d.ts +1 -1
- package/dist/TypeBuilder.d.ts.map +1 -1
- package/dist/TypeBuilder.js +1 -1
- package/dist/TypeBuilder.js.map +1 -1
- package/dist/TypeBuilder.test.js +1 -1
- package/dist/TypeBuilder.test.js.map +1 -1
- package/dist/WebToMarkdown.d.ts +5 -2
- package/dist/WebToMarkdown.d.ts.map +1 -1
- package/dist/WebToMarkdown.js +4 -2
- package/dist/WebToMarkdown.js.map +1 -1
- package/dist/WebToMarkdown.test.js +3 -2
- package/dist/WebToMarkdown.test.js.map +1 -1
- package/package.json +1 -1
- package/src/Agent.ts +52 -43
- package/src/AgentExecutor.ts +28 -26
- package/src/AgentTools.ts +18 -18
- package/src/ApplyPatch.ts +1 -1
- package/src/Codex.ts +16 -7
- package/src/CodexAuth.test.ts +8 -3
- package/src/CodexAuth.ts +18 -20
- package/src/Copilot.ts +15 -7
- package/src/CopilotAuth.test.ts +6 -2
- package/src/CopilotAuth.ts +14 -18
- package/src/ExaSearch.ts +5 -1
- package/src/McpClient.ts +4 -1
- package/src/OutputFormatter.ts +9 -4
- package/src/ToolkitRenderer.ts +8 -4
- package/src/TypeBuilder.test.ts +1 -1
- package/src/TypeBuilder.ts +2 -1
- package/src/WebToMarkdown.test.ts +3 -2
- package/src/WebToMarkdown.ts +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebToMarkdown.test.js","sourceRoot":"","sources":["../src/WebToMarkdown.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,
|
|
1
|
+
{"version":3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|
|
8
|
-
Layer,
|
|
9
|
-
MutableRef,
|
|
10
|
-
Option,
|
|
11
|
-
pipe,
|
|
12
|
-
Queue,
|
|
13
|
-
Schema,
|
|
14
|
-
Scope,
|
|
15
|
-
Semaphore,
|
|
16
|
-
ServiceMap,
|
|
17
|
-
Stream,
|
|
18
|
-
} from "effect"
|
|
19
|
-
import {
|
|
20
|
-
AiError,
|
|
21
|
-
LanguageModel,
|
|
22
|
-
Prompt,
|
|
23
|
-
Tool,
|
|
24
|
-
Toolkit,
|
|
25
|
-
} from "effect/unstable/ai"
|
|
26
|
-
import { ModelName, ProviderName } from "effect/unstable/ai/Model"
|
|
27
|
-
import { type StreamPart } from "effect/unstable/ai/Response"
|
|
4
|
+
import * as Model from "effect/unstable/ai/Model"
|
|
5
|
+
import type * as Response from "effect/unstable/ai/Response"
|
|
28
6
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
29
7
|
import { stripWrappingCodeFence } from "./ScriptExtraction.ts"
|
|
30
|
-
import type
|
|
31
|
-
import type
|
|
32
|
-
import type
|
|
8
|
+
import type * as Path from "effect/Path"
|
|
9
|
+
import type * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner"
|
|
10
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient"
|
|
33
11
|
import type {
|
|
34
12
|
CurrentDirectory,
|
|
35
13
|
SubagentExecutor,
|
|
36
14
|
TaskCompleter,
|
|
37
15
|
} from "./AgentTools.ts"
|
|
38
|
-
import type
|
|
16
|
+
import type * as FileSystem from "effect/FileSystem"
|
|
17
|
+
import * as Prompt from "effect/unstable/ai/Prompt"
|
|
18
|
+
import * as Effect from "effect/Effect"
|
|
19
|
+
import * as Stream from "effect/Stream"
|
|
20
|
+
import type * as Scope from "effect/Scope"
|
|
21
|
+
import * as LanguageModel from "effect/unstable/ai/LanguageModel"
|
|
22
|
+
import type * as AiError from "effect/unstable/ai/AiError"
|
|
23
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
24
|
+
import * as Option from "effect/Option"
|
|
25
|
+
import { identity, pipe } from "effect/Function"
|
|
26
|
+
import * as MutableRef from "effect/MutableRef"
|
|
27
|
+
import * as Queue from "effect/Queue"
|
|
28
|
+
import * as Array from "effect/Array"
|
|
29
|
+
import * as Schema from "effect/Schema"
|
|
30
|
+
import * as Layer from "effect/Layer"
|
|
31
|
+
import * as Tool from "effect/unstable/ai/Tool"
|
|
32
|
+
import * as Toolkit from "effect/unstable/ai/Toolkit"
|
|
33
|
+
import * as Semaphore from "effect/Semaphore"
|
|
39
34
|
|
|
40
35
|
/**
|
|
41
36
|
* @since 1.0.0
|
|
@@ -78,7 +73,10 @@ export interface Agent {
|
|
|
78
73
|
}): Effect.Effect<
|
|
79
74
|
Stream.Stream<Output, AgentFinished | AiError.AiError>,
|
|
80
75
|
never,
|
|
81
|
-
Scope.Scope
|
|
76
|
+
| Scope.Scope
|
|
77
|
+
| LanguageModel.LanguageModel
|
|
78
|
+
| Model.ProviderName
|
|
79
|
+
| Model.ModelName
|
|
82
80
|
>
|
|
83
81
|
|
|
84
82
|
/**
|
|
@@ -158,14 +156,14 @@ ${content}
|
|
|
158
156
|
}) => Stream.Stream<
|
|
159
157
|
Output,
|
|
160
158
|
AgentFinished | AiError.AiError,
|
|
161
|
-
LanguageModel.LanguageModel | ProviderName | ModelName
|
|
159
|
+
LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName
|
|
162
160
|
> = Effect.fnUntraced(function* (opts) {
|
|
163
161
|
const agentId = opts.agentId
|
|
164
162
|
const ai = yield* LanguageModel.LanguageModel
|
|
165
163
|
const subagentModel = yield* Effect.serviceOption(SubagentModel)
|
|
166
164
|
const modelConfig = yield* AgentModelConfig
|
|
167
165
|
const services = yield* Effect.services<
|
|
168
|
-
LanguageModel.LanguageModel | ProviderName | ModelName
|
|
166
|
+
LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName
|
|
169
167
|
>()
|
|
170
168
|
let finalSummary = Option.none<string>()
|
|
171
169
|
|
|
@@ -233,8 +231,8 @@ ${content}
|
|
|
233
231
|
system: opts.system,
|
|
234
232
|
disableHistory: true,
|
|
235
233
|
})
|
|
236
|
-
const provider = yield* ProviderName
|
|
237
|
-
const model = yield* ModelName
|
|
234
|
+
const provider = yield* Model.ProviderName
|
|
235
|
+
const model = yield* Model.ModelName
|
|
238
236
|
maybeSend({
|
|
239
237
|
agentId: opts.agentId,
|
|
240
238
|
part: new SubagentStart({ id, prompt, model, provider }),
|
|
@@ -341,7 +339,7 @@ ${content}
|
|
|
341
339
|
}
|
|
342
340
|
|
|
343
341
|
// oxlint-disable-next-line typescript/no-explicit-any
|
|
344
|
-
let response = Array.empty<StreamPart<any>>()
|
|
342
|
+
let response = Array.empty<Response.StreamPart<any>>()
|
|
345
343
|
let reasoningStarted = false
|
|
346
344
|
let hadReasoningDelta = false
|
|
347
345
|
yield* pipe(
|
|
@@ -373,6 +371,14 @@ ${content}
|
|
|
373
371
|
switch (part.type) {
|
|
374
372
|
case "text-start":
|
|
375
373
|
if (singleToolMode) {
|
|
374
|
+
if (hadReasoningDelta) {
|
|
375
|
+
hadReasoningDelta = false
|
|
376
|
+
maybeSend({
|
|
377
|
+
agentId,
|
|
378
|
+
part: new ReasoningEnd(),
|
|
379
|
+
release: true,
|
|
380
|
+
})
|
|
381
|
+
}
|
|
376
382
|
reasoningStarted = true
|
|
377
383
|
break
|
|
378
384
|
}
|
|
@@ -490,8 +496,8 @@ ${content}
|
|
|
490
496
|
new AgentStart({
|
|
491
497
|
id: opts.agentId,
|
|
492
498
|
prompt: opts.prompt,
|
|
493
|
-
provider: yield* ProviderName,
|
|
494
|
-
model: yield* ModelName,
|
|
499
|
+
provider: yield* Model.ProviderName,
|
|
500
|
+
model: yield* Model.ModelName,
|
|
495
501
|
}),
|
|
496
502
|
)
|
|
497
503
|
|
|
@@ -574,7 +580,7 @@ ${systemToolsCommon(toolsDts)}`
|
|
|
574
580
|
|
|
575
581
|
// oxlint-disable-next-line typescript/no-explicit-any
|
|
576
582
|
const generateSystemSingle = (toolsDts: string) => {
|
|
577
|
-
return
|
|
583
|
+
return `**YOU ONLY HAVE ACCESS TO ONE TOOL** "execute", to run javascript code to do your work.
|
|
578
584
|
|
|
579
585
|
${systemToolsCommon(toolsDts)}`
|
|
580
586
|
}
|
|
@@ -585,6 +591,7 @@ const systemToolsCommon = (
|
|
|
585
591
|
- Top level await is supported.
|
|
586
592
|
- AVOID passing scripts into the "bash" function, and instead write javascript.
|
|
587
593
|
- PREFER the "search" function over "rg" for finding information or code
|
|
594
|
+
- Variables **are not shared** between executions, so you must include all necessary code in each script you execute.
|
|
588
595
|
|
|
589
596
|
**When you have fully completed your task**, call the "taskComplete" function with the final output.
|
|
590
597
|
Make sure every detail of the task is done before calling "taskComplete".
|
|
@@ -639,10 +646,10 @@ export const layerLocal = <Toolkit extends Toolkit.Any = never>(options: {
|
|
|
639
646
|
}): Layer.Layer<
|
|
640
647
|
Agent,
|
|
641
648
|
never,
|
|
642
|
-
| FileSystem
|
|
643
|
-
| Path
|
|
644
|
-
| ChildProcessSpawner
|
|
645
|
-
| HttpClient
|
|
649
|
+
| FileSystem.FileSystem
|
|
650
|
+
| Path.Path
|
|
651
|
+
| ChildProcessSpawner.ChildProcessSpawner
|
|
652
|
+
| HttpClient.HttpClient
|
|
646
653
|
| Exclude<
|
|
647
654
|
Toolkit extends Toolkit.Toolkit<infer T>
|
|
648
655
|
? Tool.HandlersFor<T> | Tool.HandlerServices<T[keyof T]>
|
|
@@ -657,7 +664,9 @@ export const layerLocal = <Toolkit extends Toolkit.Any = never>(options: {
|
|
|
657
664
|
*/
|
|
658
665
|
export class SubagentModel extends ServiceMap.Service<
|
|
659
666
|
SubagentModel,
|
|
660
|
-
ServiceMap.ServiceMap<
|
|
667
|
+
ServiceMap.ServiceMap<
|
|
668
|
+
LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName
|
|
669
|
+
>
|
|
661
670
|
>()("clanka/Agent/SubagentModel") {}
|
|
662
671
|
|
|
663
672
|
/**
|
|
@@ -666,7 +675,7 @@ export class SubagentModel extends ServiceMap.Service<
|
|
|
666
675
|
*/
|
|
667
676
|
export const layerSubagentModel = <E, R>(
|
|
668
677
|
layer: Layer.Layer<
|
|
669
|
-
LanguageModel.LanguageModel | ProviderName | ModelName,
|
|
678
|
+
LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName,
|
|
670
679
|
E,
|
|
671
680
|
R
|
|
672
681
|
>,
|
package/src/AgentExecutor.ts
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
Cause,
|
|
6
|
-
Console,
|
|
7
|
-
Effect,
|
|
8
|
-
Exit,
|
|
9
|
-
Fiber,
|
|
10
|
-
FileSystem,
|
|
11
|
-
Layer,
|
|
12
|
-
Option,
|
|
13
|
-
Path,
|
|
14
|
-
pipe,
|
|
15
|
-
Queue,
|
|
16
|
-
Result,
|
|
17
|
-
Schema,
|
|
18
|
-
Scope,
|
|
19
|
-
ServiceMap,
|
|
20
|
-
Stream,
|
|
21
|
-
} from "effect"
|
|
22
|
-
import { Tool, Toolkit } from "effect/unstable/ai"
|
|
23
|
-
import { Rpc, RpcClient, RpcGroup, RpcServer } from "effect/unstable/rpc"
|
|
24
4
|
import * as NodeConsole from "node:console"
|
|
25
5
|
import * as NodeVm from "node:vm"
|
|
26
6
|
import { Writable } from "node:stream"
|
|
@@ -32,8 +12,30 @@ import {
|
|
|
32
12
|
TaskCompleter,
|
|
33
13
|
} from "./AgentTools.ts"
|
|
34
14
|
import { ToolkitRenderer } from "./ToolkitRenderer.ts"
|
|
35
|
-
import type
|
|
36
|
-
import type
|
|
15
|
+
import type * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner"
|
|
16
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient"
|
|
17
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
18
|
+
import * as Effect from "effect/Effect"
|
|
19
|
+
import type * as Option from "effect/Option"
|
|
20
|
+
import * as Stream from "effect/Stream"
|
|
21
|
+
import * as FileSystem from "effect/FileSystem"
|
|
22
|
+
import * as Toolkit from "effect/unstable/ai/Toolkit"
|
|
23
|
+
import * as Path from "effect/Path"
|
|
24
|
+
import type * as Tool from "effect/unstable/ai/Tool"
|
|
25
|
+
import * as Queue from "effect/Queue"
|
|
26
|
+
import * as Cause from "effect/Cause"
|
|
27
|
+
import * as Scope from "effect/Scope"
|
|
28
|
+
import * as Fiber from "effect/Fiber"
|
|
29
|
+
import * as Console from "effect/Console"
|
|
30
|
+
import * as Exit from "effect/Exit"
|
|
31
|
+
import { pipe } from "effect/Function"
|
|
32
|
+
import * as RpcClient from "effect/unstable/rpc/RpcClient"
|
|
33
|
+
import * as Layer from "effect/Layer"
|
|
34
|
+
import * as RpcServer from "effect/unstable/rpc/RpcServer"
|
|
35
|
+
import * as Schema from "effect/Schema"
|
|
36
|
+
import * as RpcGroup from "effect/unstable/rpc/RpcGroup"
|
|
37
|
+
import * as Rpc from "effect/unstable/rpc/Rpc"
|
|
38
|
+
import * as Result from "effect/Result"
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* @since 1.0.0
|
|
@@ -237,8 +239,8 @@ export const layerLocal = <Toolkit extends Toolkit.Any = never>(options: {
|
|
|
237
239
|
never,
|
|
238
240
|
| FileSystem.FileSystem
|
|
239
241
|
| Path.Path
|
|
240
|
-
| ChildProcessSpawner
|
|
241
|
-
| HttpClient
|
|
242
|
+
| ChildProcessSpawner.ChildProcessSpawner
|
|
243
|
+
| HttpClient.HttpClient
|
|
242
244
|
| Exclude<
|
|
243
245
|
Toolkit extends Toolkit.Toolkit<infer T>
|
|
244
246
|
? Tool.HandlersFor<T> | Tool.HandlerServices<T[keyof T]>
|
|
@@ -276,9 +278,9 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(options: {
|
|
|
276
278
|
never,
|
|
277
279
|
| RpcServer.Protocol
|
|
278
280
|
| FileSystem.FileSystem
|
|
279
|
-
| HttpClient
|
|
281
|
+
| HttpClient.HttpClient
|
|
280
282
|
| Path.Path
|
|
281
|
-
| ChildProcessSpawner
|
|
283
|
+
| ChildProcessSpawner.ChildProcessSpawner
|
|
282
284
|
| Exclude<
|
|
283
285
|
Toolkit extends Toolkit.Toolkit<infer T>
|
|
284
286
|
? Tool.HandlersFor<T> | Tool.HandlerServices<T[keyof T]>
|
package/src/AgentTools.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
Array,
|
|
6
|
-
Data,
|
|
7
|
-
Effect,
|
|
8
|
-
FileSystem,
|
|
9
|
-
Layer,
|
|
10
|
-
Path,
|
|
11
|
-
pipe,
|
|
12
|
-
Schema,
|
|
13
|
-
ServiceMap,
|
|
14
|
-
Stream,
|
|
15
|
-
} from "effect"
|
|
16
|
-
import { Tool, Toolkit } from "effect/unstable/ai"
|
|
17
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
|
|
18
4
|
import * as Glob from "glob"
|
|
19
5
|
import { parsePatch, patchChunks } from "./ApplyPatch.ts"
|
|
20
6
|
import * as ExaSearch from "./ExaSearch.ts"
|
|
21
7
|
import * as WebToMarkdown from "./WebToMarkdown.ts"
|
|
22
|
-
import type
|
|
8
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient"
|
|
9
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
10
|
+
import * as Effect from "effect/Effect"
|
|
11
|
+
import * as Toolkit from "effect/unstable/ai/Toolkit"
|
|
12
|
+
import * as Tool from "effect/unstable/ai/Tool"
|
|
13
|
+
import * as Schema from "effect/Schema"
|
|
14
|
+
import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner"
|
|
15
|
+
import * as FileSystem from "effect/FileSystem"
|
|
16
|
+
import * as Path from "effect/Path"
|
|
17
|
+
import * as ChildProcess from "effect/unstable/process/ChildProcess"
|
|
18
|
+
import * as Stream from "effect/Stream"
|
|
19
|
+
import { pipe } from "effect/Function"
|
|
20
|
+
import * as Array from "effect/Array"
|
|
21
|
+
import * as Data from "effect/Data"
|
|
22
|
+
import * as Layer from "effect/Layer"
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* @since 1.0.0
|
|
@@ -93,7 +93,7 @@ export const AgentTools = Toolkit.make(
|
|
|
93
93
|
}),
|
|
94
94
|
Tool.make("applyPatch", {
|
|
95
95
|
description:
|
|
96
|
-
"Apply a git diff / unified diff patch, or a wrapped
|
|
96
|
+
"Apply a git diff / unified diff patch, or a wrapped patch, across one or more files.",
|
|
97
97
|
parameters: Schema.String.annotate({
|
|
98
98
|
identifier: "patch",
|
|
99
99
|
}),
|
|
@@ -414,7 +414,7 @@ export const AgentToolHandlersNoDeps = AgentTools.toLayer(
|
|
|
414
414
|
readonly path: string
|
|
415
415
|
}
|
|
416
416
|
>
|
|
417
|
-
const out = [] as string
|
|
417
|
+
const out = [] as Array<string>
|
|
418
418
|
const rel = (path: string) =>
|
|
419
419
|
pathService.relative(cwd, path).replaceAll("\\", "/")
|
|
420
420
|
const load = Effect.fn("AgentTools.applyPatch.load")(function* (
|
|
@@ -558,7 +558,7 @@ export const AgentToolHandlers: Layer.Layer<
|
|
|
558
558
|
| FileSystem.FileSystem
|
|
559
559
|
| Path.Path
|
|
560
560
|
| ChildProcessSpawner.ChildProcessSpawner
|
|
561
|
-
| HttpClient
|
|
561
|
+
| HttpClient.HttpClient
|
|
562
562
|
> = AgentToolHandlersNoDeps.pipe(
|
|
563
563
|
Layer.provide([ExaSearch.layer, WebToMarkdown.layer]),
|
|
564
564
|
)
|
package/src/ApplyPatch.ts
CHANGED
|
@@ -638,7 +638,7 @@ export const patchChunks = (
|
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
const out = [...lines]
|
|
641
|
-
for (const [at, size, next] of compute(file, lines, chunks).
|
|
641
|
+
for (const [at, size, next] of compute(file, lines, chunks).toReversed()) {
|
|
642
642
|
out.splice(at, size, ...next)
|
|
643
643
|
}
|
|
644
644
|
|
package/src/Codex.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai"
|
|
5
|
-
import
|
|
5
|
+
import * as Layer from "effect/Layer"
|
|
6
|
+
import * as Struct from "effect/Struct"
|
|
6
7
|
import { CodexAuth } from "./CodexAuth.ts"
|
|
7
8
|
import { AgentModelConfig } from "./Agent.ts"
|
|
8
|
-
import
|
|
9
|
-
import type
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
9
|
+
import * as Model from "effect/unstable/ai/Model"
|
|
10
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient"
|
|
11
|
+
import type * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
12
|
+
import type * as LanguageModel from "effect/unstable/ai/LanguageModel"
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @since 1.0.0
|
|
@@ -27,7 +28,11 @@ export const model = (
|
|
|
27
28
|
options?:
|
|
28
29
|
| (OpenAiLanguageModel.Config["Service"] & typeof AgentModelConfig.Service)
|
|
29
30
|
| undefined,
|
|
30
|
-
): Model.Model<
|
|
31
|
+
): Model.Model<
|
|
32
|
+
"openai",
|
|
33
|
+
LanguageModel.LanguageModel,
|
|
34
|
+
HttpClient.HttpClient | KeyValueStore.KeyValueStore
|
|
35
|
+
> =>
|
|
31
36
|
Model.make(
|
|
32
37
|
"openai",
|
|
33
38
|
model,
|
|
@@ -35,7 +40,11 @@ export const model = (
|
|
|
35
40
|
OpenAiLanguageModel.layer({
|
|
36
41
|
model,
|
|
37
42
|
config: {
|
|
38
|
-
...options,
|
|
43
|
+
...Struct.omit(options ?? {}, [
|
|
44
|
+
"reasoning",
|
|
45
|
+
"supportsNoTools",
|
|
46
|
+
"supportsAssistantPrefill",
|
|
47
|
+
]),
|
|
39
48
|
store: false,
|
|
40
49
|
reasoning: {
|
|
41
50
|
effort: options?.reasoning?.effort ?? "medium",
|
package/src/CodexAuth.test.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { assert, describe, it } from "@effect/vitest"
|
|
2
|
-
import
|
|
2
|
+
import * as Deferred from "effect/Deferred"
|
|
3
|
+
import * as Effect from "effect/Effect"
|
|
4
|
+
import * as Encoding from "effect/Encoding"
|
|
5
|
+
import * as Fiber from "effect/Fiber"
|
|
6
|
+
import * as Option from "effect/Option"
|
|
7
|
+
import * as Ref from "effect/Ref"
|
|
3
8
|
import {
|
|
4
9
|
HttpClient,
|
|
5
|
-
HttpClientRequest,
|
|
10
|
+
type HttpClientRequest,
|
|
6
11
|
HttpClientResponse,
|
|
7
12
|
} from "effect/unstable/http"
|
|
8
|
-
import
|
|
13
|
+
import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
9
14
|
import {
|
|
10
15
|
CodexAuth,
|
|
11
16
|
CodexAuthError,
|
package/src/CodexAuth.ts
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
HttpClientRequest,
|
|
20
|
-
HttpClientResponse,
|
|
21
|
-
} from "effect/unstable/http"
|
|
22
|
-
import { KeyValueStore } from "effect/unstable/persistence"
|
|
4
|
+
import * as Console from "effect/Console"
|
|
5
|
+
import * as Effect from "effect/Effect"
|
|
6
|
+
import * as Encoding from "effect/Encoding"
|
|
7
|
+
import * as Function from "effect/Function"
|
|
8
|
+
import * as Layer from "effect/Layer"
|
|
9
|
+
import * as Option from "effect/Option"
|
|
10
|
+
import * as Result from "effect/Result"
|
|
11
|
+
import * as Schedule from "effect/Schedule"
|
|
12
|
+
import * as Schema from "effect/Schema"
|
|
13
|
+
import * as Semaphore from "effect/Semaphore"
|
|
14
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
15
|
+
import * as HttpClient from "effect/unstable/http/HttpClient"
|
|
16
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest"
|
|
17
|
+
import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"
|
|
18
|
+
import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
23
19
|
|
|
24
20
|
export const CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann"
|
|
25
21
|
export const ISSUER = "https://auth.openai.com"
|
|
@@ -299,7 +295,9 @@ export class CodexAuth extends ServiceMap.Service<
|
|
|
299
295
|
static readonly make = Effect.gen(function* () {
|
|
300
296
|
const tokenStore = toTokenStore(yield* KeyValueStore.KeyValueStore)
|
|
301
297
|
const httpClient = (yield* HttpClient.HttpClient).pipe(
|
|
302
|
-
HttpClient.mapRequest(
|
|
298
|
+
HttpClient.mapRequest(
|
|
299
|
+
Function.flow(HttpClientRequest.prependUrl(ISSUER)),
|
|
300
|
+
),
|
|
303
301
|
HttpClient.filterStatusOk,
|
|
304
302
|
HttpClient.retryTransient({
|
|
305
303
|
times: 5,
|
package/src/Copilot.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai-compat"
|
|
5
|
-
import
|
|
5
|
+
import * as Layer from "effect/Layer"
|
|
6
|
+
import * as Struct from "effect/Struct"
|
|
6
7
|
import { API_URL, GithubCopilotAuth } from "./CopilotAuth.ts"
|
|
7
8
|
import { AgentModelConfig } from "./Agent.ts"
|
|
8
|
-
import
|
|
9
|
-
import type
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
9
|
+
import * as Model from "effect/unstable/ai/Model"
|
|
10
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient"
|
|
11
|
+
import type * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
12
|
+
import type * as LanguageModel from "effect/unstable/ai/LanguageModel"
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @since 1.0.0
|
|
@@ -27,14 +28,21 @@ export const model = (
|
|
|
27
28
|
options?:
|
|
28
29
|
| (OpenAiLanguageModel.Config["Service"] & typeof AgentModelConfig.Service)
|
|
29
30
|
| undefined,
|
|
30
|
-
): Model.Model<
|
|
31
|
+
): Model.Model<
|
|
32
|
+
"openai",
|
|
33
|
+
LanguageModel.LanguageModel,
|
|
34
|
+
HttpClient.HttpClient | KeyValueStore.KeyValueStore
|
|
35
|
+
> =>
|
|
31
36
|
Model.make(
|
|
32
37
|
"openai",
|
|
33
38
|
model,
|
|
34
39
|
Layer.merge(
|
|
35
40
|
OpenAiLanguageModel.layer({
|
|
36
41
|
model,
|
|
37
|
-
config: options,
|
|
42
|
+
config: Struct.omit(options ?? {}, [
|
|
43
|
+
"supportsNoTools",
|
|
44
|
+
"supportsAssistantPrefill",
|
|
45
|
+
]),
|
|
38
46
|
}),
|
|
39
47
|
AgentModelConfig.layer({
|
|
40
48
|
supportsAssistantPrefill: options?.supportsAssistantPrefill ?? false,
|
package/src/CopilotAuth.test.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { assert, describe, it } from "@effect/vitest"
|
|
2
|
-
import
|
|
2
|
+
import * as Deferred from "effect/Deferred"
|
|
3
|
+
import * as Effect from "effect/Effect"
|
|
4
|
+
import * as Fiber from "effect/Fiber"
|
|
5
|
+
import * as Option from "effect/Option"
|
|
6
|
+
import * as Ref from "effect/Ref"
|
|
3
7
|
import {
|
|
4
8
|
HttpClient,
|
|
5
9
|
HttpClientRequest,
|
|
6
10
|
HttpClientResponse,
|
|
7
11
|
} from "effect/unstable/http"
|
|
8
|
-
import
|
|
12
|
+
import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
9
13
|
import {
|
|
10
14
|
COPILOT_VISION_REQUEST_HEADER,
|
|
11
15
|
DEFAULT_OPENAI_INTENT,
|
package/src/CopilotAuth.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
HttpClientRequest,
|
|
18
|
-
HttpClientResponse,
|
|
19
|
-
} from "effect/unstable/http"
|
|
20
|
-
import { KeyValueStore } from "effect/unstable/persistence"
|
|
4
|
+
import * as Console from "effect/Console"
|
|
5
|
+
import * as Effect from "effect/Effect"
|
|
6
|
+
import * as Function from "effect/Function"
|
|
7
|
+
import * as Layer from "effect/Layer"
|
|
8
|
+
import * as Option from "effect/Option"
|
|
9
|
+
import * as Schedule from "effect/Schedule"
|
|
10
|
+
import * as Schema from "effect/Schema"
|
|
11
|
+
import * as Semaphore from "effect/Semaphore"
|
|
12
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
13
|
+
import * as HttpClient from "effect/unstable/http/HttpClient"
|
|
14
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest"
|
|
15
|
+
import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"
|
|
16
|
+
import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
|
|
21
17
|
|
|
22
18
|
export const CLIENT_ID = "Ov23li8tweQw6odWQebz"
|
|
23
19
|
export const ISSUER = "https://github.com"
|
|
@@ -229,7 +225,7 @@ export class GithubCopilotAuth extends ServiceMap.Service<
|
|
|
229
225
|
const tokenStore = toTokenStore(yield* KeyValueStore.KeyValueStore)
|
|
230
226
|
const httpClient = (yield* HttpClient.HttpClient).pipe(
|
|
231
227
|
HttpClient.mapRequest(
|
|
232
|
-
flow(
|
|
228
|
+
Function.flow(
|
|
233
229
|
HttpClientRequest.prependUrl(ISSUER),
|
|
234
230
|
HttpClientRequest.acceptJson,
|
|
235
231
|
),
|
package/src/ExaSearch.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import * as Effect from "effect/Effect"
|
|
5
|
+
import { pipe } from "effect/Function"
|
|
6
|
+
import * as Layer from "effect/Layer"
|
|
7
|
+
import * as Schema from "effect/Schema"
|
|
8
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
5
9
|
import * as McpClient from "./McpClient.ts"
|
|
6
10
|
|
|
7
11
|
/**
|
package/src/McpClient.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import * as Effect from "effect/Effect"
|
|
5
|
+
import * as Layer from "effect/Layer"
|
|
6
|
+
import * as Schema from "effect/Schema"
|
|
7
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
5
8
|
import { Client } from "@modelcontextprotocol/sdk/client"
|
|
6
9
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
|
|
7
10
|
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"
|
package/src/OutputFormatter.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import * as Effect from "effect/Effect"
|
|
5
|
+
import * as Layer from "effect/Layer"
|
|
6
|
+
import * as PubSub from "effect/PubSub"
|
|
7
|
+
import * as Semaphore from "effect/Semaphore"
|
|
8
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
9
|
+
import * as Stream from "effect/Stream"
|
|
10
|
+
import type { AgentFinished, Output } from "./Agent.ts"
|
|
6
11
|
import chalk from "chalk"
|
|
7
|
-
import type
|
|
12
|
+
import type * as Prompt from "effect/unstable/ai/Prompt"
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* @since 1.0.0
|
|
@@ -78,7 +83,7 @@ ${output.summary}\n\n`
|
|
|
78
83
|
)
|
|
79
84
|
|
|
80
85
|
const promptToString = (prompt: Prompt.Prompt): string => {
|
|
81
|
-
let textParts: string
|
|
86
|
+
let textParts: Array<string> = []
|
|
82
87
|
for (const message of prompt.content) {
|
|
83
88
|
if (message.role !== "user") continue
|
|
84
89
|
let content = message.content
|