clanka 0.2.49 → 0.2.51

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 (101) hide show
  1. package/dist/Agent.d.ts +20 -20
  2. package/dist/Agent.d.ts.map +1 -1
  3. package/dist/Agent.js +9 -9
  4. package/dist/Agent.js.map +1 -1
  5. package/dist/Agent.test.js +1 -0
  6. package/dist/Agent.test.js.map +1 -1
  7. package/dist/AgentExecutor.d.ts +62 -101
  8. package/dist/AgentExecutor.d.ts.map +1 -1
  9. package/dist/AgentExecutor.js +28 -7
  10. package/dist/AgentExecutor.js.map +1 -1
  11. package/dist/AgentTools.d.ts +6 -6
  12. package/dist/AgentTools.d.ts.map +1 -1
  13. package/dist/AgentTools.js +5 -5
  14. package/dist/AgentTools.js.map +1 -1
  15. package/dist/ApplyPatch.test.js +3 -3
  16. package/dist/ApplyPatch.test.js.map +1 -1
  17. package/dist/ChunkRepo.d.ts +16 -16
  18. package/dist/ChunkRepo.d.ts.map +1 -1
  19. package/dist/ChunkRepo.js +7 -6
  20. package/dist/ChunkRepo.js.map +1 -1
  21. package/dist/CodeChunker.d.ts +2 -2
  22. package/dist/CodeChunker.d.ts.map +1 -1
  23. package/dist/CodeChunker.js +2 -2
  24. package/dist/CodeChunker.js.map +1 -1
  25. package/dist/Codex.d.ts +1 -1
  26. package/dist/Codex.d.ts.map +1 -1
  27. package/dist/CodexAuth.d.ts +13 -7
  28. package/dist/CodexAuth.d.ts.map +1 -1
  29. package/dist/CodexAuth.js +13 -8
  30. package/dist/CodexAuth.js.map +1 -1
  31. package/dist/CodexAuth.test.js +1 -262
  32. package/dist/CodexAuth.test.js.map +1 -1
  33. package/dist/Copilot.d.ts +1 -1
  34. package/dist/Copilot.d.ts.map +1 -1
  35. package/dist/CopilotAuth.d.ts +13 -7
  36. package/dist/CopilotAuth.d.ts.map +1 -1
  37. package/dist/CopilotAuth.js +10 -5
  38. package/dist/CopilotAuth.js.map +1 -1
  39. package/dist/CopilotAuth.test.js +7 -8
  40. package/dist/CopilotAuth.test.js.map +1 -1
  41. package/dist/DeviceCodeHandler.d.ts +14 -0
  42. package/dist/DeviceCodeHandler.d.ts.map +1 -0
  43. package/dist/DeviceCodeHandler.js +9 -0
  44. package/dist/DeviceCodeHandler.js.map +1 -0
  45. package/dist/ExaSearch.d.ts +3 -3
  46. package/dist/ExaSearch.d.ts.map +1 -1
  47. package/dist/ExaSearch.js +2 -2
  48. package/dist/ExaSearch.js.map +1 -1
  49. package/dist/McpClient.d.ts +3 -3
  50. package/dist/McpClient.d.ts.map +1 -1
  51. package/dist/McpClient.js +2 -2
  52. package/dist/McpClient.js.map +1 -1
  53. package/dist/OutputFormatter.d.ts +2 -2
  54. package/dist/OutputFormatter.d.ts.map +1 -1
  55. package/dist/OutputFormatter.js +2 -2
  56. package/dist/OutputFormatter.js.map +1 -1
  57. package/dist/SemanticSearch/Service.d.ts +2 -2
  58. package/dist/SemanticSearch/Service.d.ts.map +1 -1
  59. package/dist/SemanticSearch/Service.js +2 -2
  60. package/dist/SemanticSearch/Service.js.map +1 -1
  61. package/dist/SemanticSearch.js +3 -3
  62. package/dist/SemanticSearch.js.map +1 -1
  63. package/dist/ToolkitRenderer.d.ts +2 -2
  64. package/dist/ToolkitRenderer.d.ts.map +1 -1
  65. package/dist/ToolkitRenderer.js +2 -2
  66. package/dist/ToolkitRenderer.js.map +1 -1
  67. package/dist/WebToMarkdown.d.ts +2 -2
  68. package/dist/WebToMarkdown.d.ts.map +1 -1
  69. package/dist/WebToMarkdown.js +2 -2
  70. package/dist/WebToMarkdown.js.map +1 -1
  71. package/dist/cli.js +2 -0
  72. package/dist/cli.js.map +1 -1
  73. package/dist/index.d.ts +4 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +4 -0
  76. package/dist/index.js.map +1 -1
  77. package/package.json +8 -6
  78. package/src/Agent.test.ts +1 -0
  79. package/src/Agent.ts +9 -9
  80. package/src/AgentExecutor.ts +46 -13
  81. package/src/AgentTools.ts +7 -7
  82. package/src/ApplyPatch.test.ts +3 -3
  83. package/src/ChunkRepo.ts +8 -6
  84. package/src/CodeChunker.ts +2 -2
  85. package/src/CodexAuth.test.ts +0 -433
  86. package/src/CodexAuth.ts +16 -19
  87. package/src/CopilotAuth.test.ts +11 -7
  88. package/src/CopilotAuth.ts +11 -7
  89. package/src/DeviceCodeHandler.ts +21 -0
  90. package/src/ExaSearch.ts +2 -2
  91. package/src/McpClient.ts +2 -2
  92. package/src/OutputFormatter.ts +2 -2
  93. package/src/SemanticSearch/Service.ts +2 -2
  94. package/src/SemanticSearch.ts +3 -3
  95. package/src/ToolkitRenderer.ts +2 -2
  96. package/src/WebToMarkdown.ts +2 -2
  97. package/src/cli.ts +2 -0
  98. package/src/fixtures/fiber.txt +9 -9
  99. package/src/fixtures/patch18-broken.txt +5 -5
  100. package/src/fixtures/patch18-fixed.txt +5 -5
  101. package/src/index.ts +5 -0
