@wular/coder 0.3.18 → 0.4.1
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/README.md +18 -16
- package/bin/coder.mjs +3 -1
- package/dist/actions-Mk3FSlpJ.js +20 -0
- package/dist/adapter-B0oYCI0S.js +1 -0
- package/dist/adapter-BKVzTDnn.js +1 -0
- package/dist/adapter-DPInwbJG.js +1 -0
- package/dist/adapter-DaiJMOYo.js +1 -0
- package/dist/adapter-PeKziOUg.js +1 -0
- package/dist/add-BxpLHnvD.js +1 -0
- package/dist/add-CE-70LFs.js +1 -0
- package/dist/add-U-pty9qJ.js +6 -0
- package/dist/add-ej0X9e3a.js +1 -0
- package/dist/add-json-CEa-6luW.js +1 -0
- package/dist/agent-BsYx3Odz.js +3 -0
- package/dist/agent-JdtZozvP.js +1 -0
- package/dist/alias-DX-Bm86x.js +2 -0
- package/dist/app-BT5f7zL5.js +1 -0
- package/dist/approvals-C-AvFt6s.js +2 -0
- package/dist/approve-DOmpQRNd.js +2 -0
- package/dist/apps-CjfrZyM5.js +1 -0
- package/dist/archive-BUB8gFKD.js +4 -0
- package/dist/archive-BziJ1rQ-.js +3 -0
- package/dist/archive-sweep-CtBcARgN.js +1 -0
- package/dist/args-BOEEdpWk.js +1 -0
- package/dist/ask-dE3U3ss2.js +4 -0
- package/dist/auth-BFny--17.js +1 -0
- package/dist/auth-DWHIzqbA.js +1 -0
- package/dist/builtin/coder/agent.json +24 -0
- package/dist/builtin/coder/system.md +17 -0
- package/dist/chat-3Znsevah.js +1 -0
- package/dist/chat-B_yhNTo0.js +13 -0
- package/dist/chat-bridge-BS9WtP3X.js +2 -0
- package/dist/cli-BilSDkvE.js +9 -0
- package/dist/cli.d.ts +71 -1
- package/dist/cli.js +1 -91
- package/dist/client-D9IoAuDD.js +1 -0
- package/dist/config-Da_cwoxI.js +3 -0
- package/dist/create-C_iMJV4Y.js +1 -0
- package/dist/credentials-B1jv6dkg.js +1 -0
- package/dist/dash/manifest.json +3427 -0
- package/dist/dash/public/assets/apple-touch-icon.png +0 -0
- package/dist/dash/public/assets/chunks/agent-pills-c9c4ac4d4a10df83.js +1 -0
- package/dist/dash/public/assets/chunks/agent-settings-form-8be2ddab074aba6d.js +1 -0
- package/dist/dash/public/assets/chunks/agents-grid-951584b6f4c4314e.js +1 -0
- package/dist/dash/public/assets/chunks/badge-676b01e0c615bf7b.js +1 -0
- package/dist/dash/public/assets/chunks/card-e0901d68b79dfa93.js +1 -0
- package/dist/dash/public/assets/chunks/combo-41234c24668b1db1.js +1 -0
- package/dist/dash/public/assets/chunks/composer-5534be50bc12385e.js +1 -0
- package/dist/dash/public/assets/chunks/composer-d10d4b1d54c4f751.js +1 -0
- package/dist/dash/public/assets/chunks/composer-data-6f7608fed13f3dd7.js +1 -0
- package/dist/dash/public/assets/chunks/confirm-f2fe4ba9905a89c6.js +1 -0
- package/dist/dash/public/assets/chunks/connect-apps-aa2a3d82e48ed8c3.js +1 -0
- package/dist/dash/public/assets/chunks/connect-repositories-5389ec8701a3deac.js +1 -0
- package/dist/dash/public/assets/chunks/credentials-list-bc5bfcab058176c5.js +2 -0
- package/dist/dash/public/assets/chunks/custom-range-4761ab14f05149df.js +1 -0
- package/dist/dash/public/assets/chunks/editor-bfe8cd854f8001be.js +7 -0
- package/dist/dash/public/assets/chunks/engines-list-f1191390f5715b39.js +1 -0
- package/dist/dash/public/assets/chunks/field-901f1f35c18c39c9.js +1 -0
- package/dist/dash/public/assets/chunks/format-eb03fc9d9744d960.js +1 -0
- package/dist/dash/public/assets/chunks/heads-f3bcd289663d48fa.js +1 -0
- package/dist/dash/public/assets/chunks/instructions-052fa45a9daf6db6.js +2 -0
- package/dist/dash/public/assets/chunks/instructions-d0a4b0d95009c262.js +1 -0
- package/dist/dash/public/assets/chunks/list-1d259660d7612c5f.js +1 -0
- package/dist/dash/public/assets/chunks/mcp-list-e3bebbbe831393b8.js +1 -0
- package/dist/dash/public/assets/chunks/model-options-15c53331a2f28a4f.js +1 -0
- package/dist/dash/public/assets/chunks/models-list-44f857a469ca04d5.js +1 -0
- package/dist/dash/public/assets/chunks/paged-bc6fa0c2b9d52ed7.js +1 -0
- package/dist/dash/public/assets/chunks/platform-actions-d1426602049926d2.js +1 -0
- package/dist/dash/public/assets/chunks/runners-list-1901af8a5dea1f09.js +1 -0
- package/dist/dash/public/assets/chunks/runtime-246221e985d863e5-1.js +2 -0
- package/dist/dash/public/assets/chunks/segmented-358ff2b4992b8384.js +1 -0
- package/dist/dash/public/assets/chunks/select-7ae25fd8a7d6c338.js +1 -0
- package/dist/dash/public/assets/chunks/sentinel-c972a33dc69a5135.js +1 -0
- package/dist/dash/public/assets/chunks/shared-init-246221e985d863e5-2.js +1 -0
- package/dist/dash/public/assets/chunks/shared-init-88cce66bb3cfe1e5.js +5 -0
- package/dist/dash/public/assets/chunks/shared-init-8f2ac936c95a7f7b.js +1 -0
- package/dist/dash/public/assets/chunks/shared-init-ffb3397e494137c9.js +2 -0
- package/dist/dash/public/assets/chunks/tail-7c27aab8ba268bd9.js +1 -0
- package/dist/dash/public/assets/chunks/task-actions-8e1d93c788d001df.js +1 -0
- package/dist/dash/public/assets/chunks/task-fa8b82e95e771c4a.js +1 -0
- package/dist/dash/public/assets/chunks/task-view-6d7618d2820a5cb4.js +3 -0
- package/dist/dash/public/assets/chunks/tasks-list-f4784e5cbd0ed785.js +1 -0
- package/dist/dash/public/assets/chunks/toolbar-a75d2570f07cbb70.js +1 -0
- package/dist/dash/public/assets/chunks/versions-list-fc2e0d2a7382e049.js +1 -0
- package/dist/dash/public/assets/chunks/wular-pnext-246221e985d863e5-0.js +1 -0
- package/dist/dash/public/assets/connect-382b1729a7ae7808.css +1 -0
- package/dist/dash/public/assets/dash-9e02d5d1a6d42ee3.css +1 -0
- package/dist/dash/public/assets/dash-account-04859899c1838ada.css +1 -0
- package/dist/dash/public/assets/dash-agents-9e678137267dec07.css +1 -0
- package/dist/dash/public/assets/dash-agents-new-26fa27b17ef9b8d8.css +1 -0
- package/dist/dash/public/assets/dash-agents-param-slug-b975c48f8abf3444.css +1 -0
- package/dist/dash/public/assets/dash-agents-param-slug-edit-e13fda599bb04843.css +1 -0
- package/dist/dash/public/assets/dash-agents-param-slug-platforms-70292932cb27bc96.css +1 -0
- package/dist/dash/public/assets/dash-agents-param-slug-settings-71f9a86251723fcc.css +1 -0
- package/dist/dash/public/assets/dash-agents-param-slug-tasks-fb8eb2ed71006601.css +1 -0
- package/dist/dash/public/assets/dash-agents-param-slug-usage-7c8740f1cdd52c71.css +1 -0
- package/dist/dash/public/assets/dash-settings-8eb818da462227e8.css +1 -0
- package/dist/dash/public/assets/dash-settings-param-tab-849a1a9542e273f5.css +1 -0
- package/dist/dash/public/assets/dash-tasks-81e510e0b6931b42.css +1 -0
- package/dist/dash/public/assets/dash-tasks-param-id-bbd2a83342f2ec10.css +1 -0
- package/dist/dash/public/assets/dash-usage-8e0259e03eaed1bd.css +1 -0
- package/dist/dash/public/assets/favicon.ico +0 -0
- package/dist/dash/public/assets/favicon.svg +1 -0
- package/dist/dash/public/assets/fonts/LICENSE-fira-code +93 -0
- package/dist/dash/public/assets/fonts/fira-code-latin-400-normal-717ee080.woff2 +0 -0
- package/dist/dash/public/assets/fonts/fira-code-latin-500-normal-530b6706.woff2 +0 -0
- package/dist/dash/public/assets/fonts/fira-code-latin-700-normal-98730669.woff2 +0 -0
- package/dist/dash/public/assets/global-d2adbf01910d9df5.css +1 -0
- package/dist/dash/public/assets/login-c129b1ce237be260.css +1 -0
- package/dist/dash/public/assets/pnext-client-03b03b254e525e82.js +1 -0
- package/dist/dash/public/assets/pnext-client-1b9ab0963a8ff77b.js +1 -0
- package/dist/dash/public/assets/pnext-client-1c7859bb888f4ef0.js +1 -0
- package/dist/dash/public/assets/pnext-client-3c748afe963fb05d.js +1 -0
- package/dist/dash/public/assets/pnext-client-4f47c2cae220f107.js +1 -0
- package/dist/dash/public/assets/pnext-client-6ab9fd9b53b794d2.js +1 -0
- package/dist/dash/public/assets/pnext-client-6c241786342498e4.js +1 -0
- package/dist/dash/public/assets/pnext-client-80b56d420f02b808.js +1 -0
- package/dist/dash/public/assets/pnext-client-83135c17bae850a3.js +1 -0
- package/dist/dash/public/assets/pnext-client-8e6fa4302ae0396f.js +1 -0
- package/dist/dash/public/assets/pnext-client-932c9d8cc0717fc8.js +1 -0
- package/dist/dash/public/assets/pnext-client-a42ae63d4de113f9.js +1 -0
- package/dist/dash/public/assets/pnext-client-d2ee6f8c1e337032.js +1 -0
- package/dist/dash/public/assets/pnext-client-d513f65ec23b7f20.js +1 -0
- package/dist/dash/public/assets/pnext-client-ecb88e2a8a109954.js +1 -0
- package/dist/dash/public/assets/pnext-client-f1545ee6270bbf9a.js +1 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/boot-B2MFTRO2.js +30 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/build-tier-XJJSL5FR.js +2704 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-2HFY3DQT.js +208 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-2ICEVELW.js +834 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-3UPROT2C.js +35 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-4P5CMIYT.js +1582 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-4TKZKZ3Q.js +131 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-5RDEILQB.js +437 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-62KEQM43.js +25 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-6KQSWT6D.js +831 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-7DCNCW6O.js +724 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-B4THCTQP.js +22 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-C2LIV2MM.js +172 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-CCATPVTW.js +378 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-COXJAPTU.js +89 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-E6IXL2NJ.js +6270 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-FLGRBFAH.js +1198 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-FTJVHFWD.js +61 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-H523KSIH.js +5151 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-HT6KKX6A.js +20 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-JESFYECC.js +438 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-JRPJM2XY.js +17 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-L2IWDUXG.js +107 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-L5P4Y4UC.js +183 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-NQE46AZN.js +647 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-PA4QEARJ.js +129 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-PZ5AXOLW.js +7146 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-SNVPTULL.js +2397 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-T3QZT3PG.js +220 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-VC5O2SDP.js +72 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-WZX4V6CM.js +231 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-XUUIDXY5.js +627 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/chunk-ZHFDO3PR.js +265 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/compile-CE2DN7ZA.js +18 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/config-UREY7XJT.js +16 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/config-loader-UI2XE3PZ.js +17 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/entry.js +219 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/generate-I2PPTDFD.js +16 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/modules-UVOCE4C2.js +48 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/pipeline-UW47K537.js +963 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/proxy-ITGOVJBW.js +26 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/register-4SA55SWT.js +12579 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/router-JNKHLBCZ.js +505 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/routes-PD6J2NXW.js +54 -0
- package/dist/dash/server/bundle-0.1.5-1508b6c99c0d1e68/tsconfig-defaults-ZXEH7RQK.js +15 -0
- package/dist/default-Bobztoxf.js +1 -0
- package/dist/default-vYPT26DR.js +1 -0
- package/dist/delete-D8gEwoOj.js +4 -0
- package/dist/delete-z1_86nf6.js +2 -0
- package/dist/disable-DVKd-0Xb.js +1 -0
- package/dist/discover-Df-a8K4R.js +3 -0
- package/dist/discover-Dvr_3_Xr.js +1 -0
- package/dist/dispatch-BKeAch9E.js +14 -0
- package/dist/docs-BX65z2Iu.js +2 -0
- package/dist/docs-DKJnqZqt.js +2 -0
- package/dist/enable-C8Zf_wpN.js +1 -0
- package/dist/env-CRf6wkM2.js +1 -0
- package/dist/exec-RZFLclKX.js +11 -0
- package/dist/executor-BvAA7Cgw.js +10 -0
- package/dist/flow/builtin/review.d.ts +157 -0
- package/dist/flow/builtin/review.js +19 -0
- package/dist/flow/index.d.ts +1 -1
- package/dist/flow/index.js +1 -1
- package/dist/flow-17k25MHt.js +1 -0
- package/dist/github-actions-DwUzm4hC.js +24 -0
- package/dist/http-Bkg_OQ6r.js +1 -0
- package/dist/{index-BQ-b77or.d.ts → index-CZjFX5zV.d.ts} +116 -238
- package/dist/init-CoMfFxbG.js +1 -0
- package/dist/integrations-5xCaXSd-.js +1 -0
- package/dist/integrations-BAgdVDhj.js +5 -0
- package/dist/lib/broker.js +3 -3
- package/dist/list-BAKvxSbh.js +4 -0
- package/dist/list-BYiG8Zav.js +2 -0
- package/dist/list-BxEywhHU.js +1 -0
- package/dist/list-C5w01-8q.js +1 -0
- package/dist/list-CIW2joV1.js +1 -0
- package/dist/list-DX-z3SBp.js +3 -0
- package/dist/list-DpCf4G-H.js +4 -0
- package/dist/list-VToARh3C.js +1 -0
- package/dist/load-BpEsAn51.js +2 -0
- package/dist/local-H3uvqEbq.js +1 -0
- package/dist/log-view-dg0TlKLA.js +1 -0
- package/dist/login-BFxX4jJy.js +1 -0
- package/dist/login-DkkslfBx.js +1 -0
- package/dist/logout-BHAtw4Z8.js +1 -0
- package/dist/maintenance-C5FklUw3.js +1 -0
- package/dist/match-CXAjDhg7.js +1 -0
- package/dist/mcp-BgKb2Cdk.js +1 -0
- package/dist/mcp-CCZOAo06.js +1 -0
- package/dist/mcp-server-DGzme0YX.js +1 -0
- package/dist/migrate-C4vM7DQN.js +2 -0
- package/dist/migrate-N-85_N7J.js +1 -0
- package/dist/model-Bs1StDo3.js +1 -0
- package/dist/models-_5LVGC3m.js +1 -0
- package/dist/output-BKeyLbvt.js +5 -0
- package/dist/prompt-CEuBMNhk.js +7 -0
- package/dist/push-CUC55Bqd.js +1 -0
- package/dist/queue-6io_NOP3.js +116 -0
- package/dist/refresh-BIrmrWYq.js +1 -0
- package/dist/remote-miQNTVRa.js +1 -0
- package/dist/remove-B93LNkZI.js +1 -0
- package/dist/remove-C5_xggx7.js +1 -0
- package/dist/remove-CuH8a3L9.js +1 -0
- package/dist/remove-eQ8y5C5p.js +1 -0
- package/dist/rename-CYfy03FE.js +1 -0
- package/dist/result-BEtQZHaY.js +5 -0
- package/dist/result-BzaM3inj.js +15 -0
- package/dist/resume-DYzKvyEw.js +3 -0
- package/dist/review-oIBeECZE.js +7 -0
- package/dist/rolldown-runtime-DT7IzrpZ.js +1 -0
- package/dist/rotate-key-IdMYH7gg.js +1 -0
- package/dist/run-BDYl0CKl.js +2 -0
- package/dist/run-CTtd0Znc.js +5 -0
- package/dist/run-CawRGnOg.js +2 -0
- package/dist/runner-D7ScbIHJ.js +1 -0
- package/dist/runner-sUpWJ_k0.js +1 -0
- package/dist/schema-CU2iFkp8.js +1 -0
- package/dist/sdk.d.ts +1166 -191
- package/dist/sdk.js +1 -1
- package/dist/serve-BTeomYxW.js +1 -0
- package/dist/serve-CE8YV2e9.js +1 -0
- package/dist/serve-CPnmrKyf.js +2 -0
- package/dist/serve-CQKZxzFE.js +4 -0
- package/dist/serve-GmRO89s5.js +12 -0
- package/dist/server-Kb22cWfF.js +1 -0
- package/dist/setup-host-GFTUzzZJ.js +6 -0
- package/dist/shared-DVtzWhUT.js +1 -0
- package/dist/show-CMUg8SJu.js +1 -0
- package/dist/show-COTZEYgc.js +1 -0
- package/dist/status-D26U--p8.js +1 -0
- package/dist/steer-C6uARLp5.js +4 -0
- package/dist/stop-BrGI3hSS.js +1 -0
- package/dist/stop-ByCAlbmN.js +3 -0
- package/dist/store-B94tSate.js +42 -0
- package/dist/store-DzqXS2wT.js +8 -0
- package/dist/task-C6VAg5WU.js +1 -0
- package/dist/task-CgOKgkEG.js +1 -0
- package/dist/task-DeglY79z.js +5 -0
- package/dist/test-NEbhlxvo.js +1 -0
- package/dist/tools-D0Zfs8Hx.js +1 -0
- package/dist/types-D0q15RJa.js +1 -0
- package/dist/types-I5Cwtl_K.d.ts +389 -0
- package/dist/unalias-C9NqmSDq.js +1 -0
- package/dist/update-BTxYQj7Z.js +2 -0
- package/dist/upgrade-hA0yWBvx.js +2 -0
- package/dist/usage-BhqoCjvE.js +1 -0
- package/dist/usage-C4d9X2Uq.js +1 -0
- package/dist/watch-CSdj24ct.js +5 -0
- package/dist/watch-DtRuC0Wc.js +8 -0
- package/dist/wire-BeT1Axeo.js +1 -0
- package/dist/worker-CXndxmGF.js +9 -0
- package/dist/worker-DX7P9kWl.js +1 -0
- package/dist/workflow-Dcmdooi8.js +1 -0
- package/docs/agents/coder.md +26 -0
- package/docs/agents/index.md +120 -0
- package/docs/config.md +51 -30
- package/docs/dash.md +64 -0
- package/docs/flows.md +20 -15
- package/docs/mcp.md +62 -0
- package/docs/models.md +41 -23
- package/docs/review.md +41 -0
- package/docs/sdk.md +57 -38
- package/docs/self-host.md +188 -0
- package/migrations/0000_initial.sql +252 -0
- package/migrations/meta/0000_snapshot.json +1787 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +37 -7
- package/plugins/agents/skills/coder/SKILL.md +14 -60
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/commands/setup.md +2 -2
- package/plugins/claude/skills/dispatch/SKILL.md +14 -58
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/README.md +5 -5
- package/plugins/cursor/assets/logo.png +0 -0
- package/plugins/cursor/skills/coder/SKILL.md +14 -59
- package/src/client/index.ts +573 -0
- package/src/client/types.ts +506 -0
- package/src/core/errors.ts +72 -0
- package/src/core/task/log-view.ts +173 -0
- package/src/server/auth/sign-in.ts +14 -0
- package/src/server/dash/api/load.ts +62 -0
- package/src/server/dash/api/types.ts +11 -0
- package/src/server/dash/app/connect/page.tsx +42 -0
- package/src/server/dash/app/dash/account/loading.tsx +11 -0
- package/src/server/dash/app/dash/account/notify.tsx +42 -0
- package/src/server/dash/app/dash/account/page.css +81 -0
- package/src/server/dash/app/dash/account/page.tsx +126 -0
- package/src/server/dash/app/dash/account/sign-out.tsx +24 -0
- package/src/server/dash/app/dash/agents/(list)/agent-menu.tsx +10 -0
- package/src/server/dash/app/dash/agents/(list)/agents-grid.tsx +143 -0
- package/src/server/dash/app/dash/agents/(list)/connect-apps.tsx +46 -0
- package/src/server/dash/app/dash/agents/(list)/loading.tsx +14 -0
- package/src/server/dash/app/dash/agents/(list)/page.css +72 -0
- package/src/server/dash/app/dash/agents/(list)/page.tsx +89 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/layout.tsx +135 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/loading.tsx +5 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/page.css +21 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/page.tsx +173 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/platforms/loading.tsx +18 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/platforms/page.css +87 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/platforms/page.tsx +258 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/platforms/platform-actions.tsx +111 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/settings/agent-settings-form.css +114 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/settings/agent-settings-form.tsx +294 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/settings/loading.tsx +5 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/settings/page.tsx +54 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/tasks/loading.tsx +5 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/tasks/page.tsx +14 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/usage/loading.tsx +31 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/usage/page.css +12 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/usage/page.tsx +163 -0
- package/src/server/dash/app/dash/agents/[slug]/(tabs)/versions-list.tsx +53 -0
- package/src/server/dash/app/dash/agents/[slug]/edit/loading.tsx +31 -0
- package/src/server/dash/app/dash/agents/[slug]/edit/page.tsx +91 -0
- package/src/server/dash/app/dash/agents/agent/agent-pills.css +27 -0
- package/src/server/dash/app/dash/agents/agent/agent-pills.tsx +133 -0
- package/src/server/dash/app/dash/agents/agent/hero.css +40 -0
- package/src/server/dash/app/dash/agents/agent/hero.tsx +60 -0
- package/src/server/dash/app/dash/agents/agent/instructions.css +29 -0
- package/src/server/dash/app/dash/agents/agent/instructions.tsx +82 -0
- package/src/server/dash/app/dash/agents/editor/connect-repositories.ts +16 -0
- package/src/server/dash/app/dash/agents/editor/editor.css +263 -0
- package/src/server/dash/app/dash/agents/editor/editor.tsx +774 -0
- package/src/server/dash/app/dash/agents/editor/import-picker.css +48 -0
- package/src/server/dash/app/dash/agents/editor/import-picker.tsx +253 -0
- package/src/server/dash/app/dash/agents/editor/names.ts +35 -0
- package/src/server/dash/app/dash/agents/new/loading.tsx +25 -0
- package/src/server/dash/app/dash/agents/new/page.tsx +72 -0
- package/src/server/dash/app/dash/layout.css +265 -0
- package/src/server/dash/app/dash/layout.tsx +332 -0
- package/src/server/dash/app/dash/page.tsx +14 -0
- package/src/server/dash/app/dash/settings/[tab]/credentials-list.css +94 -0
- package/src/server/dash/app/dash/settings/[tab]/credentials-list.tsx +619 -0
- package/src/server/dash/app/dash/settings/[tab]/credentials.tsx +36 -0
- package/src/server/dash/app/dash/settings/[tab]/engines-list.css +16 -0
- package/src/server/dash/app/dash/settings/[tab]/engines-list.tsx +135 -0
- package/src/server/dash/app/dash/settings/[tab]/list.css +98 -0
- package/src/server/dash/app/dash/settings/[tab]/list.tsx +215 -0
- package/src/server/dash/app/dash/settings/[tab]/loading.tsx +6 -0
- package/src/server/dash/app/dash/settings/[tab]/mcp-list.css +43 -0
- package/src/server/dash/app/dash/settings/[tab]/mcp-list.tsx +290 -0
- package/src/server/dash/app/dash/settings/[tab]/models-list.tsx +513 -0
- package/src/server/dash/app/dash/settings/[tab]/page.tsx +89 -0
- package/src/server/dash/app/dash/settings/[tab]/runners-list.css +153 -0
- package/src/server/dash/app/dash/settings/[tab]/runners-list.tsx +457 -0
- package/src/server/dash/app/dash/settings/layout.tsx +50 -0
- package/src/server/dash/app/dash/settings/model-options.ts +117 -0
- package/src/server/dash/app/dash/settings/page.tsx +7 -0
- package/src/server/dash/app/dash/settings/settings-head.tsx +24 -0
- package/src/server/dash/app/dash/settings/tunnel-guide.tsx +28 -0
- package/src/server/dash/app/dash/tasks/[id]/activity.tsx +202 -0
- package/src/server/dash/app/dash/tasks/[id]/loading.tsx +31 -0
- package/src/server/dash/app/dash/tasks/[id]/page.tsx +30 -0
- package/src/server/dash/app/dash/tasks/[id]/task-actions.tsx +164 -0
- package/src/server/dash/app/dash/tasks/[id]/task-view.css +407 -0
- package/src/server/dash/app/dash/tasks/[id]/task-view.tsx +513 -0
- package/src/server/dash/app/dash/tasks/composer-data.ts +96 -0
- package/src/server/dash/app/dash/tasks/composer.css +316 -0
- package/src/server/dash/app/dash/tasks/composer.tsx +890 -0
- package/src/server/dash/app/dash/tasks/list/status.css +50 -0
- package/src/server/dash/app/dash/tasks/list/status.tsx +20 -0
- package/src/server/dash/app/dash/tasks/list/task.ts +45 -0
- package/src/server/dash/app/dash/tasks/list/tasks-list.css +85 -0
- package/src/server/dash/app/dash/tasks/list/tasks-list.tsx +402 -0
- package/src/server/dash/app/dash/tasks/list/tasks-section.tsx +96 -0
- package/src/server/dash/app/dash/tasks/page.tsx +53 -0
- package/src/server/dash/app/dash/token-from-hash.tsx +17 -0
- package/src/server/dash/app/dash/usage/custom-range.tsx +63 -0
- package/src/server/dash/app/dash/usage/day-chart.css +109 -0
- package/src/server/dash/app/dash/usage/day-chart.tsx +110 -0
- package/src/server/dash/app/dash/usage/loading.tsx +17 -0
- package/src/server/dash/app/dash/usage/metric.ts +13 -0
- package/src/server/dash/app/dash/usage/page.tsx +117 -0
- package/src/server/dash/app/dash/usage/range-bar.css +13 -0
- package/src/server/dash/app/dash/usage/range-bar.tsx +69 -0
- package/src/server/dash/app/dash/usage/stats.css +52 -0
- package/src/server/dash/app/dash/usage/stats.tsx +19 -0
- package/src/server/dash/app/dash/usage/top-agents.css +40 -0
- package/src/server/dash/app/dash/usage/top-agents.tsx +138 -0
- package/src/server/dash/app/dash/usage/usage.css +0 -0
- package/src/server/dash/app/globals.css +692 -0
- package/src/server/dash/app/layout.tsx +52 -0
- package/src/server/dash/app/login/page.css +26 -0
- package/src/server/dash/app/login/page.tsx +57 -0
- package/src/server/dash/app/page.tsx +5 -0
- package/src/server/dash/app/responsive.css +49 -0
- package/src/server/dash/app/zone.tsx +13 -0
- package/src/server/dash/comps/frame/auth-panel.css +60 -0
- package/src/server/dash/comps/frame/auth-panel.tsx +44 -0
- package/src/server/dash/comps/frame/drawer.css +28 -0
- package/src/server/dash/comps/frame/drawer.tsx +39 -0
- package/src/server/dash/comps/frame/heads.ts +41 -0
- package/src/server/dash/comps/frame/loading-card.tsx +65 -0
- package/src/server/dash/comps/frame/page-head.css +83 -0
- package/src/server/dash/comps/frame/page-head.tsx +71 -0
- package/src/server/dash/comps/frame/stream.tsx +50 -0
- package/src/server/dash/comps/frame/task-toasts.tsx +214 -0
- package/src/server/dash/comps/frame/theme-choices.tsx +46 -0
- package/src/server/dash/comps/nav/current-link.tsx +53 -0
- package/src/server/dash/comps/nav/side-toggle.tsx +30 -0
- package/src/server/dash/comps/nav/to.ts +22 -0
- package/src/server/dash/comps/ui/badge.css +64 -0
- package/src/server/dash/comps/ui/badge.tsx +41 -0
- package/src/server/dash/comps/ui/card.css +93 -0
- package/src/server/dash/comps/ui/card.tsx +77 -0
- package/src/server/dash/comps/ui/collapse.css +32 -0
- package/src/server/dash/comps/ui/collapse.tsx +49 -0
- package/src/server/dash/comps/ui/combo.tsx +154 -0
- package/src/server/dash/comps/ui/confirm.css +36 -0
- package/src/server/dash/comps/ui/confirm.tsx +67 -0
- package/src/server/dash/comps/ui/field.css +25 -0
- package/src/server/dash/comps/ui/field.tsx +34 -0
- package/src/server/dash/comps/ui/icon.css +22 -0
- package/src/server/dash/comps/ui/icon.tsx +17 -0
- package/src/server/dash/comps/ui/icons.ts +44 -0
- package/src/server/dash/comps/ui/menu.css +178 -0
- package/src/server/dash/comps/ui/menu.tsx +152 -0
- package/src/server/dash/comps/ui/segmented.css +44 -0
- package/src/server/dash/comps/ui/segmented.tsx +58 -0
- package/src/server/dash/comps/ui/select.css +103 -0
- package/src/server/dash/comps/ui/select.tsx +250 -0
- package/src/server/dash/comps/ui/sentinel.css +58 -0
- package/src/server/dash/comps/ui/sentinel.tsx +67 -0
- package/src/server/dash/comps/ui/tabs.css +81 -0
- package/src/server/dash/comps/ui/tabs.tsx +32 -0
- package/src/server/dash/comps/ui/tail.css +12 -0
- package/src/server/dash/comps/ui/tail.tsx +37 -0
- package/src/server/dash/comps/ui/toast.css +72 -0
- package/src/server/dash/comps/ui/toolbar.css +143 -0
- package/src/server/dash/comps/ui/toolbar.tsx +93 -0
- package/src/server/dash/package.json +5 -0
- package/src/server/dash/pnext-env.d.ts +4 -0
- package/src/server/dash/pnext.config.ts +5 -0
- package/src/server/dash/public/assets/apple-touch-icon.png +0 -0
- package/src/server/dash/public/assets/favicon.ico +0 -0
- package/src/server/dash/public/assets/favicon.svg +1 -0
- package/src/server/dash/public/assets/fonts/LICENSE-fira-code +93 -0
- package/src/server/dash/public/assets/fonts/fira-code-latin-400-normal-717ee080.woff2 +0 -0
- package/src/server/dash/public/assets/fonts/fira-code-latin-500-normal-530b6706.woff2 +0 -0
- package/src/server/dash/public/assets/fonts/fira-code-latin-700-normal-98730669.woff2 +0 -0
- package/src/server/dash/tsconfig.json +10 -0
- package/src/server/dash/utils/client.ts +19 -0
- package/src/server/dash/utils/format.ts +75 -0
- package/src/server/dash/utils/paged.ts +184 -0
- package/src/server/dash/utils/range.ts +117 -0
- package/dist/app-server-CW93J9zJ.js +0 -3
- package/dist/runtime-D-U1DNkI.js +0 -26
- package/dist/upgrade-DOj06r5b.js +0 -37
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ServerClient } from '@coder/client';
|
|
4
|
+
|
|
5
|
+
export const client = new ServerClient(
|
|
6
|
+
'',
|
|
7
|
+
{ cookie: true },
|
|
8
|
+
{
|
|
9
|
+
onError(error) {
|
|
10
|
+
if (error.status === 401 && (error.authenticate || /^Sign in/.test(error.message)))
|
|
11
|
+
location.href = `/login?return=${encodeURIComponent(location.pathname + location.search)}`;
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export async function signOut(): Promise<void> {
|
|
17
|
+
const { url } = await client.signOut();
|
|
18
|
+
location.href = url ?? '/?signed_out=1';
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Formats shared by server pages and islands; `tz` is the browser's zone from the `tz` cookie. */
|
|
2
|
+
|
|
3
|
+
export function zoneOf(request: Request): string {
|
|
4
|
+
const match = (request.headers.get('cookie') ?? '').match(/(?:^|; )tz=([^;]+)/);
|
|
5
|
+
const value = match ? decodeURIComponent(match[1]!) : '';
|
|
6
|
+
try {
|
|
7
|
+
if (value) new Intl.DateTimeFormat('en-US', { timeZone: value });
|
|
8
|
+
return value || 'UTC';
|
|
9
|
+
} catch {
|
|
10
|
+
return 'UTC';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const parts = (value: number, tz: string, options: Intl.DateTimeFormatOptions) =>
|
|
15
|
+
Object.fromEntries(
|
|
16
|
+
new Intl.DateTimeFormat('en-US', { ...options, timeZone: tz })
|
|
17
|
+
.formatToParts(value)
|
|
18
|
+
.map(part => [part.type, part.value]),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Built from parts, so every ICU version, on the server or in the browser, prints the same text.
|
|
22
|
+
export function formatDate(value: number | undefined, tz: string) {
|
|
23
|
+
if (!value) return 'Not available';
|
|
24
|
+
const p = parts(value, tz, {
|
|
25
|
+
month: 'short',
|
|
26
|
+
day: 'numeric',
|
|
27
|
+
year: 'numeric',
|
|
28
|
+
hour: 'numeric',
|
|
29
|
+
minute: '2-digit',
|
|
30
|
+
hour12: true,
|
|
31
|
+
});
|
|
32
|
+
return `${p.month} ${p.day}, ${p.year}, ${p.hour}:${p.minute} ${p.dayPeriod}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The time of day as `formatDate` prints it, with seconds. */
|
|
36
|
+
export function formatTime(value: number, tz: string) {
|
|
37
|
+
const p = parts(value, tz, {
|
|
38
|
+
hour: 'numeric',
|
|
39
|
+
minute: '2-digit',
|
|
40
|
+
second: '2-digit',
|
|
41
|
+
hour12: true,
|
|
42
|
+
});
|
|
43
|
+
return `${p.hour}:${p.minute}:${p.second} ${p.dayPeriod}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function formatDay(value: number, tz: string) {
|
|
47
|
+
const p = parts(value, tz, {
|
|
48
|
+
month: 'short',
|
|
49
|
+
day: 'numeric',
|
|
50
|
+
year: 'numeric',
|
|
51
|
+
});
|
|
52
|
+
return `${p.month} ${p.day}, ${p.year}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function formatDuration(value?: number) {
|
|
56
|
+
if (value === undefined) return 'Not available';
|
|
57
|
+
if (value < 1000) return `${Math.round(value)} ms`;
|
|
58
|
+
if (value < 60_000) return `${(value / 1000).toFixed(1)} s`;
|
|
59
|
+
const [unit, size] =
|
|
60
|
+
value < 3_600_000
|
|
61
|
+
? (['min', 60_000] as const)
|
|
62
|
+
: value < 172_800_000
|
|
63
|
+
? (['h', 3_600_000] as const)
|
|
64
|
+
: (['d', 86_400_000] as const);
|
|
65
|
+
return `${(value / size).toLocaleString('en-US', { minimumFractionDigits: 1, maximumFractionDigits: 1 })} ${unit}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const formatCount = (value: number) => value.toLocaleString('en-US');
|
|
69
|
+
|
|
70
|
+
export function initial(name?: string) {
|
|
71
|
+
return (name ?? '?').trim().charAt(0).toUpperCase() || '?';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const reasonText = (reason: unknown) =>
|
|
75
|
+
reason instanceof Error ? reason.message : String(reason);
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
2
|
+
|
|
3
|
+
import type { Paged } from '@coder/client/types';
|
|
4
|
+
|
|
5
|
+
type Kept = { query: string; rows: unknown[]; next?: string; meta?: unknown };
|
|
6
|
+
|
|
7
|
+
const entry = (name: string) =>
|
|
8
|
+
`${(history.state as { __pnextEntry?: string } | null)?.__pnextEntry ?? location.pathname}|${name}`;
|
|
9
|
+
const savedRows = (name: string): Kept | undefined => history.state?.coderPages?.[name];
|
|
10
|
+
const saveRows = (name: string, rows: Kept) =>
|
|
11
|
+
history.replaceState(
|
|
12
|
+
{ ...history.state, coderPages: { ...history.state?.coderPages, [name]: rows } },
|
|
13
|
+
'',
|
|
14
|
+
);
|
|
15
|
+
const FRESH_MS = 60_000;
|
|
16
|
+
|
|
17
|
+
/** Passes `value` on once a loader shown since `since` has stayed its 300 ms; one that never showed holds nothing. */
|
|
18
|
+
export const held =
|
|
19
|
+
(since: number) =>
|
|
20
|
+
<T>(value: T) =>
|
|
21
|
+
new Promise<T>(done => {
|
|
22
|
+
const waited = performance.now() - since;
|
|
23
|
+
setTimeout(done, waited > 150 ? 450 - waited : 0, value);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const fromPage = (query: string, page: Paged<unknown>): Kept => ({
|
|
27
|
+
query,
|
|
28
|
+
rows: page.items,
|
|
29
|
+
next: page.next,
|
|
30
|
+
meta: page,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** Cursor pages; the server renders the first, more load near the end, a new `query` starts over. */
|
|
34
|
+
export function usePaged<T>({
|
|
35
|
+
name,
|
|
36
|
+
query,
|
|
37
|
+
first,
|
|
38
|
+
initial,
|
|
39
|
+
root,
|
|
40
|
+
fetchPage,
|
|
41
|
+
}: {
|
|
42
|
+
name: string;
|
|
43
|
+
/** What the rows are filtered by. */
|
|
44
|
+
query: string;
|
|
45
|
+
/** The server's first page, and the query it answered. */
|
|
46
|
+
first: Paged<T>;
|
|
47
|
+
initial: string;
|
|
48
|
+
/** A scrolling box, when the list scrolls inside one instead of the page. */
|
|
49
|
+
root?: () => Element | null;
|
|
50
|
+
/** For APIs with their own paging shape. */
|
|
51
|
+
fetchPage: (cursor: string) => Promise<Paged<T>>;
|
|
52
|
+
}) {
|
|
53
|
+
const firstPages = useRef(
|
|
54
|
+
new Map<string, { page: Paged<unknown>; at: number }>([
|
|
55
|
+
[initial, { page: first, at: Date.now() }],
|
|
56
|
+
]),
|
|
57
|
+
);
|
|
58
|
+
const [state, setState] = useState<Kept>(() => fromPage(initial, first));
|
|
59
|
+
const [error, setError] = useState('');
|
|
60
|
+
const [busy, setBusy] = useState(false);
|
|
61
|
+
const sentinel = useRef<HTMLElement>(null);
|
|
62
|
+
const live = useRef(state);
|
|
63
|
+
live.current = state;
|
|
64
|
+
const loading = useRef<string | undefined>(undefined);
|
|
65
|
+
const failed = useRef<(() => void) | undefined>(undefined);
|
|
66
|
+
|
|
67
|
+
const load = (cursor: string, forQuery: string, append: boolean) => {
|
|
68
|
+
const key = `${forQuery}|${cursor}`;
|
|
69
|
+
if (loading.current === key) return;
|
|
70
|
+
loading.current = key;
|
|
71
|
+
setError('');
|
|
72
|
+
setBusy(true);
|
|
73
|
+
const since = performance.now();
|
|
74
|
+
const at = entry(name);
|
|
75
|
+
const cached = append ? undefined : firstPages.current.get(forQuery);
|
|
76
|
+
if (cached && Date.now() - cached.at < FRESH_MS) setState(fromPage(forQuery, cached.page));
|
|
77
|
+
void fetchPage(cursor)
|
|
78
|
+
.then(held(since))
|
|
79
|
+
.then(page => {
|
|
80
|
+
if (loading.current !== key) return;
|
|
81
|
+
if (!append) firstPages.current.set(forQuery, { page, at: Date.now() });
|
|
82
|
+
setError('');
|
|
83
|
+
failed.current = undefined;
|
|
84
|
+
setState(current => {
|
|
85
|
+
const next =
|
|
86
|
+
append && current.query === forQuery
|
|
87
|
+
? {
|
|
88
|
+
...current,
|
|
89
|
+
rows: [...current.rows, ...page.items],
|
|
90
|
+
next: page.next,
|
|
91
|
+
}
|
|
92
|
+
: fromPage(forQuery, page);
|
|
93
|
+
if (entry(name) === at) saveRows(name, next);
|
|
94
|
+
return next;
|
|
95
|
+
});
|
|
96
|
+
})
|
|
97
|
+
.catch(reason => {
|
|
98
|
+
if (loading.current !== key) return;
|
|
99
|
+
failed.current = () => load(cursor, forQuery, append);
|
|
100
|
+
setError(reason instanceof Error ? reason.message : String(reason));
|
|
101
|
+
})
|
|
102
|
+
.finally(() => {
|
|
103
|
+
if (loading.current !== key) return;
|
|
104
|
+
loading.current = undefined;
|
|
105
|
+
setBusy(false);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
useEffect(
|
|
110
|
+
() => () => {
|
|
111
|
+
loading.current = undefined;
|
|
112
|
+
},
|
|
113
|
+
[],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// A refresh hands the island a new first page.
|
|
117
|
+
const seen = useRef(first);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (seen.current === first) return;
|
|
120
|
+
seen.current = first;
|
|
121
|
+
firstPages.current.set(initial, { page: first, at: Date.now() });
|
|
122
|
+
setState(fromPage(initial, first));
|
|
123
|
+
}, [first]);
|
|
124
|
+
|
|
125
|
+
// A new query drops any load for another; back to this entry: the rows it had; else its first page.
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
loading.current = undefined;
|
|
128
|
+
failed.current = undefined;
|
|
129
|
+
setError('');
|
|
130
|
+
setBusy(false);
|
|
131
|
+
const saved = savedRows(name);
|
|
132
|
+
if (saved && saved.query === query && saved.rows.length > live.current.rows.length) {
|
|
133
|
+
setState(saved);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (query !== live.current.query) load('', query, false);
|
|
137
|
+
}, [query]);
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const mark = sentinel.current;
|
|
141
|
+
if (!mark || !state.next || error) return;
|
|
142
|
+
const observer = new IntersectionObserver(
|
|
143
|
+
([seen]) => {
|
|
144
|
+
if (seen?.isIntersecting && live.current.next && live.current.query === query)
|
|
145
|
+
load(live.current.next, query, true);
|
|
146
|
+
},
|
|
147
|
+
{ root: root?.() ?? null, rootMargin: '0px 0px 300px 0px' },
|
|
148
|
+
);
|
|
149
|
+
observer.observe(mark);
|
|
150
|
+
return () => observer.disconnect();
|
|
151
|
+
}, [state.next, state.rows.length, query, error]);
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
rows: state.rows as T[],
|
|
155
|
+
/** The first page as the server sent it, for totals that ride along. */
|
|
156
|
+
meta: state.meta as Paged<T> & Record<string, unknown>,
|
|
157
|
+
more: Boolean(state.next),
|
|
158
|
+
busy,
|
|
159
|
+
error,
|
|
160
|
+
stale: busy && state.query !== query,
|
|
161
|
+
sentinel,
|
|
162
|
+
retry: () => {
|
|
163
|
+
setError('');
|
|
164
|
+
failed.current?.();
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Filters live in the address bar, so a reload or a shared link shows the same list. */
|
|
170
|
+
export function writeQuery(values: Record<string, string>) {
|
|
171
|
+
const url = new URL(location.href);
|
|
172
|
+
for (const [key, value] of Object.entries(values))
|
|
173
|
+
if (value) url.searchParams.set(key, value);
|
|
174
|
+
else url.searchParams.delete(key);
|
|
175
|
+
history.replaceState(history.state, '', url);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function readQuery(keys: string[]): Record<string, string> {
|
|
179
|
+
const params = new URLSearchParams(location.search);
|
|
180
|
+
return Object.fromEntries(keys.map(key => [key, params.get(key) ?? '']));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Rows a list loads per page; more load as it scrolls. */
|
|
184
|
+
export const LIST_PAGE = 20;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** Usage ranges: presets back from now, or whole days from one date to another in the viewer's zone. */
|
|
2
|
+
|
|
3
|
+
const DAY = 86_400_000;
|
|
4
|
+
const timeKey = Symbol('coder.dashboard.time');
|
|
5
|
+
|
|
6
|
+
/** Repeated renders keep the same usage bounds and share their reads. */
|
|
7
|
+
export function rangeFor(request: Request, tz: string): Range {
|
|
8
|
+
const render = request as Request & { [timeKey]?: number };
|
|
9
|
+
const now = (render[timeKey] ??= Date.now());
|
|
10
|
+
return rangeOf(new URL(request.url).searchParams, tz, now);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PRESETS: Record<string, { label: string; short: string; span: number }> = {
|
|
14
|
+
'24h': { label: 'Last 24 hours', short: '24h', span: DAY },
|
|
15
|
+
'7d': { label: 'Last 7 days', short: '7d', span: 7 * DAY },
|
|
16
|
+
'30d': { label: 'Last 30 days', short: '30d', span: 30 * DAY },
|
|
17
|
+
'90d': { label: 'Last 90 days', short: '90d', span: 90 * DAY },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export interface Range {
|
|
21
|
+
key: string;
|
|
22
|
+
label: string;
|
|
23
|
+
since: number;
|
|
24
|
+
until: number;
|
|
25
|
+
/** The query that selects it, without a leading `?`. */
|
|
26
|
+
query: string;
|
|
27
|
+
from?: string;
|
|
28
|
+
to?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
32
|
+
|
|
33
|
+
/** Milliseconds `tz` is ahead of UTC at `at`. */
|
|
34
|
+
function offset(at: number, tz: string): number {
|
|
35
|
+
const parts = Object.fromEntries(
|
|
36
|
+
new Intl.DateTimeFormat('en-US', {
|
|
37
|
+
timeZone: tz,
|
|
38
|
+
hourCycle: 'h23',
|
|
39
|
+
year: 'numeric',
|
|
40
|
+
month: '2-digit',
|
|
41
|
+
day: '2-digit',
|
|
42
|
+
hour: '2-digit',
|
|
43
|
+
minute: '2-digit',
|
|
44
|
+
second: '2-digit',
|
|
45
|
+
})
|
|
46
|
+
.formatToParts(at)
|
|
47
|
+
.map(part => [part.type, Number(part.value)]),
|
|
48
|
+
);
|
|
49
|
+
return (
|
|
50
|
+
Date.UTC(parts.year!, parts.month! - 1, parts.day!, parts.hour!, parts.minute!, parts.second!) -
|
|
51
|
+
Math.floor(at / 1000) * 1000
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Midnight at the start of `date` (YYYY-MM-DD) in `tz`. */
|
|
56
|
+
export function startOfDay(date: string, tz: string): number {
|
|
57
|
+
const [y, m, d] = date.split('-').map(Number);
|
|
58
|
+
const guess = Date.UTC(y!, m! - 1, d!);
|
|
59
|
+
return guess - offset(guess - offset(guess, tz), tz);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function dayOf(at: number, tz: string): string {
|
|
63
|
+
return new Intl.DateTimeFormat('en-CA', {
|
|
64
|
+
timeZone: tz,
|
|
65
|
+
year: 'numeric',
|
|
66
|
+
month: '2-digit',
|
|
67
|
+
day: '2-digit',
|
|
68
|
+
}).format(at);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function nextDay(date: string): string {
|
|
72
|
+
const [y, m, d] = date.split('-').map(Number);
|
|
73
|
+
return new Date(Date.UTC(y!, m! - 1, d! + 1)).toISOString().slice(0, 10);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const short = (date: string) =>
|
|
77
|
+
new Date(`${date}T12:00:00Z`).toLocaleDateString('en-US', {
|
|
78
|
+
month: 'short',
|
|
79
|
+
day: 'numeric',
|
|
80
|
+
timeZone: 'UTC',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export function rangeOf(params: URLSearchParams, tz: string, now = Date.now()): Range {
|
|
84
|
+
const from = params.get('from') ?? '';
|
|
85
|
+
const to = params.get('to') ?? '';
|
|
86
|
+
if (DATE.test(from) && DATE.test(to) && from <= to) {
|
|
87
|
+
const since = startOfDay(from, tz);
|
|
88
|
+
return {
|
|
89
|
+
key: 'custom',
|
|
90
|
+
label: `${short(from)} to ${short(to)}`,
|
|
91
|
+
since,
|
|
92
|
+
until: Math.min(startOfDay(nextDay(to), tz), now),
|
|
93
|
+
query: `from=${from}&to=${to}`,
|
|
94
|
+
from,
|
|
95
|
+
to,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const key = params.get('range') ?? '';
|
|
99
|
+
const chosen = Object.hasOwn(PRESETS, key) ? key : '7d';
|
|
100
|
+
const preset = PRESETS[chosen]!;
|
|
101
|
+
return {
|
|
102
|
+
key: chosen,
|
|
103
|
+
label: preset.label,
|
|
104
|
+
since: now - preset.span,
|
|
105
|
+
until: now,
|
|
106
|
+
query: `range=${chosen}`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Every day the range touches, oldest first. */
|
|
111
|
+
export function daysIn(range: Range, tz: string): string[] {
|
|
112
|
+
const days: string[] = [];
|
|
113
|
+
const last = dayOf(range.until - 1, tz);
|
|
114
|
+
for (let day = dayOf(range.since, tz); day <= last && days.length < 400; day = nextDay(day))
|
|
115
|
+
days.push(day);
|
|
116
|
+
return days;
|
|
117
|
+
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import e from"node:process";import t from"node:fs";import n from"node:path";import{execFileSync as r,spawn as i,spawnSync as a}from"node:child_process";import o from"node:os";import{fileURLToPath as s}from"node:url";import*as c from"zod/mini";import l from"node:net";import u from"node:readline";function d(e){try{let t=i(`codex`,[`archive`,e],{detached:!0,stdio:`ignore`});t.on(`error`,()=>{}),t.unref()}catch{}}function f(e){let r=n.join(process.env.CODEX_HOME||n.join(o.homedir(),`.codex`),`archived_sessions`);try{return t.readdirSync(r).some(t=>t.endsWith(`-${e}.jsonl`))}catch{return!1}}function p(e){return new Promise(t=>{try{let n=i(`codex`,[`unarchive`,e],{stdio:`ignore`});n.on(`error`,()=>t(!1)),n.on(`close`,e=>t(e===0))}catch{t(!1)}})}function ee(e){return a(`codex`,[`delete`,`--force`,e],{encoding:`utf8`}).status===0}const m=[`completed`,`failed`,`cancelled`],te=[`queued`,`running`],ne=/^[a-z0-9][a-z0-9_-]*$/i;function h(e){return ne.test(e)}function g(e,t){if(!h(e))throw Error(`Invalid ${t} "${e}".`)}function _(){return n.resolve(process.env.CODER_HOME||n.join(o.homedir(),`.coder`))}const v=new Map;function re(e){let t=v.get(e);if(t!==void 0)return t;let n;try{n=r(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{n=e}return v.set(e,n),n}const y=`global`;function b(e){return n.join(_(),`state`,y)}let x=null;function S(){if(x)return x;let e=n.join(_(),`state`),r=[];try{r=t.readdirSync(e,{withFileTypes:!0})}catch{}return x=r.filter(e=>e.isDirectory()&&e.name!==y).map(t=>n.join(e,t.name)),x}function C(e){return n.join(b(e),`jobs`)}const ie=6e5;function w(e){return n.join(b(e),`archive`)}function T(e,r){g(r,`task id`);let i=n.join(C(e),r);if(t.existsSync(n.join(i,`job.json`)))return i;let a=n.join(w(e),r);if(t.existsSync(n.join(a,`job.json`)))return a;for(let e of S()){let i=n.join(e,`jobs`,r);if(t.existsSync(n.join(i,`job.json`)))return i}return i}function E(e,t){return t.archived?t:O(e,t.id,{archived:!0,archivedAt:new Date().toISOString()})}function D(e,r){let i=E(e,r);r.engine===`codex`&&r.threadId&&d(r.threadId);let a=T(e,r.id),o=n.join(w(e),r.id);if(a!==o)try{t.mkdirSync(w(e),{recursive:!0}),t.renameSync(a,o)}catch{}return i}function ae(){let e=Math.random().toString(36).slice(2,8);return`task-${Date.now().toString(36)}-${e}`}function O(e,r,i){let a=T(e,r);t.mkdirSync(a,{recursive:!0});let o=n.join(a,`job.json`),s={...A(e,r)??{id:r,createdAt:new Date().toISOString(),status:`queued`},...i,updatedAt:new Date().toISOString()};return t.writeFileSync(o,`${JSON.stringify(s,null,2)}\n`,`utf8`),s}function k(e){return!e.engine&&(e.agent===`codex`||e.agent===`claude`)&&(e.engine=e.agent),e}function A(e,r){if(!h(r))return null;let i=n.join(T(e,r),`job.json`);if(!t.existsSync(i))return null;try{return k(JSON.parse(t.readFileSync(i,`utf8`)))}catch{return null}}function oe(e,n){let r=T(e,n);return t.existsSync(r)?(t.rmSync(r,{recursive:!0,force:!0}),!0):!1}function se(e){if(!e)return!1;try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const j=new Map;function M(e){let t=j.get(e);if(t&&Date.now()-t.at<5e3)return t.value;let n=ce(e);return j.set(e,{at:Date.now(),value:n}),n}function ce(e){try{let t=r(`ps`,[`-o`,`lstart=`,`-p`,String(e)],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`],env:{...process.env,TZ:Intl.DateTimeFormat().resolvedOptions().timeZone}}).trim(),n=t?Date.parse(t):NaN;return Number.isFinite(n)?n:null}catch{return null}}function le(e,t){if(!se(e))return!1;let n=M(e),r=Date.parse(t.resumedAt??t.createdAt??``);return n===null||!Number.isFinite(r)||n<=r+6e4}function N(e,t){if(t.status!==`running`&&t.status!==`queued`)return t;let n;if(t.pid)n=!le(t.pid,t);else{let e=Date.parse(t.updatedAt??t.createdAt??``);n=Number.isFinite(e)&&Date.now()-e>6e4}return n?O(e,t.id,{status:`failed`,error:`worker exited without finishing`,completedAt:new Date().toISOString()}):t}function P(e,r){let i=[];for(let a of e){let e=[];try{e=t.readdirSync(a)}catch{continue}for(let o of e){if(r.has(o))continue;let e=n.join(a,o,`job.json`);try{let n=k(JSON.parse(t.readFileSync(e,`utf8`)));r.add(o),i.push(n)}catch{}}}return i}const F=(e,t)=>String(t.updatedAt??``).localeCompare(String(e.updatedAt??``));function ue(e){let t=[C(e),...S().map(e=>n.join(e,`jobs`))],r=[];for(let n of P(t,new Set))n.archived?D(e,n):r.push(N(e,n));return r.sort(F)}function I(e,t){let r=t?.migrate??!0,i=new Set,a=P([w(e)],i),o=[C(e),...S().map(e=>n.join(e,`jobs`))];for(let t of P(o,i))t.archived&&a.push(r?D(e,t):t);return a.sort(F)}function de(e,t){let n=[...ue(e),...I(e)].sort(F);if(!t)return n[0]??null;let r=n.find(e=>e.id===t);if(r)return r;let i=n.filter(e=>e.id.startsWith(t));if(i.length===1)return i[0];if(i.length>1)throw Error(`Job reference "${t}" is ambiguous. Use a longer id.`);return null}function fe(e,r){let i=T(e,r);try{t.mkdirSync(i,{recursive:!0}),t.writeFileSync(n.join(i,`heartbeat`),``,`utf8`)}catch{}}function pe(e,r){let i=T(e,r.id),a=Date.parse(r.updatedAt??``)||0;for(let e of[`log.jsonl`,`heartbeat`])try{a=Math.max(a,t.statSync(n.join(i,e)).mtimeMs)}catch{}return a?new Date(a).toISOString():void 0}async function me(e,t,n=400){let r=t;for(;!m.includes(r.status);)await new Promise(e=>setTimeout(e,n)),r=N(e,A(e,r.id)??r);return r}const L=`steer-queue.jsonl`;function he(e,r,i){let a=T(e,r);t.mkdirSync(a,{recursive:!0}),t.appendFileSync(n.join(a,L),`${JSON.stringify({at:new Date().toISOString(),text:i})}\n`,`utf8`)}function ge(e,r){let i=T(e,r),a=n.join(i,L),o=n.join(i,`steer-claim-${process.pid}-${Date.now()}.tmp`);try{t.renameSync(a,o)}catch{return[]}try{return t.readFileSync(o,`utf8`).split(/\r?\n/).filter(Boolean).map(e=>{try{return String(JSON.parse(e).text??``)}catch{return``}}).filter(Boolean)}finally{try{t.unlinkSync(o)}catch{}}}function _e(e,r,i){let a=T(e,r);t.mkdirSync(a,{recursive:!0}),t.appendFileSync(n.join(a,`log.jsonl`),`${JSON.stringify({at:new Date().toISOString(),...i})}\n`,`utf8`)}function ve(e,r){let i=n.join(T(e,r),`results.jsonl`);return t.existsSync(i)?t.readFileSync(i,`utf8`).split(/\r?\n/).filter(Boolean).flatMap(e=>{try{return[JSON.parse(e)]}catch{return[]}}):[]}function ye(e,t){if(t<=0)return[];let n=0;for(let r=e.length-1;r>=0;--r)if(e[r]?.kind!==`usage`&&(n+=1)===t)return e.slice(r);return e}function be(e,r,i=40){let a=n.join(T(e,r),`log.jsonl`);return t.existsSync(a)?t.readFileSync(a,`utf8`).split(/\r?\n/).filter(Boolean).slice(-i).map(e=>{try{return JSON.parse(e)}catch{return{message:e}}}):[]}function xe(){let e=n.dirname(s(import.meta.url));for(let r=0;r<10;r++){let r=n.join(e,`package.json`);try{if(JSON.parse(t.readFileSync(r,`utf8`)).name===`@wular/coder`)return e}catch{}let i=n.dirname(e);if(i===e)break;e=i}return n.resolve(n.dirname(s(import.meta.url)),`..`)}const R=xe(),Se=t.existsSync(n.join(R,`dist/cli.js`))?n.join(R,`dist/cli.js`):n.join(R,`src/cli.ts`);function z(){try{return JSON.parse(t.readFileSync(n.join(R,`package.json`),`utf8`)).version??`unknown`}catch{return`unknown`}}function Ce(e){try{return JSON.parse(t.readFileSync(e,`utf8`)).version??null}catch{return null}}function we(){return R}const B=c.optional(c.boolean()),V=c.optional(c.string()),Te={cwd:V,json:B},Ee=c.optional(c.union([c.literal(`all`),c.coerce.number().check(c.int(),c.positive())],{error:`expected a positive integer or "all"`})),De=c.optional(c.union([c.literal(`all`),c.coerce.number().check(c.int(),c.nonnegative())],{error:`expected a number or "all"`}));function H(e){let t=e.def;for(;t;){if(t.type===`boolean`)return!0;let e=t.innerType??t.in;t=e?e.def:void 0}return!1}function Oe(e,t){let n=t.shape,r={},i=[],a=!1,o=(e,t,i,a)=>{let o=n[t],s=a?`-`:`--`;if(!o)throw Error(`Unknown option ${s}${e} (use -- to pass literal text starting with -)`);if(H(o))return r[t]=i===void 0||i!==`false`,0;if(i===void 0)throw Error(`Missing value for ${s}${e}`);return r[t]=i,1};for(let t=0;t<e.length;t+=1){let r=e[t];if(a){i.push(r);continue}if(r===`--`){a=!0;continue}if(!r.startsWith(`-`)||r===`-`){i.push(r);continue}if(r.startsWith(`--`)){let[i,a]=r.slice(2).split(`=`,2);a===void 0&&n[i]&&!H(n[i])?t+=o(i,i,e[t+1],!1):o(i,i,a,!1);continue}let s=r.slice(1);n[s]&&!H(n[s])?t+=o(s,s,e[t+1],!0):o(s,s,void 0,!0)}let s=t.safeParse(r);if(!s.success){let e=s.error.issues[0],t=String(e.path[0]??``),n=r[t];throw Error(n===void 0?`Missing required --${t}.`:`Invalid --${t} value ${JSON.stringify(n)}: ${e.message}`)}return{options:s.data,positionals:i}}function ke(e){return String(e??``).replace(/[^A-Za-z0-9._-]/g,`-`).replace(/^-+|-+$/g,``)}function Ae(t,r=e.platform){return r===`win32`?`pipe:\\\\.\\pipe\\${ke(`${n.win32.basename(t)}-codex-app-server`)}`:`unix:${n.join(t,`broker.sock`)}`}function U(e){if(typeof e!=`string`||e.length===0)throw Error(`Missing broker endpoint.`);if(e.startsWith(`pipe:`)){let t=e.slice(5);if(!t)throw Error(`Broker pipe endpoint is missing its path.`);return{kind:`pipe`,path:t}}if(e.startsWith(`unix:`)){let t=e.slice(5);if(!t)throw Error(`Broker Unix socket endpoint is missing its path.`);return{kind:`unix`,path:t}}throw Error(`Unsupported broker endpoint: ${e}`)}function je(e=`coder-`){return t.mkdtempSync(n.join(o.tmpdir(),e))}function Me(e){let t=U(e);return l.createConnection({path:t.path})}async function W(e,t=2e3){let n=Date.now();for(;Date.now()-n<t;){if(await new Promise(t=>{let n=Me(e);n.on(`connect`,()=>{n.end(),t(!0)}),n.on(`error`,()=>t(!1))}))return!0;await new Promise(e=>setTimeout(e,50))}return!1}function Ne({scriptPath:n,cwd:r,endpoint:a,pidFile:o,logFile:s,env:c=e.env}){let l=t.openSync(s,`a`),u=i(e.execPath,[n,`serve`,`--endpoint`,a,`--cwd`,r,`--pid-file`,o],{cwd:r,env:c,detached:!0,stdio:[`ignore`,l,l]});return u.unref(),t.closeSync(l),u}function Pe(){let e=[new URL(`./lib/broker.js`,import.meta.url),new URL(`./broker.js`,import.meta.url)];for(let n of e){let e=s(n);if(t.existsSync(e))return e}throw Error("Coder broker script not found next to the runtime. Rebuild with `bun run build`.")}function G(e){return n.join(b(e),`broker.json`)}function K(e){let n=G(e);if(!t.existsSync(n))return null;try{return JSON.parse(t.readFileSync(n,`utf8`))}catch{return null}}function Fe(e,n){let r=b(e);t.mkdirSync(r,{recursive:!0}),t.writeFileSync(G(e),`${JSON.stringify(n,null,2)}\n`,`utf8`)}function Ie(e){let n=G(e);t.existsSync(n)&&t.unlinkSync(n)}async function Le(e){if(!e)return!1;try{return await W(e,150)}catch{return!1}}async function Re(t,r={}){let i=r.scriptPath??Pe(),a=z(),o=K(t),s=o?.version===a&&o?.scriptPath===i;if(o&&s&&await Le(o.endpoint))return o;o&&(q({endpoint:o.endpoint??null,pidFile:o.pidFile??null,logFile:o.logFile??null,sessionDir:o.sessionDir??null,pid:o.pid??null,killProcess:r.killProcess??null}),Ie(t));let c=je(),l=(r.createBrokerEndpoint??Ae)(c,r.platform),u=n.join(c,`broker.pid`),d=n.join(c,`broker.log`),f=Ne({scriptPath:i,cwd:t,endpoint:l,pidFile:u,logFile:d,env:r.env??e.env});if(!await W(l,r.timeoutMs??2e3))return q({endpoint:l,pidFile:u,logFile:d,sessionDir:c,pid:f.pid??null,killProcess:r.killProcess??null}),null;let p={endpoint:l,pidFile:u,logFile:d,sessionDir:c,pid:f.pid??null,version:a,scriptPath:i};return Fe(t,p),p}function q({endpoint:e=null,pidFile:r,logFile:i,sessionDir:a=null,pid:o=null,killProcess:s=null}){if(Number.isFinite(o)&&s)try{s(o)}catch{}if(r&&t.existsSync(r)&&t.unlinkSync(r),i&&t.existsSync(i)&&t.unlinkSync(i),e)try{let n=U(e);n.kind===`unix`&&t.existsSync(n.path)&&t.unlinkSync(n.path)}catch{}let c=a??(r?n.dirname(r):i?n.dirname(i):null);if(c&&t.existsSync(c))try{t.rmdirSync(c)}catch{}}function J(t,n=[],r={}){let i=a(t,n,{cwd:r.cwd,env:r.env,encoding:`utf8`,input:r.input,maxBuffer:r.maxBuffer,stdio:r.stdio??`pipe`,shell:e.platform===`win32`?e.env.SHELL||!0:!1,windowsHide:!0});return{command:t,args:n,status:i.status??0,signal:i.signal??null,stdout:i.stdout??``,stderr:i.stderr??``,error:i.error??null}}function ze(e,t=[`--version`],n={}){let r=J(e,t,n);return r.error&&r.error.code===`ENOENT`?{available:!1,detail:`not found`}:r.error?{available:!1,detail:r.error.message}:r.status===0?{available:!0,detail:r.stdout.trim()||r.stderr.trim()||`ok`}:{available:!1,detail:r.stderr.trim()||r.stdout.trim()||`exit ${r.status}`}}function Be(e){return/not found|no running instance|cannot find|does not exist|no such process/i.test(e)}function Ve(t,n={}){if(!Number.isFinite(t))return{attempted:!1,delivered:!1,method:null};let r=t,i=n.platform??e.platform,a=n.runCommandImpl??J,o=n.killImpl??e.kill.bind(e);if(i===`win32`){let e=a(`taskkill`,[`/PID`,String(r),`/T`,`/F`],{cwd:n.cwd,env:n.env});if(!e.error&&e.status===0)return{attempted:!0,delivered:!0,method:`taskkill`,result:e};let t=`${e.stderr}\n${e.stdout}`.trim();if(!e.error&&Be(t))return{attempted:!0,delivered:!1,method:`taskkill`,result:e};if(e.error?.code===`ENOENT`)try{return o(r),{attempted:!0,delivered:!0,method:`kill`}}catch(e){if(e?.code===`ESRCH`)return{attempted:!0,delivered:!1,method:`kill`};throw e}throw e.error?e.error:Error(He(e))}try{return o(-r,`SIGTERM`),{attempted:!0,delivered:!0,method:`process-group`}}catch(e){if(e?.code!==`ESRCH`)try{return o(r,`SIGTERM`),{attempted:!0,delivered:!0,method:`process`}}catch(e){if(e?.code===`ESRCH`)return{attempted:!0,delivered:!1,method:`process`};throw e}return{attempted:!0,delivered:!1,method:`process-group`}}}function He(e){let t=[`${e.command} ${e.args.join(` `)}`.trim()];e.signal?t.push(`signal=${e.signal}`):t.push(`exit=${e.status}`);let n=(e.stderr||``).trim(),r=(e.stdout||``).trim();return n?t.push(n):r&&t.push(r),t.join(`: `)}const Ue=`CODER_APP_SERVER_ENDPOINT`,We=-32001;let Y;function Ge(){if(Y===void 0){let e=J(`codex`,[`--version`]),t=/(\d+\.\d+\.\d+(?:-[\w.]+)?)/.exec(`${e.stdout} ${e.stderr}`);Y=t?t[1]:`0.144.1`}return Y}function X(){return{title:`Coder`,name:`coder`,version:Ge()}}const Z={experimentalApi:!1,requestAttestation:!1,optOutNotificationMethods:[`item/agentMessage/delta`,`item/reasoning/summaryTextDelta`,`item/reasoning/summaryPartAdded`,`item/reasoning/textDelta`]};function Q(e,t,n){return n===void 0?{code:e,message:t}:{code:e,message:t,data:n}}function $(e,t){let n=Error(e);return n.data=t,t?.code!==void 0&&(n.rpcCode=t.code),n}var Ke=class{cwd;options;pending;nextId;stderr;closed;exitError;notificationHandler;serverRequestHandler;lineBuffer;transport;exitPromise;exitResolved;resolveExit;handleServerRequest;constructor(e,t={}){this.cwd=e,this.options=t,this.pending=new Map,this.nextId=1,this.stderr=``,this.closed=!1,this.exitError=null,this.notificationHandler=null,this.serverRequestHandler=null,this.lineBuffer=``,this.transport=`unknown`,this.handleServerRequest=e=>this.defaultHandleServerRequest(e),this.exitPromise=new Promise(e=>{this.resolveExit=e})}setNotificationHandler(e){this.notificationHandler=e}setServerRequestHandler(e){this.serverRequestHandler=e}request(e,t){if(this.closed)throw Error(`codex app-server client is closed.`);let n=this.nextId;return this.nextId+=1,new Promise((r,i)=>{this.pending.set(n,{resolve:r,reject:i,method:e}),this.sendMessage({id:n,method:e,params:t})})}notify(e,t={}){this.closed||this.sendMessage({method:e,params:t})}handleChunk(e){this.lineBuffer+=e;let t=this.lineBuffer.indexOf(`
|
|
2
|
-
`);for(;t!==-1;){let e=this.lineBuffer.slice(0,t);this.lineBuffer=this.lineBuffer.slice(t+1),this.handleLine(e),t=this.lineBuffer.indexOf(`
|
|
3
|
-
`)}}handleLine(e){if(!e.trim())return;let t;try{t=JSON.parse(e)}catch(t){this.handleExit($(`Failed to parse codex app-server JSONL: ${t instanceof Error?t.message:String(t)}`,{line:e}));return}if(t.id!==void 0&&t.method){this.handleServerRequest(t);return}if(t.id!==void 0){let e=this.pending.get(t.id);if(!e)return;this.pending.delete(t.id),t.error?e.reject($(t.error.message??`codex app-server ${e.method} failed.`,t.error)):e.resolve(t.result??{});return}t.method&&this.notificationHandler&&this.notificationHandler(t)}defaultHandleServerRequest(e){let t=this.serverRequestHandler;if(!t){this.sendMessage({id:e.id,error:Q(-32601,`Unsupported server request: ${e.method}`)});return}Promise.resolve().then(()=>t(e.method,e.params??{})).then(t=>{this.sendMessage({id:e.id,result:t??{}})}).catch(t=>{this.sendMessage({id:e.id,error:Q(-32e3,t instanceof Error?t.message:String(t))})})}handleExit(e){if(!this.exitResolved){this.exitResolved=!0,this.exitError=e??null;for(let e of this.pending.values())e.reject(this.exitError??Error(`codex app-server connection closed.`));this.pending.clear(),this.resolveExit(void 0)}}sendMessage(e){throw Error(`sendMessage must be implemented by subclasses.`)}},qe=class extends Ke{proc;readline;constructor(e,t={}){super(e,t),this.transport=`direct`}async initialize(){this.proc=i(`codex`,[`-c`,`sandbox_workspace_write.network_access=false`,`app-server`,`--disable`,`plugins`],{cwd:this.cwd,env:this.options.env??e.env,stdio:[`pipe`,`pipe`,`pipe`],shell:e.platform===`win32`?e.env.SHELL||!0:!1,windowsHide:!0});let t=this.proc.stdout,n=this.proc.stderr;if(!t||!n)throw Error(`codex app-server did not expose stdio streams.`);t.setEncoding(`utf8`),n.setEncoding(`utf8`),n.on(`data`,e=>{this.stderr+=e}),this.proc.on(`error`,e=>{this.handleExit(e)}),this.proc.on(`exit`,(e,t)=>{let n=this.stderr.trim(),r=e===0?null:$(`codex app-server exited unexpectedly (${t?`signal ${t}`:`exit ${e}`}).${n?`\n${n}`:``}`);this.handleExit(r)}),this.readline=u.createInterface({input:t}),this.readline.on(`line`,e=>{this.handleLine(e)}),await this.request(`initialize`,{clientInfo:this.options.clientInfo??X(),capabilities:this.options.capabilities??Z}),this.notify(`initialized`,{})}async close(){if(this.closed){await this.exitPromise;return}this.closed=!0,this.readline&&this.readline.close(),this.proc&&!this.proc.killed&&(this.proc.stdin?.end(),setTimeout(()=>{if(this.proc&&!this.proc.killed&&this.proc.exitCode===null)if(e.platform===`win32`)try{Ve(this.proc.pid)}catch{}else this.proc.kill(`SIGTERM`)},50).unref?.()),await this.exitPromise}sendMessage(e){let t=`${JSON.stringify(e)}\n`,n=this.proc?.stdin;if(!n)throw Error(`codex app-server stdin is not available.`);n.write(t)}},Je=class extends Ke{endpoint;socket;constructor(e,t={}){super(e,t),this.transport=`broker`,this.endpoint=t.brokerEndpoint}async initialize(){await new Promise((e,t)=>{let n=U(this.endpoint);this.socket=l.createConnection({path:n.path}),this.socket.setEncoding(`utf8`),this.socket.on(`connect`,e),this.socket.on(`data`,e=>{this.handleChunk(e)}),this.socket.on(`error`,e=>{this.exitResolved||t(e),this.handleExit(e)}),this.socket.on(`close`,()=>{this.handleExit(this.exitError)})}),await this.request(`initialize`,{clientInfo:this.options.clientInfo??X(),capabilities:this.options.capabilities??Z}),this.notify(`initialized`,{})}async close(){if(this.closed){await this.exitPromise;return}this.closed=!0,this.socket&&this.socket.end(),await this.exitPromise}sendMessage(e){let t=`${JSON.stringify(e)}\n`,n=this.socket;if(!n)throw Error(`codex app-server broker connection is not connected.`);n.write(t)}},Ye=class{static async connect(t,n={}){let r=null;n.disableBroker||(r=n.brokerEndpoint??n.env?.CODER_APP_SERVER_ENDPOINT??e.env.CODER_APP_SERVER_ENDPOINT??null,!r&&n.reuseExistingBroker&&(r=K(t)?.endpoint??null),!r&&!n.reuseExistingBroker&&(r=(await Re(t,{env:n.env}))?.endpoint??null));let i=r?new Je(t,{...n,brokerEndpoint:r}):new qe(t,n);return await i.initialize(),i}};export{M as A,me as B,de as C,I as D,pe as E,_ as F,f as G,te as H,T as I,p as K,re as L,be as M,ve as N,ue as O,N as P,ye as R,he as S,h as T,m as U,O as V,ee as W,_e as _,U as a,ge as b,Ee as c,De as d,Se as f,ie as g,we as h,ze as i,A as j,E as k,Oe as l,z as m,Ue as n,Te as o,Ce as p,Ye as r,B as s,We as t,V as u,D as v,ae as w,oe as x,g as y,fe as z};
|