@agent-spaces/server 0.3.4 → 0.3.6
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/dist/adapters/claude-code-runtime/index.js +19 -1
- package/dist/adapters/codex-runtime.js +13 -3
- package/dist/agents/agent-message-parts.js +9 -1
- package/dist/agents/commit-agent.js +7 -15
- package/dist/app.js +26 -0
- package/dist/package.json +3 -1
- package/dist/routes/code-favorites.js +60 -0
- package/dist/routes/file.js +13 -0
- package/dist/routes/prompt-template.js +48 -0
- package/dist/services/agent.js +45 -3
- package/dist/services/code-favorites.js +23 -0
- package/dist/services/file.js +4 -0
- package/dist/services/persistent-agent-context.js +3 -2
- package/dist/services/prompt-template.js +93 -0
- package/dist/services/pty.js +18 -1
- package/dist/storage/code-favorites-store.js +15 -0
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +4 -4
- package/dist/web/__next._full.txt +21 -21
- package/dist/web/__next._head.txt +4 -4
- package/dist/web/__next._index.txt +13 -13
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/0-1pn22sg~67u.js +2 -0
- package/dist/web/_next/static/chunks/0-lseun2l1m_t.js +2 -0
- package/dist/web/_next/static/chunks/0-wkj-hzh444r.css +4 -0
- package/dist/web/_next/static/chunks/{0f6vrjsdauiwl.js → 0-~4vw4_9z_0_.js} +2 -2
- package/dist/web/_next/static/chunks/0..g0jl-8qup7.js +1 -0
- package/dist/web/_next/static/chunks/0.006.ycpe92w.js +496 -0
- package/dist/web/_next/static/chunks/0.6x8f.mb-1qf.js +1 -0
- package/dist/web/_next/static/chunks/{0qe5wvs8fe9ip.js → 004wt62de8617.js} +1 -1
- package/dist/web/_next/static/chunks/016xz2o-hv3am.js +1 -0
- package/dist/web/_next/static/chunks/01gi~q0c6ez6..js +1 -0
- package/dist/web/_next/static/chunks/023lpc7n70tav.css +1 -0
- package/dist/web/_next/static/chunks/03me5_ir..2ix.js +1 -0
- package/dist/web/_next/static/chunks/04fk~8rnrvs44.js +1 -0
- package/dist/web/_next/static/chunks/05eu2fdixf7c9.js +1 -0
- package/dist/web/_next/static/chunks/05gt_g_vbzh-5.css +1 -0
- package/dist/web/_next/static/chunks/06vadtvw631k5.css +1 -0
- package/dist/web/_next/static/chunks/07ge_85i__6pb.js +1 -0
- package/dist/web/_next/static/chunks/07ne4g8zopykv.js +1 -0
- package/dist/web/_next/static/chunks/07xvadmf~8bow.js +1 -0
- package/dist/web/_next/static/chunks/08.u~dmq20cak.css +23 -0
- package/dist/web/_next/static/chunks/{03sd~wmqw.9gc.js → 08kpa0nox.bb1.js} +2 -2
- package/dist/web/_next/static/chunks/08o-zmr-40r5g.js +1 -0
- package/dist/web/_next/static/chunks/0_-c.y2qq4ax4.js +270 -0
- package/dist/web/_next/static/chunks/0a1rewz7xr-xi.js +1 -0
- package/dist/web/_next/static/chunks/0amcocbojo4v2.js +1 -0
- package/dist/web/_next/static/chunks/0brrgp3ki5w4_.css +17 -0
- package/dist/web/_next/static/chunks/0bzmgi.ynrn.0.css +3 -0
- package/dist/web/_next/static/chunks/0c_vfzf1z7-rt.js +2 -0
- package/dist/web/_next/static/chunks/0cjmfclopcxho.css +1 -0
- package/dist/web/_next/static/chunks/0cs830n97dgjy.js +1 -0
- package/dist/web/_next/static/chunks/0d_dp_4ofz0l3.css +3 -0
- package/dist/web/_next/static/chunks/0dws-faof-ryx.css +13 -0
- package/dist/web/_next/static/chunks/0ejc_zlyocy_r.css +1 -0
- package/dist/web/_next/static/chunks/0esty_4gmxfq3.js +1 -0
- package/dist/web/_next/static/chunks/0evjw7bao5_e~.js +1 -0
- package/dist/web/_next/static/chunks/{0ag4p6m9rze~n.js → 0g-0n6glz_z6w.js} +1 -1
- package/dist/web/_next/static/chunks/{145qu5b0tgm9w.js → 0gig.k.rq8d0x.js} +1 -1
- package/dist/web/_next/static/chunks/0hl_7y464qll6.css +2 -0
- package/dist/web/_next/static/chunks/0hrbuvzuxrjfl.js +1 -0
- package/dist/web/_next/static/chunks/0i_3.3rdsu2mw.js +2 -0
- package/dist/web/_next/static/chunks/0i_gi.kq2dau8.css +1 -0
- package/dist/web/_next/static/chunks/0j00r2f_n-.lx.js +1 -0
- package/dist/web/_next/static/chunks/0jh9xnkimjkyh.js +1 -0
- package/dist/web/_next/static/chunks/0jokpgh485~28.js +167 -0
- package/dist/web/_next/static/chunks/0kvsjgpj7zcb9.css +9 -0
- package/dist/web/_next/static/chunks/0l5ab99s37x5f.js +1 -0
- package/dist/web/_next/static/chunks/0lcc9r.o.p.sc.js +1 -0
- package/dist/web/_next/static/chunks/0lh~x2tf~i1hd.css +2 -0
- package/dist/web/_next/static/chunks/0me8ho8j4tq7_.css +2 -0
- package/dist/web/_next/static/chunks/0mny8i81aenx3.js +1 -0
- package/dist/web/_next/static/chunks/0mt-7av8yrg0o.css +3 -0
- package/dist/web/_next/static/chunks/0njy89g5coeyi.js +60 -0
- package/dist/web/_next/static/chunks/0nsu~f3voe~0i.js +5 -0
- package/dist/web/_next/static/chunks/0ow~co9wcleka.js +173 -0
- package/dist/web/_next/static/chunks/0pldvk5_h__t7.css +3 -0
- package/dist/web/_next/static/chunks/0qad.lgvtlt0b.css +16 -0
- package/dist/web/_next/static/chunks/0qpq0~_58fe9a.js +18 -0
- package/dist/web/_next/static/chunks/{0.335m_d-cd_g.js → 0qtc_rbo1oghu.js} +1 -1
- package/dist/web/_next/static/chunks/0qz5~3wquy~3q.css +2 -0
- package/dist/web/_next/static/chunks/0rv0nj__24y60.js +10 -0
- package/dist/web/_next/static/chunks/{145gbwitjxamg.js → 0sz8_nijfiz0p.js} +1 -1
- package/dist/web/_next/static/chunks/0tvd~rxgf0oh_.js +1 -0
- package/dist/web/_next/static/chunks/0wv0h27jafag4.js +1 -0
- package/dist/web/_next/static/chunks/0wwvc4zc2q6bn.js +1 -0
- package/dist/web/_next/static/chunks/0x4b-a2ixww6m.js +1 -0
- package/dist/web/_next/static/chunks/0z8ipjj2z-3al.css +8 -0
- package/dist/web/_next/static/chunks/0zd1o3u04~qvo.js +127 -0
- package/dist/web/_next/static/chunks/0~2l1-8o4delc.js +1 -0
- package/dist/web/_next/static/chunks/0~w6ugk9s5p-h.css +1 -0
- package/dist/web/_next/static/chunks/10jfi.9fw5g48.js +1 -0
- package/dist/web/_next/static/chunks/11_tltlhc8.sj.js +1 -0
- package/dist/web/_next/static/chunks/125nunjfj2fj0.js +1 -0
- package/dist/web/_next/static/chunks/1285yqy_oirb-.js +1 -0
- package/dist/web/_next/static/chunks/12md9ajfx2o85.css +1 -0
- package/dist/web/_next/static/chunks/12odetnu-lyrr.js +167 -0
- package/dist/web/_next/static/chunks/12u4g4uzrlten.js +2 -0
- package/dist/web/_next/static/chunks/134ozsnbd~0qw.js +1 -0
- package/dist/web/_next/static/chunks/13ess~4pdmxma.js +1 -0
- package/dist/web/_next/static/chunks/13xfagjq0q~tf.js +1 -0
- package/dist/web/_next/static/chunks/143.pbs8a1ivm.js +1 -0
- package/dist/web/_next/static/chunks/14_y_s_5rhsd1.css +5 -0
- package/dist/web/_next/static/chunks/15hca2.5le07..js +3 -0
- package/dist/web/_next/static/chunks/15rf3~h7sugz4.css +19 -0
- package/dist/web/_next/static/chunks/16i87txo0qh0h.css +6 -0
- package/dist/web/_next/static/chunks/16~udgv7eel6a.css +2 -0
- package/dist/web/_next/static/chunks/{turbopack-0-j2hpomozegf.js → turbopack-000x5q9w-wx10.js} +1 -1
- package/dist/web/_next/static/chunks/{turbopack-0rrhp9pbrv0p3.js → turbopack-0hrx111grzq49.js} +1 -1
- package/dist/web/_next/static/chunks/{turbopack-0_zn00zg5kmqz.js → turbopack-0w-kua.9ymd0x.js} +1 -1
- package/dist/web/_next/static/chunks/{turbopack-0l~pq1hytx49z.js → turbopack-15zqm_4ixj.18.js} +1 -1
- package/dist/web/_next/static/media/code-icon.0g3wskzlr7oxf.svg +1 -0
- package/dist/web/_next/static/media/codicon.0pqe-t5rtghj8.ttf +0 -0
- package/dist/web/_next/static/media/continue-tb.0qei4mru4tzd2.png +0 -0
- package/dist/web/_next/static/media/dark_modern.09.uq6bp373zs.json +1 -0
- package/dist/web/_next/static/media/dark_plus.187umr0~d1_r7.json +1 -0
- package/dist/web/_next/static/media/dark_vs.12ju8ocr7rg--.json +1 -0
- package/dist/web/_next/static/media/document-dark.0vvlbsi_fdy~4.svg +3 -0
- package/dist/web/_next/static/media/document-light.0bfi_yt9e~vk7.svg +3 -0
- package/dist/web/_next/static/media/editor.worker.0ffjdaaj15t6e.js +1 -0
- package/dist/web/_next/static/media/extensionHost.worker.14sz5xf8-1efr.js +2 -0
- package/dist/web/_next/static/media/fake.16yx0-xxqj4pc.html +10 -0
- package/dist/web/_next/static/media/folder-dark.02kdicw3013tb.svg +3 -0
- package/dist/web/_next/static/media/folder-light.0s165k4fp3.53.svg +3 -0
- package/dist/web/_next/static/media/folder-open-dark.0sk6.yh45uqs3.svg +4 -0
- package/dist/web/_next/static/media/folder-open-light.10k1v_ugaq8ic.svg +4 -0
- package/dist/web/_next/static/media/hc_black.0-ul9e2oc5twb.json +1 -0
- package/dist/web/_next/static/media/hc_light.0vi.a7fr.z4gy.json +1 -0
- package/dist/web/_next/static/media/index.0jmafs_mwcjgg.html +1341 -0
- package/dist/web/_next/static/media/keyboard-dark.0t86n~1rrhj2-.svg +10 -0
- package/dist/web/_next/static/media/keyboard-light.0abw0ukjcd9ox.svg +10 -0
- package/dist/web/_next/static/media/letterpress-dark.181s2xkw~lfyo.svg +3 -0
- package/dist/web/_next/static/media/letterpress-hcDark.0ftfw8fess-5y.svg +3 -0
- package/dist/web/_next/static/media/letterpress-hcLight.06x23d0.aixf_.svg +3 -0
- package/dist/web/_next/static/media/letterpress-light.0xb1bapis~iw7.svg +3 -0
- package/dist/web/_next/static/media/light_modern.00ps-apoc9ph7.json +1 -0
- package/dist/web/_next/static/media/light_plus.0ow37ouyuazdz.json +1 -0
- package/dist/web/_next/static/media/light_vs.0fdbve5sxkgq1.json +1 -0
- package/dist/web/_next/static/media/onig.0dk~55st~1x8..wasm +0 -0
- package/dist/web/_next/static/media/opacity-background.0-9.t0ta0ko23.png +0 -0
- package/dist/web/_next/static/media/package.0_p8a~hpmb_uj.json +1 -0
- package/dist/web/_next/static/media/package.nls.0e5hn-g497b64.json +1 -0
- package/dist/web/_next/static/media/pause-tb.0ttrm1r1uuz_c.png +0 -0
- package/dist/web/_next/static/media/restart-tb.086872s_sc2qv.png +0 -0
- package/dist/web/_next/static/media/root-folder-dark.14iwnfb7p2na~.svg +5 -0
- package/dist/web/_next/static/media/root-folder-light.0ljk9fi7sw3.2.svg +5 -0
- package/dist/web/_next/static/media/root-folder-open-dark.08vw3g9zvki33.svg +5 -0
- package/dist/web/_next/static/media/root-folder-open-light.0f46.ahns5c~..svg +5 -0
- package/dist/web/_next/static/media/run-with-debugging-tb.0j1h52k~h~72z.png +0 -0
- package/dist/web/_next/static/media/service-worker.0_udu6mraxn4k.js +543 -0
- package/dist/web/_next/static/media/stepinto-tb.0cl87yt4ub_j8.png +0 -0
- package/dist/web/_next/static/media/stepout-tb.0vjib_bn-_xax.png +0 -0
- package/dist/web/_next/static/media/stepover-tb.04beeu~7cxr4l.png +0 -0
- package/dist/web/_next/static/media/stop-tb.1498tmu97_y9j.png +0 -0
- package/dist/web/_next/static/media/vs_minimal-icon-theme.0-qs73lvw4voi.json +1 -0
- package/dist/web/_next/static/media/webWorkerExtensionHostIframe.0x2r1o97s.m0m.html +156 -0
- package/dist/web/_next/static/media/worker.081j0x4avp1l1.js +2 -0
- package/dist/web/_not-found/__next._full.txt +19 -19
- package/dist/web/_not-found/__next._head.txt +4 -4
- package/dist/web/_not-found/__next._index.txt +13 -13
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/web/_not-found/__next._not-found.txt +3 -3
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +19 -19
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +21 -21
- package/dist/web/login/__next._full.txt +21 -21
- package/dist/web/login/__next._head.txt +4 -4
- package/dist/web/login/__next._index.txt +13 -13
- package/dist/web/login/__next._tree.txt +2 -2
- package/dist/web/login/__next.login.__PAGE__.txt +4 -4
- package/dist/web/login/__next.login.txt +3 -3
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +21 -21
- package/dist/web/settings/__next._full.txt +23 -23
- package/dist/web/settings/__next._head.txt +4 -4
- package/dist/web/settings/__next._index.txt +13 -13
- package/dist/web/settings/__next._tree.txt +2 -2
- package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
- package/dist/web/settings/__next.settings.txt +5 -5
- package/dist/web/settings/agents/__next._full.txt +23 -23
- package/dist/web/settings/agents/__next._head.txt +4 -4
- package/dist/web/settings/agents/__next._index.txt +13 -13
- package/dist/web/settings/agents/__next._tree.txt +2 -2
- package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
- package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
- package/dist/web/settings/agents/__next.settings.txt +5 -5
- package/dist/web/settings/agents.html +1 -1
- package/dist/web/settings/agents.txt +23 -23
- package/dist/web/settings/mcps/__next._full.txt +23 -23
- package/dist/web/settings/mcps/__next._head.txt +4 -4
- package/dist/web/settings/mcps/__next._index.txt +13 -13
- package/dist/web/settings/mcps/__next._tree.txt +2 -2
- package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
- package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
- package/dist/web/settings/mcps/__next.settings.txt +5 -5
- package/dist/web/settings/mcps.html +1 -1
- package/dist/web/settings/mcps.txt +23 -23
- package/dist/web/settings/models/__next._full.txt +23 -23
- package/dist/web/settings/models/__next._head.txt +4 -4
- package/dist/web/settings/models/__next._index.txt +13 -13
- package/dist/web/settings/models/__next._tree.txt +2 -2
- package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
- package/dist/web/settings/models/__next.settings.models.txt +3 -3
- package/dist/web/settings/models/__next.settings.txt +5 -5
- package/dist/web/settings/models.html +1 -1
- package/dist/web/settings/models.txt +23 -23
- package/dist/web/settings/prompts/__next._full.txt +42 -0
- package/dist/web/settings/prompts/__next._head.txt +6 -0
- package/dist/web/settings/prompts/__next._index.txt +15 -0
- package/dist/web/settings/prompts/__next._tree.txt +8 -0
- package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +9 -0
- package/dist/web/settings/prompts/__next.settings.prompts.txt +5 -0
- package/dist/web/settings/prompts/__next.settings.txt +7 -0
- package/dist/web/settings/prompts.html +1 -0
- package/dist/web/settings/prompts.txt +42 -0
- package/dist/web/settings/providers/__next._full.txt +23 -23
- package/dist/web/settings/providers/__next._head.txt +4 -4
- package/dist/web/settings/providers/__next._index.txt +13 -13
- package/dist/web/settings/providers/__next._tree.txt +2 -2
- package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
- package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
- package/dist/web/settings/providers/__next.settings.txt +5 -5
- package/dist/web/settings/providers.html +1 -1
- package/dist/web/settings/providers.txt +23 -23
- package/dist/web/settings/skills/__next._full.txt +23 -23
- package/dist/web/settings/skills/__next._head.txt +4 -4
- package/dist/web/settings/skills/__next._index.txt +13 -13
- package/dist/web/settings/skills/__next._tree.txt +2 -2
- package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
- package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
- package/dist/web/settings/skills/__next.settings.txt +5 -5
- package/dist/web/settings/skills.html +1 -1
- package/dist/web/settings/skills.txt +23 -23
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +23 -23
- package/dist/web/workflows/__next._full.txt +21 -21
- package/dist/web/workflows/__next._head.txt +4 -4
- package/dist/web/workflows/__next._index.txt +13 -13
- package/dist/web/workflows/__next._tree.txt +2 -2
- package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
- package/dist/web/workflows/__next.workflows.txt +3 -3
- package/dist/web/workflows.html +1 -1
- package/dist/web/workflows.txt +21 -21
- package/dist/web/workspace/_/__next._full.txt +68 -35
- package/dist/web/workspace/_/__next._head.txt +4 -4
- package/dist/web/workspace/_/__next._index.txt +13 -13
- package/dist/web/workspace/_/__next._tree.txt +15 -3
- package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +16 -4
- package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.txt +3 -3
- package/dist/web/workspace/_.html +1 -1
- package/dist/web/workspace/_.txt +68 -35
- package/dist/web/workspaces/__next._full.txt +21 -21
- package/dist/web/workspaces/__next._head.txt +4 -4
- package/dist/web/workspaces/__next._index.txt +13 -13
- package/dist/web/workspaces/__next._tree.txt +2 -2
- package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
- package/dist/web/workspaces/__next.workspaces.txt +3 -3
- package/dist/web/workspaces.html +1 -1
- package/dist/web/workspaces.txt +21 -21
- package/dist/ws/agent-runner.js +158 -20
- package/dist/ws/handler.js +6 -1
- package/dist/ws/message-parts.js +20 -1
- package/dist/ws/terminal-handler.js +12 -7
- package/dist/ws/typescript-lsp.js +78 -0
- package/package.json +13 -10
- package/dist/web/_next/static/chunks/0-a17~4piefz_.js +0 -1
- package/dist/web/_next/static/chunks/01tyftu_-l7tm.css +0 -1
- package/dist/web/_next/static/chunks/028b9_5cyq-_m.js +0 -1
- package/dist/web/_next/static/chunks/0anuxr11yn5iv.js +0 -2
- package/dist/web/_next/static/chunks/0e.z4v3cd78dx.js +0 -1
- package/dist/web/_next/static/chunks/0egot8y~i-ge3.js +0 -1
- package/dist/web/_next/static/chunks/0eq7wt-l.fetc.js +0 -1
- package/dist/web/_next/static/chunks/0gtbd3yt7y1gx.js +0 -1
- package/dist/web/_next/static/chunks/0j2w71psq6w9u.js +0 -1
- package/dist/web/_next/static/chunks/0kyv5yika-41a.js +0 -1
- package/dist/web/_next/static/chunks/0ms3tsu4men_j.js +0 -204
- package/dist/web/_next/static/chunks/0plreh4_gkxf9.js +0 -1
- package/dist/web/_next/static/chunks/0qxk21zejhdbm.js +0 -1
- package/dist/web/_next/static/chunks/12gvpt~z9mn8w.js +0 -1
- package/dist/web/_next/static/chunks/14iaqoj9-09g..js +0 -2
- package/dist/web/_next/static/chunks/15dyaigebtnwg.js +0 -5
- package/dist/web/_next/static/chunks/17oc2l.ekcs8b.css +0 -1
- /package/dist/web/_next/static/{O5-QCW1u2YNyAUyaoYh6s → HUlYEknPhyW7dRmJ5mFdG}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{O5-QCW1u2YNyAUyaoYh6s → HUlYEknPhyW7dRmJ5mFdG}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{O5-QCW1u2YNyAUyaoYh6s → HUlYEknPhyW7dRmJ5mFdG}/_ssgManifest.js +0 -0
package/dist/ws/agent-runner.js
CHANGED
|
@@ -158,6 +158,14 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
158
158
|
];
|
|
159
159
|
const workingDir = agentService.resolveWorkingDir(workspaceId, preset);
|
|
160
160
|
const startTime = Date.now();
|
|
161
|
+
const runtimePromptConfig = {
|
|
162
|
+
mcpServers: Object.keys(mcpServers ?? {}),
|
|
163
|
+
skills,
|
|
164
|
+
boundDirs: workspace?.boundDirs,
|
|
165
|
+
workingDir,
|
|
166
|
+
excludeNativeClaudeMd: preset.runtimeKind === 'claude-code',
|
|
167
|
+
builtInTools: buildBuiltInTools(functionTools, channel, issue),
|
|
168
|
+
};
|
|
161
169
|
const existingMessage = options.messageId
|
|
162
170
|
? listMessages(workspaceId, channelId).find((message) => message.id === options.messageId)
|
|
163
171
|
: undefined;
|
|
@@ -167,6 +175,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
167
175
|
metadata: {
|
|
168
176
|
...existingMessage.metadata,
|
|
169
177
|
agentSessionId: session.id,
|
|
178
|
+
runtimeSessionId: options.resumeSessionId ?? existingMessage.metadata?.runtimeSessionId,
|
|
170
179
|
runtime: preset.runtimeKind,
|
|
171
180
|
model: preset.modelId,
|
|
172
181
|
duration: 0,
|
|
@@ -196,6 +205,8 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
196
205
|
broadcastToWorkspace(workspaceId, existingMessage ? 'channel.message.updated' : 'channel.message', pending);
|
|
197
206
|
let activeRun;
|
|
198
207
|
const liveReasoning = [];
|
|
208
|
+
let agentPrompt = '';
|
|
209
|
+
let runtimeSessionId = options.resumeSessionId ?? existingMessage?.metadata?.runtimeSessionId;
|
|
199
210
|
try {
|
|
200
211
|
const runtime = createAgentRuntime({
|
|
201
212
|
kind: preset.runtimeKind,
|
|
@@ -213,8 +224,23 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
213
224
|
runtime,
|
|
214
225
|
};
|
|
215
226
|
trackChannelRun(workspaceId, channelId, activeRun);
|
|
216
|
-
const history = listMessages(workspaceId, channelId, { limit: 20 })
|
|
227
|
+
const history = filterPromptHistory(listMessages(workspaceId, channelId, { limit: 20 }), {
|
|
228
|
+
excludeMessageIds: [
|
|
229
|
+
...(!existingMessage ? [pending.id] : []),
|
|
230
|
+
...(options.excludeHistoryMessageIds ?? []),
|
|
231
|
+
],
|
|
232
|
+
excludeReplyIds: options.excludeHistoryReplyIds,
|
|
233
|
+
});
|
|
234
|
+
const isRuntimeSessionResume = Boolean(options.resumeSessionId && (preset.runtimeKind === 'claude-code' || preset.runtimeKind === 'codex'));
|
|
235
|
+
agentPrompt = isRuntimeSessionResume
|
|
236
|
+
? prompt
|
|
237
|
+
: buildAgentPrompt(workspaceId, preset.systemPrompt, prompt, history, runtimePromptConfig);
|
|
217
238
|
const liveOutput = [...(options.seedOutput ?? [])];
|
|
239
|
+
const liveOutputItems = liveOutput.map((line, index) => buildOutputItem({
|
|
240
|
+
id: `seed-${index}`,
|
|
241
|
+
type: 'output',
|
|
242
|
+
text: line,
|
|
243
|
+
}));
|
|
218
244
|
const askUserQuestions = [...(options.seedQuestions ?? [])];
|
|
219
245
|
const toolDetails = new Map();
|
|
220
246
|
const toolUseDetailIds = new Map();
|
|
@@ -231,12 +257,17 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
231
257
|
workspaceRoot: workspace?.boundDirs?.[0],
|
|
232
258
|
presetName: preset.name || preset.role,
|
|
233
259
|
role: preset.role,
|
|
260
|
+
agentConfigId: preset.id,
|
|
261
|
+
runtime: preset.runtimeKind,
|
|
234
262
|
model: preset.modelId,
|
|
235
263
|
systemPrompt: preset.systemPrompt,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
264
|
+
userPrompt: prompt,
|
|
265
|
+
fullPrompt: agentPrompt,
|
|
266
|
+
mcpServers: runtimePromptConfig.mcpServers,
|
|
267
|
+
skills: runtimePromptConfig.skills,
|
|
268
|
+
builtInTools: runtimePromptConfig.builtInTools,
|
|
239
269
|
output: liveOutput,
|
|
270
|
+
outputItems: liveOutputItems,
|
|
240
271
|
reasoning: liveReasoning,
|
|
241
272
|
toolDetails,
|
|
242
273
|
askUserQuestions,
|
|
@@ -252,29 +283,37 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
252
283
|
parts: displayParts,
|
|
253
284
|
metadata: {
|
|
254
285
|
...pending.metadata,
|
|
286
|
+
runtimeSessionId,
|
|
255
287
|
duration: Date.now() - startTime,
|
|
256
288
|
},
|
|
257
289
|
});
|
|
258
290
|
if (live)
|
|
259
291
|
broadcastToWorkspace(workspaceId, 'channel.message.updated', live);
|
|
260
292
|
};
|
|
261
|
-
const result = await runtime.execute(
|
|
262
|
-
mcpServers: Object.keys(mcpServers ?? {}),
|
|
263
|
-
skills,
|
|
264
|
-
boundDirs: workspace?.boundDirs,
|
|
265
|
-
workingDir,
|
|
266
|
-
excludeNativeClaudeMd: preset.runtimeKind === 'claude-code',
|
|
267
|
-
builtInTools: buildBuiltInTools(functionTools, channel, issue),
|
|
268
|
-
}), workingDir, {
|
|
293
|
+
const result = await runtime.execute(agentPrompt, workingDir, {
|
|
269
294
|
maxTurns: 100,
|
|
270
295
|
functionTools,
|
|
271
296
|
mcpServers,
|
|
272
297
|
skills,
|
|
273
298
|
configDir,
|
|
274
299
|
sandboxDirs: preset.sandboxDirs,
|
|
300
|
+
resumeSessionId: isRuntimeSessionResume ? options.resumeSessionId : undefined,
|
|
275
301
|
onEvent: (event) => {
|
|
276
302
|
if (activeRun?.stopped)
|
|
277
303
|
return;
|
|
304
|
+
if (event.type === 'session') {
|
|
305
|
+
runtimeSessionId = event.sessionId;
|
|
306
|
+
const live = updateMessage(workspaceId, channelId, pending.id, {
|
|
307
|
+
metadata: {
|
|
308
|
+
...pending.metadata,
|
|
309
|
+
runtimeSessionId,
|
|
310
|
+
duration: Date.now() - startTime,
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
if (live)
|
|
314
|
+
broadcastToWorkspace(workspaceId, 'channel.message.updated', live);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
278
317
|
if (event.type === 'reasoning') {
|
|
279
318
|
liveReasoning.push({ text: event.text, status: event.status });
|
|
280
319
|
broadcastToWorkspace(workspaceId, 'agent.output', { agentId: session.id, data: event.text });
|
|
@@ -322,6 +361,14 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
322
361
|
});
|
|
323
362
|
saveToolDetails(workspaceId, channelId, Array.from(toolDetails.values()));
|
|
324
363
|
liveOutput.push(event.line);
|
|
364
|
+
liveOutputItems.push(buildOutputItem({
|
|
365
|
+
id: event.id,
|
|
366
|
+
type: 'tool_use',
|
|
367
|
+
title: summarizeToolLine(event.line, workspace?.boundDirs?.[0]).title,
|
|
368
|
+
toolUseId: event.id,
|
|
369
|
+
toolName: event.name,
|
|
370
|
+
text: event.line,
|
|
371
|
+
}));
|
|
325
372
|
broadcastToWorkspace(workspaceId, 'agent.output', { agentId: session.id, data: event.line });
|
|
326
373
|
broadcastLiveParts();
|
|
327
374
|
return;
|
|
@@ -347,11 +394,24 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
347
394
|
detail.updatedAt = new Date().toISOString();
|
|
348
395
|
saveToolDetails(workspaceId, channelId, [detail]);
|
|
349
396
|
}
|
|
397
|
+
liveOutputItems.push(buildOutputItem({
|
|
398
|
+
id: `result-${event.toolUseId ?? liveOutputItems.length}`,
|
|
399
|
+
type: 'tool_result',
|
|
400
|
+
title: detail?.title || detail?.raw || 'Tool result',
|
|
401
|
+
toolUseId: event.toolUseId,
|
|
402
|
+
text: serializeToolResult(event.result),
|
|
403
|
+
}));
|
|
404
|
+
broadcastLiveParts();
|
|
350
405
|
return;
|
|
351
406
|
}
|
|
352
407
|
if (event.type !== 'output')
|
|
353
408
|
return;
|
|
354
409
|
liveOutput.push(event.line);
|
|
410
|
+
liveOutputItems.push(buildOutputItem({
|
|
411
|
+
id: `output-${liveOutputItems.length}`,
|
|
412
|
+
type: 'output',
|
|
413
|
+
text: event.line,
|
|
414
|
+
}));
|
|
355
415
|
broadcastToWorkspace(workspaceId, 'agent.output', { agentId: session.id, data: event.line });
|
|
356
416
|
broadcastLiveParts();
|
|
357
417
|
},
|
|
@@ -367,11 +427,16 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
367
427
|
workspaceRoot: workspace?.boundDirs?.[0],
|
|
368
428
|
presetName: preset.name || preset.role,
|
|
369
429
|
role: preset.role,
|
|
430
|
+
agentConfigId: preset.id,
|
|
431
|
+
runtime: preset.runtimeKind,
|
|
370
432
|
model: preset.modelId,
|
|
371
433
|
systemPrompt: preset.systemPrompt,
|
|
372
|
-
|
|
373
|
-
|
|
434
|
+
userPrompt: prompt,
|
|
435
|
+
fullPrompt: agentPrompt,
|
|
436
|
+
mcpServers: runtimePromptConfig.mcpServers,
|
|
437
|
+
skills: runtimePromptConfig.skills,
|
|
374
438
|
output: waitingOutput,
|
|
439
|
+
outputItems: liveOutputItems,
|
|
375
440
|
reasoning: liveReasoning,
|
|
376
441
|
toolDetails,
|
|
377
442
|
askUserQuestions,
|
|
@@ -383,6 +448,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
383
448
|
status: 'waiting_for_user',
|
|
384
449
|
metadata: {
|
|
385
450
|
agentSessionId: session.id,
|
|
451
|
+
runtimeSessionId: result.sessionId ?? runtimeSessionId,
|
|
386
452
|
runtime: preset.runtimeKind,
|
|
387
453
|
model: preset.modelId,
|
|
388
454
|
summary: 'Waiting for user answer',
|
|
@@ -430,13 +496,22 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
430
496
|
workspaceRoot: workspace?.boundDirs?.[0],
|
|
431
497
|
presetName: preset.name || preset.role,
|
|
432
498
|
role: preset.role,
|
|
499
|
+
agentConfigId: preset.id,
|
|
500
|
+
runtime: preset.runtimeKind,
|
|
433
501
|
model: preset.modelId,
|
|
434
502
|
usage: result.usage,
|
|
435
503
|
systemPrompt: preset.systemPrompt,
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
504
|
+
userPrompt: prompt,
|
|
505
|
+
fullPrompt: agentPrompt,
|
|
506
|
+
mcpServers: runtimePromptConfig.mcpServers,
|
|
507
|
+
skills: runtimePromptConfig.skills,
|
|
508
|
+
builtInTools: runtimePromptConfig.builtInTools,
|
|
439
509
|
output: displayOutput,
|
|
510
|
+
outputItems: liveOutputItems.length ? liveOutputItems : displayOutput.map((line, index) => buildOutputItem({
|
|
511
|
+
id: `result-output-${index}`,
|
|
512
|
+
type: 'output',
|
|
513
|
+
text: line,
|
|
514
|
+
})),
|
|
440
515
|
reasoning: liveReasoning,
|
|
441
516
|
toolDetails,
|
|
442
517
|
askUserQuestions,
|
|
@@ -449,6 +524,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
449
524
|
status: result.success ? 'completed' : 'error',
|
|
450
525
|
metadata: {
|
|
451
526
|
agentSessionId: session.id,
|
|
527
|
+
runtimeSessionId: result.sessionId ?? runtimeSessionId,
|
|
452
528
|
runtime: preset.runtimeKind,
|
|
453
529
|
model: preset.modelId,
|
|
454
530
|
summary: result.summary,
|
|
@@ -476,12 +552,21 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
476
552
|
workspaceRoot: workspace?.boundDirs?.[0],
|
|
477
553
|
presetName: preset.name || preset.role,
|
|
478
554
|
role: preset.role,
|
|
555
|
+
agentConfigId: preset.id,
|
|
556
|
+
runtime: preset.runtimeKind,
|
|
479
557
|
model: preset.modelId,
|
|
480
558
|
systemPrompt: preset.systemPrompt,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
559
|
+
userPrompt: prompt,
|
|
560
|
+
fullPrompt: agentPrompt,
|
|
561
|
+
mcpServers: runtimePromptConfig.mcpServers,
|
|
562
|
+
skills: runtimePromptConfig.skills,
|
|
563
|
+
builtInTools: runtimePromptConfig.builtInTools,
|
|
484
564
|
output: [error],
|
|
565
|
+
outputItems: [buildOutputItem({
|
|
566
|
+
id: 'error',
|
|
567
|
+
type: 'output',
|
|
568
|
+
text: error,
|
|
569
|
+
})],
|
|
485
570
|
reasoning: liveReasoning,
|
|
486
571
|
toolDetails: new Map(),
|
|
487
572
|
askUserQuestions: [],
|
|
@@ -494,6 +579,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
494
579
|
status: 'error',
|
|
495
580
|
metadata: {
|
|
496
581
|
agentSessionId: session.id,
|
|
582
|
+
runtimeSessionId,
|
|
497
583
|
runtime: preset.runtimeKind,
|
|
498
584
|
model: preset.modelId,
|
|
499
585
|
duration: Date.now() - startTime,
|
|
@@ -547,6 +633,20 @@ function untrackChannelRun(workspaceId, channelId, agentId) {
|
|
|
547
633
|
if (runs.size === 0)
|
|
548
634
|
activeChannelRuns.delete(key);
|
|
549
635
|
}
|
|
636
|
+
function filterPromptHistory(messages, options) {
|
|
637
|
+
const excludeMessageIds = new Set(options.excludeMessageIds ?? []);
|
|
638
|
+
const excludeReplyIds = new Set(options.excludeReplyIds ?? []);
|
|
639
|
+
return messages
|
|
640
|
+
.filter((message) => !excludeMessageIds.has(message.id))
|
|
641
|
+
.map((message) => {
|
|
642
|
+
if (!message.replies?.length || excludeReplyIds.size === 0)
|
|
643
|
+
return message;
|
|
644
|
+
return {
|
|
645
|
+
...message,
|
|
646
|
+
replies: message.replies.filter((reply) => !excludeReplyIds.has(reply.id)),
|
|
647
|
+
};
|
|
648
|
+
});
|
|
649
|
+
}
|
|
550
650
|
function buildContinuationParts(previousParts, sessionId, userMessage, nextParts) {
|
|
551
651
|
if (!userMessage)
|
|
552
652
|
return nextParts;
|
|
@@ -612,4 +712,42 @@ function stripAskUserQuestionErrorLines(output) {
|
|
|
612
712
|
function isAskUserQuestionError(error) {
|
|
613
713
|
return /Answer questions\?/i.test(error);
|
|
614
714
|
}
|
|
715
|
+
function buildOutputItem(input) {
|
|
716
|
+
const text = clipOutputText(input.text);
|
|
717
|
+
return {
|
|
718
|
+
id: input.id,
|
|
719
|
+
type: input.type,
|
|
720
|
+
title: input.title,
|
|
721
|
+
toolUseId: input.toolUseId,
|
|
722
|
+
toolName: input.toolName,
|
|
723
|
+
text,
|
|
724
|
+
characters: countCharacters(text),
|
|
725
|
+
tokens: estimateTextTokens(text),
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
function serializeToolResult(result) {
|
|
729
|
+
const text = typeof result === 'string'
|
|
730
|
+
? result
|
|
731
|
+
: JSON.stringify(result, null, 2);
|
|
732
|
+
if (!text)
|
|
733
|
+
return String(result);
|
|
734
|
+
return clipOutputText(text);
|
|
735
|
+
}
|
|
736
|
+
function clipOutputText(text) {
|
|
737
|
+
const maxLength = 40_000;
|
|
738
|
+
return text.length > maxLength
|
|
739
|
+
? `${text.slice(0, maxLength)}\n... truncated ${text.length - maxLength} chars`
|
|
740
|
+
: text;
|
|
741
|
+
}
|
|
742
|
+
function countCharacters(text) {
|
|
743
|
+
return Array.from(text).length;
|
|
744
|
+
}
|
|
745
|
+
function estimateTextTokens(text) {
|
|
746
|
+
if (!text.trim())
|
|
747
|
+
return 0;
|
|
748
|
+
const cjkChars = text.match(/[\u3400-\u9fff\uf900-\ufaff]/g)?.length ?? 0;
|
|
749
|
+
const nonCjkText = text.replace(/[\u3400-\u9fff\uf900-\ufaff]/g, ' ');
|
|
750
|
+
const words = nonCjkText.match(/[A-Za-z0-9_]+|[^\sA-Za-z0-9_]/g)?.length ?? 0;
|
|
751
|
+
return Math.max(1, Math.ceil(cjkChars + words * 0.75));
|
|
752
|
+
}
|
|
615
753
|
//# sourceMappingURL=agent-runner.js.map
|
package/dist/ws/handler.js
CHANGED
|
@@ -68,9 +68,12 @@ registerHandler('channel.message', (_ws, workspaceId, data) => {
|
|
|
68
68
|
broadcastToWorkspace(workspaceId, 'channel.message.updated', updated);
|
|
69
69
|
const agentId = updated.senderId !== 'user' ? updated.senderId : undefined;
|
|
70
70
|
if (agentId) {
|
|
71
|
+
const latestReplyId = updated.replies?.at(-1)?.id;
|
|
71
72
|
void runMentionedAgent(workspaceId, channelId, agentId, stripHtml(content), {
|
|
72
73
|
messageId: updated.id,
|
|
73
74
|
appendUserMessage: stripHtml(content),
|
|
75
|
+
resumeSessionId: updated.metadata?.runtimeSessionId,
|
|
76
|
+
excludeHistoryReplyIds: latestReplyId ? [latestReplyId] : undefined,
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
return;
|
|
@@ -84,7 +87,9 @@ registerHandler('channel.message', (_ws, workspaceId, data) => {
|
|
|
84
87
|
broadcastToWorkspace(workspaceId, 'channel.message', message);
|
|
85
88
|
const agentIds = [...new Set([...(mentions || []), ...extractMentionIds(content)].filter(Boolean))];
|
|
86
89
|
for (const agentId of agentIds) {
|
|
87
|
-
void runMentionedAgent(workspaceId, channelId, agentId, stripHtml(content)
|
|
90
|
+
void runMentionedAgent(workspaceId, channelId, agentId, stripHtml(content), {
|
|
91
|
+
excludeHistoryMessageIds: [message.id],
|
|
92
|
+
});
|
|
88
93
|
}
|
|
89
94
|
});
|
|
90
95
|
registerHandler('channel.stop', (_ws, workspaceId, data) => {
|
package/dist/ws/message-parts.js
CHANGED
|
@@ -45,6 +45,19 @@ export function buildAgentMessageParts(input) {
|
|
|
45
45
|
maxTokens: 128_000,
|
|
46
46
|
modelId: input.model,
|
|
47
47
|
usage,
|
|
48
|
+
agentContext: {
|
|
49
|
+
sessionId: input.sessionId,
|
|
50
|
+
agentConfigId: input.agentConfigId,
|
|
51
|
+
name: input.presetName,
|
|
52
|
+
role: input.role,
|
|
53
|
+
runtime: input.runtime,
|
|
54
|
+
model: input.model,
|
|
55
|
+
systemPrompt: input.systemPrompt,
|
|
56
|
+
userPrompt: input.userPrompt,
|
|
57
|
+
fullPrompt: input.fullPrompt,
|
|
58
|
+
output: lines.join('\n'),
|
|
59
|
+
outputItems: input.outputItems,
|
|
60
|
+
},
|
|
48
61
|
});
|
|
49
62
|
}
|
|
50
63
|
if (input.error) {
|
|
@@ -441,11 +454,17 @@ function isToolLikeLine(line) {
|
|
|
441
454
|
return /^(Using|Tool:|Read|Write|Edit|MultiEdit|Bash|Search|Grep|Glob|Todo|Task|Web|Fetch|Claude Code initialized|Codex initialized|.+ running \(\d+s\))/i.test(line.trim());
|
|
442
455
|
}
|
|
443
456
|
function isIgnorableToolProgressLine(line) {
|
|
444
|
-
const
|
|
457
|
+
const raw = line.trim();
|
|
458
|
+
const trimmed = stripSubagentProgressPrefix(raw);
|
|
459
|
+
const isSubagentProgress = trimmed !== raw;
|
|
445
460
|
return /^Claude$/i.test(trimmed)
|
|
446
461
|
|| /^(Reading|Searching)(\.{1,3}|…)?$/i.test(trimmed)
|
|
462
|
+
|| (isSubagentProgress && /^(Reading|Searching)\s+\S.+$/i.test(trimmed))
|
|
447
463
|
|| /^(Read|Search|Grep|Glob|SemanticSearch|WebSearch)\s+running\s+\(\d+s\)$/i.test(trimmed);
|
|
448
464
|
}
|
|
465
|
+
function stripSubagentProgressPrefix(line) {
|
|
466
|
+
return line.replace(/^\[[^\]]+\]\s+subagent progress\s+\|\s*/i, '');
|
|
467
|
+
}
|
|
449
468
|
function isFinalAnswerLine(line) {
|
|
450
469
|
return !isToolLikeLine(line) && !/^(\[.*\]|Agent runtime configuration:|Conversation history:)/.test(line.trim());
|
|
451
470
|
}
|
|
@@ -20,13 +20,18 @@ export function handleTerminalEvent(ws, workspaceId, event, data) {
|
|
|
20
20
|
case 'terminal.create': {
|
|
21
21
|
const payload = data;
|
|
22
22
|
const cwd = payload.cwd || process.env.HOME || process.env.USERPROFILE || (process.platform === 'win32' ? process.env.SYSTEMROOT || 'C:\\' : '/tmp');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
try {
|
|
24
|
+
const sessionId = ptyService.createSession(workspaceId, cwd, (id, output) => {
|
|
25
|
+
broadcastToWorkspace(workspaceId, 'terminal.output', { sessionId: id, data: output });
|
|
26
|
+
}, (id, exitCode) => {
|
|
27
|
+
broadcastToWorkspace(workspaceId, 'terminal.closed', { sessionId: id, exitCode });
|
|
28
|
+
}, payload.shell, undefined, payload.sessionId);
|
|
29
|
+
const session = ptyService.getSession(sessionId);
|
|
30
|
+
broadcastToWorkspace(workspaceId, 'terminal.created', { sessionId, cwd, shell: session?.shell ?? payload.shell });
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
broadcastToWorkspace(workspaceId, 'terminal.error', { sessionId: payload.sessionId, error: err.message || String(err) });
|
|
34
|
+
}
|
|
30
35
|
break;
|
|
31
36
|
}
|
|
32
37
|
case 'terminal.input': {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { createServerProcess, createWebSocketConnection, forward } from 'vscode-ws-jsonrpc/server';
|
|
5
|
+
import { getById as getWorkspaceById } from '../services/workspace.js';
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
function resolveTypeScriptRoot(rootDir) {
|
|
8
|
+
const candidates = [
|
|
9
|
+
rootDir,
|
|
10
|
+
join(rootDir, 'packages/web'),
|
|
11
|
+
];
|
|
12
|
+
for (const candidate of candidates) {
|
|
13
|
+
if (existsSync(join(candidate, 'tsconfig.json')) || existsSync(join(candidate, 'jsconfig.json'))) {
|
|
14
|
+
return candidate;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return rootDir;
|
|
18
|
+
}
|
|
19
|
+
function closeWithReason(ws, code, reason) {
|
|
20
|
+
try {
|
|
21
|
+
ws.close(code, reason);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// The socket may already be closing.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function toRpcSocket(ws) {
|
|
28
|
+
return {
|
|
29
|
+
send: (content) => {
|
|
30
|
+
if (ws.readyState === ws.OPEN) {
|
|
31
|
+
ws.send(content);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
onMessage: (cb) => {
|
|
35
|
+
ws.on('message', (data) => cb(data.toString()));
|
|
36
|
+
},
|
|
37
|
+
onError: (cb) => {
|
|
38
|
+
ws.on('error', cb);
|
|
39
|
+
},
|
|
40
|
+
onClose: (cb) => {
|
|
41
|
+
ws.on('close', (code, buffer) => cb(code, buffer.toString()));
|
|
42
|
+
},
|
|
43
|
+
dispose: () => {
|
|
44
|
+
closeWithReason(ws, 1000, 'disposed');
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function handleTypeScriptLspConnection(ws, workspaceId) {
|
|
49
|
+
const workspace = getWorkspaceById(workspaceId);
|
|
50
|
+
const rootDir = workspace?.boundDirs?.[0] ? resolve(workspace.boundDirs[0]) : null;
|
|
51
|
+
if (!workspace || !rootDir) {
|
|
52
|
+
closeWithReason(ws, 4004, 'Workspace not found');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const tsRootDir = resolveTypeScriptRoot(rootDir);
|
|
56
|
+
console.info('[typescript-lsp] starting', {
|
|
57
|
+
workspaceId,
|
|
58
|
+
rootDir,
|
|
59
|
+
tsRootDir,
|
|
60
|
+
});
|
|
61
|
+
const socketConnection = createWebSocketConnection(toRpcSocket(ws));
|
|
62
|
+
const serverConnection = createServerProcess('TypeScript', process.execPath, [
|
|
63
|
+
require.resolve('typescript-language-server/lib/cli.mjs'),
|
|
64
|
+
'--stdio',
|
|
65
|
+
], {
|
|
66
|
+
cwd: tsRootDir,
|
|
67
|
+
env: {
|
|
68
|
+
...process.env,
|
|
69
|
+
TSS_LOG: process.env.TSS_LOG ?? '-level off',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
if (!serverConnection) {
|
|
73
|
+
closeWithReason(ws, 1011, 'Failed to start TypeScript language server');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
forward(socketConnection, serverConnection);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=typescript-lsp.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-spaces/server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agent-spaces-server": "./dist/app.js"
|
|
@@ -14,7 +14,15 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "tsx watch src/app.ts",
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"start": "node dist/app.js",
|
|
21
|
+
"prepublishOnly": "pnpm build",
|
|
22
|
+
"postinstall": "node -e \"try{require('node-pty')}catch(e){if(!require('fs').existsSync('node_modules/node-pty/prebuilds')){process.exit(1)}}\""
|
|
23
|
+
},
|
|
17
24
|
"dependencies": {
|
|
25
|
+
"@agent-spaces/shared": "workspace:*",
|
|
18
26
|
"@anthropic-ai/claude-agent-sdk": "^0.2.126",
|
|
19
27
|
"@codeany/open-agent-sdk": "^0.2.1",
|
|
20
28
|
"@langchain/anthropic": "^1.3.29",
|
|
@@ -29,10 +37,11 @@
|
|
|
29
37
|
"minimatch": "^10.2.5",
|
|
30
38
|
"node-pty": "^1.1.0",
|
|
31
39
|
"simple-git": "^3.36.0",
|
|
40
|
+
"typescript-language-server": "^5.2.0",
|
|
32
41
|
"uuid": "^11.1.0",
|
|
42
|
+
"vscode-ws-jsonrpc": "^3.5.0",
|
|
33
43
|
"ws": "^8.18.2",
|
|
34
|
-
"zod": "^4.0.0"
|
|
35
|
-
"@agent-spaces/shared": "0.2.1"
|
|
44
|
+
"zod": "^4.0.0"
|
|
36
45
|
},
|
|
37
46
|
"devDependencies": {
|
|
38
47
|
"@types/cors": "^2.8.17",
|
|
@@ -43,11 +52,5 @@
|
|
|
43
52
|
"@types/ws": "^8.18.1",
|
|
44
53
|
"tsx": "^4.19.4",
|
|
45
54
|
"typescript": "^5.8.3"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"dev": "tsx watch src/app.ts",
|
|
49
|
-
"build": "tsc",
|
|
50
|
-
"start": "node dist/app.js",
|
|
51
|
-
"postinstall": "node -e \"try{require('node-pty')}catch(e){if(!require('fs').existsSync('node_modules/node-pty/prebuilds')){process.exit(1)}}\""
|
|
52
55
|
}
|
|
53
|
-
}
|
|
56
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,893300,(e,t,r)=>{var n={229:function(e){var t,r,n,a=e.exports={};function o(){throw Error("setTimeout has not been defined")}function c(){throw Error("clearTimeout has not been defined")}try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:c}catch(e){r=c}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}var s=[],l=!1,u=-1;function f(){l&&n&&(l=!1,n.length?s=n.concat(s):u=-1,s.length&&d())}function d(){if(!l){var e=i(f);l=!0;for(var t=s.length;t;){for(n=s,s=[];++u<t;)n&&n[u].run();u=-1,t=s.length}n=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===c||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];s.push(new h(e,t)),1!==s.length||l||i(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=p,a.addListener=p,a.once=p,a.off=p,a.removeListener=p,a.removeAllListeners=p,a.emit=p,a.prependListener=p,a.prependOnceListener=p,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}},c=!0;try{n[e](r,r.exports,o),c=!1}finally{c&&delete a[e]}return r.exports}o.ab="/ROOT/node_modules/.pnpm/next@16.2.4_@babel+core@7.29.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/next/dist/compiled/process/",t.exports=o(229)},8890,(e,t,r)=>{"use strict";var n,a;t.exports=(null==(n=e.g.process)?void 0:n.env)&&"object"==typeof(null==(a=e.g.process)?void 0:a.env)?e.g.process:e.r(893300)},754747,e=>{"use strict";var t,r,n,a,o,c,i,s,l;function u(e,t=!1){let r=e.length,n=0,a="",o=0,c=16,i=0,s=0,l=0,p=0,k=0;function g(){if(a="",k=0,o=n,s=i,p=l,n>=r)return o=r,c=17;let t=e.charCodeAt(n);if(f(t)){do n++,a+=String.fromCharCode(t),t=e.charCodeAt(n);while(f(t))return c=15}if(d(t))return n++,a+=String.fromCharCode(t),13===t&&10===e.charCodeAt(n)&&(n++,a+="\n"),i++,l=n,c=14;switch(t){case 123:return n++,c=1;case 125:return n++,c=2;case 91:return n++,c=3;case 93:return n++,c=4;case 58:return n++,c=6;case 44:return n++,c=5;case 34:return n++,a=function(){let t="",a=n;for(;;){if(n>=r){t+=e.substring(a,n),k=2;break}let o=e.charCodeAt(n);if(34===o){t+=e.substring(a,n),n++;break}if(92===o){if(t+=e.substring(a,n),++n>=r){k=2;break}switch(e.charCodeAt(n++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+=" ";break;case 117:let o=function(){let t=0,r=0;for(;t<4;){let a=e.charCodeAt(n);if(a>=48&&a<=57)r=16*r+a-48;else if(a>=65&&a<=70)r=16*r+a-65+10;else if(a>=97&&a<=102)r=16*r+a-97+10;else break;n++,t++}return t<4&&(r=-1),r}();o>=0?t+=String.fromCharCode(o):k=4;break;default:k=5}a=n;continue}if(o>=0&&o<=31)if(d(o)){t+=e.substring(a,n),k=2;break}else k=6;n++}return t}(),c=10;case 47:let u=n-1;if(47===e.charCodeAt(n+1)){for(n+=2;n<r&&!d(e.charCodeAt(n));)n++;return a=e.substring(u,n),c=12}if(42===e.charCodeAt(n+1)){n+=2;let t=r-1,o=!1;for(;n<t;){let t=e.charCodeAt(n);if(42===t&&47===e.charCodeAt(n+1)){n+=2,o=!0;break}n++,d(t)&&(13===t&&10===e.charCodeAt(n)&&n++,i++,l=n)}return o||(n++,k=1),a=e.substring(u,n),c=13}return a+=String.fromCharCode(t),n++,c=16;case 45:if(a+=String.fromCharCode(t),++n===r||!h(e.charCodeAt(n)))return c=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return a+=function(){let t=n;if(48===e.charCodeAt(n))n++;else for(n++;n<e.length&&h(e.charCodeAt(n));)n++;if(n<e.length&&46===e.charCodeAt(n)){if(!(++n<e.length&&h(e.charCodeAt(n))))return k=3,e.substring(t,n);for(n++;n<e.length&&h(e.charCodeAt(n));)n++}let r=n;if(n<e.length&&(69===e.charCodeAt(n)||101===e.charCodeAt(n)))if((++n<e.length&&43===e.charCodeAt(n)||45===e.charCodeAt(n))&&n++,n<e.length&&h(e.charCodeAt(n))){for(n++;n<e.length&&h(e.charCodeAt(n));)n++;r=n}else k=3;return e.substring(t,r)}(),c=11;default:for(;n<r&&function(e){if(f(e)||d(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}(t);)n++,t=e.charCodeAt(n);if(o!==n){switch(a=e.substring(o,n)){case"true":return c=8;case"false":return c=9;case"null":return c=7}return c=16}return a+=String.fromCharCode(t),n++,c=16}}return{setPosition:function(e){n=e,a="",o=0,c=16,k=0},getPosition:()=>n,scan:t?function(){let e;do e=g();while(e>=12&&e<=15)return e}:g,getToken:()=>c,getTokenValue:()=>a,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>s,getTokenStartCharacter:()=>o-p,getTokenError:()=>k}}function f(e){return 32===e||9===e}function d(e){return 10===e||13===e}function h(e){return e>=48&&e<=57}(c=t||(t={}))[c.lineFeed=10]="lineFeed",c[c.carriageReturn=13]="carriageReturn",c[c.space=32]="space",c[c._0=48]="_0",c[c._1=49]="_1",c[c._2=50]="_2",c[c._3=51]="_3",c[c._4=52]="_4",c[c._5=53]="_5",c[c._6=54]="_6",c[c._7=55]="_7",c[c._8=56]="_8",c[c._9=57]="_9",c[c.a=97]="a",c[c.b=98]="b",c[c.c=99]="c",c[c.d=100]="d",c[c.e=101]="e",c[c.f=102]="f",c[c.g=103]="g",c[c.h=104]="h",c[c.i=105]="i",c[c.j=106]="j",c[c.k=107]="k",c[c.l=108]="l",c[c.m=109]="m",c[c.n=110]="n",c[c.o=111]="o",c[c.p=112]="p",c[c.q=113]="q",c[c.r=114]="r",c[c.s=115]="s",c[c.t=116]="t",c[c.u=117]="u",c[c.v=118]="v",c[c.w=119]="w",c[c.x=120]="x",c[c.y=121]="y",c[c.z=122]="z",c[c.A=65]="A",c[c.B=66]="B",c[c.C=67]="C",c[c.D=68]="D",c[c.E=69]="E",c[c.F=70]="F",c[c.G=71]="G",c[c.H=72]="H",c[c.I=73]="I",c[c.J=74]="J",c[c.K=75]="K",c[c.L=76]="L",c[c.M=77]="M",c[c.N=78]="N",c[c.O=79]="O",c[c.P=80]="P",c[c.Q=81]="Q",c[c.R=82]="R",c[c.S=83]="S",c[c.T=84]="T",c[c.U=85]="U",c[c.V=86]="V",c[c.W=87]="W",c[c.X=88]="X",c[c.Y=89]="Y",c[c.Z=90]="Z",c[c.asterisk=42]="asterisk",c[c.backslash=92]="backslash",c[c.closeBrace=125]="closeBrace",c[c.closeBracket=93]="closeBracket",c[c.colon=58]="colon",c[c.comma=44]="comma",c[c.dot=46]="dot",c[c.doubleQuote=34]="doubleQuote",c[c.minus=45]="minus",c[c.openBrace=123]="openBrace",c[c.openBracket=91]="openBracket",c[c.plus=43]="plus",c[c.slash=47]="slash",c[c.formFeed=12]="formFeed",c[c.tab=9]="tab";let p=Array(20).fill(0).map((e,t)=>" ".repeat(t)),k={" ":{"\n":Array(200).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":Array(200).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))}," ":{"\n":Array(200).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":Array(200).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))}},g=["\n","\r","\r\n"];function m(e,t){let r="";for(let n=0;n<t;n++)r+=e;return r}function T(e,t){return -1!=="\r\n".indexOf(e.charAt(t))}(r||(r={})).DEFAULT={allowTrailingComma:!1},(i=n||(n={}))[i.None=0]="None",i[i.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",i[i.UnexpectedEndOfString=2]="UnexpectedEndOfString",i[i.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",i[i.InvalidUnicode=4]="InvalidUnicode",i[i.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",i[i.InvalidCharacter=6]="InvalidCharacter",(s=a||(a={}))[s.OpenBraceToken=1]="OpenBraceToken",s[s.CloseBraceToken=2]="CloseBraceToken",s[s.OpenBracketToken=3]="OpenBracketToken",s[s.CloseBracketToken=4]="CloseBracketToken",s[s.CommaToken=5]="CommaToken",s[s.ColonToken=6]="ColonToken",s[s.NullKeyword=7]="NullKeyword",s[s.TrueKeyword=8]="TrueKeyword",s[s.FalseKeyword=9]="FalseKeyword",s[s.StringLiteral=10]="StringLiteral",s[s.NumericLiteral=11]="NumericLiteral",s[s.LineCommentTrivia=12]="LineCommentTrivia",s[s.BlockCommentTrivia=13]="BlockCommentTrivia",s[s.LineBreakTrivia=14]="LineBreakTrivia",s[s.Trivia=15]="Trivia",s[s.Unknown=16]="Unknown",s[s.EOF=17]="EOF";let b=function(e,t=[],n=r.DEFAULT){let a=null,o=[],c=[];function i(e){Array.isArray(o)?o.push(e):null!==a&&(o[a]=e)}return function(e,t,n=r.DEFAULT){let a=u(e,!1),o=[];function c(e){return e?()=>e(a.getTokenOffset(),a.getTokenLength(),a.getTokenStartLine(),a.getTokenStartCharacter()):()=>!0}function i(e){return e?()=>e(a.getTokenOffset(),a.getTokenLength(),a.getTokenStartLine(),a.getTokenStartCharacter(),()=>o.slice()):()=>!0}function s(e){return e?t=>e(t,a.getTokenOffset(),a.getTokenLength(),a.getTokenStartLine(),a.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>e(t,a.getTokenOffset(),a.getTokenLength(),a.getTokenStartLine(),a.getTokenStartCharacter(),()=>o.slice()):()=>!0}let f=i(t.onObjectBegin),d=l(t.onObjectProperty),h=c(t.onObjectEnd),p=i(t.onArrayBegin),k=c(t.onArrayEnd),g=l(t.onLiteralValue),m=s(t.onSeparator),T=c(t.onComment),b=s(t.onError),C=n&&n.disallowComments,v=n&&n.allowTrailingComma;function A(){for(;;){let e=a.scan();switch(a.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:C||y(11);break;case 2:y(12);break;case 6:y(16)}switch(e){case 12:case 13:C?y(10):T();break;case 16:y(1);break;case 15:case 14:break;default:return e}}}function y(e,t=[],r=[]){if(b(e),t.length+r.length>0){let e=a.getToken();for(;17!==e;){if(-1!==t.indexOf(e)){A();break}if(-1!==r.indexOf(e))break;e=A()}}}function E(e){let t=a.getTokenValue();return e?g(t):(d(t),o.push(t)),A(),!0}if(A(),17===a.getToken())return n.allowEmptyContent||y(4,[],[]);!function e(){switch(a.getToken()){case 3:p(),A();let t=!0,r=!1;for(;4!==a.getToken()&&17!==a.getToken();){if(5===a.getToken()){if(r||y(4,[],[]),m(","),A(),4===a.getToken()&&v)break}else r&&y(6,[],[]);t?(o.push(0),t=!1):o[o.length-1]++,e()||y(4,[],[4,5]),r=!0}return k(),t||o.pop(),4!==a.getToken()?y(8,[4],[]):A(),!0;case 1:f(),A();let n=!1;for(;2!==a.getToken()&&17!==a.getToken();){if(5===a.getToken()){if(n||y(4,[],[]),m(","),A(),2===a.getToken()&&v)break}else n&&y(6,[],[]);(10!==a.getToken()?(y(3,[],[2,5]),1):(E(!1),6===a.getToken()?(m(":"),A(),e()||y(4,[],[2,5])):y(5,[],[2,5]),o.pop(),0))&&y(4,[],[2,5]),n=!0}return h(),2!==a.getToken()?y(7,[2],[]):A(),!0;case 10:return E(!0);default:switch(a.getToken()){case 11:let c=Number(a.getTokenValue());isNaN(c)&&(y(2),c=0),g(c);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return A(),!0}}()?y(4,[],[]):17!==a.getToken()&&y(9,[],[])}(e,{onObjectBegin:()=>{let e={};i(e),c.push(o),o=e,a=null},onObjectProperty:e=>{a=e},onObjectEnd:()=>{o=c.pop()},onArrayBegin:()=>{let e=[];i(e),c.push(o),o=e,a=null},onArrayEnd:()=>{o=c.pop()},onLiteralValue:i,onError:(e,r,n)=>{t.push({error:e,offset:r,length:n})}},n),o[0]};(l=o||(o={}))[l.InvalidSymbol=1]="InvalidSymbol",l[l.InvalidNumberFormat=2]="InvalidNumberFormat",l[l.PropertyNameExpected=3]="PropertyNameExpected",l[l.ValueExpected=4]="ValueExpected",l[l.ColonExpected=5]="ColonExpected",l[l.CommaExpected=6]="CommaExpected",l[l.CloseBraceExpected=7]="CloseBraceExpected",l[l.CloseBracketExpected=8]="CloseBracketExpected",l[l.EndOfFileExpected=9]="EndOfFileExpected",l[l.InvalidCommentToken=10]="InvalidCommentToken",l[l.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",l[l.UnexpectedEndOfString=12]="UnexpectedEndOfString",l[l.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",l[l.InvalidUnicode=14]="InvalidUnicode",l[l.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",l[l.InvalidCharacter=16]="InvalidCharacter",e.s(["createScanner",0,u,"findNodeAtOffset",0,function e(t,r,n=!1){if(function(e,t,r=!1){return t>=e.offset&&t<e.offset+e.length||r&&t===e.offset+e.length}(t,r,n)){let a=t.children;if(Array.isArray(a))for(let t=0;t<a.length&&a[t].offset<=r;t++){let o=e(a[t],r,n);if(o)return o}return t}},"format",0,function(e,t,r){return function(e,t,r){let n,a,o,c,i,s;if(t){for(i=(c=t.offset)+t.length,o=c;o>0&&!T(e,o-1);)o--;let s=i;for(;s<e.length&&!T(e,s);)s++;n=function(e,t){let r=0,n=0,a=t.tabSize||4;for(;r<e.length;){let t=e.charAt(r);if(t===p[1])n++;else if(" "===t)n+=a;else break;r++}return Math.floor(n/a)}(a=e.substring(o,s),r)}else a=e,n=0,o=0,c=0,i=e.length;let l=function(e,t){for(let e=0;e<t.length;e++){let r=t.charAt(e);if("\r"===r){if(e+1<t.length&&"\n"===t.charAt(e+1))return"\r\n";return"\r"}if("\n"===r)return"\n"}return e&&e.eol||"\n"}(r,e),f=g.includes(l),d=0,h=0,b=" "===(s=r.insertSpaces?p[r.tabSize||4]??m(p[1],r.tabSize||4):" ")?" ":" ",C=u(a,!1),v=!1;function A(){if(d>1)return m(l,d)+m(s,n+h);let e=s.length*(n+h);return!f||e>k[b][l].length?l+m(s,n+h):e<=0?l:k[b][l][e]}function y(){let e=C.scan();for(d=0;15===e||14===e;)14===e&&r.keepLines?d+=1:14===e&&(d=1),e=C.scan();return v=16===e||0!==C.getTokenError(),e}let E=[];function O(r,n,a){!v&&(!t||n<i&&a>c)&&e.substring(n,a)!==r&&E.push({offset:n,length:a-n,content:r})}let L=y();if(r.keepLines&&d>0&&O(m(l,d),0,0),17!==L){let e=C.getTokenOffset()+o;O(s.length*n<20&&r.insertSpaces?p[s.length*n]:m(s,n),o,e)}for(;17!==L;){let e=C.getTokenOffset()+C.getTokenLength()+o,t=y(),n="",a=!1;for(;0===d&&(12===t||13===t);){let r=C.getTokenOffset()+o;O(p[1],e,r),e=C.getTokenOffset()+C.getTokenLength()+o,n=(a=12===t)?A():"",t=y()}if(2===t)1!==L&&h--,r.keepLines&&d>0||!r.keepLines&&1!==L?n=A():r.keepLines&&(n=p[1]);else if(4===t)3!==L&&h--,r.keepLines&&d>0||!r.keepLines&&3!==L?n=A():r.keepLines&&(n=p[1]);else{switch(L){case 3:case 1:h++,n=r.keepLines&&d>0||!r.keepLines?A():p[1];break;case 5:n=r.keepLines&&d>0||!r.keepLines?A():p[1];break;case 12:n=A();break;case 13:d>0?n=A():a||(n=p[1]);break;case 6:r.keepLines&&d>0?n=A():a||(n=p[1]);break;case 10:r.keepLines&&d>0?n=A():6!==t||a||(n="");break;case 7:case 8:case 9:case 11:case 2:case 4:r.keepLines&&d>0?n=A():12!==t&&13!==t||a?5!==t&&17!==t&&(v=!0):n=p[1];break;case 16:v=!0}d>0&&(12===t||13===t)&&(n=A())}17===t&&(n=r.keepLines&&d>0?A():r.insertFinalNewline?l:""),O(n,e,C.getTokenOffset()+o),L=t}return E}(e,t,r)},"getNodePath",0,function e(t){if(!t.parent||!t.parent.children)return[];let r=e(t.parent);if("property"===t.parent.type){let e=t.parent.children[0].value;r.push(e)}else if("array"===t.parent.type){let e=t.parent.children.indexOf(t);-1!==e&&r.push(e)}return r},"getNodeValue",0,function e(t){switch(t.type){case"array":return t.children.map(e);case"object":let r=Object.create(null);for(let n of t.children){let t=n.children[1];t&&(r[n.children[0].value]=e(t))}return r;case"null":case"string":case"number":case"boolean":return t.value;default:return}},"parse",0,b],754747)}]);
|