@codeworksh/cli 0.3.0-canary.36.1.g9945773b → 0.3.0-canary.38.1.gc623a3eb
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/{acp-cPC9bjak.mjs → acp-I5zgK_rF.mjs} +3 -3
- package/{acp-cPC9bjak.mjs.map → acp-I5zgK_rF.mjs.map} +1 -1
- package/{add-B1SAcg06.mjs → add-DNUklw-1.mjs} +3 -3
- package/{add-B1SAcg06.mjs.map → add-DNUklw-1.mjs.map} +1 -1
- package/{check-CR9sclsm.mjs → check-kFowK1HH.mjs} +3 -3
- package/{check-CR9sclsm.mjs.map → check-kFowK1HH.mjs.map} +1 -1
- package/{entries-B8NQbs-T.mjs → entries-DK4If3_G.mjs} +3 -3
- package/{entries-B8NQbs-T.mjs.map → entries-DK4If3_G.mjs.map} +1 -1
- package/{error-DX_41fjo.mjs → error-CPo0lJt1.mjs} +4 -2
- package/error-CPo0lJt1.mjs.map +1 -0
- package/{identity-CVv4o4ef.mjs → identity-w6kME98x.mjs} +2 -2
- package/{identity-CVv4o4ef.mjs.map → identity-w6kME98x.mjs.map} +1 -1
- package/index.mjs +24 -24
- package/{install-D9Vj8y7R.mjs → install-BPF55E27.mjs} +3 -3
- package/{install-D9Vj8y7R.mjs.map → install-BPF55E27.mjs.map} +1 -1
- package/{link-qcVRRHd6.mjs → link-CVKXgNxQ.mjs} +2 -2
- package/{link-qcVRRHd6.mjs.map → link-CVKXgNxQ.mjs.map} +1 -1
- package/{list-j7pd2GYd.mjs → list-CjEHPoW7.mjs} +3 -3
- package/{list-j7pd2GYd.mjs.map → list-CjEHPoW7.mjs.map} +1 -1
- package/{list-BvYHjYrU.mjs → list-DRnMn-TS.mjs} +2 -2
- package/{list-BvYHjYrU.mjs.map → list-DRnMn-TS.mjs.map} +1 -1
- package/{login-B_b0JBhw.mjs → login-BSa_WYlV.mjs} +3 -3
- package/{login-B_b0JBhw.mjs.map → login-BSa_WYlV.mjs.map} +1 -1
- package/{logout-CazQJ7j7.mjs → logout-BP79XZqa.mjs} +3 -3
- package/{logout-CazQJ7j7.mjs.map → logout-BP79XZqa.mjs.map} +1 -1
- package/package-CPZXeEhq.mjs +6 -0
- package/package-CPZXeEhq.mjs.map +1 -0
- package/package.json +4 -4
- package/{providers-Ayi-HdX4.mjs → providers-CEw_yhL4.mjs} +2 -2
- package/{providers-Ayi-HdX4.mjs.map → providers-CEw_yhL4.mjs.map} +1 -1
- package/{refresh-TCB33nqi.mjs → refresh-BiN_5HeQ.mjs} +2 -2
- package/{refresh-TCB33nqi.mjs.map → refresh-BiN_5HeQ.mjs.map} +1 -1
- package/{refresh-BIUnxAMl.mjs → refresh-O6AOOTiX.mjs} +3 -3
- package/{refresh-BIUnxAMl.mjs.map → refresh-O6AOOTiX.mjs.map} +1 -1
- package/{reload-Ce0_GT0S.mjs → reload-DMJ4jfv6.mjs} +2 -2
- package/{reload-Ce0_GT0S.mjs.map → reload-DMJ4jfv6.mjs.map} +1 -1
- package/{remove-CheUuyPa.mjs → remove-DXODbsDw.mjs} +3 -3
- package/{remove-CheUuyPa.mjs.map → remove-DXODbsDw.mjs.map} +1 -1
- package/{restart-BWknvqRJ.mjs → restart-DaJeZyor.mjs} +3 -3
- package/{restart-BWknvqRJ.mjs.map → restart-DaJeZyor.mjs.map} +1 -1
- package/{run-B3ZAC2hS.mjs → run-C19PINh0.mjs} +2 -2
- package/{run-B3ZAC2hS.mjs.map → run-C19PINh0.mjs.map} +1 -1
- package/{serve-Bnbl161Q.mjs → serve-CfAjy9Ft.mjs} +5 -4
- package/serve-CfAjy9Ft.mjs.map +1 -0
- package/{service-Ct21IdRt.mjs → service-Bv9A1pOh.mjs} +3 -3
- package/{service-Ct21IdRt.mjs.map → service-Bv9A1pOh.mjs.map} +1 -1
- package/{settings-BFphEXdJ.mjs → settings-BHxEl9yP.mjs} +2 -2
- package/{settings-BFphEXdJ.mjs.map → settings-BHxEl9yP.mjs.map} +1 -1
- package/{shared-Bwij5nJf.mjs → shared-CCdYmc2s.mjs} +2 -2
- package/{shared-Bwij5nJf.mjs.map → shared-CCdYmc2s.mjs.map} +1 -1
- package/{start-BgKd-1zM.mjs → start-DyssDnmr.mjs} +3 -3
- package/{start-BgKd-1zM.mjs.map → start-DyssDnmr.mjs.map} +1 -1
- package/{status-BW3CW3qc.mjs → status-D-DUySYj.mjs} +3 -3
- package/{status-BW3CW3qc.mjs.map → status-D-DUySYj.mjs.map} +1 -1
- package/{status-CZv1vZz8.mjs → status-JqyYbpR6.mjs} +3 -3
- package/{status-CZv1vZz8.mjs.map → status-JqyYbpR6.mjs.map} +1 -1
- package/{stop-pkmzg8yC.mjs → stop-C66c4rkN.mjs} +3 -3
- package/{stop-pkmzg8yC.mjs.map → stop-C66c4rkN.mjs.map} +1 -1
- package/{tui-DBwWDTpR.mjs → tui-29VBbdeK.mjs} +4 -4
- package/{tui-DBwWDTpR.mjs.map → tui-29VBbdeK.mjs.map} +1 -1
- package/{update-Bg2lCTQP.mjs → update-DZiXdSAV.mjs} +3 -3
- package/{update-Bg2lCTQP.mjs.map → update-DZiXdSAV.mjs.map} +1 -1
- package/error-DX_41fjo.mjs.map +0 -1
- package/package-kn0jeDdD.mjs +0 -6
- package/package-kn0jeDdD.mjs.map +0 -1
- package/serve-Bnbl161Q.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-CPZXeEhq.mjs";
|
|
2
2
|
import { i as Cmd, t as handler } from "./runtime-B43doHjV.mjs";
|
|
3
|
-
import { i as reportFailure } from "./error-
|
|
3
|
+
import { i as reportFailure } from "./error-CPo0lJt1.mjs";
|
|
4
4
|
import { t as harnessOptions } from "./harness-6d8TlAVk.mjs";
|
|
5
5
|
import { Cause, DateTime, Deferred, Effect, Exit, Fiber, Logger, Option, Schema, Stdio, Stream } from "effect";
|
|
6
6
|
import { Model } from "@codeworksh/aikit";
|
|
@@ -491,4 +491,4 @@ var acp_default = handler(Cmd.commands.acp, Effect.fn("CLI.acp", { level: "Info"
|
|
|
491
491
|
//#endregion
|
|
492
492
|
export { acp_default as default };
|
|
493
493
|
|
|
494
|
-
//# sourceMappingURL=acp-
|
|
494
|
+
//# sourceMappingURL=acp-I5zgK_rF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-cPC9bjak.mjs","names":["serve","Agent.RequestError","pkg.version","Config.options","Feed.replay","Config.parseModel","Config.known","Config.isThinkingLevel","update","Feed.update","notice","Feed.notice","Feed.noticeUpdate","Handlers.make","Agent.serve","Runtime.handler","Server.serve"],"sources":["../../src/acp/agent.ts","../../src/acp/config.ts","../../src/acp/feed.ts","../../src/acp/handlers.ts","../../src/acp/server.ts","../../src/cli/cmd/handlers/acp.ts"],"sourcesContent":["import * as Acp from \"@agentclientprotocol/sdk\";\nimport { Cause, Deferred, Effect, Exit, Option, Schema, type Scope, type Stdio, Stream } from \"effect\";\n\n/** A JSON-RPC error a handler answers a request with. */\nexport class RequestError extends Schema.TaggedError<RequestError>()(\"AcpRequestError\", {\n\tcode: Schema.Int,\n\tmessage: Schema.String,\n}) {\n\tstatic invalidRequest = (message: string) => new RequestError({ code: -32600, message });\n\tstatic invalidParams = (message: string) => new RequestError({ code: -32602, message });\n\tstatic internalError = (message: string) => new RequestError({ code: -32603, message });\n\tstatic resourceNotFound = (message: string) => new RequestError({ code: -32002, message });\n}\n\ntype Handler<Request, Response> = (request: Request) => Effect.Effect<Response, RequestError>;\n\n/** Calls the agent makes to the connected client. */\nexport interface Client {\n\treadonly sessionUpdate: (notification: Acp.SessionNotification) => Effect.Effect<void, RequestError>;\n}\n\nexport interface Handlers {\n\treadonly initialize: Handler<Acp.InitializeRequest, Acp.InitializeResponse>;\n\treadonly newSession: Handler<Acp.NewSessionRequest, Acp.NewSessionResponse>;\n\t/** Must replay the session's history through `Client.sessionUpdate` before it returns. */\n\treadonly loadSession: Handler<Acp.LoadSessionRequest, Acp.LoadSessionResponse>;\n\treadonly listSessions: Handler<Acp.ListSessionsRequest, Acp.ListSessionsResponse>;\n\treadonly setConfigOption: Handler<Acp.SetSessionConfigOptionRequest, Acp.SetSessionConfigOptionResponse>;\n\treadonly prompt: Handler<Acp.PromptRequest, Acp.PromptResponse>;\n\treadonly cancel: (notification: Acp.CancelNotification) => Effect.Effect<void>;\n}\n\n/**\n * Serves an ACP agent over `stdio` until the client closes its end.\n *\n * Handlers run as fibers on this effect's services; a request the client cancels, or the\n * connection closing, interrupts its fiber.\n */\nexport const serve = Effect.fn(\"ACP.serve\")(function* (\n\tstdio: Stdio.Stdio,\n\tmakeHandlers: (client: Client) => Handlers,\n): Effect.fn.Return<void, never, Scope.Scope> {\n\tconst context = yield* Effect.context<never>();\n\tconst runExit = Effect.runPromiseExitWith(context);\n\tconst opened = yield* Deferred.make<Acp.AgentConnection>();\n\n\tconst handlers = makeHandlers({\n\t\tsessionUpdate: (notification) =>\n\t\t\tDeferred.await(opened).pipe(\n\t\t\t\tEffect.flatMap((connection) =>\n\t\t\t\t\tEffect.tryPromise({\n\t\t\t\t\t\ttry: () => connection.client.notify(Acp.methods.client.session.update, notification),\n\t\t\t\t\t\tcatch: (error) => RequestError.internalError(`Failed to send session/update: ${String(error)}`),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n\n\t// A JSON-RPC answer for a handler that didn't succeed; the SDK sends what `handle` throws.\n\tconst toWire = (cause: Cause.Cause<RequestError>): Acp.RequestError => {\n\t\tconst error = Cause.findErrorOption(cause);\n\t\tif (Option.isSome(error)) return new Acp.RequestError(error.value.code, error.value.message);\n\t\tif (Cause.hasInterruptsOnly(cause)) return Acp.RequestError.requestCancelled();\n\t\treturn Acp.RequestError.internalError(undefined, String(Cause.squash(cause)));\n\t};\n\tconst handle =\n\t\t<Params, A>(handler: (params: Params) => Effect.Effect<A, RequestError>) =>\n\t\t({ params, signal }: { readonly params: Params; readonly signal: AbortSignal }): Promise<A> =>\n\t\t\trunExit(handler(params), { signal }).then((exit) => {\n\t\t\t\tif (Exit.isSuccess(exit)) return exit.value;\n\t\t\t\tthrow toWire(exit.cause);\n\t\t\t});\n\n\tconst input = yield* Stream.toReadableStreamEffect(stdio.stdin);\n\tconst output = new WritableStream<Uint8Array>({\n\t\twrite: (chunk) => Effect.runPromiseWith(context)(Stream.run(Stream.make(chunk), stdio.stdout())),\n\t});\n\n\tconst connection = Acp.agent({ name: \"codework\" })\n\t\t.onRequest(\"initialize\", handle(handlers.initialize))\n\t\t.onRequest(\"session/new\", handle(handlers.newSession))\n\t\t.onRequest(\"session/load\", handle(handlers.loadSession))\n\t\t.onRequest(\"session/list\", handle(handlers.listSessions))\n\t\t.onRequest(\"session/set_config_option\", handle(handlers.setConfigOption))\n\t\t.onRequest(\"session/prompt\", handle(handlers.prompt))\n\t\t.onNotification(\"session/cancel\", handle(handlers.cancel))\n\t\t.connect(Acp.ndJsonStream(output, input));\n\tyield* Deferred.succeed(opened, connection);\n\tyield* Effect.addFinalizer(() => Effect.sync(() => connection.close()));\n\tyield* Effect.promise(() => connection.closed);\n});\n\nexport * as Agent from \"./agent.ts\";\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport { Model } from \"@codeworksh/aikit\";\nimport { ModelCatalog, Settings, type State } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } from \"effect\";\n\nexport const MODEL = \"model\";\nexport const THOUGHT_LEVEL = \"thought_level\";\n\nconst thinkingLabels: Record<Model.ThinkingLevel, string> = {\n\toff: \"Off\",\n\tminimal: \"Minimal\",\n\tlow: \"Low\",\n\tmedium: \"Medium\",\n\thigh: \"High\",\n\txhigh: \"Extra High\",\n\tmax: \"Max\",\n};\n\nexport const isThinkingLevel = (value: string): value is Model.ThinkingLevel => Object.hasOwn(thinkingLabels, value);\n\n/** Splits a `provider/model` option value on its first slash; model ids may contain more. */\nexport const parseModel = (value: string): Option.Option<{ readonly provider: string; readonly id: string }> => {\n\tconst slash = value.indexOf(\"/\");\n\tif (slash <= 0 || slash === value.length - 1) return Option.none();\n\treturn Option.some({ provider: value.slice(0, slash), id: value.slice(slash + 1) });\n};\n\n/** The catalog a session in `hostDir` sees: generated entries plus its settings' `models`. */\nconst catalogFor = (hostDir: string | undefined) =>\n\tEffect.gen(function* () {\n\t\tconst settings = yield* Settings.Service;\n\t\treturn yield* ModelCatalog.effective((yield* settings.load(hostDir)).models);\n\t}).pipe(Effect.orElseSucceed((): Model.BuiltInModels => ({})));\n\n/** The `model` and `thought_level` selectors for a session's current configuration. */\nexport const options = Effect.fn(\"ACP.config.options\")(function* (\n\tselection: State.Configuration,\n\thostDir: string | undefined,\n) {\n\tconst catalog = yield* catalogFor(hostDir);\n\t// Providers the harness has credentials for; the current model stays selectable even if not.\n\tconst providers = yield* ModelCatalog.available(hostDir === undefined ? {} : { hostDir }).pipe(\n\t\tEffect.orElseSucceed(() => []),\n\t);\n\n\tconst current = `${selection.provider}/${selection.model}`;\n\tconst models = providers.flatMap((provider) =>\n\t\tObject.entries(provider.models).map(([id, info]) => ({\n\t\t\tvalue: `${provider.id}/${id}`,\n\t\t\tname: `${info.provider.name}: ${info.name}`,\n\t\t})),\n\t);\n\tif (!models.some((option) => option.value === current)) models.unshift({ value: current, name: current });\n\n\tconst result: Array<Acp.SessionConfigOption> = [\n\t\t{ id: MODEL, name: \"Model\", category: \"model\", type: \"select\", currentValue: current, options: models },\n\t];\n\n\tconst info = catalog[selection.provider]?.[selection.model];\n\tconst levels = info === undefined ? [] : Model.getSupportedThinkingLevels(info);\n\tif (levels.some((level) => level !== \"off\")) {\n\t\tresult.push({\n\t\t\tid: THOUGHT_LEVEL,\n\t\t\tname: \"Thinking Effort\",\n\t\t\tcategory: \"thought_level\",\n\t\t\ttype: \"select\",\n\t\t\tcurrentValue: selection.thinkingLevel,\n\t\t\toptions: levels.map((level) => ({ value: level, name: thinkingLabels[level] })),\n\t\t});\n\t}\n\treturn result;\n});\n\n/** Whether a model is in the catalog a session in `hostDir` sees. */\nexport const known = Effect.fn(\"ACP.config.known\")(function* (\n\tmodel: { readonly provider: string; readonly id: string },\n\thostDir: string | undefined,\n) {\n\tconst catalog = yield* catalogFor(hostDir);\n\treturn catalog[model.provider]?.[model.id] !== undefined;\n});\n\nexport * as Config from \"./config.ts\";\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport { EventList, type EventSchema, type SessionStore } from \"@codeworksh/harness/effect\";\nimport { Option, Schema } from \"effect\";\n\nconst isTextDelta = Schema.is(EventList.LLMTextDelta);\nconst isThinkingDelta = Schema.is(EventList.LLMThinkingDelta);\nconst isToolStarted = Schema.is(EventList.ToolStarted);\nconst isToolSettled = Schema.is(EventList.ToolSettled);\nconst isPluginUpdated = Schema.is(EventList.PluginUpdated);\n\nconst TextContent = Schema.Struct({ type: Schema.Literal(\"text\"), text: Schema.String });\nconst ImageContent = Schema.Struct({ type: Schema.Literal(\"image\"), data: Schema.String, mimeType: Schema.String });\nconst ToolResult = Schema.Struct({\n\tcontent: Schema.Array(Schema.Union([TextContent, Schema.Struct({ type: Schema.Literal(\"image\") })])),\n\tisError: Schema.Boolean,\n});\nconst ToolCall = Schema.Struct({\n\ttype: Schema.Literal(\"toolCall\"),\n\tcallID: Schema.String,\n\tname: Schema.String,\n\targuments: Schema.Record(Schema.String, Schema.Json),\n\tstatus: Schema.String,\n\tresult: Schema.optional(ToolResult),\n});\nconst StoredPart = Schema.Union([\n\tTextContent,\n\tImageContent,\n\tSchema.Struct({ type: Schema.Literal(\"thinking\"), thinking: Schema.String }),\n\tToolCall,\n]);\nconst decodePart = Schema.decodeUnknownOption(Schema.fromJsonString(StoredPart));\n\ntype ToolCall = typeof ToolCall.Type;\n\nconst text = (value: string): Acp.ContentBlock => ({ type: \"text\", text: value });\n\n// The kind comes from the tool's name. Only `bash` ships built in; plugin tools report `other`.\nconst kind = (name: string): Acp.ToolKind => (name === \"bash\" ? \"execute\" : \"other\");\n\n/** The command for `bash`, otherwise the tool's label or name. */\nconst title = (name: string, args: Readonly<Record<string, unknown>>, label?: string): string =>\n\tname === \"bash\" && typeof args.command === \"string\" ? args.command : (label ?? name);\n\nconst settled = (call: Pick<ToolCall, \"callID\" | \"name\" | \"arguments\" | \"status\" | \"result\">): Acp.SessionUpdate => {\n\tconst output = call.result?.content.flatMap((block) => (block.type === \"text\" ? [block.text] : [])).join(\"\\n\");\n\treturn {\n\t\tsessionUpdate: \"tool_call_update\",\n\t\ttoolCallId: call.callID,\n\t\tkind: kind(call.name),\n\t\tstatus: call.status === \"completed\" ? \"completed\" : \"failed\",\n\t\trawInput: call.arguments,\n\t\t...(call.result === undefined ? {} : { rawOutput: call.result }),\n\t\t...(output ? { content: [{ type: \"content\", content: text(output) }] } : {}),\n\t};\n};\n\n/** The live `session/update` for a harness event, if the client should see one. */\nexport const update = (event: EventSchema.Payload): Option.Option<Acp.SessionUpdate> => {\n\tif (isTextDelta(event)) {\n\t\treturn Option.some({ sessionUpdate: \"agent_message_chunk\", content: text(event.data.delta) });\n\t}\n\tif (isThinkingDelta(event)) {\n\t\treturn Option.some({ sessionUpdate: \"agent_thought_chunk\", content: text(event.data.delta) });\n\t}\n\tif (isToolStarted(event)) {\n\t\treturn Option.some({\n\t\t\tsessionUpdate: \"tool_call\",\n\t\t\ttoolCallId: event.data.callID,\n\t\t\ttitle: title(event.data.name, event.data.arguments, event.data.label),\n\t\t\tkind: kind(event.data.name),\n\t\t\tstatus: \"in_progress\",\n\t\t\trawInput: event.data.arguments,\n\t\t});\n\t}\n\tif (isToolSettled(event)) return Option.some(settled(event.data.part));\n\treturn Option.none();\n};\n\n/**\n * Text for the user about a plugin that failed to load, such as one configured but not installed.\n * It belongs in the conversation because the user may never see this process's logs.\n */\nexport const notice = (event: EventSchema.Payload): Option.Option<string> =>\n\tisPluginUpdated(event) && event.data.status === \"failed\" && event.data.error !== undefined\n\t\t? Option.some(event.data.error)\n\t\t: Option.none();\n\n/** A notice shown to the user in the agent's message. */\nexport const noticeUpdate = (notice: string): Acp.SessionUpdate => ({\n\tsessionUpdate: \"agent_message_chunk\",\n\tcontent: text(`> ⚠ ${notice}\\n\\n`),\n});\n\n/** The `session/update`s that replay one stored entry during `session/load`. */\nexport const replay = ({ entry, parts }: SessionStore.HydratedEntry): ReadonlyArray<Acp.SessionUpdate> => {\n\tif (entry.type !== \"user\" && entry.type !== \"assistant\") return [];\n\treturn parts.flatMap((row): ReadonlyArray<Acp.SessionUpdate> => {\n\t\tconst part = decodePart(row.data);\n\t\tif (Option.isNone(part)) return [];\n\t\tswitch (part.value.type) {\n\t\t\tcase \"text\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: entry.type === \"user\" ? \"user_message_chunk\" : \"agent_message_chunk\",\n\t\t\t\t\t\tcontent: text(part.value.text),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\tcase \"image\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: entry.type === \"user\" ? \"user_message_chunk\" : \"agent_message_chunk\",\n\t\t\t\t\t\tcontent: { type: \"image\", data: part.value.data, mimeType: part.value.mimeType },\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\tcase \"thinking\":\n\t\t\t\treturn [{ sessionUpdate: \"agent_thought_chunk\", content: text(part.value.thinking) }];\n\t\t\tcase \"toolCall\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: \"tool_call\",\n\t\t\t\t\t\ttoolCallId: part.value.callID,\n\t\t\t\t\t\ttitle: title(part.value.name, part.value.arguments),\n\t\t\t\t\t\tkind: kind(part.value.name),\n\t\t\t\t\t\tstatus: \"in_progress\",\n\t\t\t\t\t\trawInput: part.value.arguments,\n\t\t\t\t\t},\n\t\t\t\t\tsettled(part.value),\n\t\t\t\t];\n\t\t}\n\t});\n};\n\nexport * as Feed from \"./feed.ts\";\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport {\n\tControl,\n\tEventList,\n\ttype EventSchema,\n\ttype Harness,\n\tPromptSchema,\n\tSession,\n\tSessionStore,\n} from \"@codeworksh/harness/effect\";\nimport { DateTime, Effect, Fiber, type Layer, Option, Schema, Stream } from \"effect\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\nimport { Agent } from \"./agent.ts\";\nimport { Config } from \"./config.ts\";\nimport { Feed } from \"./feed.ts\";\n\nconst PAGE_SIZE = 50;\n\nconst isRequestError = Schema.is(Agent.RequestError);\nconst isNotFound = Schema.is(SessionStore.SessionNotFoundError);\nconst isConflict = Schema.is(Control.PromptConflictError);\nconst isInvalidPrompt = Schema.is(PromptSchema.InvalidPromptError);\nconst isLLMEnded = Schema.is(EventList.LLMEnded);\nconst isSucceeded = Schema.is(EventList.ExecutionSucceeded);\nconst isFailed = Schema.is(EventList.ExecutionFailed);\nconst isInterrupted = Schema.is(EventList.ExecutionInterrupted);\nconst isSettled = (event: EventSchema.Payload) => isSucceeded(event) || isFailed(event) || isInterrupted(event);\n\n/** Harness failures as JSON-RPC errors; handlers raise protocol-level ones directly. */\nconst toRequestError = (error: { readonly message: string }): Agent.RequestError => {\n\tif (isRequestError(error)) return error;\n\tif (isNotFound(error)) return Agent.RequestError.resourceNotFound(`Session not found: ${error.sessionId}`);\n\tif (isConflict(error)) return Agent.RequestError.invalidRequest(error.message);\n\tif (isInvalidPrompt(error)) return Agent.RequestError.invalidParams(error.message);\n\treturn Agent.RequestError.internalError(error.message);\n};\n\n/**\n * Prompt content as harness prompt parts, in order. Text, embedded context and images are\n * advertised; anything else is rejected. Adjacent text joins into one part. The harness checks\n * the images.\n */\nconst promptParts = Effect.fnUntraced(function* (blocks: ReadonlyArray<Acp.ContentBlock>) {\n\tconst parts: Array<PromptSchema.Part> = [];\n\tconst add = (part: PromptSchema.Part) => {\n\t\tconst last = parts.at(-1);\n\t\tif (part.type === \"text\" && last?.type === \"text\")\n\t\t\tparts[parts.length - 1] = { ...last, text: `${last.text}\\n\\n${part.text}` };\n\t\telse parts.push(part);\n\t};\n\tfor (const block of blocks) {\n\t\tswitch (block.type) {\n\t\t\tcase \"text\":\n\t\t\t\tadd({ type: \"text\", text: block.text });\n\t\t\t\tbreak;\n\t\t\tcase \"resource_link\":\n\t\t\t\tadd({ type: \"text\", text: `[${block.name}](${block.uri})` });\n\t\t\t\tbreak;\n\t\t\tcase \"image\":\n\t\t\t\tadd({ type: \"image\", data: block.data, mimeType: block.mimeType });\n\t\t\t\tbreak;\n\t\t\tcase \"resource\":\n\t\t\t\tif (\"text\" in block.resource) {\n\t\t\t\t\tadd({ type: \"text\", text: `\\`\\`\\`${block.resource.uri}\\n${block.resource.text}\\n\\`\\`\\`` });\n\t\t\t\t} else if (block.resource.mimeType?.startsWith(\"image/\")) {\n\t\t\t\t\tadd({ type: \"image\", data: block.resource.blob, mimeType: block.resource.mimeType });\n\t\t\t\t} else {\n\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unsupported binary resource: ${block.resource.uri}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unsupported prompt content: ${block.type}`);\n\t\t}\n\t}\n\treturn parts;\n});\n\nconst sessionId = (id: string) => Session.SessionSchema.ID.make(id);\n\ntype Services = Layer.Success<ReturnType<typeof Harness.layer>>;\n\nexport const make = Effect.gen(function* () {\n\tconst control = yield* Control.Service;\n\tconst sessions = yield* SessionStore.Service;\n\t// Handlers run on the agent's fibers, outside this layer; they carry the harness with them.\n\tconst context = yield* Effect.context<Services>();\n\n\tconst running = new Set<string>();\n\n\tconst found = Effect.fn(\"ACP.found\")(function* (id: string) {\n\t\tconst row = yield* sessions.get(sessionId(id));\n\t\tif (Option.isNone(row)) return yield* new SessionStore.SessionNotFoundError({ sessionId: sessionId(id) });\n\t\treturn row.value;\n\t});\n\n\treturn (client: Agent.Client): Agent.Handlers => {\n\t\tconst run = <A, E extends { readonly message: string }>(effect: Effect.Effect<A, E, Services>) =>\n\t\t\teffect.pipe(Effect.provide(context), Effect.mapError(toRequestError));\n\n\t\treturn {\n\t\t\tinitialize: () =>\n\t\t\t\tEffect.succeed({\n\t\t\t\t\tprotocolVersion: 1,\n\t\t\t\t\tagentInfo: { name: \"codework\", version: pkg.version },\n\t\t\t\t\tagentCapabilities: {\n\t\t\t\t\t\tloadSession: true,\n\t\t\t\t\t\tpromptCapabilities: { embeddedContext: true, image: true },\n\t\t\t\t\t\tsessionCapabilities: { list: {} },\n\t\t\t\t\t},\n\t\t\t\t}),\n\n\t\t\tnewSession: ({ cwd }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst handle = yield* Session.create({ directory: cwd, hostDir: cwd });\n\t\t\t\t\t\tconst current = yield* Session.configuration(handle.id);\n\t\t\t\t\t\treturn { sessionId: handle.id, configOptions: yield* Config.options(current, cwd) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tloadSession: ({ sessionId: id }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tyield* Session.attach({ sessionId: sessionId(id) });\n\t\t\t\t\t\tconst row = yield* found(id);\n\t\t\t\t\t\tconst hostDir = Option.getOrUndefined(row.hostDir);\n\t\t\t\t\t\tconst current = yield* Session.configuration(row.id);\n\t\t\t\t\t\tfor (const entry of yield* sessions.path(sessionId(id))) {\n\t\t\t\t\t\t\tfor (const update of Feed.replay(entry)) {\n\t\t\t\t\t\t\t\tyield* client.sessionUpdate({ sessionId: id, update });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { configOptions: yield* Config.options(current, hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tlistSessions: ({ cwd, cursor }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst rows = (yield* sessions.list())\n\t\t\t\t\t\t\t.filter((row) => cwd == null || Option.getOrUndefined(row.hostDir) === cwd)\n\t\t\t\t\t\t\t.sort((a, b) => DateTime.Order(b.updatedAt ?? b.createdAt, a.updatedAt ?? a.createdAt));\n\t\t\t\t\t\tconst offset = cursor == null ? 0 : Number(cursor);\n\t\t\t\t\t\tif (!Number.isSafeInteger(offset) || offset < 0) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Invalid cursor: ${cursor}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst next = offset + PAGE_SIZE;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsessions: rows.slice(offset, next).map((row) => ({\n\t\t\t\t\t\t\t\tsessionId: row.id,\n\t\t\t\t\t\t\t\tcwd: Option.getOrElse(row.hostDir, () => row.directory),\n\t\t\t\t\t\t\t\ttitle: row.title,\n\t\t\t\t\t\t\t\tupdatedAt: DateTime.formatIso(row.updatedAt ?? row.createdAt),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t...(next < rows.length ? { nextCursor: String(next) } : {}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tsetConfigOption: (request) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst row = yield* found(request.sessionId);\n\t\t\t\t\t\tconst hostDir = Option.getOrUndefined(row.hostDir);\n\t\t\t\t\t\tconst value = String(request.value);\n\t\t\t\t\t\tif (request.configId === Config.MODEL) {\n\t\t\t\t\t\t\tconst model = Option.getOrUndefined(Config.parseModel(value));\n\t\t\t\t\t\t\tif (model === undefined || !(yield* Config.known(model, hostDir))) {\n\t\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown model: ${value}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tyield* Session.attach({ sessionId: row.id, model });\n\t\t\t\t\t\t} else if (request.configId === Config.THOUGHT_LEVEL) {\n\t\t\t\t\t\t\tif (!Config.isThinkingLevel(value)) {\n\t\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown thinking level: ${value}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tyield* Session.attach({ sessionId: row.id, thinkingLevel: value });\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown config option: ${request.configId}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { configOptions: yield* Config.options(yield* Session.configuration(row.id), hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tprompt: ({ sessionId: id, prompt }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst parts = yield* promptParts(prompt);\n\t\t\t\t\t\tconst handle = Option.getOrUndefined(yield* Session.get(sessionId(id)));\n\t\t\t\t\t\tif (handle === undefined) {\n\t\t\t\t\t\t\treturn yield* new SessionStore.SessionNotFoundError({ sessionId: sessionId(id) });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (running.has(id)) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidRequest(\"A prompt is already running for this session\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\trunning.add(id);\n\t\t\t\t\t\tyield* Effect.addFinalizer(() => Effect.sync(() => running.delete(id)));\n\n\t\t\t\t\t\t// Forward this execution's updates until it settles; the settling event decides the answer.\n\t\t\t\t\t\tlet reason: EventList.LLMEnded[\"data\"][\"reason\"] | undefined;\n\t\t\t\t\t\t// Plugins are checked every exchange; tell the user about each failure once per prompt.\n\t\t\t\t\t\tconst notices = new Set<string>();\n\t\t\t\t\t\tconst settled = yield* handle.events().pipe(\n\t\t\t\t\t\t\tStream.tap((event) => {\n\t\t\t\t\t\t\t\tif (isLLMEnded(event)) reason = event.data.reason;\n\t\t\t\t\t\t\t\tlet update = Feed.update(event);\n\t\t\t\t\t\t\t\tconst notice = Feed.notice(event);\n\t\t\t\t\t\t\t\tif (Option.isSome(notice) && !notices.has(notice.value)) {\n\t\t\t\t\t\t\t\t\tnotices.add(notice.value);\n\t\t\t\t\t\t\t\t\tupdate = Option.some(Feed.noticeUpdate(notice.value));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn Option.match(update, {\n\t\t\t\t\t\t\t\t\tonNone: () => Effect.void,\n\t\t\t\t\t\t\t\t\tonSome: (update) => client.sessionUpdate({ sessionId: id, update }).pipe(Effect.ignore),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tStream.filter(isSettled),\n\t\t\t\t\t\t\tStream.runHead,\n\t\t\t\t\t\t\tEffect.forkScoped({ startImmediately: true }),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst before = (yield* handle.info).title;\n\t\t\t\t\t\tyield* handle.run({ parts });\n\t\t\t\t\t\tconst end = yield* Fiber.join(settled);\n\n\t\t\t\t\t\t// The harness titles a session from its first prompt; tell the editor.\n\t\t\t\t\t\tconst { title } = yield* handle.info;\n\t\t\t\t\t\tif (title !== before) {\n\t\t\t\t\t\t\tyield* client\n\t\t\t\t\t\t\t\t.sessionUpdate({ sessionId: id, update: { sessionUpdate: \"session_info_update\", title } })\n\t\t\t\t\t\t\t\t.pipe(Effect.ignore);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (Option.isNone(end) || isInterrupted(end.value)) return { stopReason: \"cancelled\" as const };\n\t\t\t\t\t\tif (isFailed(end.value)) return yield* Agent.RequestError.internalError(end.value.data.error.message);\n\t\t\t\t\t\treturn { stopReason: reason === \"length\" ? (\"max_tokens\" as const) : (\"end_turn\" as const) };\n\t\t\t\t\t}).pipe(Effect.scoped),\n\t\t\t\t),\n\n\t\t\tcancel: ({ sessionId: id }) => control.interrupt(sessionId(id), { reason: \"user\" }).pipe(Effect.asVoid),\n\t\t};\n\t};\n});\n\nexport * as Handlers from \"./handlers.ts\";\n","import { Control, Harness, Sandbox } from \"@codeworksh/harness/effect\";\nimport { Effect, Logger, Stdio } from \"effect\";\nimport { Agent } from \"./agent.ts\";\nimport { Handlers } from \"./handlers.ts\";\n\n// Sessions and managed sandboxes outlive any single request; the connection's end is what stops them.\nconst shutdown = Effect.gen(function* () {\n\tconst control = yield* Control.Service;\n\tyield* Effect.forEach(\n\t\tyield* control.active,\n\t\t(id) =>\n\t\t\tcontrol\n\t\t\t\t.interrupt(id, { reason: \"shutdown\", awaitSettlement: true })\n\t\t\t\t.pipe(Effect.timeout(\"10 seconds\"), Effect.ignore),\n\t\t{ concurrency: \"unbounded\", discard: true },\n\t);\n\tconst managed = (yield* Sandbox.list()).filter((info) => info.ownership === \"managed\");\n\tyield* Effect.forEach(\n\t\tmanaged,\n\t\t(info) =>\n\t\t\tSandbox.stop(info.id).pipe(\n\t\t\t\tEffect.timeout(\"10 seconds\"),\n\t\t\t\tEffect.catchCause((cause) =>\n\t\t\t\t\tEffect.logError(\"Failed to stop managed sandbox during ACP shutdown\", cause).pipe(\n\t\t\t\t\t\tEffect.annotateLogs({ sandboxInstanceId: info.id }),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t{ concurrency: \"unbounded\", discard: true },\n\t);\n});\n\n/**\n * Serves ACP v1 on stdio until the client disconnects.\n *\n * stdout carries the protocol, so logs go to stderr. The reference is set outside the harness layer\n * so the fibers it forks (turns, plugin loads) inherit it too.\n */\nexport const serve = (options: Harness.Options) =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.addFinalizer(() => shutdown.pipe(Effect.ignore));\n\t\tconst handlers = yield* Handlers.make;\n\t\tyield* Agent.serve(yield* Stdio.Stdio, handlers);\n\t}).pipe(Effect.scoped, Effect.provide(Harness.layer(options)), Effect.provideService(Logger.LogToStderr, true));\n\nexport * as Server from \"./server.ts\";\n","import { Effect } from \"effect\";\nimport { Server } from \"../../../acp/server.ts\";\nimport { Runtime } from \"../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../error.ts\";\nimport { harnessOptions } from \"../../harness.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.acp,\n\tEffect.fn(\"CLI.acp\", { level: \"Info\" })(function* () {\n\t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AAa,SAAS;CAAK,CAC3C;AACD,CAAC;;;;;;;AAQD,MAAa,SAAS,YACrB,OAAO,IAAI,aAAa;CACvB,OAAO,OAAO,mBAAmB,SAAS,KAAK,OAAO,MAAM,CAAC;CAC7D,MAAM,WAAW,OAAOK;CACxB,OAAOC,QAAY,OAAO,MAAM,OAAO,QAAQ;AAChD,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAO,QAAQ,QAAQ,MAAM,OAAO,CAAC,GAAG,OAAO,eAAe,OAAO,aAAa,IAAI,CAAC;;;ACpC/G,IAAA,cAAeC,QACd,IAAI,SAAS,KACb,OAAO,GAAG,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC,CAAC,aAAa;CACpD,MAAM,SAAS,OAAO,IAAI;CAC1B,OAAO,OAAOC,MAAa,eAAe,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACpF,CAAC,CACF"}
|
|
1
|
+
{"version":3,"file":"acp-I5zgK_rF.mjs","names":["serve","Agent.RequestError","pkg.version","Config.options","Feed.replay","Config.parseModel","Config.known","Config.isThinkingLevel","update","Feed.update","notice","Feed.notice","Feed.noticeUpdate","Handlers.make","Agent.serve","Runtime.handler","Server.serve"],"sources":["../../src/acp/agent.ts","../../src/acp/config.ts","../../src/acp/feed.ts","../../src/acp/handlers.ts","../../src/acp/server.ts","../../src/cli/cmd/handlers/acp.ts"],"sourcesContent":["import * as Acp from \"@agentclientprotocol/sdk\";\nimport { Cause, Deferred, Effect, Exit, Option, Schema, type Scope, type Stdio, Stream } from \"effect\";\n\n/** A JSON-RPC error a handler answers a request with. */\nexport class RequestError extends Schema.TaggedError<RequestError>()(\"AcpRequestError\", {\n\tcode: Schema.Int,\n\tmessage: Schema.String,\n}) {\n\tstatic invalidRequest = (message: string) => new RequestError({ code: -32600, message });\n\tstatic invalidParams = (message: string) => new RequestError({ code: -32602, message });\n\tstatic internalError = (message: string) => new RequestError({ code: -32603, message });\n\tstatic resourceNotFound = (message: string) => new RequestError({ code: -32002, message });\n}\n\ntype Handler<Request, Response> = (request: Request) => Effect.Effect<Response, RequestError>;\n\n/** Calls the agent makes to the connected client. */\nexport interface Client {\n\treadonly sessionUpdate: (notification: Acp.SessionNotification) => Effect.Effect<void, RequestError>;\n}\n\nexport interface Handlers {\n\treadonly initialize: Handler<Acp.InitializeRequest, Acp.InitializeResponse>;\n\treadonly newSession: Handler<Acp.NewSessionRequest, Acp.NewSessionResponse>;\n\t/** Must replay the session's history through `Client.sessionUpdate` before it returns. */\n\treadonly loadSession: Handler<Acp.LoadSessionRequest, Acp.LoadSessionResponse>;\n\treadonly listSessions: Handler<Acp.ListSessionsRequest, Acp.ListSessionsResponse>;\n\treadonly setConfigOption: Handler<Acp.SetSessionConfigOptionRequest, Acp.SetSessionConfigOptionResponse>;\n\treadonly prompt: Handler<Acp.PromptRequest, Acp.PromptResponse>;\n\treadonly cancel: (notification: Acp.CancelNotification) => Effect.Effect<void>;\n}\n\n/**\n * Serves an ACP agent over `stdio` until the client closes its end.\n *\n * Handlers run as fibers on this effect's services; a request the client cancels, or the\n * connection closing, interrupts its fiber.\n */\nexport const serve = Effect.fn(\"ACP.serve\")(function* (\n\tstdio: Stdio.Stdio,\n\tmakeHandlers: (client: Client) => Handlers,\n): Effect.fn.Return<void, never, Scope.Scope> {\n\tconst context = yield* Effect.context<never>();\n\tconst runExit = Effect.runPromiseExitWith(context);\n\tconst opened = yield* Deferred.make<Acp.AgentConnection>();\n\n\tconst handlers = makeHandlers({\n\t\tsessionUpdate: (notification) =>\n\t\t\tDeferred.await(opened).pipe(\n\t\t\t\tEffect.flatMap((connection) =>\n\t\t\t\t\tEffect.tryPromise({\n\t\t\t\t\t\ttry: () => connection.client.notify(Acp.methods.client.session.update, notification),\n\t\t\t\t\t\tcatch: (error) => RequestError.internalError(`Failed to send session/update: ${String(error)}`),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n\n\t// A JSON-RPC answer for a handler that didn't succeed; the SDK sends what `handle` throws.\n\tconst toWire = (cause: Cause.Cause<RequestError>): Acp.RequestError => {\n\t\tconst error = Cause.findErrorOption(cause);\n\t\tif (Option.isSome(error)) return new Acp.RequestError(error.value.code, error.value.message);\n\t\tif (Cause.hasInterruptsOnly(cause)) return Acp.RequestError.requestCancelled();\n\t\treturn Acp.RequestError.internalError(undefined, String(Cause.squash(cause)));\n\t};\n\tconst handle =\n\t\t<Params, A>(handler: (params: Params) => Effect.Effect<A, RequestError>) =>\n\t\t({ params, signal }: { readonly params: Params; readonly signal: AbortSignal }): Promise<A> =>\n\t\t\trunExit(handler(params), { signal }).then((exit) => {\n\t\t\t\tif (Exit.isSuccess(exit)) return exit.value;\n\t\t\t\tthrow toWire(exit.cause);\n\t\t\t});\n\n\tconst input = yield* Stream.toReadableStreamEffect(stdio.stdin);\n\tconst output = new WritableStream<Uint8Array>({\n\t\twrite: (chunk) => Effect.runPromiseWith(context)(Stream.run(Stream.make(chunk), stdio.stdout())),\n\t});\n\n\tconst connection = Acp.agent({ name: \"codework\" })\n\t\t.onRequest(\"initialize\", handle(handlers.initialize))\n\t\t.onRequest(\"session/new\", handle(handlers.newSession))\n\t\t.onRequest(\"session/load\", handle(handlers.loadSession))\n\t\t.onRequest(\"session/list\", handle(handlers.listSessions))\n\t\t.onRequest(\"session/set_config_option\", handle(handlers.setConfigOption))\n\t\t.onRequest(\"session/prompt\", handle(handlers.prompt))\n\t\t.onNotification(\"session/cancel\", handle(handlers.cancel))\n\t\t.connect(Acp.ndJsonStream(output, input));\n\tyield* Deferred.succeed(opened, connection);\n\tyield* Effect.addFinalizer(() => Effect.sync(() => connection.close()));\n\tyield* Effect.promise(() => connection.closed);\n});\n\nexport * as Agent from \"./agent.ts\";\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport { Model } from \"@codeworksh/aikit\";\nimport { ModelCatalog, Settings, type State } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } from \"effect\";\n\nexport const MODEL = \"model\";\nexport const THOUGHT_LEVEL = \"thought_level\";\n\nconst thinkingLabels: Record<Model.ThinkingLevel, string> = {\n\toff: \"Off\",\n\tminimal: \"Minimal\",\n\tlow: \"Low\",\n\tmedium: \"Medium\",\n\thigh: \"High\",\n\txhigh: \"Extra High\",\n\tmax: \"Max\",\n};\n\nexport const isThinkingLevel = (value: string): value is Model.ThinkingLevel => Object.hasOwn(thinkingLabels, value);\n\n/** Splits a `provider/model` option value on its first slash; model ids may contain more. */\nexport const parseModel = (value: string): Option.Option<{ readonly provider: string; readonly id: string }> => {\n\tconst slash = value.indexOf(\"/\");\n\tif (slash <= 0 || slash === value.length - 1) return Option.none();\n\treturn Option.some({ provider: value.slice(0, slash), id: value.slice(slash + 1) });\n};\n\n/** The catalog a session in `hostDir` sees: generated entries plus its settings' `models`. */\nconst catalogFor = (hostDir: string | undefined) =>\n\tEffect.gen(function* () {\n\t\tconst settings = yield* Settings.Service;\n\t\treturn yield* ModelCatalog.effective((yield* settings.load(hostDir)).models);\n\t}).pipe(Effect.orElseSucceed((): Model.BuiltInModels => ({})));\n\n/** The `model` and `thought_level` selectors for a session's current configuration. */\nexport const options = Effect.fn(\"ACP.config.options\")(function* (\n\tselection: State.Configuration,\n\thostDir: string | undefined,\n) {\n\tconst catalog = yield* catalogFor(hostDir);\n\t// Providers the harness has credentials for; the current model stays selectable even if not.\n\tconst providers = yield* ModelCatalog.available(hostDir === undefined ? {} : { hostDir }).pipe(\n\t\tEffect.orElseSucceed(() => []),\n\t);\n\n\tconst current = `${selection.provider}/${selection.model}`;\n\tconst models = providers.flatMap((provider) =>\n\t\tObject.entries(provider.models).map(([id, info]) => ({\n\t\t\tvalue: `${provider.id}/${id}`,\n\t\t\tname: `${info.provider.name}: ${info.name}`,\n\t\t})),\n\t);\n\tif (!models.some((option) => option.value === current)) models.unshift({ value: current, name: current });\n\n\tconst result: Array<Acp.SessionConfigOption> = [\n\t\t{ id: MODEL, name: \"Model\", category: \"model\", type: \"select\", currentValue: current, options: models },\n\t];\n\n\tconst info = catalog[selection.provider]?.[selection.model];\n\tconst levels = info === undefined ? [] : Model.getSupportedThinkingLevels(info);\n\tif (levels.some((level) => level !== \"off\")) {\n\t\tresult.push({\n\t\t\tid: THOUGHT_LEVEL,\n\t\t\tname: \"Thinking Effort\",\n\t\t\tcategory: \"thought_level\",\n\t\t\ttype: \"select\",\n\t\t\tcurrentValue: selection.thinkingLevel,\n\t\t\toptions: levels.map((level) => ({ value: level, name: thinkingLabels[level] })),\n\t\t});\n\t}\n\treturn result;\n});\n\n/** Whether a model is in the catalog a session in `hostDir` sees. */\nexport const known = Effect.fn(\"ACP.config.known\")(function* (\n\tmodel: { readonly provider: string; readonly id: string },\n\thostDir: string | undefined,\n) {\n\tconst catalog = yield* catalogFor(hostDir);\n\treturn catalog[model.provider]?.[model.id] !== undefined;\n});\n\nexport * as Config from \"./config.ts\";\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport { EventList, type EventSchema, type SessionStore } from \"@codeworksh/harness/effect\";\nimport { Option, Schema } from \"effect\";\n\nconst isTextDelta = Schema.is(EventList.LLMTextDelta);\nconst isThinkingDelta = Schema.is(EventList.LLMThinkingDelta);\nconst isToolStarted = Schema.is(EventList.ToolStarted);\nconst isToolSettled = Schema.is(EventList.ToolSettled);\nconst isPluginUpdated = Schema.is(EventList.PluginUpdated);\n\nconst TextContent = Schema.Struct({ type: Schema.Literal(\"text\"), text: Schema.String });\nconst ImageContent = Schema.Struct({ type: Schema.Literal(\"image\"), data: Schema.String, mimeType: Schema.String });\nconst ToolResult = Schema.Struct({\n\tcontent: Schema.Array(Schema.Union([TextContent, Schema.Struct({ type: Schema.Literal(\"image\") })])),\n\tisError: Schema.Boolean,\n});\nconst ToolCall = Schema.Struct({\n\ttype: Schema.Literal(\"toolCall\"),\n\tcallID: Schema.String,\n\tname: Schema.String,\n\targuments: Schema.Record(Schema.String, Schema.Json),\n\tstatus: Schema.String,\n\tresult: Schema.optional(ToolResult),\n});\nconst StoredPart = Schema.Union([\n\tTextContent,\n\tImageContent,\n\tSchema.Struct({ type: Schema.Literal(\"thinking\"), thinking: Schema.String }),\n\tToolCall,\n]);\nconst decodePart = Schema.decodeUnknownOption(Schema.fromJsonString(StoredPart));\n\ntype ToolCall = typeof ToolCall.Type;\n\nconst text = (value: string): Acp.ContentBlock => ({ type: \"text\", text: value });\n\n// The kind comes from the tool's name. Only `bash` ships built in; plugin tools report `other`.\nconst kind = (name: string): Acp.ToolKind => (name === \"bash\" ? \"execute\" : \"other\");\n\n/** The command for `bash`, otherwise the tool's label or name. */\nconst title = (name: string, args: Readonly<Record<string, unknown>>, label?: string): string =>\n\tname === \"bash\" && typeof args.command === \"string\" ? args.command : (label ?? name);\n\nconst settled = (call: Pick<ToolCall, \"callID\" | \"name\" | \"arguments\" | \"status\" | \"result\">): Acp.SessionUpdate => {\n\tconst output = call.result?.content.flatMap((block) => (block.type === \"text\" ? [block.text] : [])).join(\"\\n\");\n\treturn {\n\t\tsessionUpdate: \"tool_call_update\",\n\t\ttoolCallId: call.callID,\n\t\tkind: kind(call.name),\n\t\tstatus: call.status === \"completed\" ? \"completed\" : \"failed\",\n\t\trawInput: call.arguments,\n\t\t...(call.result === undefined ? {} : { rawOutput: call.result }),\n\t\t...(output ? { content: [{ type: \"content\", content: text(output) }] } : {}),\n\t};\n};\n\n/** The live `session/update` for a harness event, if the client should see one. */\nexport const update = (event: EventSchema.Payload): Option.Option<Acp.SessionUpdate> => {\n\tif (isTextDelta(event)) {\n\t\treturn Option.some({ sessionUpdate: \"agent_message_chunk\", content: text(event.data.delta) });\n\t}\n\tif (isThinkingDelta(event)) {\n\t\treturn Option.some({ sessionUpdate: \"agent_thought_chunk\", content: text(event.data.delta) });\n\t}\n\tif (isToolStarted(event)) {\n\t\treturn Option.some({\n\t\t\tsessionUpdate: \"tool_call\",\n\t\t\ttoolCallId: event.data.callID,\n\t\t\ttitle: title(event.data.name, event.data.arguments, event.data.label),\n\t\t\tkind: kind(event.data.name),\n\t\t\tstatus: \"in_progress\",\n\t\t\trawInput: event.data.arguments,\n\t\t});\n\t}\n\tif (isToolSettled(event)) return Option.some(settled(event.data.part));\n\treturn Option.none();\n};\n\n/**\n * Text for the user about a plugin that failed to load, such as one configured but not installed.\n * It belongs in the conversation because the user may never see this process's logs.\n */\nexport const notice = (event: EventSchema.Payload): Option.Option<string> =>\n\tisPluginUpdated(event) && event.data.status === \"failed\" && event.data.error !== undefined\n\t\t? Option.some(event.data.error)\n\t\t: Option.none();\n\n/** A notice shown to the user in the agent's message. */\nexport const noticeUpdate = (notice: string): Acp.SessionUpdate => ({\n\tsessionUpdate: \"agent_message_chunk\",\n\tcontent: text(`> ⚠ ${notice}\\n\\n`),\n});\n\n/** The `session/update`s that replay one stored entry during `session/load`. */\nexport const replay = ({ entry, parts }: SessionStore.HydratedEntry): ReadonlyArray<Acp.SessionUpdate> => {\n\tif (entry.type !== \"user\" && entry.type !== \"assistant\") return [];\n\treturn parts.flatMap((row): ReadonlyArray<Acp.SessionUpdate> => {\n\t\tconst part = decodePart(row.data);\n\t\tif (Option.isNone(part)) return [];\n\t\tswitch (part.value.type) {\n\t\t\tcase \"text\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: entry.type === \"user\" ? \"user_message_chunk\" : \"agent_message_chunk\",\n\t\t\t\t\t\tcontent: text(part.value.text),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\tcase \"image\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: entry.type === \"user\" ? \"user_message_chunk\" : \"agent_message_chunk\",\n\t\t\t\t\t\tcontent: { type: \"image\", data: part.value.data, mimeType: part.value.mimeType },\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\tcase \"thinking\":\n\t\t\t\treturn [{ sessionUpdate: \"agent_thought_chunk\", content: text(part.value.thinking) }];\n\t\t\tcase \"toolCall\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: \"tool_call\",\n\t\t\t\t\t\ttoolCallId: part.value.callID,\n\t\t\t\t\t\ttitle: title(part.value.name, part.value.arguments),\n\t\t\t\t\t\tkind: kind(part.value.name),\n\t\t\t\t\t\tstatus: \"in_progress\",\n\t\t\t\t\t\trawInput: part.value.arguments,\n\t\t\t\t\t},\n\t\t\t\t\tsettled(part.value),\n\t\t\t\t];\n\t\t}\n\t});\n};\n\nexport * as Feed from \"./feed.ts\";\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport {\n\tControl,\n\tEventList,\n\ttype EventSchema,\n\ttype Harness,\n\tPromptSchema,\n\tSession,\n\tSessionStore,\n} from \"@codeworksh/harness/effect\";\nimport { DateTime, Effect, Fiber, type Layer, Option, Schema, Stream } from \"effect\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\nimport { Agent } from \"./agent.ts\";\nimport { Config } from \"./config.ts\";\nimport { Feed } from \"./feed.ts\";\n\nconst PAGE_SIZE = 50;\n\nconst isRequestError = Schema.is(Agent.RequestError);\nconst isNotFound = Schema.is(SessionStore.SessionNotFoundError);\nconst isConflict = Schema.is(Control.PromptConflictError);\nconst isInvalidPrompt = Schema.is(PromptSchema.InvalidPromptError);\nconst isLLMEnded = Schema.is(EventList.LLMEnded);\nconst isSucceeded = Schema.is(EventList.ExecutionSucceeded);\nconst isFailed = Schema.is(EventList.ExecutionFailed);\nconst isInterrupted = Schema.is(EventList.ExecutionInterrupted);\nconst isSettled = (event: EventSchema.Payload) => isSucceeded(event) || isFailed(event) || isInterrupted(event);\n\n/** Harness failures as JSON-RPC errors; handlers raise protocol-level ones directly. */\nconst toRequestError = (error: { readonly message: string }): Agent.RequestError => {\n\tif (isRequestError(error)) return error;\n\tif (isNotFound(error)) return Agent.RequestError.resourceNotFound(`Session not found: ${error.sessionId}`);\n\tif (isConflict(error)) return Agent.RequestError.invalidRequest(error.message);\n\tif (isInvalidPrompt(error)) return Agent.RequestError.invalidParams(error.message);\n\treturn Agent.RequestError.internalError(error.message);\n};\n\n/**\n * Prompt content as harness prompt parts, in order. Text, embedded context and images are\n * advertised; anything else is rejected. Adjacent text joins into one part. The harness checks\n * the images.\n */\nconst promptParts = Effect.fnUntraced(function* (blocks: ReadonlyArray<Acp.ContentBlock>) {\n\tconst parts: Array<PromptSchema.Part> = [];\n\tconst add = (part: PromptSchema.Part) => {\n\t\tconst last = parts.at(-1);\n\t\tif (part.type === \"text\" && last?.type === \"text\")\n\t\t\tparts[parts.length - 1] = { ...last, text: `${last.text}\\n\\n${part.text}` };\n\t\telse parts.push(part);\n\t};\n\tfor (const block of blocks) {\n\t\tswitch (block.type) {\n\t\t\tcase \"text\":\n\t\t\t\tadd({ type: \"text\", text: block.text });\n\t\t\t\tbreak;\n\t\t\tcase \"resource_link\":\n\t\t\t\tadd({ type: \"text\", text: `[${block.name}](${block.uri})` });\n\t\t\t\tbreak;\n\t\t\tcase \"image\":\n\t\t\t\tadd({ type: \"image\", data: block.data, mimeType: block.mimeType });\n\t\t\t\tbreak;\n\t\t\tcase \"resource\":\n\t\t\t\tif (\"text\" in block.resource) {\n\t\t\t\t\tadd({ type: \"text\", text: `\\`\\`\\`${block.resource.uri}\\n${block.resource.text}\\n\\`\\`\\`` });\n\t\t\t\t} else if (block.resource.mimeType?.startsWith(\"image/\")) {\n\t\t\t\t\tadd({ type: \"image\", data: block.resource.blob, mimeType: block.resource.mimeType });\n\t\t\t\t} else {\n\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unsupported binary resource: ${block.resource.uri}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unsupported prompt content: ${block.type}`);\n\t\t}\n\t}\n\treturn parts;\n});\n\nconst sessionId = (id: string) => Session.SessionSchema.ID.make(id);\n\ntype Services = Layer.Success<ReturnType<typeof Harness.layer>>;\n\nexport const make = Effect.gen(function* () {\n\tconst control = yield* Control.Service;\n\tconst sessions = yield* SessionStore.Service;\n\t// Handlers run on the agent's fibers, outside this layer; they carry the harness with them.\n\tconst context = yield* Effect.context<Services>();\n\n\tconst running = new Set<string>();\n\n\tconst found = Effect.fn(\"ACP.found\")(function* (id: string) {\n\t\tconst row = yield* sessions.get(sessionId(id));\n\t\tif (Option.isNone(row)) return yield* new SessionStore.SessionNotFoundError({ sessionId: sessionId(id) });\n\t\treturn row.value;\n\t});\n\n\treturn (client: Agent.Client): Agent.Handlers => {\n\t\tconst run = <A, E extends { readonly message: string }>(effect: Effect.Effect<A, E, Services>) =>\n\t\t\teffect.pipe(Effect.provide(context), Effect.mapError(toRequestError));\n\n\t\treturn {\n\t\t\tinitialize: () =>\n\t\t\t\tEffect.succeed({\n\t\t\t\t\tprotocolVersion: 1,\n\t\t\t\t\tagentInfo: { name: \"codework\", version: pkg.version },\n\t\t\t\t\tagentCapabilities: {\n\t\t\t\t\t\tloadSession: true,\n\t\t\t\t\t\tpromptCapabilities: { embeddedContext: true, image: true },\n\t\t\t\t\t\tsessionCapabilities: { list: {} },\n\t\t\t\t\t},\n\t\t\t\t}),\n\n\t\t\tnewSession: ({ cwd }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst handle = yield* Session.create({ directory: cwd, hostDir: cwd });\n\t\t\t\t\t\tconst current = yield* Session.configuration(handle.id);\n\t\t\t\t\t\treturn { sessionId: handle.id, configOptions: yield* Config.options(current, cwd) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tloadSession: ({ sessionId: id }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tyield* Session.attach({ sessionId: sessionId(id) });\n\t\t\t\t\t\tconst row = yield* found(id);\n\t\t\t\t\t\tconst hostDir = Option.getOrUndefined(row.hostDir);\n\t\t\t\t\t\tconst current = yield* Session.configuration(row.id);\n\t\t\t\t\t\tfor (const entry of yield* sessions.path(sessionId(id))) {\n\t\t\t\t\t\t\tfor (const update of Feed.replay(entry)) {\n\t\t\t\t\t\t\t\tyield* client.sessionUpdate({ sessionId: id, update });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { configOptions: yield* Config.options(current, hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tlistSessions: ({ cwd, cursor }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst rows = (yield* sessions.list())\n\t\t\t\t\t\t\t.filter((row) => cwd == null || Option.getOrUndefined(row.hostDir) === cwd)\n\t\t\t\t\t\t\t.sort((a, b) => DateTime.Order(b.updatedAt ?? b.createdAt, a.updatedAt ?? a.createdAt));\n\t\t\t\t\t\tconst offset = cursor == null ? 0 : Number(cursor);\n\t\t\t\t\t\tif (!Number.isSafeInteger(offset) || offset < 0) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Invalid cursor: ${cursor}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst next = offset + PAGE_SIZE;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsessions: rows.slice(offset, next).map((row) => ({\n\t\t\t\t\t\t\t\tsessionId: row.id,\n\t\t\t\t\t\t\t\tcwd: Option.getOrElse(row.hostDir, () => row.directory),\n\t\t\t\t\t\t\t\ttitle: row.title,\n\t\t\t\t\t\t\t\tupdatedAt: DateTime.formatIso(row.updatedAt ?? row.createdAt),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t...(next < rows.length ? { nextCursor: String(next) } : {}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tsetConfigOption: (request) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst row = yield* found(request.sessionId);\n\t\t\t\t\t\tconst hostDir = Option.getOrUndefined(row.hostDir);\n\t\t\t\t\t\tconst value = String(request.value);\n\t\t\t\t\t\tif (request.configId === Config.MODEL) {\n\t\t\t\t\t\t\tconst model = Option.getOrUndefined(Config.parseModel(value));\n\t\t\t\t\t\t\tif (model === undefined || !(yield* Config.known(model, hostDir))) {\n\t\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown model: ${value}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tyield* Session.attach({ sessionId: row.id, model });\n\t\t\t\t\t\t} else if (request.configId === Config.THOUGHT_LEVEL) {\n\t\t\t\t\t\t\tif (!Config.isThinkingLevel(value)) {\n\t\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown thinking level: ${value}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tyield* Session.attach({ sessionId: row.id, thinkingLevel: value });\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown config option: ${request.configId}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { configOptions: yield* Config.options(yield* Session.configuration(row.id), hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tprompt: ({ sessionId: id, prompt }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst parts = yield* promptParts(prompt);\n\t\t\t\t\t\tconst handle = Option.getOrUndefined(yield* Session.get(sessionId(id)));\n\t\t\t\t\t\tif (handle === undefined) {\n\t\t\t\t\t\t\treturn yield* new SessionStore.SessionNotFoundError({ sessionId: sessionId(id) });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (running.has(id)) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidRequest(\"A prompt is already running for this session\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\trunning.add(id);\n\t\t\t\t\t\tyield* Effect.addFinalizer(() => Effect.sync(() => running.delete(id)));\n\n\t\t\t\t\t\t// Forward this execution's updates until it settles; the settling event decides the answer.\n\t\t\t\t\t\tlet reason: EventList.LLMEnded[\"data\"][\"reason\"] | undefined;\n\t\t\t\t\t\t// Plugins are checked every exchange; tell the user about each failure once per prompt.\n\t\t\t\t\t\tconst notices = new Set<string>();\n\t\t\t\t\t\tconst settled = yield* handle.events().pipe(\n\t\t\t\t\t\t\tStream.tap((event) => {\n\t\t\t\t\t\t\t\tif (isLLMEnded(event)) reason = event.data.reason;\n\t\t\t\t\t\t\t\tlet update = Feed.update(event);\n\t\t\t\t\t\t\t\tconst notice = Feed.notice(event);\n\t\t\t\t\t\t\t\tif (Option.isSome(notice) && !notices.has(notice.value)) {\n\t\t\t\t\t\t\t\t\tnotices.add(notice.value);\n\t\t\t\t\t\t\t\t\tupdate = Option.some(Feed.noticeUpdate(notice.value));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn Option.match(update, {\n\t\t\t\t\t\t\t\t\tonNone: () => Effect.void,\n\t\t\t\t\t\t\t\t\tonSome: (update) => client.sessionUpdate({ sessionId: id, update }).pipe(Effect.ignore),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tStream.filter(isSettled),\n\t\t\t\t\t\t\tStream.runHead,\n\t\t\t\t\t\t\tEffect.forkScoped({ startImmediately: true }),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst before = (yield* handle.info).title;\n\t\t\t\t\t\tyield* handle.run({ parts });\n\t\t\t\t\t\tconst end = yield* Fiber.join(settled);\n\n\t\t\t\t\t\t// The harness titles a session from its first prompt; tell the editor.\n\t\t\t\t\t\tconst { title } = yield* handle.info;\n\t\t\t\t\t\tif (title !== before) {\n\t\t\t\t\t\t\tyield* client\n\t\t\t\t\t\t\t\t.sessionUpdate({ sessionId: id, update: { sessionUpdate: \"session_info_update\", title } })\n\t\t\t\t\t\t\t\t.pipe(Effect.ignore);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (Option.isNone(end) || isInterrupted(end.value)) return { stopReason: \"cancelled\" as const };\n\t\t\t\t\t\tif (isFailed(end.value)) return yield* Agent.RequestError.internalError(end.value.data.error.message);\n\t\t\t\t\t\treturn { stopReason: reason === \"length\" ? (\"max_tokens\" as const) : (\"end_turn\" as const) };\n\t\t\t\t\t}).pipe(Effect.scoped),\n\t\t\t\t),\n\n\t\t\tcancel: ({ sessionId: id }) => control.interrupt(sessionId(id), { reason: \"user\" }).pipe(Effect.asVoid),\n\t\t};\n\t};\n});\n\nexport * as Handlers from \"./handlers.ts\";\n","import { Control, Harness, Sandbox } from \"@codeworksh/harness/effect\";\nimport { Effect, Logger, Stdio } from \"effect\";\nimport { Agent } from \"./agent.ts\";\nimport { Handlers } from \"./handlers.ts\";\n\n// Sessions and managed sandboxes outlive any single request; the connection's end is what stops them.\nconst shutdown = Effect.gen(function* () {\n\tconst control = yield* Control.Service;\n\tyield* Effect.forEach(\n\t\tyield* control.active,\n\t\t(id) =>\n\t\t\tcontrol\n\t\t\t\t.interrupt(id, { reason: \"shutdown\", awaitSettlement: true })\n\t\t\t\t.pipe(Effect.timeout(\"10 seconds\"), Effect.ignore),\n\t\t{ concurrency: \"unbounded\", discard: true },\n\t);\n\tconst managed = (yield* Sandbox.list()).filter((info) => info.ownership === \"managed\");\n\tyield* Effect.forEach(\n\t\tmanaged,\n\t\t(info) =>\n\t\t\tSandbox.stop(info.id).pipe(\n\t\t\t\tEffect.timeout(\"10 seconds\"),\n\t\t\t\tEffect.catchCause((cause) =>\n\t\t\t\t\tEffect.logError(\"Failed to stop managed sandbox during ACP shutdown\", cause).pipe(\n\t\t\t\t\t\tEffect.annotateLogs({ sandboxInstanceId: info.id }),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t{ concurrency: \"unbounded\", discard: true },\n\t);\n});\n\n/**\n * Serves ACP v1 on stdio until the client disconnects.\n *\n * stdout carries the protocol, so logs go to stderr. The reference is set outside the harness layer\n * so the fibers it forks (turns, plugin loads) inherit it too.\n */\nexport const serve = (options: Harness.Options) =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.addFinalizer(() => shutdown.pipe(Effect.ignore));\n\t\tconst handlers = yield* Handlers.make;\n\t\tyield* Agent.serve(yield* Stdio.Stdio, handlers);\n\t}).pipe(Effect.scoped, Effect.provide(Harness.layer(options)), Effect.provideService(Logger.LogToStderr, true));\n\nexport * as Server from \"./server.ts\";\n","import { Effect } from \"effect\";\nimport { Server } from \"../../../acp/server.ts\";\nimport { Runtime } from \"../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../error.ts\";\nimport { harnessOptions } from \"../../harness.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.acp,\n\tEffect.fn(\"CLI.acp\", { level: \"Info\" })(function* () {\n\t\tconst shared = yield* Cmd.spec;\n\t\treturn yield* Server.serve(harnessOptions(shared)).pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;AAIA,IAAa,eAAb,MAAa,qBAAqB,OAAO,YAA0B,CAAC,CAAC,mBAAmB;CACvF,MAAM,OAAO;CACb,SAAS,OAAO;AACjB,CAAC,CAAC,CAAC;CACF,OAAO,kBAAkB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;CACvF,OAAO,iBAAiB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;CACtF,OAAO,iBAAiB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;CACtF,OAAO,oBAAoB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;AAC1F;;;;;;;AA0BA,MAAaA,UAAQ,OAAO,GAAG,WAAW,CAAC,CAAC,WAC3C,OACA,cAC6C;CAC7C,MAAM,UAAU,OAAO,OAAO,QAAe;CAC7C,MAAM,UAAU,OAAO,mBAAmB,OAAO;CACjD,MAAM,SAAS,OAAO,SAAS,KAA0B;CAEzD,MAAM,WAAW,aAAa,EAC7B,gBAAgB,iBACf,SAAS,MAAM,MAAM,CAAC,CAAC,KACtB,OAAO,SAAS,eACf,OAAO,WAAW;EACjB,WAAW,WAAW,OAAO,OAAO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M,GACnD;EAAE,aAAa;EAAa,SAAS;CAAK,CAC3C;CACA,MAAM,WAAW,OAAO,QAAQ,KAAK,EAAA,CAAG,QAAQ,SAAS,KAAK,cAAc,SAAS;CACrF,OAAO,OAAO,QACb,UACC,SACA,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC,KACrB,OAAO,QAAQ,YAAY,GAC3B,OAAO,YAAY,UAClB,OAAO,SAAS,sDAAsD,KAAK,CAAC,CAAC,KAC5E,OAAO,aAAa,EAAE,mBAAmB,KAAK,GAAG,CAAC,CACnD,CACD,CACD,GACD;EAAE,aAAa;EAAa,SAAS;CAAK,CAC3C;AACD,CAAC;;;;;;;AAQD,MAAa,SAAS,YACrB,OAAO,IAAI,aAAa;CACvB,OAAO,OAAO,mBAAmB,SAAS,KAAK,OAAO,MAAM,CAAC;CAC7D,MAAM,WAAW,OAAOK;CACxB,OAAOC,QAAY,OAAO,MAAM,OAAO,QAAQ;AAChD,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAO,QAAQ,QAAQ,MAAM,OAAO,CAAC,GAAG,OAAO,eAAe,OAAO,aAAa,IAAI,CAAC;;;ACpC/G,IAAA,cAAeC,QACd,IAAI,SAAS,KACb,OAAO,GAAG,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC,CAAC,aAAa;CACpD,MAAM,SAAS,OAAO,IAAI;CAC1B,OAAO,OAAOC,MAAa,eAAe,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACpF,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as Cmd, t as handler } from "./runtime-B43doHjV.mjs";
|
|
2
|
-
import { d as writeOut, i as reportFailure } from "./error-
|
|
3
|
-
import { a as resolveTarget, c as withPluginsLock, i as readPlugins, l as writePlugins, n as matches, o as spellings, t as identify, u as written } from "./settings-
|
|
2
|
+
import { d as writeOut, i as reportFailure } from "./error-CPo0lJt1.mjs";
|
|
3
|
+
import { a as resolveTarget, c as withPluginsLock, i as readPlugins, l as writePlugins, n as matches, o as spellings, t as identify, u as written } from "./settings-BHxEl9yP.mjs";
|
|
4
4
|
import { Effect, Layer, Option, Path } from "effect";
|
|
5
5
|
import { Database, Event, Global, Plugin, Session, SessionStore } from "@codeworksh/harness/effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/plugin/session.ts
|
|
@@ -79,4 +79,4 @@ var add_default = handler(Cmd.commands.plugin.commands.add, Effect.fn("CLI.plugi
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { add_default as default };
|
|
81
81
|
|
|
82
|
-
//# sourceMappingURL=add-
|
|
82
|
+
//# sourceMappingURL=add-DNUklw-1.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-B1SAcg06.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/session.ts","../../src/cli/cmd/handlers/plugin/add.ts"],"sourcesContent":["import { Database, Event, Global, Session, SessionStore } from \"@codeworksh/harness/effect\";\nimport { Effect, Layer, Option } from \"effect\";\n\n/**\n * The host directory a session is linked to.\n *\n * **A session ID can answer this and a project ID cannot**, which is why the flag takes one. A\n * `Project` is env-independent by design -- its identity is a repo marker, a remote hash or a root\n * commit, never a path -- and its spaces hold `location`s *inside* an env, which may be a container\n * on another machine. Deriving a host settings file from one would mean walking the host\n * filesystem from a path that means something somewhere else, which is the exact failure the\n * `hostDir` split exists to prevent: it does not error, it finds a stranger's project.\n *\n * A session, by contrast, carries a `hostDir` that was *declared* on the host. Absent is a normal\n * state rather than corruption, and it is the one this refuses.\n */\nexport const linkedDirectory = Effect.fn(\"CLI.plugin.linkedDirectory\")(function* (\n\tsessionId: string,\n\thome: Option.Option<string>,\n) {\n\tconst paths = yield* Global.resolve(Option.isNone(home) ? {} : { home: home.value });\n\tconst id = Session.SessionSchema.ID.ascending(sessionId);\n\n\treturn yield* Effect.gen(function* () {\n\t\tconst sessions = yield* SessionStore.Service;\n\t\tconst found = yield* sessions.get(id);\n\t\tif (Option.isNone(found)) return yield* new SessionStore.SessionNotFoundError({ sessionId: id });\n\t\tconst hostDir = Option.getOrUndefined(found.value.hostDir);\n\t\tif (hostDir === undefined) return yield* new SessionStore.SessionNotLinkedError({ sessionId: id });\n\t\treturn hostDir;\n\t}).pipe(\n\t\t// Only the session row is read, so this needs the database and the event log the store is\n\t\t// built on -- no sandboxes, no control plane, no plugin machinery.\n\t\tEffect.provide(\n\t\t\tSessionStore.layer.pipe(\n\t\t\t\tLayer.provide(Event.layer),\n\t\t\t\tLayer.provide(Database.layer(yield* Database.path(paths.data))),\n\t\t\t),\n\t\t),\n\t);\n});\n","import { Global, Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { linkedDirectory } from \"./session.ts\";\nimport {\n\tidentify,\n\tmatches,\n\treadPlugins,\n\tresolveTarget,\n\tspellings,\n\twithPluginsLock,\n\twritePlugins,\n\twritten,\n} from \"./settings.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.add,\n\tEffect.fn(\"CLI.plugin.add\")(function* ({ package: reference, global: userWide, session }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst path = yield* Path.Path;\n\t\t\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\n\t\t\t// A session names the project to write into when the shell's directory is not it --\n\t\t\t// a server or a UI acting on a session's behalf, rather than a person standing in the\n\t\t\t// repository. It fails when that session has no project, which is a state `session\n\t\t\t// link` exists to fix.\n\t\t\tconst linked = Option.isNone(session) ? undefined : yield* linkedDirectory(session.value, shared.home);\n\t\t\t/*\n\t\t\t * One directory answers every question this command asks about the reference, and it\n\t\t\t * is resolved before any of them.\n\t\t\t *\n\t\t\t * A relative spec anchors here, the `.npmrc` chain governing the install is read from\n\t\t\t * here, and the entry is written anchored here. Splitting them is not a cosmetic\n\t\t\t * inconsistency: under `--session` the shell's directory is a server's, so validating\n\t\t\t * `./plugins/x.ts` against it imports one file and writes a reference to another, and\n\t\t\t * reading the `.npmrc` chain from it installs from the wrong registry -- a private\n\t\t\t * scope's token lives in the project being written to, not wherever the server runs.\n\t\t\t */\n\t\t\tconst from = linked ?? path.resolve(\".\");\n\n\t\t\t// The file the entry will land in decides the install's registry identity: it is named\n\t\t\t// here -- without creating the marker -- so the store keys the artifact under the same\n\t\t\t// `.npmrc` chain every later resolve of this entry re-derives, and a bad reference\n\t\t\t// still leaves nothing behind.\n\t\t\tconst target = yield* resolveTarget(shared, userWide, linked, false);\n\n\t\t\t// Install and import before touching the file: a spec that turns out not to be a plugin\n\t\t\t// should fail here, with its own error, rather than at the next run from a file the user\n\t\t\t// then has to repair by hand.\n\t\t\tconst plugin = yield* Plugin.inspect(reference, { cache: paths.cache, hostDir: from, file: target.path });\n\t\t\t// What goes in the file, which is not always what was typed: a relative path anchors to\n\t\t\t// the settings file being written, not to the directory the command ran in.\n\t\t\tconst entry = yield* written(reference, {\n\t\t\t\thostDir: from,\n\t\t\t\tfile: target.path,\n\t\t\t\troot: target.root,\n\t\t\t});\n\t\t\tconst spelled = yield* spellings(reference, from);\n\t\t\tconst version = plugin.version === undefined ? \"\" : `@${plugin.version}`;\n\t\t\tyield* withPluginsLock(\n\t\t\t\ttarget.path,\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst { source, plugins } = yield* readPlugins(target.path);\n\t\t\t\t\tconst entries = yield* identify(plugins, target.path, paths.cache);\n\t\t\t\t\t// Configured already if any spelling of an existing entry names this plugin -- the same\n\t\t\t\t\t// package under a different version, the path it was added by, or the ID it declares.\n\t\t\t\t\tconst names = (candidate: (typeof entries)[number]) =>\n\t\t\t\t\t\tmatches(candidate, spelled) || candidate.answers.has(plugin.id);\n\t\t\t\t\tconst existing = entries.findIndex((candidate) => candidate.loads && names(candidate));\n\t\t\t\t\tif (existing >= 0) {\n\t\t\t\t\t\tconst current = entries[existing]?.value;\n\t\t\t\t\t\tif (current === entry) {\n\t\t\t\t\t\t\tyield* writeOut(`Plugin \"${reference}\" is already configured in ${target.path}\\n`);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst replaced = [...plugins];\n\t\t\t\t\t\treplaced[existing] = entry;\n\t\t\t\t\t\tyield* writePlugins(target.path, source, replaced);\n\t\t\t\t\t\tyield* writeOut(\n\t\t\t\t\t\t\t`Updated ${plugin.id} (${String(current)} -> ${entry}${version}) in ${target.path}\\n`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Put the loader before existing configuration so its options apply to the module.\n\t\t\t\t\tconst configured = entries.findIndex((candidate) => !candidate.loads && names(candidate));\n\t\t\t\t\tconst updated = [...plugins];\n\t\t\t\t\tupdated.splice(configured < 0 ? updated.length : configured, 0, entry);\n\t\t\t\t\tyield* writePlugins(target.path, source, updated);\n\t\t\t\t\tyield* writeOut(`Added ${plugin.id} (${entry}${version}) to ${target.path}\\n`);\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// Said after the write, because `resolveTarget` only named the marker: the lock's\n\t\t\t// write is what made it, and \"created\" should be true by the time it is printed.\n\t\t\tif (target.created !== undefined) yield* writeOut(`Created ${target.created}/\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,OAAO,GAAG,4BAA4B,CAAC,CAAC,WACtE,WACA,MACC;CACD,MAAM,QAAQ,OAAO,OAAO,QAAQ,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACnF,MAAM,KAAK,QAAQ,cAAc,GAAG,UAAU,SAAS;CAEvD,OAAO,OAAO,OAAO,IA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AC;AACvD,CAAC,CACF"}
|
|
1
|
+
{"version":3,"file":"add-DNUklw-1.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/session.ts","../../src/cli/cmd/handlers/plugin/add.ts"],"sourcesContent":["import { Database, Event, Global, Session, SessionStore } from \"@codeworksh/harness/effect\";\nimport { Effect, Layer, Option } from \"effect\";\n\n/**\n * The host directory a session is linked to.\n *\n * **A session ID can answer this and a project ID cannot**, which is why the flag takes one. A\n * `Project` is env-independent by design -- its identity is a repo marker, a remote hash or a root\n * commit, never a path -- and its spaces hold `location`s *inside* an env, which may be a container\n * on another machine. Deriving a host settings file from one would mean walking the host\n * filesystem from a path that means something somewhere else, which is the exact failure the\n * `hostDir` split exists to prevent: it does not error, it finds a stranger's project.\n *\n * A session, by contrast, carries a `hostDir` that was *declared* on the host. Absent is a normal\n * state rather than corruption, and it is the one this refuses.\n */\nexport const linkedDirectory = Effect.fn(\"CLI.plugin.linkedDirectory\")(function* (\n\tsessionId: string,\n\thome: Option.Option<string>,\n) {\n\tconst paths = yield* Global.resolve(Option.isNone(home) ? {} : { home: home.value });\n\tconst id = Session.SessionSchema.ID.ascending(sessionId);\n\n\treturn yield* Effect.gen(function* () {\n\t\tconst sessions = yield* SessionStore.Service;\n\t\tconst found = yield* sessions.get(id);\n\t\tif (Option.isNone(found)) return yield* new SessionStore.SessionNotFoundError({ sessionId: id });\n\t\tconst hostDir = Option.getOrUndefined(found.value.hostDir);\n\t\tif (hostDir === undefined) return yield* new SessionStore.SessionNotLinkedError({ sessionId: id });\n\t\treturn hostDir;\n\t}).pipe(\n\t\t// Only the session row is read, so this needs the database and the event log the store is\n\t\t// built on -- no sandboxes, no control plane, no plugin machinery.\n\t\tEffect.provide(\n\t\t\tSessionStore.layer.pipe(\n\t\t\t\tLayer.provide(Event.layer),\n\t\t\t\tLayer.provide(Database.layer(yield* Database.path(paths.data))),\n\t\t\t),\n\t\t),\n\t);\n});\n","import { Global, Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { linkedDirectory } from \"./session.ts\";\nimport {\n\tidentify,\n\tmatches,\n\treadPlugins,\n\tresolveTarget,\n\tspellings,\n\twithPluginsLock,\n\twritePlugins,\n\twritten,\n} from \"./settings.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.add,\n\tEffect.fn(\"CLI.plugin.add\")(function* ({ package: reference, global: userWide, session }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst path = yield* Path.Path;\n\t\t\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\n\t\t\t// A session names the project to write into when the shell's directory is not it --\n\t\t\t// a server or a UI acting on a session's behalf, rather than a person standing in the\n\t\t\t// repository. It fails when that session has no project, which is a state `session\n\t\t\t// link` exists to fix.\n\t\t\tconst linked = Option.isNone(session) ? undefined : yield* linkedDirectory(session.value, shared.home);\n\t\t\t/*\n\t\t\t * One directory answers every question this command asks about the reference, and it\n\t\t\t * is resolved before any of them.\n\t\t\t *\n\t\t\t * A relative spec anchors here, the `.npmrc` chain governing the install is read from\n\t\t\t * here, and the entry is written anchored here. Splitting them is not a cosmetic\n\t\t\t * inconsistency: under `--session` the shell's directory is a server's, so validating\n\t\t\t * `./plugins/x.ts` against it imports one file and writes a reference to another, and\n\t\t\t * reading the `.npmrc` chain from it installs from the wrong registry -- a private\n\t\t\t * scope's token lives in the project being written to, not wherever the server runs.\n\t\t\t */\n\t\t\tconst from = linked ?? path.resolve(\".\");\n\n\t\t\t// The file the entry will land in decides the install's registry identity: it is named\n\t\t\t// here -- without creating the marker -- so the store keys the artifact under the same\n\t\t\t// `.npmrc` chain every later resolve of this entry re-derives, and a bad reference\n\t\t\t// still leaves nothing behind.\n\t\t\tconst target = yield* resolveTarget(shared, userWide, linked, false);\n\n\t\t\t// Install and import before touching the file: a spec that turns out not to be a plugin\n\t\t\t// should fail here, with its own error, rather than at the next run from a file the user\n\t\t\t// then has to repair by hand.\n\t\t\tconst plugin = yield* Plugin.inspect(reference, { cache: paths.cache, hostDir: from, file: target.path });\n\t\t\t// What goes in the file, which is not always what was typed: a relative path anchors to\n\t\t\t// the settings file being written, not to the directory the command ran in.\n\t\t\tconst entry = yield* written(reference, {\n\t\t\t\thostDir: from,\n\t\t\t\tfile: target.path,\n\t\t\t\troot: target.root,\n\t\t\t});\n\t\t\tconst spelled = yield* spellings(reference, from);\n\t\t\tconst version = plugin.version === undefined ? \"\" : `@${plugin.version}`;\n\t\t\tyield* withPluginsLock(\n\t\t\t\ttarget.path,\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst { source, plugins } = yield* readPlugins(target.path);\n\t\t\t\t\tconst entries = yield* identify(plugins, target.path, paths.cache);\n\t\t\t\t\t// Configured already if any spelling of an existing entry names this plugin -- the same\n\t\t\t\t\t// package under a different version, the path it was added by, or the ID it declares.\n\t\t\t\t\tconst names = (candidate: (typeof entries)[number]) =>\n\t\t\t\t\t\tmatches(candidate, spelled) || candidate.answers.has(plugin.id);\n\t\t\t\t\tconst existing = entries.findIndex((candidate) => candidate.loads && names(candidate));\n\t\t\t\t\tif (existing >= 0) {\n\t\t\t\t\t\tconst current = entries[existing]?.value;\n\t\t\t\t\t\tif (current === entry) {\n\t\t\t\t\t\t\tyield* writeOut(`Plugin \"${reference}\" is already configured in ${target.path}\\n`);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst replaced = [...plugins];\n\t\t\t\t\t\treplaced[existing] = entry;\n\t\t\t\t\t\tyield* writePlugins(target.path, source, replaced);\n\t\t\t\t\t\tyield* writeOut(\n\t\t\t\t\t\t\t`Updated ${plugin.id} (${String(current)} -> ${entry}${version}) in ${target.path}\\n`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Put the loader before existing configuration so its options apply to the module.\n\t\t\t\t\tconst configured = entries.findIndex((candidate) => !candidate.loads && names(candidate));\n\t\t\t\t\tconst updated = [...plugins];\n\t\t\t\t\tupdated.splice(configured < 0 ? updated.length : configured, 0, entry);\n\t\t\t\t\tyield* writePlugins(target.path, source, updated);\n\t\t\t\t\tyield* writeOut(`Added ${plugin.id} (${entry}${version}) to ${target.path}\\n`);\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// Said after the write, because `resolveTarget` only named the marker: the lock's\n\t\t\t// write is what made it, and \"created\" should be true by the time it is printed.\n\t\t\tif (target.created !== undefined) yield* writeOut(`Created ${target.created}/\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,OAAO,GAAG,4BAA4B,CAAC,CAAC,WACtE,WACA,MACC;CACD,MAAM,QAAQ,OAAO,OAAO,QAAQ,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACnF,MAAM,KAAK,QAAQ,cAAc,GAAG,UAAU,SAAS;CAEvD,OAAO,OAAO,OAAO,IAAI,aAAa;EAErC,MAAM,QAAQ,QAAO,OADG,aAAa,QAAA,CACP,IAAI,EAAE;EACpC,IAAI,OAAO,OAAO,KAAK,GAAG,OAAO,OAAO,IAAI,aAAa,qBAAqB,EAAE,WAAW,GAAG,CAAC;EAC/F,MAAM,UAAU,OAAO,eAAe,MAAM,MAAM,OAAO;EACzD,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,IAAI,aAAa,sBAAsB,EAAE,WAAW,GAAG,CAAC;EACjG,OAAO;CACR,CAAC,CAAC,CAAC,KAGF,OAAO,QACN,aAAa,MAAM,KAClB,MAAM,QAAQ,MAAM,KAAK,GACzB,MAAM,QAAQ,SAAS,MAAM,O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C;GACrF,IAAI,YAAY,GAAG;IAClB,MAAM,UAAU,QAAQ,SAAS,EAAE;IACnC,IAAI,YAAY,OAAO;KACtB,OAAO,SAAS,WAAW,UAAU,6BAA6B,OAAO,KAAK,GAAG;KACjF;IACD;IACA,MAAM,WAAW,CAAC,GAAG,OAAO;IAC5B,SAAS,YAAY;IACrB,OAAO,aAAa,OAAO,MAAM,QAAQ,QAAQ;IACjD,OAAO,SACN,WAAW,OAAO,GAAG,IAAI,OAAO,OAAO,EAAE,MAAM,QAAQ,QAAQ,OAAO,OAAO,KAAK,GACnF;IACA;GACD;GAGA,MAAM,aAAa,QAAQ,WAAW,cAAc,CAAC,UAAU,SAAS,MAAM,SAAS,CAAC;GACxF,MAAM,UAAU,CAAC,GAAG,OAAO;GAC3B,QAAQ,OAAO,aAAa,IAAI,QAAQ,SAAS,YAAY,GAAG,KAAK;GACrE,OAAO,aAAa,OAAO,MAAM,QAAQ,OAAO;GAChD,OAAO,SAAS,SAAS,OAAO,GAAG,IAAI,QAAQ,QAAQ,OAAO,OAAO,KAAK,GAAG;EAC9E,CAAC,CACF;EAGA,IAAI,OAAO,YAAY,KAAA,GAAW,OAAO,SAAS,WAAW,OAAO,QAAQ,IAAI;CACjF,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as Cmd, t as handler } from "./runtime-B43doHjV.mjs";
|
|
2
|
-
import { d as writeOut, i as reportFailure } from "./error-
|
|
3
|
-
import { a as targeted, i as read, n as local, r as probe, t as fetchable } from "./entries-
|
|
2
|
+
import { d as writeOut, i as reportFailure } from "./error-CPo0lJt1.mjs";
|
|
3
|
+
import { a as targeted, i as read, n as local, r as probe, t as fetchable } from "./entries-DK4If3_G.mjs";
|
|
4
4
|
import { Effect, Option } from "effect";
|
|
5
5
|
import { Plugin } from "@codeworksh/harness/effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/plugin/check.ts
|
|
@@ -51,4 +51,4 @@ var check_default = handler(Cmd.commands.plugin.commands.check, Effect.fn("CLI.p
|
|
|
51
51
|
//#endregion
|
|
52
52
|
export { check_default as default };
|
|
53
53
|
|
|
54
|
-
//# sourceMappingURL=check-
|
|
54
|
+
//# sourceMappingURL=check-kFowK1HH.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-
|
|
1
|
+
{"version":3,"file":"check-kFowK1HH.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/check.ts"],"sourcesContent":["import { Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { fetchable, local, probe, read, targeted } from \"./entries.ts\";\n\n/**\n * Which configured plugins have a newer revision available.\n *\n * A probe failure -- offline, registry down, a remote that refuses -- is **not** an update. It is\n * reported per target and the command exits non-zero, rather than being swallowed into \"you are up\n * to date\": an outage that reads as currency is the one answer this command must never give.\n */\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.check,\n\tEffect.fn(\"CLI.plugin.check\")(function* ({ refresh, spec }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst { entries, cache, hostDir } = yield* read(shared);\n\t\t\tconst selected = yield* targeted(entries, spec, hostDir);\n\t\t\tif (selected.length === 0 && Option.isSome(spec)) return;\n\n\t\t\tlet outdated = 0;\n\t\t\tlet failed = 0;\n\t\t\tfor (const entry of selected) {\n\t\t\t\tconst target = fetchable(entry.target);\n\t\t\t\t// Nothing to compare: a local path has no revision, and `check` skips it rather\n\t\t\t\t// than reporting it as current.\n\t\t\t\tif (target === undefined) {\n\t\t\t\t\tyield* local(entry, spec);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst state = yield* Plugin.check(target, cache, {\n\t\t\t\t\trefresh,\n\t\t\t\t\tprobe: probe(cache, entry.from),\n\t\t\t\t\tfrom: entry.from,\n\t\t\t\t}).pipe(Effect.result);\n\t\t\t\tif (state._tag === \"Failure\") {\n\t\t\t\t\tfailed += 1;\n\t\t\t\t\tyield* writeOut(`${entry.reference} error[${state.failure.reason}]: ${state.failure.message}\\n`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tswitch (state.success._tag) {\n\t\t\t\t\tcase \"outdated\":\n\t\t\t\t\t\toutdated += 1;\n\t\t\t\t\t\tyield* writeOut(`${entry.reference} ${state.success.filed ?? \"?\"} -> ${state.success.available}\\n`);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"not-installed\":\n\t\t\t\t\t\tyield* writeOut(`${entry.reference} plugin-not-installed\\n`);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t// An exact version and a commit SHA cannot move, so neither is worth a line.\n\t\t\t\t\tcase \"immutable\":\n\t\t\t\t\tcase \"current\":\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// A spec that named only local plugins compared nothing, so there is nothing to sum up.\n\t\t\tif (Option.isSome(spec) && selected.every((entry) => fetchable(entry.target) === undefined)) return;\n\t\t\tyield* writeOut(\n\t\t\t\toutdated === 0 && failed === 0\n\t\t\t\t\t? \"Everything is up to date.\\n\"\n\t\t\t\t\t: `${outdated} update${outdated === 1 ? \"\" : \"s\"} available.\\n`,\n\t\t\t);\n\t\t\tif (failed > 0) process.exitCode = 1;\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;AAeA,IAAA,gBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,OAC7B,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,EAAE,SAAS,QAAQ;CAqD3D,OAAO,OApDS,OAAO,IAAI,aAAa;EACvC,MAAM,SAAS,OAAO,IA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-
import { s as userLayer } from "./settings-
|
|
1
|
+
import { d as writeOut } from "./error-CPo0lJt1.mjs";
|
|
2
|
+
import { s as userLayer } from "./settings-BHxEl9yP.mjs";
|
|
3
3
|
import { Effect, Option, Path } from "effect";
|
|
4
4
|
import { Global, Plugin, Settings } from "@codeworksh/harness/effect";
|
|
5
5
|
//#region src/cli/cmd/handlers/plugin/entries.ts
|
|
@@ -87,4 +87,4 @@ const fetchable = (target) => target === void 0 || target.kind === "local" ? voi
|
|
|
87
87
|
//#endregion
|
|
88
88
|
export { targeted as a, read as i, local as n, probe as r, fetchable as t };
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=entries-
|
|
90
|
+
//# sourceMappingURL=entries-DK4If3_G.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries-
|
|
1
|
+
{"version":3,"file":"entries-DK4If3_G.mjs","names":[],"sources":["../../src/cli/cmd/handlers/plugin/entries.ts"],"sourcesContent":["import { Global, Plugin, Settings } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport { writeOut } from \"../../../output.ts\";\nimport { userLayer, type Shared } from \"./settings.ts\";\n\n/**\n * Every plugin entry the settings files name, across every layer, in the order they accumulate.\n *\n * This is what `install`, `list`, `check` and `update` all operate on: unlike `add` and `remove`,\n * none of them writes an entry. They read what is already there and act on the store -- each one\n * under the `.npmrc` context of the file that declared it, which is what keys the artifact.\n */\nexport interface Entry {\n\t/** The reference as the settings file spells it: the string a person will search for. */\n\treadonly written: string;\n\t/** The same reference, anchored to the file that declared it. This is what resolves. */\n\treadonly reference: string;\n\t/** Which settings file owns it: the last to declare it in the view that needs it. */\n\treadonly file: string;\n\t/**\n\t * The `.npmrc` anchor for the entry's store identity: the project that declared it, so the\n\t * registry context is the same wherever this command happens to run.\n\t */\n\treadonly from: string;\n\t/** Absent for an unparseable entry and for a local path. */\n\treadonly target: Plugin.Target | undefined;\n}\n\n/** Only a string entry loads a module; `{ package }` is configuration for one already selected. */\nconst moduleOf = (entry: unknown): string | undefined => (typeof entry === \"string\" ? entry : undefined);\n\nexport const read = Effect.fn(\"CLI.plugin.entries\")(function* (shared: Shared) {\n\tconst nodePath = yield* Path.Path;\n\t// The directory the command runs in resolves its app-level flags. No session links it to\n\t// another host directory, so it is the command's anchor too: project settings are discovered\n\t// from here, and a relative spec typed here resolves here.\n\tconst hostCwd = nodePath.resolve(\".\");\n\tconst hostDir = hostCwd;\n\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\tconst root = yield* Settings.projectRoot(hostDir, paths.home);\n\tconst layers = { home: paths.home, ...userLayer(shared, hostCwd) };\n\t/*\n\t * The runtime resolves plugins in two views, and each needs its own artifact on disk: boot\n\t * reads the user layers alone, and a session reads every layer. Within a view the last file to\n\t * declare a reference owns it, so a spec both layers name is owned by the user file at boot and\n\t * by the project file in the project's sessions -- two `.npmrc` anchors, and possibly two\n\t * registries. Collapsing it to one owner leaves one of those views without its artifact.\n\t */\n\tconst boot = yield* Settings.load(layers);\n\tconst views = root === undefined ? [boot] : [boot, yield* Settings.load({ ...layers, hostDir: root })];\n\n\t// One entry per store artifact, so two anchors on one registry stay a single line. A later\n\t// view names the file, which is the one a person in this project would edit.\n\tconst entries = new Map<string, Entry>();\n\tfor (const view of views) {\n\t\t// views is [boot] outside a project, or [boot, session] inside one.\n\t\t// Boot comes first, and the order matters (see below).\n\t\tfor (const [reference, one] of Settings.modules(view.declared)) {\n\t\t\t// Already anchored to the file that declared it, so `hostDir` here only affects a\n\t\t\t// reference no settings file produced.\n\t\t\tconst target = Option.getOrUndefined(yield* Plugin.parse(reference, hostDir).pipe(Effect.option));\n\t\t\tconst from = Plugin.anchor(one.file, hostDir);\n\t\t\tconst key = yield* identity(target, reference, from, paths.cache);\n\t\t\tentries.set(key, { written: moduleOf(one.written) ?? reference, reference, file: one.file, from, target });\n\t\t}\n\t}\n\treturn { entries: [...entries.values()] as ReadonlyArray<Entry>, cache: paths.cache, hostDir };\n});\n\n/**\n * What makes two entries one artifact: the store's own key for a fetched target, the file for a\n * local one. A registry that cannot be read keeps the entry apart, so its install reports why.\n */\nconst identity = (target: Plugin.Target | undefined, reference: string, from: string, cache: string) => {\n\tconst fetched = fetchable(target);\n\tif (fetched === undefined) return Effect.succeed(target?.kind === \"local\" ? target.path : reference);\n\treturn Plugin.identity(fetched, cache, from).pipe(Effect.orElseSucceed(() => `${reference}\\0${from}`));\n};\n\n/** What a reference names, whatever version it was written with: a package, a git spec, a file. */\nconst source = (reference: string, hostDir: string) =>\n\tPlugin.canonical(reference, hostDir).pipe(Effect.orElseSucceed(() => reference));\n\n/**\n * The entries a command acts on: all of them, or every one `spec` names.\n *\n * Matched by source identity, the way the `plugins` array reads -- `@acme/x` selects\n * `@acme/x@^1`, a relative path selects the file it resolves to from `hostDir`, and a local package\n * also answers to the name its `package.json` declares. A plugin ID is not a spelling of anything\n * in that array, so it matches nothing. Every match is kept: a spec both layers declare under\n * different registries is two artifacts, and both answer to it.\n */\nexport const targeted = Effect.fn(\"CLI.plugin.targeted\")(function* (\n\tentries: ReadonlyArray<Entry>,\n\tspec: Option.Option<string>,\n\t/** The host directory the command resolves from, which a relative spec is typed against. */\n\thostDir: string,\n) {\n\tif (Option.isNone(spec)) return entries;\n\tconst wanted = yield* source(spec.value, hostDir);\n\tconst selected: Entry[] = [];\n\tfor (const entry of entries) {\n\t\tconst named =\n\t\t\t(yield* source(entry.reference, hostDir)) === wanted ||\n\t\t\t(entry.target?.kind === \"local\" && (yield* Plugin.localName(entry.target.path)) === wanted);\n\t\tif (named) selected.push(entry);\n\t}\n\tif (selected.length === 0) {\n\t\tyield* writeOut(`Plugin \"${spec.value}\" is not configured. Run \\`codework plugin list\\` to see what is.\\n`);\n\t\tprocess.exitCode = 1;\n\t}\n\treturn selected as ReadonlyArray<Entry>;\n});\n\n/**\n * A local plugin has no revision to compare and is never copied into the store. Skipped quietly\n * when a command walks everything; named, it says why nothing happened.\n */\nexport const local = (entry: Entry, spec: Option.Option<string>) =>\n\tOption.isSome(spec) ? writeOut(`${entry.reference} local: no remote revision to compare\\n`) : Effect.void;\n\n/**\n * The network half, handed to the store so the store itself never opens a socket.\n *\n * `probe` bypasses pacote's own metadata cache, because a staleness check that reads a cache is\n * not a staleness check. `from` is the host directory: a probe that read a different `.npmrc`\n * chain than the install would answer about a registry nothing is ever fetched from.\n */\nexport const probe =\n\t(cache: string, from: string): Plugin.Probe =>\n\t(target) =>\n\t\tPlugin.probe(target, cache, from);\n\n/** Only a fetched target has a store entry; a local one is loaded where it lies. */\nexport const fetchable = (target: Plugin.Target | undefined): Plugin.Fetchable | undefined =>\n\ttarget === undefined || target.kind === \"local\" ? undefined : target;\n"],"mappings":";;;;;;AA6BA,MAAM,YAAY,UAAwC,OAAO,UAAU,WAAW,QAAQ,KAAA;AAE9F,MAAa,OAAO,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,QAAgB;CAK9E,MAAM,WAAU,OAJQ,KAAK,KAAA,CAIJ,QAAQ,GAAG;CACpC,MAAM,UAAU;CAChB,MAAM,QAAQ,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,KAAK,MAAM,CAAC;CACjG,MAAM,OAAO,OAAO,SAAS,YAAY,SAAS,MAAM,IAAI;CAC5D,MAAM,SAAS;EAAE,MAAM,MAAM;EAAM,GAAG,UAAU,QAAQ,OAAO;CAAE;CAQjE,MAAM,OAAO,OAAO,SAAS,KAAK,MAAM;CACxC,MAAM,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,IAAI,CAAC,MAAM,OAAO,SAAS,KAAK;EAAE,GAAG;EAAQ,SAAS;CAAK,CAAC,CAAC;CAIrG,MAAM,0BAAU,IAAI,IAAmB;CACvC,KAAK,MAAM,QAAQ,OAGlB,KAAK,MAAM,CAAC,WAAW,QAAQ,SAAS,QAAQ,KAAK,QAAQ,GAAG;EAG/D,MAAM,SAAS,OAAO,eAA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AAQ,WAAW;CACpB;CACA,OAAO;AACR,CAAC;;;;;AAMD,MAAa,SAAS,OAAc,SACnC,OAAO,OAAO,IAAI,IAAI,SAAS,GAAG,MAAM,UAAU,yCAAyC,IAAI,OAAO;;;;;;;;AASvG,MAAa,SACX,OAAe,UACf,WACA,OAAO,MAAM,QAAQ,OAAO,IAAI;;AAGlC,MAAa,aAAa,WACzB,WAAW,KAAA,KAAa,OAAO,SAAS,UAAU,KAAA,IAAY"}
|
|
@@ -153,7 +153,9 @@ const SessionInfo = Schema.Struct({
|
|
|
153
153
|
model: optional(Schema.Struct({
|
|
154
154
|
provider: Schema.String,
|
|
155
155
|
id: Schema.String
|
|
156
|
-
}))
|
|
156
|
+
})),
|
|
157
|
+
/** The thinking level chosen for this session; absent when settings decide. */
|
|
158
|
+
thinkingLevel: optional(Schema.Enum(Model.ThinkingLevelEnum))
|
|
157
159
|
});
|
|
158
160
|
/** One message on a session's active branch, oldest first. */
|
|
159
161
|
const HistoryEntry = Schema.Struct({
|
|
@@ -797,4 +799,4 @@ const reportFailure = (error) => writeError(renderError(error)).pipe(Effect.andT
|
|
|
797
799
|
//#endregion
|
|
798
800
|
export { path as _, addUsage as a, Core as b, terminalColumns as c, writeOut as d, layer as f, OAuthError$1 as g, Api as h, reportFailure as i, usage as l, run as m, OAuthError as n, emptyUsage as o, make as p, renderError as r, header as s, InvalidInputError as t, writeError as u, decode as v, encode as x, Connected as y };
|
|
799
801
|
|
|
800
|
-
//# sourceMappingURL=error-
|
|
802
|
+
//# sourceMappingURL=error-CPo0lJt1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-CPo0lJt1.mjs","names":["decode","OAuthError","Contract.Api","Envelope.decode","Client.ExecutionError"],"sources":["../../src/server/envelope.ts","../../src/server/part.ts","../../src/server/contract.ts","../../src/server/client.ts","../../src/cli/output.ts","../../src/cli/error.ts"],"sourcesContent":["import { EventList, EventSchema, optional } from \"@codeworksh/harness/effect\";\nimport { Effect, Schema } from \"effect\";\n\n/**\n * The wire form of an `EventSchema.Payload`. `data` is carried in its encoded\n * form — decoded payloads are not wire-safe (`Schema.Duration`, aikit class\n * transforms) — so clients decode it lazily through their own copy of the\n * registry and can skip types they do not know.\n */\nexport const EventEnvelope = Schema.Struct({\n\tid: EventSchema.ID,\n\ttype: Schema.String,\n\tdurable: optional(Schema.Struct({ aggregateId: Schema.String, seq: Schema.Int, version: Schema.Int })),\n\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\tdata: Schema.Unknown,\n});\nexport type EventEnvelope = typeof EventEnvelope.Type;\n\nexport class UnknownEventTypeError extends Schema.TaggedError<UnknownEventTypeError>()(\"UnknownEventTypeError\", {\n\ttype: Schema.String,\n}) {}\n\n/** The transport's own readiness frame; it has no meaning inside the harness. */\nexport const Connected = EventSchema.define({ type: \"server.connected\", schema: {} });\n\n/** Resolves a published type to the definition that encodes it. */\nexport type Registry = (type: string) => EventSchema.Definition | undefined;\n\n/**\n * What a stock client can decode: the harness's public events plus the frames\n * the transport adds itself. A server may know more than this -- plugins\n * register their own types -- which is exactly why `data` crosses the wire\n * encoded and is decoded lazily, so an unknown type is skipped, not fatal.\n */\nconst core = EventSchema.latest([...EventList.PublicDefinitions, Connected]);\nexport const Core: Registry = (type) => core.get(type);\n\nexport class EncodingError extends Schema.TaggedError<EncodingError>()(\"EventEncodingError\", {\n\ttype: Schema.String,\n\tcause: Schema.Defect(),\n}) {}\n\nexport const encode = Effect.fn(\"Envelope.encode\")(function* (payload: EventSchema.Payload, registry: Registry = Core) {\n\tconst definition = registry(payload.type);\n\tif (definition === undefined) return yield* new UnknownEventTypeError({ type: payload.type });\n\tconst data = yield* Schema.encodeEffect(definition.data)(payload.data).pipe(\n\t\tEffect.mapError((cause) => new EncodingError({ type: payload.type, cause })),\n\t);\n\treturn {\n\t\tid: payload.id,\n\t\ttype: payload.type,\n\t\t...(payload.durable === undefined ? {} : { durable: payload.durable }),\n\t\t...(payload.metadata === undefined ? {} : { metadata: payload.metadata }),\n\t\tdata,\n\t};\n});\n\nexport const decode = Effect.fn(\"Envelope.decode\")(function* (envelope: EventEnvelope, registry: Registry = Core) {\n\tconst definition = registry(envelope.type);\n\tif (definition === undefined) {\n\t\treturn yield* new UnknownEventTypeError({ type: envelope.type });\n\t}\n\tconst data = yield* Schema.decodeEffect(definition.data)(envelope.data);\n\treturn {\n\t\tid: envelope.id,\n\t\ttype: envelope.type,\n\t\t...(envelope.durable === undefined ? {} : { durable: envelope.durable }),\n\t\t...(envelope.metadata === undefined ? {} : { metadata: envelope.metadata }),\n\t\tdata,\n\t} as EventSchema.Payload;\n});\n\nexport * as Envelope from \"./envelope.ts\";\n","import { Schema } from \"effect\";\n\n/*\n * A stored message part as clients see it: aikit's part JSON (persisted verbatim by the harness),\n * narrowed to what a client renders. Provider replay data (signatures, namespaces) and tool\n * `details` are left out, so decoding a stored part drops them.\n */\n\nexport const TextContent = Schema.Struct({ type: Schema.Literal(\"text\"), text: Schema.String });\nexport const ImageContent = Schema.Struct({\n\ttype: Schema.Literal(\"image\"),\n\tdata: Schema.String,\n\tmimeType: Schema.String,\n});\nexport const ThinkingContent = Schema.Struct({\n\ttype: Schema.Literal(\"thinking\"),\n\tthinking: Schema.String,\n\t/** The provider withheld the reasoning; `thinking` is then empty. */\n\tredacted: Schema.optionalKey(Schema.Boolean),\n});\n\n/** aikit's ToolStatusEnum. */\nexport const ToolStatus = Schema.Literals([\"pending\", \"running\", \"completed\", \"error\", \"skipped\", \"aborted\"]);\n\nexport const ToolResult = Schema.Struct({\n\tcontent: Schema.Array(Schema.Union([TextContent, ImageContent])),\n\tisError: Schema.Boolean,\n});\n\nexport const ToolCall = Schema.Struct({\n\ttype: Schema.Literal(\"toolCall\"),\n\tcallID: Schema.String,\n\tname: Schema.String,\n\targuments: Schema.Record(Schema.String, Schema.Json),\n\tstatus: ToolStatus,\n\t/** Present once the call settled (completed, error, skipped, aborted). */\n\tresult: Schema.optionalKey(ToolResult),\n\t/** Epoch milliseconds: started, and last lifecycle update. */\n\ttime: Schema.optionalKey(Schema.Struct({ start: Schema.Finite, end: Schema.Finite })),\n});\nexport type ToolCall = typeof ToolCall.Type;\n\nexport const Part = Schema.Union([TextContent, ImageContent, ThinkingContent, ToolCall]);\nexport type Part = typeof Part.Type;\n\n/** A stored part row's JSON, or none when it is not a part a client renders. */\nexport const decode = Schema.decodeUnknownOption(Schema.fromJsonString(Part));\n\nexport * as MessagePart from \"./part.ts\";\n","import { Model } from \"@codeworksh/aikit\";\nimport {\n\tControl,\n\tEvent,\n\tLocation,\n\toptional,\n\tProject,\n\tPromptSchema,\n\tRunner,\n\tSandbox,\n\tSandboxError,\n\tSession,\n\tSessionStore,\n\tSettings,\n} from \"@codeworksh/harness/effect\";\nimport { Schema } from \"effect\";\nimport { Rpc, RpcGroup } from \"effect/rpc\";\nimport { EncodingError, EventEnvelope } from \"./envelope.ts\";\nimport { Part } from \"./part.ts\";\n\n/** The HTTP path the RPC endpoint is served on; the version moves with breaking wire changes. */\nexport const path = \"/rpc/v1\";\n\nexport const SandboxInfo = Schema.Struct({\n\tid: Sandbox.SandboxInstance.ID,\n\tdriver: Schema.String,\n\tkind: Sandbox.SandboxInstance.Kind,\n\tproviderResourceId: Schema.OptionFromNullOr(Schema.String),\n\townership: Sandbox.SandboxInstance.Ownership,\n\tstatus: Sandbox.SandboxInstance.Status,\n\tusage: Sandbox.SandboxInstance.Usage,\n\trefCount: Schema.Int,\n\tcreatedAt: Schema.DateFromString,\n\tupdatedAt: Schema.DateFromString,\n});\nexport type SandboxInfo = typeof SandboxInfo.Type;\n\nexport const SessionInfo = Schema.Struct({\n\tid: Session.SessionSchema.ID,\n\ttitle: Schema.String,\n\tdirectory: Session.AbsolutePath,\n\t/** The host directory this session is anchored to. Absent when it has none. */\n\thostDir: optional(Session.AbsolutePath),\n\tsandbox: optional(SandboxInfo),\n\t/** The project the session's space belongs to. */\n\tproject: optional(Schema.Struct({ id: Schema.String, name: Schema.String })),\n\t/** Last activity, epoch milliseconds. */\n\tupdatedAt: Schema.Finite,\n\t/** The model chosen for this session; absent when settings decide. */\n\tmodel: optional(Schema.Struct({ provider: Schema.String, id: Schema.String })),\n\t/** The thinking level chosen for this session; absent when settings decide. */\n\tthinkingLevel: optional(Schema.Enum(Model.ThinkingLevelEnum)),\n});\nexport type SessionInfo = typeof SessionInfo.Type;\n\n/** One message on a session's active branch, oldest first. */\nexport const HistoryEntry = Schema.Struct({\n\t/** The entry id: what live events and `session.message` refer to. */\n\tid: Schema.String,\n\t/** Its place in the session's durable log; live events continue from it. */\n\tseq: Schema.Int,\n\trole: Schema.Literals([\"user\", \"assistant\"]),\n\t/** `draft` is a reply still streaming; `aborted` one that was interrupted. */\n\tstate: Schema.Literals([\"committed\", \"draft\", \"aborted\"]),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\t/** Epoch milliseconds of the last change; for a reply, when it ended once it is no longer a draft. */\n\tupdatedAt: Schema.Finite,\n\tparts: Schema.Array(Part),\n});\nexport type HistoryEntry = typeof HistoryEntry.Type;\n\n/** Ends `session.log`'s replay; `seq` is absent when the session has no durable events yet. */\nexport const LogSynced = Schema.Struct({\n\ttype: Schema.Literal(\"log.synced\"),\n\t/** The session the log was read for. */\n\taggregateId: Schema.String,\n\tseq: optional(Schema.Int),\n});\nexport type LogSynced = typeof LogSynced.Type;\n\nexport const RuntimeConfig = Schema.Struct({\n\tmodel: optional(Schema.Struct({ provider: Schema.String, id: Schema.String })),\n\tthinkingLevel: optional(Schema.Enum(Model.ThinkingLevelEnum)),\n});\nexport type RuntimeConfig = typeof RuntimeConfig.Type;\n\nexport const SandboxRef = Sandbox.Selection;\n\n/** A model to choose, by the catalog's id and display name, with the thinking levels it supports. */\nexport const ModelOption = Schema.Struct({\n\tid: Schema.String,\n\tname: Schema.String,\n\t/** In ascending order; `[\"off\"]` for a model that does not reason. */\n\tthinkingLevels: Schema.Array(Schema.Enum(Model.ThinkingLevelEnum)),\n});\n\n/** A provider this server can call, with the models a session may use from it. */\nexport const ModelProvider = Schema.Struct({\n\tid: Schema.String,\n\tname: Schema.String,\n\tmodels: Schema.Array(ModelOption),\n});\nexport type ModelProvider = typeof ModelProvider.Type;\n\n/** A project's name as a client sets it: trimmed, never empty. */\nexport const ProjectName = Schema.Trimmed.check(Schema.isNonEmpty());\n\nexport class OAuthError extends Schema.TaggedError<OAuthError>()(\"Server.OAuthError\", {\n\tmessage: Schema.String,\n}) {}\n\n/** OAuth providers whose credentials this server stores. */\nexport const OAuthProvider = Schema.Literals([\"openai-codex\", \"github-copilot\"]);\nexport type OAuthProvider = typeof OAuthProvider.Type;\n\n/**\n * Credentials as the provider's aikit module persists them. The union is\n * discriminated by `provider` so one set of RPCs serves every login.\n */\nexport const OAuthCredentials = Schema.Union([\n\tSchema.Struct({\n\t\tprovider: Schema.Literal(\"openai-codex\"),\n\t\taccess: Schema.String,\n\t\trefresh: Schema.String,\n\t\texpires: Schema.Finite,\n\t\taccountId: Schema.String,\n\t}),\n\tSchema.Struct({\n\t\tprovider: Schema.Literal(\"github-copilot\"),\n\t\taccess: Schema.String,\n\t\trefresh: Schema.String,\n\t\texpires: Schema.Finite,\n\t\tenterpriseUrl: optional(Schema.String),\n\t\tapiEndpoint: optional(Schema.String),\n\t\tavailableModelIds: optional(Schema.Array(Schema.String)),\n\t}),\n]);\nexport type OAuthCredentials = typeof OAuthCredentials.Type;\n\n/** What a login looks like from the outside: never the tokens themselves. */\nexport const OAuthInfo = Schema.Struct({\n\tprovider: OAuthProvider,\n\t/** Epoch millis, or 0 for a credential that does not expire. */\n\texpires: Schema.Finite,\n\taccountId: optional(Schema.String),\n\tapiEndpoint: optional(Schema.String),\n\tenterpriseUrl: optional(Schema.String),\n\tavailableModels: optional(Schema.Int),\n});\nexport type OAuthInfo = typeof OAuthInfo.Type;\n\nconst SessionErrors = Schema.Union([\n\tSessionStore.SessionNotFoundError,\n\tSessionStore.SessionLinkedSpaceNotFoundError,\n\tSessionStore.RelinkError,\n]);\n\n// Every lifecycle error the sandbox control plane can raise; narrowing per\n// endpoint would misreport what `withMount` and `stop` actually fail with.\nconst SandboxErrors = Schema.Union([\n\tSandboxError.SandboxNotFoundError,\n\tSandboxError.SandboxDriverNotRegisteredError,\n\tSandboxError.SandboxDriverRegistrationError,\n\tSandboxError.SandboxUnsupportedError,\n\tSandboxError.SandboxProviderError,\n\tSandboxError.SandboxUnavailError,\n\tSandboxError.SandboxRemovedError,\n\tSandboxError.SandboxTransitionConflictError,\n\tSandboxError.SandboxBusyError,\n]);\n\nconst LocationErrors = Schema.Union([Location.DirectoryNotFoundError, Location.NotDirectoryError]);\n\nexport const Api = RpcGroup.make(\n\t/**\n\t * The server's own identity: the process and build a client is talking to.\n\t *\n\t * The health probe: a discovery registration names a pid and version, and a\n\t * caller confirms the process answering is the one that registered before it\n\t * trusts the endpoint. Like every other capability it rides the RPC channel,\n\t * so there is no separate HTTP surface to keep in step.\n\t */\n\tRpc.make(\"server.info\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ pid: Schema.Int, version: Schema.String }),\n\t}),\n\tRpc.make(\"auth.save\", {\n\t\tpayload: { credentials: OAuthCredentials },\n\t\tsuccess: OAuthInfo,\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.status\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.NullOr(OAuthInfo),\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.refresh\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.NullOr(OAuthInfo),\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.logout\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.Void,\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"session.create\", {\n\t\tpayload: {\n\t\t\ttitle: optional(Schema.String),\n\t\t\tdirectory: optional(Schema.String),\n\t\t\t/**\n\t\t\t * The host directory this session is anchored to, usually the caller's project root.\n\t\t\t * Unrelated to `directory`, which names a place inside the session's space.\n\t\t\t *\n\t\t\t * It is an anchor and nothing more: whatever needs a host-side directory resolves from\n\t\t\t * here rather than from wherever the server happens to be running. What reads it is the\n\t\t\t * reader's business, not this field's.\n\t\t\t *\n\t\t\t * Optional and honoured as given. Omitting it is normal, not a failure.\n\t\t\t */\n\t\t\thostDir: optional(Session.AbsolutePath),\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\truntime: optional(RuntimeConfig),\n\t\t\t/**\n\t\t\t * Names the project when this session creates it, ahead of the repository's and the\n\t\t\t * folder's name. A project that already exists keeps its name; `project.rename` changes it.\n\t\t\t */\n\t\t\tproject: optional(Schema.Struct({ name: ProjectName })),\n\t\t},\n\t\tsuccess: SessionInfo,\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors]),\n\t}),\n\tRpc.make(\"project.rename\", {\n\t\tpayload: { projectId: Schema.String, name: ProjectName },\n\t\tsuccess: Schema.Struct({ id: Schema.String, name: Schema.String }),\n\t\terror: Project.ProjectNotFoundError,\n\t}),\n\t/**\n\t * The models a session anchored at `hostDir` can use: providers this server holds credentials\n\t * for, in the catalog plus that project's settings, and the model settings pick when a session\n\t * names none. Without `hostDir`, only the user's settings apply. Credentials are checked for\n\t * presence, not validity.\n\t */\n\tRpc.make(\"model.list\", {\n\t\tpayload: { hostDir: optional(Session.AbsolutePath) },\n\t\tsuccess: Schema.Struct({\n\t\t\tproviders: Schema.Array(ModelProvider),\n\t\t\tdefault: Schema.Struct({\n\t\t\t\tprovider: Schema.String,\n\t\t\t\tid: Schema.String,\n\t\t\t\t/** As settings name it; a run clamps it to what the model supports. */\n\t\t\t\tthinkingLevel: Schema.Enum(Model.ThinkingLevelEnum),\n\t\t\t\t/** Display names from the catalog, present even when its provider is not listed. */\n\t\t\t\tname: optional(Schema.String),\n\t\t\t\tproviderName: optional(Schema.String),\n\t\t\t}),\n\t\t}),\n\t\terror: Schema.Union([Settings.SettingsError, Runner.ModelCatalogError]),\n\t}),\n\tRpc.make(\"session.list\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(SessionInfo),\n\t}),\n\t/**\n\t * The conversation on a session's active branch: user and assistant messages, oldest first.\n\t * Other branches and the harness's own entries (compactions, summaries) are left out.\n\t */\n\tRpc.make(\"session.history\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: SessionStore.SessionNotFoundError,\n\t}),\n\t/**\n\t * A session's durable events after `after` (exclusive; omitted reads from the start), then a\n\t * `log.synced` marker at the head read when the call began. With `follow`, each event then\n\t * streams as it commits; without it the stream ends at the marker.\n\t * Ephemeral events (text and tool progress deltas) are never stored, so they are not here;\n\t * `event.subscribe` carries them live. To resume, pass the higher of the last event's\n\t * `durable.seq` and the last marker's `seq`: the marker can sit past the last event sent.\n\t */\n\tRpc.make(\"session.log\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID, after: optional(Schema.Int), follow: optional(Schema.Boolean) },\n\t\tsuccess: Schema.Union([EventEnvelope, LogSynced]),\n\t\terror: Schema.Union([SessionStore.SessionNotFoundError, EncodingError]),\n\t\tstream: true,\n\t}),\n\tRpc.make(\"session.configure\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID, runtime: RuntimeConfig },\n\t\tsuccess: SessionInfo,\n\t\terror: SessionStore.SessionNotFoundError,\n\t}),\n\tRpc.make(\"session.info\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: SessionInfo,\n\t\terror: SessionStore.SessionNotFoundError,\n\t}),\n\t/**\n\t * Point an existing session at a host directory, or clear it with `null`.\n\t *\n\t * Not `session.relink`: that moves where the *work* happens, this changes which host directory\n\t * the session is *anchored to*. Conflating them would recreate exactly the `cwd`/`hostDir`\n\t * confusion the split exists to remove, which is why they sound alike and stay apart.\n\t */\n\tRpc.make(\"session.link\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\t/** Absent clears the anchor, leaving the session with no host directory. */\n\t\t\thostDir: optional(Session.AbsolutePath),\n\t\t},\n\t\tsuccess: SessionInfo,\n\t\terror: SessionStore.SessionNotFoundError,\n\t}),\n\tRpc.make(\"session.relink\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\tdirectory: optional(Schema.String),\n\t\t},\n\t\tsuccess: SessionInfo,\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors]),\n\t}),\n\tRpc.make(\"session.prompt\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\ttext: Schema.String,\n\t\t\tdelivery: optional(PromptSchema.Delivery),\n\t\t\tid: optional(Session.SessionMessageSchema.ID),\n\t\t},\n\t\tsuccess: Schema.Void,\n\t\terror: Schema.Union([SessionStore.SessionNotFoundError, Control.PromptConflictError]),\n\t}),\n\tRpc.make(\"session.interrupt\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: Schema.Struct({ interrupted: Schema.Boolean }),\n\t}),\n\t/**\n\t * Whether a prompt materialized into the conversation. An admitted prompt\n\t * that is still queued has no entry yet, so this is the projection a client\n\t * reconciles against when the volatile stream left it unsure\n\t */\n\tRpc.make(\"session.message\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID, messageId: Session.SessionMessageSchema.ID },\n\t\tsuccess: Schema.Struct({ found: Schema.Boolean }),\n\t}),\n\tRpc.make(\"session.wait\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: Schema.Void,\n\t\terror: SessionStore.SessionNotFoundError,\n\t}),\n\t/**\n\t * Re-import every configured plugin, for the whole server.\n\t *\n\t * The one thing an exchange cannot notice on its own: a local plugin whose contents changed\n\t * while its path did not. A failure keeps the previous set and is reported here rather than\n\t * emptying a running server's tool registry.\n\t */\n\tRpc.make(\"plugin.reload\", {\n\t\tpayload: {},\n\t\t// No error channel: a reload that fails keeps the previous set and reports why, because a\n\t\t// server that empties its tool registry over a typo is worse than one that says so.\n\t\tsuccess: Schema.Struct({ plugins: Schema.Int, failure: optional(Schema.String) }),\n\t}),\n\tRpc.make(\"sandbox.drivers\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(Schema.Struct({ name: Schema.String, kind: Schema.String })),\n\t}),\n\tRpc.make(\"sandbox.list\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(SandboxInfo),\n\t}),\n\tRpc.make(\"sandbox.create\", {\n\t\tpayload: { driver: Schema.String },\n\t\tsuccess: SandboxInfo,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"sandbox.register\", {\n\t\tpayload: { driver: Schema.String, providerResourceId: Schema.String },\n\t\tsuccess: SandboxInfo,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"sandbox.stop\", {\n\t\tpayload: { sandboxId: Sandbox.SandboxInstance.ID },\n\t\tsuccess: Schema.Void,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"event.subscribe\", {\n\t\tpayload: {},\n\t\tsuccess: EventEnvelope,\n\t\terror: Schema.Union([Event.SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n);\n\nexport * as Contract from \"./contract.ts\";\n","import { EventList, type EventSchema, optional, Session } from \"@codeworksh/harness/effect\";\nimport { NodeSocket } from \"@effect/platform-node\";\nimport { Deferred, Effect, Layer, Predicate, Schema, Stream } from \"effect\";\nimport { RpcClient, RpcSerialization } from \"effect/rpc\";\nimport { Contract } from \"./contract.ts\";\nimport { Envelope } from \"./envelope.ts\";\n\nexport const make = RpcClient.make(Contract.Api);\nexport type Client = Effect.Success<typeof make>;\n\nexport const layer = (url: string) =>\n\tRpcClient.layerProtocolSocket().pipe(\n\t\tLayer.provide(NodeSocket.layerWebSocket(url)),\n\t\tLayer.provide(RpcSerialization.layerNdjson),\n\t);\n\n/** A server-side failure as the client sees it: the category, not the cause. */\nexport class ExecutionError extends Schema.TaggedError<ExecutionError>()(\"Client.ExecutionError\", {\n\ttype: Schema.String,\n\tmessage: Schema.String,\n\tstatus: optional(Schema.Int),\n}) {}\n\n/**\n * Runs one prompt against a server and renders its output.\n *\n * Sessions are shared, so the stream carries other clients' work too and every\n * terminal event has to be attributed before it is believed. A terminal that\n * arrives before our own prompt is promoted belongs to somebody else's drain:\n * it is remembered rather than raised, and forgotten the moment our prompt is\n * promoted. It only becomes our outcome if the session reaches idle having\n * never promoted us -- at which point it is the best explanation available for\n * why our prompt never ran.\n */\nexport const run = Effect.fn(\"Client.run\")(function* <E, R>(\n\trpc: Client,\n\tinput: { sessionId: Session.SessionSchema.ID; text: string },\n\trender: (event: EventSchema.Payload) => Effect.Effect<void, E, R>,\n) {\n\tconst id = Session.SessionMessageSchema.ID.create();\n\tlet admitted = false;\n\tlet promoted = false;\n\tlet settled = false;\n\tlet unattributed: ExecutionError | undefined;\n\t// Raised once a busy period ends without our prompt in it: the session may be\n\t// about to go idle, and only idleness proves our prompt is never running.\n\tconst stalled = yield* Deferred.make<void>();\n\n\tconst terminal = (event: EventSchema.Payload): ExecutionError | undefined => {\n\t\tif (Schema.is(EventList.ExecutionInterrupted)(event))\n\t\t\treturn new ExecutionError({\n\t\t\t\ttype: \"aborted\",\n\t\t\t\tmessage: event.data.reason === \"shutdown\" ? \"Server stopped the session\" : \"Session interrupted\",\n\t\t\t});\n\t\tif (Schema.is(EventList.ExecutionFailed)(event))\n\t\t\treturn new ExecutionError({\n\t\t\t\ttype: event.data.error.type,\n\t\t\t\tmessage: event.data.error.message,\n\t\t\t\t...(event.data.error.status === undefined ? {} : { status: event.data.error.status }),\n\t\t\t});\n\t\treturn undefined;\n\t};\n\n\tconst consume = rpc[\"event.subscribe\"]({}).pipe(\n\t\tStream.mapEffect(\n\t\t\tEffect.fnUntraced(function* (envelope) {\n\t\t\t\tif (envelope.type === Envelope.Connected.type) {\n\t\t\t\t\tyield* rpc[\"session.prompt\"]({ ...input, id, delivery: \"followUp\" });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst event = yield* Envelope.decode(envelope).pipe(\n\t\t\t\t\tEffect.catchTag(\"UnknownEventTypeError\", () => Effect.void),\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tevent === undefined ||\n\t\t\t\t\t!Predicate.hasProperty(event.data, \"sessionId\") ||\n\t\t\t\t\tevent.data.sessionId !== input.sessionId\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tif (Schema.is(EventList.PromptAdmitted)(event) && event.data.messageId === id) admitted = true;\n\t\t\t\tif (Schema.is(EventList.Prompted)(event) && event.data.messageId === id) {\n\t\t\t\t\tpromoted = true;\n\t\t\t\t\t// Our prompt is running after all; whatever ended before it was not ours.\n\t\t\t\t\tunattributed = undefined;\n\t\t\t\t}\n\t\t\t\tif (!admitted) return;\n\n\t\t\t\tconst ended = terminal(event);\n\t\t\t\tconst succeeded = Schema.is(EventList.ExecutionSucceeded)(event);\n\t\t\t\tif (!promoted) {\n\t\t\t\t\tif (ended !== undefined) unattributed = ended;\n\t\t\t\t\t// A busy period that ended without us: wait for idle to find out\n\t\t\t\t\t// whether a successor still picks our prompt up.\n\t\t\t\t\tif (ended !== undefined || succeeded) yield* Deferred.succeed(stalled, undefined);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (ended !== undefined) return yield* ended;\n\t\t\t\tif (succeeded) {\n\t\t\t\t\tsettled = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield* render(event);\n\t\t\t}),\n\t\t),\n\t\tStream.takeUntil(() => settled),\n\t\tStream.runDrain,\n\t);\n\n\t// Idle is the cue to reconcile, not the verdict. `wait` follows successors, so\n\t// it resolves only once the session is quiet -- then the projection says\n\t// whether our prompt was ever part of it. A prompt that did run leaves its\n\t// terminal in flight on the same socket, so the consumer is left alone to\n\t// finish; only a prompt that never materialized ends the run early.\n\tlet abandoned = false;\n\tconst reconcile = Deferred.await(stalled).pipe(\n\t\tEffect.andThen(rpc[\"session.wait\"]({ sessionId: input.sessionId })),\n\t\tEffect.andThen(rpc[\"session.message\"]({ sessionId: input.sessionId, messageId: id })),\n\t\tEffect.andThen(({ found }) =>\n\t\t\tfound\n\t\t\t\t? Effect.never\n\t\t\t\t: Effect.sync(() => {\n\t\t\t\t\t\tabandoned = true;\n\t\t\t\t\t}),\n\t\t),\n\t);\n\n\tyield* Effect.raceFirst(consume, reconcile);\n\tif (settled) return;\n\tif (abandoned)\n\t\treturn yield* unattributed ?? new ExecutionError({ type: \"unknown\", message: \"Prompt was not promoted\" });\n\treturn yield* new ExecutionError({\n\t\ttype: \"transport.disconnected\",\n\t\tmessage: \"Event stream ended before the prompt finished; its output was not rendered\",\n\t});\n});\n\nexport * as Client from \"./client.ts\";\n","import type { Message } from \"@codeworksh/aikit\";\nimport { Effect } from \"effect\";\n\nexport interface UsageSummary {\n\treadonly turns: number;\n\treadonly provider?: string;\n\treadonly model?: string;\n\treadonly input: number;\n\treadonly output: number;\n\treadonly reasoning: number;\n\treadonly cacheRead: number;\n\treadonly cacheWrite: number;\n\treadonly totalTokens: number;\n\treadonly cost: number;\n}\n\nexport const emptyUsage: UsageSummary = {\n\tturns: 0,\n\tinput: 0,\n\toutput: 0,\n\treasoning: 0,\n\tcacheRead: 0,\n\tcacheWrite: 0,\n\ttotalTokens: 0,\n\tcost: 0,\n};\n\nexport const addUsage = (summary: UsageSummary, message: Message.AssistantMessage): UsageSummary => ({\n\tturns: summary.turns + 1,\n\tprovider: message.provider.id,\n\tmodel: message.responseModel ?? message.model,\n\tinput: summary.input + message.usage.input,\n\toutput: summary.output + message.usage.output,\n\treasoning: summary.reasoning + (message.usage.reasoning ?? 0),\n\tcacheRead: summary.cacheRead + message.usage.cacheRead,\n\tcacheWrite: summary.cacheWrite + message.usage.cacheWrite,\n\ttotalTokens: summary.totalTokens + message.usage.totalTokens,\n\tcost: summary.cost + message.usage.cost.total,\n});\n\nconst number = new Intl.NumberFormat(\"en-US\");\nconst row = (label: string, value: string) => `${label.padEnd(9)}${value}\\n`;\n\nconst formatCost = (cost: number): string => `$${cost.toFixed(cost > 0 && cost < 0.01 ? 6 : 4)}`;\n\nexport const divider = (label: string, columns = 72): string => {\n\tconst width = Math.min(100, Math.max(32, columns));\n\tconst start = `── ${label} `;\n\treturn `${start}${\"─\".repeat(Math.max(2, width - start.length))}\\n`;\n};\n\nexport const header = (input: {\n\treadonly sessionId: string;\n\treadonly sandbox: string;\n\treadonly directory: string;\n\treadonly columns?: number;\n}): string =>\n\t`${row(\"session\", input.sessionId)}${row(\"sandbox\", `${input.sandbox} · ${input.directory}`)}\\n${divider(\n\t\t\"response\",\n\t\tinput.columns,\n\t)}`;\n\nexport const usage = (summary: UsageSummary, columns?: number): string => {\n\tconst turns = `${summary.turns} ${summary.turns === 1 ? \"turn\" : \"turns\"}`;\n\tconst model =\n\t\tsummary.provider === undefined || summary.model === undefined\n\t\t\t? \"unknown\"\n\t\t\t: `${summary.provider}/${summary.model}`;\n\tconst reasoning = summary.reasoning === 0 ? \"\" : ` · ${number.format(summary.reasoning)} reasoning`;\n\treturn `${divider(\"usage\", columns)}${row(\"model\", model)}${row(\n\t\t\"tokens\",\n\t\t`${number.format(summary.input)} input · ${number.format(summary.output)} output${reasoning} · ${number.format(\n\t\t\tsummary.totalTokens,\n\t\t)} total`,\n\t)}${row(\"cache\", `${number.format(summary.cacheRead)} read · ${number.format(summary.cacheWrite)} write`)}${row(\n\t\t\"cost\",\n\t\t`${formatCost(summary.cost)} · ${turns}`,\n\t)}`;\n};\n\nexport const writeOut = (value: string) => Effect.sync(() => void process.stdout.write(value));\nexport const writeError = (value: string) => Effect.sync(() => void process.stderr.write(value));\nexport const terminalColumns = () => (process.stderr.isTTY ? (process.stderr.columns ?? 72) : 72);\n","import { ModelCatalog, Plugin, Runner, SandboxError, SessionStore, Settings } from \"@codeworksh/harness/effect\";\nimport { SandboxProvider } from \"@codeworksh/harness/sandbox\";\nimport { Duration, Effect, Schema } from \"effect\";\nimport { Client } from \"../server/client.ts\";\nimport { writeError } from \"./output.ts\";\n\n/** Bad flag or argument combinations the parser cannot express on its own. */\nexport class InvalidInputError extends Schema.TaggedError<InvalidInputError>()(\"CLI.InvalidInputError\", {\n\tmessage: Schema.String,\n}) {}\n\nexport class OAuthError extends Schema.TaggedError<OAuthError>()(\"CLI.OAuthError\", {\n\tmessage: Schema.String,\n\tcause: Schema.optional(Schema.Defect()),\n}) {}\n\n/**\n * Every failure a command handler may surface to the runtime. Harness failures are\n * rendered inside the handler that owns them, so only the CLI's own errors reach\n * the top-level renderer.\n */\nexport type CommandError = InvalidInputError | OAuthError;\n\nconst isInvalidInputError = Schema.is(InvalidInputError);\nconst isOAuthError = Schema.is(OAuthError);\nconst isProviderError = Schema.is(Runner.ProviderError);\nconst isModelCatalogError = Schema.is(Runner.ModelCatalogError);\nconst isModelCatalogRefreshError = Schema.is(ModelCatalog.RefreshError);\nconst isModelNotFoundError = Schema.is(Runner.ModelNotFoundError);\nconst isLLMStreamError = Schema.is(Runner.LLMStreamError);\nconst isSandboxProviderError = Schema.is(SandboxProvider.SandboxProviderError);\nconst isPluginInstallError = Schema.is(Plugin.InstallError);\nconst isPluginSourceError = Schema.is(Plugin.SourceError);\nconst isPluginStoreError = Schema.is(Plugin.StoreError);\nconst isPluginLoadError = Schema.is(Plugin.LoadError);\nconst isSessionNotLinkedError = Schema.is(SessionStore.SessionNotLinkedError);\nconst isSettingsError = Schema.is(Settings.SettingsError);\nconst isSandboxDriverNotRegisteredError = Schema.is(SandboxError.SandboxDriverNotRegisteredError);\nconst isSandboxDriverRegistrationError = Schema.is(SandboxError.SandboxDriverRegistrationError);\nconst isExecutionError = Schema.is(Client.ExecutionError);\n\nconst credentialHint = (provider: string): string => {\n\tswitch (provider) {\n\t\tcase \"openrouter\":\n\t\t\treturn \"set OPENROUTER_API_KEY and retry\";\n\t\tcase \"openai\":\n\t\t\treturn \"set OPENAI_API_KEY and retry\";\n\t\tcase \"openai-codex\":\n\t\t\treturn \"run `codework auth login --openai-codex` and retry\";\n\t\tcase \"github-copilot\":\n\t\t\treturn \"run `codework auth login --github-copilot` and retry\";\n\t\tcase \"anthropic\":\n\t\t\treturn \"set ANTHROPIC_API_KEY and retry\";\n\t\tcase \"google\":\n\t\t\treturn \"set GOOGLE_GENERATIVE_AI_API_KEY and retry\";\n\t\tcase \"xai\":\n\t\t\treturn \"set XAI_API_KEY and retry\";\n\t\tdefault:\n\t\t\treturn `configure credentials for provider \"${provider}\" and retry`;\n\t}\n};\n\nconst providerHint = (error: Runner.ProviderError): string | undefined => {\n\tswitch (error.reason._tag) {\n\t\tcase \"Runner.ProviderAuthenticationError\":\n\t\t\treturn error.reason.authentication === \"missing\"\n\t\t\t\t? credentialHint(error.provider)\n\t\t\t\t: `check the credentials configured for provider \"${error.provider}\"`;\n\t\tcase \"Runner.ProviderAuthorizationError\":\n\t\t\treturn \"check that the credential can access this model and endpoint\";\n\t\tcase \"Runner.ProviderModelUnavailableError\":\n\t\t\treturn \"check the provider model ID and whether your account can access it\";\n\t\tcase \"Runner.ProviderRateLimitError\":\n\t\t\treturn error.reason.retryAfter === undefined\n\t\t\t\t? \"retry after the provider rate-limit window resets\"\n\t\t\t\t: `retry in about ${Math.ceil(Duration.toMillis(error.reason.retryAfter) / 1_000)} seconds`;\n\t\tcase \"Runner.ProviderQuotaError\":\n\t\t\treturn \"check the provider account quota or billing balance\";\n\t\tcase \"Runner.ProviderTimeoutError\":\n\t\tcase \"Runner.ProviderTransportError\":\n\t\tcase \"Runner.ProviderUnavailableError\":\n\t\t\treturn error.isRetryable ? \"this failure is retryable\" : undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n};\n\nconst unknownMessage = (error: unknown): string => {\n\tif (error instanceof Error && error.message.trim().length > 0) return error.message;\n\tif (typeof error === \"string\" && error.trim().length > 0) return error;\n\tif (typeof error === \"object\" && error !== null && \"_tag\" in error) {\n\t\t// A bare tag such as `ServeError` hides the reason; its cause carries it (`EADDRINUSE`).\n\t\tconst cause = \"cause\" in error ? error.cause : undefined;\n\t\treturn cause instanceof Error ? `${String(error._tag)}: ${cause.message}` : String(error._tag);\n\t}\n\treturn \"the command failed for an unknown reason\";\n};\n\n/**\n * What the reader can do about a reference that failed to prepare. A plugin list is\n * usually hand-written in a settings file, so the phase is worth translating.\n */\n/** One hint per reason. Lowercase, like everything else a plugin failure prints. */\nconst providerCategory = (reason: Runner.ProviderFailureReason): string => {\n\tswitch (reason._tag) {\n\t\tcase \"Runner.ProviderAuthenticationError\":\n\t\t\treturn \"provider-authentication-error\";\n\t\tcase \"Runner.ProviderConfigurationError\":\n\t\t\treturn \"provider-configuration-error\";\n\t\tcase \"Runner.ProviderAuthorizationError\":\n\t\t\treturn \"provider-authorization-error\";\n\t\tcase \"Runner.ProviderModelUnavailableError\":\n\t\t\treturn \"provider-model-unavailable-error\";\n\t\tcase \"Runner.ProviderRateLimitError\":\n\t\t\treturn \"provider-rate-limit-error\";\n\t\tcase \"Runner.ProviderQuotaError\":\n\t\t\treturn \"provider-quota-error\";\n\t\tcase \"Runner.ProviderInvalidRequestError\":\n\t\t\treturn \"provider-invalid-request-error\";\n\t\tcase \"Runner.ProviderContentPolicyError\":\n\t\t\treturn \"provider-content-filter-error\";\n\t\tcase \"Runner.ProviderTimeoutError\":\n\t\t\treturn \"provider-timeout-error\";\n\t\tcase \"Runner.ProviderTransportError\":\n\t\t\treturn \"provider-transport-error\";\n\t\tcase \"Runner.ProviderUnavailableError\":\n\t\t\treturn \"provider-unavailable-error\";\n\t\tcase \"Runner.ProviderInvalidResponseError\":\n\t\t\treturn \"provider-invalid-response-error\";\n\t\tcase \"Runner.ProviderUnknownError\":\n\t\t\treturn \"provider-unknown-error\";\n\t}\n};\n\nconst pluginReasonHint = (\n\treason:\n\t\t| Plugin.SourceError[\"reason\"]\n\t\t| Plugin.InstallError[\"reason\"]\n\t\t| Plugin.StoreError[\"reason\"]\n\t\t| Plugin.LoadError[\"reason\"],\n): string => {\n\tswitch (reason) {\n\t\tcase \"plugin-unsupported-source\":\n\t\t\treturn \"a path entry starts with `./`, `../`, `~/` or `/`; anything else is a package or a git spec, and a remote tarball is not supported\";\n\t\tcase \"plugin-not-found\":\n\t\t\treturn \"the path does not exist; check the spelling, remembering it anchors to the settings file that declares it\";\n\t\tcase \"plugin-escapes-root\":\n\t\t\treturn \"a plugin path must stay inside the project it is declared in\";\n\t\tcase \"plugin-resolve-failed\":\n\t\t\treturn \"check that the registry or git remote is reachable, and that your credentials are current\";\n\t\tcase \"plugin-fetch-failed\":\n\t\t\treturn \"check the package name and version, and that the registry is reachable\";\n\t\tcase \"plugin-no-commit\":\n\t\t\treturn \"the git source installed but no commit could be recovered; name a branch, tag or commit explicitly\";\n\t\tcase \"plugin-no-entrypoint\":\n\t\t\treturn \"the package installed but exports no module to import; check its `exports` and `main`\";\n\t\tcase \"plugin-not-installed\":\n\t\t\treturn \"run `codework plugin install` to fetch what the settings files name\";\n\t\tcase \"plugin-lock-timeout\":\n\t\t\treturn \"another install is holding this entry; wait for it to finish, or remove the stale `.lock` directory\";\n\t\tcase \"plugin-marker-invalid\":\n\t\tcase \"plugin-index-invalid\":\n\t\t\treturn \"the store entry is damaged; remove it and install again\";\n\t\tcase \"plugin-collect-failed\":\n\t\t\treturn \"the store could not be tidied; check the permissions on the plugin cache\";\n\t\tcase \"plugin-import-failed\":\n\t\t\treturn \"the module failed to load; import it directly to see its own error\";\n\t\tcase \"plugin-missing-dependency\":\n\t\t\treturn \"the plugin's own dependencies are missing; install them where the plugin lives\";\n\t\tcase \"plugin-not-compiled\":\n\t\t\treturn \"a plugin installed from git or npm must ship compiled javascript; build it and commit or publish the output\";\n\t\tcase \"plugin-invalid-definition\":\n\t\t\treturn \"a plugin module must default-export one object with a `setup` and a `vendor.domain.name` id\";\n\t}\n};\n\nconst settingsHint = (reason: Settings.SettingsError[\"reason\"]): string => {\n\tswitch (reason) {\n\t\tcase \"read\":\n\t\t\treturn \"the file exists but could not be read; check that it is a file and readable\";\n\t\tcase \"parse\":\n\t\t\treturn \"the file is not valid JSON; the location above is where parsing stopped\";\n\t\tcase \"decode\":\n\t\t\treturn \"the key above holds a value this setting does not accept\";\n\t}\n};\n\n/** Render typed SDK errors for humans without exposing Effect causes or provider payloads. */\nexport const renderError = (error: unknown): string => {\n\tif (isSandboxDriverNotRegisteredError(error)) {\n\t\treturn `error: sandbox driver \"${error.driver}\" is not registered (available: ${error.registered?.join(\", \") ?? \"none\"})\\n`;\n\t}\n\tif (isSandboxDriverRegistrationError(error)) {\n\t\treturn `error: ${error.reason}\\n`;\n\t}\n\tif (isInvalidInputError(error)) {\n\t\treturn `error: ${error.message}\\n`;\n\t}\n\tif (isOAuthError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[oauth-credential-error]: ${error.message}`,\n\t\t\t\t...(error.cause === undefined ? [] : [`detail: ${unknownMessage(error.cause)}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isSandboxProviderError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error: SandboxProviderError - ${error.sanitized.message}`,\n\t\t\t\t`driver: ${error.driver}`,\n\t\t\t\t`operation: ${error.operation}`,\n\t\t\t\t...(error.sanitized.code === undefined ? [] : [`code: ${error.sanitized.code}`]),\n\t\t\t\t...(error.stack === undefined ? [] : [\"traceback:\", error.stack]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isSessionNotLinkedError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${error.reason}]: ${error.message}`,\n\t\t\t\t`session: ${error.sessionId}`,\n\t\t\t\t\"hint: run `codework session link <session-id>` from the directory to anchor it to\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isSettingsError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[settings-${error.reason}-failed]: ${error.path}`,\n\t\t\t\t`detail: ${error.detail}`,\n\t\t\t\t`hint: ${settingsHint(error.reason)}`,\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\t// One shape for all three plugin domains: the reason is the slug, the message is the sentence,\n\t// and the reference is the string the person recognises from their settings file.\n\tif (\n\t\tisPluginSourceError(error) ||\n\t\tisPluginInstallError(error) ||\n\t\tisPluginStoreError(error) ||\n\t\tisPluginLoadError(error)\n\t) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${error.reason}]: ${error.message}`,\n\t\t\t\t...(error.reference === \"\" ? [] : [`reference: ${error.reference}`]),\n\t\t\t\t...(error.file === undefined ? [] : [`declared in: ${error.file}`]),\n\t\t\t\t...(isPluginLoadError(error) && error.id !== undefined ? [`id: ${error.id}`] : []),\n\t\t\t\t`hint: ${pluginReasonHint(error.reason)}`,\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isProviderError(error)) {\n\t\tconst hint = providerHint(error);\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${providerCategory(error.reason)}]: ${error.message}`,\n\t\t\t\t`provider: ${error.provider}`,\n\t\t\t\t`model: ${error.model}`,\n\t\t\t\t...(error.reason.requestId === undefined ? [] : [`request: ${error.reason.requestId}`]),\n\t\t\t\t...(hint === undefined ? [] : [`hint: ${hint}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isModelCatalogError(error)) {\n\t\treturn (\n\t\t\t[`error[model-catalog-${error.reason}]: ${error.message}`, \"hint: run `codework models refresh`\"].join(\"\\n\") +\n\t\t\t\"\\n\"\n\t\t);\n\t}\n\tif (isModelCatalogRefreshError(error)) {\n\t\treturn (\n\t\t\t[`error[catalog-refresh-failed]: ${error.message}`, \"hint: check the network connection and retry\"].join(\n\t\t\t\t\"\\n\",\n\t\t\t) + \"\\n\"\n\t\t);\n\t}\n\tif (isModelNotFoundError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[model-not-found-error]: ${error.message}`,\n\t\t\t\t\"hint: check the provider/model IDs in models.gen.json or regenerate the catalog\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isLLMStreamError(error)) {\n\t\treturn `error[llm-stream-error]: ${error.message}\\n`;\n\t}\n\t// A remote run has only the category the server published; render it the same\n\t// way a local typed error is rendered, minus the detail that stayed server-side.\n\tif (isExecutionError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\terror.type === \"aborted\" ? `error: ${error.message}` : `error[${error.type}]: ${error.message}`,\n\t\t\t\t...(error.status === undefined ? [] : [`status: ${error.status}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\treturn `error: ${unknownMessage(error)}\\n`;\n};\n\nexport const reportFailure = (error: unknown) =>\n\twriteError(renderError(error)).pipe(\n\t\tEffect.andThen(\n\t\t\tEffect.sync(() => {\n\t\t\t\tprocess.exitCode = 1;\n\t\t\t}),\n\t\t),\n\t);\n"],"mappings":";;;;;;;;;;;;;AASA,MAAa,gBAAgB,OAAO,OAAO;CAC1C,IAAI,YAAY;CAChB,MAAM,OAAO;CACb,SAAS,SAAS,OAAO,OAAO;EAAE,aAAa,OAAO;EAAQ,KAAK,OAAO;EAAK,SAAS,OAAO;CAAI,CAAC,CAAC;CACrG,UAAU,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;CAC9D,MAAM,OAAO;AACd,CAAC;AAGD,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CAAC,yBAAyB,EAC/G,MAAM,OAAO,OACd,CAAC,CAAC,CAAC,CAAC;;AAGJ,MAAa,YAAY,YAAY,OAAO;CAAE,MAAM;CAAoB,QAAQ,CAAC;AAAE,CAAC;;;;;;;AAWpF,MAAM,OAAO,YAAY,OAAO,CAAC,GAAG,UAAU,mBAAmB,SAAS,CAAC;AAC3E,MAAa,QAAkB,SAAS,KAAK,IAAI,IAAI;AAErD,IAAa,gBAAb,cAAmC,OAAO,YAA2B,CAAC,CAAC,sBAAsB;CAC5F,MAAM,OAAO;CACb,OAAO,OA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AGF,IAAI,2BAA2B,KAAK,GACnC,OACC,CAAC,kCAAkC,MAAM,WAAW,8CAA8C,CAAC,CAAC,KACnG,IACD,IAAI;CAGN,IAAI,qBAAqB,KAAK,GAC7B,OACC,CACC,iCAAiC,MAAM,WACvC,iFACD,CAAC,CAAC,KAAK,IAAI,IAAI;CAGjB,IAAI,iBAAiB,KAAK,GACzB,OAAO,4BAA4B,MAAM,QAAQ;CAIlD,IAAI,iBAAiB,KAAK,GACzB,OACC,CACC,MAAM,SAAS,YAAY,UAAU,MAAM,YAAY,SAAS,MAAM,KAAK,KAAK,MAAM,WACtF,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,WAAW,MAAM,QAAQ,CACjE,CAAC,CAAC,KAAK,IAAI,IAAI;CAGjB,OAAO,UAAU,eAAe,KAAK,EAAE;AACxC;AAEA,MAAa,iBAAiB,UAC7B,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,KAC9B,OAAO,QACN,OAAO,WAAW;CACjB,QAAQ,WAAW;AACpB,CAAC,CACF,CACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-CPZXeEhq.mjs";
|
|
2
2
|
import { Context, Effect, FileSystem, Layer, Option, Path, Schedule, Schema } from "effect";
|
|
3
3
|
import { isSea } from "node:sea";
|
|
4
4
|
//#region src/server/registration.ts
|
|
@@ -89,4 +89,4 @@ const layer = Layer.succeed(Service, Service.of(current));
|
|
|
89
89
|
//#endregion
|
|
90
90
|
export { file as a, register as c, command as i, current as n, infoJson as o, layer as r, log as s, Service as t };
|
|
91
91
|
|
|
92
|
-
//# sourceMappingURL=identity-
|
|
92
|
+
//# sourceMappingURL=identity-w6kME98x.mjs.map
|