chatroom-cli 1.34.1 → 1.36.0

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/index.js CHANGED
@@ -10503,7 +10503,7 @@ class PiRpcReader {
10503
10503
  var init_pi_rpc_reader = () => {};
10504
10504
 
10505
10505
  // src/infrastructure/services/remote-agents/pi/pi-agent-service.ts
10506
- var PI_COMMAND = "pi", DEFAULT_TRIGGER_PROMPT = "Please read your system prompt carefully and follow the Getting Started instructions.", PiAgentService;
10506
+ var PI_COMMAND = "pi", PiAgentService;
10507
10507
  var init_pi_agent_service = __esm(() => {
10508
10508
  init_base_cli_agent_service();
10509
10509
  init_pi_rpc_reader();
@@ -10549,8 +10549,7 @@ var init_pi_agent_service = __esm(() => {
10549
10549
  }
10550
10550
  }
10551
10551
  async spawn(options) {
10552
- const { systemPrompt, model } = options;
10553
- const prompt = options.prompt?.trim() ? options.prompt : DEFAULT_TRIGGER_PROMPT;
10552
+ const { prompt, systemPrompt, model } = options;
10554
10553
  const args = ["--mode", "rpc", "--no-session"];
10555
10554
  if (model) {
10556
10555
  args.push("--model", model);
@@ -11040,7 +11039,7 @@ var init_copilot_stream_reader = __esm(() => {
11040
11039
  });
11041
11040
 
11042
11041
  // src/infrastructure/services/remote-agents/copilot/copilot-agent-service.ts
11043
- var COPILOT_COMMAND = "copilot", DEFAULT_TRIGGER_PROMPT2 = "Please read your system prompt carefully and follow the Getting Started instructions.", CopilotAgentService;
11042
+ var COPILOT_COMMAND = "copilot", CopilotAgentService;
11044
11043
  var init_copilot_agent_service = __esm(() => {
11045
11044
  init_base_cli_agent_service();
11046
11045
  init_copilot_stream_reader();
@@ -11072,7 +11071,7 @@ var init_copilot_agent_service = __esm(() => {
11072
11071
  ];
11073
11072
  }
11074
11073
  async spawn(options) {
11075
- const prompt = options.prompt?.trim() ? options.prompt : DEFAULT_TRIGGER_PROMPT2;
11074
+ const { prompt } = options;
11076
11075
  const args = ["-p"];
11077
11076
  args.push("--stream", "on");
11078
11077
  if (options.model) {
@@ -11228,7 +11227,7 @@ class ClaudeStreamReader {
11228
11227
  var init_claude_stream_reader = () => {};
11229
11228
 
11230
11229
  // src/infrastructure/services/remote-agents/claude/claude-code-agent-service.ts
11231
- var DEFAULT_TRIGGER_PROMPT3 = "Please read your system prompt carefully and follow the Getting Started instructions.", CLAUDE_COMMAND = "claude", DEFAULT_MAX_TURNS = 200, ClaudeCodeAgentService;
11230
+ var CLAUDE_COMMAND = "claude", DEFAULT_MAX_TURNS = 200, ClaudeCodeAgentService;
11232
11231
  var init_claude_code_agent_service = __esm(() => {
11233
11232
  init_base_cli_agent_service();
11234
11233
  init_claude_stream_reader();
@@ -11249,8 +11248,7 @@ var init_claude_code_agent_service = __esm(() => {
11249
11248
  return ["claude-haiku-4-5", "claude-sonnet-4-6", "claude-opus-4-6"];
11250
11249
  }
11251
11250
  async spawn(options) {
11252
- const { systemPrompt, model } = options;
11253
- const prompt = options.prompt?.trim() ? options.prompt : DEFAULT_TRIGGER_PROMPT3;
11251
+ const { prompt, systemPrompt, model } = options;
11254
11252
  const args = ["-p", "--output-format", "stream-json", "--verbose"];
11255
11253
  args.push("--max-turns", String(DEFAULT_MAX_TURNS));
11256
11254
  if (model) {
@@ -11380,11 +11378,2333 @@ var init_claude = __esm(() => {
11380
11378
  init_claude_code_agent_service();
11381
11379
  });
11382
11380
 
11381
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/types.gen.js
11382
+ var init_types_gen = () => {};
11383
+
11384
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
11385
+ var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
11386
+ let lastEventId;
11387
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
11388
+ const createStream = async function* () {
11389
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
11390
+ let attempt = 0;
11391
+ const signal = options.signal ?? new AbortController().signal;
11392
+ while (true) {
11393
+ if (signal.aborted)
11394
+ break;
11395
+ attempt++;
11396
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
11397
+ if (lastEventId !== undefined) {
11398
+ headers.set("Last-Event-ID", lastEventId);
11399
+ }
11400
+ try {
11401
+ const response = await fetch(url, { ...options, headers, signal });
11402
+ if (!response.ok)
11403
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
11404
+ if (!response.body)
11405
+ throw new Error("No body in SSE response");
11406
+ const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
11407
+ let buffer = "";
11408
+ const abortHandler = () => {
11409
+ try {
11410
+ reader.cancel();
11411
+ } catch {}
11412
+ };
11413
+ signal.addEventListener("abort", abortHandler);
11414
+ try {
11415
+ while (true) {
11416
+ const { done, value } = await reader.read();
11417
+ if (done)
11418
+ break;
11419
+ buffer += value;
11420
+ const chunks = buffer.split(`
11421
+
11422
+ `);
11423
+ buffer = chunks.pop() ?? "";
11424
+ for (const chunk of chunks) {
11425
+ const lines = chunk.split(`
11426
+ `);
11427
+ const dataLines = [];
11428
+ let eventName;
11429
+ for (const line of lines) {
11430
+ if (line.startsWith("data:")) {
11431
+ dataLines.push(line.replace(/^data:\s*/, ""));
11432
+ } else if (line.startsWith("event:")) {
11433
+ eventName = line.replace(/^event:\s*/, "");
11434
+ } else if (line.startsWith("id:")) {
11435
+ lastEventId = line.replace(/^id:\s*/, "");
11436
+ } else if (line.startsWith("retry:")) {
11437
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
11438
+ if (!Number.isNaN(parsed)) {
11439
+ retryDelay = parsed;
11440
+ }
11441
+ }
11442
+ }
11443
+ let data;
11444
+ let parsedJson = false;
11445
+ if (dataLines.length) {
11446
+ const rawData = dataLines.join(`
11447
+ `);
11448
+ try {
11449
+ data = JSON.parse(rawData);
11450
+ parsedJson = true;
11451
+ } catch {
11452
+ data = rawData;
11453
+ }
11454
+ }
11455
+ if (parsedJson) {
11456
+ if (responseValidator) {
11457
+ await responseValidator(data);
11458
+ }
11459
+ if (responseTransformer) {
11460
+ data = await responseTransformer(data);
11461
+ }
11462
+ }
11463
+ onSseEvent?.({
11464
+ data,
11465
+ event: eventName,
11466
+ id: lastEventId,
11467
+ retry: retryDelay
11468
+ });
11469
+ if (dataLines.length) {
11470
+ yield data;
11471
+ }
11472
+ }
11473
+ }
11474
+ } finally {
11475
+ signal.removeEventListener("abort", abortHandler);
11476
+ reader.releaseLock();
11477
+ }
11478
+ break;
11479
+ } catch (error) {
11480
+ onSseError?.(error);
11481
+ if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
11482
+ break;
11483
+ }
11484
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
11485
+ await sleep(backoff);
11486
+ }
11487
+ }
11488
+ };
11489
+ const stream = createStream();
11490
+ return { stream };
11491
+ };
11492
+
11493
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/auth.gen.js
11494
+ var getAuthToken = async (auth, callback) => {
11495
+ const token = typeof callback === "function" ? await callback(auth) : callback;
11496
+ if (!token) {
11497
+ return;
11498
+ }
11499
+ if (auth.scheme === "bearer") {
11500
+ return `Bearer ${token}`;
11501
+ }
11502
+ if (auth.scheme === "basic") {
11503
+ return `Basic ${btoa(token)}`;
11504
+ }
11505
+ return token;
11506
+ };
11507
+
11508
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/bodySerializer.gen.js
11509
+ var jsonBodySerializer;
11510
+ var init_bodySerializer_gen = __esm(() => {
11511
+ jsonBodySerializer = {
11512
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
11513
+ };
11514
+ });
11515
+
11516
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/pathSerializer.gen.js
11517
+ var separatorArrayExplode = (style) => {
11518
+ switch (style) {
11519
+ case "label":
11520
+ return ".";
11521
+ case "matrix":
11522
+ return ";";
11523
+ case "simple":
11524
+ return ",";
11525
+ default:
11526
+ return "&";
11527
+ }
11528
+ }, separatorArrayNoExplode = (style) => {
11529
+ switch (style) {
11530
+ case "form":
11531
+ return ",";
11532
+ case "pipeDelimited":
11533
+ return "|";
11534
+ case "spaceDelimited":
11535
+ return "%20";
11536
+ default:
11537
+ return ",";
11538
+ }
11539
+ }, separatorObjectExplode = (style) => {
11540
+ switch (style) {
11541
+ case "label":
11542
+ return ".";
11543
+ case "matrix":
11544
+ return ";";
11545
+ case "simple":
11546
+ return ",";
11547
+ default:
11548
+ return "&";
11549
+ }
11550
+ }, serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
11551
+ if (!explode) {
11552
+ const joinedValues2 = (allowReserved ? value : value.map((v3) => encodeURIComponent(v3))).join(separatorArrayNoExplode(style));
11553
+ switch (style) {
11554
+ case "label":
11555
+ return `.${joinedValues2}`;
11556
+ case "matrix":
11557
+ return `;${name}=${joinedValues2}`;
11558
+ case "simple":
11559
+ return joinedValues2;
11560
+ default:
11561
+ return `${name}=${joinedValues2}`;
11562
+ }
11563
+ }
11564
+ const separator = separatorArrayExplode(style);
11565
+ const joinedValues = value.map((v3) => {
11566
+ if (style === "label" || style === "simple") {
11567
+ return allowReserved ? v3 : encodeURIComponent(v3);
11568
+ }
11569
+ return serializePrimitiveParam({
11570
+ allowReserved,
11571
+ name,
11572
+ value: v3
11573
+ });
11574
+ }).join(separator);
11575
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
11576
+ }, serializePrimitiveParam = ({ allowReserved, name, value }) => {
11577
+ if (value === undefined || value === null) {
11578
+ return "";
11579
+ }
11580
+ if (typeof value === "object") {
11581
+ throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
11582
+ }
11583
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
11584
+ }, serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
11585
+ if (value instanceof Date) {
11586
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
11587
+ }
11588
+ if (style !== "deepObject" && !explode) {
11589
+ let values = [];
11590
+ Object.entries(value).forEach(([key, v3]) => {
11591
+ values = [...values, key, allowReserved ? v3 : encodeURIComponent(v3)];
11592
+ });
11593
+ const joinedValues2 = values.join(",");
11594
+ switch (style) {
11595
+ case "form":
11596
+ return `${name}=${joinedValues2}`;
11597
+ case "label":
11598
+ return `.${joinedValues2}`;
11599
+ case "matrix":
11600
+ return `;${name}=${joinedValues2}`;
11601
+ default:
11602
+ return joinedValues2;
11603
+ }
11604
+ }
11605
+ const separator = separatorObjectExplode(style);
11606
+ const joinedValues = Object.entries(value).map(([key, v3]) => serializePrimitiveParam({
11607
+ allowReserved,
11608
+ name: style === "deepObject" ? `${name}[${key}]` : key,
11609
+ value: v3
11610
+ })).join(separator);
11611
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
11612
+ };
11613
+
11614
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
11615
+ var PATH_PARAM_RE, defaultPathSerializer = ({ path, url: _url }) => {
11616
+ let url = _url;
11617
+ const matches = _url.match(PATH_PARAM_RE);
11618
+ if (matches) {
11619
+ for (const match of matches) {
11620
+ let explode = false;
11621
+ let name = match.substring(1, match.length - 1);
11622
+ let style = "simple";
11623
+ if (name.endsWith("*")) {
11624
+ explode = true;
11625
+ name = name.substring(0, name.length - 1);
11626
+ }
11627
+ if (name.startsWith(".")) {
11628
+ name = name.substring(1);
11629
+ style = "label";
11630
+ } else if (name.startsWith(";")) {
11631
+ name = name.substring(1);
11632
+ style = "matrix";
11633
+ }
11634
+ const value = path[name];
11635
+ if (value === undefined || value === null) {
11636
+ continue;
11637
+ }
11638
+ if (Array.isArray(value)) {
11639
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
11640
+ continue;
11641
+ }
11642
+ if (typeof value === "object") {
11643
+ url = url.replace(match, serializeObjectParam({
11644
+ explode,
11645
+ name,
11646
+ style,
11647
+ value,
11648
+ valueOnly: true
11649
+ }));
11650
+ continue;
11651
+ }
11652
+ if (style === "matrix") {
11653
+ url = url.replace(match, `;${serializePrimitiveParam({
11654
+ name,
11655
+ value
11656
+ })}`);
11657
+ continue;
11658
+ }
11659
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
11660
+ url = url.replace(match, replaceValue);
11661
+ }
11662
+ }
11663
+ return url;
11664
+ }, getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
11665
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
11666
+ let url = (baseUrl ?? "") + pathUrl;
11667
+ if (path) {
11668
+ url = defaultPathSerializer({ path, url });
11669
+ }
11670
+ let search = query ? querySerializer(query) : "";
11671
+ if (search.startsWith("?")) {
11672
+ search = search.substring(1);
11673
+ }
11674
+ if (search) {
11675
+ url += `?${search}`;
11676
+ }
11677
+ return url;
11678
+ };
11679
+ var init_utils_gen = __esm(() => {
11680
+ PATH_PARAM_RE = /\{[^{}]+\}/g;
11681
+ });
11682
+
11683
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client/utils.gen.js
11684
+ class Interceptors {
11685
+ _fns;
11686
+ constructor() {
11687
+ this._fns = [];
11688
+ }
11689
+ clear() {
11690
+ this._fns = [];
11691
+ }
11692
+ getInterceptorIndex(id) {
11693
+ if (typeof id === "number") {
11694
+ return this._fns[id] ? id : -1;
11695
+ } else {
11696
+ return this._fns.indexOf(id);
11697
+ }
11698
+ }
11699
+ exists(id) {
11700
+ const index = this.getInterceptorIndex(id);
11701
+ return !!this._fns[index];
11702
+ }
11703
+ eject(id) {
11704
+ const index = this.getInterceptorIndex(id);
11705
+ if (this._fns[index]) {
11706
+ this._fns[index] = null;
11707
+ }
11708
+ }
11709
+ update(id, fn) {
11710
+ const index = this.getInterceptorIndex(id);
11711
+ if (this._fns[index]) {
11712
+ this._fns[index] = fn;
11713
+ return id;
11714
+ } else {
11715
+ return false;
11716
+ }
11717
+ }
11718
+ use(fn) {
11719
+ this._fns = [...this._fns, fn];
11720
+ return this._fns.length - 1;
11721
+ }
11722
+ }
11723
+ var createQuerySerializer = ({ allowReserved, array, object } = {}) => {
11724
+ const querySerializer = (queryParams) => {
11725
+ const search = [];
11726
+ if (queryParams && typeof queryParams === "object") {
11727
+ for (const name in queryParams) {
11728
+ const value = queryParams[name];
11729
+ if (value === undefined || value === null) {
11730
+ continue;
11731
+ }
11732
+ if (Array.isArray(value)) {
11733
+ const serializedArray = serializeArrayParam({
11734
+ allowReserved,
11735
+ explode: true,
11736
+ name,
11737
+ style: "form",
11738
+ value,
11739
+ ...array
11740
+ });
11741
+ if (serializedArray)
11742
+ search.push(serializedArray);
11743
+ } else if (typeof value === "object") {
11744
+ const serializedObject = serializeObjectParam({
11745
+ allowReserved,
11746
+ explode: true,
11747
+ name,
11748
+ style: "deepObject",
11749
+ value,
11750
+ ...object
11751
+ });
11752
+ if (serializedObject)
11753
+ search.push(serializedObject);
11754
+ } else {
11755
+ const serializedPrimitive = serializePrimitiveParam({
11756
+ allowReserved,
11757
+ name,
11758
+ value
11759
+ });
11760
+ if (serializedPrimitive)
11761
+ search.push(serializedPrimitive);
11762
+ }
11763
+ }
11764
+ }
11765
+ return search.join("&");
11766
+ };
11767
+ return querySerializer;
11768
+ }, getParseAs = (contentType) => {
11769
+ if (!contentType) {
11770
+ return "stream";
11771
+ }
11772
+ const cleanContent = contentType.split(";")[0]?.trim();
11773
+ if (!cleanContent) {
11774
+ return;
11775
+ }
11776
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
11777
+ return "json";
11778
+ }
11779
+ if (cleanContent === "multipart/form-data") {
11780
+ return "formData";
11781
+ }
11782
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
11783
+ return "blob";
11784
+ }
11785
+ if (cleanContent.startsWith("text/")) {
11786
+ return "text";
11787
+ }
11788
+ return;
11789
+ }, checkForExistence = (options, name) => {
11790
+ if (!name) {
11791
+ return false;
11792
+ }
11793
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
11794
+ return true;
11795
+ }
11796
+ return false;
11797
+ }, setAuthParams = async ({ security, ...options }) => {
11798
+ for (const auth of security) {
11799
+ if (checkForExistence(options, auth.name)) {
11800
+ continue;
11801
+ }
11802
+ const token = await getAuthToken(auth, options.auth);
11803
+ if (!token) {
11804
+ continue;
11805
+ }
11806
+ const name = auth.name ?? "Authorization";
11807
+ switch (auth.in) {
11808
+ case "query":
11809
+ if (!options.query) {
11810
+ options.query = {};
11811
+ }
11812
+ options.query[name] = token;
11813
+ break;
11814
+ case "cookie":
11815
+ options.headers.append("Cookie", `${name}=${token}`);
11816
+ break;
11817
+ case "header":
11818
+ default:
11819
+ options.headers.set(name, token);
11820
+ break;
11821
+ }
11822
+ }
11823
+ }, buildUrl = (options) => getUrl({
11824
+ baseUrl: options.baseUrl,
11825
+ path: options.path,
11826
+ query: options.query,
11827
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
11828
+ url: options.url
11829
+ }), mergeConfigs = (a, b) => {
11830
+ const config = { ...a, ...b };
11831
+ if (config.baseUrl?.endsWith("/")) {
11832
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
11833
+ }
11834
+ config.headers = mergeHeaders(a.headers, b.headers);
11835
+ return config;
11836
+ }, mergeHeaders = (...headers) => {
11837
+ const mergedHeaders = new Headers;
11838
+ for (const header of headers) {
11839
+ if (!header || typeof header !== "object") {
11840
+ continue;
11841
+ }
11842
+ const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
11843
+ for (const [key, value] of iterator) {
11844
+ if (value === null) {
11845
+ mergedHeaders.delete(key);
11846
+ } else if (Array.isArray(value)) {
11847
+ for (const v3 of value) {
11848
+ mergedHeaders.append(key, v3);
11849
+ }
11850
+ } else if (value !== undefined) {
11851
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
11852
+ }
11853
+ }
11854
+ }
11855
+ return mergedHeaders;
11856
+ }, createInterceptors = () => ({
11857
+ error: new Interceptors,
11858
+ request: new Interceptors,
11859
+ response: new Interceptors
11860
+ }), defaultQuerySerializer, defaultHeaders, createConfig = (override = {}) => ({
11861
+ ...jsonBodySerializer,
11862
+ headers: defaultHeaders,
11863
+ parseAs: "auto",
11864
+ querySerializer: defaultQuerySerializer,
11865
+ ...override
11866
+ });
11867
+ var init_utils_gen2 = __esm(() => {
11868
+ init_bodySerializer_gen();
11869
+ init_utils_gen();
11870
+ defaultQuerySerializer = createQuerySerializer({
11871
+ allowReserved: false,
11872
+ array: {
11873
+ explode: true,
11874
+ style: "form"
11875
+ },
11876
+ object: {
11877
+ explode: true,
11878
+ style: "deepObject"
11879
+ }
11880
+ });
11881
+ defaultHeaders = {
11882
+ "Content-Type": "application/json"
11883
+ };
11884
+ });
11885
+
11886
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client/client.gen.js
11887
+ var createClient = (config = {}) => {
11888
+ let _config = mergeConfigs(createConfig(), config);
11889
+ const getConfig = () => ({ ..._config });
11890
+ const setConfig = (config2) => {
11891
+ _config = mergeConfigs(_config, config2);
11892
+ return getConfig();
11893
+ };
11894
+ const interceptors = createInterceptors();
11895
+ const beforeRequest = async (options) => {
11896
+ const opts = {
11897
+ ..._config,
11898
+ ...options,
11899
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
11900
+ headers: mergeHeaders(_config.headers, options.headers),
11901
+ serializedBody: undefined
11902
+ };
11903
+ if (opts.security) {
11904
+ await setAuthParams({
11905
+ ...opts,
11906
+ security: opts.security
11907
+ });
11908
+ }
11909
+ if (opts.requestValidator) {
11910
+ await opts.requestValidator(opts);
11911
+ }
11912
+ if (opts.body && opts.bodySerializer) {
11913
+ opts.serializedBody = opts.bodySerializer(opts.body);
11914
+ }
11915
+ if (opts.serializedBody === undefined || opts.serializedBody === "") {
11916
+ opts.headers.delete("Content-Type");
11917
+ }
11918
+ const url = buildUrl(opts);
11919
+ return { opts, url };
11920
+ };
11921
+ const request = async (options) => {
11922
+ const { opts, url } = await beforeRequest(options);
11923
+ const requestInit = {
11924
+ redirect: "follow",
11925
+ ...opts,
11926
+ body: opts.serializedBody
11927
+ };
11928
+ let request2 = new Request(url, requestInit);
11929
+ for (const fn of interceptors.request._fns) {
11930
+ if (fn) {
11931
+ request2 = await fn(request2, opts);
11932
+ }
11933
+ }
11934
+ const _fetch = opts.fetch;
11935
+ let response = await _fetch(request2);
11936
+ for (const fn of interceptors.response._fns) {
11937
+ if (fn) {
11938
+ response = await fn(response, request2, opts);
11939
+ }
11940
+ }
11941
+ const result = {
11942
+ request: request2,
11943
+ response
11944
+ };
11945
+ if (response.ok) {
11946
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
11947
+ return opts.responseStyle === "data" ? {} : {
11948
+ data: {},
11949
+ ...result
11950
+ };
11951
+ }
11952
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
11953
+ let data;
11954
+ switch (parseAs) {
11955
+ case "arrayBuffer":
11956
+ case "blob":
11957
+ case "formData":
11958
+ case "json":
11959
+ case "text":
11960
+ data = await response[parseAs]();
11961
+ break;
11962
+ case "stream":
11963
+ return opts.responseStyle === "data" ? response.body : {
11964
+ data: response.body,
11965
+ ...result
11966
+ };
11967
+ }
11968
+ if (parseAs === "json") {
11969
+ if (opts.responseValidator) {
11970
+ await opts.responseValidator(data);
11971
+ }
11972
+ if (opts.responseTransformer) {
11973
+ data = await opts.responseTransformer(data);
11974
+ }
11975
+ }
11976
+ return opts.responseStyle === "data" ? data : {
11977
+ data,
11978
+ ...result
11979
+ };
11980
+ }
11981
+ const textError = await response.text();
11982
+ let jsonError;
11983
+ try {
11984
+ jsonError = JSON.parse(textError);
11985
+ } catch {}
11986
+ const error = jsonError ?? textError;
11987
+ let finalError = error;
11988
+ for (const fn of interceptors.error._fns) {
11989
+ if (fn) {
11990
+ finalError = await fn(error, response, request2, opts);
11991
+ }
11992
+ }
11993
+ finalError = finalError || {};
11994
+ if (opts.throwOnError) {
11995
+ throw finalError;
11996
+ }
11997
+ return opts.responseStyle === "data" ? undefined : {
11998
+ error: finalError,
11999
+ ...result
12000
+ };
12001
+ };
12002
+ const makeMethod = (method) => {
12003
+ const fn = (options) => request({ ...options, method });
12004
+ fn.sse = async (options) => {
12005
+ const { opts, url } = await beforeRequest(options);
12006
+ return createSseClient({
12007
+ ...opts,
12008
+ body: opts.body,
12009
+ headers: opts.headers,
12010
+ method,
12011
+ url
12012
+ });
12013
+ };
12014
+ return fn;
12015
+ };
12016
+ return {
12017
+ buildUrl,
12018
+ connect: makeMethod("CONNECT"),
12019
+ delete: makeMethod("DELETE"),
12020
+ get: makeMethod("GET"),
12021
+ getConfig,
12022
+ head: makeMethod("HEAD"),
12023
+ interceptors,
12024
+ options: makeMethod("OPTIONS"),
12025
+ patch: makeMethod("PATCH"),
12026
+ post: makeMethod("POST"),
12027
+ put: makeMethod("PUT"),
12028
+ request,
12029
+ setConfig,
12030
+ trace: makeMethod("TRACE")
12031
+ };
12032
+ };
12033
+ var init_client_gen = __esm(() => {
12034
+ init_utils_gen2();
12035
+ });
12036
+
12037
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/params.gen.js
12038
+ var extraPrefixesMap, extraPrefixes;
12039
+ var init_params_gen = __esm(() => {
12040
+ extraPrefixesMap = {
12041
+ $body_: "body",
12042
+ $headers_: "headers",
12043
+ $path_: "path",
12044
+ $query_: "query"
12045
+ };
12046
+ extraPrefixes = Object.entries(extraPrefixesMap);
12047
+ });
12048
+
12049
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client/index.js
12050
+ var init_client3 = __esm(() => {
12051
+ init_bodySerializer_gen();
12052
+ init_params_gen();
12053
+ init_client_gen();
12054
+ init_utils_gen2();
12055
+ });
12056
+
12057
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client.gen.js
12058
+ var client2;
12059
+ var init_client_gen2 = __esm(() => {
12060
+ init_client3();
12061
+ client2 = createClient(createConfig({
12062
+ baseUrl: "http://localhost:4096"
12063
+ }));
12064
+ });
12065
+
12066
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/sdk.gen.js
12067
+ class _HeyApiClient {
12068
+ _client = client2;
12069
+ constructor(args) {
12070
+ if (args?.client) {
12071
+ this._client = args.client;
12072
+ }
12073
+ }
12074
+ }
12075
+ var Global, Project, Pty, Config, Tool, Instance, Path, Vcs, Session, Command2, Oauth, Provider, Find, File, App, Auth, Mcp, Lsp, Formatter, Control, Tui, Event, OpencodeClient;
12076
+ var init_sdk_gen = __esm(() => {
12077
+ init_client_gen2();
12078
+ Global = class Global extends _HeyApiClient {
12079
+ event(options) {
12080
+ return (options?.client ?? this._client).get.sse({
12081
+ url: "/global/event",
12082
+ ...options
12083
+ });
12084
+ }
12085
+ };
12086
+ Project = class Project extends _HeyApiClient {
12087
+ list(options) {
12088
+ return (options?.client ?? this._client).get({
12089
+ url: "/project",
12090
+ ...options
12091
+ });
12092
+ }
12093
+ current(options) {
12094
+ return (options?.client ?? this._client).get({
12095
+ url: "/project/current",
12096
+ ...options
12097
+ });
12098
+ }
12099
+ };
12100
+ Pty = class Pty extends _HeyApiClient {
12101
+ list(options) {
12102
+ return (options?.client ?? this._client).get({
12103
+ url: "/pty",
12104
+ ...options
12105
+ });
12106
+ }
12107
+ create(options) {
12108
+ return (options?.client ?? this._client).post({
12109
+ url: "/pty",
12110
+ ...options,
12111
+ headers: {
12112
+ "Content-Type": "application/json",
12113
+ ...options?.headers
12114
+ }
12115
+ });
12116
+ }
12117
+ remove(options) {
12118
+ return (options.client ?? this._client).delete({
12119
+ url: "/pty/{id}",
12120
+ ...options
12121
+ });
12122
+ }
12123
+ get(options) {
12124
+ return (options.client ?? this._client).get({
12125
+ url: "/pty/{id}",
12126
+ ...options
12127
+ });
12128
+ }
12129
+ update(options) {
12130
+ return (options.client ?? this._client).put({
12131
+ url: "/pty/{id}",
12132
+ ...options,
12133
+ headers: {
12134
+ "Content-Type": "application/json",
12135
+ ...options.headers
12136
+ }
12137
+ });
12138
+ }
12139
+ connect(options) {
12140
+ return (options.client ?? this._client).get({
12141
+ url: "/pty/{id}/connect",
12142
+ ...options
12143
+ });
12144
+ }
12145
+ };
12146
+ Config = class Config extends _HeyApiClient {
12147
+ get(options) {
12148
+ return (options?.client ?? this._client).get({
12149
+ url: "/config",
12150
+ ...options
12151
+ });
12152
+ }
12153
+ update(options) {
12154
+ return (options?.client ?? this._client).patch({
12155
+ url: "/config",
12156
+ ...options,
12157
+ headers: {
12158
+ "Content-Type": "application/json",
12159
+ ...options?.headers
12160
+ }
12161
+ });
12162
+ }
12163
+ providers(options) {
12164
+ return (options?.client ?? this._client).get({
12165
+ url: "/config/providers",
12166
+ ...options
12167
+ });
12168
+ }
12169
+ };
12170
+ Tool = class Tool extends _HeyApiClient {
12171
+ ids(options) {
12172
+ return (options?.client ?? this._client).get({
12173
+ url: "/experimental/tool/ids",
12174
+ ...options
12175
+ });
12176
+ }
12177
+ list(options) {
12178
+ return (options.client ?? this._client).get({
12179
+ url: "/experimental/tool",
12180
+ ...options
12181
+ });
12182
+ }
12183
+ };
12184
+ Instance = class Instance extends _HeyApiClient {
12185
+ dispose(options) {
12186
+ return (options?.client ?? this._client).post({
12187
+ url: "/instance/dispose",
12188
+ ...options
12189
+ });
12190
+ }
12191
+ };
12192
+ Path = class Path extends _HeyApiClient {
12193
+ get(options) {
12194
+ return (options?.client ?? this._client).get({
12195
+ url: "/path",
12196
+ ...options
12197
+ });
12198
+ }
12199
+ };
12200
+ Vcs = class Vcs extends _HeyApiClient {
12201
+ get(options) {
12202
+ return (options?.client ?? this._client).get({
12203
+ url: "/vcs",
12204
+ ...options
12205
+ });
12206
+ }
12207
+ };
12208
+ Session = class Session extends _HeyApiClient {
12209
+ list(options) {
12210
+ return (options?.client ?? this._client).get({
12211
+ url: "/session",
12212
+ ...options
12213
+ });
12214
+ }
12215
+ create(options) {
12216
+ return (options?.client ?? this._client).post({
12217
+ url: "/session",
12218
+ ...options,
12219
+ headers: {
12220
+ "Content-Type": "application/json",
12221
+ ...options?.headers
12222
+ }
12223
+ });
12224
+ }
12225
+ status(options) {
12226
+ return (options?.client ?? this._client).get({
12227
+ url: "/session/status",
12228
+ ...options
12229
+ });
12230
+ }
12231
+ delete(options) {
12232
+ return (options.client ?? this._client).delete({
12233
+ url: "/session/{id}",
12234
+ ...options
12235
+ });
12236
+ }
12237
+ get(options) {
12238
+ return (options.client ?? this._client).get({
12239
+ url: "/session/{id}",
12240
+ ...options
12241
+ });
12242
+ }
12243
+ update(options) {
12244
+ return (options.client ?? this._client).patch({
12245
+ url: "/session/{id}",
12246
+ ...options,
12247
+ headers: {
12248
+ "Content-Type": "application/json",
12249
+ ...options.headers
12250
+ }
12251
+ });
12252
+ }
12253
+ children(options) {
12254
+ return (options.client ?? this._client).get({
12255
+ url: "/session/{id}/children",
12256
+ ...options
12257
+ });
12258
+ }
12259
+ todo(options) {
12260
+ return (options.client ?? this._client).get({
12261
+ url: "/session/{id}/todo",
12262
+ ...options
12263
+ });
12264
+ }
12265
+ init(options) {
12266
+ return (options.client ?? this._client).post({
12267
+ url: "/session/{id}/init",
12268
+ ...options,
12269
+ headers: {
12270
+ "Content-Type": "application/json",
12271
+ ...options.headers
12272
+ }
12273
+ });
12274
+ }
12275
+ fork(options) {
12276
+ return (options.client ?? this._client).post({
12277
+ url: "/session/{id}/fork",
12278
+ ...options,
12279
+ headers: {
12280
+ "Content-Type": "application/json",
12281
+ ...options.headers
12282
+ }
12283
+ });
12284
+ }
12285
+ abort(options) {
12286
+ return (options.client ?? this._client).post({
12287
+ url: "/session/{id}/abort",
12288
+ ...options
12289
+ });
12290
+ }
12291
+ unshare(options) {
12292
+ return (options.client ?? this._client).delete({
12293
+ url: "/session/{id}/share",
12294
+ ...options
12295
+ });
12296
+ }
12297
+ share(options) {
12298
+ return (options.client ?? this._client).post({
12299
+ url: "/session/{id}/share",
12300
+ ...options
12301
+ });
12302
+ }
12303
+ diff(options) {
12304
+ return (options.client ?? this._client).get({
12305
+ url: "/session/{id}/diff",
12306
+ ...options
12307
+ });
12308
+ }
12309
+ summarize(options) {
12310
+ return (options.client ?? this._client).post({
12311
+ url: "/session/{id}/summarize",
12312
+ ...options,
12313
+ headers: {
12314
+ "Content-Type": "application/json",
12315
+ ...options.headers
12316
+ }
12317
+ });
12318
+ }
12319
+ messages(options) {
12320
+ return (options.client ?? this._client).get({
12321
+ url: "/session/{id}/message",
12322
+ ...options
12323
+ });
12324
+ }
12325
+ prompt(options) {
12326
+ return (options.client ?? this._client).post({
12327
+ url: "/session/{id}/message",
12328
+ ...options,
12329
+ headers: {
12330
+ "Content-Type": "application/json",
12331
+ ...options.headers
12332
+ }
12333
+ });
12334
+ }
12335
+ message(options) {
12336
+ return (options.client ?? this._client).get({
12337
+ url: "/session/{id}/message/{messageID}",
12338
+ ...options
12339
+ });
12340
+ }
12341
+ promptAsync(options) {
12342
+ return (options.client ?? this._client).post({
12343
+ url: "/session/{id}/prompt_async",
12344
+ ...options,
12345
+ headers: {
12346
+ "Content-Type": "application/json",
12347
+ ...options.headers
12348
+ }
12349
+ });
12350
+ }
12351
+ command(options) {
12352
+ return (options.client ?? this._client).post({
12353
+ url: "/session/{id}/command",
12354
+ ...options,
12355
+ headers: {
12356
+ "Content-Type": "application/json",
12357
+ ...options.headers
12358
+ }
12359
+ });
12360
+ }
12361
+ shell(options) {
12362
+ return (options.client ?? this._client).post({
12363
+ url: "/session/{id}/shell",
12364
+ ...options,
12365
+ headers: {
12366
+ "Content-Type": "application/json",
12367
+ ...options.headers
12368
+ }
12369
+ });
12370
+ }
12371
+ revert(options) {
12372
+ return (options.client ?? this._client).post({
12373
+ url: "/session/{id}/revert",
12374
+ ...options,
12375
+ headers: {
12376
+ "Content-Type": "application/json",
12377
+ ...options.headers
12378
+ }
12379
+ });
12380
+ }
12381
+ unrevert(options) {
12382
+ return (options.client ?? this._client).post({
12383
+ url: "/session/{id}/unrevert",
12384
+ ...options
12385
+ });
12386
+ }
12387
+ };
12388
+ Command2 = class Command2 extends _HeyApiClient {
12389
+ list(options) {
12390
+ return (options?.client ?? this._client).get({
12391
+ url: "/command",
12392
+ ...options
12393
+ });
12394
+ }
12395
+ };
12396
+ Oauth = class Oauth extends _HeyApiClient {
12397
+ authorize(options) {
12398
+ return (options.client ?? this._client).post({
12399
+ url: "/provider/{id}/oauth/authorize",
12400
+ ...options,
12401
+ headers: {
12402
+ "Content-Type": "application/json",
12403
+ ...options.headers
12404
+ }
12405
+ });
12406
+ }
12407
+ callback(options) {
12408
+ return (options.client ?? this._client).post({
12409
+ url: "/provider/{id}/oauth/callback",
12410
+ ...options,
12411
+ headers: {
12412
+ "Content-Type": "application/json",
12413
+ ...options.headers
12414
+ }
12415
+ });
12416
+ }
12417
+ };
12418
+ Provider = class Provider extends _HeyApiClient {
12419
+ list(options) {
12420
+ return (options?.client ?? this._client).get({
12421
+ url: "/provider",
12422
+ ...options
12423
+ });
12424
+ }
12425
+ auth(options) {
12426
+ return (options?.client ?? this._client).get({
12427
+ url: "/provider/auth",
12428
+ ...options
12429
+ });
12430
+ }
12431
+ oauth = new Oauth({ client: this._client });
12432
+ };
12433
+ Find = class Find extends _HeyApiClient {
12434
+ text(options) {
12435
+ return (options.client ?? this._client).get({
12436
+ url: "/find",
12437
+ ...options
12438
+ });
12439
+ }
12440
+ files(options) {
12441
+ return (options.client ?? this._client).get({
12442
+ url: "/find/file",
12443
+ ...options
12444
+ });
12445
+ }
12446
+ symbols(options) {
12447
+ return (options.client ?? this._client).get({
12448
+ url: "/find/symbol",
12449
+ ...options
12450
+ });
12451
+ }
12452
+ };
12453
+ File = class File extends _HeyApiClient {
12454
+ list(options) {
12455
+ return (options.client ?? this._client).get({
12456
+ url: "/file",
12457
+ ...options
12458
+ });
12459
+ }
12460
+ read(options) {
12461
+ return (options.client ?? this._client).get({
12462
+ url: "/file/content",
12463
+ ...options
12464
+ });
12465
+ }
12466
+ status(options) {
12467
+ return (options?.client ?? this._client).get({
12468
+ url: "/file/status",
12469
+ ...options
12470
+ });
12471
+ }
12472
+ };
12473
+ App = class App extends _HeyApiClient {
12474
+ log(options) {
12475
+ return (options?.client ?? this._client).post({
12476
+ url: "/log",
12477
+ ...options,
12478
+ headers: {
12479
+ "Content-Type": "application/json",
12480
+ ...options?.headers
12481
+ }
12482
+ });
12483
+ }
12484
+ agents(options) {
12485
+ return (options?.client ?? this._client).get({
12486
+ url: "/agent",
12487
+ ...options
12488
+ });
12489
+ }
12490
+ };
12491
+ Auth = class Auth extends _HeyApiClient {
12492
+ remove(options) {
12493
+ return (options.client ?? this._client).delete({
12494
+ url: "/mcp/{name}/auth",
12495
+ ...options
12496
+ });
12497
+ }
12498
+ start(options) {
12499
+ return (options.client ?? this._client).post({
12500
+ url: "/mcp/{name}/auth",
12501
+ ...options
12502
+ });
12503
+ }
12504
+ callback(options) {
12505
+ return (options.client ?? this._client).post({
12506
+ url: "/mcp/{name}/auth/callback",
12507
+ ...options,
12508
+ headers: {
12509
+ "Content-Type": "application/json",
12510
+ ...options.headers
12511
+ }
12512
+ });
12513
+ }
12514
+ authenticate(options) {
12515
+ return (options.client ?? this._client).post({
12516
+ url: "/mcp/{name}/auth/authenticate",
12517
+ ...options
12518
+ });
12519
+ }
12520
+ set(options) {
12521
+ return (options.client ?? this._client).put({
12522
+ url: "/auth/{id}",
12523
+ ...options,
12524
+ headers: {
12525
+ "Content-Type": "application/json",
12526
+ ...options.headers
12527
+ }
12528
+ });
12529
+ }
12530
+ };
12531
+ Mcp = class Mcp extends _HeyApiClient {
12532
+ status(options) {
12533
+ return (options?.client ?? this._client).get({
12534
+ url: "/mcp",
12535
+ ...options
12536
+ });
12537
+ }
12538
+ add(options) {
12539
+ return (options?.client ?? this._client).post({
12540
+ url: "/mcp",
12541
+ ...options,
12542
+ headers: {
12543
+ "Content-Type": "application/json",
12544
+ ...options?.headers
12545
+ }
12546
+ });
12547
+ }
12548
+ connect(options) {
12549
+ return (options.client ?? this._client).post({
12550
+ url: "/mcp/{name}/connect",
12551
+ ...options
12552
+ });
12553
+ }
12554
+ disconnect(options) {
12555
+ return (options.client ?? this._client).post({
12556
+ url: "/mcp/{name}/disconnect",
12557
+ ...options
12558
+ });
12559
+ }
12560
+ auth = new Auth({ client: this._client });
12561
+ };
12562
+ Lsp = class Lsp extends _HeyApiClient {
12563
+ status(options) {
12564
+ return (options?.client ?? this._client).get({
12565
+ url: "/lsp",
12566
+ ...options
12567
+ });
12568
+ }
12569
+ };
12570
+ Formatter = class Formatter extends _HeyApiClient {
12571
+ status(options) {
12572
+ return (options?.client ?? this._client).get({
12573
+ url: "/formatter",
12574
+ ...options
12575
+ });
12576
+ }
12577
+ };
12578
+ Control = class Control extends _HeyApiClient {
12579
+ next(options) {
12580
+ return (options?.client ?? this._client).get({
12581
+ url: "/tui/control/next",
12582
+ ...options
12583
+ });
12584
+ }
12585
+ response(options) {
12586
+ return (options?.client ?? this._client).post({
12587
+ url: "/tui/control/response",
12588
+ ...options,
12589
+ headers: {
12590
+ "Content-Type": "application/json",
12591
+ ...options?.headers
12592
+ }
12593
+ });
12594
+ }
12595
+ };
12596
+ Tui = class Tui extends _HeyApiClient {
12597
+ appendPrompt(options) {
12598
+ return (options?.client ?? this._client).post({
12599
+ url: "/tui/append-prompt",
12600
+ ...options,
12601
+ headers: {
12602
+ "Content-Type": "application/json",
12603
+ ...options?.headers
12604
+ }
12605
+ });
12606
+ }
12607
+ openHelp(options) {
12608
+ return (options?.client ?? this._client).post({
12609
+ url: "/tui/open-help",
12610
+ ...options
12611
+ });
12612
+ }
12613
+ openSessions(options) {
12614
+ return (options?.client ?? this._client).post({
12615
+ url: "/tui/open-sessions",
12616
+ ...options
12617
+ });
12618
+ }
12619
+ openThemes(options) {
12620
+ return (options?.client ?? this._client).post({
12621
+ url: "/tui/open-themes",
12622
+ ...options
12623
+ });
12624
+ }
12625
+ openModels(options) {
12626
+ return (options?.client ?? this._client).post({
12627
+ url: "/tui/open-models",
12628
+ ...options
12629
+ });
12630
+ }
12631
+ submitPrompt(options) {
12632
+ return (options?.client ?? this._client).post({
12633
+ url: "/tui/submit-prompt",
12634
+ ...options
12635
+ });
12636
+ }
12637
+ clearPrompt(options) {
12638
+ return (options?.client ?? this._client).post({
12639
+ url: "/tui/clear-prompt",
12640
+ ...options
12641
+ });
12642
+ }
12643
+ executeCommand(options) {
12644
+ return (options?.client ?? this._client).post({
12645
+ url: "/tui/execute-command",
12646
+ ...options,
12647
+ headers: {
12648
+ "Content-Type": "application/json",
12649
+ ...options?.headers
12650
+ }
12651
+ });
12652
+ }
12653
+ showToast(options) {
12654
+ return (options?.client ?? this._client).post({
12655
+ url: "/tui/show-toast",
12656
+ ...options,
12657
+ headers: {
12658
+ "Content-Type": "application/json",
12659
+ ...options?.headers
12660
+ }
12661
+ });
12662
+ }
12663
+ publish(options) {
12664
+ return (options?.client ?? this._client).post({
12665
+ url: "/tui/publish",
12666
+ ...options,
12667
+ headers: {
12668
+ "Content-Type": "application/json",
12669
+ ...options?.headers
12670
+ }
12671
+ });
12672
+ }
12673
+ control = new Control({ client: this._client });
12674
+ };
12675
+ Event = class Event extends _HeyApiClient {
12676
+ subscribe(options) {
12677
+ return (options?.client ?? this._client).get.sse({
12678
+ url: "/event",
12679
+ ...options
12680
+ });
12681
+ }
12682
+ };
12683
+ OpencodeClient = class OpencodeClient extends _HeyApiClient {
12684
+ postSessionIdPermissionsPermissionId(options) {
12685
+ return (options.client ?? this._client).post({
12686
+ url: "/session/{id}/permissions/{permissionID}",
12687
+ ...options,
12688
+ headers: {
12689
+ "Content-Type": "application/json",
12690
+ ...options.headers
12691
+ }
12692
+ });
12693
+ }
12694
+ global = new Global({ client: this._client });
12695
+ project = new Project({ client: this._client });
12696
+ pty = new Pty({ client: this._client });
12697
+ config = new Config({ client: this._client });
12698
+ tool = new Tool({ client: this._client });
12699
+ instance = new Instance({ client: this._client });
12700
+ path = new Path({ client: this._client });
12701
+ vcs = new Vcs({ client: this._client });
12702
+ session = new Session({ client: this._client });
12703
+ command = new Command2({ client: this._client });
12704
+ provider = new Provider({ client: this._client });
12705
+ find = new Find({ client: this._client });
12706
+ file = new File({ client: this._client });
12707
+ app = new App({ client: this._client });
12708
+ mcp = new Mcp({ client: this._client });
12709
+ lsp = new Lsp({ client: this._client });
12710
+ formatter = new Formatter({ client: this._client });
12711
+ tui = new Tui({ client: this._client });
12712
+ auth = new Auth({ client: this._client });
12713
+ event = new Event({ client: this._client });
12714
+ };
12715
+ });
12716
+
12717
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/client.js
12718
+ function pick(value, fallback) {
12719
+ if (!value)
12720
+ return;
12721
+ if (!fallback)
12722
+ return value;
12723
+ if (value === fallback)
12724
+ return fallback;
12725
+ if (value === encodeURIComponent(fallback))
12726
+ return fallback;
12727
+ return value;
12728
+ }
12729
+ function rewrite(request, directory) {
12730
+ if (request.method !== "GET" && request.method !== "HEAD")
12731
+ return request;
12732
+ const value = pick(request.headers.get("x-opencode-directory"), directory);
12733
+ if (!value)
12734
+ return request;
12735
+ const url = new URL(request.url);
12736
+ if (!url.searchParams.has("directory")) {
12737
+ url.searchParams.set("directory", value);
12738
+ }
12739
+ const next = new Request(url, request);
12740
+ next.headers.delete("x-opencode-directory");
12741
+ return next;
12742
+ }
12743
+ function createOpencodeClient(config) {
12744
+ if (!config?.fetch) {
12745
+ const customFetch = (req) => {
12746
+ req.timeout = false;
12747
+ return fetch(req);
12748
+ };
12749
+ config = {
12750
+ ...config,
12751
+ fetch: customFetch
12752
+ };
12753
+ }
12754
+ if (config?.directory) {
12755
+ config.headers = {
12756
+ ...config.headers,
12757
+ "x-opencode-directory": encodeURIComponent(config.directory)
12758
+ };
12759
+ }
12760
+ const client3 = createClient(config);
12761
+ client3.interceptors.request.use((request) => rewrite(request, config?.directory));
12762
+ return new OpencodeClient({ client: client3 });
12763
+ }
12764
+ var init_client4 = __esm(() => {
12765
+ init_client_gen();
12766
+ init_sdk_gen();
12767
+ init_types_gen();
12768
+ });
12769
+
12770
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
12771
+ var require_windows = __commonJS((exports, module) => {
12772
+ module.exports = isexe;
12773
+ isexe.sync = sync;
12774
+ var fs = __require("fs");
12775
+ function checkPathExt(path, options) {
12776
+ var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
12777
+ if (!pathext) {
12778
+ return true;
12779
+ }
12780
+ pathext = pathext.split(";");
12781
+ if (pathext.indexOf("") !== -1) {
12782
+ return true;
12783
+ }
12784
+ for (var i2 = 0;i2 < pathext.length; i2++) {
12785
+ var p = pathext[i2].toLowerCase();
12786
+ if (p && path.substr(-p.length).toLowerCase() === p) {
12787
+ return true;
12788
+ }
12789
+ }
12790
+ return false;
12791
+ }
12792
+ function checkStat(stat, path, options) {
12793
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
12794
+ return false;
12795
+ }
12796
+ return checkPathExt(path, options);
12797
+ }
12798
+ function isexe(path, options, cb) {
12799
+ fs.stat(path, function(er, stat) {
12800
+ cb(er, er ? false : checkStat(stat, path, options));
12801
+ });
12802
+ }
12803
+ function sync(path, options) {
12804
+ return checkStat(fs.statSync(path), path, options);
12805
+ }
12806
+ });
12807
+
12808
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
12809
+ var require_mode = __commonJS((exports, module) => {
12810
+ module.exports = isexe;
12811
+ isexe.sync = sync;
12812
+ var fs = __require("fs");
12813
+ function isexe(path, options, cb) {
12814
+ fs.stat(path, function(er, stat) {
12815
+ cb(er, er ? false : checkStat(stat, options));
12816
+ });
12817
+ }
12818
+ function sync(path, options) {
12819
+ return checkStat(fs.statSync(path), options);
12820
+ }
12821
+ function checkStat(stat, options) {
12822
+ return stat.isFile() && checkMode(stat, options);
12823
+ }
12824
+ function checkMode(stat, options) {
12825
+ var mod = stat.mode;
12826
+ var uid = stat.uid;
12827
+ var gid = stat.gid;
12828
+ var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
12829
+ var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
12830
+ var u = parseInt("100", 8);
12831
+ var g = parseInt("010", 8);
12832
+ var o = parseInt("001", 8);
12833
+ var ug = u | g;
12834
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
12835
+ return ret;
12836
+ }
12837
+ });
12838
+
12839
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
12840
+ var require_isexe = __commonJS((exports, module) => {
12841
+ var fs = __require("fs");
12842
+ var core;
12843
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
12844
+ core = require_windows();
12845
+ } else {
12846
+ core = require_mode();
12847
+ }
12848
+ module.exports = isexe;
12849
+ isexe.sync = sync;
12850
+ function isexe(path, options, cb) {
12851
+ if (typeof options === "function") {
12852
+ cb = options;
12853
+ options = {};
12854
+ }
12855
+ if (!cb) {
12856
+ if (typeof Promise !== "function") {
12857
+ throw new TypeError("callback not provided");
12858
+ }
12859
+ return new Promise(function(resolve, reject) {
12860
+ isexe(path, options || {}, function(er, is) {
12861
+ if (er) {
12862
+ reject(er);
12863
+ } else {
12864
+ resolve(is);
12865
+ }
12866
+ });
12867
+ });
12868
+ }
12869
+ core(path, options || {}, function(er, is) {
12870
+ if (er) {
12871
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
12872
+ er = null;
12873
+ is = false;
12874
+ }
12875
+ }
12876
+ cb(er, is);
12877
+ });
12878
+ }
12879
+ function sync(path, options) {
12880
+ try {
12881
+ return core.sync(path, options || {});
12882
+ } catch (er) {
12883
+ if (options && options.ignoreErrors || er.code === "EACCES") {
12884
+ return false;
12885
+ } else {
12886
+ throw er;
12887
+ }
12888
+ }
12889
+ }
12890
+ });
12891
+
12892
+ // ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
12893
+ var require_which = __commonJS((exports, module) => {
12894
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
12895
+ var path = __require("path");
12896
+ var COLON = isWindows ? ";" : ":";
12897
+ var isexe = require_isexe();
12898
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
12899
+ var getPathInfo = (cmd, opt) => {
12900
+ const colon = opt.colon || COLON;
12901
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
12902
+ ...isWindows ? [process.cwd()] : [],
12903
+ ...(opt.path || process.env.PATH || "").split(colon)
12904
+ ];
12905
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
12906
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
12907
+ if (isWindows) {
12908
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
12909
+ pathExt.unshift("");
12910
+ }
12911
+ return {
12912
+ pathEnv,
12913
+ pathExt,
12914
+ pathExtExe
12915
+ };
12916
+ };
12917
+ var which = (cmd, opt, cb) => {
12918
+ if (typeof opt === "function") {
12919
+ cb = opt;
12920
+ opt = {};
12921
+ }
12922
+ if (!opt)
12923
+ opt = {};
12924
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
12925
+ const found = [];
12926
+ const step = (i2) => new Promise((resolve, reject) => {
12927
+ if (i2 === pathEnv.length)
12928
+ return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
12929
+ const ppRaw = pathEnv[i2];
12930
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12931
+ const pCmd = path.join(pathPart, cmd);
12932
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12933
+ resolve(subStep(p, i2, 0));
12934
+ });
12935
+ const subStep = (p, i2, ii) => new Promise((resolve, reject) => {
12936
+ if (ii === pathExt.length)
12937
+ return resolve(step(i2 + 1));
12938
+ const ext = pathExt[ii];
12939
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
12940
+ if (!er && is) {
12941
+ if (opt.all)
12942
+ found.push(p + ext);
12943
+ else
12944
+ return resolve(p + ext);
12945
+ }
12946
+ return resolve(subStep(p, i2, ii + 1));
12947
+ });
12948
+ });
12949
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
12950
+ };
12951
+ var whichSync = (cmd, opt) => {
12952
+ opt = opt || {};
12953
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
12954
+ const found = [];
12955
+ for (let i2 = 0;i2 < pathEnv.length; i2++) {
12956
+ const ppRaw = pathEnv[i2];
12957
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12958
+ const pCmd = path.join(pathPart, cmd);
12959
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12960
+ for (let j = 0;j < pathExt.length; j++) {
12961
+ const cur = p + pathExt[j];
12962
+ try {
12963
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
12964
+ if (is) {
12965
+ if (opt.all)
12966
+ found.push(cur);
12967
+ else
12968
+ return cur;
12969
+ }
12970
+ } catch (ex) {}
12971
+ }
12972
+ }
12973
+ if (opt.all && found.length)
12974
+ return found;
12975
+ if (opt.nothrow)
12976
+ return null;
12977
+ throw getNotFoundError(cmd);
12978
+ };
12979
+ module.exports = which;
12980
+ which.sync = whichSync;
12981
+ });
12982
+
12983
+ // ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
12984
+ var require_path_key = __commonJS((exports, module) => {
12985
+ var pathKey = (options = {}) => {
12986
+ const environment = options.env || process.env;
12987
+ const platform = options.platform || process.platform;
12988
+ if (platform !== "win32") {
12989
+ return "PATH";
12990
+ }
12991
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
12992
+ };
12993
+ module.exports = pathKey;
12994
+ module.exports.default = pathKey;
12995
+ });
12996
+
12997
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
12998
+ var require_resolveCommand = __commonJS((exports, module) => {
12999
+ var path = __require("path");
13000
+ var which = require_which();
13001
+ var getPathKey = require_path_key();
13002
+ function resolveCommandAttempt(parsed, withoutPathExt) {
13003
+ const env = parsed.options.env || process.env;
13004
+ const cwd = process.cwd();
13005
+ const hasCustomCwd = parsed.options.cwd != null;
13006
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
13007
+ if (shouldSwitchCwd) {
13008
+ try {
13009
+ process.chdir(parsed.options.cwd);
13010
+ } catch (err) {}
13011
+ }
13012
+ let resolved;
13013
+ try {
13014
+ resolved = which.sync(parsed.command, {
13015
+ path: env[getPathKey({ env })],
13016
+ pathExt: withoutPathExt ? path.delimiter : undefined
13017
+ });
13018
+ } catch (e) {} finally {
13019
+ if (shouldSwitchCwd) {
13020
+ process.chdir(cwd);
13021
+ }
13022
+ }
13023
+ if (resolved) {
13024
+ resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
13025
+ }
13026
+ return resolved;
13027
+ }
13028
+ function resolveCommand(parsed) {
13029
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
13030
+ }
13031
+ module.exports = resolveCommand;
13032
+ });
13033
+
13034
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
13035
+ var require_escape = __commonJS((exports, module) => {
13036
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
13037
+ function escapeCommand(arg) {
13038
+ arg = arg.replace(metaCharsRegExp, "^$1");
13039
+ return arg;
13040
+ }
13041
+ function escapeArgument(arg, doubleEscapeMetaChars) {
13042
+ arg = `${arg}`;
13043
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
13044
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
13045
+ arg = `"${arg}"`;
13046
+ arg = arg.replace(metaCharsRegExp, "^$1");
13047
+ if (doubleEscapeMetaChars) {
13048
+ arg = arg.replace(metaCharsRegExp, "^$1");
13049
+ }
13050
+ return arg;
13051
+ }
13052
+ exports.command = escapeCommand;
13053
+ exports.argument = escapeArgument;
13054
+ });
13055
+
13056
+ // ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
13057
+ var require_shebang_regex = __commonJS((exports, module) => {
13058
+ module.exports = /^#!(.*)/;
13059
+ });
13060
+
13061
+ // ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
13062
+ var require_shebang_command = __commonJS((exports, module) => {
13063
+ var shebangRegex = require_shebang_regex();
13064
+ module.exports = (string = "") => {
13065
+ const match = string.match(shebangRegex);
13066
+ if (!match) {
13067
+ return null;
13068
+ }
13069
+ const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
13070
+ const binary = path.split("/").pop();
13071
+ if (binary === "env") {
13072
+ return argument;
13073
+ }
13074
+ return argument ? `${binary} ${argument}` : binary;
13075
+ };
13076
+ });
13077
+
13078
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
13079
+ var require_readShebang = __commonJS((exports, module) => {
13080
+ var fs = __require("fs");
13081
+ var shebangCommand = require_shebang_command();
13082
+ function readShebang(command) {
13083
+ const size = 150;
13084
+ const buffer = Buffer.alloc(size);
13085
+ let fd;
13086
+ try {
13087
+ fd = fs.openSync(command, "r");
13088
+ fs.readSync(fd, buffer, 0, size, 0);
13089
+ fs.closeSync(fd);
13090
+ } catch (e) {}
13091
+ return shebangCommand(buffer.toString());
13092
+ }
13093
+ module.exports = readShebang;
13094
+ });
13095
+
13096
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
13097
+ var require_parse = __commonJS((exports, module) => {
13098
+ var path = __require("path");
13099
+ var resolveCommand = require_resolveCommand();
13100
+ var escape = require_escape();
13101
+ var readShebang = require_readShebang();
13102
+ var isWin = process.platform === "win32";
13103
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
13104
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
13105
+ function detectShebang(parsed) {
13106
+ parsed.file = resolveCommand(parsed);
13107
+ const shebang = parsed.file && readShebang(parsed.file);
13108
+ if (shebang) {
13109
+ parsed.args.unshift(parsed.file);
13110
+ parsed.command = shebang;
13111
+ return resolveCommand(parsed);
13112
+ }
13113
+ return parsed.file;
13114
+ }
13115
+ function parseNonShell(parsed) {
13116
+ if (!isWin) {
13117
+ return parsed;
13118
+ }
13119
+ const commandFile = detectShebang(parsed);
13120
+ const needsShell = !isExecutableRegExp.test(commandFile);
13121
+ if (parsed.options.forceShell || needsShell) {
13122
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
13123
+ parsed.command = path.normalize(parsed.command);
13124
+ parsed.command = escape.command(parsed.command);
13125
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
13126
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
13127
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
13128
+ parsed.command = process.env.comspec || "cmd.exe";
13129
+ parsed.options.windowsVerbatimArguments = true;
13130
+ }
13131
+ return parsed;
13132
+ }
13133
+ function parse(command, args, options) {
13134
+ if (args && !Array.isArray(args)) {
13135
+ options = args;
13136
+ args = null;
13137
+ }
13138
+ args = args ? args.slice(0) : [];
13139
+ options = Object.assign({}, options);
13140
+ const parsed = {
13141
+ command,
13142
+ args,
13143
+ options,
13144
+ file: undefined,
13145
+ original: {
13146
+ command,
13147
+ args
13148
+ }
13149
+ };
13150
+ return options.shell ? parsed : parseNonShell(parsed);
13151
+ }
13152
+ module.exports = parse;
13153
+ });
13154
+
13155
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
13156
+ var require_enoent = __commonJS((exports, module) => {
13157
+ var isWin = process.platform === "win32";
13158
+ function notFoundError(original, syscall) {
13159
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
13160
+ code: "ENOENT",
13161
+ errno: "ENOENT",
13162
+ syscall: `${syscall} ${original.command}`,
13163
+ path: original.command,
13164
+ spawnargs: original.args
13165
+ });
13166
+ }
13167
+ function hookChildProcess(cp, parsed) {
13168
+ if (!isWin) {
13169
+ return;
13170
+ }
13171
+ const originalEmit = cp.emit;
13172
+ cp.emit = function(name, arg1) {
13173
+ if (name === "exit") {
13174
+ const err = verifyENOENT(arg1, parsed);
13175
+ if (err) {
13176
+ return originalEmit.call(cp, "error", err);
13177
+ }
13178
+ }
13179
+ return originalEmit.apply(cp, arguments);
13180
+ };
13181
+ }
13182
+ function verifyENOENT(status, parsed) {
13183
+ if (isWin && status === 1 && !parsed.file) {
13184
+ return notFoundError(parsed.original, "spawn");
13185
+ }
13186
+ return null;
13187
+ }
13188
+ function verifyENOENTSync(status, parsed) {
13189
+ if (isWin && status === 1 && !parsed.file) {
13190
+ return notFoundError(parsed.original, "spawnSync");
13191
+ }
13192
+ return null;
13193
+ }
13194
+ module.exports = {
13195
+ hookChildProcess,
13196
+ verifyENOENT,
13197
+ verifyENOENTSync,
13198
+ notFoundError
13199
+ };
13200
+ });
13201
+
13202
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
13203
+ var require_cross_spawn = __commonJS((exports, module) => {
13204
+ var cp = __require("child_process");
13205
+ var parse = require_parse();
13206
+ var enoent = require_enoent();
13207
+ function spawn2(command, args, options) {
13208
+ const parsed = parse(command, args, options);
13209
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
13210
+ enoent.hookChildProcess(spawned, parsed);
13211
+ return spawned;
13212
+ }
13213
+ function spawnSync(command, args, options) {
13214
+ const parsed = parse(command, args, options);
13215
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
13216
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
13217
+ return result;
13218
+ }
13219
+ module.exports = spawn2;
13220
+ module.exports.spawn = spawn2;
13221
+ module.exports.sync = spawnSync;
13222
+ module.exports._parse = parse;
13223
+ module.exports._enoent = enoent;
13224
+ });
13225
+
13226
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/process.js
13227
+ var init_process = () => {};
13228
+
13229
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/server.js
13230
+ var import_cross_spawn;
13231
+ var init_server2 = __esm(() => {
13232
+ init_process();
13233
+ import_cross_spawn = __toESM(require_cross_spawn(), 1);
13234
+ });
13235
+
13236
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/index.js
13237
+ var init_dist = __esm(() => {
13238
+ init_client4();
13239
+ init_server2();
13240
+ init_client4();
13241
+ init_server2();
13242
+ });
13243
+
13244
+ // src/infrastructure/services/remote-agents/opencode-sdk/select-agent.ts
13245
+ function selectAgent(agents) {
13246
+ const primaries = agents.filter((a) => a.mode !== "subagent");
13247
+ if (primaries.length === 0) {
13248
+ throw new Error("No usable opencode agent available (server returned 0 non-subagent agents)");
13249
+ }
13250
+ const buildAgent = primaries.find((a) => a.name === "build");
13251
+ return buildAgent ?? primaries[0];
13252
+ }
13253
+
13254
+ // src/infrastructure/services/remote-agents/opencode-sdk/compose-system-prompt.ts
13255
+ function composeSystemPrompt(agentPrompt, chatroomSystemPrompt) {
13256
+ const trimmedAgent = agentPrompt?.trim() ?? "";
13257
+ const trimmedChatroom = chatroomSystemPrompt.trim();
13258
+ if (!trimmedAgent && !trimmedChatroom) {
13259
+ return;
13260
+ }
13261
+ if (!trimmedAgent) {
13262
+ return trimmedChatroom;
13263
+ }
13264
+ if (!trimmedChatroom) {
13265
+ return trimmedAgent;
13266
+ }
13267
+ return `${trimmedAgent}${CHATROOM_PROMPT_SEPARATOR}${trimmedChatroom}`;
13268
+ }
13269
+ var CHATROOM_PROMPT_SEPARATOR = `
13270
+
13271
+ # Chatroom Role & Instructions (Important)
13272
+
13273
+ `;
13274
+
13275
+ // src/infrastructure/services/remote-agents/opencode-sdk/parse-listening-url.ts
13276
+ async function waitForListeningUrl(child, options) {
13277
+ return new Promise((resolve, reject) => {
13278
+ const buffers = { stdout: "", stderr: "" };
13279
+ const cleanup = () => {
13280
+ clearTimeout(timer);
13281
+ child.stdout?.removeListener("data", onStdout);
13282
+ child.stderr?.removeListener("data", onStderr);
13283
+ child.removeListener("exit", onExit);
13284
+ };
13285
+ const tryMatch = (key, chunk) => {
13286
+ buffers[key] += typeof chunk === "string" ? chunk : chunk.toString("utf8");
13287
+ const match = buffers[key].match(LISTENING_URL_RE);
13288
+ if (match) {
13289
+ cleanup();
13290
+ resolve(match[1]);
13291
+ return;
13292
+ }
13293
+ const lastNl = buffers[key].lastIndexOf(`
13294
+ `);
13295
+ if (lastNl >= 0) {
13296
+ buffers[key] = buffers[key].slice(lastNl + 1);
13297
+ }
13298
+ };
13299
+ const onStdout = (chunk) => tryMatch("stdout", chunk);
13300
+ const onStderr = (chunk) => tryMatch("stderr", chunk);
13301
+ const onExit = (code2, signal) => {
13302
+ cleanup();
13303
+ reject(new Error(`opencode serve exited unexpectedly during startup (code=${code2}, signal=${signal})`));
13304
+ };
13305
+ child.stdout?.on("data", onStdout);
13306
+ child.stderr?.on("data", onStderr);
13307
+ child.on("exit", onExit);
13308
+ const timer = setTimeout(() => {
13309
+ cleanup();
13310
+ reject(new Error(`opencode serve did not print a listening URL within ${options.timeoutMs}ms`));
13311
+ }, options.timeoutMs);
13312
+ });
13313
+ }
13314
+ var LISTENING_URL_RE;
13315
+ var init_parse_listening_url = __esm(() => {
13316
+ LISTENING_URL_RE = /opencode server listening on (https?:\/\/127\.0\.0\.1:\d+(?:\/[^\s]*)?)/;
13317
+ });
13318
+
13319
+ // src/infrastructure/services/remote-agents/opencode-sdk/session-metadata-store.ts
13320
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
13321
+ import { dirname as dirname2, join as join3 } from "node:path";
13322
+ import { homedir as homedir2 } from "node:os";
13323
+
13324
+ class FileSessionMetadataStore {
13325
+ filePath;
13326
+ constructor(filePath) {
13327
+ this.filePath = filePath ?? join3(homedir2(), ".chatroom", "opencode-sdk-sessions.json");
13328
+ }
13329
+ load() {
13330
+ try {
13331
+ if (existsSync2(this.filePath)) {
13332
+ return JSON.parse(readFileSync3(this.filePath, "utf-8"));
13333
+ }
13334
+ } catch {}
13335
+ return {};
13336
+ }
13337
+ save(sessions) {
13338
+ try {
13339
+ const dir = dirname2(this.filePath);
13340
+ if (!existsSync2(dir)) {
13341
+ mkdirSync2(dir, { recursive: true });
13342
+ }
13343
+ writeFileSync2(this.filePath, JSON.stringify(sessions, null, 2));
13344
+ } catch {}
13345
+ }
13346
+ get(sessionId) {
13347
+ return this.load()[sessionId];
13348
+ }
13349
+ findByPid(pid) {
13350
+ const sessions = this.load();
13351
+ return Object.values(sessions).find((m) => m.pid === pid);
13352
+ }
13353
+ upsert(meta) {
13354
+ const sessions = this.load();
13355
+ sessions[meta.sessionId] = meta;
13356
+ this.save(sessions);
13357
+ }
13358
+ remove(sessionId) {
13359
+ const sessions = this.load();
13360
+ delete sessions[sessionId];
13361
+ this.save(sessions);
13362
+ }
13363
+ }
13364
+ var init_session_metadata_store = () => {};
13365
+
13366
+ // src/infrastructure/services/remote-agents/opencode-sdk/node-streams.ts
13367
+ function forwardFiltered(source, target, shouldDrop) {
13368
+ if (!source)
13369
+ return;
13370
+ let buf = "";
13371
+ source.on("data", (chunk) => {
13372
+ buf += typeof chunk === "string" ? chunk : chunk.toString("utf8");
13373
+ let nl;
13374
+ while ((nl = buf.indexOf(`
13375
+ `)) !== -1) {
13376
+ const line = buf.slice(0, nl);
13377
+ buf = buf.slice(nl + 1);
13378
+ if (!shouldDrop(line))
13379
+ target.write(line + `
13380
+ `);
13381
+ }
13382
+ });
13383
+ source.on("end", () => {
13384
+ if (buf.length > 0 && !shouldDrop(buf))
13385
+ target.write(buf);
13386
+ buf = "";
13387
+ });
13388
+ }
13389
+
13390
+ // src/infrastructure/services/remote-agents/opencode-sdk/pure.ts
13391
+ function parseModelId(model) {
13392
+ if (!model)
13393
+ return;
13394
+ const slashIdx = model.indexOf("/");
13395
+ if (slashIdx === -1)
13396
+ return;
13397
+ const providerID = model.substring(0, slashIdx);
13398
+ const modelID = model.substring(slashIdx + 1);
13399
+ if (!providerID || !modelID)
13400
+ return;
13401
+ return { providerID, modelID };
13402
+ }
13403
+ var isInfoLine = (line) => line.trimStart().startsWith("INFO ");
13404
+
13405
+ // src/infrastructure/services/remote-agents/opencode-sdk/session-event-forwarder.ts
13406
+ function formatLogLine(options, kind, payload) {
13407
+ const ts = options.now ? options.now() : new Date().toISOString();
13408
+ return `[${ts}] role:${options.role} ${kind}]${payload ? ` ${payload}` : ""}`;
13409
+ }
13410
+ function eventSessionId(event) {
13411
+ const p = event.properties;
13412
+ if (!p || typeof p !== "object")
13413
+ return;
13414
+ if ("sessionID" in p && typeof p.sessionID === "string")
13415
+ return p.sessionID;
13416
+ if ("part" in p && p.part && typeof p.part === "object") {
13417
+ return p.part.sessionID;
13418
+ }
13419
+ if ("info" in p && p.info && typeof p.info === "object") {
13420
+ return p.info.sessionID;
13421
+ }
13422
+ return;
13423
+ }
13424
+ function startSessionEventForwarder(client4, options) {
13425
+ const target = options.target ?? process.stdout;
13426
+ const errorTarget = options.errorTarget ?? process.stderr;
13427
+ let cancelled = false;
13428
+ let doneResolve;
13429
+ const donePromise = new Promise((resolve) => {
13430
+ doneResolve = resolve;
13431
+ });
13432
+ async function run() {
13433
+ try {
13434
+ const result = await client4.event.subscribe();
13435
+ const stream = result.stream;
13436
+ if (cancelled) {
13437
+ await stream.return?.(undefined);
13438
+ return;
13439
+ }
13440
+ for await (const event of stream) {
13441
+ if (cancelled) {
13442
+ await stream.return?.(undefined);
13443
+ break;
13444
+ }
13445
+ const eventSession = eventSessionId(event);
13446
+ if (eventSession && eventSession !== options.sessionId)
13447
+ continue;
13448
+ if (eventSession === undefined && event.type !== "session.idle" && event.type !== "session.compacted" && event.type !== "session.error" && event.type !== "session.status" && event.type !== "file.edited")
13449
+ continue;
13450
+ switch (event.type) {
13451
+ case "message.part.updated": {
13452
+ const props = event.properties;
13453
+ const part = props?.part;
13454
+ if (part?.type === "text" && part.delta) {
13455
+ target.write(formatLogLine(options, "text", part.delta) + `
13456
+ `);
13457
+ } else if (part?.type === "tool" && part.tool) {
13458
+ const state = props?.state ?? "started";
13459
+ target.write(formatLogLine(options, "tool: " + part.tool, state) + `
13460
+ `);
13461
+ }
13462
+ break;
13463
+ }
13464
+ case "file.edited": {
13465
+ const props = event.properties;
13466
+ target.write(formatLogLine(options, "file", props?.file) + `
13467
+ `);
13468
+ break;
13469
+ }
13470
+ case "session.idle": {
13471
+ target.write(formatLogLine(options, "agent_end") + `
13472
+ `);
13473
+ break;
13474
+ }
13475
+ case "session.compacted": {
13476
+ target.write(formatLogLine(options, "compacted") + `
13477
+ `);
13478
+ break;
13479
+ }
13480
+ case "session.status": {
13481
+ const props = event.properties;
13482
+ target.write(formatLogLine(options, "status", props?.status?.type) + `
13483
+ `);
13484
+ break;
13485
+ }
13486
+ case "session.error": {
13487
+ const props = event.properties;
13488
+ const err = props?.error;
13489
+ const errMsg = err?.name ? `${err.name}${err?.data?.message ? ": " + err.data.message : ""}` : String(err ?? "unknown");
13490
+ errorTarget.write(formatLogLine(options, "error", errMsg) + `
13491
+ `);
13492
+ break;
13493
+ }
13494
+ default:
13495
+ break;
13496
+ }
13497
+ }
13498
+ } catch (err) {
13499
+ const message = err instanceof Error ? err.message : String(err);
13500
+ errorTarget.write(formatLogLine(options, "error", message) + `
13501
+ `);
13502
+ } finally {
13503
+ doneResolve();
13504
+ }
13505
+ }
13506
+ run();
13507
+ return {
13508
+ stop: () => {
13509
+ cancelled = true;
13510
+ },
13511
+ done: donePromise
13512
+ };
13513
+ }
13514
+
13515
+ // src/infrastructure/services/remote-agents/opencode-sdk/opencode-sdk-agent-service.ts
13516
+ async function withTimeout(p, ms, label) {
13517
+ let timer;
13518
+ try {
13519
+ return await Promise.race([
13520
+ p,
13521
+ new Promise((_, reject) => {
13522
+ timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
13523
+ })
13524
+ ]);
13525
+ } finally {
13526
+ if (timer)
13527
+ clearTimeout(timer);
13528
+ }
13529
+ }
13530
+ var OPENCODE_COMMAND2 = "opencode", SERVE_STARTUP_TIMEOUT_MS = 1e4, SESSION_CREATE_TIMEOUT_MS = 30000, PROMPT_ASYNC_TIMEOUT_MS = 60000, SESSION_ABORT_TIMEOUT_MS = 5000, AGENTS_LIST_TIMEOUT_MS = 1e4, OpenCodeSdkAgentService;
13531
+ var init_opencode_sdk_agent_service = __esm(() => {
13532
+ init_dist();
13533
+ init_base_cli_agent_service();
13534
+ init_parse_listening_url();
13535
+ init_session_metadata_store();
13536
+ OpenCodeSdkAgentService = class OpenCodeSdkAgentService extends BaseCLIAgentService {
13537
+ id = "opencode-sdk";
13538
+ displayName = "OpenCode (SDK)";
13539
+ command = OPENCODE_COMMAND2;
13540
+ sessionStore;
13541
+ forwarders = new Map;
13542
+ constructor(deps) {
13543
+ super(deps);
13544
+ this.sessionStore = deps?.sessionMetadataStore ?? new FileSessionMetadataStore;
13545
+ }
13546
+ isInstalled() {
13547
+ return this.checkInstalled(OPENCODE_COMMAND2);
13548
+ }
13549
+ getVersion() {
13550
+ return this.checkVersion(OPENCODE_COMMAND2);
13551
+ }
13552
+ async listModels() {
13553
+ try {
13554
+ const output = this.deps.execSync(`${OPENCODE_COMMAND2} models`, {
13555
+ stdio: ["pipe", "pipe", "pipe"],
13556
+ timeout: 1e4
13557
+ }).toString().trim();
13558
+ if (!output)
13559
+ return [];
13560
+ return output.split(`
13561
+ `).map((line) => line.trim()).filter((line) => line.length > 0);
13562
+ } catch {
13563
+ return [];
13564
+ }
13565
+ }
13566
+ async stop(pid) {
13567
+ const forwarder = this.forwarders.get(pid);
13568
+ if (forwarder) {
13569
+ forwarder.stop();
13570
+ this.forwarders.delete(pid);
13571
+ }
13572
+ const meta = this.sessionStore.findByPid(pid);
13573
+ if (meta) {
13574
+ try {
13575
+ const client4 = createOpencodeClient({ baseUrl: meta.baseUrl });
13576
+ await withTimeout(client4.session.abort({ path: { id: meta.sessionId } }), SESSION_ABORT_TIMEOUT_MS, "session.abort");
13577
+ } catch (err) {
13578
+ console.warn(`[opencode-sdk] session.abort for pid=${pid} sessionId=${meta.sessionId} failed (continuing with SIGTERM):`, err instanceof Error ? err.message : err);
13579
+ }
13580
+ }
13581
+ await super.stop(pid);
13582
+ }
13583
+ async spawn(options) {
13584
+ const { prompt, systemPrompt, model, context } = options;
13585
+ const childProcess = this.deps.spawn(OPENCODE_COMMAND2, ["serve", "--print-logs"], {
13586
+ cwd: options.workingDir,
13587
+ stdio: ["pipe", "pipe", "pipe"],
13588
+ shell: false,
13589
+ detached: true,
13590
+ env: {
13591
+ ...process.env,
13592
+ GIT_EDITOR: "true",
13593
+ GIT_SEQUENCE_EDITOR: "true"
13594
+ }
13595
+ });
13596
+ if (!childProcess.pid) {
13597
+ throw new Error("Failed to spawn opencode serve process");
13598
+ }
13599
+ const pid = childProcess.pid;
13600
+ const baseUrl = await waitForListeningUrl(childProcess, {
13601
+ timeoutMs: SERVE_STARTUP_TIMEOUT_MS
13602
+ }).catch((err) => {
13603
+ childProcess.kill();
13604
+ throw err;
13605
+ });
13606
+ const client4 = createOpencodeClient({
13607
+ baseUrl
13608
+ });
13609
+ let sessionId;
13610
+ let forwarder;
13611
+ try {
13612
+ const sessionCreateResult = await withTimeout(client4.session.create({ body: {} }), SESSION_CREATE_TIMEOUT_MS, "session.create");
13613
+ if (!sessionCreateResult.data?.id) {
13614
+ throw new Error("Failed to create session");
13615
+ }
13616
+ sessionId = sessionCreateResult.data.id;
13617
+ forwarder = startSessionEventForwarder(client4, {
13618
+ sessionId,
13619
+ role: context.role
13620
+ });
13621
+ const agentsResponse = await withTimeout(client4.app.agents(), AGENTS_LIST_TIMEOUT_MS, "app.agents");
13622
+ const availableAgents = agentsResponse.data ?? [];
13623
+ const selected = selectAgent(availableAgents);
13624
+ const composedSystem = composeSystemPrompt(selected.prompt, systemPrompt);
13625
+ const modelParts = model ? parseModelId(model) : undefined;
13626
+ await withTimeout(client4.session.promptAsync({
13627
+ path: { id: sessionId },
13628
+ body: {
13629
+ agent: selected.name,
13630
+ ...composedSystem ? { system: composedSystem } : {},
13631
+ parts: [{ type: "text", text: prompt }],
13632
+ ...modelParts ? { model: modelParts } : {}
13633
+ }
13634
+ }), PROMPT_ASYNC_TIMEOUT_MS, "session.promptAsync");
13635
+ } catch (err) {
13636
+ const reason = err instanceof Error ? err.message : String(err);
13637
+ process.stderr.write(`[${new Date().toISOString()}] role:${context.role} spawn-error] ${reason}
13638
+ `);
13639
+ forwarder?.stop();
13640
+ childProcess.kill();
13641
+ if (sessionId)
13642
+ this.sessionStore.remove(sessionId);
13643
+ throw err;
13644
+ }
13645
+ const meta = {
13646
+ sessionId,
13647
+ machineId: context.machineId,
13648
+ chatroomId: context.chatroomId,
13649
+ role: context.role,
13650
+ pid,
13651
+ createdAt: new Date().toISOString(),
13652
+ baseUrl
13653
+ };
13654
+ this.sessionStore.upsert(meta);
13655
+ const entry = this.registerProcess(pid, context);
13656
+ if (forwarder)
13657
+ this.forwarders.set(pid, forwarder);
13658
+ const outputCallbacks = [];
13659
+ forwardFiltered(childProcess.stdout, process.stdout, isInfoLine);
13660
+ forwardFiltered(childProcess.stderr, process.stderr, isInfoLine);
13661
+ if (childProcess.stdout) {
13662
+ childProcess.stdout.on("data", () => {
13663
+ entry.lastOutputAt = Date.now();
13664
+ for (const cb of outputCallbacks)
13665
+ cb();
13666
+ });
13667
+ }
13668
+ if (childProcess.stderr) {
13669
+ childProcess.stderr.on("data", () => {
13670
+ entry.lastOutputAt = Date.now();
13671
+ for (const cb of outputCallbacks)
13672
+ cb();
13673
+ });
13674
+ }
13675
+ return {
13676
+ pid,
13677
+ onExit: (cb) => {
13678
+ childProcess.on("exit", (code2, signal) => {
13679
+ const fwd = this.forwarders.get(pid);
13680
+ if (fwd) {
13681
+ fwd.stop();
13682
+ this.forwarders.delete(pid);
13683
+ }
13684
+ this.sessionStore.remove(sessionId);
13685
+ this.deleteProcess(pid);
13686
+ cb({ code: code2, signal, context });
13687
+ });
13688
+ },
13689
+ onOutput: (cb) => {
13690
+ outputCallbacks.push(cb);
13691
+ }
13692
+ };
13693
+ }
13694
+ };
13695
+ });
13696
+
13697
+ // src/infrastructure/services/remote-agents/opencode-sdk/index.ts
13698
+ var init_opencode_sdk = __esm(() => {
13699
+ init_opencode_sdk_agent_service();
13700
+ });
13701
+
11383
13702
  // src/infrastructure/services/remote-agents/init-registry.ts