@@ -0,0 +1,21 @@
1
+ import * as Console from "effect/Console"
2
+ import type * as Effect from "effect/Effect"
3
+ import * as Layer from "effect/Layer"
4
+ import * as Context from "effect/Context"
5
+
6
+ export class DeviceCodeHandler extends Context.Service<
7
+ DeviceCodeHandler,
8
+ {
9
+ onCode(options: {
10
+ readonly verifyUrl: string
11
+ readonly deviceCode: string
12
+ }): Effect.Effect<void>
13
+ }
14
+ >()("clanka/DeviceCodeHandler") {}
15
+
16
+ export const layerConsole = Layer.succeed(DeviceCodeHandler, {
17
+ onCode: (options) =>
18
+ Console.log(
19
+ `Open ${options.verifyUrl} and enter code ${options.deviceCode}.`,
20
+ ),
21
+ })
package/src/ExaSearch.ts CHANGED
@@ -5,14 +5,14 @@ import * as Effect from "effect/Effect"
5
5
  import { pipe } from "effect/Function"
6
6
  import * as Layer from "effect/Layer"
7
7
  import * as Schema from "effect/Schema"
8
- import * as ServiceMap from "effect/ServiceMap"
8
+ import * as Context from "effect/Context"
9
9
  import * as McpClient from "./McpClient.ts"
10
10
 
11
11
  /**
12
12
  * @since 1.0.0
13
13
  * @category Services
14
14
  */
15
- export class ExaSearch extends ServiceMap.Service<
15
+ export class ExaSearch extends Context.Service<
16
16
  ExaSearch,
