@gulbanana/jagman 0.0.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/LICENSE +663 -0
- package/README.md +40 -0
- package/bin/jagman.js +35 -0
- package/build/client/_app/immutable/assets/0.B3c8us65.css +1 -0
- package/build/client/_app/immutable/assets/0.B3c8us65.css.br +0 -0
- package/build/client/_app/immutable/assets/0.B3c8us65.css.gz +0 -0
- package/build/client/_app/immutable/assets/2.QhF3SmLf.css +1 -0
- package/build/client/_app/immutable/assets/2.QhF3SmLf.css.br +0 -0
- package/build/client/_app/immutable/assets/2.QhF3SmLf.css.gz +0 -0
- package/build/client/_app/immutable/assets/4.BoAskxZr.css +1 -0
- package/build/client/_app/immutable/assets/4.BoAskxZr.css.br +0 -0
- package/build/client/_app/immutable/assets/4.BoAskxZr.css.gz +0 -0
- package/build/client/_app/immutable/assets/5.DYpN9IwI.css +1 -0
- package/build/client/_app/immutable/assets/5.DYpN9IwI.css.br +0 -0
- package/build/client/_app/immutable/assets/5.DYpN9IwI.css.gz +0 -0
- package/build/client/_app/immutable/assets/7.BBPBRqyF.css +1 -0
- package/build/client/_app/immutable/assets/7.BBPBRqyF.css.br +0 -0
- package/build/client/_app/immutable/assets/7.BBPBRqyF.css.gz +0 -0
- package/build/client/_app/immutable/assets/8.WP6ZlE0M.css +1 -0
- package/build/client/_app/immutable/assets/8.WP6ZlE0M.css.br +0 -0
- package/build/client/_app/immutable/assets/8.WP6ZlE0M.css.gz +0 -0
- package/build/client/_app/immutable/assets/9.DH8YZ1_b.css +1 -0
- package/build/client/_app/immutable/assets/9.DH8YZ1_b.css.br +0 -0
- package/build/client/_app/immutable/assets/9.DH8YZ1_b.css.gz +0 -0
- package/build/client/_app/immutable/assets/ErrorSpan.BarpW_JY.css +1 -0
- package/build/client/_app/immutable/assets/ErrorSpan.BarpW_JY.css.br +0 -0
- package/build/client/_app/immutable/assets/ErrorSpan.BarpW_JY.css.gz +0 -0
- package/build/client/_app/immutable/assets/Icon.Di_GsCEs.css +1 -0
- package/build/client/_app/immutable/assets/Icon.Di_GsCEs.css.br +0 -0
- package/build/client/_app/immutable/assets/Icon.Di_GsCEs.css.gz +0 -0
- package/build/client/_app/immutable/assets/Pane.LvSW-vL-.css +1 -0
- package/build/client/_app/immutable/assets/Pane.LvSW-vL-.css.br +0 -0
- package/build/client/_app/immutable/assets/Pane.LvSW-vL-.css.gz +0 -0
- package/build/client/_app/immutable/assets/favicon.DGDeBov5.svg +191 -0
- package/build/client/_app/immutable/assets/favicon.DGDeBov5.svg.br +0 -0
- package/build/client/_app/immutable/assets/favicon.DGDeBov5.svg.gz +0 -0
- package/build/client/_app/immutable/assets/feather-sprite.BfIm3Xr9.svg +1 -0
- package/build/client/_app/immutable/assets/feather-sprite.BfIm3Xr9.svg.br +0 -0
- package/build/client/_app/immutable/assets/feather-sprite.BfIm3Xr9.svg.gz +0 -0
- package/build/client/_app/immutable/assets/gc-dark.DHisUerN.svg +101 -0
- package/build/client/_app/immutable/assets/gc-dark.DHisUerN.svg.br +0 -0
- package/build/client/_app/immutable/assets/gc-dark.DHisUerN.svg.gz +0 -0
- package/build/client/_app/immutable/assets/gc-light.C55NzigM.svg +100 -0
- package/build/client/_app/immutable/assets/gc-light.C55NzigM.svg.br +0 -0
- package/build/client/_app/immutable/assets/gc-light.C55NzigM.svg.gz +0 -0
- package/build/client/_app/immutable/chunks/B3ZkAhB4.js +1 -0
- package/build/client/_app/immutable/chunks/B3ZkAhB4.js.br +0 -0
- package/build/client/_app/immutable/chunks/B3ZkAhB4.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B9tazVuH.js +2 -0
- package/build/client/_app/immutable/chunks/B9tazVuH.js.br +0 -0
- package/build/client/_app/immutable/chunks/B9tazVuH.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BdkrN5mN.js +1 -0
- package/build/client/_app/immutable/chunks/BdkrN5mN.js.br +0 -0
- package/build/client/_app/immutable/chunks/BdkrN5mN.js.gz +0 -0
- package/build/client/_app/immutable/chunks/ByNAvWKi.js +1 -0
- package/build/client/_app/immutable/chunks/ByNAvWKi.js.br +0 -0
- package/build/client/_app/immutable/chunks/ByNAvWKi.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C8oOvULD.js +1 -0
- package/build/client/_app/immutable/chunks/C8oOvULD.js.br +0 -0
- package/build/client/_app/immutable/chunks/C8oOvULD.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CCH3sm1V.js +1 -0
- package/build/client/_app/immutable/chunks/CCH3sm1V.js.br +0 -0
- package/build/client/_app/immutable/chunks/CCH3sm1V.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CDD8JGhu.js +1 -0
- package/build/client/_app/immutable/chunks/CDD8JGhu.js.br +0 -0
- package/build/client/_app/immutable/chunks/CDD8JGhu.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CKIpFoVh.js +1 -0
- package/build/client/_app/immutable/chunks/CKIpFoVh.js.br +0 -0
- package/build/client/_app/immutable/chunks/CKIpFoVh.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CMyhPqp1.js +1 -0
- package/build/client/_app/immutable/chunks/CMyhPqp1.js.br +0 -0
- package/build/client/_app/immutable/chunks/CMyhPqp1.js.gz +0 -0
- package/build/client/_app/immutable/chunks/COe4_SPO.js +1 -0
- package/build/client/_app/immutable/chunks/COe4_SPO.js.br +0 -0
- package/build/client/_app/immutable/chunks/COe4_SPO.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CaZKc3PV.js +2 -0
- package/build/client/_app/immutable/chunks/CaZKc3PV.js.br +0 -0
- package/build/client/_app/immutable/chunks/CaZKc3PV.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Cj8zunyE.js +1 -0
- package/build/client/_app/immutable/chunks/Cj8zunyE.js.br +2 -0
- package/build/client/_app/immutable/chunks/Cj8zunyE.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CvfIoSRb.js +1 -0
- package/build/client/_app/immutable/chunks/CvfIoSRb.js.br +0 -0
- package/build/client/_app/immutable/chunks/CvfIoSRb.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DhBP0au1.js +1 -0
- package/build/client/_app/immutable/chunks/DhBP0au1.js.br +0 -0
- package/build/client/_app/immutable/chunks/DhBP0au1.js.gz +0 -0
- package/build/client/_app/immutable/chunks/F2VqmO6x.js +1 -0
- package/build/client/_app/immutable/chunks/F2VqmO6x.js.br +0 -0
- package/build/client/_app/immutable/chunks/F2VqmO6x.js.gz +0 -0
- package/build/client/_app/immutable/chunks/hlNgmD7C.js +1 -0
- package/build/client/_app/immutable/chunks/hlNgmD7C.js.br +0 -0
- package/build/client/_app/immutable/chunks/hlNgmD7C.js.gz +0 -0
- package/build/client/_app/immutable/chunks/tW0gGpbB.js +2 -0
- package/build/client/_app/immutable/chunks/tW0gGpbB.js.br +0 -0
- package/build/client/_app/immutable/chunks/tW0gGpbB.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.BJglbmCx.js +2 -0
- package/build/client/_app/immutable/entry/app.BJglbmCx.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BJglbmCx.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.f6OGjaz6.js +1 -0
- package/build/client/_app/immutable/entry/start.f6OGjaz6.js.br +2 -0
- package/build/client/_app/immutable/entry/start.f6OGjaz6.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.BcUb2smo.js +1 -0
- package/build/client/_app/immutable/nodes/0.BcUb2smo.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.BcUb2smo.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.xem2AZVD.js +1 -0
- package/build/client/_app/immutable/nodes/1.xem2AZVD.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.xem2AZVD.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.CDTJMs0M.js +1 -0
- package/build/client/_app/immutable/nodes/2.CDTJMs0M.js.br +1 -0
- package/build/client/_app/immutable/nodes/2.CDTJMs0M.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.Kr4ly1KY.js +1 -0
- package/build/client/_app/immutable/nodes/3.Kr4ly1KY.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.Kr4ly1KY.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.CkrrNwwZ.js +1 -0
- package/build/client/_app/immutable/nodes/4.CkrrNwwZ.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.CkrrNwwZ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.Ck9pAYWh.js +3 -0
- package/build/client/_app/immutable/nodes/5.Ck9pAYWh.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.Ck9pAYWh.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BZru-VFo.js +1 -0
- package/build/client/_app/immutable/nodes/6.BZru-VFo.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BZru-VFo.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.DQKVlDfB.js +1 -0
- package/build/client/_app/immutable/nodes/7.DQKVlDfB.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.DQKVlDfB.js.gz +0 -0
- package/build/client/_app/immutable/nodes/8.CRaTbcsI.js +1 -0
- package/build/client/_app/immutable/nodes/8.CRaTbcsI.js.br +0 -0
- package/build/client/_app/immutable/nodes/8.CRaTbcsI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/9.ZY9fPTpH.js +1 -0
- package/build/client/_app/immutable/nodes/9.ZY9fPTpH.js.br +0 -0
- package/build/client/_app/immutable/nodes/9.ZY9fPTpH.js.gz +0 -0
- package/build/client/_app/version.json +1 -0
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/env.js +94 -0
- package/build/handler.js +1494 -0
- package/build/index.js +345 -0
- package/build/server/chunks/0-DFKHNL47.js +9 -0
- package/build/server/chunks/0-DFKHNL47.js.map +1 -0
- package/build/server/chunks/1-rBV5UzK8.js +9 -0
- package/build/server/chunks/1-rBV5UzK8.js.map +1 -0
- package/build/server/chunks/2-DNhpm2f0.js +9 -0
- package/build/server/chunks/2-DNhpm2f0.js.map +1 -0
- package/build/server/chunks/3-BriZP-4z.js +9 -0
- package/build/server/chunks/3-BriZP-4z.js.map +1 -0
- package/build/server/chunks/4-BRqbjiow.js +9 -0
- package/build/server/chunks/4-BRqbjiow.js.map +1 -0
- package/build/server/chunks/5-DxPUkn7K.js +9 -0
- package/build/server/chunks/5-DxPUkn7K.js.map +1 -0
- package/build/server/chunks/6-OQ8ks1e7.js +19 -0
- package/build/server/chunks/6-OQ8ks1e7.js.map +1 -0
- package/build/server/chunks/7-wbR5qPH1.js +9 -0
- package/build/server/chunks/7-wbR5qPH1.js.map +1 -0
- package/build/server/chunks/8-BL7_9qSi.js +9 -0
- package/build/server/chunks/8-BL7_9qSi.js.map +1 -0
- package/build/server/chunks/9-DC9G3Slz.js +9 -0
- package/build/server/chunks/9-DC9G3Slz.js.map +1 -0
- package/build/server/chunks/ErrorSpan-BSqKaGqG.js +9 -0
- package/build/server/chunks/ErrorSpan-BSqKaGqG.js.map +1 -0
- package/build/server/chunks/Icon-Dr5EwAkb.js +10 -0
- package/build/server/chunks/Icon-Dr5EwAkb.js.map +1 -0
- package/build/server/chunks/Pane-DcSwhEiL.js +41 -0
- package/build/server/chunks/Pane-DcSwhEiL.js.map +1 -0
- package/build/server/chunks/_error.svelte-Cw0MGN-r.js +18 -0
- package/build/server/chunks/_error.svelte-Cw0MGN-r.js.map +1 -0
- package/build/server/chunks/_layout.svelte-CFeu3znf.js +14 -0
- package/build/server/chunks/_layout.svelte-CFeu3znf.js.map +1 -0
- package/build/server/chunks/_layout.svelte-CQ3MtcgC.js +33 -0
- package/build/server/chunks/_layout.svelte-CQ3MtcgC.js.map +1 -0
- package/build/server/chunks/_layout.svelte-D_GQeKpE.js +9 -0
- package/build/server/chunks/_layout.svelte-D_GQeKpE.js.map +1 -0
- package/build/server/chunks/_page.svelte-C8O6i1zq.js +282 -0
- package/build/server/chunks/_page.svelte-C8O6i1zq.js.map +1 -0
- package/build/server/chunks/_page.svelte-CfJpXtNh.js +104 -0
- package/build/server/chunks/_page.svelte-CfJpXtNh.js.map +1 -0
- package/build/server/chunks/_page.svelte-CkpYjdBP.js +68 -0
- package/build/server/chunks/_page.svelte-CkpYjdBP.js.map +1 -0
- package/build/server/chunks/_page.svelte-DbAHpdpc.js +6 -0
- package/build/server/chunks/_page.svelte-DbAHpdpc.js.map +1 -0
- package/build/server/chunks/agent-C7A3zEr3.js +708 -0
- package/build/server/chunks/agent-C7A3zEr3.js.map +1 -0
- package/build/server/chunks/data.remote-3GWudL8p.js +28 -0
- package/build/server/chunks/data.remote-3GWudL8p.js.map +1 -0
- package/build/server/chunks/data.remote2-DPGOveFg.js +23 -0
- package/build/server/chunks/data.remote2-DPGOveFg.js.map +1 -0
- package/build/server/chunks/data.remote3-CDhxyD61.js +25 -0
- package/build/server/chunks/data.remote3-CDhxyD61.js.map +1 -0
- package/build/server/chunks/error.svelte-D0cH8izO.js +13 -0
- package/build/server/chunks/error.svelte-D0cH8izO.js.map +1 -0
- package/build/server/chunks/exports-DsGzTZ0S.js +121 -0
- package/build/server/chunks/exports-DsGzTZ0S.js.map +1 -0
- package/build/server/chunks/hooks.server-Cke-TrVc.js +14 -0
- package/build/server/chunks/hooks.server-Cke-TrVc.js.map +1 -0
- package/build/server/chunks/index-CoD1IJuy.js +190 -0
- package/build/server/chunks/index-CoD1IJuy.js.map +1 -0
- package/build/server/chunks/index-DwoWbz0A.js +1819 -0
- package/build/server/chunks/index-DwoWbz0A.js.map +1 -0
- package/build/server/chunks/index2-Ej5CkWKF.js +44 -0
- package/build/server/chunks/index2-Ej5CkWKF.js.map +1 -0
- package/build/server/chunks/mock-data-D8qN6SIX.js +18 -0
- package/build/server/chunks/mock-data-D8qN6SIX.js.map +1 -0
- package/build/server/chunks/opencode-vgZ5DMQ2.js +452 -0
- package/build/server/chunks/opencode-vgZ5DMQ2.js.map +1 -0
- package/build/server/chunks/remote-1jrju9-CYV2OBS9.js +16 -0
- package/build/server/chunks/remote-1jrju9-CYV2OBS9.js.map +1 -0
- package/build/server/chunks/remote-1t3e9fx-Bq2E-Huu.js +16 -0
- package/build/server/chunks/remote-1t3e9fx-Bq2E-Huu.js.map +1 -0
- package/build/server/chunks/remote-dsfuc2-DwI4AU9q.js +15 -0
- package/build/server/chunks/remote-dsfuc2-DwI4AU9q.js.map +1 -0
- package/build/server/chunks/root-C5lyo0VT.js +2906 -0
- package/build/server/chunks/root-C5lyo0VT.js.map +1 -0
- package/build/server/chunks/shared-bytReIJX.js +1236 -0
- package/build/server/chunks/shared-bytReIJX.js.map +1 -0
- package/build/server/index.js +4422 -0
- package/build/server/index.js.map +1 -0
- package/build/server/manifest.js +83 -0
- package/build/server/manifest.js.map +1 -0
- package/build/shims.js +32 -0
- package/package.json +70 -0
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
import { g as get_request_store, w as with_request_store } from './root-C5lyo0VT.js';
|
|
2
|
+
import { s as stringify_remote_arg, c as create_remote_key, h as handle_error_and_jsonify } from './shared-bytReIJX.js';
|
|
3
|
+
import { e as error, H as HttpError, S as SvelteKitError } from './index-CoD1IJuy.js';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { createReadStream } from 'node:fs';
|
|
8
|
+
import { createInterface } from 'node:readline';
|
|
9
|
+
import { O as OpenCodeAgent, g as getAgentProcesses, a as getWorkspacesWithAgent, m as markExternalSessions } from './opencode-vgZ5DMQ2.js';
|
|
10
|
+
|
|
11
|
+
/** @import { RemoteInfo } from 'types' */
|
|
12
|
+
|
|
13
|
+
/** @type {RemoteInfo['type'][]} */
|
|
14
|
+
const types = ['command', 'form', 'prerender', 'query', 'query_batch'];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {Record<string, any>} module
|
|
18
|
+
* @param {string} file
|
|
19
|
+
* @param {string} hash
|
|
20
|
+
*/
|
|
21
|
+
function init_remote_functions(module, file, hash) {
|
|
22
|
+
if (module.default) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Cannot export \`default\` from a remote module (${file}) — please use named exports instead`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const [name, fn] of Object.entries(module)) {
|
|
29
|
+
if (!types.includes(fn?.__?.type)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`\`${name}\` exported from ${file} is invalid — all exports from this file must be remote functions`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fn.__.id = `${hash}/${name}`;
|
|
36
|
+
fn.__.name = name;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function create_validator(validate_or_fn, maybe_fn) {
|
|
41
|
+
if (!maybe_fn) {
|
|
42
|
+
return (arg) => {
|
|
43
|
+
if (arg !== void 0) {
|
|
44
|
+
error(400, "Bad Request");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (validate_or_fn === "unchecked") {
|
|
49
|
+
return (arg) => arg;
|
|
50
|
+
}
|
|
51
|
+
if ("~standard" in validate_or_fn) {
|
|
52
|
+
return async (arg) => {
|
|
53
|
+
const { event, state } = get_request_store();
|
|
54
|
+
const result = await validate_or_fn["~standard"].validate(arg);
|
|
55
|
+
if (result.issues) {
|
|
56
|
+
error(
|
|
57
|
+
400,
|
|
58
|
+
await state.handleValidationError({
|
|
59
|
+
issues: result.issues,
|
|
60
|
+
event
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return result.value;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
throw new Error(
|
|
68
|
+
'Invalid validator passed to remote function. Expected "unchecked" or a Standard Schema (https://standardschema.dev)'
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
async function get_response(info, arg, state, get_result) {
|
|
72
|
+
await 0;
|
|
73
|
+
const cache = get_cache(info, state);
|
|
74
|
+
return cache[stringify_remote_arg(arg, state.transport)] ??= get_result();
|
|
75
|
+
}
|
|
76
|
+
async function run_remote_function(event, state, allow_cookies, get_input, fn) {
|
|
77
|
+
const store = {
|
|
78
|
+
event: {
|
|
79
|
+
...event,
|
|
80
|
+
setHeaders: () => {
|
|
81
|
+
throw new Error("setHeaders is not allowed in remote functions");
|
|
82
|
+
},
|
|
83
|
+
cookies: {
|
|
84
|
+
...event.cookies,
|
|
85
|
+
set: (name, value, opts) => {
|
|
86
|
+
{
|
|
87
|
+
throw new Error("Cannot set cookies in `query` or `prerender` functions");
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
delete: (name, opts) => {
|
|
91
|
+
{
|
|
92
|
+
throw new Error("Cannot delete cookies in `query` or `prerender` functions");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
state: {
|
|
98
|
+
...state,
|
|
99
|
+
is_in_remote_function: true
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const input = await with_request_store(store, get_input);
|
|
103
|
+
return with_request_store(store, () => fn(input));
|
|
104
|
+
}
|
|
105
|
+
function get_cache(info, state = get_request_store().state) {
|
|
106
|
+
let cache = state.remote_data?.get(info);
|
|
107
|
+
if (cache === void 0) {
|
|
108
|
+
cache = {};
|
|
109
|
+
(state.remote_data ??= /* @__PURE__ */ new Map()).set(info, cache);
|
|
110
|
+
}
|
|
111
|
+
return cache;
|
|
112
|
+
}
|
|
113
|
+
// @__NO_SIDE_EFFECTS__
|
|
114
|
+
function query(validate_or_fn, maybe_fn) {
|
|
115
|
+
const fn = maybe_fn ?? validate_or_fn;
|
|
116
|
+
const validate = create_validator(validate_or_fn, maybe_fn);
|
|
117
|
+
const __ = { type: "query", id: "", name: "" };
|
|
118
|
+
const wrapper = (arg) => {
|
|
119
|
+
const { event, state } = get_request_store();
|
|
120
|
+
const get_remote_function_result = () => run_remote_function(event, state, false, () => validate(arg), fn);
|
|
121
|
+
const promise = get_response(__, arg, state, get_remote_function_result);
|
|
122
|
+
promise.catch(() => {
|
|
123
|
+
});
|
|
124
|
+
promise.set = (value) => update_refresh_value(get_refresh_context(__, "set", arg), value);
|
|
125
|
+
promise.refresh = () => {
|
|
126
|
+
const refresh_context = get_refresh_context(__, "refresh", arg);
|
|
127
|
+
const is_immediate_refresh = !refresh_context.cache[refresh_context.cache_key];
|
|
128
|
+
const value = is_immediate_refresh ? promise : get_remote_function_result();
|
|
129
|
+
return update_refresh_value(refresh_context, value, is_immediate_refresh);
|
|
130
|
+
};
|
|
131
|
+
promise.withOverride = () => {
|
|
132
|
+
throw new Error(`Cannot call '${__.name}.withOverride()' on the server`);
|
|
133
|
+
};
|
|
134
|
+
return (
|
|
135
|
+
/** @type {RemoteQuery<Output>} */
|
|
136
|
+
promise
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
Object.defineProperty(wrapper, "__", { value: __ });
|
|
140
|
+
return wrapper;
|
|
141
|
+
}
|
|
142
|
+
// @__NO_SIDE_EFFECTS__
|
|
143
|
+
function batch(validate_or_fn, maybe_fn) {
|
|
144
|
+
const fn = maybe_fn ?? validate_or_fn;
|
|
145
|
+
const validate = create_validator(validate_or_fn, maybe_fn);
|
|
146
|
+
const __ = {
|
|
147
|
+
type: "query_batch",
|
|
148
|
+
id: "",
|
|
149
|
+
name: "",
|
|
150
|
+
run: async (args, options) => {
|
|
151
|
+
const { event, state } = get_request_store();
|
|
152
|
+
return run_remote_function(
|
|
153
|
+
event,
|
|
154
|
+
state,
|
|
155
|
+
false,
|
|
156
|
+
async () => Promise.all(args.map(validate)),
|
|
157
|
+
async (input) => {
|
|
158
|
+
const get_result = await fn(input);
|
|
159
|
+
return Promise.all(
|
|
160
|
+
input.map(async (arg, i) => {
|
|
161
|
+
try {
|
|
162
|
+
return { type: "result", data: get_result(arg, i) };
|
|
163
|
+
} catch (error2) {
|
|
164
|
+
return {
|
|
165
|
+
type: "error",
|
|
166
|
+
error: await handle_error_and_jsonify(event, state, options, error2),
|
|
167
|
+
status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
let batching = { args: [], resolvers: [] };
|
|
177
|
+
const wrapper = (arg) => {
|
|
178
|
+
const { event, state } = get_request_store();
|
|
179
|
+
const get_remote_function_result = () => {
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
batching.args.push(arg);
|
|
182
|
+
batching.resolvers.push({ resolve, reject });
|
|
183
|
+
if (batching.args.length > 1) return;
|
|
184
|
+
setTimeout(async () => {
|
|
185
|
+
const batched = batching;
|
|
186
|
+
batching = { args: [], resolvers: [] };
|
|
187
|
+
try {
|
|
188
|
+
return await run_remote_function(
|
|
189
|
+
event,
|
|
190
|
+
state,
|
|
191
|
+
false,
|
|
192
|
+
async () => Promise.all(batched.args.map(validate)),
|
|
193
|
+
async (input) => {
|
|
194
|
+
const get_result = await fn(input);
|
|
195
|
+
for (let i = 0; i < batched.resolvers.length; i++) {
|
|
196
|
+
try {
|
|
197
|
+
batched.resolvers[i].resolve(get_result(input[i], i));
|
|
198
|
+
} catch (error2) {
|
|
199
|
+
batched.resolvers[i].reject(error2);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
} catch (error2) {
|
|
205
|
+
for (const resolver of batched.resolvers) {
|
|
206
|
+
resolver.reject(error2);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, 0);
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
const promise = get_response(__, arg, state, get_remote_function_result);
|
|
213
|
+
promise.catch(() => {
|
|
214
|
+
});
|
|
215
|
+
promise.set = (value) => update_refresh_value(get_refresh_context(__, "set", arg), value);
|
|
216
|
+
promise.refresh = () => {
|
|
217
|
+
const refresh_context = get_refresh_context(__, "refresh", arg);
|
|
218
|
+
const is_immediate_refresh = !refresh_context.cache[refresh_context.cache_key];
|
|
219
|
+
const value = is_immediate_refresh ? promise : get_remote_function_result();
|
|
220
|
+
return update_refresh_value(refresh_context, value, is_immediate_refresh);
|
|
221
|
+
};
|
|
222
|
+
promise.withOverride = () => {
|
|
223
|
+
throw new Error(`Cannot call '${__.name}.withOverride()' on the server`);
|
|
224
|
+
};
|
|
225
|
+
return (
|
|
226
|
+
/** @type {RemoteQuery<Output>} */
|
|
227
|
+
promise
|
|
228
|
+
);
|
|
229
|
+
};
|
|
230
|
+
Object.defineProperty(wrapper, "__", { value: __ });
|
|
231
|
+
return wrapper;
|
|
232
|
+
}
|
|
233
|
+
Object.defineProperty(query, "batch", { value: batch, enumerable: true });
|
|
234
|
+
function get_refresh_context(__, action, arg) {
|
|
235
|
+
const { state } = get_request_store();
|
|
236
|
+
const { refreshes } = state;
|
|
237
|
+
if (!refreshes) {
|
|
238
|
+
const name = __.type === "query_batch" ? `query.batch '${__.name}'` : `query '${__.name}'`;
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Cannot call ${action} on ${name} because it is not executed in the context of a command/form remote function`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
const cache = get_cache(__, state);
|
|
244
|
+
const cache_key = stringify_remote_arg(arg, state.transport);
|
|
245
|
+
const refreshes_key = create_remote_key(__.id, cache_key);
|
|
246
|
+
return { __, state, refreshes, refreshes_key, cache, cache_key };
|
|
247
|
+
}
|
|
248
|
+
function update_refresh_value({ __, refreshes, refreshes_key, cache, cache_key }, value, is_immediate_refresh = false) {
|
|
249
|
+
const promise = Promise.resolve(value);
|
|
250
|
+
if (!is_immediate_refresh) {
|
|
251
|
+
cache[cache_key] = promise;
|
|
252
|
+
}
|
|
253
|
+
if (__.id) {
|
|
254
|
+
refreshes[refreshes_key] = promise;
|
|
255
|
+
}
|
|
256
|
+
return promise.then(() => {
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const REPO_PATHS = [
|
|
261
|
+
"C:\\Users\\banana\\Documents\\code\\jagman",
|
|
262
|
+
"C:\\Users\\banana\\Documents\\code\\gg",
|
|
263
|
+
"C:\\Users\\banana\\Documents\\code\\lockhaven"
|
|
264
|
+
];
|
|
265
|
+
let activeOrder = [];
|
|
266
|
+
function updateActiveOrder(sessions) {
|
|
267
|
+
const currentlyActive = new Set(
|
|
268
|
+
sessions.filter((s) => s.status === "running" || s.status === "waiting" || s.status === "external").map((s) => s.id)
|
|
269
|
+
);
|
|
270
|
+
activeOrder = activeOrder.filter((id) => currentlyActive.has(id));
|
|
271
|
+
const existing = new Set(activeOrder);
|
|
272
|
+
const newlyActive = [...currentlyActive].filter((id) => !existing.has(id));
|
|
273
|
+
activeOrder = [...newlyActive, ...activeOrder];
|
|
274
|
+
return activeOrder;
|
|
275
|
+
}
|
|
276
|
+
function parseRecord(line) {
|
|
277
|
+
let obj;
|
|
278
|
+
try {
|
|
279
|
+
obj = JSON.parse(line);
|
|
280
|
+
} catch {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
if (obj.type === "user" && obj.message) {
|
|
284
|
+
const msg = obj.message;
|
|
285
|
+
return {
|
|
286
|
+
type: "user",
|
|
287
|
+
uuid: obj.uuid ?? "",
|
|
288
|
+
parentUuid: obj.parentUuid ?? null,
|
|
289
|
+
timestamp: obj.timestamp ?? "",
|
|
290
|
+
sessionId: obj.sessionId ?? "",
|
|
291
|
+
slug: obj.slug ?? null,
|
|
292
|
+
permissionMode: obj.permissionMode ?? null,
|
|
293
|
+
cwd: obj.cwd ?? "",
|
|
294
|
+
gitBranch: obj.gitBranch ?? "",
|
|
295
|
+
isSidechain: obj.isSidechain ?? false,
|
|
296
|
+
message: {
|
|
297
|
+
role: "user",
|
|
298
|
+
content: msg.content
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if (obj.type === "assistant" && obj.message) {
|
|
303
|
+
const msg = obj.message;
|
|
304
|
+
return {
|
|
305
|
+
type: "assistant",
|
|
306
|
+
uuid: obj.uuid ?? "",
|
|
307
|
+
parentUuid: obj.parentUuid ?? null,
|
|
308
|
+
timestamp: obj.timestamp ?? "",
|
|
309
|
+
isSidechain: obj.isSidechain ?? false,
|
|
310
|
+
message: {
|
|
311
|
+
role: "assistant",
|
|
312
|
+
model: msg.model ?? "",
|
|
313
|
+
content: msg.content ?? [],
|
|
314
|
+
stop_reason: msg.stop_reason ?? null
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
async function scanSession(filePath, visitor) {
|
|
321
|
+
const stream = createReadStream(filePath, { encoding: "utf-8" });
|
|
322
|
+
const rl = createInterface({ input: stream, crlfDelay: Infinity });
|
|
323
|
+
try {
|
|
324
|
+
for await (const line of rl) {
|
|
325
|
+
const record = parseRecord(line);
|
|
326
|
+
if (record) {
|
|
327
|
+
const cont = visitor(record);
|
|
328
|
+
if (cont === false) break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} finally {
|
|
332
|
+
rl.close();
|
|
333
|
+
stream.destroy();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async function readFirstUserRecord(filePath) {
|
|
337
|
+
let result = null;
|
|
338
|
+
await scanSession(filePath, (record) => {
|
|
339
|
+
if (record.type === "user") {
|
|
340
|
+
result = record;
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
async function readSessionOverview(filePath) {
|
|
347
|
+
let sessionId = null;
|
|
348
|
+
let cwd = "";
|
|
349
|
+
let gitBranch = "";
|
|
350
|
+
let permissionMode = null;
|
|
351
|
+
let hasContent = false;
|
|
352
|
+
let lastTimestamp = "";
|
|
353
|
+
let lastAssistantText = null;
|
|
354
|
+
let firstUserText = null;
|
|
355
|
+
await scanSession(filePath, (record) => {
|
|
356
|
+
if (record.timestamp > lastTimestamp) {
|
|
357
|
+
lastTimestamp = record.timestamp;
|
|
358
|
+
}
|
|
359
|
+
if (record.type === "user") {
|
|
360
|
+
if (sessionId === null) {
|
|
361
|
+
sessionId = record.sessionId;
|
|
362
|
+
cwd = record.cwd;
|
|
363
|
+
gitBranch = record.gitBranch;
|
|
364
|
+
}
|
|
365
|
+
if (record.permissionMode !== null) permissionMode = record.permissionMode;
|
|
366
|
+
if (!record.isSidechain && firstUserText === null) {
|
|
367
|
+
const text = getUserText(record);
|
|
368
|
+
if (text && !isMetaMessage(record)) {
|
|
369
|
+
hasContent = true;
|
|
370
|
+
firstUserText = text;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
} else if (record.type === "assistant" && !record.isSidechain) {
|
|
374
|
+
hasContent = true;
|
|
375
|
+
const text = getAssistantText(record);
|
|
376
|
+
if (text) lastAssistantText = text;
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
if (!sessionId) return null;
|
|
380
|
+
return { sessionId, cwd, gitBranch, permissionMode, hasContent, lastTimestamp, lastAssistantText, firstUserText };
|
|
381
|
+
}
|
|
382
|
+
async function readAllRecords(filePath) {
|
|
383
|
+
const records = [];
|
|
384
|
+
await scanSession(filePath, (record) => {
|
|
385
|
+
if (!record.isSidechain) {
|
|
386
|
+
records.push(record);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
return records;
|
|
390
|
+
}
|
|
391
|
+
function isIdeTag(text) {
|
|
392
|
+
const trimmed = text.trimStart();
|
|
393
|
+
return trimmed.startsWith("<ide_selection") || trimmed.startsWith("<ide_opened_file");
|
|
394
|
+
}
|
|
395
|
+
function getUserText(record) {
|
|
396
|
+
const content = record.message.content;
|
|
397
|
+
if (typeof content === "string") return content.trim();
|
|
398
|
+
return content.filter((b) => b.type === "text" && b.text.trim() !== "" && !isIdeTag(b.text)).map((b) => b.text).join("\n").trim();
|
|
399
|
+
}
|
|
400
|
+
function getAssistantText(record) {
|
|
401
|
+
return record.message.content.filter((b) => b.type === "text" && b.text.trim() !== "").map((b) => b.text).join("\n").trim();
|
|
402
|
+
}
|
|
403
|
+
function isMetaMessage(record) {
|
|
404
|
+
const text = getUserText(record).trimStart();
|
|
405
|
+
return text.startsWith("<command-name>") || text.startsWith("<local-command-stdout>") || text.startsWith("<local-command-caveat>");
|
|
406
|
+
}
|
|
407
|
+
function getToolUses(record) {
|
|
408
|
+
return record.message.content.filter((b) => b.type === "tool_use").map((b) => ({ id: b.id, name: b.name, input: b.input }));
|
|
409
|
+
}
|
|
410
|
+
function getToolResults(record) {
|
|
411
|
+
const content = record.message.content;
|
|
412
|
+
if (typeof content === "string") return [];
|
|
413
|
+
return content.filter((b) => b.type === "tool_result").map((b) => ({ toolUseId: b.tool_use_id, isError: b.is_error }));
|
|
414
|
+
}
|
|
415
|
+
const PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
416
|
+
let projectIndex = null;
|
|
417
|
+
const sessionFileCache = /* @__PURE__ */ new Map();
|
|
418
|
+
function firstLine(text) {
|
|
419
|
+
const nl = text.indexOf("\n");
|
|
420
|
+
return nl === -1 ? text : text.slice(0, nl);
|
|
421
|
+
}
|
|
422
|
+
function mapPermissionMode(permissionMode) {
|
|
423
|
+
switch (permissionMode) {
|
|
424
|
+
case "default":
|
|
425
|
+
case "acceptEdits":
|
|
426
|
+
return "standard";
|
|
427
|
+
case "plan":
|
|
428
|
+
return "plan";
|
|
429
|
+
case "bypassPermissions":
|
|
430
|
+
return "yolo";
|
|
431
|
+
default:
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
async function buildProjectIndex() {
|
|
436
|
+
const index = /* @__PURE__ */ new Map();
|
|
437
|
+
let dirs;
|
|
438
|
+
try {
|
|
439
|
+
dirs = await readdir(PROJECTS_DIR);
|
|
440
|
+
} catch {
|
|
441
|
+
return index;
|
|
442
|
+
}
|
|
443
|
+
await Promise.all(
|
|
444
|
+
dirs.map(async (dirName) => {
|
|
445
|
+
const dirPath = join(PROJECTS_DIR, dirName);
|
|
446
|
+
try {
|
|
447
|
+
const s = await stat(dirPath);
|
|
448
|
+
if (!s.isDirectory()) return;
|
|
449
|
+
} catch {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
let entries;
|
|
453
|
+
try {
|
|
454
|
+
entries = await readdir(dirPath);
|
|
455
|
+
} catch {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
const firstJsonl = entries.find((e) => e.endsWith(".jsonl"));
|
|
459
|
+
if (!firstJsonl) return;
|
|
460
|
+
const record = await readFirstUserRecord(join(dirPath, firstJsonl));
|
|
461
|
+
if (record) {
|
|
462
|
+
index.set(record.cwd.toLowerCase(), dirName);
|
|
463
|
+
}
|
|
464
|
+
})
|
|
465
|
+
);
|
|
466
|
+
return index;
|
|
467
|
+
}
|
|
468
|
+
async function getProjectIndex() {
|
|
469
|
+
if (!projectIndex) {
|
|
470
|
+
projectIndex = await buildProjectIndex();
|
|
471
|
+
}
|
|
472
|
+
return projectIndex;
|
|
473
|
+
}
|
|
474
|
+
async function readProjectSessions(projectDirName, workspace) {
|
|
475
|
+
const projectPath = join(PROJECTS_DIR, projectDirName);
|
|
476
|
+
let allEntries;
|
|
477
|
+
try {
|
|
478
|
+
allEntries = await readdir(projectPath);
|
|
479
|
+
} catch {
|
|
480
|
+
return { sessions: [], branch: "" };
|
|
481
|
+
}
|
|
482
|
+
const jsonlFiles = allEntries.filter((e) => e.endsWith(".jsonl"));
|
|
483
|
+
const headers = await Promise.all(
|
|
484
|
+
jsonlFiles.map(async (file) => {
|
|
485
|
+
const filePath = join(projectPath, file);
|
|
486
|
+
const overview = await readSessionOverview(filePath);
|
|
487
|
+
if (!overview || !overview.hasContent) return null;
|
|
488
|
+
sessionFileCache.set(overview.sessionId, filePath);
|
|
489
|
+
return {
|
|
490
|
+
sessionId: overview.sessionId,
|
|
491
|
+
title: overview.firstUserText ? firstLine(overview.firstUserText) : overview.sessionId,
|
|
492
|
+
mode: mapPermissionMode(overview.permissionMode),
|
|
493
|
+
timestamp: new Date(overview.lastTimestamp).getTime(),
|
|
494
|
+
gitBranch: overview.gitBranch,
|
|
495
|
+
lastAssistantText: overview.lastAssistantText
|
|
496
|
+
};
|
|
497
|
+
})
|
|
498
|
+
);
|
|
499
|
+
const sessionHeaders = headers.filter((h) => h !== null);
|
|
500
|
+
const branch = sessionHeaders[0]?.gitBranch ?? "";
|
|
501
|
+
const sessions = sessionHeaders.map((session) => ({
|
|
502
|
+
id: session.sessionId,
|
|
503
|
+
workspace,
|
|
504
|
+
status: "inactive",
|
|
505
|
+
mode: session.mode,
|
|
506
|
+
title: session.title,
|
|
507
|
+
timestamp: session.timestamp,
|
|
508
|
+
lastAssistantText: session.lastAssistantText
|
|
509
|
+
}));
|
|
510
|
+
return { sessions, branch };
|
|
511
|
+
}
|
|
512
|
+
async function findSessionFile(sessionId) {
|
|
513
|
+
const cached = sessionFileCache.get(sessionId);
|
|
514
|
+
if (cached) return cached;
|
|
515
|
+
const index = await getProjectIndex();
|
|
516
|
+
const targetFilename = `${sessionId}.jsonl`;
|
|
517
|
+
for (const [, projectDirName] of index) {
|
|
518
|
+
const projectPath = join(PROJECTS_DIR, projectDirName);
|
|
519
|
+
let entries;
|
|
520
|
+
try {
|
|
521
|
+
entries = await readdir(projectPath);
|
|
522
|
+
} catch {
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
if (entries.includes(targetFilename)) {
|
|
526
|
+
const filePath = join(projectPath, targetFilename);
|
|
527
|
+
sessionFileCache.set(sessionId, filePath);
|
|
528
|
+
return filePath;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
class ClaudeAgent {
|
|
534
|
+
brand = "cc";
|
|
535
|
+
async loadRepos(repoPaths) {
|
|
536
|
+
const index = await getProjectIndex();
|
|
537
|
+
const repos = await Promise.all(
|
|
538
|
+
repoPaths.map(async (repoPath) => {
|
|
539
|
+
const projectDirName = index.get(repoPath.toLowerCase());
|
|
540
|
+
if (!projectDirName) {
|
|
541
|
+
return { path: repoPath, branch: "HEAD", sessions: [] };
|
|
542
|
+
}
|
|
543
|
+
const { sessions, branch } = await readProjectSessions(projectDirName, repoPath);
|
|
544
|
+
return {
|
|
545
|
+
path: repoPath,
|
|
546
|
+
branch: branch || "HEAD",
|
|
547
|
+
sessions
|
|
548
|
+
};
|
|
549
|
+
})
|
|
550
|
+
);
|
|
551
|
+
const processes = await getAgentProcesses();
|
|
552
|
+
const activeWorkspaces = getWorkspacesWithAgent(processes, "claude");
|
|
553
|
+
markExternalSessions(repos.flatMap((r) => r.sessions), activeWorkspaces);
|
|
554
|
+
return repos;
|
|
555
|
+
}
|
|
556
|
+
async loadSession(id) {
|
|
557
|
+
const filePath = await findSessionFile(id);
|
|
558
|
+
if (!filePath) return null;
|
|
559
|
+
const records = await readAllRecords(filePath);
|
|
560
|
+
const firstUser = records.find((r) => r.type === "user");
|
|
561
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
562
|
+
for (const record of records) {
|
|
563
|
+
if (record.type === "user") {
|
|
564
|
+
for (const { toolUseId, isError } of getToolResults(record)) {
|
|
565
|
+
resultMap.set(toolUseId, !isError);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
const log = [];
|
|
570
|
+
for (const record of records) {
|
|
571
|
+
if (record.type === "user") {
|
|
572
|
+
const text = getUserText(record);
|
|
573
|
+
if (text && !isMetaMessage(record)) {
|
|
574
|
+
log.push({ type: "user", text, timestamp: record.timestamp });
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
const text = getAssistantText(record);
|
|
578
|
+
if (text) {
|
|
579
|
+
log.push({ type: "assistant", text, timestamp: record.timestamp });
|
|
580
|
+
}
|
|
581
|
+
for (const { id: toolId, name, input } of getToolUses(record)) {
|
|
582
|
+
log.push({
|
|
583
|
+
type: "tool_use",
|
|
584
|
+
tool: name,
|
|
585
|
+
args: new Map(Object.entries(input)),
|
|
586
|
+
success: resultMap.get(toolId) ?? true,
|
|
587
|
+
timestamp: record.timestamp
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const firstUserText = firstUser ? getUserText(firstUser) : null;
|
|
593
|
+
const title = firstUserText && !isMetaMessage(firstUser) ? firstLine(firstUserText) : id;
|
|
594
|
+
return {
|
|
595
|
+
id,
|
|
596
|
+
title,
|
|
597
|
+
log
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
let wellKnownAgents = [new ClaudeAgent(), new OpenCodeAgent()];
|
|
602
|
+
const HOME = homedir();
|
|
603
|
+
function toDisplayPath(path) {
|
|
604
|
+
if (path.toLowerCase().startsWith(HOME.toLowerCase())) {
|
|
605
|
+
return "~" + path.slice(HOME.length);
|
|
606
|
+
}
|
|
607
|
+
return path;
|
|
608
|
+
}
|
|
609
|
+
async function getAllRepos() {
|
|
610
|
+
const repoMap = /* @__PURE__ */ new Map();
|
|
611
|
+
const agentErrors = [];
|
|
612
|
+
for (const agent of wellKnownAgents) {
|
|
613
|
+
let agentRepos;
|
|
614
|
+
try {
|
|
615
|
+
agentRepos = await agent.loadRepos(REPO_PATHS);
|
|
616
|
+
} catch (error) {
|
|
617
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
618
|
+
agentErrors.push({ brand: agent.brand, message });
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
for (const repo of agentRepos) {
|
|
622
|
+
const key = repo.path.toLowerCase();
|
|
623
|
+
const existing = repoMap.get(key);
|
|
624
|
+
const brandedSessions = repo.sessions.map((s) => ({ ...s, mode: s.status == "inactive" ? null : s.mode, brand: agent.brand }));
|
|
625
|
+
if (existing) {
|
|
626
|
+
existing.sessions.push(...brandedSessions);
|
|
627
|
+
if (!existing.branch || existing.branch === "HEAD") {
|
|
628
|
+
existing.branch = repo.branch;
|
|
629
|
+
}
|
|
630
|
+
} else {
|
|
631
|
+
repoMap.set(key, {
|
|
632
|
+
path: repo.path,
|
|
633
|
+
branch: repo.branch,
|
|
634
|
+
sessions: brandedSessions,
|
|
635
|
+
errors: []
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
for (const repoPath of REPO_PATHS) {
|
|
641
|
+
const key = repoPath.toLowerCase();
|
|
642
|
+
if (!repoMap.has(key)) {
|
|
643
|
+
repoMap.set(key, {
|
|
644
|
+
path: repoPath,
|
|
645
|
+
branch: "",
|
|
646
|
+
sessions: [],
|
|
647
|
+
errors: []
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (agentErrors.length > 0) {
|
|
652
|
+
for (const repo of repoMap.values()) {
|
|
653
|
+
repo.errors.push(...agentErrors);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
const repos = [...repoMap.values()];
|
|
657
|
+
const allSessions = repos.flatMap((r) => r.sessions);
|
|
658
|
+
const order = updateActiveOrder(allSessions);
|
|
659
|
+
const activeIndex = new Map(order.map((id, i) => [id, i]));
|
|
660
|
+
for (const repo of repos) {
|
|
661
|
+
repo.sessions.sort((a, b) => {
|
|
662
|
+
const aActive = activeIndex.has(a.id);
|
|
663
|
+
const bActive = activeIndex.has(b.id);
|
|
664
|
+
if (aActive && !bActive) return -1;
|
|
665
|
+
if (!aActive && bActive) return 1;
|
|
666
|
+
if (aActive && bActive) {
|
|
667
|
+
return activeIndex.get(a.id) - activeIndex.get(b.id);
|
|
668
|
+
}
|
|
669
|
+
return b.timestamp - a.timestamp;
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
repos.sort((a, b) => {
|
|
673
|
+
const aTime = a.sessions[0]?.timestamp ?? 0;
|
|
674
|
+
const bTime = b.sessions[0]?.timestamp ?? 0;
|
|
675
|
+
return bTime - aTime;
|
|
676
|
+
});
|
|
677
|
+
return repos.map((repo) => ({
|
|
678
|
+
path: toDisplayPath(repo.path),
|
|
679
|
+
branch: repo.branch,
|
|
680
|
+
sessions: repo.sessions,
|
|
681
|
+
errors: repo.errors
|
|
682
|
+
}));
|
|
683
|
+
}
|
|
684
|
+
async function getAgentSession(id) {
|
|
685
|
+
const results = await Promise.allSettled(
|
|
686
|
+
wellKnownAgents.map((agent) => agent.loadSession(id))
|
|
687
|
+
);
|
|
688
|
+
const errors = [];
|
|
689
|
+
for (let i = 0; i < results.length; i++) {
|
|
690
|
+
const result = results[i];
|
|
691
|
+
if (result.status === "fulfilled" && result.value) {
|
|
692
|
+
return { ...result.value, brand: wellKnownAgents[i].brand };
|
|
693
|
+
}
|
|
694
|
+
if (result.status === "rejected") {
|
|
695
|
+
const message = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
696
|
+
errors.push({ brand: wellKnownAgents[i].brand, message });
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (errors.length > 0) {
|
|
700
|
+
const detail = errors.map((e) => `[${e.brand}] ${e.message}`).join("\n");
|
|
701
|
+
throw new Error(`Session not found. Agent errors:
|
|
702
|
+
${detail}`);
|
|
703
|
+
}
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export { getAgentSession as a, getAllRepos as g, init_remote_functions as i, query as q };
|
|
708
|
+
//# sourceMappingURL=agent-C7A3zEr3.js.map
|