11384
13703
  function initHarnessRegistry() {
11385
13704
  if (initialized)
11386
13705
  return;
11387
13706
  registerHarness(new OpenCodeAgentService);
13707
+ registerHarness(new OpenCodeSdkAgentService);
11388
13708
  registerHarness(new PiAgentService);
11389
13709
  registerHarness(new CursorAgentService);
11390
13710
  registerHarness(new ClaudeCodeAgentService);
@@ -11397,6 +13717,7 @@ var init_init_registry = __esm(() => {
11397
13717
  init_copilot();
11398
13718
  init_cursor();
11399
13719
  init_opencode();
13720
+ init_opencode_sdk();
11400
13721
  init_pi();
11401
13722
  init_registry();
11402
13723
  });
@@ -11442,24 +13763,28 @@ var MACHINE_CONFIG_VERSION = "1";
11442
13763
 
11443
13764
  // src/infrastructure/machine/storage.ts
11444
13765
  import { randomUUID } from "node:crypto";
11445
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2, renameSync } from "node:fs";
11446
- import { homedir as homedir2, hostname as hostname2 } from "node:os";
11447
- import { join as join3 } from "node:path";
13766
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3, renameSync } from "node:fs";
13767
+ import { homedir as homedir3, hostname as hostname2 } from "node:os";
13768
+ import { join as join4 } from "node:path";
13769
+ function chatroomConfigDir() {
13770
+ return join4(homedir3(), ".chatroom");
13771
+ }
11448
13772
  function ensureConfigDir2() {
11449
- if (!existsSync2(CHATROOM_DIR2)) {
11450
- mkdirSync2(CHATROOM_DIR2, { recursive: true, mode: 448 });
13773
+ const dir = chatroomConfigDir();
13774
+ if (!existsSync3(dir)) {
13775
+ mkdirSync3(dir, { recursive: true, mode: 448 });
11451
13776
  }
11452
13777
  }
11453
13778
  function getMachineConfigPath() {
11454
- return join3(CHATROOM_DIR2, MACHINE_FILE);
13779
+ return join4(chatroomConfigDir(), MACHINE_FILE);
11455
13780
  }
11456
13781
  function loadConfigFile() {
11457
13782
  const configPath = getMachineConfigPath();
11458
- if (!existsSync2(configPath)) {
13783
+ if (!existsSync3(configPath)) {
11459
13784
  return null;
11460
13785
  }
11461
13786
  try {
11462
- const content = readFileSync3(configPath, "utf-8");
13787
+ const content = readFileSync4(configPath, "utf-8");
11463
13788
  return JSON.parse(content);
11464
13789
  } catch (error) {
11465
13790
  console.warn(`⚠️ Failed to read machine config at ${configPath}: ${error.message}`);
@@ -11473,7 +13798,7 @@ function saveConfigFile(configFile) {
11473
13798
  const configPath = getMachineConfigPath();
11474
13799
  const tempPath = `${configPath}.tmp`;
11475
13800
  const content = JSON.stringify(configFile, null, 2);
11476
- writeFileSync2(tempPath, content, { encoding: "utf-8", mode: 384 });
13801
+ writeFileSync3(tempPath, content, { encoding: "utf-8", mode: 384 });
11477
13802
  renameSync(tempPath, configPath);
11478
13803
  }
11479
13804
  function loadMachineConfig() {
@@ -11505,9 +13830,14 @@ function createNewEndpointConfig() {
11505
13830
  harnessVersions: detectHarnessVersions(availableHarnesses)
11506
13831
  };
11507
13832
  }
11508
- function ensureMachineRegistered() {
13833
+ function ensureMachineRegistered(options = {}) {
13834
+ const { allowCreate = false } = options;
11509
13835
  let config = loadMachineConfig();
11510
13836
  if (!config) {
13837
+ if (!allowCreate) {
13838
+ const convexUrl = getConvexUrl();
13839
+ throw new Error(`Machine not registered for endpoint "${convexUrl}". Run "chatroom machine start" to create a new machine identity for this deployment.`);
13840
+ }
11511
13841
  config = createNewEndpointConfig();
11512
13842
  saveMachineConfig(config);
11513
13843
  } else {
@@ -11529,35 +13859,34 @@ function getMachineId() {
11529
13859
  const config = loadMachineConfig();
11530
13860
  return config?.machineId ?? null;
11531
13861
  }
11532
- var CHATROOM_DIR2, MACHINE_FILE = "machine.json";
13862
+ var MACHINE_FILE = "machine.json";
11533
13863
  var init_storage2 = __esm(() => {
11534
13864
  init_detection();
11535
13865
  init_client2();
11536
- CHATROOM_DIR2 = join3(homedir2(), ".chatroom");
11537
13866
  });
11538
13867
 
11539
13868
  // src/infrastructure/machine/daemon-state.ts
11540
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3, renameSync as renameSync2 } from "node:fs";
11541
- import { homedir as homedir3 } from "node:os";
11542
- import { join as join4 } from "node:path";
13869
+ import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4, renameSync as renameSync2 } from "node:fs";
13870
+ import { homedir as homedir4 } from "node:os";
13871
+ import { join as join5 } from "node:path";
11543
13872
  function agentKey(chatroomId, role) {
11544
13873
  return `${chatroomId}/${role}`;
11545
13874
  }
11546
13875
  function ensureStateDir() {
11547
- if (!existsSync3(STATE_DIR)) {
11548
- mkdirSync3(STATE_DIR, { recursive: true, mode: 448 });
13876
+ if (!existsSync4(STATE_DIR)) {
13877
+ mkdirSync4(STATE_DIR, { recursive: true, mode: 448 });
11549
13878
  }
11550
13879
  }
11551
13880
  function stateFilePath(machineId) {
11552
- return join4(STATE_DIR, `${machineId}.json`);
13881
+ return join5(STATE_DIR, `${machineId}.json`);
11553
13882
  }
11554
13883
  function loadDaemonState(machineId) {
11555
13884
  const filePath = stateFilePath(machineId);
11556
- if (!existsSync3(filePath)) {
13885
+ if (!existsSync4(filePath)) {
11557
13886
  return null;
11558
13887
  }
11559
13888
  try {
11560
- const content = readFileSync4(filePath, "utf-8");
13889
+ const content = readFileSync5(filePath, "utf-8");
11561
13890
  return JSON.parse(content);
11562
13891
  } catch {
11563
13892
  return null;
@@ -11568,7 +13897,7 @@ function saveDaemonState(state) {
11568
13897
  const filePath = stateFilePath(state.machineId);
11569
13898
  const tempPath = `${filePath}.tmp`;
11570
13899
  const content = JSON.stringify(state, null, 2);
11571
- writeFileSync3(tempPath, content, { encoding: "utf-8", mode: 384 });
13900
+ writeFileSync4(tempPath, content, { encoding: "utf-8", mode: 384 });
11572
13901
  renameSync2(tempPath, filePath);
11573
13902
  }
11574
13903
  function loadOrCreate(machineId) {
@@ -11629,10 +13958,10 @@ function loadEventCursor(machineId) {
11629
13958
  const state = loadDaemonState(machineId);
11630
13959
  return state?.lastSeenEventId ?? null;
11631
13960
  }
11632
- var CHATROOM_DIR3, STATE_DIR, STATE_VERSION = "1";
13961
+ var CHATROOM_DIR2, STATE_DIR, STATE_VERSION = "1";
11633
13962
  var init_daemon_state = __esm(() => {
11634
- CHATROOM_DIR3 = join4(homedir3(), ".chatroom");
11635
- STATE_DIR = join4(CHATROOM_DIR3, "machines", "state");
13963
+ CHATROOM_DIR2 = join5(homedir4(), ".chatroom");
13964
+ STATE_DIR = join5(CHATROOM_DIR2, "machines", "state");
11636
13965
  });
11637
13966
 
11638
13967
  // src/infrastructure/machine/index.ts
@@ -11671,10 +14000,10 @@ __export(exports_auth_status, {
11671
14000
  authStatus: () => authStatus
11672
14001
  });
11673
14002
  async function createDefaultDeps3() {
11674
- const client2 = await getConvexClient();
14003
+ const client4 = await getConvexClient();
11675
14004
  return {
11676
14005
  backend: {
11677
- query: (endpoint, args) => client2.query(endpoint, args)
14006
+ query: (endpoint, args) => client4.query(endpoint, args)
11678
14007
  },
11679
14008
  session: {
11680
14009
  loadAuthData,
@@ -11993,9 +14322,9 @@ var init_init = __esm(() => {
11993
14322
  });
11994
14323
 
11995
14324
  // src/tools/output.ts
11996
- import { join as join5 } from "node:path";
14325
+ import { join as join6 } from "node:path";
11997
14326
  function resolveChatroomDir(workingDir) {
11998
- return join5(workingDir, CHATROOM_DIR4);
14327
+ return join6(workingDir, CHATROOM_DIR3);
11999
14328
  }
12000
14329
  async function ensureChatroomDir(deps, workingDir) {
12001
14330
  const dir = resolveChatroomDir(workingDir);
@@ -12003,8 +14332,8 @@ async function ensureChatroomDir(deps, workingDir) {
12003
14332
  return dir;
12004
14333
  }
12005
14334
  async function ensureGitignore(deps, workingDir) {
12006
- const gitignorePath = join5(workingDir, ".gitignore");
12007
- const entry = CHATROOM_DIR4;
14335
+ const gitignorePath = join6(workingDir, ".gitignore");
14336
+ const entry = CHATROOM_DIR3;
12008
14337
  let content = "";
12009
14338
  try {
12010
14339
  content = await deps.fs.readFile(gitignorePath, "utf8");
@@ -12033,9 +14362,9 @@ function formatOutputTimestamp(date = new Date) {
12033
14362
  function generateOutputPath(workingDir, toolName, extension, date) {
12034
14363
  const timestamp = formatOutputTimestamp(date);
12035
14364
  const filename = `${toolName}-${timestamp}.${extension}`;
12036
- return join5(resolveChatroomDir(workingDir), filename);
14365
+ return join6(resolveChatroomDir(workingDir), filename);
12037
14366
  }
12038
- var CHATROOM_DIR4 = ".chatroom";
14367
+ var CHATROOM_DIR3 = ".chatroom";
12039
14368
  var init_output = () => {};
12040
14369
 
12041
14370
  // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
@@ -18047,7 +20376,7 @@ var require_filesystem = __commonJS((exports, module) => {
18047
20376
  var LDD_PATH = "/usr/bin/ldd";
18048
20377
  var SELF_PATH = "/proc/self/exe";
18049
20378
  var MAX_LENGTH = 2048;
18050
- var readFileSync5 = (path2) => {
20379
+ var readFileSync6 = (path2) => {
18051
20380
  const fd = fs.openSync(path2, "r");
18052
20381
  const buffer = Buffer.alloc(MAX_LENGTH);
18053
20382
  const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
@@ -18070,7 +20399,7 @@ var require_filesystem = __commonJS((exports, module) => {
18070
20399
  module.exports = {
18071
20400
  LDD_PATH,
18072
20401
  SELF_PATH,
18073
- readFileSync: readFileSync5,
20402
+ readFileSync: readFileSync6,
18074
20403
  readFile
18075
20404
  };
18076
20405
  });
@@ -18113,7 +20442,7 @@ var require_elf = __commonJS((exports, module) => {
18113
20442
  var require_detect_libc = __commonJS((exports, module) => {
18114
20443
  var childProcess = __require("child_process");
18115
20444
  var { isLinux, getReport } = require_process();
18116
- var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync5 } = require_filesystem();
20445
+ var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync6 } = require_filesystem();
18117
20446
  var { interpreterPath } = require_elf();
18118
20447
  var cachedFamilyInterpreter;
18119
20448
  var cachedFamilyFilesystem;
@@ -18204,7 +20533,7 @@ var require_detect_libc = __commonJS((exports, module) => {
18204
20533
  }
18205
20534
  cachedFamilyFilesystem = null;
18206
20535
  try {
18207
- const lddContent = readFileSync5(LDD_PATH);
20536
+ const lddContent = readFileSync6(LDD_PATH);
18208
20537
  cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
18209
20538
  } catch (e) {}
18210
20539
  return cachedFamilyFilesystem;
@@ -18227,7 +20556,7 @@ var require_detect_libc = __commonJS((exports, module) => {
18227
20556
  }
18228
20557
  cachedFamilyInterpreter = null;
18229
20558
  try {
18230
- const selfContent = readFileSync5(SELF_PATH);
20559
+ const selfContent = readFileSync6(SELF_PATH);
18231
20560
  const path2 = interpreterPath(selfContent);
18232
20561
  cachedFamilyInterpreter = familyFromInterpreterPath(path2);
18233
20562
  } catch (e) {}
@@ -18289,7 +20618,7 @@ var require_detect_libc = __commonJS((exports, module) => {
18289
20618
  }
18290
20619
  cachedVersionFilesystem = null;
18291
20620
  try {
18292
- const lddContent = readFileSync5(LDD_PATH);
20621
+ const lddContent = readFileSync6(LDD_PATH);
18293
20622
  const versionMatch = lddContent.match(RE_GLIBC_VERSION);
18294
20623
  if (versionMatch) {
18295
20624
  cachedVersionFilesystem = versionMatch[1];
@@ -18782,7 +21111,7 @@ var require_semver = __commonJS((exports, module) => {
18782
21111
  });
18783
21112
 
18784
21113
  // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js
18785
- var require_parse = __commonJS((exports, module) => {
21114
+ var require_parse2 = __commonJS((exports, module) => {
18786
21115
  var SemVer = require_semver();
18787
21116
  var parse = (version2, options, throwErrors = false) => {
18788
21117
  if (version2 instanceof SemVer) {
@@ -18803,7 +21132,7 @@ var require_parse = __commonJS((exports, module) => {
18803
21132
  // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js
18804
21133
  var require_coerce = __commonJS((exports, module) => {
18805
21134
  var SemVer = require_semver();
18806
- var parse = require_parse();
21135
+ var parse = require_parse2();
18807
21136
  var { safeRe: re, t } = require_re();
18808
21137
  var coerce = (version2, options) => {
18809
21138
  if (version2 instanceof SemVer) {
@@ -24485,11 +26814,11 @@ var init_pdfium_renderer = __esm(() => {
24485
26814
 
24486
26815
  // ../../node_modules/.pnpm/@llamaindex+liteparse@1.4.6/node_modules/@llamaindex/liteparse/dist/src/engines/pdf/pdfjsImporter.js
24487
26816
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24488
- import { dirname as dirname2 } from "node:path";
26817
+ import { dirname as dirname3 } from "node:path";
24489
26818
  async function importPdfJs() {
24490
26819
  const pdfUrl = new URL("../../vendor/pdfjs/pdf.mjs", import.meta.url);
24491
26820
  const pdfjs = await import(pdfUrl.href);
24492
- const dirPath = dirname2(fileURLToPath2(pdfUrl));
26821
+ const dirPath = dirname3(fileURLToPath2(pdfUrl));
24493
26822
  return {
24494
26823
  fn: pdfjs.getDocument,
24495
26824
  dir: dirPath
@@ -27989,11 +30318,11 @@ var require_lib3 = __commonJS((exports, module) => {
27989
30318
  }
27990
30319
  var MAP = Symbol("map");
27991
30320
 
27992
- class Headers {
30321
+ class Headers2 {
27993
30322
  constructor() {
27994
30323
  let init2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
27995
30324
  this[MAP] = Object.create(null);
27996
- if (init2 instanceof Headers) {
30325
+ if (init2 instanceof Headers2) {
27997
30326
  const rawHeaders = init2.raw();
27998
30327
  const headerNames = Object.keys(rawHeaders);
27999
30328
  for (const headerName of headerNames) {
@@ -28101,14 +30430,14 @@ var require_lib3 = __commonJS((exports, module) => {
28101
30430
  return createHeadersIterator(this, "key+value");
28102
30431
  }
28103
30432
  }
28104
- Headers.prototype.entries = Headers.prototype[Symbol.iterator];
28105
- Object.defineProperty(Headers.prototype, Symbol.toStringTag, {
30433
+ Headers2.prototype.entries = Headers2.prototype[Symbol.iterator];
30434
+ Object.defineProperty(Headers2.prototype, Symbol.toStringTag, {
28106
30435
  value: "Headers",
28107
30436
  writable: false,
28108
30437
  enumerable: false,
28109
30438
  configurable: true
28110
30439
  });
28111
- Object.defineProperties(Headers.prototype, {
30440
+ Object.defineProperties(Headers2.prototype, {
28112
30441
  get: { enumerable: true },
28113
30442
  forEach: { enumerable: true },
28114
30443
  set: { enumerable: true },
@@ -28177,7 +30506,7 @@ var require_lib3 = __commonJS((exports, module) => {
28177
30506
  return obj;
28178
30507
  }
28179
30508
  function createHeadersLenient(obj) {
28180
- const headers = new Headers;
30509
+ const headers = new Headers2;
28181
30510
  for (const name of Object.keys(obj)) {
28182
30511
  if (invalidTokenRegex.test(name)) {
28183
30512
  continue;
@@ -28208,7 +30537,7 @@ var require_lib3 = __commonJS((exports, module) => {
28208
30537
  let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
28209
30538
  Body.call(this, body, opts);
28210
30539
  const status = opts.status || 200;
28211
- const headers = new Headers(opts.headers);
30540
+ const headers = new Headers2(opts.headers);
28212
30541
  if (body != null && !headers.has("Content-Type")) {
28213
30542
  const contentType = extractContentType(body);
28214
30543
  if (contentType) {
@@ -28287,7 +30616,7 @@ var require_lib3 = __commonJS((exports, module) => {
28287
30616
  return !!(proto && proto.constructor.name === "AbortSignal");
28288
30617
  }
28289
30618
 
28290
- class Request {
30619
+ class Request2 {
28291
30620
  constructor(input) {
28292
30621
  let init2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
28293
30622
  let parsedURL;
@@ -28311,7 +30640,7 @@ var require_lib3 = __commonJS((exports, module) => {
28311
30640
  timeout: init2.timeout || input.timeout || 0,
28312
30641
  size: init2.size || input.size || 0
28313
30642
  });
28314
- const headers = new Headers(init2.headers || input.headers || {});
30643
+ const headers = new Headers2(init2.headers || input.headers || {});
28315
30644
  if (inputBody != null && !headers.has("Content-Type")) {
28316
30645
  const contentType = extractContentType(inputBody);
28317
30646
  if (contentType) {
@@ -28352,17 +30681,17 @@ var require_lib3 = __commonJS((exports, module) => {
28352
30681
  return this[INTERNALS$2].signal;
28353
30682
  }
28354
30683
  clone() {
28355
- return new Request(this);
30684
+ return new Request2(this);
28356
30685
  }
28357
30686
  }
28358
- Body.mixIn(Request.prototype);
28359
- Object.defineProperty(Request.prototype, Symbol.toStringTag, {
30687
+ Body.mixIn(Request2.prototype);
30688
+ Object.defineProperty(Request2.prototype, Symbol.toStringTag, {
28360
30689
  value: "Request",
28361
30690
  writable: false,
28362
30691
  enumerable: false,
28363
30692
  configurable: true
28364
30693
  });
28365
- Object.defineProperties(Request.prototype, {
30694
+ Object.defineProperties(Request2.prototype, {
28366
30695
  method: { enumerable: true },
28367
30696
  url: { enumerable: true },
28368
30697
  headers: { enumerable: true },
@@ -28372,7 +30701,7 @@ var require_lib3 = __commonJS((exports, module) => {
28372
30701
  });
28373
30702
  function getNodeRequestOptions(request) {
28374
30703
  const parsedURL = request[INTERNALS$2].parsedURL;
28375
- const headers = new Headers(request[INTERNALS$2].headers);
30704
+ const headers = new Headers2(request[INTERNALS$2].headers);
28376
30705
  if (!headers.has("Accept")) {
28377
30706
  headers.set("Accept", "*/*");
28378
30707
  }
@@ -28441,7 +30770,7 @@ var require_lib3 = __commonJS((exports, module) => {
28441
30770
  }
28442
30771
  Body.Promise = fetch2.Promise;
28443
30772
  return new fetch2.Promise(function(resolve, reject) {
28444
- const request = new Request(url, opts);
30773
+ const request = new Request2(url, opts);
28445
30774
  const options = getNodeRequestOptions(request);
28446
30775
  const send = (options.protocol === "https:" ? https : http).request;
28447
30776
  const signal = request.signal;
@@ -28549,7 +30878,7 @@ var require_lib3 = __commonJS((exports, module) => {
28549
30878
  return;
28550
30879
  }
28551
30880
  const requestOpts = {
28552
- headers: new Headers(request.headers),
30881
+ headers: new Headers2(request.headers),
28553
30882
  follow: request.follow,
28554
30883
  counter: request.counter + 1,
28555
30884
  agent: request.agent,
@@ -28575,7 +30904,7 @@ var require_lib3 = __commonJS((exports, module) => {
28575
30904
  requestOpts.body = undefined;
28576
30905
  requestOpts.headers.delete("content-length");
28577
30906
  }
28578
- resolve(fetch2(new Request(locationURL, requestOpts)));
30907
+ resolve(fetch2(new Request2(locationURL, requestOpts)));
28579
30908
  finalize();
28580
30909
  return;
28581
30910
  }
@@ -28675,8 +31004,8 @@ var require_lib3 = __commonJS((exports, module) => {
28675
31004
  module.exports = exports = fetch2;
28676
31005
  Object.defineProperty(exports, "__esModule", { value: true });
28677
31006
  exports.default = exports;
28678
- exports.Headers = Headers;
28679
- exports.Request = Request;
31007
+ exports.Headers = Headers2;
31008
+ exports.Request = Request2;
28680
31009
  exports.Response = Response2;
28681
31010
  exports.FetchError = FetchError;
28682
31011
  exports.AbortError = AbortError;
@@ -40459,7 +42788,7 @@ var init_AxiosHeaders = __esm(() => {
40459
42788
  constructor(headers) {
40460
42789
  headers && this.set(headers);
40461
42790
  }
40462
- set(header, valueOrRewrite, rewrite) {
42791
+ set(header, valueOrRewrite, rewrite2) {
40463
42792
  const self2 = this;
40464
42793
  function setHeader(_value, _header, _rewrite) {
40465
42794
  const lHeader = normalizeHeader(_header);
@@ -40487,7 +42816,7 @@ var init_AxiosHeaders = __esm(() => {
40487
42816
  }
40488
42817
  setHeaders(obj, valueOrRewrite);
40489
42818
  } else {
40490
- header != null && setHeader(valueOrRewrite, header, rewrite);
42819
+ header != null && setHeader(valueOrRewrite, header, rewrite2);
40491
42820
  }
40492
42821
  return this;
40493
42822
  }
@@ -43635,19 +45964,19 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43635
45964
  env = utils_default.merge.call({
43636
45965
  skipUndefined: true
43637
45966
  }, globalFetchAPI, env);
43638
- const { fetch: envFetch, Request, Response: Response2 } = env;
45967
+ const { fetch: envFetch, Request: Request2, Response: Response2 } = env;
43639
45968
  const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
43640
- const isRequestSupported = isFunction2(Request);
45969
+ const isRequestSupported = isFunction2(Request2);
43641
45970
  const isResponseSupported = isFunction2(Response2);
43642
45971
  if (!isFetchSupported) {
43643
45972
  return false;
43644
45973
  }
43645
45974
  const isReadableStreamSupported = isFetchSupported && isFunction2(ReadableStream2);
43646
- const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder2) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
45975
+ const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder2) : async (str) => new Uint8Array(await new Request2(str).arrayBuffer()));
43647
45976
  const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
43648
45977
  let duplexAccessed = false;
43649
45978
  const body = new ReadableStream2;
43650
- const hasContentType = new Request(platform_default.origin, {
45979
+ const hasContentType = new Request2(platform_default.origin, {
43651
45980
  body,
43652
45981
  method: "POST",
43653
45982
  get duplex() {
@@ -43681,7 +46010,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43681
46010
  return body.size;
43682
46011
  }
43683
46012
  if (utils_default.isSpecCompliantForm(body)) {
43684
- const _request = new Request(platform_default.origin, {
46013
+ const _request = new Request2(platform_default.origin, {
43685
46014
  method: "POST",
43686
46015
  body
43687
46016
  });
@@ -43726,7 +46055,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43726
46055
  let requestContentLength;
43727
46056
  try {
43728
46057
  if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
43729
- let _request = new Request(url2, {
46058
+ let _request = new Request2(url2, {
43730
46059
  method: "POST",
43731
46060
  body: data,
43732
46061
  duplex: "half"
@@ -43743,7 +46072,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43743
46072
  if (!utils_default.isString(withCredentials)) {
43744
46073
  withCredentials = withCredentials ? "include" : "omit";
43745
46074
  }
43746
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
46075
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request2.prototype;
43747
46076
  const resolvedOptions = {
43748
46077
  ...fetchOptions,
43749
46078
  signal: composedSignal,
@@ -43753,7 +46082,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43753
46082
  duplex: "half",
43754
46083
  credentials: isCredentialsSupported ? withCredentials : undefined
43755
46084
  };
43756
- request = isRequestSupported && new Request(url2, resolvedOptions);
46085
+ request = isRequestSupported && new Request2(url2, resolvedOptions);
43757
46086
  let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
43758
46087
  const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
43759
46088
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
@@ -43793,8 +46122,8 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43793
46122
  };
43794
46123
  }, seedCache, getFetch = (config) => {
43795
46124
  let env = config && config.env || {};
43796
- const { fetch: fetch2, Request, Response: Response2 } = env;
43797
- const seeds = [Request, Response2, fetch2];
46125
+ const { fetch: fetch2, Request: Request2, Response: Response2 } = env;
46126
+ const seeds = [Request2, Response2, fetch2];
43798
46127
  let len2 = seeds.length, i2 = len2, seed, target, map = seedCache;
43799
46128
  while (i2--) {
43800
46129
  seed = seeds[i2];
@@ -43815,8 +46144,8 @@ var init_fetch = __esm(() => {
43815
46144
  init_settle();
43816
46145
  DEFAULT_CHUNK_SIZE = 64 * 1024;
43817
46146
  ({ isFunction: isFunction2 } = utils_default);
43818
- globalFetchAPI = (({ Request, Response: Response2 }) => ({
43819
- Request,
46147
+ globalFetchAPI = (({ Request: Request2, Response: Response2 }) => ({
46148
+ Request: Request2,
43820
46149
  Response: Response2
43821
46150
  }))(utils_default.global);
43822
46151
  ({ ReadableStream: ReadableStream2, TextEncoder: TextEncoder2 } = utils_default.global);
@@ -47339,13 +49668,13 @@ class ZipHandler {
47339
49668
  if (entries) {
47340
49669
  return this.iterateOverCentralDirectory(entries, fileCb);
47341
49670
  }
47342
- let stop = false;
49671
+ let stop2 = false;
47343
49672
  do {
47344
49673
  const zipHeader = await this.readLocalFileHeader();
47345
49674
  if (!zipHeader)
47346
49675
  break;
47347
49676
  const next = fileCb(zipHeader);
47348
- stop = !!next.stop;
49677
+ stop2 = !!next.stop;
47349
49678
  let fileData;
47350
49679
  await this.tokenizer.ignore(zipHeader.extraFieldLength);
47351
49680
  if (zipHeader.dataDescriptor && zipHeader.compressedSize === 0) {
@@ -47387,7 +49716,7 @@ class ZipHandler {
47387
49716
  throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - DataDescriptor.len}`);
47388
49717
  }
47389
49718
  }
47390
- } while (!stop);
49719
+ } while (!stop2);
47391
49720
  }
47392
49721
  async iterateOverCentralDirectory(entries, fileCb) {
47393
49722
  for (const fileHeader of entries) {
@@ -50103,7 +52432,7 @@ var init_core2 = __esm(() => {
50103
52432
  return callback(uncompressedData);
50104
52433
  };
50105
52434
  ZipHandler.prototype.unzip = async function(fileCallback) {
50106
- let stop = false;
52435
+ let stop2 = false;
50107
52436
  let zipEntryCount = 0;
50108
52437
  const zipScanStart = this.tokenizer.position;
50109
52438
  this.knownSizeDescriptorScannedBytes = 0;
@@ -50120,7 +52449,7 @@ var init_core2 = __esm(() => {
50120
52449
  throw new Error(`ZIP entry count exceeds ${maximumZipEntryCount}`);
50121
52450
  }
50122
52451
  const next = fileCallback(zipHeader);
50123
- stop = Boolean(next.stop);
52452
+ stop2 = Boolean(next.stop);
50124
52453
  await this.tokenizer.ignore(zipHeader.extraFieldLength);
50125
52454
  const fileData = await readZipEntryData(this, zipHeader, {
50126
52455
  shouldBuffer: Boolean(next.handler),
@@ -50139,7 +52468,7 @@ var init_core2 = __esm(() => {
50139
52468
  if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
50140
52469
  throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
50141
52470
  }
50142
- } while (!stop);
52471
+ } while (!stop2);
50143
52472
  };
50144
52473
  supportedExtensions = new Set(extensions);
50145
52474
  supportedMimeTypes = new Set(mimeTypes);
@@ -51057,11 +53386,11 @@ __export(exports_register_agent, {
51057
53386
  registerAgent: () => registerAgent
51058
53387
  });
51059
53388
  async function createDefaultDeps7() {
51060
- const client2 = await getConvexClient();
53389
+ const client4 = await getConvexClient();
51061
53390
  return {
51062
53391
  backend: {
51063
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
51064
- query: (endpoint, args) => client2.query(endpoint, args)
53392
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
53393
+ query: (endpoint, args) => client4.query(endpoint, args)
51065
53394
  },
51066
53395
  session: {
51067
53396
  getSessionId,
@@ -51072,7 +53401,7 @@ async function createDefaultDeps7() {
51072
53401
  }
51073
53402
  async function registerAgent(chatroomId, options, deps) {
51074
53403
  const d = deps ?? await createDefaultDeps7();
51075
- const { role, type } = options;
53404
+ const { role, type, allowTypeChange } = options;
51076
53405
  const sessionId = d.session.getSessionId();
51077
53406
  if (!sessionId) {
51078
53407
  const otherUrls = d.session.getOtherSessionUrls();
@@ -51117,11 +53446,10 @@ async function registerAgent(chatroomId, options, deps) {
51117
53446
  }
51118
53447
  const config = loadMachineConfig();
51119
53448
  try {
51120
- await d.backend.mutation(api.machines.recordAgentRegistered, {
53449
+ await d.backend.mutation(api.machines.recordRemoteAgentRegistered, {
51121
53450
  sessionId,
51122
53451
  chatroomId,
51123
53452
  role,
51124
- agentType: "remote",
51125
53453
  machineId
51126
53454
  });
51127
53455
  } catch {}
@@ -51130,11 +53458,11 @@ async function registerAgent(chatroomId, options, deps) {
51130
53458
  console.log(` Working directory: ${process.cwd()}`);
51131
53459
  } else {
51132
53460
  try {
51133
- await d.backend.mutation(api.machines.saveTeamAgentConfig, {
53461
+ await d.backend.mutation(api.machines.recordCustomAgentRegistered, {
51134
53462
  sessionId,
51135
53463
  chatroomId,
51136
53464
  role,
51137
- type: "custom"
53465
+ allowTypeChange
51138
53466
  });
51139
53467
  console.log(`✅ Registered as custom agent for role "${role}"`);
51140
53468
  } catch (error) {
@@ -51523,7 +53851,7 @@ __export(exports_get_next_task, {
51523
53851
  GetNextTaskSession: () => GetNextTaskSession
51524
53852
  });
51525
53853
  async function getNextTask(chatroomId, options) {
51526
- const client2 = await getConvexClient();
53854
+ const client4 = await getConvexClient();
51527
53855
  const { role, silent } = options;
51528
53856
  const convexUrl = getConvexUrl();
51529
53857
  const cliEnvPrefix = getCliEnvPrefix(convexUrl);
@@ -51556,7 +53884,7 @@ async function getNextTask(chatroomId, options) {
51556
53884
  }
51557
53885
  let chatroom;
51558
53886
  try {
51559
- chatroom = await client2.query(api.chatrooms.get, {
53887
+ chatroom = await client4.query(api.chatrooms.get, {
51560
53888
  sessionId,
51561
53889
  chatroomId
51562
53890
  });
@@ -51574,14 +53902,14 @@ async function getNextTask(chatroomId, options) {
51574
53902
  const connectionId = `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
51575
53903
  let participantAgentType;
51576
53904
  try {
51577
- const teamConfigs = await client2.query(api.machines.getTeamAgentConfigs, {
53905
+ const teamConfigs = await client4.query(api.machines.getTeamAgentConfigs, {
51578
53906
  sessionId,
51579
53907
  chatroomId
51580
53908
  });
51581
53909
  const roleConfig = teamConfigs?.find((c) => c.role.toLowerCase() === role.toLowerCase());
51582
53910
  participantAgentType = roleConfig?.type;
51583
53911
  } catch {}
51584
- await client2.mutation(api.participants.join, {
53912
+ await client4.mutation(api.participants.join, {
51585
53913
  sessionId,
51586
53914
  chatroomId,
51587
53915
  role,
@@ -51594,7 +53922,7 @@ async function getNextTask(chatroomId, options) {
51594
53922
  console.log(`[${connectionTime}] ⏳ Connecting to chatroom as "${role}"...`);
51595
53923
  }
51596
53924
  try {
51597
- const initPromptResult = await client2.query(api.messages.getInitPrompt, {
53925
+ const initPromptResult = await client4.query(api.messages.getInitPrompt, {
51598
53926
  sessionId,
51599
53927
  chatroomId,
51600
53928
  role,
@@ -51632,7 +53960,7 @@ async function getNextTask(chatroomId, options) {
51632
53960
  sessionId,
51633
53961
  connectionId,
51634
53962
  cliEnvPrefix,
51635
- client: client2
53963
+ client: client4
51636
53964
  });
51637
53965
  await session.start();
51638
53966
  }
@@ -51653,11 +53981,11 @@ __export(exports_classify, {
51653
53981
  classify: () => classify
51654
53982
  });
51655
53983
  async function createDefaultDeps8() {
51656
- const client2 = await getConvexClient();
53984
+ const client4 = await getConvexClient();
51657
53985
  return {
51658
53986
  backend: {
51659
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
51660
- query: (endpoint, args) => client2.query(endpoint, args)
53987
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
53988
+ query: (endpoint, args) => client4.query(endpoint, args)
51661
53989
  },
51662
53990
  session: {
51663
53991
  getSessionId,
@@ -51937,11 +54265,11 @@ __export(exports_handoff, {
51937
54265
  handoff: () => handoff
51938
54266
  });
51939
54267
  async function createDefaultDeps9() {
51940
- const client2 = await getConvexClient();
54268
+ const client4 = await getConvexClient();
51941
54269
  return {
51942
54270
  backend: {
51943
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
51944
- query: (endpoint, args) => client2.query(endpoint, args)
54271
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
54272
+ query: (endpoint, args) => client4.query(endpoint, args)
51945
54273
  },
51946
54274
  session: {
51947
54275
  getSessionId,
@@ -52142,11 +54470,11 @@ __export(exports_report_progress, {
52142
54470
  reportProgress: () => reportProgress
52143
54471
  });
52144
54472
  async function createDefaultDeps10() {
52145
- const client2 = await getConvexClient();
54473
+ const client4 = await getConvexClient();
52146
54474
  return {
52147
54475
  backend: {
52148
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
52149
- query: (endpoint, args) => client2.query(endpoint, args)
54476
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
54477
+ query: (endpoint, args) => client4.query(endpoint, args)
52150
54478
  },
52151
54479
  session: {
52152
54480
  getSessionId,
@@ -52257,12 +54585,12 @@ __export(exports_backlog, {
52257
54585
  import { createHash } from "node:crypto";
52258
54586
  import * as nodePath from "node:path";
52259
54587
  async function createDefaultDeps11() {
52260
- const client2 = await getConvexClient();
54588
+ const client4 = await getConvexClient();
52261
54589
  const fs6 = await import("node:fs/promises");
52262
54590
  return {
52263
54591
  backend: {
52264
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
52265
- query: (endpoint, args) => client2.query(endpoint, args)
54592
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
54593
+ query: (endpoint, args) => client4.query(endpoint, args)
52266
54594
  },
52267
54595
  session: {
52268
54596
  getSessionId,
@@ -52886,12 +55214,12 @@ var exports_file_content = {};
52886
55214
  __export(exports_file_content, {
52887
55215
  readFileContent: () => readFileContent
52888
55216
  });
52889
- import { readFileSync as readFileSync5 } from "fs";
52890
- import { resolve as resolve2 } from "path";
55217
+ import { readFileSync as readFileSync6 } from "node:fs";
55218
+ import { resolve as resolve2 } from "node:path";
52891
55219
  function readFileContent(filePath, optionName) {
52892
55220
  const absolutePath = resolve2(process.cwd(), filePath);
52893
55221
  try {
52894
- return readFileSync5(absolutePath, "utf-8");
55222
+ return readFileSync6(absolutePath, "utf-8");
52895
55223
  } catch (err) {
52896
55224
  const nodeErr = err;
52897
55225
  throw new Error(`Cannot read file for --${optionName}: ${absolutePath}
@@ -52913,11 +55241,11 @@ __export(exports_workflow, {
52913
55241
  completeStep: () => completeStep
52914
55242
  });
52915
55243
  async function createDefaultDeps12() {
52916
- const client2 = await getConvexClient();
55244
+ const client4 = await getConvexClient();
52917
55245
  return {
52918
55246
  backend: {
52919
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
52920
- query: (endpoint, args) => client2.query(endpoint, args)
55247
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
55248
+ query: (endpoint, args) => client4.query(endpoint, args)
52921
55249
  },
52922
55250
  session: {
52923
55251
  getSessionId,
@@ -53405,11 +55733,11 @@ __export(exports_read, {
53405
55733
  taskRead: () => taskRead
53406
55734
  });
53407
55735
  async function createDefaultDeps13() {
53408
- const client2 = await getConvexClient();
55736
+ const client4 = await getConvexClient();
53409
55737
  return {
53410
55738
  backend: {
53411
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
53412
- query: (endpoint, args) => client2.query(endpoint, args)
55739
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
55740
+ query: (endpoint, args) => client4.query(endpoint, args)
53413
55741
  },
53414
55742
  session: {
53415
55743
  getSessionId,
@@ -53533,11 +55861,11 @@ __export(exports_skill, {
53533
55861
  activateSkill: () => activateSkill
53534
55862
  });
53535
55863
  async function createDefaultDeps14() {
53536
- const client2 = await getConvexClient();
55864
+ const client4 = await getConvexClient();
53537
55865
  return {
53538
55866
  backend: {
53539
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
53540
- query: (endpoint, args) => client2.query(endpoint, args)
55867
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
55868
+ query: (endpoint, args) => client4.query(endpoint, args)
53541
55869
  },
53542
55870
  session: {
53543
55871
  getSessionId,
@@ -53614,11 +55942,11 @@ __export(exports_messages, {
53614
55942
  listBySenderRole: () => listBySenderRole
53615
55943
  });
53616
55944
  async function createDefaultDeps15() {
53617
- const client2 = await getConvexClient();
55945
+ const client4 = await getConvexClient();
53618
55946
  return {
53619
55947
  backend: {
53620
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
53621
- query: (endpoint, args) => client2.query(endpoint, args)
55948
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
55949
+ query: (endpoint, args) => client4.query(endpoint, args)
53622
55950
  },
53623
55951
  session: {
53624
55952
  getSessionId,
@@ -53769,11 +56097,11 @@ __export(exports_context, {
53769
56097
  inspectContext: () => inspectContext
53770
56098
  });
53771
56099
  async function createDefaultDeps16() {
53772
- const client2 = await getConvexClient();
56100
+ const client4 = await getConvexClient();
53773
56101
  return {
53774
56102
  backend: {
53775
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
53776
- query: (endpoint, args) => client2.query(endpoint, args)
56103
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
56104
+ query: (endpoint, args) => client4.query(endpoint, args)
53777
56105
  },
53778
56106
  session: {
53779
56107
  getSessionId,
@@ -54064,11 +56392,11 @@ __export(exports_guidelines, {
54064
56392
  listGuidelineTypes: () => listGuidelineTypes
54065
56393
  });
54066
56394
  async function createDefaultDeps17() {
54067
- const client2 = await getConvexClient();
56395
+ const client4 = await getConvexClient();
54068
56396
  return {
54069
56397
  backend: {
54070
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
54071
- query: (endpoint, args) => client2.query(endpoint, args)
56398
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
56399
+ query: (endpoint, args) => client4.query(endpoint, args)
54072
56400
  },
54073
56401
  session: {
54074
56402
  getSessionId,
@@ -54156,11 +56484,11 @@ __export(exports_artifact, {
54156
56484
  createArtifact: () => createArtifact
54157
56485
  });
54158
56486
  async function createDefaultDeps18() {
54159
- const client2 = await getConvexClient();
56487
+ const client4 = await getConvexClient();
54160
56488
  return {
54161
56489
  backend: {
54162
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
54163
- query: (endpoint, args) => client2.query(endpoint, args)
56490
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
56491
+ query: (endpoint, args) => client4.query(endpoint, args)
54164
56492
  },
54165
56493
  session: {
54166
56494
  getSessionId,
@@ -54335,11 +56663,11 @@ __export(exports_get_system_prompt, {
54335
56663
  getSystemPrompt: () => getSystemPrompt
54336
56664
  });
54337
56665
  async function createDefaultDeps19() {
54338
- const client2 = await getConvexClient();
56666
+ const client4 = await getConvexClient();
54339
56667
  return {
54340
56668
  backend: {
54341
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
54342
- query: (endpoint, args) => client2.query(endpoint, args)
56669
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
56670
+ query: (endpoint, args) => client4.query(endpoint, args)
54343
56671
  },
54344
56672
  session: {
54345
56673
  getSessionId,
@@ -54397,10 +56725,10 @@ __export(exports_telegram, {
54397
56725
  sendMessage: () => sendMessage
54398
56726
  });
54399
56727
  async function createDefaultDeps20() {
54400
- const client2 = await getConvexClient();
56728
+ const client4 = await getConvexClient();
54401
56729
  return {
54402
56730
  backend: {
54403
- action: (endpoint, args) => client2.action(endpoint, args)
56731
+ action: (endpoint, args) => client4.action(endpoint, args)
54404
56732
  },
54405
56733
  session: {
54406
56734
  getSessionId,
@@ -54562,9 +56890,9 @@ var init_on_request_stop_agent = () => {};
54562
56890
 
54563
56891
  // src/commands/machine/pid.ts
54564
56892
  import { createHash as createHash2 } from "node:crypto";
54565
- import { existsSync as existsSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync4 } from "node:fs";
54566
- import { homedir as homedir4 } from "node:os";
54567
- import { join as join7 } from "node:path";
56893
+ import { existsSync as existsSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync5, unlinkSync as unlinkSync2, mkdirSync as mkdirSync5 } from "node:fs";
56894
+ import { homedir as homedir5 } from "node:os";
56895
+ import { join as join8 } from "node:path";
54568
56896
  function getUrlHash() {
54569
56897
  const url2 = getConvexUrl();
54570
56898
  return createHash2("sha256").update(url2).digest("hex").substring(0, 8);
@@ -54573,12 +56901,12 @@ function getPidFileName() {
54573
56901
  return `daemon-${getUrlHash()}.pid`;
54574
56902
  }
54575
56903
  function ensureChatroomDir2() {
54576
- if (!existsSync4(CHATROOM_DIR5)) {
54577
- mkdirSync4(CHATROOM_DIR5, { recursive: true, mode: 448 });
56904
+ if (!existsSync5(CHATROOM_DIR4)) {
56905
+ mkdirSync5(CHATROOM_DIR4, { recursive: true, mode: 448 });
54578
56906
  }
54579
56907
  }
54580
56908
  function getPidFilePath() {
54581
- return join7(CHATROOM_DIR5, getPidFileName());
56909
+ return join8(CHATROOM_DIR4, getPidFileName());
54582
56910
  }
54583
56911
  function isProcessRunning(pid) {
54584
56912
  try {
@@ -54590,11 +56918,11 @@ function isProcessRunning(pid) {
54590
56918
  }
54591
56919
  function readPid() {
54592
56920
  const pidPath = getPidFilePath();
54593
- if (!existsSync4(pidPath)) {
56921
+ if (!existsSync5(pidPath)) {
54594
56922
  return null;
54595
56923
  }
54596
56924
  try {
54597
- const content = readFileSync6(pidPath, "utf-8").trim();
56925
+ const content = readFileSync7(pidPath, "utf-8").trim();
54598
56926
  const pid = parseInt(content, 10);
54599
56927
  if (isNaN(pid) || pid <= 0) {
54600
56928
  return null;
@@ -54607,12 +56935,12 @@ function readPid() {
54607
56935
  function writePid() {
54608
56936
  ensureChatroomDir2();
54609
56937
  const pidPath = getPidFilePath();
54610
- writeFileSync4(pidPath, process.pid.toString(), "utf-8");
56938
+ writeFileSync5(pidPath, process.pid.toString(), "utf-8");
54611
56939
  }
54612
56940
  function removePid() {
54613
56941
  const pidPath = getPidFilePath();
54614
56942
  try {
54615
- if (existsSync4(pidPath)) {
56943
+ if (existsSync5(pidPath)) {
54616
56944
  unlinkSync2(pidPath);
54617
56945
  }
54618
56946
  } catch {}
@@ -54640,10 +56968,10 @@ function acquireLock() {
54640
56968
  function releaseLock() {
54641
56969
  removePid();
54642
56970
  }
54643
- var CHATROOM_DIR5;
56971
+ var CHATROOM_DIR4;
54644
56972
  var init_pid = __esm(() => {
54645
56973
  init_client2();
54646
- CHATROOM_DIR5 = join7(homedir4(), ".chatroom");
56974
+ CHATROOM_DIR4 = join8(homedir5(), ".chatroom");
54647
56975
  });
54648
56976
 
54649
56977
  // src/commands/machine/daemon-start/utils.ts
@@ -55521,20 +57849,20 @@ var init_git_heartbeat = __esm(() => {
55521
57849
 
55522
57850
  // src/infrastructure/services/workspace/workspace-resolver.ts
55523
57851
  import { readFile as readFile2, readdir, stat } from "node:fs/promises";
55524
- import { join as join8, basename, resolve as resolve3 } from "node:path";
57852
+ import { join as join9, basename, resolve as resolve3 } from "node:path";
55525
57853
  async function resolveGlobPattern(rootDir, pattern) {
55526
57854
  const cleaned = pattern.replace(/\/+$/, "");
55527
57855
  if (cleaned.includes("..")) {
55528
57856
  return [];
55529
57857
  }
55530
57858
  if (cleaned.endsWith("/*")) {
55531
- const parentDir = join8(rootDir, cleaned.slice(0, -2));
57859
+ const parentDir = join9(rootDir, cleaned.slice(0, -2));
55532
57860
  try {
55533
57861
  const entries = await readdir(parentDir, { withFileTypes: true });
55534
57862
  const dirs = [];
55535
57863
  for (const entry of entries) {
55536
57864
  if (entry.isDirectory()) {
55537
- const dirPath = join8(parentDir, entry.name);
57865
+ const dirPath = join9(parentDir, entry.name);
55538
57866
  if (resolve3(dirPath).startsWith(resolve3(rootDir))) {
55539
57867
  dirs.push(dirPath);
55540
57868
  }
@@ -55545,7 +57873,7 @@ async function resolveGlobPattern(rootDir, pattern) {
55545
57873
  return [];
55546
57874
  }
55547
57875
  } else {
55548
- const dir = join8(rootDir, cleaned);
57876
+ const dir = join9(rootDir, cleaned);
55549
57877
  try {
55550
57878
  if (!resolve3(dir).startsWith(resolve3(rootDir)))
55551
57879
  return [];
@@ -55558,7 +57886,7 @@ async function resolveGlobPattern(rootDir, pattern) {
55558
57886
  }
55559
57887
  async function readPackageJson(dir) {
55560
57888
  try {
55561
- const content = await readFile2(join8(dir, "package.json"), "utf-8");
57889
+ const content = await readFile2(join9(dir, "package.json"), "utf-8");
55562
57890
  const pkg = JSON.parse(content);
55563
57891
  return {
55564
57892
  name: pkg.name || basename(dir),
@@ -55570,7 +57898,7 @@ async function readPackageJson(dir) {
55570
57898
  }
55571
57899
  async function readPnpmWorkspacePatterns(rootDir) {
55572
57900
  try {
55573
- const content = await readFile2(join8(rootDir, "pnpm-workspace.yaml"), "utf-8");
57901
+ const content = await readFile2(join9(rootDir, "pnpm-workspace.yaml"), "utf-8");
55574
57902
  const patterns = [];
55575
57903
  let inPackages = false;
55576
57904
  for (const line of content.split(`
@@ -55597,7 +57925,7 @@ async function readPnpmWorkspacePatterns(rootDir) {
55597
57925
  }
55598
57926
  async function readPackageJsonWorkspacePatterns(rootDir) {
55599
57927
  try {
55600
- const content = await readFile2(join8(rootDir, "package.json"), "utf-8");
57928
+ const content = await readFile2(join9(rootDir, "package.json"), "utf-8");
55601
57929
  const pkg = JSON.parse(content);
55602
57930
  if (!pkg.workspaces)
55603
57931
  return [];
@@ -55647,11 +57975,11 @@ var init_workspace_resolver = () => {};
55647
57975
  // src/infrastructure/services/workspace/command-discovery.ts
55648
57976
  import { access as access2 } from "node:fs/promises";
55649
57977
  import { readFile as readFile3 } from "node:fs/promises";
55650
- import { join as join9, relative, basename as basename2 } from "node:path";
57978
+ import { join as join10, relative, basename as basename2 } from "node:path";
55651
57979
  async function detectPackageManager(workingDir) {
55652
57980
  for (const { file, manager } of LOCKFILE_MAP) {
55653
57981
  try {
55654
- await access2(join9(workingDir, file));
57982
+ await access2(join10(workingDir, file));
55655
57983
  return manager;
55656
57984
  } catch {}
55657
57985
  }
@@ -55698,7 +58026,7 @@ async function discoverCommands(workingDir) {
55698
58026
  const turboTaskNames = [];
55699
58027
  let rootPackageName = basename2(workingDir);
55700
58028
  try {
55701
- const pkgPath = join9(workingDir, "package.json");
58029
+ const pkgPath = join10(workingDir, "package.json");
55702
58030
  const pkgContent = await readFile3(pkgPath, "utf-8");
55703
58031
  const pkg = JSON.parse(pkgContent);
55704
58032
  if (pkg.name)
@@ -55719,7 +58047,7 @@ async function discoverCommands(workingDir) {
55719
58047
  } catch {}
55720
58048
  const rootSubWorkspace = { type: "npm", path: ".", name: rootPackageName };
55721
58049
  try {
55722
- const turboPath = join9(workingDir, "turbo.json");
58050
+ const turboPath = join10(workingDir, "turbo.json");
55723
58051
  const turboContent = await readFile3(turboPath, "utf-8");
55724
58052
  const turbo = JSON.parse(turboContent);
55725
58053
  if (turbo.tasks && typeof turbo.tasks === "object") {
@@ -56654,7 +58982,7 @@ function ts() {
56654
58982
  }
56655
58983
  async function startLocalApi(ctx, port = resolvePort()) {
56656
58984
  const router = createRouter();
56657
- const server = createServer(async (req, res) => {
58985
+ const server2 = createServer(async (req, res) => {
56658
58986
  try {
56659
58987
  const localReq = await normalizeRequest(req);
56660
58988
  const localRes = await router.handleRequest(localReq, ctx);
@@ -56664,11 +58992,11 @@ async function startLocalApi(ctx, port = resolvePort()) {
56664
58992
  }
56665
58993
  });
56666
58994
  await new Promise((resolve5) => {
56667
- server.listen(port, "127.0.0.1", () => {
58995
+ server2.listen(port, "127.0.0.1", () => {
56668
58996
  console.log(`[${ts()}] \uD83C\uDF10 Local API started on http://localhost:${port}`);
56669
58997
  resolve5();
56670
58998
  });
56671
- server.on("error", (err) => {
58999
+ server2.on("error", (err) => {
56672
59000
  if (err.code === "EADDRINUSE") {
56673
59001
  console.warn(`[${ts()}] ⚠️ Local API port ${port} already in use — skipping local API`);
56674
59002
  } else {
@@ -56677,12 +59005,12 @@ async function startLocalApi(ctx, port = resolvePort()) {
56677
59005
  resolve5();
56678
59006
  });
56679
59007
  });
56680
- const stop = () => new Promise((resolve5, reject) => {
56681
- if (!server.listening) {
59008
+ const stop2 = () => new Promise((resolve5, reject) => {
59009
+ if (!server2.listening) {
56682
59010
  resolve5();
56683
59011
  return;
56684
59012
  }
56685
- server.close((err) => {
59013
+ server2.close((err) => {
56686
59014
  if (err) {
56687
59015
  reject(err);
56688
59016
  } else {
@@ -56691,10 +59019,10 @@ async function startLocalApi(ctx, port = resolvePort()) {
56691
59019
  }
56692
59020
  });
56693
59021
  });
56694
- return { stop };
59022
+ return { stop: stop2 };
56695
59023
  }
56696
59024
  var LOCAL_API_PORT = 19847;
56697
- var init_server2 = __esm(() => {
59025
+ var init_server3 = __esm(() => {
56698
59026
  init_identity();
56699
59027
  init_open_finder();
56700
59028
  init_open_github_desktop();
@@ -56704,7 +59032,7 @@ var init_server2 = __esm(() => {
56704
59032
 
56705
59033
  // src/infrastructure/local-api/index.ts
56706
59034
  var init_local_api = __esm(() => {
56707
- init_server2();
59035
+ init_server3();
56708
59036
  });
56709
59037
 
56710
59038
  // src/events/daemon/event-bus.ts
@@ -56951,6 +59279,13 @@ function resolveStopReason(code2, signal) {
56951
59279
  return "agent_process.crashed";
56952
59280
  }
56953
59281
 
59282
+ // src/infrastructure/services/remote-agents/spawn-prompt.ts
59283
+ function createSpawnPrompt(raw) {
59284
+ const trimmed = raw?.trim();
59285
+ return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_TRIGGER_PROMPT;
59286
+ }
59287
+ var DEFAULT_TRIGGER_PROMPT = "Please read your system prompt carefully and follow the Getting Started instructions.";
59288
+
56954
59289
  // src/infrastructure/services/agent-process-manager/agent-process-manager.ts
56955
59290
  function agentKey2(chatroomId, role) {
56956
59291
  return `${chatroomId}:${role.toLowerCase()}`;
@@ -57259,7 +59594,7 @@ class AgentProcessManager {
57259
59594
  try {
57260
59595
  spawnResult = await service.spawn({
57261
59596
  workingDir: opts.workingDir,
57262
- prompt: initPromptResult.initialMessage,
59597
+ prompt: createSpawnPrompt(initPromptResult.initialMessage),
57263
59598
  systemPrompt: initPromptResult.rolePrompt,
57264
59599
  model: opts.model,
57265
59600
  context: {
@@ -57474,8 +59809,8 @@ Run: chatroom auth login`);
57474
59809
  ⏳ Waiting for authentication (timeout: 5 minutes)...`);
57475
59810
  return waitForAuthentication(convexUrl);
57476
59811
  }
57477
- async function validateSession(client2, sessionId, convexUrl) {
57478
- const validation = await client2.query(api.cliAuth.validateSession, { sessionId });
59812
+ async function validateSession(client4, sessionId, convexUrl) {
59813
+ const validation = await client4.query(api.cliAuth.validateSession, { sessionId });
57479
59814
  if (validation.valid) {
57480
59815
  return sessionId;
57481
59816
  }
@@ -57486,7 +59821,7 @@ Run: chatroom auth login`);
57486
59821
  ⏳ Waiting for re-authentication (timeout: 5 minutes)...`);
57487
59822
  const newSessionId2 = await waitForAuthentication(convexUrl);
57488
59823
  const typedNewSession = newSessionId2;
57489
- const revalidation = await client2.query(api.cliAuth.validateSession, {
59824
+ const revalidation = await client4.query(api.cliAuth.validateSession, {
57490
59825
  sessionId: typedNewSession
57491
59826
  });
57492
59827
  if (!revalidation.valid) {
@@ -57497,15 +59832,15 @@ Run: chatroom auth login`);
57497
59832
  return typedNewSession;
57498
59833
  }
57499
59834
  function setupMachine() {
57500
- ensureMachineRegistered();
59835
+ ensureMachineRegistered({ allowCreate: true });
57501
59836
  const config3 = loadMachineConfig();
57502
59837
  return config3;
57503
59838
  }
57504
- async function registerCapabilities(client2, sessionId, config3, agentServices) {
59839
+ async function registerCapabilities(client4, sessionId, config3, agentServices) {
57505
59840
  const { machineId } = config3;
57506
59841
  const availableModels = await discoverModels(agentServices);
57507
59842
  try {
57508
- await client2.mutation(api.machines.register, {
59843
+ await client4.mutation(api.machines.register, {
57509
59844
  sessionId,
57510
59845
  machineId,
57511
59846
  hostname: config3.hostname,
@@ -57519,9 +59854,9 @@ async function registerCapabilities(client2, sessionId, config3, agentServices)
57519
59854
  }
57520
59855
  return availableModels;
57521
59856
  }
57522
- async function connectDaemon(client2, sessionId, machineId, convexUrl) {
59857
+ async function connectDaemon(client4, sessionId, machineId, convexUrl) {
57523
59858
  try {
57524
- await client2.mutation(api.machines.updateDaemonStatus, {
59859
+ await client4.mutation(api.machines.updateDaemonStatus, {
57525
59860
  sessionId,
57526
59861
  machineId,
57527
59862
  connected: true
@@ -57572,25 +59907,25 @@ async function initDaemon() {
57572
59907
  }
57573
59908
  const convexUrl = getConvexUrl();
57574
59909
  const sessionId = await validateAuthentication(convexUrl);
57575
- const client2 = await getConvexClient();
59910
+ const client4 = await getConvexClient();
57576
59911
  let typedSessionId = sessionId;
57577
59912
  let consecutiveFailures = 0;
57578
59913
  while (true) {
57579
59914
  try {
57580
- typedSessionId = await validateSession(client2, typedSessionId, convexUrl);
59915
+ typedSessionId = await validateSession(client4, typedSessionId, convexUrl);
57581
59916
  const config3 = setupMachine();
57582
59917
  const { machineId } = config3;
57583
59918
  initHarnessRegistry();
57584
59919
  const agentServices = new Map(getAllHarnesses().map((s) => [s.id, s]));
57585
- const availableModels = await registerCapabilities(client2, typedSessionId, config3, agentServices);
57586
- await connectDaemon(client2, typedSessionId, machineId, convexUrl);
59920
+ const availableModels = await registerCapabilities(client4, typedSessionId, config3, agentServices);
59921
+ await connectDaemon(client4, typedSessionId, machineId, convexUrl);
57587
59922
  if (consecutiveFailures > 0) {
57588
59923
  console.log(`[${formatTimestamp()}] ✅ Backend reachable again at ${convexUrl}`);
57589
59924
  consecutiveFailures = 0;
57590
59925
  }
57591
59926
  const deps = createDefaultDeps21();
57592
- deps.backend.mutation = (endpoint, args) => client2.mutation(endpoint, args);
57593
- deps.backend.query = (endpoint, args) => client2.query(endpoint, args);
59927
+ deps.backend.mutation = (endpoint, args) => client4.mutation(endpoint, args);
59928
+ deps.backend.query = (endpoint, args) => client4.query(endpoint, args);
57594
59929
  deps.agentProcessManager = new AgentProcessManager({
57595
59930
  agentServices,
57596
59931
  backend: deps.backend,
@@ -57606,7 +59941,7 @@ async function initDaemon() {
57606
59941
  });
57607
59942
  const events = new DaemonEventBus;
57608
59943
  const ctx = {
57609
- client: client2,
59944
+ client: client4,
57610
59945
  sessionId: typedSessionId,
57611
59946
  machineId,
57612
59947
  config: config3,
@@ -58181,12 +60516,12 @@ async function isChatroomInstalledDefault() {
58181
60516
  }
58182
60517
  }
58183
60518
  async function createDefaultDeps22() {
58184
- const client2 = await getConvexClient();
60519
+ const client4 = await getConvexClient();
58185
60520
  const fs6 = await import("fs/promises");
58186
60521
  return {
58187
60522
  backend: {
58188
- mutation: (endpoint, args) => client2.mutation(endpoint, args),
58189
- query: (endpoint, args) => client2.query(endpoint, args)
60523
+ mutation: (endpoint, args) => client4.mutation(endpoint, args),
60524
+ query: (endpoint, args) => client4.query(endpoint, args)
58190
60525
  },
58191
60526
  session: {
58192
60527
  getSessionId,
@@ -58611,8 +60946,8 @@ var exports_lifecycle_heartbeat = {};
58611
60946
  __export(exports_lifecycle_heartbeat, {
58612
60947
  sendLifecycleHeartbeat: () => sendLifecycleHeartbeat
58613
60948
  });
58614
- function sendLifecycleHeartbeat(client2, opts) {
58615
- withRetry(() => client2.mutation(api.participants.join, {
60949
+ function sendLifecycleHeartbeat(client4, opts) {
60950
+ withRetry(() => client4.mutation(api.participants.join, {
58616
60951
  sessionId: opts.sessionId,
58617
60952
  chatroomId: opts.chatroomId,
58618
60953
  role: opts.role,
@@ -58700,7 +61035,7 @@ toolCommand.command("parse-pdf").description("Parse a PDF file and extract text
58700
61035
  console.log(result.message);
58701
61036
  process.exit(result.success ? 0 : 1);
58702
61037
  });
58703
- program2.command("register-agent").description("Register agent type for a chatroom role").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Role to register as (e.g., builder, reviewer)").requiredOption("--type <type>", "Agent type: remote or custom").action(async (options) => {
61038
+ program2.command("register-agent").description("Register agent type for a chatroom role").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Role to register as (e.g., builder, reviewer)").requiredOption("--type <type>", "Agent type: remote or custom").option("--allow-type-change", "Required for --type=custom when the role is currently bound to a remote machine; explicitly opts into clearing the existing binding.").action(async (options) => {
58704
61039
  await maybeRequireAuth();
58705
61040
  if (options.type !== "remote" && options.type !== "custom") {
58706
61041
  console.error(`❌ Invalid agent type: "${options.type}". Must be "remote" or "custom".`);
@@ -58709,7 +61044,8 @@ program2.command("register-agent").description("Register agent type for a chatro
58709
61044
  const { registerAgent: registerAgent2 } = await Promise.resolve().then(() => (init_register_agent(), exports_register_agent));
58710
61045
  await registerAgent2(options.chatroomId, {
58711
61046
  role: options.role,
58712
- type: options.type
61047
+ type: options.type,
61048
+ allowTypeChange: options.allowTypeChange
58713
61049
  });
58714
61050
  });
58715
61051
  program2.command("get-next-task").description("Join a chatroom and get the next task").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Role to join as (e.g., builder, reviewer)").action(async (options) => {
@@ -59184,10 +61520,10 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
59184
61520
  const sessionId = getSessionId2();
59185
61521
  if (!sessionId)
59186
61522
  return;
59187
- const client2 = await getConvexClient2();
59188
- sendLifecycleHeartbeat2(client2, { sessionId, chatroomId, role, action: actionCommand.name() });
61523
+ const client4 = await getConvexClient2();
61524
+ sendLifecycleHeartbeat2(client4, { sessionId, chatroomId, role, action: actionCommand.name() });
59189
61525
  });
59190
61526
  program2.parse();
59191
61527
 
59192
- //# debugId=590723263840AC7564756E2164756E21
61528
+ //# debugId=29314BC73A4B833B64756E2164756E21
59193
61529
  //# sourceMappingURL=index.js.map