@codeworksh/cli 0.8.0-canary.136.1.gd49b43a0 → 0.8.0-canary.138.1.gd46f92cb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/{acp-52MbcwkL.mjs → acp-CJsNVIrq.mjs} +3 -3
  2. package/acp-CJsNVIrq.mjs.map +1 -0
  3. package/{add-2JwsoW7_.mjs → add-BmROWuHU.mjs} +3 -3
  4. package/add-BmROWuHU.mjs.map +1 -0
  5. package/{add-X6KvkHMs.mjs → add-m4j4pRf0.mjs} +4 -4
  6. package/add-m4j4pRf0.mjs.map +1 -0
  7. package/{check-Dfa50wOY.mjs → check-BdN8vvHQ.mjs} +3 -3
  8. package/check-BdN8vvHQ.mjs.map +1 -0
  9. package/{control-BccZ281F.mjs → control-FinHtYLF.mjs} +4 -4
  10. package/control-FinHtYLF.mjs.map +1 -0
  11. package/disconnect-Bh-Mg7Ew.mjs +2 -0
  12. package/{entries-mPkFRA-f.mjs → entries-BZA9G7f0.mjs} +3 -3
  13. package/{entries-mPkFRA-f.mjs.map → entries-BZA9G7f0.mjs.map} +1 -1
  14. package/{error-BE7K70v8.mjs → error-BU5WVAb2.mjs} +70 -2
  15. package/error-BU5WVAb2.mjs.map +1 -0
  16. package/{fork-DVLAR2qg.mjs → fork-CCS7whub.mjs} +3 -3
  17. package/fork-CCS7whub.mjs.map +1 -0
  18. package/{identity-CKBJiD_d.mjs → identity-BVTCyU5i.mjs} +2 -2
  19. package/identity-BVTCyU5i.mjs.map +1 -0
  20. package/index.mjs +33 -33
  21. package/index.mjs.map +1 -1
  22. package/{install-C4W8hfls.mjs → install-DCUZDpRI.mjs} +3 -3
  23. package/install-DCUZDpRI.mjs.map +1 -0
  24. package/jsonc-B3ackf25.mjs +33 -0
  25. package/jsonc-B3ackf25.mjs.map +1 -0
  26. package/{link-qVwvZmA1.mjs → link-DWil9fU6.mjs} +2 -2
  27. package/link-DWil9fU6.mjs.map +1 -0
  28. package/{list-D23TXjlY.mjs → list-BaFwSDO0.mjs} +3 -3
  29. package/list-BaFwSDO0.mjs.map +1 -0
  30. package/{list-Bt3ouolZ.mjs → list-CovP7nPq.mjs} +3 -3
  31. package/list-CovP7nPq.mjs.map +1 -0
  32. package/{list-Bf1hEU8J.mjs → list-DDLes-GH.mjs} +2 -2
  33. package/list-DDLes-GH.mjs.map +1 -0
  34. package/{list-DqgxOo7n.mjs → list-VEqzQJSN.mjs} +2 -2
  35. package/list-VEqzQJSN.mjs.map +1 -0
  36. package/{login-DcgEg12S.mjs → login-BiAt5Rbc.mjs} +3 -3
  37. package/login-BiAt5Rbc.mjs.map +1 -0
  38. package/{login-CMAlTjiK.mjs → login-QHk3zh53.mjs} +3 -3
  39. package/login-QHk3zh53.mjs.map +1 -0
  40. package/{logout-CeAGmiSn.mjs → logout-BfUtvU2r.mjs} +3 -3
  41. package/logout-BfUtvU2r.mjs.map +1 -0
  42. package/{logout-D1xI2NRN.mjs → logout-DjEv31ne.mjs} +3 -3
  43. package/logout-DjEv31ne.mjs.map +1 -0
  44. package/package-lN9W6TGr.mjs +6 -0
  45. package/package-lN9W6TGr.mjs.map +1 -0
  46. package/package.json +3 -3
  47. package/{providers-DBFqwwTv.mjs → providers-Bq4r0L3-.mjs} +2 -2
  48. package/providers-Bq4r0L3-.mjs.map +1 -0
  49. package/reconnect-meCirFLz.mjs +2 -0
  50. package/{refresh-DUdUMbFI.mjs → refresh-BcEZbN1M.mjs} +3 -3
  51. package/refresh-BcEZbN1M.mjs.map +1 -0
  52. package/{refresh-CGcQq37V.mjs → refresh-GCPWtEyM.mjs} +2 -2
  53. package/refresh-GCPWtEyM.mjs.map +1 -0
  54. package/{relink-BodbEN6d.mjs → relink-DZMBrGYH.mjs} +3 -3
  55. package/relink-DZMBrGYH.mjs.map +1 -0
  56. package/{reload-D6-UfcG1.mjs → reload-DRItkMBi.mjs} +2 -2
  57. package/reload-DRItkMBi.mjs.map +1 -0
  58. package/{remove-ZdjqQX9i.mjs → remove-BCGe4voQ.mjs} +4 -4
  59. package/remove-BCGe4voQ.mjs.map +1 -0
  60. package/{remove-D3bNv2QX.mjs → remove-BzxXS7R4.mjs} +3 -3
  61. package/remove-BzxXS7R4.mjs.map +1 -0
  62. package/{restart-CKf3ePDj.mjs → restart-CaSIi-QA.mjs} +3 -3
  63. package/restart-CaSIi-QA.mjs.map +1 -0
  64. package/{run-fXg0o1k-.mjs → run-CEwzra2s.mjs} +3 -3
  65. package/run-CEwzra2s.mjs.map +1 -0
  66. package/runtime-CK2CunDw.mjs.map +1 -1
  67. package/{serve-DbdHtKcg.mjs → serve-Cgc_oGnQ.mjs} +62 -6
  68. package/serve-Cgc_oGnQ.mjs.map +1 -0
  69. package/{service-DEupCSxf.mjs → service-L5vWoPz6.mjs} +3 -3
  70. package/service-L5vWoPz6.mjs.map +1 -0
  71. package/{settings-Df1FiiC-.mjs → settings-D8gDoYEc.mjs} +3 -3
  72. package/settings-D8gDoYEc.mjs.map +1 -0
  73. package/{shared-DHhdjc3Z.mjs → shared-D07L1jA1.mjs} +2 -2
  74. package/shared-D07L1jA1.mjs.map +1 -0
  75. package/{shared-C8WKgxTL.mjs → shared-DkiZmtNa.mjs} +3 -3
  76. package/shared-DkiZmtNa.mjs.map +1 -0
  77. package/{start-JKcYzwQl.mjs → start-BefqfIKI.mjs} +3 -3
  78. package/start-BefqfIKI.mjs.map +1 -0
  79. package/{status-CVFY9ful.mjs → status-7eZ8SNj6.mjs} +3 -3
  80. package/status-7eZ8SNj6.mjs.map +1 -0
  81. package/{status-DBztqldO.mjs → status-CLq0c9qg.mjs} +3 -3
  82. package/status-CLq0c9qg.mjs.map +1 -0
  83. package/{stop-DhDXVZpr.mjs → stop-CJbSa7t1.mjs} +3 -3
  84. package/stop-CJbSa7t1.mjs.map +1 -0
  85. package/{thread-D1njx-PT.mjs → thread-DNi9NNai.mjs} +2 -2
  86. package/{thread-D1njx-PT.mjs.map → thread-DNi9NNai.mjs.map} +1 -1
  87. package/{update-B0UA9M3G.mjs → update-B0GsDRpJ.mjs} +3 -3
  88. package/update-B0GsDRpJ.mjs.map +1 -0
  89. package/acp-52MbcwkL.mjs.map +0 -1
  90. package/add-2JwsoW7_.mjs.map +0 -1
  91. package/add-X6KvkHMs.mjs.map +0 -1
  92. package/check-Dfa50wOY.mjs.map +0 -1
  93. package/control-BccZ281F.mjs.map +0 -1
  94. package/disconnect-CwIeFpti.mjs +0 -2
  95. package/error-BE7K70v8.mjs.map +0 -1
  96. package/fork-DVLAR2qg.mjs.map +0 -1
  97. package/identity-CKBJiD_d.mjs.map +0 -1
  98. package/install-C4W8hfls.mjs.map +0 -1
  99. package/jsonc-DxaGxpLV.mjs +0 -58
  100. package/jsonc-DxaGxpLV.mjs.map +0 -1
  101. package/link-qVwvZmA1.mjs.map +0 -1
  102. package/list-Bf1hEU8J.mjs.map +0 -1
  103. package/list-Bt3ouolZ.mjs.map +0 -1
  104. package/list-D23TXjlY.mjs.map +0 -1
  105. package/list-DqgxOo7n.mjs.map +0 -1
  106. package/login-CMAlTjiK.mjs.map +0 -1
  107. package/login-DcgEg12S.mjs.map +0 -1
  108. package/logout-CeAGmiSn.mjs.map +0 -1
  109. package/logout-D1xI2NRN.mjs.map +0 -1
  110. package/package-C_XwZ54u.mjs +0 -6
  111. package/package-C_XwZ54u.mjs.map +0 -1
  112. package/providers-DBFqwwTv.mjs.map +0 -1
  113. package/reconnect-Dcsvfdpt.mjs +0 -2
  114. package/refresh-CGcQq37V.mjs.map +0 -1
  115. package/refresh-DUdUMbFI.mjs.map +0 -1
  116. package/relink-BodbEN6d.mjs.map +0 -1
  117. package/reload-D6-UfcG1.mjs.map +0 -1
  118. package/remove-D3bNv2QX.mjs.map +0 -1
  119. package/remove-ZdjqQX9i.mjs.map +0 -1
  120. package/restart-CKf3ePDj.mjs.map +0 -1
  121. package/run-fXg0o1k-.mjs.map +0 -1
  122. package/serve-DbdHtKcg.mjs.map +0 -1
  123. package/service-DEupCSxf.mjs.map +0 -1
  124. package/settings-Df1FiiC-.mjs.map +0 -1
  125. package/shared-C8WKgxTL.mjs.map +0 -1
  126. package/shared-DHhdjc3Z.mjs.map +0 -1
  127. package/start-JKcYzwQl.mjs.map +0 -1
  128. package/status-CVFY9ful.mjs.map +0 -1
  129. package/status-DBztqldO.mjs.map +0 -1
  130. package/stop-DhDXVZpr.mjs.map +0 -1
  131. package/update-B0UA9M3G.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-BU5WVAb2.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, Predicate, 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\n/** Whether an event belongs to a thread: every thread-scoped event names its `threadId`. */\nexport const ofThread =\n\t(threadId: string) =>\n\t(event: { readonly data: unknown }): boolean =>\n\t\tPredicate.hasProperty(event.data, \"threadId\") && event.data.threadId === threadId;\n\nclass 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","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\nconst TextContent = Schema.Struct({ type: Schema.Literal(\"text\"), text: Schema.String });\nconst ImageContent = Schema.Struct({\n\ttype: Schema.Literal(\"image\"),\n\tdata: Schema.String,\n\tmimeType: Schema.String,\n});\nconst 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. */\nconst ToolStatus = Schema.Literals([\"pending\", \"running\", \"completed\", \"error\", \"skipped\", \"aborted\"]);\n\nconst ToolResult = Schema.Struct({\n\tcontent: Schema.Array(Schema.Union([TextContent, ImageContent])),\n\tisError: Schema.Boolean,\n});\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: 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","import { Model } from \"@codeworksh/aikit\";\nimport {\n\tControl,\n\tEvent,\n\tEventList,\n\tLocation,\n\tMcpError,\n\toptional,\n\tProject,\n\tPromptSchema,\n\tRunner,\n\tSandbox,\n\tSandboxError,\n\tSession,\n\tSessionStore,\n\tSettings,\n\tSettingsFile,\n\tThreadSchema,\n\tThreadStore,\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\n/** One logical codebase, whatever env it is checked out in. */\nconst ProjectInfo = Schema.Struct({\n\tid: Schema.String,\n\tname: Schema.String,\n\tstatus: Schema.Literals([\"active\", \"archived\"]),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\tupdatedAt: Schema.Finite,\n});\nexport type ProjectInfo = typeof ProjectInfo.Type;\n\n/** One directory of a project in one env; sessions attach to it. */\nconst SpaceInfo = Schema.Struct({\n\tid: Schema.String,\n\tprojectId: Schema.String,\n\tlocation: Session.AbsolutePath,\n\tkind: Schema.Literals([\"primary\", \"linked\", \"copy\", \"plain\"]),\n\t/** The sandbox it is in; absent for the host. */\n\tenv: optional(Schema.String),\n\tstatus: Schema.Literals([\"active\", \"archived\"]),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\tupdatedAt: Schema.Finite,\n});\nexport type SpaceInfo = typeof SpaceInfo.Type;\n\n/** The container: where its threads run by default, and which host project it reads. */\nexport const SessionInfo = Schema.Struct({\n\tid: Session.SessionSchema.ID,\n\tspaceId: Schema.String,\n\tslug: 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\ttag: optional(Schema.String),\n\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\t/** Last activity in any of its threads, epoch milliseconds. */\n\tupdatedAt: Schema.Finite,\n\t/** Where unaddressed prompts go. */\n\tmainThreadId: ThreadSchema.ID,\n});\nexport type SessionInfo = typeof SessionInfo.Type;\n\n/** `cut` is the committed seq of `entryId`: the inherited line ends there. */\nconst ThreadOrigin = Schema.Union([\n\tSchema.Struct({ kind: Schema.Literal(\"main\") }),\n\tSchema.Struct({ kind: Schema.Literal(\"fork\"), threadId: Schema.String, entryId: Schema.String, cut: Schema.Int }),\n\tSchema.Struct({\n\t\tkind: Schema.Literal(\"subagent\"),\n\t\tthreadId: Schema.String,\n\t\tcallId: Schema.String,\n\t\tentryId: optional(Schema.String),\n\t\t/** Present once `entryId` is committed. */\n\t\tcut: optional(Schema.Int),\n\t}),\n]);\n\n/** Billed usage of a thread's own entries; what it inherits through a fork point counts for its source. */\nconst ThreadUsage = Schema.Struct({\n\t/** Total cost in US dollars, from the catalog's prices. */\n\tcost: Schema.Finite,\n\tinput: Schema.Int,\n\toutput: Schema.Int,\n\tcacheRead: Schema.Int,\n\tcacheWrite: Schema.Int,\n});\nexport type ThreadUsage = typeof ThreadUsage.Type;\n\n/** The last run of a thread; `error` is set unless it succeeded or is still going. */\nconst ThreadRun = Schema.Struct({\n\t/** Epoch milliseconds. */\n\tstartedAt: Schema.Finite,\n\tendedAt: optional(Schema.Finite),\n\toutcome: optional(ThreadSchema.RunOutcome),\n\terror: optional(ThreadSchema.RunError),\n});\n\nconst ThreadFields = {\n\tid: ThreadSchema.ID,\n\torigin: ThreadOrigin,\n\t/** Absent until its first own prompt; clients show a fork's source title until then. */\n\ttitle: optional(Schema.String),\n\t/** Last activity, epoch milliseconds. */\n\tupdatedAt: Schema.Finite,\n\t/** The model chosen for this thread; absent when settings decide. */\n\tmodel: optional(Schema.Struct({ provider: Schema.String, id: Schema.String })),\n\t/** The thinking level chosen for this thread; absent when settings decide. */\n\tthinkingLevel: optional(Schema.Enum(Model.ThinkingLevelEnum)),\n\t/** The prompt foundation chosen for this thread; absent when prompt plugins render it. */\n\tfoundation: optional(Schema.String),\n\t/** Where it runs instead of the session's space and directory. */\n\tplacement: optional(Schema.Struct({ spaceId: Schema.String, directory: Session.AbsolutePath })),\n\tusage: ThreadUsage,\n\t/** Where its run is, as the harness stores it: live whenever the server is up. */\n\trunState: ThreadSchema.RunState,\n\t/** When `runState` last changed, epoch milliseconds; absent before the first run. */\n\trunStateAt: optional(Schema.Finite),\n\t/** Absent before the first run. */\n\tlastRun: optional(ThreadRun),\n\t/** Whether it holds queued prompts that wait for its next prompt instead of running by themselves. */\n\tparked: Schema.Boolean,\n\t/** Automatic restarts of the current run. */\n\trestarts: Schema.Int,\n\t/** The 1-based provider request in flight; absent when none is. */\n\tattempt: optional(Schema.Int),\n\t/** The seq of the session event that created it. */\n\tcreatedSeq: Schema.Int,\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n};\n\n/** One linear transcript of a session, with the session embedded. */\nexport const ThreadInfo = Schema.Struct({ ...ThreadFields, session: SessionInfo });\nexport type ThreadInfo = typeof ThreadInfo.Type;\n\n/** A thread as `index.sync` sends it: its session is a row of its own. */\nexport const ThreadSummary = Schema.Struct({ ...ThreadFields, sessionId: Session.SessionSchema.ID });\nexport type ThreadSummary = typeof ThreadSummary.Type;\n\n/** An `index.sync` item: a row with the revision that last wrote it, a deletion, or progress. */\nexport const IndexItem = Schema.Union([\n\tSchema.TaggedStruct(\"Project\", { project: ProjectInfo, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Space\", { space: SpaceInfo, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Session\", { session: SessionInfo, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Thread\", { thread: ThreadSummary, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Removed\", { kind: Schema.Literal(\"session\"), id: Schema.String, rev: Schema.Int }),\n\t/** Every row with a revision up to `rev` has been sent. */\n\tSchema.TaggedStruct(\"Synced\", { storeId: Schema.String, rev: Schema.Int }),\n]);\nexport type IndexItem = typeof IndexItem.Type;\n\n/** A thread of a session: `threadId`, or the session's `main` thread when absent. */\nconst ThreadRef = {\n\tsessionId: Session.SessionSchema.ID,\n\tthreadId: optional(ThreadSchema.ID),\n};\n\n/** A thread's MCP server, by the name its `mcp.json` gives it. */\nconst McpServerRef = { ...ThreadRef, server: Schema.String };\n\n/** One message in a thread's line (inherited ones first), oldest first. */\nexport const HistoryEntry = Schema.Struct({\n\t/** The entry id: what live events and `thread.message` refer to. */\n\tid: Schema.String,\n\t/** The thread that wrote it: this one, or a source it was forked from. */\n\tthreadId: 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\t/** Bytes of its parts as the harness stores them; `thread.sync`'s budget counts it. */\n\tsize: Schema.Int,\n\t/** Why a reply failed, as `provider/model: reason`; absent for one that ended normally or was stopped. */\n\terror: optional(Schema.String),\n});\nexport type HistoryEntry = typeof HistoryEntry.Type;\n\n/** A prompt admitted but not yet in the conversation: a steer waiting for the next model request, or a follow-up for the next turn. */\nexport const QueuedPrompt = Schema.Struct({\n\t/** The id of the user message it becomes once promoted. */\n\tid: Schema.String,\n\tdelivery: PromptSchema.Delivery,\n\ttext: Schema.String,\n\t/** The thread's sequence number at admission; orders the queue. */\n\tadmittedSeq: Schema.Int,\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n});\nexport type QueuedPrompt = typeof QueuedPrompt.Type;\n\n/** Text streamed into a reply's part since its last checkpoint; never stored. */\nexport const LiveDelta = Schema.Struct({\n\t/** The reply's entry id. */\n\tentryId: Schema.String,\n\tpartIndex: Schema.Int,\n\tkind: Schema.Literals([\"text\", \"thinking\"]),\n\t/** The part's text length before this delta: apply it only where the held text ends there. */\n\toffset: Schema.Int,\n\tdelta: Schema.String,\n});\nexport type LiveDelta = typeof LiveDelta.Type;\n\n/** A `thread.sync` item: a row with the revision that last wrote it, progress, or a live delta. */\nexport const ThreadItem = Schema.Union([\n\t/** Upsert by entry id. */\n\tSchema.TaggedStruct(\"Entry\", { entry: HistoryEntry, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Inbox\", {\n\t\tprompt: QueuedPrompt,\n\t\tstate: Schema.Literals([\"pending\", \"promoted\", \"cancelled\"]),\n\t\trev: Schema.Int,\n\t}),\n\t/** Every row with a revision up to `rev` has been sent; `floor`, on the first, is the oldest entry's seq. */\n\tSchema.TaggedStruct(\"Synced\", { storeId: Schema.String, rev: Schema.Int, floor: optional(Schema.Int) }),\n\tSchema.TaggedStruct(\"Delta\", { delta: LiveDelta }),\n]);\nexport type ThreadItem = typeof ThreadItem.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\n/** A thread's model, thinking and foundation choices: a given field replaces the stored one, `null` clears it. */\nexport const RuntimeConfig = Schema.Struct({\n\tmodel: optional(Schema.NullOr(Schema.Struct({ provider: Schema.String, id: Schema.String }))),\n\tthinkingLevel: optional(Schema.NullOr(Schema.Enum(Model.ThinkingLevelEnum))),\n\tfoundation: optional(Schema.NullOr(Schema.NonEmptyString)),\n});\nexport type RuntimeConfig = typeof RuntimeConfig.Type;\n\nconst SandboxRef = Sandbox.Selection;\n\n/** A model to choose, by the catalog's id and display name, with the thinking levels it supports. */\nconst 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. */\nconst 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. */\nconst 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\n/** A host folder operation that failed: unreadable, not a directory, taken, or git/gh refused. */\nexport class HostError extends Schema.TaggedError<HostError>()(\"Server.HostError\", {\n\tmessage: Schema.String,\n}) {}\n\n/** A directory on the host, by its name and absolute path. */\nexport const Folder = Schema.Struct({ name: Schema.String, path: Schema.String });\nexport type Folder = typeof Folder.Type;\n\n/** A GitHub repository as `gh` names it, with its web and SSH clone URLs. */\nexport const Repository = Schema.Struct({ nameWithOwner: Schema.String, url: Schema.String, sshUrl: Schema.String });\nexport type Repository = typeof Repository.Type;\n\nexport const CloneStage = Schema.Literals([\"connecting\", \"counting\", \"receiving\", \"resolving\", \"checkout\"]);\nexport type CloneStage = typeof CloneStage.Type;\n\nconst ClonePhase = Schema.Literals([\"running\", \"done\", \"failed\", \"cancelled\"]);\nexport type ClonePhase = typeof ClonePhase.Type;\n\n/** A tracked clone; `path` (the absolute destination) is its id. */\nexport const Clone = Schema.Struct({\n\tpath: Schema.String,\n\t/** Credentials and query stripped. */\n\tremote: Schema.String,\n\tphase: ClonePhase,\n\tstage: CloneStage,\n\t/** 0 to 100 within `stage`, when git prints one. */\n\tpercent: Schema.NullOr(Schema.Int),\n\t/** Git's transfer note, such as its speed; at most 200 characters. */\n\tdetail: Schema.NullOr(Schema.String),\n\t/** Git has printed no progress for 20 seconds. */\n\tstalled: Schema.Boolean,\n\t/** Why it failed; at most 1000 characters. */\n\terror: Schema.NullOr(Schema.String),\n\t/** Epoch milliseconds. */\n\tstartedAt: Schema.Finite,\n\tendedAt: Schema.NullOr(Schema.Finite),\n\t/** Bumped on every change across all clones; a higher one is newer. */\n\tsequence: Schema.Int,\n});\nexport type Clone = typeof Clone.Type;\n\nconst SessionErrors = Schema.Union([\n\tSessionStore.SessionNotFoundError,\n\tThreadStore.ThreadNotFoundError,\n\tSessionStore.SessionLinkedSpaceNotFoundError,\n\tSessionStore.RelinkError,\n]);\n\nconst ThreadErrors = Schema.Union([SessionStore.SessionNotFoundError, ThreadStore.ThreadNotFoundError]);\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\n/** One of a thread's MCP servers as that thread sees it. */\nconst McpStatus = Schema.Struct({\n\tserver: Schema.String,\n\tstate: EventList.McpState,\n\terror: optional(Schema.String),\n\t/** Tools the server offered when last listed, each with its exposure in the thread. */\n\ttools: Schema.Array(\n\t\tSchema.Struct({ name: Schema.String, exposure: Schema.Literals([\"direct\", \"codemode\", \"deferred\", \"hidden\"]) }),\n\t),\n\tresources: Schema.Boolean,\n\t/** Tools it listed last that were left out because the MCP SDK rejects them; absent when none were. */\n\tskipped: optional(EventList.McpSkipped),\n});\nexport type McpStatus = typeof McpStatus.Type;\n\nconst McpErrors = Schema.Union([ThreadErrors, McpError.UnknownServerError]);\n\nconst SettingsFileRef = { projectId: optional(Schema.String), file: Schema.Literals([\"settings\", \"mcp\"]) };\n/** The settings a project's `settings.jsonc` falls back to, as the page shows them. */\nconst Inherited = Schema.Struct({\n\tretry: Schema.Struct({ maxRetries: Schema.Int, baseDelayMs: Schema.Int, maxDelayMs: Schema.Int }),\n});\nconst SettingsFileErrors = Schema.Union([\n\tSettings.SettingsError,\n\tProject.ProjectNotFoundError,\n\tProject.ProjectCheckoutError,\n]);\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({\n\t\t\tpid: Schema.Int,\n\t\t\tversion: Schema.String,\n\t\t\t/** The harness store this server serves; a sync cursor is only valid against it. */\n\t\t\tstoreId: Schema.String,\n\t\t\t/** The store's head: the last revision taken. */\n\t\t\trev: Schema.Int,\n\t\t}),\n\t}),\n\t/**\n\t * The index of this machine: every project, space, session and thread whose revision is past\n\t * `after`, in revision order, then `Synced` at the head read when the call began; then the same\n\t * live after each commit. `after: 0` reads the whole index. A row written again moves to a later\n\t * revision and is sent again; the latest wins. A deleted session arrives as `Removed`.\n\t */\n\tRpc.make(\"index.sync\", {\n\t\tpayload: { after: Schema.Int },\n\t\tsuccess: IndexItem,\n\t\tstream: true,\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\t/** A session and its `main` thread; the main thread's info, with the session embedded. */\n\tRpc.make(\"session.create\", {\n\t\tpayload: {\n\t\t\t/** The main thread's title; absent = its first prompt names it. */\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: ThreadInfo,\n\t\t/** `HostError` when `hostDir` is a clone still running, failed or cancelled. */\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors, HostError]),\n\t}),\n\t/** The `origin` URL of a project's main checkout on the host, credentials taken out; null when there is none. */\n\tRpc.make(\"project.remote\", {\n\t\tpayload: { projectId: Schema.String },\n\t\tsuccess: Schema.Struct({ url: Schema.NullOr(Schema.String) }),\n\t\terror: Project.ProjectNotFoundError,\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 * A settings file as written: the project's when `projectId` is given -- the one sessions in its\n\t * main checkout read -- otherwise the user's. `version` is what `settings.write` is held to;\n\t * `error` is what the runtime would reject in the file as it stands.\n\t */\n\tRpc.make(\"settings.read\", {\n\t\tpayload: SettingsFileRef,\n\t\tsuccess: Schema.Struct({\n\t\t\tpath: Schema.String,\n\t\t\tsource: Schema.String,\n\t\t\texists: Schema.Boolean,\n\t\t\tversion: Schema.String,\n\t\t\t/** The file's JSONC as a value; absent when it does not parse. */\n\t\t\tvalue: optional(Schema.Unknown),\n\t\t\terror: optional(Schema.String),\n\t\t\t/**\n\t\t\t * For `settings.jsonc`: what applies where this file sets nothing -- the user's settings over the\n\t\t\t * defaults for a project's file, the defaults for the user's. Absent when a lower file is broken.\n\t\t\t */\n\t\t\tinherited: optional(Inherited),\n\t\t}),\n\t\terror: SettingsFileErrors,\n\t}),\n\t/** The whole file, written only when it is still at `version` and the runtime would accept it. */\n\tRpc.make(\"settings.write\", {\n\t\tpayload: { ...SettingsFileRef, source: Schema.String, version: Schema.String },\n\t\tsuccess: Schema.Struct({ version: Schema.String }),\n\t\terror: Schema.Union([SettingsFileErrors, SettingsFile.SettingsConflictError]),\n\t}),\n\t/**\n\t * One value at `at` set in place, keeping the rest of the file as written; no `value` removes it.\n\t * Refused when the result would not be accepted.\n\t */\n\tRpc.make(\"settings.set\", {\n\t\tpayload: {\n\t\t\t...SettingsFileRef,\n\t\t\tat: Schema.NonEmptyArray(Schema.Union([Schema.String, Schema.Int])),\n\t\t\tvalue: optional(Schema.Unknown),\n\t\t},\n\t\tsuccess: Schema.Struct({ version: Schema.String }),\n\t\terror: SettingsFileErrors,\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\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\t/**\n\t * Moves where the work happens. Without `threadId`, the session's default space and directory,\n\t * which every thread without its own placement follows; with it, that thread's placement only.\n\t * Answers with the addressed thread (`main` when absent): its `placement` and embedded session\n\t * show where it now runs.\n\t */\n\tRpc.make(\"session.relink\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: optional(ThreadSchema.ID),\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\tdirectory: optional(Schema.String),\n\t\t},\n\t\tsuccess: ThreadInfo,\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors]),\n\t}),\n\t/** Stops every thread, then removes the session with its log. `deleted` is false when it did not exist. */\n\tRpc.make(\"session.delete\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: Schema.Struct({ deleted: Schema.Boolean }),\n\t}),\n\t/** Interrupts every running thread of the session. */\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 * 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. Every thread of the session\n\t * writes this one log; events name their `threadId`.\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 * With `threadId`, only that thread's events; the marker still names the session's head. A fork's\n\t * own log starts at its `session.thread.forked`: what it inherits is in `thread.history`.\n\t */\n\tRpc.make(\"session.log\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: optional(ThreadSchema.ID),\n\t\t\tafter: optional(Schema.Int),\n\t\t\tfollow: optional(Schema.Boolean),\n\t\t},\n\t\tsuccess: Schema.Union([EventEnvelope, LogSynced]),\n\t\terror: Schema.Union([SessionStore.SessionNotFoundError, EncodingError]),\n\t\tstream: true,\n\t}),\n\t/** Threads newest first, each with its session embedded: of one session, or all. */\n\tRpc.make(\"thread.list\", {\n\t\tpayload: { sessionId: optional(Session.SessionSchema.ID) },\n\t\tsuccess: Schema.Array(ThreadInfo),\n\t}),\n\tRpc.make(\"thread.info\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: ThreadInfo,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * The conversation in a thread's line: user and assistant messages, inherited ones first, oldest\n\t * first. The harness's own entries (compactions, resets, notices) are left out.\n\t */\n\tRpc.make(\"thread.history\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Prompts admitted to the thread but not yet promoted, in admission order. Admission and\n\t * promotion are durable events, so a client following `session.log` rereads this whenever the\n\t * log moves.\n\t */\n\tRpc.make(\"thread.queue\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(QueuedPrompt) }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * One thread's detail. Without `after`, the newest entries of its line (inherited ones\n\t * included) within `budget` bytes (default 1 MiB) and its pending inbox, then `Synced` with\n\t * `floor`. With `after`, its own entries and inbox rows whose revision is past it, then\n\t * `Synced`. Then the same live after each commit, with the thread's text and thinking deltas\n\t * as `Delta` between.\n\t */\n\tRpc.make(\"thread.sync\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: ThreadSchema.ID,\n\t\t\tafter: optional(Schema.Int),\n\t\t\tbudget: optional(Schema.Int),\n\t\t},\n\t\tsuccess: ThreadItem,\n\t\terror: Schema.Union([ThreadErrors, Event.SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n\t/**\n\t * Older entries of a thread's line (inherited ones included), oldest first: the newest `limit`\n\t * whose `seq` is below `before`, cut to `budget` bytes (default 1 MiB). The newest is always sent.\n\t */\n\tRpc.make(\"thread.page\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: ThreadSchema.ID,\n\t\t\tbefore: Schema.Int,\n\t\t\tlimit: Schema.Int,\n\t\t\tbudget: optional(Schema.Int),\n\t\t},\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.configure\", {\n\t\tpayload: { ...ThreadRef, runtime: RuntimeConfig },\n\t\tsuccess: ThreadInfo,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * A new thread whose history continues from this one's line through `entryId`, which must be\n\t * committed. `before` stops at the entry's predecessor and returns its text to edit again.\n\t */\n\tRpc.make(\"thread.fork\", {\n\t\tpayload: { ...ThreadRef, entryId: Schema.String, mode: optional(Schema.Literals([\"at\", \"before\"])) },\n\t\tsuccess: Schema.Struct({ thread: ThreadInfo, text: optional(Schema.String) }),\n\t\terror: Schema.Union([ThreadErrors, ThreadStore.ForkError]),\n\t}),\n\tRpc.make(\"thread.prompt\", {\n\t\tpayload: {\n\t\t\t...ThreadRef,\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.Struct({ threadId: ThreadSchema.ID }),\n\t\terror: Schema.Union([ThreadErrors, Control.PromptConflictError]),\n\t}),\n\t/**\n\t * Withdraws a queued prompt before it joins the conversation. `cancelled` is false when it had\n\t * already been promoted (it then stays in the conversation) or no pending prompt has that id.\n\t */\n\tRpc.make(\"thread.cancel\", {\n\t\tpayload: { ...ThreadRef, messageId: Session.SessionMessageSchema.ID },\n\t\tsuccess: Schema.Struct({ cancelled: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Moves a queued prompt to the other lane or rewrites it, keeping its place in the queue.\n\t * `delivery: \"steer\"` also wakes the thread, so a prompt left waiting after a stop runs now.\n\t * `updated` is false when it had already been promoted or cancelled, or no pending prompt has that id.\n\t */\n\tRpc.make(\"thread.update\", {\n\t\tpayload: {\n\t\t\t...ThreadRef,\n\t\t\tmessageId: Session.SessionMessageSchema.ID,\n\t\t\tdelivery: optional(PromptSchema.Delivery),\n\t\t\ttext: optional(Schema.String),\n\t\t},\n\t\tsuccess: Schema.Struct({ updated: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.interrupt\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ interrupted: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Whether a prompt materialized into the thread's conversation. An admitted prompt that is still\n\t * queued has no entry yet, so this is the projection a client reconciles against when the\n\t * volatile stream left it unsure.\n\t */\n\tRpc.make(\"thread.message\", {\n\t\tpayload: { ...ThreadRef, messageId: Session.SessionMessageSchema.ID },\n\t\tsuccess: Schema.Struct({ found: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.wait\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Void,\n\t\terror: ThreadErrors,\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\t/**\n\t * Close the instance behind a thread's MCP server, or its attempt, and connect it afresh, for\n\t * every thread sharing it. Answers once that attempt finished, with the server's state then.\n\t */\n\tRpc.make(\"mcp.connect\", {\n\t\tpayload: McpServerRef,\n\t\tsuccess: McpStatus,\n\t\terror: McpErrors,\n\t}),\n\t/** Close it, for every thread sharing it, and keep it closed until `mcp.connect` or a config change. */\n\tRpc.make(\"mcp.disconnect\", {\n\t\tpayload: McpServerRef,\n\t\tsuccess: McpStatus,\n\t\terror: McpErrors,\n\t}),\n\t/** The OS home directory, and the folder `host.create` makes projects in. */\n\tRpc.make(\"host.info\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ home: Schema.String, projects: Schema.String }),\n\t}),\n\t/**\n\t * The directories in `path` (a leading `~` is the OS home), hidden ones included, symlinks and\n\t * files left out. One the server may not read lists as empty.\n\t */\n\tRpc.make(\"host.browse\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, entries: Schema.Array(Folder) }),\n\t\terror: HostError,\n\t}),\n\t/**\n\t * A new folder under `host.info`'s `projects`, named after `name`, with a git repository and a\n\t * README. A first commit git refused is not fatal: `commitError` says why it was skipped.\n\t */\n\tRpc.make(\"host.create\", {\n\t\tpayload: { name: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, commitError: optional(Schema.String) }),\n\t\terror: HostError,\n\t}),\n\t/** An existing folder as an absolute path; a missing one is created. */\n\tRpc.make(\"host.add\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String }),\n\t\terror: HostError,\n\t}),\n\t/**\n\t * Starts a background clone of `remote` into `path`, which must be missing or empty, and answers\n\t * at once with the destination and the redacted remote; `host.clones` follows it. Git never prompts.\n\t */\n\tRpc.make(\"host.clone\", {\n\t\tpayload: { remote: Schema.String, path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, remote: Schema.String }),\n\t\terror: HostError,\n\t}),\n\t/** Every tracked clone now, then the whole list again on each change. A finished one leaves 30 seconds after. */\n\tRpc.make(\"host.clones\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(Clone),\n\t\tstream: true,\n\t}),\n\t/** Stops a running clone and empties its folder; `applied` is false when it was not running. */\n\tRpc.make(\"host.cancel\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t}),\n\t/** Clones a failed or cancelled one again into its emptied folder; `applied` is false otherwise. */\n\tRpc.make(\"host.retry\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t\terror: HostError,\n\t}),\n\t/** Stops tracking a clone, stopping it and emptying its folder unless it finished. */\n\tRpc.make(\"host.discard\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Void,\n\t}),\n\t/** Whether `gh` is installed and signed in; `hint` says what to do when it is not. */\n\tRpc.make(\"github.status\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ ready: Schema.Boolean, hint: optional(Schema.String) }),\n\t}),\n\t/** A repository by `owner/name`, `host/owner/name`, its URL, or a bare name of the signed-in user's. */\n\tRpc.make(\"github.lookup\", {\n\t\tpayload: { repository: Schema.String },\n\t\tsuccess: Repository,\n\t\terror: HostError,\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\t/**\n\t * Every event the server publishes, live, after a `server.connected` frame. With `threadId`,\n\t * only the events naming that thread; the frame still comes first.\n\t */\n\tRpc.make(\"event.subscribe\", {\n\t\tpayload: { threadId: optional(ThreadSchema.ID) },\n\t\tsuccess: EventEnvelope,\n\t\terror: Schema.Union([Event.SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n);\n","import { EventList, type EventSchema, optional, Session } from \"@codeworksh/harness/effect\";\nimport { NodeSocket } from \"@effect/platform-node\";\nimport { Deferred, Effect, Layer, Schema, Stream } from \"effect\";\nimport { RpcClient, RpcSerialization } from \"effect/rpc\";\nimport * as Contract from \"./contract.ts\";\nimport * as 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 * Threads 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; threadId: Session.ThreadSchema.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\t// By log position, since notifications may arrive out of order: a run that started after our\n\t// admission is one our prompt woke, so its failure before promoting us is ours. A run already going\n\t// fails on its own, and parks our prompt behind it.\n\tlet admittedAt: number | undefined;\n\tconst starts: Array<number> = [];\n\t// Runs that ended before promoting us, failed ones with their error.\n\tconst ends: Array<{ readonly at: number; readonly error: ExecutionError | undefined }> = [];\n\tconst ours = () =>\n\t\tends.findLast(({ at, error }) => {\n\t\t\tconst start = Math.max(...starts.filter((seq) => seq < at));\n\t\t\treturn error !== undefined && admittedAt !== undefined && start > admittedAt;\n\t\t})?.error;\n\t// Raised once a run ends after our admission without our prompt in it: the session may be about to\n\t// go idle, and only idleness proves our prompt is never running.\n\tconst stalled = yield* Deferred.make<void>();\n\n\t/** How a run ended, as this client reports it; `undefined` for a success. */\n\tconst failure = (event: EventList.RunEnded): 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.RunFailed)(event))\n\t\t\treturn new ExecutionError({ type: `run.${event.data.reason}`, message: event.data.message });\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\"]({ threadId: input.threadId }).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[\"thread.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 (event === undefined) return;\n\t\t\t\tconst seq = event.durable?.seq;\n\t\t\t\tif (Schema.is(EventList.ExecutionStarted)(event) && seq !== undefined) starts.push(seq);\n\t\t\t\tif (Schema.is(EventList.PromptAdmitted)(event) && event.data.messageId === id) {\n\t\t\t\t\tadmitted = true;\n\t\t\t\t\tadmittedAt = seq;\n\t\t\t\t}\n\t\t\t\tif (Schema.is(EventList.Prompted)(event) && event.data.messageId === id) promoted = true;\n\n\t\t\t\tconst ended = EventList.isRunEnded(event);\n\t\t\t\tconst error = ended ? failure(event) : undefined;\n\t\t\t\tif (!promoted) {\n\t\t\t\t\t// Kept whatever arrives first: our admission comes from another fiber than the runs, so a\n\t\t\t\t\t// run's end may be notified before it.\n\t\t\t\t\tif (ended && seq !== undefined) ends.push({ at: seq, error });\n\t\t\t\t\tif (admitted && ends.some(({ at }) => admittedAt === undefined || at > admittedAt))\n\t\t\t\t\t\tyield* Deferred.succeed(stalled, undefined);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (error !== undefined) return yield* error;\n\t\t\t\tif (ended) {\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[\"thread.wait\"]({ sessionId: input.sessionId, threadId: input.threadId })),\n\t\tEffect.andThen(rpc[\"thread.message\"]({ sessionId: input.sessionId, threadId: input.threadId, 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) return yield* ours() ?? 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","import type { Message } from \"@codeworksh/aikit\";\nimport { Effect, Schema } 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\nconst 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));\n/** A value in its wire form, as indented JSON. */\nexport const writeJson = <A, I>(schema: Schema.Codec<A, I>, value: A) =>\n\tSchema.encodeEffect(schema)(value).pipe(\n\t\tEffect.orDie,\n\t\tEffect.flatMap((encoded) => writeOut(`${JSON.stringify(encoded, null, \"\\t\")}\\n`)),\n\t);\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 {\n\tDatabase,\n\tModelCatalog,\n\tPlugin,\n\tRunner,\n\tSandboxError,\n\tSessionStore,\n\tSettings,\n} from \"@codeworksh/harness/effect\";\nimport { SandboxProvider } from \"@codeworksh/harness/sandbox\";\nimport { Duration, Effect, Schema } from \"effect\";\nimport * as 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);\nconst isDatabaseOutdatedError = Schema.is(Database.OutdatedError);\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 \"write\":\n\t\t\treturn \"the file could not be written; check that its directory is writable\";\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 (isDatabaseOutdatedError(error)) {\n\t\treturn `error[database-outdated]: ${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;CAC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AA,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,6 +1,6 @@
1
1
  import { i as Cmd, t as handler } from "./runtime-CK2CunDw.mjs";
2
- import { d as writeJson, f as writeOut, i as reportFailure, m as make, p as layer, t as InvalidInputError, y as ThreadInfo } from "./error-BE7K70v8.mjs";
3
- import { t as threadFlag } from "./thread-D1njx-PT.mjs";
2
+ import { d as writeJson, f as writeOut, i as reportFailure, m as make, p as layer, t as InvalidInputError, y as ThreadInfo } from "./error-BU5WVAb2.mjs";
3
+ import { t as threadFlag } from "./thread-DNi9NNai.mjs";
4
4
  import { Effect, Option, Schema } from "effect";
5
5
  import { Session } from "@codeworksh/harness/effect";
6
6
  //#region src/cli/cmd/handlers/thread/fork.ts
@@ -29,4 +29,4 @@ var fork_default = handler(Cmd.commands.thread.commands.fork, Effect.fn("CLI.thr
29
29
  //#endregion
30
30
  export { fork_default as default };
31
31
 
32
- //# sourceMappingURL=fork-DVLAR2qg.mjs.map
32
+ //# sourceMappingURL=fork-CCS7whub.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork-CCS7whub.mjs","names":["Runtime.handler","Client.make","Client.layer"],"sources":["../../src/cli/cmd/handlers/thread/fork.ts"],"sourcesContent":["import { Session } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Schema } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport { ThreadInfo } from \"../../../../server/contract.ts\";\nimport { InvalidInputError, reportFailure } from \"../../../error.ts\";\nimport { writeJson, writeOut } from \"../../../output.ts\";\nimport { threadFlag } from \"../../../thread.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nconst Forked = Schema.Struct({ thread: ThreadInfo, text: Schema.optional(Schema.String) });\n\nexport default Runtime.handler(\n\tCmd.commands.thread.commands.fork,\n\tEffect.fn(\"CLI.thread.fork\")(function* ({ session, thread, at, before, json, server }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst point = Option.isSome(at)\n\t\t\t\t? Option.isNone(before)\n\t\t\t\t\t? { entryId: at.value }\n\t\t\t\t\t: undefined\n\t\t\t\t: Option.map(before, (entryId) => ({ entryId, mode: \"before\" as const })).pipe(Option.getOrUndefined);\n\t\t\tif (point === undefined) {\n\t\t\t\treturn yield* new InvalidInputError({ message: \"Pass exactly one of --at or --before\" });\n\t\t\t}\n\t\t\tconst threadId = yield* threadFlag(thread);\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst forked = yield* rpc[\"thread.fork\"]({\n\t\t\t\tsessionId: Session.SessionSchema.ID.make(session),\n\t\t\t\t...(threadId === undefined ? {} : { threadId }),\n\t\t\t\t...point,\n\t\t\t});\n\t\t\tif (json) return yield* writeJson(Forked, forked);\n\t\t\tyield* writeOut(`${forked.thread.id}\\n`);\n\t\t\tif (forked.text !== undefined) yield* writeOut(`\\n${forked.text}\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.provide(Client.layer(server)), Effect.scoped, Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAUA,MAAM,SAAS,OAAO,OAAO;CAAE,QAAQ;CAAY,MAAM,OAAO,SAAS,OAAO,MAAM;AAAE,CAAC;AAEzF,IAAA,eAAeA,QACd,IAAI,SAAS,OAAO,SAAS,MAC7B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,SAAS,QAAQ,IAAI,QAAQ,MAAM,UAAU;CAsBtF,OAAO,OArBS,OAAO,IAAI,aAAa;EACvC,MAAM,QAAQ,OAAO,OAAO,EAAE,IAC3B,OAAO,OAAO,MAAM,IACnB,EAAE,SAAS,GAAG,MAAM,IACpB,KAAA,IACD,OAAO,IAAI,SAAS,aAAa;GAAE;GAAS,MAAM;EAAkB,EAAE,CAAC,CAAC,KAAK,OAAO,cAAc;EACrG,IAAI,UAAU,KAAA,GACb,OAAO,OAAO,IAAI,kBAAkB,EAAE,SAAS,uCAAuC,CAAC;EAExF,MAAM,WAAW,OAAO,WAAW,MAAM;EAEzC,MAAM,SAAS,QAAO,OADHC,KAAAA,CACO,cAAc,CAAC;GACxC,WAAW,QAAQ,cAAc,GAAG,KAAK,OAAO;GAChD,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;GAC7C,GAAG;EACJ,CAAC;EACD,IAAI,MAAM,OAAO,OAAO,UAAU,QAAQ,MAAM;EAChD,OAAO,SAAS,GAAG,OAAO,OAAO,GAAG,GAAG;EACvC,IAAI,OAAO,SAAS,KAAA,GAAW,OAAO,SAAS,KAAK,OAAO,KAAK,GAAG;CACpE,CAEoB,CAAC,CAAC,KAAK,OAAO,QAAQC,MAAa,MAAM,CAAC,GAAG,OAAO,QAAQ,OAAO,MAAM,aAAa,CAAC;AAC5G,CAAC,CACF"}
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-C_XwZ54u.mjs";
1
+ import { t as version } from "./package-lN9W6TGr.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-CKBJiD_d.mjs.map
92
+ //# sourceMappingURL=identity-BVTCyU5i.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-BVTCyU5i.mjs","names":["pkg.version"],"sources":["../../src/server/registration.ts","../../src/server/identity.ts"],"sourcesContent":["import { Effect, FileSystem, Layer, Option, Path, Schedule, Schema } from \"effect\";\nimport { isSea } from \"node:sea\";\n\n/**\n * How a running server advertises itself so later invocations can find it\n * without scanning ports or the process table.\n *\n * The file is a discovery hint, never proof: a caller reads it for the endpoint,\n * then asks the endpoint `server.info` and believes the answer only when the\n * live pid and version match the ones on file. A crashed server leaves a\n * registration behind; the failed probe is what retires it.\n */\nexport const Info = Schema.Struct({\n\t/** Operating system process identifier of the server that wrote this. */\n\tpid: Schema.Int,\n\t/** The build serving this endpoint; a mismatch means a different binary. */\n\tversion: Schema.String,\n\t/** The `ws://host:port/rpc/v1` endpoint a client connects to. */\n\turl: Schema.String,\n\t/** The TCP port the server bound, for a caller that would rather reuse it than default. */\n\tport: Schema.Int,\n});\nexport type Info = typeof Info.Type;\n\nexport const infoJson = Schema.fromJsonString(Info);\n\n/** The registration file for a CodeWork home: `<home>/service.json`. */\nexport const file = (home: string) => `${home}/service.json`;\n\n/** Where a background (`serve --service`) server writes its log: `<log>/server.log`, truncated per start. */\nexport const log = (logDir: string) => `${logDir}/server.log`;\n\nconst decode = Schema.decodeUnknownEffect(infoJson);\n\nconst write = Effect.fn(\"ServerRegistration.write\")(function* (path: string, info: Info) {\n\tconst fs = yield* FileSystem.FileSystem;\n\tconst paths = yield* Path.Path;\n\tyield* fs.makeDirectory(paths.dirname(path), { recursive: true });\n\tconst encoded = yield* Schema.encodeEffect(infoJson)(info);\n\t// Write beside the target and rename, so a reader never sees a half-written\n\t// file. 0600 because a future registration may carry a credential.\n\tconst temp = `${path}.${info.pid}.tmp`;\n\tyield* fs.writeFileString(temp, encoded, { mode: 0o600 });\n\tyield* fs.rename(temp, path);\n});\n\n/**\n * Publishes a registration for as long as this server lives, removing it on the\n * way out if it is still the one on file. A file left by a crash is overwritten\n * by the next server to start, and retired by a probe that cannot confirm it.\n *\n * One home has one discoverable server. Every few seconds the file is checked:\n * a missing or unreadable file is written again, and a file naming another\n * server means this one lost discovery for good, so it shuts down rather than\n * run on where nothing can find or stop it.\n */\nexport const register = (options: { readonly home: string; readonly info: Info }) =>\n\tLayer.effectDiscard(\n\t\tEffect.gen(function* () {\n\t\t\tconst path = file(options.home);\n\t\t\tconst fs = yield* FileSystem.FileSystem;\n\t\t\tconst current = fs.readFileString(path).pipe(Effect.flatMap(decode), Effect.option);\n\t\t\tconst owns = (found: Info) => found.pid === options.info.pid && found.url === options.info.url;\n\n\t\t\tyield* write(path, options.info);\n\t\t\tyield* Effect.addFinalizer(() =>\n\t\t\t\tcurrent.pipe(\n\t\t\t\t\tEffect.flatMap((found) => (Option.isSome(found) && owns(found.value) ? fs.remove(path) : Effect.void)),\n\t\t\t\t\tEffect.ignore,\n\t\t\t\t),\n\t\t\t);\n\t\t\t// Forked after the finalizer, so shutdown stops the watch before the file is removed.\n\t\t\tyield* current.pipe(\n\t\t\t\tEffect.flatMap((found) =>\n\t\t\t\t\tOption.isNone(found)\n\t\t\t\t\t\t? write(path, options.info).pipe(Effect.ignore, Effect.as(true))\n\t\t\t\t\t\t: Effect.succeed(owns(found.value)),\n\t\t\t\t),\n\t\t\t\tEffect.repeat({ while: (ours) => ours, schedule: Schedule.spaced(\"5 seconds\") }),\n\t\t\t\tEffect.andThen(Effect.logWarning(`${path} names another server; shutting down`)),\n\t\t\t\t// The same graceful path `codework service stop` takes.\n\t\t\t\tEffect.andThen(Effect.sync(() => process.kill(process.pid, \"SIGTERM\"))),\n\t\t\t\tEffect.forkScoped,\n\t\t\t);\n\t\t}),\n\t);\n\n/**\n * The launcher command for a managed server: this same CLI, asked to serve.\n *\n * A packaged install runs `dist/pack/index.mjs`; under `--conditions=development`\n * the entry is TypeScript, and `process.execArgv` carries the conditions forward\n * so a managed server resolves workspace sources the same way this process did.\n * The standalone binary is its own entry.\n */\nexport const command = (): ReadonlyArray<string> => {\n\tif (isSea()) return [process.execPath];\n\tconst entry = process.argv[1];\n\tif (entry === undefined) return [process.execPath];\n\tconst runtime = import.meta.url.endsWith(\".ts\") ? process.execArgv : [];\n\treturn [process.execPath, ...runtime, entry];\n};\n","import { Context, Layer } from \"effect\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\n\n/**\n * What a running server is, as its clients need to know it.\n *\n * A discovery registration names the pid and version it wrote; `server.info`\n * answers with the live ones so a caller can tell the process it reached is the\n * one that registered rather than a different server that took the same port.\n */\nexport interface Interface {\n\treadonly pid: number;\n\treadonly version: string;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/cli/server/identity/Service\") {}\n\n/** This process: a server answers with it, a client compares a server's version against it. */\nexport const current: Interface = { pid: process.pid, version: pkg.version };\n\nexport const layer = Layer.succeed(Service, Service.of(current));\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,OAAO,OAAO,OAAO;;CAEjC,KAAK,OAAO;;CAEZ,SAAS,OAAO;;CAEhB,KAAK,OAAO;;CAEZ,MAAM,OAAO;AACd,CAAC;AAGD,MAAa,WAAW,OAAO,eAAe,IAAI;;AAGlD,MAAa,QAAQ,SAAiB,GAAG,KAAK;;AAG9C,MAAa,OAAO,WAAmB,GAAG,OAAO;AAEjD,MAAM,SAAS,OAAO,oBAAoB,QAAQ;AAElD,MAAM,QAAQ,OAAO,GAAG,0BAA0B,CAAC,CAAC,WAAW,MAAc,MAAY;CACxF,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,QAAQ,OAAO,KAAK;CAC1B,OAAO,GAAG,cAAc,MAAM,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CAChE,MAAM,UAAU,OAAO,OAAO,aAAa,QAAQ,CAAC,CAAC,IAAI;CAGzD,MAAM,OAAO,GAAG,KAAK,GAAG,KAAK,IAAI;CACjC,OAAO,GAAG,gBAAgB,MAAM,SAAS,EAAE,MAAM,IAAM,CAAC;CACxD,OAAO,GAAG,OAAO,MAAM,IAAI;AAC5B,CAAC;;;;;;;;;;;AAYD,MAAa,YAAY,YACxB,MAAM,cACL,OAAO,IAAI,aAAa;CACvB,MAAM,OAAO,KAAK,QAAQ,IAAI;CAC9B,MAAM,KAA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;CAAE,KAAK,QAAQ;CAAcA;AAAY;AAE3E,MAAa,QAAQ,MAAM,QAAQ,SAAS,QAAQ,GAAG,OAAO,CAAC"}
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-C_XwZ54u.mjs";
2
+ import { t as version } from "./package-lN9W6TGr.mjs";
3
3
  import { i as Cmd, n as handlers, r as run } from "./runtime-CK2CunDw.mjs";
4
4
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
5
5
  import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -7,50 +7,50 @@ import { Effect } from "effect";
7
7
  //#region src/index.ts
8
8
  const Handlers = handlers(Cmd, {
9
9
  auth: {
10
- login: () => import("./login-CMAlTjiK.mjs"),
11
- status: () => import("./status-CVFY9ful.mjs"),
12
- refresh: () => import("./refresh-DUdUMbFI.mjs"),
13
- logout: () => import("./logout-CeAGmiSn.mjs")
10
+ login: () => import("./login-QHk3zh53.mjs"),
11
+ status: () => import("./status-7eZ8SNj6.mjs"),
12
+ refresh: () => import("./refresh-BcEZbN1M.mjs"),
13
+ logout: () => import("./logout-BfUtvU2r.mjs")
14
14
  },
15
15
  mcp: {
16
- add: () => import("./add-X6KvkHMs.mjs"),
17
- remove: () => import("./remove-ZdjqQX9i.mjs"),
18
- list: () => import("./list-Bt3ouolZ.mjs"),
19
- login: () => import("./login-DcgEg12S.mjs"),
20
- logout: () => import("./logout-D1xI2NRN.mjs"),
21
- reconnect: () => import("./reconnect-Dcsvfdpt.mjs"),
22
- disconnect: () => import("./disconnect-CwIeFpti.mjs")
16
+ add: () => import("./add-m4j4pRf0.mjs"),
17
+ remove: () => import("./remove-BCGe4voQ.mjs"),
18
+ list: () => import("./list-CovP7nPq.mjs"),
19
+ login: () => import("./login-BiAt5Rbc.mjs"),
20
+ logout: () => import("./logout-DjEv31ne.mjs"),
21
+ reconnect: () => import("./reconnect-meCirFLz.mjs"),
22
+ disconnect: () => import("./disconnect-Bh-Mg7Ew.mjs")
23
23
  },
24
- run: () => import("./run-fXg0o1k-.mjs"),
25
- serve: () => import("./serve-DbdHtKcg.mjs"),
24
+ run: () => import("./run-CEwzra2s.mjs"),
25
+ serve: () => import("./serve-Cgc_oGnQ.mjs"),
26
26
  service: {
27
- start: () => import("./start-JKcYzwQl.mjs"),
28
- restart: () => import("./restart-CKf3ePDj.mjs"),
29
- status: () => import("./status-DBztqldO.mjs"),
30
- stop: () => import("./stop-DhDXVZpr.mjs")
27
+ start: () => import("./start-BefqfIKI.mjs"),
28
+ restart: () => import("./restart-CaSIi-QA.mjs"),
29
+ status: () => import("./status-CLq0c9qg.mjs"),
30
+ stop: () => import("./stop-CJbSa7t1.mjs")
31
31
  },
32
32
  session: {
33
- link: () => import("./link-qVwvZmA1.mjs"),
34
- relink: () => import("./relink-BodbEN6d.mjs")
33
+ link: () => import("./link-DWil9fU6.mjs"),
34
+ relink: () => import("./relink-DZMBrGYH.mjs")
35
35
  },
36
36
  thread: {
37
- list: () => import("./list-DqgxOo7n.mjs"),
38
- fork: () => import("./fork-DVLAR2qg.mjs")
37
+ list: () => import("./list-VEqzQJSN.mjs"),
38
+ fork: () => import("./fork-CCS7whub.mjs")
39
39
  },
40
- acp: () => import("./acp-52MbcwkL.mjs"),
40
+ acp: () => import("./acp-CJsNVIrq.mjs"),
41
41
  plugin: {
42
- add: () => import("./add-2JwsoW7_.mjs"),
43
- check: () => import("./check-Dfa50wOY.mjs"),
44
- install: () => import("./install-C4W8hfls.mjs"),
45
- list: () => import("./list-D23TXjlY.mjs"),
46
- reload: () => import("./reload-D6-UfcG1.mjs"),
47
- remove: () => import("./remove-D3bNv2QX.mjs"),
48
- update: () => import("./update-B0UA9M3G.mjs")
42
+ add: () => import("./add-BmROWuHU.mjs"),
43
+ check: () => import("./check-BdN8vvHQ.mjs"),
44
+ install: () => import("./install-DCUZDpRI.mjs"),
45
+ list: () => import("./list-BaFwSDO0.mjs"),
46
+ reload: () => import("./reload-DRItkMBi.mjs"),
47
+ remove: () => import("./remove-BzxXS7R4.mjs"),
48
+ update: () => import("./update-B0GsDRpJ.mjs")
49
49
  },
50
50
  models: {
51
- $: () => import("./list-Bf1hEU8J.mjs"),
52
- providers: () => import("./providers-DBFqwwTv.mjs"),
53
- refresh: () => import("./refresh-CGcQq37V.mjs")
51
+ $: () => import("./list-DDLes-GH.mjs"),
52
+ providers: () => import("./providers-Bq4r0L3-.mjs"),
53
+ refresh: () => import("./refresh-GCPWtEyM.mjs")
54
54
  }
55
55
  });
56
56
  const main = run(Cmd, Handlers, { version }).pipe(Effect.provide(NodeServices.layer));
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["Runtime.handlers","Runtime.run","pkg.version"],"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport { Effect } from \"effect\";\nimport type { CliError } from \"effect/cli\";\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport { Cmd } from \"./cli/cmd/cmd.ts\";\nimport type { CommandError } from \"./cli/error.ts\";\nimport { Runtime } from \"./framework/runtime.ts\";\n\nconst Handlers = Runtime.handlers(Cmd, {\n\tauth: {\n\t\tlogin: () => import(\"./cli/cmd/handlers/auth/login.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/auth/status.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/auth/refresh.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/auth/logout.ts\"),\n\t},\n\tmcp: {\n\t\tadd: () => import(\"./cli/cmd/handlers/mcp/add.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/mcp/remove.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/mcp/list.ts\"),\n\t\tlogin: () => import(\"./cli/cmd/handlers/mcp/login.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/mcp/logout.ts\"),\n\t\treconnect: () => import(\"./cli/cmd/handlers/mcp/reconnect.ts\"),\n\t\tdisconnect: () => import(\"./cli/cmd/handlers/mcp/disconnect.ts\"),\n\t},\n\trun: () => import(\"./cli/cmd/handlers/run.ts\"),\n\tserve: () => import(\"./cli/cmd/handlers/serve.ts\"),\n\tservice: {\n\t\tstart: () => import(\"./cli/cmd/handlers/service/start.ts\"),\n\t\trestart: () => import(\"./cli/cmd/handlers/service/restart.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/service/status.ts\"),\n\t\tstop: () => import(\"./cli/cmd/handlers/service/stop.ts\"),\n\t},\n\tsession: {\n\t\tlink: () => import(\"./cli/cmd/handlers/session/link.ts\"),\n\t\trelink: () => import(\"./cli/cmd/handlers/session/relink.ts\"),\n\t},\n\tthread: {\n\t\tlist: () => import(\"./cli/cmd/handlers/thread/list.ts\"),\n\t\tfork: () => import(\"./cli/cmd/handlers/thread/fork.ts\"),\n\t},\n\tacp: () => import(\"./cli/cmd/handlers/acp.ts\"),\n\tplugin: {\n\t\tadd: () => import(\"./cli/cmd/handlers/plugin/add.ts\"),\n\t\tcheck: () => import(\"./cli/cmd/handlers/plugin/check.ts\"),\n\t\tinstall: () => import(\"./cli/cmd/handlers/plugin/install.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/plugin/list.ts\"),\n\t\treload: () => import(\"./cli/cmd/handlers/plugin/reload.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/plugin/remove.ts\"),\n\t\tupdate: () => import(\"./cli/cmd/handlers/plugin/update.ts\"),\n\t},\n\tmodels: {\n\t\t$: () => import(\"./cli/cmd/handlers/models/list.ts\"),\n\t\tproviders: () => import(\"./cli/cmd/handlers/models/providers.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/models/refresh.ts\"),\n\t},\n});\n\nexport const main: Effect.Effect<void, CommandError | CliError.CliError> = Runtime.run(Cmd, Handlers, {\n\tversion: pkg.version,\n}).pipe(Effect.provide(NodeServices.layer));\n\nNodeRuntime.runMain(main);\n"],"mappings":";;;;;;;AAWA,MAAM,WAAWA,SAAiB,KAAK;CACtC,MAAM;EACL,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,eAAe,OAAO;EACtB,cAAc,OAAO;CACtB;CACA,KAAK;EACJ,WAAW,OAAO;EAClB,cAAc,OAAO;EACrB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,iBAAiB,OAAO;EACxB,kBAAkB,OAAO;CAC1B;CACA,WAAW,OAAO;CAClB,aAAa,OAAO;CACpB,SAAS;EACR,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,cAAc,OAAO;EACrB,YAAY,OAAO;CACpB;CACA,SAAS;EACR,YAAY,OAAO;EACnB,cAAc,OAAO;CACtB;CACA,QAAQ;EACP,YAAY,OAAO;EACnB,YAAY,OAAO;CACpB;CACA,WAAW,OAAO;CAClB,QAAQ;EACP,WAAW,OAAO;EAClB,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,YAAY,OAAO;EACnB,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,OAAO;CACtB;CACA,QAAQ;EACP,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,eAAe,OAAO;CACvB;AACD,CAAC;AAED,MAAa,OAA8DC,IAAY,KAAK,UAAU,EAC5FC,QACV,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE1C,YAAY,QAAQ,IAAI"}
1
+ {"version":3,"file":"index.mjs","names":["Runtime.handlers","Runtime.run","pkg.version"],"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport { Effect } from \"effect\";\nimport type { CliError } from \"effect/cli\";\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport { Cmd } from \"./cli/cmd/cmd.ts\";\nimport type { CommandError } from \"./cli/error.ts\";\nimport * as Runtime from \"./framework/runtime.ts\";\n\nconst Handlers = Runtime.handlers(Cmd, {\n\tauth: {\n\t\tlogin: () => import(\"./cli/cmd/handlers/auth/login.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/auth/status.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/auth/refresh.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/auth/logout.ts\"),\n\t},\n\tmcp: {\n\t\tadd: () => import(\"./cli/cmd/handlers/mcp/add.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/mcp/remove.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/mcp/list.ts\"),\n\t\tlogin: () => import(\"./cli/cmd/handlers/mcp/login.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/mcp/logout.ts\"),\n\t\treconnect: () => import(\"./cli/cmd/handlers/mcp/reconnect.ts\"),\n\t\tdisconnect: () => import(\"./cli/cmd/handlers/mcp/disconnect.ts\"),\n\t},\n\trun: () => import(\"./cli/cmd/handlers/run.ts\"),\n\tserve: () => import(\"./cli/cmd/handlers/serve.ts\"),\n\tservice: {\n\t\tstart: () => import(\"./cli/cmd/handlers/service/start.ts\"),\n\t\trestart: () => import(\"./cli/cmd/handlers/service/restart.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/service/status.ts\"),\n\t\tstop: () => import(\"./cli/cmd/handlers/service/stop.ts\"),\n\t},\n\tsession: {\n\t\tlink: () => import(\"./cli/cmd/handlers/session/link.ts\"),\n\t\trelink: () => import(\"./cli/cmd/handlers/session/relink.ts\"),\n\t},\n\tthread: {\n\t\tlist: () => import(\"./cli/cmd/handlers/thread/list.ts\"),\n\t\tfork: () => import(\"./cli/cmd/handlers/thread/fork.ts\"),\n\t},\n\tacp: () => import(\"./cli/cmd/handlers/acp.ts\"),\n\tplugin: {\n\t\tadd: () => import(\"./cli/cmd/handlers/plugin/add.ts\"),\n\t\tcheck: () => import(\"./cli/cmd/handlers/plugin/check.ts\"),\n\t\tinstall: () => import(\"./cli/cmd/handlers/plugin/install.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/plugin/list.ts\"),\n\t\treload: () => import(\"./cli/cmd/handlers/plugin/reload.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/plugin/remove.ts\"),\n\t\tupdate: () => import(\"./cli/cmd/handlers/plugin/update.ts\"),\n\t},\n\tmodels: {\n\t\t$: () => import(\"./cli/cmd/handlers/models/list.ts\"),\n\t\tproviders: () => import(\"./cli/cmd/handlers/models/providers.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/models/refresh.ts\"),\n\t},\n});\n\nexport const main: Effect.Effect<void, CommandError | CliError.CliError> = Runtime.run(Cmd, Handlers, {\n\tversion: pkg.version,\n}).pipe(Effect.provide(NodeServices.layer));\n\nNodeRuntime.runMain(main);\n"],"mappings":";;;;;;;AAWA,MAAM,WAAWA,SAAiB,KAAK;CACtC,MAAM;EACL,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,eAAe,OAAO;EACtB,cAAc,OAAO;CACtB;CACA,KAAK;EACJ,WAAW,OAAO;EAClB,cAAc,OAAO;EACrB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,iBAAiB,OAAO;EACxB,kBAAkB,OAAO;CAC1B;CACA,WAAW,OAAO;CAClB,aAAa,OAAO;CACpB,SAAS;EACR,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,cAAc,OAAO;EACrB,YAAY,OAAO;CACpB;CACA,SAAS;EACR,YAAY,OAAO;EACnB,cAAc,OAAO;CACtB;CACA,QAAQ;EACP,YAAY,OAAO;EACnB,YAAY,OAAO;CACpB;CACA,WAAW,OAAO;CAClB,QAAQ;EACP,WAAW,OAAO;EAClB,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,YAAY,OAAO;EACnB,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,OAAO;CACtB;CACA,QAAQ;EACP,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,eAAe,OAAO;CACvB;AACD,CAAC;AAED,MAAa,OAA8DC,IAAY,KAAK,UAAU,EAC5FC,QACV,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE1C,YAAY,QAAQ,IAAI"}
@@ -1,6 +1,6 @@
1
1
  import { i as Cmd, t as handler } from "./runtime-CK2CunDw.mjs";