17
17
  {
18
18
  search(
package/src/McpClient.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  import * as Effect from "effect/Effect"
5
5
  import * as Layer from "effect/Layer"
6
6
  import * as Schema from "effect/Schema"
7
- import * as ServiceMap from "effect/ServiceMap"
7
+ import * as Context from "effect/Context"
8
8
  import { Client } from "@modelcontextprotocol/sdk/client"
9
9
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
10
10
  import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"
@@ -13,7 +13,7 @@ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"
13
13
  * @since 1.0.0
14
14
  * @category Services
15
15
  */
16
- export class McpClient extends ServiceMap.Service<
16
+ export class McpClient extends Context.Service<
17
17
  McpClient,
18
18
  {
19
19
  connect(options: {
@@ -5,7 +5,7 @@ import * as Effect from "effect/Effect"
5
5
  import * as Layer from "effect/Layer"
6
6
  import * as PubSub from "effect/PubSub"
7
7
  import * as Semaphore from "effect/Semaphore"
8
- import * as ServiceMap from "effect/ServiceMap"
8
+ import * as Context from "effect/Context"
9
9
  import * as Stream from "effect/Stream"
10
10
  import type { AgentFinished, Output } from "./Agent.ts"
11
11
  import chalk from "chalk"
@@ -138,7 +138,7 @@ const infoIcon = "\u{f05a}"
138
138
  * @since 1.0.0
139
139
  * @category Muxer
140
140
  */
141
- export class Muxer extends ServiceMap.Service<
141
+ export class Muxer extends Context.Service<
142
142
  Muxer,
143
143
  {
144
144
  add<E, R>(
@@ -3,13 +3,13 @@
3
3
  */
4
4
  import * as Effect from "effect/Effect"
5
5
  import * as Option from "effect/Option"
6
- import * as ServiceMap from "effect/ServiceMap"
6
+ import * as Context from "effect/Context"
7
7
 
8
8
  /**
9
9
  * @since 1.0.0
10
10
  * @category Services
11
11
  */
12
- export class SemanticSearch extends ServiceMap.Service<
12
+ export class SemanticSearch extends Context.Service<
13
13
  SemanticSearch,
14
14
  {
15
15
  search(options: {
@@ -157,7 +157,7 @@ export const layer = (options: {
157
157
  )
158
158
  const vector = new Float32Array(result.vector)
159
159
  yield* repo.insert(
160
- ChunkRepo.Chunk.insert.makeUnsafe({
160
+ ChunkRepo.Chunk.insert.make({
161
161
  path: options.chunk.path,
162
162
  hash,
163
163
  content: input,
@@ -177,7 +177,7 @@ export const layer = (options: {
177
177
  )
178
178
 
179
179
  const index = Effect.gen(function* () {
180
- const syncId = ChunkRepo.SyncId.makeUnsafe(crypto.randomUUID())
180
+ const syncId = ChunkRepo.SyncId.make(crypto.randomUUID())
181
181
  yield* Effect.logInfo("Starting SemanticSearch index")
182
182
 
183
183
  yield* pipe(
@@ -246,7 +246,7 @@ export const layer = (options: {
246
246
  return
247
247
  }
248
248
 
249
- const syncId = ChunkRepo.SyncId.makeUnsafe(crypto.randomUUID())
249
+ const syncId = ChunkRepo.SyncId.make(crypto.randomUUID())
250
250
 
251
251
  yield* pipe(
252
252
  Stream.fromArray(chunks),
@@ -4,7 +4,7 @@
4
4
  import * as Array from "effect/Array"
5
5
  import * as Layer from "effect/Layer"
6
6
  import * as SchemaAST from "effect/SchemaAST"
7
- import * as ServiceMap from "effect/ServiceMap"
7
+ import * as Context from "effect/Context"
8
8
  import type * as Tool from "effect/unstable/ai/Tool"
9
9
  import type * as Toolkit from "effect/unstable/ai/Toolkit"
10
10
  import * as TypeBuilder from "./TypeBuilder.ts"
@@ -14,7 +14,7 @@ import * as Function from "effect/Function"
14
14
  * @since 1.0.0
15
15
  * @category Services
16
16
  */
17
- export class ToolkitRenderer extends ServiceMap.Service<
17
+ export class ToolkitRenderer extends Context.Service<
18
18
  ToolkitRenderer,
19
19
  {
20
20
  render<Tools extends Record<string, Tool.Any>>(
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as Effect from "effect/Effect"
5
5
  import * as Layer from "effect/Layer"
6
- import * as ServiceMap from "effect/ServiceMap"
6
+ import * as Context from "effect/Context"
7
7
  import * as HttpClient from "effect/unstable/http/HttpClient"
8
8
  import type * as HttpClientError from "effect/unstable/http/HttpClientError"
9
9
  import TurndownService from "turndown"
@@ -12,7 +12,7 @@ import TurndownService from "turndown"
12
12
  * @since 1.0.0
13
13
  * @category Services
14
14
  */
15
- export class WebToMarkdown extends ServiceMap.Service<
15
+ export class WebToMarkdown extends Context.Service<
16
16
  WebToMarkdown,
17
17
  {
18
18
  convertHtml(html: string): Effect.Effect<string>
package/src/cli.ts CHANGED
@@ -20,6 +20,7 @@ import * as Config from "effect/Config"
20
20
  import * as KeyValueStore from "effect/unstable/persistence/KeyValueStore"
21
21
  import * as Option from "effect/Option"
22
22
  import { OpenAiClient, OpenAiEmbeddingModel } from "@effect/ai-openai"
23
+ import { DeviceCodeHandler } from "./index.ts"
23
24
 
24
25
  const provider = Flag.choice("provider", ["openai", "copilot"]).pipe(
25
26
  Flag.withAlias("p"),
@@ -221,6 +222,7 @@ Command.make("clanka", { provider, model, semantic, prompt }).pipe(
221
222
  Kvs,
222
223
  NodeHttpClient.layerUndici,
223
224
  NodeSocket.layerWebSocketConstructorWS,
225
+ DeviceCodeHandler.layerConsole,
224
226
  ]),
225
227
  NodeRuntime.runMain,
226
228
  )
@@ -19,7 +19,7 @@ export const getCurrentFiber = (): Fiber.Fiber<any, any> | undefined =>
19
19
  /** @internal */
20
20
  export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
21
21
  constructor(
22
- services: ServiceMap.ServiceMap<never>,
22
+ services: Context.Context<never>,
23
23
  interruptible: boolean = true,
24
24
  ) {
25
25
  this[FiberTypeId] = fiberVariance as any
@@ -51,7 +51,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
51
51
  _yielded: Exit.Exit<any, any> | (() => void) | undefined
52
52
 
53
53
  // set in setServices
54
- services!: ServiceMap.ServiceMap<never>
54
+ services!: Context.Context<never>
55
55
  currentScheduler!: Scheduler.Scheduler
56
56
  currentTracerContext: Tracer.Tracer["context"]
57
57
  currentSpan: Tracer.AnySpan | undefined
@@ -67,8 +67,8 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
67
67
  return (this._dispatcher ??= this.currentScheduler.makeDispatcher())
68
68
  }
69
69
 
70
- getRef<X>(ref: ServiceMap.Reference<X>): X {
71
- return ServiceMap.getReferenceUnsafe(this.services, ref)
70
+ getRef<X>(ref: Context.Reference<X>): X {
71
+ return Context.getReferenceUnsafe(this.services, ref)
72
72
  }
73
73
  addObserver(cb: (exit: Exit.Exit<A, E>) => void): () => void {
74
74
  if (this._exit) {
@@ -85,7 +85,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
85
85
  }
86
86
  interruptUnsafe(
87
87
  fiberId?: number | undefined,
88
- annotations?: ServiceMap.ServiceMap<never> | undefined,
88
+ annotations?: Context.Context<never> | undefined,
89
89
  ): void {
90
90
  if (this._exit) {
91
91
  return
@@ -94,7 +94,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
94
94
  if (this.currentStackFrame) {
95
95
  cause = causeAnnotate(
96
96
  cause,
97
- ServiceMap.make(CauseStackTrace, this.currentStackFrame),
97
+ Context.make(CauseStackTrace, this.currentStackFrame),
98
98
  )
99
99
  }
100
100
  if (annotations) {
@@ -208,7 +208,7 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
208
208
  pipe() {
209
209
  return pipeArguments(this, arguments)
210
210
  }
211
- setServices(services: ServiceMap.ServiceMap<never>): void {
211
+ setServices(services: Context.Context<never>): void {
212
212
  this.services = services
213
213
  const scheduler = this.getRef(Scheduler.Scheduler)
214
214
  if (scheduler !== this.currentScheduler) {
@@ -244,7 +244,7 @@ const fiberStackAnnotations = (fiber: Fiber.Fiber<any, any>) => {
244
244
  if (!fiber.currentStackFrame) return undefined
245
245
  const annotations = new Map<string, unknown>()
246
246
  annotations.set(CauseStackTrace.key, fiber.currentStackFrame)
247
- return ServiceMap.makeUnsafe(annotations)
247
+ return Context.makeUnsafe(annotations)
248
248
  }
249
249
 
250
250
  const fiberInterruptChildren = (fiber: FiberImpl) => {
@@ -252,4 +252,4 @@ const fiberInterruptChildren = (fiber: FiberImpl) => {
252
252
  return undefined
253
253
  }
254
254
  return fiberInterruptAll(fiber._children)
255
- }
255
+ }
@@ -138,7 +138,7 @@ The exact encoding can differ, but it must be:
138
138
  Add a required service responsible for resolving public keys to store ids.
139
139
 
140
140
  ```ts
141
- export class EventLogServerStoreRegistry extends ServiceMap.Service<EventLogServerStoreRegistry, {
141
+ export class EventLogServerStoreRegistry extends Context.Service<EventLogServerStoreRegistry, {
142
142
  readonly resolve: (publicKey: string) => Effect.Effect<StoreId, EventLogServerStoreRegistryError>
143
143
  readonly assign: (options: {
144
144
  readonly publicKey: string
@@ -197,7 +197,7 @@ Keep the required auth service from the original spec for client-originated
197
197
  traffic.
198
198
 
199
199
  ```ts
200
- export class EventLogServerAuth extends ServiceMap.Service<EventLogServerAuth, {
200
+ export class EventLogServerAuth extends Context.Service<EventLogServerAuth, {
201
201
  readonly authorizeWrite: (options: {
202
202
  readonly publicKey: string
203
203
  readonly entries: ReadonlyArray<Entry>
@@ -239,7 +239,7 @@ Update the transport-history storage abstraction so it is keyed by ` + "`StoreId
239
239
  public key.
240
240
 
241
241
  ```ts
242
- export class Storage extends ServiceMap.Service<Storage, {
242
+ export class Storage extends Context.Service<Storage, {
243
243
  readonly getId: Effect.Effect<RemoteId>
244
244
  readonly write: (options: {
245
245
  readonly storeId: StoreId
@@ -287,7 +287,7 @@ responsible for:
287
287
  Suggested shape:
288
288
 
289
289
  ```ts
290
- export class EventLogServerUnencrypted extends ServiceMap.Service<EventLogServerUnencrypted, {
290
+ export class EventLogServerUnencrypted extends Context.Service<EventLogServerUnencrypted, {
291
291
  readonly ingestClient: (options: {
292
292
  readonly publicKey: string
293
293
  readonly entries: ReadonlyArray<Entry>
@@ -1029,4 +1029,4 @@ kept in mind while designing the API:
1029
1029
  - richer typed convenience APIs for server-authored writes so callers do not
1030
1030
  need to manually construct ` + "`Entry`" + String.raw` values when that ergonomics becomes
1031
1031
  important
1032
- `
1032
+ `
@@ -138,7 +138,7 @@ The exact encoding can differ, but it must be:
138
138
  Add a required service responsible for resolving public keys to store ids.
139
139
 
140
140
  \`\`\`ts
141
- export class EventLogServerStoreRegistry extends ServiceMap.Service<EventLogServerStoreRegistry, {
141
+ export class EventLogServerStoreRegistry extends Context.Service<EventLogServerStoreRegistry, {
142
142
  readonly resolve: (publicKey: string) => Effect.Effect<StoreId, EventLogServerStoreRegistryError>
143
143
  readonly assign: (options: {
144
144
  readonly publicKey: string
@@ -197,7 +197,7 @@ Keep the required auth service from the original spec for client-originated
197
197
  traffic.
198
198
 
199
199
  \`\`\`ts
200
- export class EventLogServerAuth extends ServiceMap.Service<EventLogServerAuth, {
200
+ export class EventLogServerAuth extends Context.Service<EventLogServerAuth, {
201
201
  readonly authorizeWrite: (options: {
202
202
  readonly publicKey: string
203
203
  readonly entries: ReadonlyArray<Entry>
@@ -239,7 +239,7 @@ Update the transport-history storage abstraction so it is keyed by ` + "`StoreId
239
239
  public key.
240
240
 
241
241
  \`\`\`ts
242
- export class Storage extends ServiceMap.Service<Storage, {
242
+ export class Storage extends Context.Service<Storage, {
243
243
  readonly getId: Effect.Effect<RemoteId>
244
244
  readonly write: (options: {
245
245
  readonly storeId: StoreId
@@ -287,7 +287,7 @@ responsible for:
287
287
  Suggested shape:
288
288
 
289
289
  \`\`\`ts
290
- export class EventLogServerUnencrypted extends ServiceMap.Service<EventLogServerUnencrypted, {
290
+ export class EventLogServerUnencrypted extends Context.Service<EventLogServerUnencrypted, {
291
291
  readonly ingestClient: (options: {
292
292
  readonly publicKey: string
293
293
  readonly entries: ReadonlyArray<Entry>
@@ -1029,4 +1029,4 @@ kept in mind while designing the API:
1029
1029
  - richer typed convenience APIs for server-authored writes so callers do not
1030
1030
  need to manually construct ` + "`Entry`" + String.raw` values when that ergonomics becomes
1031
1031
  important
1032
- `
1032
+ `
package/src/index.ts CHANGED
@@ -28,6 +28,11 @@ export * as CodeChunker from "./CodeChunker.ts"
28
28
  */
29
29
  export * as Copilot from "./Copilot.ts"
30
30
 
31
+ /**
32
+ * @since 1.0.0
33
+ */
34
+ export * as DeviceCodeHandler from "./DeviceCodeHandler.ts"
35
+
31
36
  /**
32
37
  * @since 1.0.0
33
38
  */