@codeworksh/cli 0.9.0-canary.167.1.g6ddcc8db → 0.9.0-canary.168.1.ge6d0f923
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{acp-CmtcmhuX.mjs → acp-C2GCSrJd.mjs} +6 -5
- package/acp-C2GCSrJd.mjs.map +1 -0
- package/{add-Bmholf85.mjs → add-Be7-HfBj.mjs} +2 -2
- package/{add-Bmholf85.mjs.map → add-Be7-HfBj.mjs.map} +1 -1
- package/{add-Ct20ZUEC.mjs → add-D2ly9-x3.mjs} +3 -3
- package/{add-Ct20ZUEC.mjs.map → add-D2ly9-x3.mjs.map} +1 -1
- package/{catalog-BJScfJLW.mjs → catalog-Dzi9__Rq.mjs} +2 -2
- package/{catalog-BJScfJLW.mjs.map → catalog-Dzi9__Rq.mjs.map} +1 -1
- package/categories-DYD_3Pt8.mjs +19 -0
- package/categories-DYD_3Pt8.mjs.map +1 -0
- package/{check-ki1450h-.mjs → check-DzxfN43i.mjs} +2 -2
- package/{check-ki1450h-.mjs.map → check-DzxfN43i.mjs.map} +1 -1
- package/{connect-KX-A0EzQ.mjs → connect-D4w0dmRc.mjs} +5 -5
- package/{connect-KX-A0EzQ.mjs.map → connect-D4w0dmRc.mjs.map} +1 -1
- package/{control-Cotypk4e.mjs → control-CFQeKIKx.mjs} +4 -4
- package/{control-Cotypk4e.mjs.map → control-CFQeKIKx.mjs.map} +1 -1
- package/create-Bt56MHKu.mjs +35 -0
- package/create-Bt56MHKu.mjs.map +1 -0
- package/{devices-BcuQ11QF.mjs → devices-DNzXKhNy.mjs} +3 -3
- package/{devices-BcuQ11QF.mjs.map → devices-DNzXKhNy.mjs.map} +1 -1
- package/disconnect-CHEHx_ic.mjs +2 -0
- package/{disconnect-CCI1DLJ0.mjs → disconnect-CXha4LTk.mjs} +4 -4
- package/{disconnect-CCI1DLJ0.mjs.map → disconnect-CXha4LTk.mjs.map} +1 -1
- package/disconnect-Cx0sydNl.mjs +19 -0
- package/disconnect-Cx0sydNl.mjs.map +1 -0
- package/discover-wWs8qDQd.mjs +35 -0
- package/discover-wWs8qDQd.mjs.map +1 -0
- package/{discovery-D2ftXE5a.mjs → discovery-C-ploGdg.mjs} +2 -2
- package/{discovery-D2ftXE5a.mjs.map → discovery-C-ploGdg.mjs.map} +1 -1
- package/{fork-DkYRL_nQ.mjs → fork-TUz05qSe.mjs} +3 -3
- package/{fork-DkYRL_nQ.mjs.map → fork-TUz05qSe.mjs.map} +1 -1
- package/{identity-Llk4K_8w.mjs → identity-Cjr43dhQ.mjs} +2 -2
- package/{identity-Llk4K_8w.mjs.map → identity-Cjr43dhQ.mjs.map} +1 -1
- package/index.mjs +49 -39
- package/index.mjs.map +1 -1
- package/{install-hs3tvWLA.mjs → install-BtoWHZoI.mjs} +2 -2
- package/{install-hs3tvWLA.mjs.map → install-BtoWHZoI.mjs.map} +1 -1
- package/{link-BzFGtDKJ.mjs → link-Cd6T22_n.mjs} +3 -3
- package/{link-BzFGtDKJ.mjs.map → link-Cd6T22_n.mjs.map} +1 -1
- package/{list-sLzs2Y7w.mjs → list-Bn5CvS1y.mjs} +3 -3
- package/{list-sLzs2Y7w.mjs.map → list-Bn5CvS1y.mjs.map} +1 -1
- package/{list-D1c5uzCc.mjs → list-CdS1_gFF.mjs} +2 -2
- package/{list-D1c5uzCc.mjs.map → list-CdS1_gFF.mjs.map} +1 -1
- package/list-D6ABpoQC.mjs +27 -0
- package/list-D6ABpoQC.mjs.map +1 -0
- package/{list-DhL_z5v2.mjs → list-DAA92mUG.mjs} +3 -3
- package/{list-DhL_z5v2.mjs.map → list-DAA92mUG.mjs.map} +1 -1
- package/{list-Dt0_ol5P.mjs → list-MiZ6rD_w.mjs} +3 -3
- package/{list-Dt0_ol5P.mjs.map → list-MiZ6rD_w.mjs.map} +1 -1
- package/{login-BxiN8frI.mjs → login-C_tBeHg6.mjs} +3 -3
- package/{login-BxiN8frI.mjs.map → login-C_tBeHg6.mjs.map} +1 -1
- package/login-DnOTWBy8.mjs +26 -0
- package/login-DnOTWBy8.mjs.map +1 -0
- package/{login-S-2L5YYB.mjs → login-Q_ezdpon.mjs} +3 -3
- package/{login-S-2L5YYB.mjs.map → login-Q_ezdpon.mjs.map} +1 -1
- package/{logout-BeMvfZkG.mjs → logout-BjL1W-0I.mjs} +3 -3
- package/{logout-BeMvfZkG.mjs.map → logout-BjL1W-0I.mjs.map} +1 -1
- package/{logout-CKcRACIf.mjs → logout-E_dRjl1L.mjs} +3 -3
- package/{logout-CKcRACIf.mjs.map → logout-E_dRjl1L.mjs.map} +1 -1
- package/package-BsCtRg3n.mjs +6 -0
- package/package-BsCtRg3n.mjs.map +1 -0
- package/package.json +4 -4
- package/{pair-BhGzBBV8.mjs → pair-BBneOJZJ.mjs} +3 -3
- package/{pair-BhGzBBV8.mjs.map → pair-BBneOJZJ.mjs.map} +1 -1
- package/{providers-DdBYxi9t.mjs → providers-BYnMGDs7.mjs} +3 -3
- package/{providers-DdBYxi9t.mjs.map → providers-BYnMGDs7.mjs.map} +1 -1
- package/reconnect-BKpud0ma.mjs +2 -0
- package/{refresh-BgQfD2zv.mjs → refresh-CvE_f1Fa.mjs} +3 -3
- package/{refresh-BgQfD2zv.mjs.map → refresh-CvE_f1Fa.mjs.map} +1 -1
- package/{refresh-Cy6abMk_.mjs → refresh-Dy9kI2El.mjs} +3 -3
- package/{refresh-Cy6abMk_.mjs.map → refresh-Dy9kI2El.mjs.map} +1 -1
- package/{relay-BmHXs1yg.mjs → relay-CO46Wh73.mjs} +3 -3
- package/{relay-BmHXs1yg.mjs.map → relay-CO46Wh73.mjs.map} +1 -1
- package/{relink-Dxg1kstB.mjs → relink-DxftNq9n.mjs} +3 -3
- package/{relink-Dxg1kstB.mjs.map → relink-DxftNq9n.mjs.map} +1 -1
- package/{reload-CUyG343t.mjs → reload-DRp3UlHQ.mjs} +3 -3
- package/{reload-CUyG343t.mjs.map → reload-DRp3UlHQ.mjs.map} +1 -1
- package/remove-Bad0ln8h.mjs +22 -0
- package/remove-Bad0ln8h.mjs.map +1 -0
- package/{remove-BXmNNX2f.mjs → remove-C0e5sHqb.mjs} +3 -3
- package/{remove-BXmNNX2f.mjs.map → remove-C0e5sHqb.mjs.map} +1 -1
- package/{remove-CJ__oofS.mjs → remove-CdcoheOp.mjs} +2 -2
- package/{remove-CJ__oofS.mjs.map → remove-CdcoheOp.mjs.map} +1 -1
- package/{restart-CMDZZJ4N.mjs → restart-CvkGtFq2.mjs} +4 -4
- package/{restart-CMDZZJ4N.mjs.map → restart-CvkGtFq2.mjs.map} +1 -1
- package/{revoke-DigrkMoL.mjs → revoke-DoMHa1vL.mjs} +3 -3
- package/{revoke-DigrkMoL.mjs.map → revoke-DoMHa1vL.mjs.map} +1 -1
- package/{run-BN0xfxh_.mjs → run-n_t47yPB.mjs} +8 -5
- package/run-n_t47yPB.mjs.map +1 -0
- package/{runtime-Q4G4z83G.mjs → runtime-CyXV7HH_.mjs} +152 -9
- package/runtime-CyXV7HH_.mjs.map +1 -0
- package/{serve-CfjS09-r.mjs → serve-BaNbYK1f.mjs} +27 -11
- package/serve-BaNbYK1f.mjs.map +1 -0
- package/service-CA6VAOdR.mjs +1652 -0
- package/service-CA6VAOdR.mjs.map +1 -0
- package/{service-B0O4PjbL.mjs → service-YVNwFMNf.mjs} +2 -2
- package/{service-B0O4PjbL.mjs.map → service-YVNwFMNf.mjs.map} +1 -1
- package/shared-CA47qIai.mjs +212 -0
- package/shared-CA47qIai.mjs.map +1 -0
- package/{shared-C2sMimyK.mjs → shared-CDJQxUb9.mjs} +4 -4
- package/{shared-C2sMimyK.mjs.map → shared-CDJQxUb9.mjs.map} +1 -1
- package/{shared-C4j4rGe4.mjs → shared-D_MVXtOf.mjs} +3 -3
- package/{shared-C4j4rGe4.mjs.map → shared-D_MVXtOf.mjs.map} +1 -1
- package/{start-DbCTFswo.mjs → start-D3lqmljh.mjs} +4 -4
- package/{start-DbCTFswo.mjs.map → start-D3lqmljh.mjs.map} +1 -1
- package/{status-CR_E6RiI.mjs → status-BoTZqXwd.mjs} +3 -3
- package/{status-CR_E6RiI.mjs.map → status-BoTZqXwd.mjs.map} +1 -1
- package/{status-Dcbdl6Sv.mjs → status-P0hOBrM6.mjs} +4 -4
- package/{status-Dcbdl6Sv.mjs.map → status-P0hOBrM6.mjs.map} +1 -1
- package/status-tYcs05sk.mjs +23 -0
- package/status-tYcs05sk.mjs.map +1 -0
- package/{stop-ML5Yeo_s.mjs → stop-BuDB-rqB.mjs} +4 -4
- package/{stop-ML5Yeo_s.mjs.map → stop-BuDB-rqB.mjs.map} +1 -1
- package/{update-BK_LdUUv.mjs → update-mWc5cR7q.mjs} +2 -2
- package/{update-BK_LdUUv.mjs.map → update-mWc5cR7q.mjs.map} +1 -1
- package/acp-CmtcmhuX.mjs.map +0 -1
- package/disconnect-DKi3PmC2.mjs +0 -2
- package/package-D_TWKUKk.mjs +0 -6
- package/package-D_TWKUKk.mjs.map +0 -1
- package/reconnect-DgUK2fwU.mjs +0 -2
- package/run-BN0xfxh_.mjs.map +0 -1
- package/runtime-Q4G4z83G.mjs.map +0 -1
- package/serve-CfjS09-r.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-CA47qIai.mjs","names":["Client.make","Service.connect","layer","ConnectorService.layer","ConnectorService.Service"],"sources":["../../src/cli/cmd/handlers/connect/shared.ts"],"sourcesContent":["/* @effect-diagnostics nodeBuiltinImport:off -- CLI OAuth flow opens a loopback listener and prompts on stdio. */\n/* @effect-diagnostics asyncFunction:off -- interactive loopback/prompt race wraps Promise callbacks. */\n/* @effect-diagnostics newPromise:off -- loopback HTTP server exposes Promise callbacks for Promise.race with stdin. */\n/* @effect-diagnostics preferSchemaOverJson:off -- CLI --json prints formatted JSON to stdout. */\n/* @effect-diagnostics abortControllerInEffect:off -- Promise.race aborts the losing loopback callback wait. */\nimport { createServer, type ServerResponse } from \"node:http\";\nimport { oauthErrorHtml, oauthSuccessHtml, openBrowser, promptLine } from \"@codeworksh/aikit/oauth/interactive\";\nimport type {\n\tConnectionSummary,\n\tConnectorCategory,\n\tConnectorKind,\n\tConnectorSpec,\n\tDevicePollResult,\n\tDeviceStartResult,\n\tOAuthStartResult,\n\tOwnership,\n\tStoredAuthType,\n} from \"@codeworksh/schema/connector\";\nimport { Duration, Effect, Option, Schema } from \"effect\";\nimport * as ConnectorService from \"../../../../connector/service.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport class ConnectCliError extends Schema.TaggedError<ConnectCliError>()(\"CLI.ConnectError\", {\n\tmessage: Schema.String,\n}) {}\n\nconst toCliError = (cause: unknown): ConnectCliError =>\n\tnew ConnectCliError({\n\t\tmessage:\n\t\t\ttypeof cause === \"object\" && cause !== null && \"message\" in cause && typeof cause.message === \"string\"\n\t\t\t\t? cause.message\n\t\t\t\t: String(cause),\n\t});\n\nconst mapErr = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, ConnectCliError, R> =>\n\teffect.pipe(Effect.mapError(toCliError));\n\nexport interface ConnectApi {\n\treadonly catalog: (input: {\n\t\treadonly kind?: ConnectorKind | undefined;\n\t\treadonly category?: string | undefined;\n\t\treadonly query?: string | undefined;\n\t\treadonly refresh?: boolean | undefined;\n\t}) => Effect.Effect<\n\t\t{\n\t\t\treadonly schemaVersion: 1;\n\t\t\treadonly generatedAt: string;\n\t\t\treadonly categories: ReadonlyArray<ConnectorCategory>;\n\t\t\treadonly connectors: ReadonlyArray<ConnectorSpec>;\n\t\t},\n\t\tConnectCliError\n\t>;\n\treadonly list: (input: {\n\t\treadonly kind?: ConnectorKind | undefined;\n\t\treadonly connectorId?: string | undefined;\n\t\treadonly enabled?: boolean | undefined;\n\t\treadonly includeEnv?: boolean | undefined;\n\t}) => Effect.Effect<ReadonlyArray<ConnectionSummary>, ConnectCliError>;\n\treadonly get: (ref: string) => Effect.Effect<ConnectionSummary, ConnectCliError>;\n\treadonly create: (input: {\n\t\treadonly connector: string;\n\t\treadonly slug?: string | undefined;\n\t\treadonly label?: string | undefined;\n\t\treadonly authType?: StoredAuthType | undefined;\n\t\treadonly ownership?: Ownership | undefined;\n\t}) => Effect.Effect<ConnectionSummary, ConnectCliError>;\n\treadonly remove: (ref: string) => Effect.Effect<boolean, ConnectCliError>;\n\treadonly setApiKey: (ref: string, apiKey: string) => Effect.Effect<ConnectionSummary, ConnectCliError>;\n\treadonly disconnect: (ref: string) => Effect.Effect<ConnectionSummary, ConnectCliError>;\n\treadonly oauthStart: (input: {\n\t\treadonly ref: string;\n\t\treadonly redirectUrl: string;\n\t}) => Effect.Effect<OAuthStartResult, ConnectCliError>;\n\treadonly oauthFinish: (input: {\n\t\treadonly state: string;\n\t\treadonly code: string;\n\t}) => Effect.Effect<ConnectionSummary, ConnectCliError>;\n\treadonly deviceStart: (input: {\n\t\treadonly ref: string;\n\t\treadonly enterpriseUrl?: string | undefined;\n\t}) => Effect.Effect<DeviceStartResult, ConnectCliError>;\n\treadonly devicePoll: (state: string) => Effect.Effect<DevicePollResult, ConnectCliError>;\n}\n\n/**\n * Runs an operation against either a running RPC server (`--server`) or the local `<home>/connections.db`.\n */\nexport const withConnectApi = <A, R = never>(\n\tserver: Option.Option<string>,\n\tfn: (api: ConnectApi) => Effect.Effect<A, ConnectCliError, R>,\n) =>\n\tEffect.gen(function* () {\n\t\tif (Option.isSome(server)) {\n\t\t\treturn yield* Effect.gen(function* () {\n\t\t\t\tconst rpc = yield* Client.make;\n\t\t\t\tconst api: ConnectApi = {\n\t\t\t\t\tcatalog: (input) => mapErr(rpc[\"connectors.catalog\"](input)),\n\t\t\t\t\tlist: (input) => mapErr(rpc[\"connections.list\"](input)),\n\t\t\t\t\tget: (ref) => mapErr(rpc[\"connections.get\"]({ ref })),\n\t\t\t\t\tcreate: (input) => mapErr(rpc[\"connections.create\"](input)),\n\t\t\t\t\tremove: (ref) => mapErr(rpc[\"connections.remove\"]({ ref }).pipe(Effect.map((r) => r.removed))),\n\t\t\t\t\tsetApiKey: (ref, apiKey) => mapErr(rpc[\"connections.setApiKey\"]({ ref, apiKey })),\n\t\t\t\t\tdisconnect: (ref) => mapErr(rpc[\"connections.disconnect\"]({ ref })),\n\t\t\t\t\toauthStart: (input) => mapErr(rpc[\"connections.oauth.start\"](input)),\n\t\t\t\t\toauthFinish: (input) => mapErr(rpc[\"connections.oauth.finish\"](input)),\n\t\t\t\t\tdeviceStart: (input) => mapErr(rpc[\"connections.oauth.deviceStart\"](input)),\n\t\t\t\t\tdevicePoll: (state) => mapErr(rpc[\"connections.oauth.devicePoll\"]({ state })),\n\t\t\t\t};\n\t\t\t\treturn yield* fn(api);\n\t\t\t}).pipe(Effect.scoped, Service.connect(server.value));\n\t\t}\n\n\t\tconst shared = yield* Cmd.spec;\n\t\tconst layer = ConnectorService.layer(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\t\treturn yield* Effect.gen(function* () {\n\t\t\tconst svc = yield* ConnectorService.Service;\n\t\t\tconst api: ConnectApi = {\n\t\t\t\tcatalog: (input) => mapErr(svc.catalog(input)),\n\t\t\t\tlist: (input) => mapErr(svc.list(input)),\n\t\t\t\tget: (ref) => mapErr(svc.get(ref)),\n\t\t\t\tcreate: (input) => mapErr(svc.create(input)),\n\t\t\t\tremove: (ref) => mapErr(svc.remove(ref)),\n\t\t\t\tsetApiKey: (ref, apiKey) => mapErr(svc.setApiKey(ref, apiKey)),\n\t\t\t\tdisconnect: (ref) => mapErr(svc.disconnect(ref)),\n\t\t\t\toauthStart: (input) => mapErr(svc.oauthStart(input)),\n\t\t\t\toauthFinish: (input) => mapErr(svc.oauthFinish(input)),\n\t\t\t\tdeviceStart: (input) => mapErr(svc.deviceStart(input)),\n\t\t\t\tdevicePoll: (state) => mapErr(svc.devicePoll(state)),\n\t\t\t};\n\t\t\treturn yield* fn(api);\n\t\t}).pipe(Effect.provide(layer));\n\t});\n\nconst replyHtml = (res: ServerResponse, status: number, html: string) =>\n\tres.writeHead(status, { \"content-type\": \"text/html; charset=utf-8\", \"cache-control\": \"no-store\" }).end(html);\n\nconst startLoopback = (opts: {\n\treadonly host: string;\n\treadonly redirectHost: string;\n\treadonly port: number;\n\treadonly path: string;\n}) =>\n\tnew Promise<{\n\t\treadonly redirectUrl: string;\n\t\treadonly wait: (expectedState: string, signal: AbortSignal) => Promise<string>;\n\t\treadonly close: () => void;\n\t}>((resolve, reject) => {\n\t\tconst server = createServer();\n\t\tlet pending:\n\t\t\t| { readonly state: string; readonly done: (code: string) => void; readonly fail: (err: Error) => void }\n\t\t\t| undefined;\n\n\t\tserver.on(\"request\", (req, res) => {\n\t\t\tconst addr = server.address();\n\t\t\tconst port = addr !== null && typeof addr === \"object\" ? addr.port : opts.port;\n\t\t\tconst base = `http://${opts.redirectHost}:${port}`;\n\t\t\tconst url = new URL(req.url ?? \"/\", base);\n\t\t\tif (url.pathname !== opts.path) return replyHtml(res, 404, oauthErrorHtml(\"Not found.\"));\n\t\t\tconst state = url.searchParams.get(\"state\");\n\t\t\tif (!pending || state !== pending.state) {\n\t\t\t\treturn replyHtml(res, 400, oauthErrorHtml(\"Invalid or expired OAuth state.\"));\n\t\t\t}\n\t\t\tconst current = pending;\n\t\t\tpending = undefined;\n\t\t\tconst error = url.searchParams.get(\"error\");\n\t\t\tconst code = url.searchParams.get(\"code\");\n\t\t\tif (error !== null) {\n\t\t\t\tconst desc = url.searchParams.get(\"error_description\") ?? error;\n\t\t\t\tcurrent.fail(new Error(desc));\n\t\t\t\treturn replyHtml(res, 200, oauthErrorHtml(\"Sign-in failed. You may close this window.\", desc));\n\t\t\t}\n\t\t\tif (code === null || code.length === 0) {\n\t\t\t\tcurrent.fail(new Error(\"Missing authorization code\"));\n\t\t\t\treturn replyHtml(res, 400, oauthErrorHtml(\"Missing authorization code.\"));\n\t\t\t}\n\t\t\tcurrent.done(code);\n\t\t\treturn replyHtml(res, 200, oauthSuccessHtml(\"Connected to CodeWork. You may close this window.\"));\n\t\t});\n\n\t\tserver.once(\"error\", (err) => reject(err));\n\t\tserver.listen(opts.port, opts.host, () => {\n\t\t\tconst addr = server.address();\n\t\t\tif (addr === null || typeof addr !== \"object\") {\n\t\t\t\tserver.close();\n\t\t\t\treject(new Error(\"Failed to bind loopback callback server\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve({\n\t\t\t\tredirectUrl: `http://${opts.redirectHost}:${addr.port}${opts.path}`,\n\t\t\t\twait: (expectedState, signal) =>\n\t\t\t\t\tnew Promise<string>((done, fail) => {\n\t\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\t\tfail(new Error(\"Cancelled\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\tif (pending?.state === expectedState) pending = undefined;\n\t\t\t\t\t\t\tfail(new Error(\"Cancelled\"));\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tpending = {\n\t\t\t\t\t\t\tstate: expectedState,\n\t\t\t\t\t\t\tdone: (code) => {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\tdone(code);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfail: (err) => {\n\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\tfail(err);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\tclose: () => {\n\t\t\t\t\tserver.close();\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t});\n\nexport interface AuthenticateOptions {\n\treadonly apiKey?: string | undefined;\n\treadonly device?: boolean | undefined;\n\treadonly enterpriseUrl?: string | undefined;\n\treadonly browser?: boolean | undefined;\n}\n\n/**\n * Runs the interactive authentication flow (API key, OAuth PKCE loopback raced with paste, or device code)\n * for an existing Connection via `api`.\n */\nexport const authenticateConnection = (\n\tapi: ConnectApi,\n\tconnection: ConnectionSummary,\n\tspec: ConnectorSpec | undefined,\n\toptions: AuthenticateOptions,\n): Effect.Effect<ConnectionSummary, ConnectCliError> =>\n\tEffect.gen(function* () {\n\t\tif (connection.authType === \"apikey\") {\n\t\t\tconst key =\n\t\t\t\toptions.apiKey ??\n\t\t\t\t(yield* Effect.tryPromise({\n\t\t\t\t\ttry: () =>\n\t\t\t\t\t\tpromptLine(\n\t\t\t\t\t\t\t`Enter API key for ${connection.uid}${spec?.auth.apikey?.keyUrl ? ` (${spec.auth.apikey.keyUrl})` : \"\"}: `,\n\t\t\t\t\t\t),\n\t\t\t\t\tcatch: toCliError,\n\t\t\t\t}));\n\t\t\treturn yield* api.setApiKey(connection.uid, key);\n\t\t}\n\n\t\tif (connection.authType !== \"oauth\") {\n\t\t\treturn connection;\n\t\t}\n\n\t\tconst oauthSpec = spec?.auth.oauth;\n\t\tconst useDevice =\n\t\t\toptions.device === true ||\n\t\t\t(oauthSpec !== undefined &&\n\t\t\t\t!oauthSpec.grants.includes(\"authorization_code\") &&\n\t\t\t\toauthSpec.grants.includes(\"device_code\"));\n\n\t\tif (useDevice) {\n\t\t\tconst started = yield* api.deviceStart({\n\t\t\t\tref: connection.uid,\n\t\t\t\tenterpriseUrl: options.enterpriseUrl,\n\t\t\t});\n\t\t\tprocess.stderr.write(`Open ${started.verificationUri} and enter code: ${started.userCode}\\n`);\n\t\t\tif (options.browser !== false) {\n\t\t\t\tvoid openBrowser(started.verificationUri, (err) => {\n\t\t\t\t\tprocess.stderr.write(`Failed to open browser: ${err.message}\\n`);\n\t\t\t\t});\n\t\t\t}\n\t\t\tlet intervalSeconds = Math.max(1, started.intervalSeconds);\n\t\t\twhile (true) {\n\t\t\t\tyield* Effect.sleep(Duration.seconds(intervalSeconds));\n\t\t\t\tconst polled = yield* api.devicePoll(started.state);\n\t\t\t\tif (polled.status === \"complete\") return polled.connection;\n\t\t\t\tif (polled.intervalSeconds !== undefined && polled.intervalSeconds > 0) {\n\t\t\t\t\tintervalSeconds = polled.intervalSeconds;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Authorization code + PKCE with loopback callback raced against manual redirect paste.\n\t\tconst isCodex = oauthSpec?.handler === \"openai-codex\";\n\t\tconst listener = yield* Effect.tryPromise({\n\t\t\ttry: () =>\n\t\t\t\tstartLoopback(\n\t\t\t\t\tisCodex\n\t\t\t\t\t\t? { host: \"127.0.0.1\", redirectHost: \"localhost\", port: 1455, path: \"/auth/callback\" }\n\t\t\t\t\t\t: { host: \"127.0.0.1\", redirectHost: \"127.0.0.1\", port: 0, path: \"/oauth/callback\" },\n\t\t\t\t),\n\t\t\tcatch: toCliError,\n\t\t});\n\n\t\ttry {\n\t\t\tconst started = yield* api.oauthStart({\n\t\t\t\tref: connection.uid,\n\t\t\t\tredirectUrl: listener.redirectUrl,\n\t\t\t});\n\t\t\tprocess.stderr.write(`Authorize ${connection.uid} in your browser:\\n${started.authorizeUrl}\\n`);\n\t\t\tif (options.browser !== false) {\n\t\t\t\tvoid openBrowser(started.authorizeUrl, (err) => {\n\t\t\t\t\tprocess.stderr.write(`Failed to open browser: ${err.message}\\n`);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst controller = new AbortController();\n\t\t\tconst code = yield* Effect.tryPromise({\n\t\t\t\ttry: async () => {\n\t\t\t\t\tconst callbackPromise = listener.wait(started.state, controller.signal);\n\t\t\t\t\tif (!process.stdin.isTTY) {\n\t\t\t\t\t\treturn await callbackPromise;\n\t\t\t\t\t}\n\t\t\t\t\tconst manualPromise = promptLine(\"Waiting for browser callback (or paste redirected URL / code here): \");\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn await Promise.race([callbackPromise, manualPromise]);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcatch: toCliError,\n\t\t\t});\n\n\t\t\treturn yield* api.oauthFinish({ state: started.state, code });\n\t\t} finally {\n\t\t\tlistener.close();\n\t\t}\n\t});\n\nexport const printJson = (value: unknown) => writeOut(`${JSON.stringify(value, null, 2)}\\n`);\n\nexport const formatConnectionLine = (c: ConnectionSummary): string => {\n\tconst flags: Array<string> = [c.status, c.sourceLabel];\n\tif (c.isDefault) flags.push(\"default\");\n\tif (!c.enabled) flags.push(\"disabled\");\n\tif (c.readOnly) flags.push(\"read-only\");\n\tconst account = c.accountLabel ? ` [${c.accountLabel}]` : \"\";\n\treturn `${c.uid}${account} (${flags.join(\", \")})`;\n};\n"],"mappings":";;;;;;;;AAyBA,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CAAC,oBAAoB,EAC9F,SAAS,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,cAAc,UACnB,IAAI,gBAAgB,EACnB,SACC,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,SAAS,OAAO,MAAM,YAAY,WAC3F,MAAM,UACN,OAAO,KAAK,EACjB,CAAC;AAEF,MAAM,UAAmB,WACxB,OAAO,KAAK,OAAO,SAAS,UAAU,CAAC;;;;AAoDxC,MAAa,kBACZ,QACA,OAEA,OAAO,IAAI,aAAa;CACvB,IAAI,OAAO,OAAO,MAAM,GACvB,OAAO,OAAO,OAAO,IAAI,aAAa;EACrC,MAAM,MAAM,OAAOA;EAcnB,OAAO,OAAO,GAAG;GAZhB,UAAU,UAAU,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC;GAC3D,OAAO,UAAU,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC;GACtD,MAAM,QAAQ,OAAO,IAAI,kBAAkB,CAAC,EAAE,IAAI,CAAC,CAAC;GACpD,SAAS,UAAU,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC;GAC1D,SAAS,QAAQ,OAAO,IAAI,qBAAqB,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK,MAAM,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,eAAe,QAAQ;GAC/C,QAAQ,OAAO,MAAM,2BAA2B,IAAI,QAAQ,GAAG;EAChE,CAAC;EAGF,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,OAAO,OAAO,OAAO,WAAW;GACrC,KAAK,YAAY;IAChB,MAAM,kBAAkB,SAAS,KAAK,QAAQ,OAAO,WAAW,MAAM;IACtE,IAAI,CAAC,QAAQ,MAAM,OAClB,OAAO,MAAM;IAEd,MAAM,gBAAgB,WAAW,sEAAsE;IACvG,IAAI;KACH,OAAO,MAAM,QAAQ,KAAK,CAAC,iBAAiB,aAAa,CAAC;IAC3D,UAAU;KACT,WAAW,MAAM;IAClB;GACD;GACA,OAAO;EACR,CAAC;EAED,OAAO,OAAO,IAAI,YAAY;GAAE,OAAO,QAAQ;GAAO;EAAK,CAAC;CAC7D,UAAU;EACT,SAAS,MAAM;CAChB;AACD,CAAC;AAEF,MAAa,aAAa,UAAmB,SAAS,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,EAAE,GAAG;AAE3F,MAAa,wBAAwB,MAAiC;CACrE,MAAM,QAAuB,CAAC,EAAE,QAAQ,EAAE,WAAW;CACrD,IAAI,EAAE,WAAW,MAAM,KAAK,SAAS;CACrC,IAAI,CAAC,EAAE,SAAS,MAAM,KAAK,UAAU;CACrC,IAAI,EAAE,UAAU,MAAM,KAAK,WAAW;CACtC,MAAM,UAAU,EAAE,eAAe,KAAK,EAAE,aAAa,KAAK;CAC1D,OAAO,GAAG,EAAE,MAAM,QAAQ,KAAK,MAAM,KAAK,IAAI,EAAE;AACjD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as OAuthError, t as InvalidInputError } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd } from "./runtime-
|
|
3
|
-
import { t as connect } from "./service-
|
|
2
|
+
import { i as Cmd } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { t as connect } from "./service-YVNwFMNf.mjs";
|
|
4
4
|
import { Effect, Option, Path } from "effect";
|
|
5
5
|
import { Global } from "@codeworksh/harness/effect";
|
|
6
|
-
import { checkOAuthProvider, oauthProviderLabel, summarizeGitHubCopilot, summarizeOpenAICodex } from "@codeworksh/aikit/oauth/summary";
|
|
7
6
|
import { GitHubCopilotOAuthClient, JsonGitHubCopilotAuthStorage } from "@codeworksh/aikit/oauth/github/copilot";
|
|
8
7
|
import { JsonOpenAICodexAuthStorage, OpenAICodexOAuthClient } from "@codeworksh/aikit/oauth/openai/codex";
|
|
8
|
+
import { checkOAuthProvider, oauthProviderLabel, summarizeGitHubCopilot, summarizeOpenAICodex } from "@codeworksh/aikit/oauth/summary";
|
|
9
9
|
import { openBrowser, promptLine } from "@codeworksh/aikit/oauth/interactive";
|
|
10
10
|
//#region src/cli/cmd/handlers/auth/shared.ts
|
|
11
11
|
const announce = (info, browser) => {
|
|
@@ -111,4 +111,4 @@ const withServer = (url, program) => program.pipe(connect(url));
|
|
|
111
111
|
//#endregion
|
|
112
112
|
export { oauthProviderLabel as a, makeOps as i, attempt as n, selectProvider as o, localOps as r, withServer as s, assertServerScope as t };
|
|
113
113
|
|
|
114
|
-
//# sourceMappingURL=shared-
|
|
114
|
+
//# sourceMappingURL=shared-CDJQxUb9.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-CDJQxUb9.mjs","names":["Service.connect"],"sources":["../../src/cli/cmd/handlers/auth/shared.ts"],"sourcesContent":["/* @effect-diagnostics nodeBuiltinImport:off -- OAuth login opens the system browser. */\n/* @effect-diagnostics globalDate:off -- Stored expiry timestamps are rendered for the user. */\n/* oxlint-disable effecttsgo/async-function -- Aikit OAuth callbacks require Promise-returning functions. */\nimport {\n\tGitHubCopilotOAuthClient,\n\tJsonGitHubCopilotAuthStorage,\n\ttype GitHubCopilotAuthStorage,\n} from \"@codeworksh/aikit/oauth/github/copilot\";\nimport {\n\tJsonOpenAICodexAuthStorage,\n\tOpenAICodexOAuthClient,\n\ttype OpenAICodexAuthStorage,\n} from \"@codeworksh/aikit/oauth/openai/codex\";\nimport { openBrowser, promptLine } from \"@codeworksh/aikit/oauth/interactive\";\nimport {\n\tcheckOAuthProvider,\n\toauthProviderLabel,\n\tsummarizeGitHubCopilot,\n\tsummarizeOpenAICodex,\n\ttype OAuthSummary,\n} from \"@codeworksh/aikit/oauth/summary\";\nimport { Global } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport * as Client from \"../../../../server/client.ts\";\nimport * as Service from \"../../../service.ts\";\nimport type * as Contract from \"../../../../server/contract.ts\";\nimport { InvalidInputError, OAuthError } from \"../../../error.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport type Provider = Contract.OAuthProvider;\n\n// The wire shape and aikit's summary are the same record.\nexport type Summary = Contract.OAuthInfo & OAuthSummary;\n\nconst announce = (\n\tinfo: { url: string; userCode?: string | undefined; instructions?: string | undefined },\n\tbrowser: boolean,\n): void => {\n\tprocess.stderr.write(\n\t\t`${info.instructions ?? \"Complete authentication in your browser.\"}\\n${\n\t\t\tinfo.userCode === undefined ? \"\" : `Enter code: ${info.userCode}\\n`\n\t\t}${info.url}\\n`,\n\t);\n\tif (browser) {\n\t\tvoid openBrowser(info.url, (error) => void process.stderr.write(`Failed to open browser: ${error.message}\\n`));\n\t}\n};\n\nexport interface LoginOptions {\n\treadonly browser: boolean;\n\treadonly device: boolean;\n\treadonly enterprise: Option.Option<string>;\n\treadonly enableModels: boolean;\n}\n\nexport interface Ops {\n\treadonly path: string;\n\treadonly login: (options: LoginOptions) => Promise<{ wire: Contract.OAuthCredentials; summary: Summary }>;\n\treadonly stored: () => Promise<Summary | undefined>;\n\treadonly refreshed: () => Promise<Summary | undefined>;\n\treadonly logout: () => Promise<void>;\n}\n\n/** Holds nothing: a server's credentials live on the server, not on this disk. */\nconst transient: OpenAICodexAuthStorage & GitHubCopilotAuthStorage = {\n\tget: async () => undefined,\n\tset: async () => {},\n\tclear: async () => {},\n};\n\nconst codexOps = (storage: OpenAICodexAuthStorage, path: string): Ops => {\n\tconst client = new OpenAICodexOAuthClient({ storage });\n\treturn {\n\t\tpath,\n\t\tlogin: async (options) => {\n\t\t\tconst credentials = await client.login({\n\t\t\t\tdevice: options.device,\n\t\t\t\tonAuth: (info) => announce(info, options.browser),\n\t\t\t\tonProgress: (message) => void process.stderr.write(`${message}\\n`),\n\t\t\t\tonPrompt: (prompt) => promptLine(prompt.message),\n\t\t\t});\n\t\t\treturn { wire: { provider: \"openai-codex\", ...credentials }, summary: summarizeOpenAICodex(credentials) };\n\t\t},\n\t\tstored: async () => {\n\t\t\tconst credentials = await storage.get();\n\t\t\treturn credentials && summarizeOpenAICodex(credentials);\n\t\t},\n\t\trefreshed: async () => {\n\t\t\tconst credentials = await client.getCredentials();\n\t\t\treturn credentials && summarizeOpenAICodex(credentials);\n\t\t},\n\t\tlogout: () => client.logout(),\n\t};\n};\n\nconst copilotOps = (storage: GitHubCopilotAuthStorage, path: string): Ops => {\n\tconst client = new GitHubCopilotOAuthClient({ storage });\n\tconst read = async () => {\n\t\tconst credentials = await storage.get();\n\t\treturn credentials && summarizeGitHubCopilot(credentials);\n\t};\n\treturn {\n\t\tpath,\n\t\tlogin: async (options) => {\n\t\t\tconst credentials = await client.login({\n\t\t\t\t...(Option.isSome(options.enterprise) && { enterpriseUrl: options.enterprise.value }),\n\t\t\t\tenableModels: options.enableModels,\n\t\t\t\tonAuth: (info) => announce(info, options.browser),\n\t\t\t\tonProgress: (message) => void process.stderr.write(`${message}\\n`),\n\t\t\t});\n\t\t\treturn { wire: { provider: \"github-copilot\", ...credentials }, summary: summarizeGitHubCopilot(credentials) };\n\t\t},\n\t\tstored: read,\n\t\t// GitHub OAuth tokens never expire, so there is nothing to refresh.\n\t\trefreshed: read,\n\t\tlogout: () => client.logout(),\n\t};\n};\n\nexport const makeOps = (provider: Provider, options: { path?: string | undefined; persist?: boolean } = {}): Ops => {\n\tconst file = options.path === undefined ? {} : { path: options.path };\n\tif (provider === \"openai-codex\") {\n\t\tconst storage = options.persist === false ? undefined : new JsonOpenAICodexAuthStorage(file);\n\t\treturn codexOps(storage ?? transient, storage?.path ?? \"\");\n\t}\n\tconst storage = options.persist === false ? undefined : new JsonGitHubCopilotAuthStorage(file);\n\treturn copilotOps(storage ?? transient, storage?.path ?? \"\");\n};\n\nexport const attempt = <A>(message: string, run: () => Promise<A>) =>\n\tEffect.tryPromise({ try: run, catch: (cause) => new OAuthError({ message, cause }) });\n\n/** The provider named by the two mutually exclusive flags. */\nexport const selectProvider = (flags: {\n\treadonly openaiCodex: boolean;\n\treadonly githubCopilot: boolean;\n}): Effect.Effect<Provider, InvalidInputError> => {\n\tconst checked = checkOAuthProvider(flags);\n\treturn checked.ok\n\t\t? Effect.succeed(checked.provider)\n\t\t: Effect.fail(new InvalidInputError({ message: checked.message }));\n};\n\n/** Reject the local credential file when the credentials live on a server. */\nexport const assertServerScope = (authFile: Option.Option<string>) =>\n\tOption.isSome(authFile)\n\t\t? Effect.fail(new InvalidInputError({ message: \"--auth-file belongs on codework serve when using --server\" }))\n\t\t: Effect.void;\n\n/** Credential operations against this machine's auth.json. */\nexport const localOps = (provider: Provider, authFile: Option.Option<string>) =>\n\tEffect.gen(function* () {\n\t\tconst shared = yield* Cmd.spec;\n\t\tconst path = yield* Path.Path;\n\t\tconst file = Option.isSome(authFile)\n\t\t\t? authFile.value\n\t\t\t: Option.isSome(shared.home)\n\t\t\t\t? path.join((yield* Global.resolve({ home: shared.home.value })).home, \"aikit\", \"auth.json\")\n\t\t\t\t: undefined;\n\t\treturn makeOps(provider, file === undefined ? {} : { path: file });\n\t});\n\n/** Run an effect against the RPC server at `url`, discharging the client. */\nexport const withServer = <A, E, R>(url: string, program: Effect.Effect<A, E, R>) => program.pipe(Service.connect(url));\n\nexport { Client, oauthProviderLabel };\n"],"mappings":";;;;;;;;;;AAkCA,MAAM,YACL,MACA,YACU;CACV,QAAQ,OAAO,MACd,GAAG,KAAK,gBAAg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AAa;CACvB,MAAM,SAAS,OAAO,IAAI;CAC1B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,OAAO,OAAO,OAAO,QAAQ,IAChC,SAAS,QACT,OAAO,OAAO,OAAO,IAAI,IACxB,KAAK,MAAM,OAAO,OAAO,QAAQ,EAAE,MAAM,OAAO,KAAK,MAAM,CAAC,EAAA,CAAG,MAAM,SAAS,WAAW,IACzF,KAAA;CACJ,OAAO,QAAQ,UAAU,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC;AAClE,CAAC;;AAGF,MAAa,cAAuB,KAAa,YAAoC,QAAQ,KAAKA,QAAgB,GAAG,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as InvalidInputError } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd } from "./runtime-
|
|
2
|
+
import { i as Cmd } from "./runtime-CyXV7HH_.mjs";
|
|
3
3
|
import { n as read } from "./jsonc-BtRExpz3.mjs";
|
|
4
4
|
import { Effect, Option, Path, Predicate } from "effect";
|
|
5
5
|
import { Global, McpConfig, McpOAuth, Settings } from "@codeworksh/harness/effect";
|
|
@@ -70,7 +70,7 @@ const oauthServer = Effect.fn("CLI.mcp.oauthServer")(function* (name) {
|
|
|
70
70
|
}
|
|
71
71
|
const config = entry.config;
|
|
72
72
|
if (!("url" in config)) return yield* new InvalidInputError({ message: `MCP server "${name}" runs over stdio; only HTTP servers sign in` });
|
|
73
|
-
if (config.auth !== void 0) return yield* new InvalidInputError({ message: `MCP server "${name}" sends the credential of provider "${config.auth.provider}"; sign in to the provider with codework auth login` });
|
|
73
|
+
if (config.auth !== void 0) return yield* new InvalidInputError({ message: "connection" in config.auth ? `MCP server "${name}" uses connector connection "${config.auth.connection}"; sign in with codework connect login ${config.auth.connection}` : `MCP server "${name}" sends the credential of provider "${config.auth.provider}"; sign in to the provider with codework auth login` });
|
|
74
74
|
if (Object.keys(config.headers ?? {}).some((header) => header.toLowerCase() === "authorization")) return yield* new InvalidInputError({ message: `MCP server "${name}" sends its own Authorization header; remove it to sign in with OAuth` });
|
|
75
75
|
return {
|
|
76
76
|
store: McpOAuth.store(home),
|
|
@@ -85,4 +85,4 @@ const oauthServer = Effect.fn("CLI.mcp.oauthServer")(function* (name) {
|
|
|
85
85
|
//#endregion
|
|
86
86
|
export { readServers as a, oauthServer as i, configured as n, describe as r, MARKS as t };
|
|
87
87
|
|
|
88
|
-
//# sourceMappingURL=shared-
|
|
88
|
+
//# sourceMappingURL=shared-D_MVXtOf.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-D_MVXtOf.mjs","names":["Jsonc.read"],"sources":["../../src/cli/cmd/handlers/mcp/shared.ts"],"sourcesContent":["import { type EventList, Global, type Mcp, McpConfig, McpOAuth, Settings } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path, Predicate } from \"effect\";\nimport { InvalidInputError } from \"../../../error.ts\";\nimport * as Jsonc from \"../../../jsonc.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\n/**\n * Where this directory's `mcp.json` files are: the user one in the home, or the `--user-config-dir`\n * that replaces it, and the project's under the nearest `.codework`, or this directory's when there\n * is none. Then what they configure.\n */\nexport const configured = Effect.fn(\"CLI.mcp.configured\")(function* () {\n\tconst shared = yield* Cmd.spec;\n\tconst path = yield* Path.Path;\n\tconst hostCwd = path.resolve(\".\");\n\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\tconst root = yield* Settings.projectRoot(hostCwd, paths.home);\n\tconst userDir = Option.isNone(shared.userConfigDir)\n\t\t? paths.home\n\t\t: Settings.userConfigDir(shared.userConfigDir.value, hostCwd);\n\tconst loaded = yield* McpConfig.load({ userDir, root });\n\treturn {\n\t\thome: paths.home,\n\t\tauthFile: Global.authFile(Option.isNone(shared.home) ? undefined : paths.home),\n\t\thostCwd,\n\t\troot,\n\t\tuser: path.join(userDir, \"mcp.json\"),\n\t\tproject: path.join(root ?? hostCwd, Global.appConfigDir, \"mcp.json\"),\n\t\t...loaded,\n\t};\n});\n\nexport const MARKS: Record<Mcp.State, string> = {\n\tconnected: \"✓\",\n\tauthenticate: \"⚠\",\n\tfailed: \"✗\",\n\tconnecting: \"○\",\n\tdisconnected: \"○\",\n\tdisabled: \"○\",\n};\n\nconst plural = (count: number, noun: string) => `${count} ${noun}${count === 1 ? \"\" : \"s\"}`;\n\n/** A server's state as the commands print it, with the tools its listing left out. */\nexport const describe = (state: Mcp.State, tools: number, skipped?: EventList.McpSkipped) => {\n\tif (state !== \"connected\") return state;\n\tconst connected = `connected, ${plural(tools, \"tool\")}`;\n\tif (skipped === undefined) return connected;\n\tconst left = [...skipped.names, ...(skipped.unnamed === 0 ? [] : [plural(skipped.unnamed, \"unnamed tool\")])];\n\treturn `${connected} — skipped ${left.join(\", \")}`;\n};\n\n/** The `mcpServers` of one `mcp.json`, and the text an edit rewrites. */\nexport const readServers = Effect.fn(\"CLI.mcp.readServers\")(function* (path: string) {\n\tconst { source, document } = yield* Jsonc.read(path, \"mcp.json\");\n\tconst servers = document.mcpServers ?? {};\n\tif (!Predicate.isObject(servers) || Array.isArray(servers))\n\t\treturn yield* new InvalidInputError({ message: `${path}: expected an object with an \"mcpServers\" object` });\n\treturn { source, servers: servers as Record<string, unknown> };\n});\n\n/**\n * The OAuth server `name` names in the `mcp.json` this directory reads, the user file and the\n * project's, and the credential store of the home. A server that sends a credential of its own\n * never signs in.\n */\nexport const oauthServer = Effect.fn(\"CLI.mcp.oauthServer\")(function* (name: string) {\n\tconst { home, servers, errors } = yield* configured();\n\tconst entry = servers.find((server) => server.name === name);\n\tif (entry === undefined) {\n\t\tconst problems = errors.length === 0 ? \"\" : `\\n${errors.join(\"\\n\")}`;\n\t\treturn yield* new InvalidInputError({ message: `no MCP server named \"${name}\" in mcp.json${problems}` });\n\t}\n\tconst config = entry.config;\n\tif (!(\"url\" in config))\n\t\treturn yield* new InvalidInputError({\n\t\t\tmessage: `MCP server \"${name}\" runs over stdio; only HTTP servers sign in`,\n\t\t});\n\tif (config.auth !== undefined)\n\t\treturn yield* new InvalidInputError({\n\t\t\tmessage:\n\t\t\t\t\"connection\" in config.auth\n\t\t\t\t\t? `MCP server \"${name}\" uses connector connection \"${config.auth.connection}\"; sign in with codework connect login ${config.auth.connection}`\n\t\t\t\t\t: `MCP server \"${name}\" sends the credential of provider \"${config.auth.provider}\"; sign in to the provider with codework auth login`,\n\t\t});\n\tif (Object.keys(config.headers ?? {}).some((header) => header.toLowerCase() === \"authorization\"))\n\t\treturn yield* new InvalidInputError({\n\t\t\tmessage: `MCP server \"${name}\" sends its own Authorization header; remove it to sign in with OAuth`,\n\t\t});\n\treturn {\n\t\tstore: McpOAuth.store(home),\n\t\tserver: { name, url: config.url, oauth: config.oauth },\n\t\tconfig,\n\t};\n});\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,aAAa,OAAO,GAAG,oBAAoB,CAAC,CAAC,aAAa;CACtE,MAAM,SAAS,OAAO,IAAI;CAC1B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,UAAU,KAAK,QAAQ,GAAG;CAChC,MAAM,QAAQ,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,KAAK,MAAM,CAAC;CACjG,MAAM,OAAO,OAAO,SAAS,YAAY,SAAS,MAAM,IAAI;CAC5D,MAAM,UAAU,OAAO,OAAO,OAAO,aAAa,IAC/C,MAAM,OACN,SAAS,cAAc,OAAO,cAAc,OAAO,OAAO;CAC7D,MAAM,SAAS,OAAO,UAAU,KAAK;EAAE;EAAS;CAAK,CAAC;CACtD,OAAO;EACN,MAAM,MAAM;EACZ,UAAU,OAAO,SAAS,OAAO,OAAO,OAAO,IAAI,IAAI,KAAA,IAAY,MAAM,IAAI;EAC7E;EACA;EACA,MAAM,KAAK,KAAK,SAAS,UAAU;EACnC,SAAS,KAAK,KAAK,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;CACA,MAAM,SAAS,MAAM;CACrB,IAAI,EAAE,SAAS,SACd,OAAO,OAAO,IAAI,kBAAkB,EACnC,SAAS,eAAe,KAAK,8CAC9B,CAAC;CACF,IAAI,OAAO,SAAS,KAAA,GACnB,OAAO,OAAO,IAAI,kBAAkB,EACnC,SACC,gBAAgB,OAAO,OACpB,eAAe,KAAK,+BAA+B,OAAO,KAAK,WAAW,yCAAyC,OAAO,KAAK,eAC/H,eAAe,KAAK,sCAAsC,OAAO,KAAK,SAAS,qDACpF,CAAC;CACF,IAAI,OAAO,KAAK,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,WAAW,OAAO,YAAY,MAAM,eAAe,GAC9F,OAAO,OAAO,IAAI,kBAAkB,EACnC,SAAS,eAAe,KAAK,uEAC9B,CAAC;CACF,OAAO;EACN,OAAO,SAAS,MAAM,IAAI;EAC1B,QAAQ;GAAE;GAAM,KAAK,OAAO;GAAK,OAAO,OAAO;EAAM;EACrD;CACD;AACD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { r as options } from "./service-
|
|
4
|
-
import { n as ensure } from "./discovery-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { r as options } from "./service-YVNwFMNf.mjs";
|
|
4
|
+
import { n as ensure } from "./discovery-C-ploGdg.mjs";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/service/start.ts
|
|
7
7
|
var start_default = handler(Cmd.commands.service.commands.start, Effect.fn("CLI.service.start")(function* ({ host, port }) {
|
|
@@ -18,4 +18,4 @@ var start_default = handler(Cmd.commands.service.commands.start, Effect.fn("CLI.
|
|
|
18
18
|
//#endregion
|
|
19
19
|
export { start_default as default };
|
|
20
20
|
|
|
21
|
-
//# sourceMappingURL=start-
|
|
21
|
+
//# sourceMappingURL=start-D3lqmljh.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-
|
|
1
|
+
{"version":3,"file":"start-D3lqmljh.mjs","names":["Runtime.handler","options","Service.options","Discovery.ensure"],"sources":["../../src/cli/cmd/handlers/service/start.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Discovery from \"../../../../server/discovery.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.service.commands.start,\n\tEffect.fn(\"CLI.service.start\")(function* ({ host, port }) {\n\t\tconst options = yield* Service.options(yield* Cmd.spec, { host, port });\n\t\tconst server = yield* Discovery.ensure({ ...options, replace: true });\n\t\tyield* writeOut(`${server.url}\\n`);\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;;AAQA,IAAA,gBAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,OAC9B,OAAO,GAAG,mBAAmB,CAAC,CAAC,WAAW,EAAE,MAAM,QAAQ;CACzD,MAAMC,YAAU,OAAOC,QAAgB,OAAO,IAAI,MAAM;EAAE;EAAM;CAAK,CAAC;CACtE,MAAM,SAAS,OAAOC,OAAiB;EAAE,GAAGF;EAAS,SAAS;CAAK,CAAC;CACpE,OAAO,SAAS,GAAG,OAAO,IAAI,GAAG;AAClC,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as reportFailure, g as make, m as writeOut, n as OAuthError } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { a as oauthProviderLabel, n as attempt, o as selectProvider, r as localOps, s as withServer, t as assertServerScope } from "./shared-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { a as oauthProviderLabel, n as attempt, o as selectProvider, r as localOps, s as withServer, t as assertServerScope } from "./shared-CDJQxUb9.mjs";
|
|
4
4
|
import { Effect, Option } from "effect";
|
|
5
5
|
import { formatOAuthSummary, oauthNotice } from "@codeworksh/aikit/oauth/summary";
|
|
6
6
|
//#region src/cli/cmd/handlers/auth/status.ts
|
|
@@ -28,4 +28,4 @@ var status_default = handler(Cmd.commands.auth.commands.status, Effect.fn("CLI.a
|
|
|
28
28
|
//#endregion
|
|
29
29
|
export { status_default as default };
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=status-
|
|
31
|
+
//# sourceMappingURL=status-BoTZqXwd.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-
|
|
1
|
+
{"version":3,"file":"status-BoTZqXwd.mjs","names":["Runtime.handler","Client.make"],"sources":["../../src/cli/cmd/handlers/auth/status.ts"],"sourcesContent":["import { formatOAuthSummary, oauthNotice } from \"@codeworksh/aikit/oauth/summary\";\nimport { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { OAuthError, reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport {\n\tassertServerScope,\n\tattempt,\n\tClient,\n\tlocalOps,\n\toauthProviderLabel,\n\tselectProvider,\n\twithServer,\n} from \"./shared.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.auth.commands.status,\n\tEffect.fn(\"CLI.auth.status\")(function* ({ server, openaiCodex, githubCopilot, authFile, json }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst provider = yield* selectProvider({ openaiCodex, githubCopilot });\n\t\t\tconst name = oauthProviderLabel(provider);\n\n\t\t\tif (Option.isSome(server)) {\n\t\t\t\tyield* assertServerScope(authFile);\n\t\t\t\treturn yield* withServer(\n\t\t\t\t\tserver.value,\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst rpc = yield* Client.make;\n\t\t\t\t\t\tconst info = yield* rpc[\"auth.status\"]({ provider });\n\t\t\t\t\t\tif (info === null) {\n\t\t\t\t\t\t\treturn yield* new OAuthError({ message: oauthNotice(\"missing\", provider, \"the server\") });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield* writeOut(formatOAuthSummary(info, { json }));\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst ops = yield* localOps(provider, authFile);\n\t\t\tconst summary = yield* attempt(`failed to read ${name} credentials`, () => ops.stored());\n\t\t\tif (summary === undefined) {\n\t\t\t\treturn yield* new OAuthError({ message: oauthNotice(\"missing\", provider, ops.path) });\n\t\t\t}\n\t\t\tyield* writeOut(formatOAuthSummary(summary, { json }));\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAgBA,IAAA,iBAAeA,QACd,IAAI,SAAS,KAAK,SAAS,QAC3B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,QAAQ,aAAa,eAAe,UAAU,QAAQ;CA4B/F,OAAO,OA3BS,OAAO,IAAI,aAAa;EACvC,MAAM,WAAW,OAAO,eAAe;GAAE;GAAa;EAAc,CAAC;EACrE,MAAM,OAAO,mBAAmB,QAAQ;EAExC,IAAI,OAAO,OAAO,MAAM,GAAG;GAC1B,OAAO,kBAAkB,QAAQ;GACjC,OAAO,OAAO,WACb,OAAO,OACP,OAAO,IAAI,aAAa;IAEvB,MAAM,OAAO,QAAO,OADDC,KAAAA,CACK,cAAc,CAAC,EAAE,SAAS,CAAC;IACnD,IAAI,SAAS,MACZ,OAAO,OAAO,IAAI,WAAW,EAAE,SAAS,YAAY,WAAW,UAAU,YAAY,EAAE,CAAC;IAEzF,OAAO,SAAS,mBAAmB,MAAM,EAAE,KAAK,CAAC,CAAC;GACnD,CAAC,CACF;EACD;EAEA,MAAM,MAAM,OAAO,SAAS,UAAU,QAAQ;EAC9C,MAAM,UAAU,OAAO,QAAQ,kBAAkB,KAAK,qBAAqB,IAAI,OAAO,CAAC;EACvF,IAAI,YAAY,KAAA,GACf,OAAO,OAAO,IAAI,WAAW,EAAE,SAAS,YAAY,WAAW,UAAU,IAAI,IAAI,EAAE,CAAC;EAErF,OAAO,SAAS,mBAAmB,SAAS,EAAE,KAAK,CAAC,CAAC;CACtD,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { n as home } from "./service-
|
|
4
|
-
import { t as discover } from "./discovery-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { n as home } from "./service-YVNwFMNf.mjs";
|
|
4
|
+
import { t as discover } from "./discovery-C-ploGdg.mjs";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/service/status.ts
|
|
7
7
|
var status_default = handler(Cmd.commands.service.commands.status, Effect.fn("CLI.service.status")(function* () {
|
|
@@ -12,4 +12,4 @@ var status_default = handler(Cmd.commands.service.commands.status, Effect.fn("CL
|
|
|
12
12
|
//#endregion
|
|
13
13
|
export { status_default as default };
|
|
14
14
|
|
|
15
|
-
//# sourceMappingURL=status-
|
|
15
|
+
//# sourceMappingURL=status-P0hOBrM6.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-
|
|
1
|
+
{"version":3,"file":"status-P0hOBrM6.mjs","names":["Runtime.handler","Service.home","Discovery.discover"],"sources":["../../src/cli/cmd/handlers/service/status.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Discovery from \"../../../../server/discovery.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.service.commands.status,\n\tEffect.fn(\"CLI.service.status\")(function* () {\n\t\tconst paths = yield* Service.home(yield* Cmd.spec);\n\t\tconst server = yield* Discovery.discover(paths.home);\n\t\tyield* writeOut(`${server?.url ?? \"stopped\"}\\n`);\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;;AAQA,IAAA,iBAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,QAC9B,OAAO,GAAG,oBAAoB,CAAC,CAAC,aAAa;CAC5C,MAAM,QAAQ,OAAOC,KAAa,OAAO,IAAI,IAAI;CACjD,MAAM,SAAS,OAAOC,SAAmB,MAAM,IAAI;CACnD,OAAO,SAAS,GAAG,QAAQ,OAAO,UAAU,GAAG;AAChD,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { i as withConnectApi, n as formatConnectionLine, r as printJson } from "./shared-CA47qIai.mjs";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
//#region src/cli/cmd/handlers/connect/status.ts
|
|
6
|
+
var status_default = handler(Cmd.commands.connect.commands.status, Effect.fn("CLI.connect.status")(function* ({ ref, server, json }) {
|
|
7
|
+
return yield* withConnectApi(server, (api) => Effect.gen(function* () {
|
|
8
|
+
const item = yield* api.get(ref);
|
|
9
|
+
if (json) {
|
|
10
|
+
yield* printJson(item);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
yield* writeOut(`${formatConnectionLine(item)}\n`);
|
|
14
|
+
yield* writeOut(` id: ${item.id}\n`);
|
|
15
|
+
yield* writeOut(` connector: ${item.connectorId}\n`);
|
|
16
|
+
yield* writeOut(` kinds: ${item.kinds.join(", ")}\n`);
|
|
17
|
+
if (item.lastError) yield* writeOut(` error: ${item.lastError}\n`);
|
|
18
|
+
})).pipe(Effect.catch(reportFailure));
|
|
19
|
+
}));
|
|
20
|
+
//#endregion
|
|
21
|
+
export { status_default as default };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=status-tYcs05sk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-tYcs05sk.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/connect/status.ts"],"sourcesContent":["import { 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 { formatConnectionLine, printJson, withConnectApi } from \"./shared.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.connect.commands.status,\n\tEffect.fn(\"CLI.connect.status\")(function* ({ ref, server, json }) {\n\t\tconst program = withConnectApi(server, (api) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst item = yield* api.get(ref);\n\t\t\t\tif (json) {\n\t\t\t\t\tyield* printJson(item);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield* writeOut(`${formatConnectionLine(item)}\\n`);\n\t\t\t\tyield* writeOut(` id: ${item.id}\\n`);\n\t\t\t\tyield* writeOut(` connector: ${item.connectorId}\\n`);\n\t\t\t\tyield* writeOut(` kinds: ${item.kinds.join(\", \")}\\n`);\n\t\t\t\tif (item.lastError) yield* writeOut(` error: ${item.lastError}\\n`);\n\t\t\t}),\n\t\t);\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;AAOA,IAAA,iBAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,QAC9B,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,QAAQ;CAejE,OAAO,OAdS,eAAe,SAAS,QACvC,OAAO,IAAI,aAAa;EACvB,MAAM,OAAO,OAAO,IAAI,IAAI,GAAG;EAC/B,IAAI,MAAM;GACT,OAAO,UAAU,IAAI;GACrB;EACD;EACA,OAAO,SAAS,GAAG,qBAAqB,IAAI,EAAE,GAAG;EACjD,OAAO,SAAS,SAAS,KAAK,GAAG,GAAG;EACpC,OAAO,SAAS,gBAAgB,KAAK,YAAY,GAAG;EACpD,OAAO,SAAS,YAAY,KAAK,MAAM,KAAK,IAAI,EAAE,GAAG;EACrD,IAAI,KAAK,WAAW,OAAO,SAAS,YAAY,KAAK,UAAU,GAAG;CACnE,CAAC,CAEkB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as reportFailure } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { n as home } from "./service-
|
|
4
|
-
import { r as stop } from "./discovery-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { n as home } from "./service-YVNwFMNf.mjs";
|
|
4
|
+
import { r as stop } from "./discovery-C-ploGdg.mjs";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/service/stop.ts
|
|
7
7
|
var stop_default = handler(Cmd.commands.service.commands.stop, Effect.fn("CLI.service.stop")(function* () {
|
|
@@ -11,4 +11,4 @@ var stop_default = handler(Cmd.commands.service.commands.stop, Effect.fn("CLI.se
|
|
|
11
11
|
//#endregion
|
|
12
12
|
export { stop_default as default };
|
|
13
13
|
|
|
14
|
-
//# sourceMappingURL=stop-
|
|
14
|
+
//# sourceMappingURL=stop-BuDB-rqB.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop-
|
|
1
|
+
{"version":3,"file":"stop-BuDB-rqB.mjs","names":["Runtime.handler","Service.home","Discovery.stop"],"sources":["../../src/cli/cmd/handlers/service/stop.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Discovery from \"../../../../server/discovery.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.service.commands.stop,\n\tEffect.fn(\"CLI.service.stop\")(function* () {\n\t\tconst paths = yield* Service.home(yield* Cmd.spec);\n\t\tyield* Discovery.stop(paths.home);\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;;AAOA,IAAA,eAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,MAC9B,OAAO,GAAG,kBAAkB,CAAC,CAAC,aAAa;CAC1C,MAAM,QAAQ,OAAOC,KAAa,OAAO,IAAI,IAAI;CACjD,OAAOC,KAAe,MAAM,IAAI;AACjC,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
3
|
import { a as targeted, i as read, n as local, r as probe, t as fetchable } from "./entries-8D1NzQXw.mjs";
|
|
4
4
|
import { Effect, Option } from "effect";
|
|
5
5
|
import { Plugin } from "@codeworksh/harness/effect";
|
|
@@ -48,4 +48,4 @@ var update_default = handler(Cmd.commands.plugin.commands.update, Effect.fn("CLI
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { update_default as default };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=update-
|
|
51
|
+
//# sourceMappingURL=update-mWc5cR7q.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-
|
|
1
|
+
{"version":3,"file":"update-mWc5cR7q.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/update.ts"],"sourcesContent":["import { Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } 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, local, probe, read, targeted } from \"./entries.ts\";\n\n/**\n * Take whatever `check` found.\n *\n * Only a plugin that is **already installed** is refreshed: \"not installed\" is not \"outdated\", and\n * `plugin install` is the verb for that. Each refresh publishes a new generation, which a running\n * session picks up at its next exchange -- so this command never has to reach into a server.\n */\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.update,\n\tEffect.fn(\"CLI.plugin.update\")(function* ({ spec }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst { entries, cache, hostDir } = yield* read(shared);\n\t\t\tconst selected = yield* targeted(entries, spec, hostDir);\n\t\t\tif (selected.length === 0 && Option.isSome(spec)) return;\n\n\t\t\tlet updated = 0;\n\t\t\tlet failed = 0;\n\t\t\tfor (const entry of selected) {\n\t\t\t\tconst target = fetchable(entry.target);\n\t\t\t\t// A local plugin has no revision to compare and is never copied into the store.\n\t\t\t\tif (target === undefined) {\n\t\t\t\t\tyield* local(entry, spec);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst result = yield* Plugin.update(target, cache, {\n\t\t\t\t\tprobe: probe(cache, entry.from),\n\t\t\t\t\tfrom: entry.from,\n\t\t\t\t\t// Validated while staged, so a refresh that fetches something broken leaves\n\t\t\t\t\t// the generation already in use as the answer. Preserve the loader's reason:\n\t\t\t\t\t// an import failure or invalid definition is not a missing entrypoint.\n\t\t\t\t\tvalidate: (fetched) => Plugin.definition(fetched.entrypoint, entry.reference).pipe(Effect.asVoid),\n\t\t\t\t}).pipe(Effect.result);\n\n\t\t\t\tif (result._tag === \"Failure\") {\n\t\t\t\t\tfailed += 1;\n\t\t\t\t\tyield* writeOut(`${entry.reference} error[${result.failure.reason}]: ${result.failure.message}\\n`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (result.success._tag === \"updated\") {\n\t\t\t\t\tupdated += 1;\n\t\t\t\t\tyield* writeOut(`Updated ${entry.reference} to ${result.success.entry.revision ?? \"a new revision\"}\\n`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// A spec that named only local plugins compared nothing, so there is nothing to sum up.\n\t\t\tif (Option.isSome(spec) && selected.every((entry) => fetchable(entry.target) === undefined)) return;\n\t\t\tyield* writeOut(updated === 0 ? \"Nothing to update.\\n\" : `${updated} updated.\\n`);\n\t\t\tif (failed > 0) process.exitCode = 1;\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;AAeA,IAAA,iBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,QAC7B,OAAO,GAAG,mBAAmB,CAAC,CAAC,WAAW,EAAE,QAAQ;CA2CnD,OAAO,OA1CS,OAAO,IAAI,aAAa;EACvC,MAAM,SAAS,OAAO,IAAI;EAC1B,MAAM,EAAE,SAAS,OAAO,YAAY,OAAO,KAAK,MAAM;EACtD,MAAM,WAAW,OAAO,SAAS,SAAS,MAAM,OAAO;EACvD,IAAI,SAAS,WAAW,KAAK,OAAO,OAAO,IAAI,GAAG;EAElD,IAAI,UAAU;EACd,IAAI,SAAS;EACb,KAAK,MAAM,SAAS,UAAU;GAC7B,MAAM,SAAS,UAAU,MAAM,MAAM;GAErC,IAAI,WAAW,KAAA,GAAW;IACzB,OAAO,MAAM,OAAO,IAAI;IACxB;GACD;GAEA,MAAM,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO;IAClD,OAAO,MAAM,OAAO,MAAM,IAAI;IAC9B,MAAM,MAAM;IAIZ,WAAW,YAAY,OAAO,WAAW,QAAQ,YAAY,MAAM,SAAS,CAAC,CAAC,KAAK,OAAO,MAAM;GACjG,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;GAErB,IAAI,OAAO,SAAS,WAAW;IAC9B,UAAU;IACV,OAAO,SAAS,GAAG,MAAM,UAAU,UAAU,OAAO,QAAQ,OAAO,KAAK,OAAO,QAAQ,QAAQ,GAAG;IAClG;GACD;GACA,IAAI,OAAO,QAAQ,SAAS,WAAW;IACtC,WAAW;IACX,OAAO,SAAS,WAAW,MAAM,UAAU,MAAM,OAAO,QAAQ,MAAM,YAAY,iBAAiB,GAAG;GACvG;EACD;EAGA,IAAI,OAAO,OAAO,IAAI,KAAK,SAAS,OAAO,UAAU,UAAU,MAAM,MAAM,MAAM,KAAA,CAAS,GAAG;EAC7F,OAAO,SAAS,YAAY,IAAI,yBAAyB,GAAG,QAAQ,YAAY;EAChF,IAAI,SAAS,GAAG,QAAQ,WAAW;CACpC,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
package/acp-CmtcmhuX.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acp-CmtcmhuX.mjs","names":["serve","Agent.RequestError","pkg.version","Config.options","Feed.replay","Config.parseModel","Config.known","Config.isThinkingLevel","update","Feed.update","notice","Feed.notice","Feed.noticeUpdate","Handlers.make","Agent.serve","Runtime.handler","Server.serve"],"sources":["../../src/acp/agent.ts","../../src/acp/config.ts","../../src/acp/feed.ts","../../src/acp/handlers.ts","../../src/acp/server.ts","../../src/cli/cmd/handlers/acp.ts"],"sourcesContent":["import * as Acp from \"@agentclientprotocol/sdk\";\nimport { Cause, Deferred, Effect, Exit, Option, Schema, type Scope, type Stdio, Stream } from \"effect\";\n\n/** A JSON-RPC error a handler answers a request with. */\nexport class RequestError extends Schema.TaggedError<RequestError>()(\"AcpRequestError\", {\n\tcode: Schema.Int,\n\tmessage: Schema.String,\n\tdata: Schema.optionalKey(Schema.Json),\n}) {\n\tstatic invalidRequest = (message: string) => new RequestError({ code: -32600, message });\n\tstatic invalidParams = (message: string) => new RequestError({ code: -32602, message });\n\tstatic internalError = (message: string, data?: Schema.Json) =>\n\t\tnew RequestError({ code: -32603, message, ...(data === undefined ? {} : { data }) });\n\tstatic resourceNotFound = (message: string) => new RequestError({ code: -32002, message });\n}\n\ntype Handler<Request, Response> = (request: Request) => Effect.Effect<Response, RequestError>;\n\n/** Calls the agent makes to the connected client. */\nexport interface Client {\n\treadonly sessionUpdate: (notification: Acp.SessionNotification) => Effect.Effect<void, RequestError>;\n}\n\nexport interface Handlers {\n\treadonly initialize: Handler<Acp.InitializeRequest, Acp.InitializeResponse>;\n\treadonly newSession: Handler<Acp.NewSessionRequest, Acp.NewSessionResponse>;\n\t/** Must replay the session's history through `Client.sessionUpdate` before it returns. */\n\treadonly loadSession: Handler<Acp.LoadSessionRequest, Acp.LoadSessionResponse>;\n\treadonly listSessions: Handler<Acp.ListSessionsRequest, Acp.ListSessionsResponse>;\n\treadonly forkSession: Handler<Acp.ForkSessionRequest, Acp.ForkSessionResponse>;\n\treadonly setConfigOption: Handler<Acp.SetSessionConfigOptionRequest, Acp.SetSessionConfigOptionResponse>;\n\treadonly prompt: Handler<Acp.PromptRequest, Acp.PromptResponse>;\n\treadonly cancel: (notification: Acp.CancelNotification) => Effect.Effect<void>;\n}\n\n/**\n * Serves an ACP agent over `stdio` until the client closes its end.\n *\n * Handlers run as fibers on this effect's services; a request the client cancels, or the\n * connection closing, interrupts its fiber.\n */\nexport const serve = Effect.fn(\"ACP.serve\")(function* (\n\tstdio: Stdio.Stdio,\n\tmakeHandlers: (client: Client) => Handlers,\n): Effect.fn.Return<void, never, Scope.Scope> {\n\tconst context = yield* Effect.context<never>();\n\tconst runExit = Effect.runPromiseExitWith(context);\n\tconst opened = yield* Deferred.make<Acp.AgentConnection>();\n\n\tconst handlers = makeHandlers({\n\t\tsessionUpdate: (notification) =>\n\t\t\tDeferred.await(opened).pipe(\n\t\t\t\tEffect.flatMap((connection) =>\n\t\t\t\t\tEffect.tryPromise({\n\t\t\t\t\t\ttry: () => connection.client.notify(Acp.methods.client.session.update, notification),\n\t\t\t\t\t\tcatch: (error) => RequestError.internalError(`Failed to send session/update: ${String(error)}`),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n\n\t// A JSON-RPC answer for a handler that didn't succeed; the SDK sends what `handle` throws.\n\tconst toWire = (cause: Cause.Cause<RequestError>): Acp.RequestError => {\n\t\tconst error = Cause.findErrorOption(cause);\n\t\tif (Option.isSome(error)) return new Acp.RequestError(error.value.code, error.value.message, error.value.data);\n\t\tif (Cause.hasInterruptsOnly(cause)) return Acp.RequestError.requestCancelled();\n\t\treturn Acp.RequestError.internalError(undefined, String(Cause.squash(cause)));\n\t};\n\tconst handle =\n\t\t<Params, A>(handler: (params: Params) => Effect.Effect<A, RequestError>) =>\n\t\t({ params, signal }: { readonly params: Params; readonly signal: AbortSignal }): Promise<A> =>\n\t\t\trunExit(handler(params), { signal }).then((exit) => {\n\t\t\t\tif (Exit.isSuccess(exit)) return exit.value;\n\t\t\t\tthrow toWire(exit.cause);\n\t\t\t});\n\n\tconst input = yield* Stream.toReadableStreamEffect(stdio.stdin);\n\tconst output = new WritableStream<Uint8Array>({\n\t\twrite: (chunk) => Effect.runPromiseWith(context)(Stream.run(Stream.make(chunk), stdio.stdout())),\n\t});\n\n\tconst connection = Acp.agent({ name: \"codework\" })\n\t\t.onRequest(\"initialize\", handle(handlers.initialize))\n\t\t.onRequest(\"session/new\", handle(handlers.newSession))\n\t\t.onRequest(\"session/load\", handle(handlers.loadSession))\n\t\t.onRequest(\"session/list\", handle(handlers.listSessions))\n\t\t.onRequest(\"session/fork\", handle(handlers.forkSession))\n\t\t.onRequest(\"session/set_config_option\", handle(handlers.setConfigOption))\n\t\t.onRequest(\"session/prompt\", handle(handlers.prompt))\n\t\t.onNotification(\"session/cancel\", handle(handlers.cancel))\n\t\t.connect(Acp.ndJsonStream(output, input));\n\tyield* Deferred.succeed(opened, connection);\n\tyield* Effect.addFinalizer(() => Effect.sync(() => connection.close()));\n\tyield* Effect.promise(() => connection.closed);\n});\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport { Model } from \"@codeworksh/aikit\";\nimport { ModelCatalog, Settings, type State } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } from \"effect\";\n\nexport const MODEL = \"model\";\nexport const THOUGHT_LEVEL = \"thought_level\";\n\nconst thinkingLabels: Record<Model.ThinkingLevel, string> = {\n\toff: \"Off\",\n\tminimal: \"Minimal\",\n\tlow: \"Low\",\n\tmedium: \"Medium\",\n\thigh: \"High\",\n\txhigh: \"Extra High\",\n\tmax: \"Max\",\n};\n\nexport const isThinkingLevel = (value: string): value is Model.ThinkingLevel => Object.hasOwn(thinkingLabels, value);\n\n/** Splits a `provider/model` option value on its first slash; model ids may contain more. */\nexport const parseModel = (value: string): Option.Option<{ readonly provider: string; readonly id: string }> => {\n\tconst slash = value.indexOf(\"/\");\n\tif (slash <= 0 || slash === value.length - 1) return Option.none();\n\treturn Option.some({ provider: value.slice(0, slash), id: value.slice(slash + 1) });\n};\n\n/** The catalog a session in `hostDir` sees: generated entries plus its settings' `models`. */\nconst catalogFor = (hostDir: string | undefined) =>\n\tEffect.gen(function* () {\n\t\tconst settings = yield* Settings.Service;\n\t\treturn yield* ModelCatalog.effective((yield* settings.load(hostDir)).models);\n\t}).pipe(Effect.orElseSucceed((): Model.BuiltInModels => ({})));\n\n/** The `model` and `thought_level` selectors for a session's current configuration. */\nexport const options = Effect.fn(\"ACP.config.options\")(function* (\n\tselection: State.Configuration,\n\thostDir: string | undefined,\n) {\n\tconst catalog = yield* catalogFor(hostDir);\n\t// Providers the harness has credentials for; the current model stays selectable even if not.\n\tconst providers = yield* ModelCatalog.available(hostDir === undefined ? {} : { hostDir }).pipe(\n\t\tEffect.orElseSucceed(() => []),\n\t);\n\n\tconst current = `${selection.provider}/${selection.model}`;\n\tconst models = providers.flatMap((provider) =>\n\t\tObject.entries(provider.models).map(([id, info]) => ({\n\t\t\tvalue: `${provider.id}/${id}`,\n\t\t\tname: `${info.provider.name}: ${info.name}`,\n\t\t})),\n\t);\n\tif (!models.some((option) => option.value === current)) models.unshift({ value: current, name: current });\n\n\tconst result: Array<Acp.SessionConfigOption> = [\n\t\t{ id: MODEL, name: \"Model\", category: \"model\", type: \"select\", currentValue: current, options: models },\n\t];\n\n\tconst info = catalog[selection.provider]?.[selection.model];\n\tconst levels = info === undefined ? [] : Model.getSupportedThinkingLevels(info);\n\tif (levels.some((level) => level !== \"off\")) {\n\t\tresult.push({\n\t\t\tid: THOUGHT_LEVEL,\n\t\t\tname: \"Thinking Effort\",\n\t\t\tcategory: \"thought_level\",\n\t\t\ttype: \"select\",\n\t\t\tcurrentValue: selection.thinkingLevel,\n\t\t\toptions: levels.map((level) => ({ value: level, name: thinkingLabels[level] })),\n\t\t});\n\t}\n\treturn result;\n});\n\n/** Whether a model is in the catalog a session in `hostDir` sees. */\nexport const known = Effect.fn(\"ACP.config.known\")(function* (\n\tmodel: { readonly provider: string; readonly id: string },\n\thostDir: string | undefined,\n) {\n\tconst catalog = yield* catalogFor(hostDir);\n\treturn catalog[model.provider]?.[model.id] !== undefined;\n});\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport { EventList, type EventSchema, type ThreadStore } from \"@codeworksh/harness/effect\";\nimport { Option, Schema } from \"effect\";\n\nconst isTextDelta = Schema.is(EventList.LLMTextDelta);\nconst isThinkingDelta = Schema.is(EventList.LLMThinkingDelta);\nconst isToolStarted = Schema.is(EventList.ToolStarted);\nconst isToolSettled = Schema.is(EventList.ToolSettled);\nconst isPluginUpdated = Schema.is(EventList.PluginUpdated);\n\nconst TextContent = Schema.Struct({ type: Schema.Literal(\"text\"), text: Schema.String });\nconst ImageContent = Schema.Struct({ type: Schema.Literal(\"image\"), data: Schema.String, mimeType: Schema.String });\nconst ToolResult = Schema.Struct({\n\tcontent: Schema.Array(Schema.Union([TextContent, Schema.Struct({ type: Schema.Literal(\"image\") })])),\n\tisError: Schema.Boolean,\n});\nconst ToolCall = Schema.Struct({\n\ttype: Schema.Literal(\"toolCall\"),\n\tcallID: Schema.String,\n\tname: Schema.String,\n\targuments: Schema.Record(Schema.String, Schema.Json),\n\tstatus: Schema.String,\n\tresult: Schema.optional(ToolResult),\n});\nconst StoredPart = Schema.Union([\n\tTextContent,\n\tImageContent,\n\tSchema.Struct({ type: Schema.Literal(\"thinking\"), thinking: Schema.String }),\n\tToolCall,\n]);\nconst decodePart = Schema.decodeUnknownOption(Schema.fromJsonString(StoredPart));\n\ntype ToolCall = typeof ToolCall.Type;\n\nconst text = (value: string): Acp.ContentBlock => ({ type: \"text\", text: value });\n\n// The kind comes from the tool's name. Only `bash` ships built in; plugin tools report `other`.\nconst kind = (name: string): Acp.ToolKind => (name === \"bash\" ? \"execute\" : \"other\");\n\n/** The command for `bash`, otherwise the tool's label or name. */\nconst title = (name: string, args: Readonly<Record<string, unknown>>, label?: string): string =>\n\tname === \"bash\" && typeof args.command === \"string\" ? args.command : (label ?? name);\n\nconst settled = (call: Pick<ToolCall, \"callID\" | \"name\" | \"arguments\" | \"status\" | \"result\">): Acp.SessionUpdate => {\n\tconst output = call.result?.content.flatMap((block) => (block.type === \"text\" ? [block.text] : [])).join(\"\\n\");\n\treturn {\n\t\tsessionUpdate: \"tool_call_update\",\n\t\ttoolCallId: call.callID,\n\t\tkind: kind(call.name),\n\t\tstatus: call.status === \"completed\" ? \"completed\" : \"failed\",\n\t\trawInput: call.arguments,\n\t\t...(call.result === undefined ? {} : { rawOutput: call.result }),\n\t\t...(output ? { content: [{ type: \"content\", content: text(output) }] } : {}),\n\t};\n};\n\n/** The live `session/update` for a harness event, if the client should see one. */\nexport const update = (event: EventSchema.Payload): Option.Option<Acp.SessionUpdate> => {\n\tif (isTextDelta(event)) {\n\t\treturn Option.some({ sessionUpdate: \"agent_message_chunk\", content: text(event.data.delta) });\n\t}\n\tif (isThinkingDelta(event)) {\n\t\treturn Option.some({ sessionUpdate: \"agent_thought_chunk\", content: text(event.data.delta) });\n\t}\n\tif (isToolStarted(event)) {\n\t\treturn Option.some({\n\t\t\tsessionUpdate: \"tool_call\",\n\t\t\ttoolCallId: event.data.callID,\n\t\t\ttitle: title(event.data.name, event.data.arguments, event.data.label),\n\t\t\tkind: kind(event.data.name),\n\t\t\tstatus: \"in_progress\",\n\t\t\trawInput: event.data.arguments,\n\t\t});\n\t}\n\tif (isToolSettled(event)) return Option.some(settled(event.data.part));\n\treturn Option.none();\n};\n\n/**\n * Text for the user about a plugin that failed to load, such as one configured but not installed.\n * It belongs in the conversation because the user may never see this process's logs.\n */\nexport const notice = (event: EventSchema.Payload): Option.Option<string> =>\n\tisPluginUpdated(event) && event.data.status === \"failed\" && event.data.error !== undefined\n\t\t? Option.some(event.data.error)\n\t\t: Option.none();\n\n/** A notice shown to the user in the agent's message. */\nexport const noticeUpdate = (notice: string): Acp.SessionUpdate => ({\n\tsessionUpdate: \"agent_message_chunk\",\n\tcontent: text(`> ⚠ ${notice}\\n\\n`),\n});\n\n/** The `session/update`s that replay one stored entry during `session/load`. */\nexport const replay = ({ entry, parts }: ThreadStore.HydratedEntry): ReadonlyArray<Acp.SessionUpdate> => {\n\tif (entry.type !== \"user\" && entry.type !== \"assistant\") return [];\n\treturn parts.flatMap((row): ReadonlyArray<Acp.SessionUpdate> => {\n\t\tconst part = decodePart(row.data);\n\t\tif (Option.isNone(part)) return [];\n\t\tswitch (part.value.type) {\n\t\t\tcase \"text\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: entry.type === \"user\" ? \"user_message_chunk\" : \"agent_message_chunk\",\n\t\t\t\t\t\tcontent: text(part.value.text),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\tcase \"image\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: entry.type === \"user\" ? \"user_message_chunk\" : \"agent_message_chunk\",\n\t\t\t\t\t\tcontent: { type: \"image\", data: part.value.data, mimeType: part.value.mimeType },\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\tcase \"thinking\":\n\t\t\t\treturn [{ sessionUpdate: \"agent_thought_chunk\", content: text(part.value.thinking) }];\n\t\t\tcase \"toolCall\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsessionUpdate: \"tool_call\",\n\t\t\t\t\t\ttoolCallId: part.value.callID,\n\t\t\t\t\t\ttitle: title(part.value.name, part.value.arguments),\n\t\t\t\t\t\tkind: kind(part.value.name),\n\t\t\t\t\t\tstatus: \"in_progress\",\n\t\t\t\t\t\trawInput: part.value.arguments,\n\t\t\t\t\t},\n\t\t\t\t\tsettled(part.value),\n\t\t\t\t];\n\t\t}\n\t});\n};\n","import type * as Acp from \"@agentclientprotocol/sdk\";\nimport {\n\tControl,\n\tEventList,\n\ttype Harness,\n\tPromptSchema,\n\tSession,\n\tSessionStore,\n\tThreadStore,\n} from \"@codeworksh/harness/effect\";\nimport { DateTime, Effect, Fiber, type Layer, Option, Schema, Stream } from \"effect\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\nimport * as Agent from \"./agent.ts\";\nimport * as Config from \"./config.ts\";\nimport * as Feed from \"./feed.ts\";\n\nconst PAGE_SIZE = 50;\n\nconst isRequestError = Schema.is(Agent.RequestError);\nconst isNotFound = Schema.is(SessionStore.SessionNotFoundError);\nconst isConflict = Schema.is(Control.PromptConflictError);\nconst isInvalidPrompt = Schema.is(PromptSchema.InvalidPromptError);\nconst isLLMEnded = Schema.is(EventList.LLMEnded);\nconst isFailed = Schema.is(EventList.ExecutionFailed);\nconst isInterrupted = Schema.is(EventList.ExecutionInterrupted);\nconst isRunFailed = Schema.is(EventList.RunFailed);\n\n/** Harness failures as JSON-RPC errors; handlers raise protocol-level ones directly. */\nconst toRequestError = (error: { readonly message: string }): Agent.RequestError => {\n\tif (isRequestError(error)) return error;\n\tif (isNotFound(error)) return Agent.RequestError.resourceNotFound(`Session not found: ${error.sessionId}`);\n\tif (isConflict(error)) return Agent.RequestError.invalidRequest(error.message);\n\tif (isInvalidPrompt(error)) return Agent.RequestError.invalidParams(error.message);\n\treturn Agent.RequestError.internalError(error.message);\n};\n\n/**\n * Prompt content as harness prompt parts, in order. Text, embedded context and images are\n * advertised; anything else is rejected. Adjacent text joins into one part. The harness checks\n * the images.\n */\nconst promptParts = Effect.fnUntraced(function* (blocks: ReadonlyArray<Acp.ContentBlock>) {\n\tconst parts: Array<PromptSchema.Part> = [];\n\tconst add = (part: PromptSchema.Part) => {\n\t\tconst last = parts.at(-1);\n\t\tif (part.type === \"text\" && last?.type === \"text\")\n\t\t\tparts[parts.length - 1] = { ...last, text: `${last.text}\\n\\n${part.text}` };\n\t\telse parts.push(part);\n\t};\n\tfor (const block of blocks) {\n\t\tswitch (block.type) {\n\t\t\tcase \"text\":\n\t\t\t\tadd({ type: \"text\", text: block.text });\n\t\t\t\tbreak;\n\t\t\tcase \"resource_link\":\n\t\t\t\tadd({ type: \"text\", text: `[${block.name}](${block.uri})` });\n\t\t\t\tbreak;\n\t\t\tcase \"image\":\n\t\t\t\tadd({ type: \"image\", data: block.data, mimeType: block.mimeType });\n\t\t\t\tbreak;\n\t\t\tcase \"resource\":\n\t\t\t\tif (\"text\" in block.resource) {\n\t\t\t\t\tadd({ type: \"text\", text: `\\`\\`\\`${block.resource.uri}\\n${block.resource.text}\\n\\`\\`\\`` });\n\t\t\t\t} else if (block.resource.mimeType?.startsWith(\"image/\")) {\n\t\t\t\t\tadd({ type: \"image\", data: block.resource.blob, mimeType: block.resource.mimeType });\n\t\t\t\t} else {\n\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unsupported binary resource: ${block.resource.uri}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unsupported prompt content: ${block.type}`);\n\t\t}\n\t}\n\treturn parts;\n});\n\nconst threadId = (id: string) => Session.ThreadSchema.ID.make(id);\n\ntype Services = Layer.Success<ReturnType<typeof Harness.layer>>;\n\nexport const make = Effect.gen(function* () {\n\tconst control = yield* Control.Service;\n\tconst sessions = yield* SessionStore.Service;\n\tconst threads = yield* ThreadStore.Service;\n\t// Handlers run on the agent's fibers, outside this layer; they carry the harness with them.\n\tconst context = yield* Effect.context<Services>();\n\n\tconst running = new Set<string>();\n\n\t// Every thread is an ACP session of its own. The main thread keeps the CodeWork session's id,\n\t// so a session an editor knew before it had forks still loads; any other thread goes by its id.\n\tconst acpId = (thread: { readonly originKind: string; readonly sessionId: string; readonly id: string }) =>\n\t\tthread.originKind === \"main\" ? thread.sessionId : thread.id;\n\n\t/** The CodeWork session and thread an ACP session id names. */\n\tconst resolve = Effect.fn(\"ACP.resolve\")(function* (id: string) {\n\t\tconst session = yield* sessions.get(id);\n\t\tif (Option.isSome(session)) {\n\t\t\tconst main = yield* threads.main(session.value.id);\n\t\t\tif (Option.isSome(main)) return { session: session.value, threadId: threadId(main.value.id) };\n\t\t}\n\t\tconst thread = yield* threads.get(id);\n\t\tif (Option.isSome(thread)) {\n\t\t\tconst owner = yield* sessions.get(thread.value.sessionId);\n\t\t\tif (Option.isSome(owner)) return { session: owner.value, threadId: threadId(thread.value.id) };\n\t\t}\n\t\treturn yield* new SessionStore.SessionNotFoundError({ sessionId: id });\n\t});\n\n\tconst attach = Effect.fn(\"ACP.attach\")(function* (id: string) {\n\t\tconst { session, threadId } = yield* resolve(id);\n\t\tconst thread = yield* Session.attach({ sessionId: session.id, threadId });\n\t\treturn { thread, hostDir: Option.getOrUndefined(session.hostDir) };\n\t});\n\n\treturn (client: Agent.Client): Agent.Handlers => {\n\t\tconst run = <A, E extends { readonly message: string }>(effect: Effect.Effect<A, E, Services>) =>\n\t\t\teffect.pipe(Effect.provide(context), Effect.mapError(toRequestError));\n\n\t\treturn {\n\t\t\tinitialize: () =>\n\t\t\t\tEffect.succeed({\n\t\t\t\t\tprotocolVersion: 1,\n\t\t\t\t\tagentInfo: { name: \"codework\", version: pkg.version },\n\t\t\t\t\tagentCapabilities: {\n\t\t\t\t\t\tloadSession: true,\n\t\t\t\t\t\tpromptCapabilities: { embeddedContext: true, image: true },\n\t\t\t\t\t\tsessionCapabilities: { list: {}, fork: {} },\n\t\t\t\t\t},\n\t\t\t\t}),\n\n\t\t\tnewSession: ({ cwd }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst handle = yield* Session.create({ directory: cwd, hostDir: cwd });\n\t\t\t\t\t\tconst current = yield* Session.configuration(handle.main.id);\n\t\t\t\t\t\treturn { sessionId: handle.id, configOptions: yield* Config.options(current, cwd) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tloadSession: ({ sessionId: id }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst { thread, hostDir } = yield* attach(id);\n\t\t\t\t\t\tconst current = yield* Session.configuration(thread.id);\n\t\t\t\t\t\t// A fork replays its whole line, the part it inherits included.\n\t\t\t\t\t\tfor (const entry of yield* thread.history()) {\n\t\t\t\t\t\t\tfor (const update of Feed.replay(entry)) {\n\t\t\t\t\t\t\t\tyield* client.sessionUpdate({ sessionId: id, update });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { configOptions: yield* Config.options(current, hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tlistSessions: ({ cwd, cursor }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst owners = new Map((yield* sessions.list()).map((row) => [row.id, row]));\n\t\t\t\t\t\tconst all = yield* threads.list();\n\t\t\t\t\t\tconst titles = new Map(all.map((thread) => [thread.id, Option.getOrUndefined(thread.title)]));\n\t\t\t\t\t\tconst rows = all\n\t\t\t\t\t\t\t.flatMap((thread) => {\n\t\t\t\t\t\t\t\tconst session = owners.get(thread.sessionId);\n\t\t\t\t\t\t\t\treturn session === undefined ? [] : [{ thread, session }];\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.filter(({ session }) => cwd == null || Option.getOrUndefined(session.hostDir) === cwd)\n\t\t\t\t\t\t\t.sort((a, b) =>\n\t\t\t\t\t\t\t\tDateTime.Order(\n\t\t\t\t\t\t\t\t\tb.thread.updatedAt ?? b.thread.createdAt,\n\t\t\t\t\t\t\t\t\ta.thread.updatedAt ?? a.thread.createdAt,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tconst offset = cursor == null ? 0 : Number(cursor);\n\t\t\t\t\t\tif (!Number.isSafeInteger(offset) || offset < 0) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Invalid cursor: ${cursor}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst next = offset + PAGE_SIZE;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsessions: rows.slice(offset, next).map(({ thread, session }) => ({\n\t\t\t\t\t\t\t\tsessionId: acpId(thread),\n\t\t\t\t\t\t\t\tcwd: Option.getOrElse(session.hostDir, () => session.directory),\n\t\t\t\t\t\t\t\t// A fork is untitled until its own first prompt; it reads as its source until then.\n\t\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\t\ttitles.get(thread.id) ??\n\t\t\t\t\t\t\t\t\tOption.match(thread.originThreadId, {\n\t\t\t\t\t\t\t\t\t\tonNone: () => undefined,\n\t\t\t\t\t\t\t\t\t\tonSome: (origin) => titles.get(origin),\n\t\t\t\t\t\t\t\t\t}) ??\n\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\tupdatedAt: DateTime.formatIso(thread.updatedAt ?? thread.createdAt),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t...(next < rows.length ? { nextCursor: String(next) } : {}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tforkSession: ({ sessionId: id }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst { thread, hostDir } = yield* attach(id);\n\t\t\t\t\t\t// ACP forks the conversation as it stands: at its last committed entry, of any type, so\n\t\t\t\t\t\t// a trailing tool result or compaction comes along.\n\t\t\t\t\t\tconst last = (yield* thread.history()).findLast(({ entry }) => entry.state === \"committed\");\n\t\t\t\t\t\tif (last === undefined) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidRequest(\n\t\t\t\t\t\t\t\t\"Nothing to fork yet: the session has no messages\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst forked = yield* thread.fork({ entryId: last.entry.id });\n\t\t\t\t\t\tconst current = yield* Session.configuration(forked.thread.id);\n\t\t\t\t\t\treturn { sessionId: forked.thread.id, configOptions: yield* Config.options(current, hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tsetConfigOption: (request) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst { session, threadId } = yield* resolve(request.sessionId);\n\t\t\t\t\t\tconst hostDir = Option.getOrUndefined(session.hostDir);\n\t\t\t\t\t\tconst value = String(request.value);\n\t\t\t\t\t\tlet runtime: Session.RuntimeInput;\n\t\t\t\t\t\tif (request.configId === Config.MODEL) {\n\t\t\t\t\t\t\tconst model = Option.getOrUndefined(Config.parseModel(value));\n\t\t\t\t\t\t\tif (model === undefined || !(yield* Config.known(model, hostDir))) {\n\t\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown model: ${value}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\truntime = { model };\n\t\t\t\t\t\t} else if (request.configId === Config.THOUGHT_LEVEL) {\n\t\t\t\t\t\t\tif (!Config.isThinkingLevel(value)) {\n\t\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown thinking level: ${value}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\truntime = { thinkingLevel: value };\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidParams(`Unknown config option: ${request.configId}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst thread = yield* Session.attach({ sessionId: session.id, threadId, ...runtime });\n\t\t\t\t\t\treturn { configOptions: yield* Config.options(yield* Session.configuration(thread.id), hostDir) };\n\t\t\t\t\t}),\n\t\t\t\t),\n\n\t\t\tprompt: ({ sessionId: id, prompt }) =>\n\t\t\t\trun(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst parts = yield* promptParts(prompt);\n\t\t\t\t\t\tconst { thread: handle } = yield* attach(id);\n\t\t\t\t\t\t// Keyed by thread: main answers to its session id and its own thread id alike.\n\t\t\t\t\t\tif (running.has(handle.id)) {\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.invalidRequest(\"A prompt is already running for this session\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\trunning.add(handle.id);\n\t\t\t\t\t\tyield* Effect.addFinalizer(() => Effect.sync(() => running.delete(handle.id)));\n\n\t\t\t\t\t\t// Forward this execution's updates until it settles; the settling event decides the answer.\n\t\t\t\t\t\tlet reason: EventList.LLMEnded[\"data\"][\"reason\"] | undefined;\n\t\t\t\t\t\t// Plugins are checked every exchange; tell the user about each failure once per prompt.\n\t\t\t\t\t\tconst notices = new Set<string>();\n\t\t\t\t\t\tconst settled = yield* handle.events().pipe(\n\t\t\t\t\t\t\tStream.tap((event) => {\n\t\t\t\t\t\t\t\tif (isLLMEnded(event)) reason = event.data.reason;\n\t\t\t\t\t\t\t\tlet update = Feed.update(event);\n\t\t\t\t\t\t\t\tconst notice = Feed.notice(event);\n\t\t\t\t\t\t\t\tif (Option.isSome(notice) && !notices.has(notice.value)) {\n\t\t\t\t\t\t\t\t\tnotices.add(notice.value);\n\t\t\t\t\t\t\t\t\tupdate = Option.some(Feed.noticeUpdate(notice.value));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn Option.match(update, {\n\t\t\t\t\t\t\t\t\tonNone: () => Effect.void,\n\t\t\t\t\t\t\t\t\tonSome: (update) => client.sessionUpdate({ sessionId: id, update }).pipe(Effect.ignore),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tStream.filter(EventList.isRunEnded),\n\t\t\t\t\t\t\tStream.runHead,\n\t\t\t\t\t\t\tEffect.forkScoped({ startImmediately: true }),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst before = (yield* handle.info).title;\n\t\t\t\t\t\tyield* handle.run({ parts });\n\t\t\t\t\t\tconst end = yield* Fiber.join(settled);\n\n\t\t\t\t\t\t// The harness titles a thread from its first prompt; tell the editor.\n\t\t\t\t\t\tconst { title } = yield* handle.info;\n\t\t\t\t\t\tif (title !== undefined && title !== before) {\n\t\t\t\t\t\t\tyield* client\n\t\t\t\t\t\t\t\t.sessionUpdate({ sessionId: id, update: { sessionUpdate: \"session_info_update\", title } })\n\t\t\t\t\t\t\t\t.pipe(Effect.ignore);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (Option.isNone(end) || isInterrupted(end.value)) return { stopReason: \"cancelled\" as const };\n\t\t\t\t\t\tif (isFailed(end.value)) return yield* Agent.RequestError.internalError(end.value.data.error.message);\n\t\t\t\t\t\tif (isRunFailed(end.value)) {\n\t\t\t\t\t\t\tconst { reason, message } = end.value.data;\n\t\t\t\t\t\t\treturn yield* Agent.RequestError.internalError(message, { reason });\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { stopReason: reason === \"length\" ? (\"max_tokens\" as const) : (\"end_turn\" as const) };\n\t\t\t\t\t}).pipe(Effect.scoped),\n\t\t\t\t),\n\n\t\t\tcancel: ({ sessionId: id }) =>\n\t\t\t\tresolve(id).pipe(\n\t\t\t\t\tEffect.flatMap((found) => control.interrupt(found.threadId, { reason: \"user\" })),\n\t\t\t\t\tEffect.ignore,\n\t\t\t\t\tEffect.provide(context),\n\t\t\t\t),\n\t\t};\n\t};\n});\n","import { Control, Harness, Sandbox } from \"@codeworksh/harness/effect\";\nimport { Effect, Logger, Stdio } from \"effect\";\nimport * as Agent from \"./agent.ts\";\nimport * as Handlers from \"./handlers.ts\";\n\n// Sessions and managed sandboxes outlive any single request; the connection's end is what stops them.\nconst shutdown = Effect.gen(function* () {\n\tconst control = yield* Control.Service;\n\tyield* Effect.forEach(\n\t\tyield* control.active,\n\t\t(id) =>\n\t\t\tcontrol\n\t\t\t\t.interrupt(id, { reason: \"shutdown\", awaitSettlement: true })\n\t\t\t\t.pipe(Effect.timeout(\"10 seconds\"), Effect.ignore),\n\t\t{ concurrency: \"unbounded\", discard: true },\n\t);\n\tconst managed = (yield* Sandbox.list()).filter((info) => info.ownership === \"managed\");\n\tyield* Effect.forEach(\n\t\tmanaged,\n\t\t(info) =>\n\t\t\tSandbox.stop(info.id).pipe(\n\t\t\t\tEffect.timeout(\"10 seconds\"),\n\t\t\t\tEffect.catchCause((cause) =>\n\t\t\t\t\tEffect.logError(\"Failed to stop managed sandbox during ACP shutdown\", cause).pipe(\n\t\t\t\t\t\tEffect.annotateLogs({ sandboxInstanceId: info.id }),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t{ concurrency: \"unbounded\", discard: true },\n\t);\n});\n\n/**\n * Serves ACP v1 on stdio until the client disconnects.\n *\n * stdout carries the protocol, so logs go to stderr. The reference is set outside the harness layer\n * so the fibers it forks (turns, plugin loads) inherit it too.\n */\nexport const serve = (options: Harness.Options) =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.addFinalizer(() => shutdown.pipe(Effect.ignore));\n\t\tconst handlers = yield* Handlers.make;\n\t\tyield* Agent.serve(yield* Stdio.Stdio, handlers);\n\t}).pipe(Effect.scoped, Effect.provide(Harness.layer(options)), Effect.provideService(Logger.LogToStderr, true));\n","import { Effect } from \"effect\";\nimport * as Server from \"../../../acp/server.ts\";\nimport * as Runtime from \"../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../error.ts\";\nimport { harnessOptions } from \"../../harness.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.acp,\n\tEffect.fn(\"CLI.acp\", { level: \"Info\" })(function* () {\n\t\tconst shared = yield* Cmd.spec;\n\t\treturn yield* Server.serve(harnessOptions(shared)).pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;AAIA,IAAa,eAAb,MAAa,qBAAqB,OAAO,YAA0B,CAAC,CAAC,mBAAmB;CACvF,MAAM,OAAO;CACb,SAAS,OAAO;CAChB,MAAM,OAAO,YAAY,OAAO,IAAI;AACrC,CAAC,CAAC,CAAC;CACF,OAAO,kBAAkB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;CACvF,OAAO,iBAAiB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;CACtF,OAAO,iBAAiB,SAAiB,SACxC,IAAI,aAAa;EAAE,MAAM;EAAQ;EAAS,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;CAAG,CAAC;CACpF,OAAO,oBAAoB,YAAoB,IAAI,aAAa;EAAE,MAAM;EAAQ;CAAQ,CAAC;AAC1F;;;;;;;AA2BA,MAAaA,UAAQ,OAAO,GAAG,WAAW,CAAC,CAAC,WAC3C,OACA,cAC6C;CAC7C,MAAM,UAAU,OAAO,OAAO,QAAe;CAC7C,MAAM,UAAU,OAAO,mBAAmB,OAAO;CACjD,MAAM,SAAS,OAAO,SAAS,KAA0B;CAEzD,MAAM,WAAW,aAAa,EAC7B,gBAAgB,iBACf,SAAS,MAAM,MAAM,CAAC,CAAC,KACtB,OAAO,SAAS,eACf,OAAO,WAAW;EACjB,WAAW,WAAW,OAAO,OAAO,IAAI,QAAQ,OAAO,QAAQ,QAAQ,YAAY;EACnF,QAAQ,UAAU,aAAa,cAAc,kCAAkC,OAAO,KAAK,GAAG;CAC/F,CAAC,CACF,CACD,EACF,CAAC;CAGD,MAAM,UAAU,U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AAC,aAAa;CACpD,MAAM,SAAS,OAAO,IAAI;CAC1B,OAAO,OAAOC,MAAa,eAAe,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACpF,CAAC,CACF"}
|
package/disconnect-DKi3PmC2.mjs
DELETED
package/package-D_TWKUKk.mjs
DELETED
package/package-D_TWKUKk.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-D_TWKUKk.mjs","names":[],"sources":["../../package.json"],"sourcesContent":[""],"mappings":""}
|
package/reconnect-DgUK2fwU.mjs
DELETED
package/run-BN0xfxh_.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-BN0xfxh_.mjs","names":["Runtime.handler","Client.make","Client.run","Service.connect"],"sources":["../../src/cli/cmd/handlers/run.ts"],"sourcesContent":["import { EventList, type EventSchema, Harness, Sandbox, Session } from \"@codeworksh/harness/effect\";\nimport { Effect, Exit, Fiber, Logger, Option, Queue, Ref, Schema, Stream } from \"effect\";\nimport * as Runtime from \"../../../framework/runtime.ts\";\nimport * as Client from \"../../../server/client.ts\";\nimport * as Service from \"../../service.ts\";\nimport { InvalidInputError, renderError } from \"../../error.ts\";\nimport { harnessOptions } from \"../../harness.ts\";\nimport {\n\taddUsage,\n\temptyUsage,\n\theader,\n\tterminalColumns,\n\tusage,\n\ttype UsageSummary,\n\twriteError,\n\twriteOut,\n} from \"../../output.ts\";\nimport { sessionId, threadFlag } from \"../../ids.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\ninterface RenderState {\n\treadonly usage: UsageSummary;\n\treadonly textSeen: boolean;\n\treadonly textEndsWithNewline: boolean;\n\treadonly reason?: EventList.LLMEnded[\"data\"][\"reason\"];\n}\n\nconst initialRenderState: RenderState = {\n\tusage: emptyUsage,\n\ttextSeen: false,\n\ttextEndsWithNewline: false,\n};\n\nconst isTextDelta = Schema.is(EventList.LLMTextDelta);\nconst isLLMEnded = Schema.is(EventList.LLMEnded);\nconst isTurnEnded = Schema.is(EventList.TurnEnded);\n\nconst render = (state: Ref.Ref<RenderState>, ended?: Queue.Queue<string>) =>\n\tEffect.fn(\"CLI.render\")(function* (event: EventSchema.Payload) {\n\t\tif (isTextDelta(event)) {\n\t\t\tyield* writeOut(event.data.delta);\n\t\t\tif (event.data.delta.length > 0) {\n\t\t\t\tyield* Ref.update(state, (current) => ({\n\t\t\t\t\t...current,\n\t\t\t\t\ttextSeen: true,\n\t\t\t\t\ttextEndsWithNewline: event.data.delta.endsWith(\"\\n\"),\n\t\t\t\t}));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (isLLMEnded(event)) {\n\t\t\tyield* Ref.update(state, (current) => ({\n\t\t\t\t...current,\n\t\t\t\tusage: addUsage(current.usage, event.data.message),\n\t\t\t\treason: event.data.reason,\n\t\t\t}));\n\t\t\treturn;\n\t\t}\n\t\tif (ended !== undefined && isTurnEnded(event)) {\n\t\t\tyield* Queue.offer(ended, event.data.messageId);\n\t\t}\n\t});\n\nconst finish = Effect.fn(\"CLI.finish\")(function* (state: Ref.Ref<RenderState>, columns: number) {\n\tconst rendered = yield* Ref.get(state);\n\tif (rendered.textSeen && !rendered.textEndsWithNewline) yield* writeOut(\"\\n\");\n\tyield* writeError(usage(rendered.usage, columns));\n\tif (rendered.reason === \"length\") {\n\t\tyield* writeError(\"Response was truncated: the model reached its output token limit.\\n\");\n\t\tyield* Effect.sync(() => {\n\t\t\tprocess.exitCode = 1;\n\t\t});\n\t}\n});\n\nconst awaitMessage = Effect.fn(\"CLI.awaitMessage\")(function* (ended: Queue.Queue<string>, messageId: string) {\n\twhile ((yield* Queue.take(ended)) !== messageId) {\n\t\t// Earlier turns in the same drain are expected when a tool call continues.\n\t}\n});\n\nconst selectSandbox = Effect.fn(\"CLI.selectSandbox\", { level: \"Info\" })(function* (input: Sandbox.Selection) {\n\tconst selection = yield* Sandbox.resolve(input);\n\tif (selection.created && selection.info !== undefined) {\n\t\tconst id = selection.info.id;\n\t\tyield* Effect.addFinalizer(() => Effect.ignore(Sandbox.stop(id)));\n\t}\n\treturn selection.info;\n});\n\nexport default Runtime.handler(\n\tCmd.commands.run,\n\tEffect.fn(\"CLI.run\", { level: \"Info\" })(function* ({\n\t\tprompt,\n\t\tsession,\n\t\tthread,\n\t\tcwd,\n\t\tsandboxDriver,\n\t\tsandboxProviderId,\n\t\tsandboxId,\n\t\tprovider,\n\t\tmodel,\n\t\tthinking,\n\t\tserver,\n\t}) {\n\t\tconst shared = yield* Cmd.spec;\n\t\tif (\n\t\t\tOption.isSome(session) &&\n\t\t\t(Option.isSome(cwd) ||\n\t\t\t\tOption.isSome(sandboxDriver) ||\n\t\t\t\tOption.isSome(sandboxProviderId) ||\n\t\t\t\tOption.isSome(sandboxId))\n\t\t) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage:\n\t\t\t\t\t\"--cwd, --sandbox-driver, --sandbox-id, and --sandbox-provider-id can only be used when creating a new session\",\n\t\t\t});\n\t\t}\n\t\tif (Option.isSome(thread) && Option.isNone(session)) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--thread continues a thread of --session\" });\n\t\t}\n\t\tconst threadId = yield* threadFlag(thread);\n\t\tconst id = Option.isSome(session) ? yield* sessionId(session.value) : undefined;\n\t\tif (Option.isSome(provider) !== Option.isSome(model)) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--provider and --model must be provided together\" });\n\t\t}\n\t\tif (Option.isSome(sandboxProviderId) && Option.isNone(sandboxDriver)) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--sandbox-provider-id requires a remote --sandbox-driver\",\n\t\t\t});\n\t\t}\n\t\t// --home stays: it names the home whose token reaches the server.\n\t\tif (Option.isSome(server) && [shared.database, shared.userConfigDir].some(Option.isSome)) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--database and --user-config-dir belong on codework serve when using --server\",\n\t\t\t});\n\t\t}\n\n\t\tif (Option.isSome(sandboxId) && (Option.isSome(sandboxDriver) || Option.isSome(sandboxProviderId))) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--sandbox-id cannot be combined with --sandbox-driver or --sandbox-provider-id\",\n\t\t\t});\n\t\t}\n\t\tconst selection: Sandbox.Selection = Option.isSome(sandboxId)\n\t\t\t? { id: Sandbox.SandboxInstance.ID.make(sandboxId.value) }\n\t\t\t: {\n\t\t\t\t\tdriver: Option.getOrElse(sandboxDriver, () => \"local\"),\n\t\t\t\t\t...(Option.isNone(sandboxProviderId) ? {} : { providerResourceId: sandboxProviderId.value }),\n\t\t\t\t};\n\n\t\t// The session's host directory, with no flag to set it: a person running a command is always\n\t\t// somewhere, and that somewhere is what they mean by \"this project\". `--cwd` is a different\n\t\t// thing entirely -- where the work runs inside the session's space, which may be a sandbox\n\t\t// on another machine.\n\t\tconst hostDir = Session.AbsolutePath.make(process.cwd());\n\n\t\tconst runtime = {\n\t\t\t...(Option.isNone(provider) || Option.isNone(model)\n\t\t\t\t? {}\n\t\t\t\t: { model: { provider: provider.value, id: model.value } }),\n\t\t\t...(Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }),\n\t\t};\n\t\tconst remote = Effect.gen(function* () {\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst info =\n\t\t\t\tid !== undefined\n\t\t\t\t\t? yield* rpc[\"thread.configure\"]({\n\t\t\t\t\t\t\tsessionId: id,\n\t\t\t\t\t\t\t...(threadId === undefined ? {} : { threadId }),\n\t\t\t\t\t\t\truntime,\n\t\t\t\t\t\t})\n\t\t\t\t\t: yield* rpc[\"session.create\"]({\n\t\t\t\t\t\t\truntime,\n\t\t\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: cwd.value }),\n\t\t\t\t\t\t\thostDir,\n\t\t\t\t\t\t\tsandbox: selection,\n\t\t\t\t\t\t});\n\t\t\tconst state = yield* Ref.make(initialRenderState);\n\t\t\tconst columns = terminalColumns();\n\t\t\tyield* writeError(\n\t\t\t\theader({\n\t\t\t\t\tsessionId: info.session.id,\n\t\t\t\t\tsandbox: info.session.sandbox?.driver ?? \"local\",\n\t\t\t\t\tdirectory: info.placement?.directory ?? info.session.directory,\n\t\t\t\t\tcolumns,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (info.session.sandbox !== undefined) yield* writeError(`sandbox-id: ${info.session.sandbox.id}\\n`);\n\t\t\tyield* Client.run(rpc, { sessionId: info.session.id, threadId: info.id, text: prompt }, render(state)).pipe(\n\t\t\t\tEffect.onInterrupt(() =>\n\t\t\t\t\trpc[\"thread.interrupt\"]({ sessionId: info.session.id, threadId: info.id }).pipe(\n\t\t\t\t\t\tEffect.timeout(\"5 seconds\"),\n\t\t\t\t\t\tEffect.ignore,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\tyield* finish(state, columns);\n\t\t});\n\t\tconst program = Effect.gen(function* () {\n\t\t\tlet handle: Session.ThreadHandle;\n\t\t\tif (id !== undefined) {\n\t\t\t\thandle = yield* Session.attach({\n\t\t\t\t\tsessionId: id,\n\t\t\t\t\t...(threadId === undefined ? {} : { threadId }),\n\t\t\t\t\t...runtime,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst selected = yield* selectSandbox(selection);\n\t\t\t\tconst created = yield* Session.create({\n\t\t\t\t\t...runtime,\n\t\t\t\t\t...(selected === undefined ? {} : { sandbox: selected }),\n\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: cwd.value }),\n\t\t\t\t\thostDir,\n\t\t\t\t});\n\t\t\t\thandle = created.main;\n\t\t\t}\n\t\t\tconst ended = yield* Queue.unbounded<string>();\n\t\t\tconst renderState = yield* Ref.make(initialRenderState);\n\t\t\tconst printer = yield* handle\n\t\t\t\t.events()\n\t\t\t\t.pipe(Stream.runForEach(render(renderState, ended)), Effect.forkScoped({ startImmediately: true }));\n\n\t\t\tconst info = yield* handle.info;\n\t\t\tconst columns = terminalColumns();\n\t\t\tyield* writeError(\n\t\t\t\theader({\n\t\t\t\t\tsessionId: handle.sessionId,\n\t\t\t\t\tsandbox: info.session.sandbox?.driver ?? \"local\",\n\t\t\t\t\tdirectory: info.placement?.directory ?? info.session.directory,\n\t\t\t\t\tcolumns,\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// The local command joins execution to retain typed error details. Ctrl+C is the user stopping\n\t\t\t// the run, as on the remote path: named so, the next server start does not resume it.\n\t\t\tconst execution = yield* handle.prompt({ text: prompt, delivery: \"followUp\" }).pipe(\n\t\t\t\tEffect.andThen(handle.resume()),\n\t\t\t\tEffect.onInterrupt(() => handle.interrupt().pipe(Effect.timeout(\"5 seconds\"), Effect.ignore)),\n\t\t\t\tEffect.exit,\n\t\t\t);\n\t\t\tyield* handle.wait();\n\t\t\tif (Exit.isFailure(execution)) return yield* Effect.failCause(execution.cause);\n\t\t\tconst leaf = (yield* handle.history()).at(-1);\n\t\t\tif (leaf !== undefined) yield* awaitMessage(ended, leaf.entry.id);\n\t\t\tyield* Fiber.interrupt(printer);\n\t\t\tyield* finish(renderState, columns);\n\t\t});\n\n\t\t// Scope inside the provided layer, so the run's finalizers (stopping a created sandbox) close\n\t\t// while the harness and its database are still open.\n\t\tconst execute = Effect.gen(function* () {\n\t\t\tif (Option.isSome(server)) return yield* remote.pipe(Service.connect(server.value));\n\t\t\t// Stdout carries only the response; harness logs go with the rest of the diagnostics.\n\t\t\treturn yield* program.pipe(\n\t\t\t\tEffect.scoped,\n\t\t\t\tEffect.provide(Harness.layer(harnessOptions(shared))),\n\t\t\t\tEffect.provideService(Logger.LogToStderr, true),\n\t\t\t);\n\t\t});\n\t\treturn yield* execute.pipe(\n\t\t\tEffect.catch((error) =>\n\t\t\t\twriteError(renderError(error)).pipe(\n\t\t\t\t\tEffect.andThen(\n\t\t\t\t\t\tEffect.sync(() => {\n\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\t}),\n);\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