2
- import { f as writeOut, i as reportFailure } from "./error-BE7K70v8.mjs";
3
- import { i as read, t as fetchable } from "./entries-mPkFRA-f.mjs";
2
+ import { f as writeOut, i as reportFailure } from "./error-BU5WVAb2.mjs";
3
+ import { i as read, t as fetchable } from "./entries-BZA9G7f0.mjs";
4
4
  import { Effect } from "effect";
5
5
  import { Plugin } from "@codeworksh/harness/effect";
6
6
  //#region src/cli/cmd/handlers/plugin/install.ts
@@ -51,4 +51,4 @@ var install_default = handler(Cmd.commands.plugin.commands.install, Effect.fn("C
51
51
  //#endregion
52
52
  export { install_default as default };
53
53
 
54
- //# sourceMappingURL=install-C4W8hfls.mjs.map
54
+ //# sourceMappingURL=install-DCUZDpRI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-DCUZDpRI.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/install.ts"],"sourcesContent":["import { Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { fetchable, read } from \"./entries.ts\";\n\n/**\n * `plugin install`, with no argument: the answer to a fresh checkout.\n *\n * A committed `.codework/settings.jsonc` names plugins, the store on a colleague's machine is\n * empty, and something has to materialise them. This is `npm install` with no arguments -- it\n * writes no settings entry, because the entries already exist.\n *\n * It is also what lets **boot stay offline**. Without it the only path from an entry to bytes is a\n * boot that installs, which makes every fresh start a possible network wait; with it, boot\n * resolves or reports, and the error names this command as the remedy.\n */\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.install,\n\tEffect.fn(\"CLI.plugin.install\")(function* () {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst { entries, cache } = yield* read(shared);\n\n\t\t\tlet installed = 0;\n\t\t\tlet present = 0;\n\t\t\tlet local = 0;\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst target = fetchable(entry.target);\n\t\t\t\tif (target === undefined) {\n\t\t\t\t\t// A local plugin is loaded where it lies and never copied into the store, so\n\t\t\t\t\t// there is nothing to install. An unparseable entry is `list`'s to report.\n\t\t\t\t\tlocal += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif ((yield* Plugin.resolve(target, cache, entry.from)) !== undefined) {\n\t\t\t\t\tpresent += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// `inspect` installs, imports and validates, so a spec that turns out not to be a\n\t\t\t\t// plugin fails here rather than at the next run. The reported ID comes from the\n\t\t\t\t// module, never from the spec.\n\t\t\t\tconst plugin = yield* Plugin.inspect(entry.reference, { cache, hostDir: entry.from, file: entry.file });\n\t\t\t\tinstalled += 1;\n\t\t\t\tyield* writeOut(`Installed ${entry.reference} (${plugin.id})\\n`);\n\t\t\t}\n\n\t\t\tconst parts = [\n\t\t\t\t`${installed} installed`,\n\t\t\t\t...(present === 0 ? [] : [`${present} already present`]),\n\t\t\t\t...(local === 0 ? [] : [`${local} local`]),\n\t\t\t];\n\t\t\tyield* writeOut(`${parts.join(\", \")}\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,IAAA,kBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,SAC7B,OAAO,GAAG,oBAAoB,CAAC,CAAC,aAAa;CAoC5C,OAAO,OAnCS,OAAO,IAAI,aAAa;EACvC,MAAM,SAAS,OAAO,IAAI;EAC1B,MAAM,EAAE,SAAS,UAAU,OAAO,KAAK,MAAM;EAE7C,IAAI,YAAY;EAChB,IAAI,UAAU;EACd,IAAI,QAAQ;EACZ,KAAK,MAAM,SAAS,SAAS;GAC5B,MAAM,SAAS,UAAU,MAAM,MAAM;GACrC,IAAI,WAAW,KAAA,GAAW;IAGzB,SAAS;IACT;GACD;GACA,KAAK,OAAO,OAAO,QAAQ,QAAQ,OAAO,MAAM,IAAI,OAAO,KAAA,GAAW;IACrE,WAAW;IACX;GACD;GAIA,MAAM,SAAS,OAAO,OAAO,QAAQ,MAAM,WAAW;IAAE;IAAO,SAAS,MAAM;IAAM,MAAM,MAAM;GAAK,CAAC;GACtG,aAAa;GACb,OAAO,SAAS,aAAa,MAAM,UAAU,IAAI,OAAO,GAAG,IAAI;EAChE;EAEA,MAAM,QAAQ;GACb,GAAG,UAAU;GACb,GAAI,YAAY,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,iBAAiB;GACtD,GAAI,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,OAAO;EACzC;EACA,OAAO,SAAS,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG;CACxC,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
@@ -0,0 +1,33 @@
1
+ import { t as InvalidInputError } from "./error-BU5WVAb2.mjs";
2
+ import { Effect, FileSystem } from "effect";
3
+ import { SettingsFile } from "@codeworksh/harness/effect";
4
+ import { parse } from "jsonc-parser";
5
+ //#region src/cli/jsonc.ts
6
+ /**
7
+ * Reading and rewriting one value of a JSONC file the CLI edits for its owner: `settings.jsonc`,
8
+ * `mcp.json`. The edit and the write are the harness's {@link SettingsFile}, shared with the app
9
+ * server.
10
+ */
11
+ /** The file's text and its top-level object; a missing file reads as `{}`. */
12
+ const read = Effect.fn("CLI.jsonc.read")(function* (path, what) {
13
+ const fs = yield* FileSystem.FileSystem;
14
+ const source = (yield* fs.exists(path)) ? yield* fs.readFileString(path) : "{}";
15
+ const errors = [];
16
+ const document = parse(source, errors, { allowTrailingComma: true });
17
+ if (errors.length > 0 || typeof document !== "object" || document === null || Array.isArray(document)) return yield* new InvalidInputError({ message: `${path} is not a valid ${what}` });
18
+ return {
19
+ source,
20
+ document
21
+ };
22
+ });
23
+ /** Set the value at `at` in `source`, or remove it when `value` is undefined, and write the file. */
24
+ const write = (path, source, at, value) => SettingsFile.save(path, SettingsFile.edit(source, at, value));
25
+ /**
26
+ * Serialize one read-modify-rename of `path` across CLI processes and the app server. Only the local
27
+ * edit is locked, so work that precedes it does not wait behind another process.
28
+ */
29
+ const locked = (path, edit) => SettingsFile.locked(path, () => new InvalidInputError({ message: `timed out waiting to edit ${path}` }), edit);
30
+ //#endregion
31
+ export { read as n, write as r, locked as t };
32
+
33
+ //# sourceMappingURL=jsonc-B3ackf25.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonc-B3ackf25.mjs","names":["parseJsonc"],"sources":["../../src/cli/jsonc.ts"],"sourcesContent":["import { SettingsFile } from \"@codeworksh/harness/effect\";\nimport { Effect, FileSystem } from \"effect\";\nimport { parse as parseJsonc, type ParseError } from \"jsonc-parser\";\nimport { InvalidInputError } from \"./error.ts\";\n\n/**\n * Reading and rewriting one value of a JSONC file the CLI edits for its owner: `settings.jsonc`,\n * `mcp.json`. The edit and the write are the harness's {@link SettingsFile}, shared with the app\n * server.\n */\n\n/** The file's text and its top-level object; a missing file reads as `{}`. */\nexport const read = Effect.fn(\"CLI.jsonc.read\")(function* (path: string, what: string) {\n\tconst fs = yield* FileSystem.FileSystem;\n\tconst source = (yield* fs.exists(path)) ? yield* fs.readFileString(path) : \"{}\";\n\tconst errors: ParseError[] = [];\n\tconst document: unknown = parseJsonc(source, errors, { allowTrailingComma: true });\n\tif (errors.length > 0 || typeof document !== \"object\" || document === null || Array.isArray(document)) {\n\t\treturn yield* new InvalidInputError({ message: `${path} is not a valid ${what}` });\n\t}\n\treturn { source, document: document as Record<string, unknown> };\n});\n\n/** Set the value at `at` in `source`, or remove it when `value` is undefined, and write the file. */\nexport const write = (path: string, source: string, at: ReadonlyArray<string>, value: unknown) =>\n\tSettingsFile.save(path, SettingsFile.edit(source, at, value));\n\n/**\n * Serialize one read-modify-rename of `path` across CLI processes and the app server. Only the local\n * edit is locked, so work that precedes it does not wait behind another process.\n */\nexport const locked = <A, E, R>(path: string, edit: Effect.Effect<A, E, R>) =>\n\tSettingsFile.locked(path, () => new InvalidInputError({ message: `timed out waiting to edit ${path}` }), edit);\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,OAAO,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,MAAc,MAAc;CACtF,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,UAAU,OAAO,GAAG,OAAO,IAAI,KAAK,OAAO,GAAG,eAAe,IAAI,IAAI;CAC3E,MAAM,SAAuB,CAAC;CAC9B,MAAM,WAAoBA,MAAW,QAAQ,QAAQ,EAAE,oBAAoB,KAAK,CAAC;CACjF,IAAI,OAAO,SAAS,KAAK,OAAO,aAAa,YAAY,aAAa,QAAQ,MAAM,QAAQ,QAAQ,GACnG,OAAO,OAAO,IAAI,kBAAkB,EAAE,SAAS,GAAG,KAAK,kBAAkB,OAAO,CAAC;CAElF,OAAO;EAAE;EAAkB;CAAoC;AAChE,CAAC;;AAGD,MAAa,SAAS,MAAc,QAAgB,IAA2B,UAC9E,aAAa,KAAK,MAAM,aAAa,KAAK,QAAQ,IAAI,KAAK,CAAC;;;;;AAM7D,MAAa,UAAmB,MAAc,SAC7C,aAAa,OAAO,YAAY,IAAI,kBAAkB,EAAE,SAAS,6BAA6B,OAAO,CAAC,GAAG,IAAI"}
@@ -1,5 +1,5 @@
1
1
  import { i as Cmd, t as handler } from "./runtime-CK2CunDw.mjs";
2
- import { f as writeOut, i as reportFailure, m as make, p as layer } from "./error-BE7K70v8.mjs";
2
+ import { f as writeOut, i as reportFailure, m as make, p as layer } from "./error-BU5WVAb2.mjs";
3
3
  import { Effect, Option, Path } from "effect";
4
4
  import { Session } from "@codeworksh/harness/effect";
5
5
  //#region src/cli/cmd/handlers/session/link.ts
@@ -38,4 +38,4 @@ var link_default = handler(Cmd.commands.session.commands.link, Effect.fn("CLI.se
38
38
  //#endregion
39
39
  export { link_default as default };
40
40
 
41
- //# sourceMappingURL=link-qVwvZmA1.mjs.map
41
+ //# sourceMappingURL=link-DWil9fU6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-DWil9fU6.mjs","names":["Runtime.handler","Client.make","Client.layer"],"sources":["../../src/cli/cmd/handlers/session/link.ts"],"sourcesContent":["import { Session } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\n/**\n * Sets `hostDir` on an existing session.\n *\n * **The session ID identifies it; the path is the target.** A project cannot identify a session --\n * it may have many or none, and it is the session that carries the field.\n *\n * The path defaults to the shell's directory, which is both the common case (you are standing in\n * the project you want to link) and safe to default: the CLI runs on the host, so the trust\n * question about naming host paths is about remote clients, not about a local shell's own cwd.\n *\n * Not `session relink`, which moves a session to another checkout of the same project. Different\n * axes -- `relink` changes where the *work* happens, `link` changes which host directory the\n * session is *anchored to* -- and conflating them would recreate the confusion the two names\n * exist to avoid.\n *\n * The anchor is not a settings mechanism. Settings discovery reads it, so do plugin installs, and\n * so will whatever needs a host-side directory next; naming any one of them in the description is\n * what made this read like a settings flag.\n */\nexport default Runtime.handler(\n\tCmd.commands.session.commands.link,\n\tEffect.fn(\"CLI.session.link\")(function* ({ session, path, unlink, server }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst nodePath = yield* Path.Path;\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst sessionId = Session.SessionSchema.ID.make(session);\n\t\t\tconst hostDir = unlink\n\t\t\t\t? undefined\n\t\t\t\t: Session.AbsolutePath.make(nodePath.resolve(Option.getOrElse(path, () => \".\")));\n\n\t\t\tconst info = yield* rpc[\"session.link\"]({\n\t\t\t\tsessionId,\n\t\t\t\t...(hostDir === undefined ? {} : { hostDir }),\n\t\t\t});\n\t\t\t// Settings are re-read every exchange, so this applies at the next one: no reload, no\n\t\t\t// restart, the project layer simply starts or stops being read.\n\t\t\tyield* writeOut(\n\t\t\t\tinfo.hostDir === undefined\n\t\t\t\t\t? `Unlinked ${info.id}; it now reads the user settings alone.\\n`\n\t\t\t\t\t: `Linked ${info.id} to ${info.hostDir}\\n`,\n\t\t\t);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.provide(Client.layer(server)), Effect.scoped, Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAA,eAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,MAC9B,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,EAAE,SAAS,MAAM,QAAQ,UAAU;CAsB3E,OAAO,OArBS,OAAO,IAAI,aAAa;EACvC,MAAM,WAAW,OAAO,KAAK;EAC7B,MAAM,MAAM,OAAOC;EACnB,MAAM,YAAY,QAAQ,cAAc,GAAG,KAAK,OAAO;EACvD,MAAM,UAAU,SACb,KAAA,IACA,QAAQ,aAAa,KAAK,SAAS,QAAQ,OAAO,UAAU,YAAY,GAAG,CAAC,CAAC;EAEhF,MAAM,OAAO,OAAO,IAAI,eAAe,CAAC;GACvC;GACA,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;EAC5C,CAAC;EAGD,OAAO,SACN,KAAK,YAAY,KAAA,IACd,YAAY,KAAK,GAAG,6CACpB,UAAU,KAAK,GAAG,MAAM,KAAK,QAAQ,GACzC;CACD,CAEoB,CAAC,CAAC,KAAK,OAAO,QAAQC,MAAa,MAAM,CAAC,GAAG,OAAO,QAAQ,OAAO,MAAM,aAAa,CAAC;AAC5G,CAAC,CACF"}
@@ -1,6 +1,6 @@
1
1
  import { i as Cmd, t as handler } from "./runtime-CK2CunDw.mjs";
2
- import { f as writeOut, i as reportFailure } from "./error-BE7K70v8.mjs";
3
- import { i as read } from "./entries-mPkFRA-f.mjs";
2
+ import { f as writeOut, i as reportFailure } from "./error-BU5WVAb2.mjs";
3
+ import { i as read } from "./entries-BZA9G7f0.mjs";
4
4
  import { Effect, Schema } from "effect";
5
5
  import { Plugin } from "@codeworksh/harness/effect";
6
6
  //#region src/cli/cmd/handlers/plugin/list.ts
@@ -74,4 +74,4 @@ var list_default = handler(Cmd.commands.plugin.commands.list, Effect.fn("CLI.plu
74
74
  //#endregion
75
75
  export { list_default as default };
76
76
 
77
- //# sourceMappingURL=list-D23TXjlY.mjs.map
77
+ //# sourceMappingURL=list-BaFwSDO0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-BaFwSDO0.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/list.ts"],"sourcesContent":["import { Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect, Schema } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { read } from \"./entries.ts\";\n\n/**\n * Two columns: what was written, and what it turned out to be.\n *\n * **The second column doubles as the state, for free.** An ID cannot be known without importing\n * the module -- the store records nothing about the plugin inside a package -- so printing one is\n * proof that everything worked: the entry parsed, the store had it, the import succeeded, and the\n * definition validated. When any of that fails there is no ID to print, and the reason goes in its\n * place.\n *\n * **Nothing is stored to make that work.** The reason is the live error from this run, not a\n * record of an older one: a stored failure goes stale the moment someone fixes the cause, and a\n * list still printing `plugin-import-failed` after you installed the missing dependency is worse\n * than one that says nothing. The work is cheap and local -- a parse, a lookup and an import.\n *\n * (`checkedAt`/`outdated` are stored, for the opposite reason: those come from the network, so\n * re-obtaining them is expensive and a slightly stale answer is the right trade. Local facts are\n * recomputed; remote facts are cached.)\n */\nconst isSourceError = Schema.is(Plugin.SourceError);\nconst isInstallError = Schema.is(Plugin.InstallError);\nconst isStoreError = Schema.is(Plugin.StoreError);\nconst isLoadError = Schema.is(Plugin.LoadError);\n\n/** The §5.5 reason slug, which is the same string the CLI prints and a log line carries. */\nconst reasonOf = (error: unknown): { readonly reason: string; readonly message: string } =>\n\tisSourceError(error) || isInstallError(error) || isStoreError(error) || isLoadError(error)\n\t\t? { reason: error.reason, message: error.message }\n\t\t: { reason: \"plugin-load-failed\", message: String(error) };\n\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.list,\n\tEffect.fn(\"CLI.plugin.list\")(function* ({ verbose }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst { entries, cache } = yield* read(shared);\n\t\t\tif (entries.length === 0) {\n\t\t\t\tyield* writeOut(\"No plugins are configured.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rows: Array<{ written: string; file: string; state: string; detail?: string }> = [];\n\t\t\tfor (const entry of entries) {\n\t\t\t\t// Resolve-only: listing what is configured must never install anything.\n\t\t\t\tconst inspected = yield* Plugin.inspect(entry.reference, {\n\t\t\t\t\tcache,\n\t\t\t\t\thostDir: entry.from,\n\t\t\t\t\tfile: entry.file,\n\t\t\t\t\tinstall: Plugin.resolveCached,\n\t\t\t\t}).pipe(Effect.result);\n\t\t\t\trows.push(\n\t\t\t\t\tinspected._tag === \"Success\"\n\t\t\t\t\t\t? { written: entry.written, file: entry.file, state: inspected.success.id }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\twritten: entry.written,\n\t\t\t\t\t\t\t\tfile: entry.file,\n\t\t\t\t\t\t\t\tstate: reasonOf(inspected.failure).reason,\n\t\t\t\t\t\t\t\tdetail: reasonOf(inspected.failure).message,\n\t\t\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The left column is the reference exactly as the entry spells it, because that is the\n\t\t\t// string a person will search their settings for.\n\t\t\tconst width = Math.max(...rows.map((row) => row.written.length));\n\t\t\tfor (const row of rows) {\n\t\t\t\tyield* writeOut(`${row.written.padEnd(width)} ${row.state}\\n`);\n\t\t\t\tif (verbose) {\n\t\t\t\t\tif (row.detail !== undefined) yield* writeOut(`${\" \".repeat(width)} ${row.detail}\\n`);\n\t\t\t\t\tyield* writeOut(`${\" \".repeat(width)} declared in: ${row.file}\\n`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,gBAAgB,OAAO,GAAG,OAAO,WAAW;AAClD,MAAM,iBAAiB,OAAO,GAAG,OAAO,YAAY;AACpD,MAAM,eAAe,OAAO,GAAG,OAAO,UAAU;AAChD,MAAM,cAAc,OAAO,GAAG,OAAO,SAAS;;AAG9C,MAAM,YAAY,UACjB,cAAc,KAAK,KAAK,eAAe,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,KAAK,IACtF;CAAE,QAAQ,MAAM;CAAQ,SAAS,MAAM;AAAQ,IAC/C;CAAE,QAAQ;CAAsB,SAAS,OAAO,KAAK;AAAE;AAE3D,IAAA,eAAeA,QACd,IAAI,SAAS,OAAO,SAAS,MAC7B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,WAAW;CA0CpD,OAAO,OAzCS,OAAO,IAAI,aAAa;EACvC,MAAM,SAAS,OAAO,IAAI;EAC1B,MAAM,EAAE,SAAS,UAAU,OAAO,KAAK,MAAM;EAC7C,IAAI,QAAQ,WAAW,GAAG;GACzB,OAAO,SAAS,8BAA8B;GAC9C;EACD;EAEA,MAAM,OAAiF,CAAC;EACxF,KAAK,MAAM,SAAS,SAAS;GAE5B,MAAM,YAAY,OAAO,OAAO,QAAQ,MAAM,WAAW;IACxD;IACA,SAAS,MAAM;IACf,MAAM,MAAM;IACZ,SAAS,OAAO;GACjB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;GACrB,KAAK,KACJ,UAAU,SAAS,YAChB;IAAE,SAAS,MAAM;IAAS,MAAM,MAAM;IAAM,OAAO,UAAU,QAAQ;GAAG,IACxE;IACA,SAAS,MAAM;IACf,MAAM,MAAM;IACZ,OAAO,SAAS,UAAU,OAAO,CAAC,CAAC;IACnC,QAAQ,SAAS,UAAU,OAAO,CAAC,CAAC;GACrC,CACH;EACD;EAIA,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,KAAK,QAAQ,IAAI,QAAQ,MAAM,CAAC;EAC/D,KAAK,MAAM,OAAO,MAAM;GACvB,OAAO,SAAS,GAAG,IAAI,QAAQ,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,GAAG;GAC9D,IAAI,SAAS;IACZ,IAAI,IAAI,WAAW,KAAA,GAAW,OAAO,SAAS,GAAG,IAAI,OAAO,KAAK,EAAE,IAAI,IAAI,OAAO,GAAG;IACrF,OAAO,SAAS,GAAG,IAAI,OAAO,KAAK,EAAE,iBAAiB,IAAI,KAAK,GAAG;GACnE;EACD;CACD,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-CK2CunDw.mjs";
2
- import { f as writeOut, i as reportFailure } from "./error-BE7K70v8.mjs";
3
- import { n as configured, r as describe, t as MARKS } from "./shared-C8WKgxTL.mjs";
2
+ import { f as writeOut, i as reportFailure } from "./error-BU5WVAb2.mjs";
3
+ import { n as configured, r as describe, t as MARKS } from "./shared-DkiZmtNa.mjs";
4
4
  import { Effect, Layer, References } from "effect";
5
5
  import { Database, Event, Mcp } from "@codeworksh/harness/effect";
6
6
  //#region src/cli/cmd/handlers/mcp/list.ts
@@ -68,4 +68,4 @@ var list_default = handler(Cmd.commands.mcp.commands.list, Effect.fn("CLI.mcp.li
68
68
  //#endregion
69
69
  export { list_default as default };
70
70
 
71
- //# sourceMappingURL=list-Bt3ouolZ.mjs.map
71
+ //# sourceMappingURL=list-CovP7nPq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-CovP7nPq.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/mcp/list.ts"],"sourcesContent":["/* @effect-diagnostics preferSchemaOverJson:off -- `--json` prints the report as it is built. */\nimport { Database, Event, type EventList, Mcp } from \"@codeworksh/harness/effect\";\nimport { Effect, Layer, References } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { configured, describe, MARKS } from \"./shared.ts\";\n\ninterface Report {\n\treadonly name: string;\n\treadonly level: \"user\" | \"project\";\n\treadonly file: string;\n\t/** The project `mcp.json` that overrides `enabled` or exposure of this user server. */\n\treadonly override?: string;\n\treadonly enabled: boolean;\n\treadonly exposure: string;\n\treadonly transport: string;\n\treadonly state: Mcp.State;\n\treadonly tools: ReadonlyArray<string>;\n\t/** Tools it listed that were left out because the MCP SDK rejects them. */\n\treadonly skipped?: EventList.McpSkipped;\n\t/** Tools whose exposure differs from the server's, from `toolExposure`. */\n\treadonly toolExposure?: Record<string, string>;\n\t/** Whether the server offers resources. They are not listed: listing every one can take long. */\n\treadonly resources?: true;\n\treadonly error?: string;\n}\n\nexport default Runtime.handler(\n\tCmd.commands.mcp.commands.list,\n\tEffect.fn(\"CLI.mcp.list\")(function* ({ json }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst { home, authFile, hostCwd, root, user, servers, errors } = yield* configured();\n\t\t\t// Every connect problem is in the report; the service's own logs would only repeat it.\n\t\t\tconst statuses = yield* Mcp.check({\n\t\t\t\tservers: servers.map((server) => [server.name, server.config] as const),\n\t\t\t\tdirectory: hostCwd,\n\t\t\t\thostDir: root ?? hostCwd,\n\t\t\t}).pipe(\n\t\t\t\t// Status events need an event service; nothing reads them here, so it keeps them in memory.\n\t\t\t\tEffect.provide(\n\t\t\t\t\tMcp.layer({ hostCwd, home, authFile }).pipe(\n\t\t\t\t\t\tLayer.provide(Event.layer.pipe(Layer.provide(Database.layer(\":memory:\")))),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tEffect.provideService(References.MinimumLogLevel, \"None\"),\n\t\t\t);\n\t\t\tconst reports = servers.map((server): Report => {\n\t\t\t\tconst { config } = server;\n\t\t\t\tconst status = statuses.find((one) => one.server === server.name);\n\t\t\t\tconst exposure = config.exposure ?? \"direct\";\n\t\t\t\tconst tools = status?.tools ?? [];\n\t\t\t\tconst overrides = tools.filter((tool) => tool.exposure !== exposure);\n\t\t\t\tconst state = status?.state ?? \"disabled\";\n\t\t\t\treturn {\n\t\t\t\t\tname: server.name,\n\t\t\t\t\tlevel: server.file === user ? \"user\" : \"project\",\n\t\t\t\t\tfile: server.file,\n\t\t\t\t\t...(server.override === undefined ? {} : { override: server.override }),\n\t\t\t\t\tenabled: config.enabled !== false,\n\t\t\t\t\texposure,\n\t\t\t\t\ttransport: \"url\" in config ? config.url : [config.command, ...(config.args ?? [])].join(\" \"),\n\t\t\t\t\tstate,\n\t\t\t\t\ttools: tools.map((tool) => tool.name),\n\t\t\t\t\t...(status?.skipped === undefined ? {} : { skipped: status.skipped }),\n\t\t\t\t\t...(overrides.length === 0\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { toolExposure: Object.fromEntries(overrides.map((tool) => [tool.name, tool.exposure])) }),\n\t\t\t\t\t...(status?.resources ? { resources: true as const } : {}),\n\t\t\t\t\t...(state !== \"connected\" && status?.error !== undefined ? { error: status.error } : {}),\n\t\t\t\t};\n\t\t\t});\n\t\t\tconst failed = errors.length > 0 || reports.some((report) => report.enabled && report.state !== \"connected\");\n\t\t\tif (failed)\n\t\t\t\tyield* Effect.sync(() => {\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t});\n\n\t\t\tif (json) return yield* writeOut(`${JSON.stringify({ servers: reports, errors }, null, 2)}\\n`);\n\t\t\tconst lines: string[] = [];\n\t\t\tif (reports.length === 0 && errors.length === 0)\n\t\t\t\tlines.push(`No MCP servers configured. Add them to ${user} or .codework/mcp.json.`);\n\t\t\tconst width = Math.max(0, ...reports.map((report) => report.name.length));\n\t\t\tfor (const report of reports) {\n\t\t\t\tlines.push(\n\t\t\t\t\t`${MARKS[report.state]} ${report.name.padEnd(width)} ${describe(report.state, report.tools.length, report.skipped)} (${report.exposure}, ${report.level})`,\n\t\t\t\t);\n\t\t\t\tconst detail = (line: string) => lines.push(` ${line}`);\n\t\t\t\tdetail(report.transport);\n\t\t\t\tif (report.override !== undefined) detail(`project override: ${report.override}`);\n\t\t\t\tif (report.tools.length > 0)\n\t\t\t\t\tdetail(\n\t\t\t\t\t\t`tools: ${report.tools\n\t\t\t\t\t\t\t.map((tool) => {\n\t\t\t\t\t\t\t\tconst exposure = report.toolExposure?.[tool];\n\t\t\t\t\t\t\t\treturn exposure === undefined ? tool : `${tool} [${exposure}]`;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\tif (report.resources) detail(\"offers resources\");\n\t\t\t\tif (report.error !== undefined) for (const line of report.error.split(\"\\n\")) detail(line);\n\t\t\t}\n\t\t\tfor (const error of errors) lines.push(`config error: ${error}`);\n\t\t\tyield* writeOut(`${lines.join(\"\\n\")}\\n`);\n\t\t});\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AA6BA,IAAA,eAAeA,QACd,IAAI,SAAS,IAAI,SAAS,MAC1B,OAAO,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE,QAAQ;CA2E9C,OAAO,OA1ES,OAAO,IAAI,aAAa;EACvC,MAAM,EAAE,MAAM,UAAU,SAAS,MAAM,MAAM,SAAS,WAAW,OAAO,WAAW;E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I,GAAG,OAAO,IAAI;EACzF;EACA,KAAK,MAAM,SAAS,QAAQ,MAAM,KAAK,iBAAiB,OAAO;EAC/D,OAAO,SAAS,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG;CACxC,CACoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
@@ -1,5 +1,5 @@
1
1
  import { i as Cmd, t as handler } from "./runtime-CK2CunDw.mjs";
2
- import { f as writeOut, i as reportFailure, t as InvalidInputError } from "./error-BE7K70v8.mjs";
2
+ import { f as writeOut, i as reportFailure, t as InvalidInputError } from "./error-BU5WVAb2.mjs";
3
3
  import { n as synced } from "./catalog-XfqtqMDz.mjs";
4
4
  import { Effect, Option } from "effect";
5
5
  import { ModelCatalog } from "@codeworksh/harness/effect";
@@ -27,4 +27,4 @@ var list_default = handler(Cmd.commands.models, Effect.fn("CLI.models.list")(fun
27
27
  //#endregion
28
28
  export { list_default as default };
29
29
 
30
- //# sourceMappingURL=list-Bf1hEU8J.mjs.map
30
+ //# sourceMappingURL=list-DDLes-GH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-DDLes-GH.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/models/list.ts"],"sourcesContent":["import { ModelCatalog } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { InvalidInputError, reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { synced } from \"./catalog.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.models,\n\tEffect.fn(\"CLI.models.list\")(function* ({ provider }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tyield* synced;\n\t\t\tconst catalog = yield* ModelCatalog.models;\n\t\t\tif (Option.isSome(provider)) {\n\t\t\t\tconst providerId = provider.value;\n\t\t\t\tif (!Object.hasOwn(catalog, providerId)) {\n\t\t\t\t\treturn yield* new InvalidInputError({\n\t\t\t\t\t\tmessage: `provider \"${providerId}\" is not in the catalog\\nhint: run \\`codework models providers\\``,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst sorted = Object.keys(catalog[providerId] ?? {}).sort((a, b) => a.localeCompare(b));\n\t\t\t\tyield* writeOut(sorted.map((modelId) => `${providerId}/${modelId}\\n`).join(\"\"));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tconst providers = Object.keys(catalog).sort((a, b) => a.localeCompare(b));\n\t\t\tfor (const providerId of providers) {\n\t\t\t\tconst providerModels = Object.keys(catalog[providerId] ?? {}).sort((a, b) => a.localeCompare(b));\n\t\t\t\tfor (const modelId of providerModels) {\n\t\t\t\t\tlines.push(`${providerId}/${modelId}\\n`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield* writeOut(lines.join(\"\"));\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAQA,IAAA,eAAeA,QACd,IAAI,SAAS,QACb,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,YAAY;CA2BrD,OAAO,OA1BS,OAAO,IAAI,aAAa;EACvC,OAAO;EACP,MAAM,UAAU,OAAO,aAAa;EACpC,IAAI,OAAO,OAAO,QAAQ,GAAG;GAC5B,MAAM,aAAa,SAAS;GAC5B,IAAI,CAAC,OAAO,OAAO,SAAS,UAAU,GACrC,OAAO,OAAO,IAAI,kBAAkB,EACnC,SAAS,aAAa,WAAW,kEAClC,CAAC;GAEF,MAAM,SAAS,OAAO,KAAK,QAAQ,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;GACvF,OAAO,SAAS,OAAO,KAAK,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;GAC9E;EACD;EAEA,MAAM,QAAkB,CAAC;EACzB,MAAM,YAAY,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;EACxE,KAAK,MAAM,cAAc,WAAW;GACnC,MAAM,iBAAiB,OAAO,KAAK,QAAQ,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;GAC/F,KAAK,MAAM,WAAW,gBACrB,MAAM,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG;EAEzC;EACA,OAAO,SAAS,MAAM,KAAK,EAAE,CAAC;CAC/B,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}