@hueyexe/opencode-ensemble 0.5.0 → 0.6.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
@@ -1,16 +1,12 @@
1
1
  // @bun
2
2
  var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
3
  var __export = (target, all) => {
8
4
  for (var name in all)
9
5
  __defProp(target, name, {
10
6
  get: all[name],
11
7
  enumerable: true,
12
8
  configurable: true,
13
- set: __exportSetter.bind(all, name)
9
+ set: (newValue) => all[name] = () => newValue
14
10
  });
15
11
  };
16
12
 
@@ -12334,228 +12330,3218 @@ function tool(input) {
12334
12330
  return input;
12335
12331
  }
12336
12332
  tool.schema = exports_external;
12337
- // src/index.ts
12338
- import path3 from "path";
12339
- import { mkdirSync } from "fs";
12340
-
12341
- // src/db.ts
12342
- import { Database } from "bun:sqlite";
12343
- import path from "path";
12344
-
12345
- // src/schema.ts
12346
- var MIGRATIONS = [
12347
- `
12348
- CREATE TABLE IF NOT EXISTS team (
12349
- id TEXT PRIMARY KEY,
12350
- name TEXT NOT NULL UNIQUE,
12351
- lead_session_id TEXT NOT NULL,
12352
- status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active', 'archived')),
12353
- delegate INTEGER NOT NULL DEFAULT 0,
12354
- time_created INTEGER NOT NULL,
12355
- time_updated INTEGER NOT NULL
12356
- );
12357
- CREATE INDEX IF NOT EXISTS team_lead_idx ON team(lead_session_id);
12358
- CREATE INDEX IF NOT EXISTS team_status_idx ON team(status);
12359
-
12360
- CREATE TABLE IF NOT EXISTS team_member (
12361
- team_id TEXT NOT NULL REFERENCES team(id) ON DELETE CASCADE,
12362
- name TEXT NOT NULL,
12363
- session_id TEXT NOT NULL,
12364
- agent TEXT NOT NULL,
12365
- status TEXT NOT NULL DEFAULT 'ready'
12366
- CHECK(status IN ('ready', 'busy', 'shutdown_requested', 'shutdown', 'error')),
12367
- execution_status TEXT NOT NULL DEFAULT 'idle'
12368
- CHECK(execution_status IN ('idle', 'starting', 'running',
12369
- 'cancel_requested', 'cancelling', 'cancelled',
12370
- 'completing', 'completed', 'failed', 'timed_out')),
12371
- model TEXT,
12372
- prompt TEXT,
12373
- time_created INTEGER NOT NULL,
12374
- time_updated INTEGER NOT NULL,
12375
- PRIMARY KEY (team_id, name)
12376
- );
12377
- CREATE INDEX IF NOT EXISTS team_member_session_idx ON team_member(session_id);
12378
- CREATE INDEX IF NOT EXISTS team_member_status_idx ON team_member(team_id, status);
12333
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
12334
+ var createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
12335
+ let lastEventId;
12336
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
12337
+ const createStream = async function* () {
12338
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
12339
+ let attempt = 0;
12340
+ const signal = options.signal ?? new AbortController().signal;
12341
+ while (true) {
12342
+ if (signal.aborted)
12343
+ break;
12344
+ attempt++;
12345
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
12346
+ if (lastEventId !== undefined) {
12347
+ headers.set("Last-Event-ID", lastEventId);
12348
+ }
12349
+ try {
12350
+ const requestInit = {
12351
+ redirect: "follow",
12352
+ ...options,
12353
+ body: options.serializedBody,
12354
+ headers,
12355
+ signal
12356
+ };
12357
+ let request = new Request(url2, requestInit);
12358
+ if (onRequest) {
12359
+ request = await onRequest(url2, requestInit);
12360
+ }
12361
+ const _fetch = options.fetch ?? globalThis.fetch;
12362
+ const response = await _fetch(request);
12363
+ if (!response.ok)
12364
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
12365
+ if (!response.body)
12366
+ throw new Error("No body in SSE response");
12367
+ const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
12368
+ let buffer = "";
12369
+ const abortHandler = () => {
12370
+ try {
12371
+ reader.cancel();
12372
+ } catch {}
12373
+ };
12374
+ signal.addEventListener("abort", abortHandler);
12375
+ try {
12376
+ while (true) {
12377
+ const { done, value } = await reader.read();
12378
+ if (done)
12379
+ break;
12380
+ buffer += value;
12381
+ buffer = buffer.replace(/\r\n/g, `
12382
+ `).replace(/\r/g, `
12383
+ `);
12384
+ const chunks = buffer.split(`
12379
12385
 
12380
- CREATE TABLE IF NOT EXISTS team_task (
12381
- id TEXT PRIMARY KEY,
12382
- team_id TEXT NOT NULL REFERENCES team(id) ON DELETE CASCADE,
12383
- content TEXT NOT NULL,
12384
- status TEXT NOT NULL DEFAULT 'pending'
12385
- CHECK(status IN ('pending', 'in_progress', 'completed', 'cancelled', 'blocked')),
12386
- priority TEXT NOT NULL DEFAULT 'medium'
12387
- CHECK(priority IN ('high', 'medium', 'low')),
12388
- assignee TEXT,
12389
- depends_on TEXT,
12390
- time_created INTEGER NOT NULL,
12391
- time_updated INTEGER NOT NULL
12392
- );
12393
- CREATE INDEX IF NOT EXISTS team_task_team_idx ON team_task(team_id);
12394
- CREATE INDEX IF NOT EXISTS team_task_assignee_idx ON team_task(assignee);
12395
- CREATE INDEX IF NOT EXISTS team_task_status_idx ON team_task(team_id, status);
12386
+ `);
12387
+ buffer = chunks.pop() ?? "";
12388
+ for (const chunk of chunks) {
12389
+ const lines = chunk.split(`
12390
+ `);
12391
+ const dataLines = [];
12392
+ let eventName;
12393
+ for (const line of lines) {
12394
+ if (line.startsWith("data:")) {
12395
+ dataLines.push(line.replace(/^data:\s*/, ""));
12396
+ } else if (line.startsWith("event:")) {
12397
+ eventName = line.replace(/^event:\s*/, "");
12398
+ } else if (line.startsWith("id:")) {
12399
+ lastEventId = line.replace(/^id:\s*/, "");
12400
+ } else if (line.startsWith("retry:")) {
12401
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
12402
+ if (!Number.isNaN(parsed)) {
12403
+ retryDelay = parsed;
12404
+ }
12405
+ }
12406
+ }
12407
+ let data;
12408
+ let parsedJson = false;
12409
+ if (dataLines.length) {
12410
+ const rawData = dataLines.join(`
12411
+ `);
12412
+ try {
12413
+ data = JSON.parse(rawData);
12414
+ parsedJson = true;
12415
+ } catch {
12416
+ data = rawData;
12417
+ }
12418
+ }
12419
+ if (parsedJson) {
12420
+ if (responseValidator) {
12421
+ await responseValidator(data);
12422
+ }
12423
+ if (responseTransformer) {
12424
+ data = await responseTransformer(data);
12425
+ }
12426
+ }
12427
+ onSseEvent?.({
12428
+ data,
12429
+ event: eventName,
12430
+ id: lastEventId,
12431
+ retry: retryDelay
12432
+ });
12433
+ if (dataLines.length) {
12434
+ yield data;
12435
+ }
12436
+ }
12437
+ }
12438
+ } finally {
12439
+ signal.removeEventListener("abort", abortHandler);
12440
+ reader.releaseLock();
12441
+ }
12442
+ break;
12443
+ } catch (error45) {
12444
+ onSseError?.(error45);
12445
+ if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
12446
+ break;
12447
+ }
12448
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
12449
+ await sleep(backoff);
12450
+ }
12451
+ }
12452
+ };
12453
+ const stream = createStream();
12454
+ return { stream };
12455
+ };
12396
12456
 
12397
- CREATE TABLE IF NOT EXISTS team_message (
12398
- id TEXT PRIMARY KEY,
12399
- team_id TEXT NOT NULL REFERENCES team(id) ON DELETE CASCADE,
12400
- from_name TEXT NOT NULL,
12401
- to_name TEXT,
12402
- content TEXT NOT NULL,
12403
- delivered INTEGER NOT NULL DEFAULT 0,
12404
- time_created INTEGER NOT NULL
12405
- );
12406
- CREATE INDEX IF NOT EXISTS team_message_team_idx ON team_message(team_id);
12407
- CREATE INDEX IF NOT EXISTS team_message_to_idx ON team_message(to_name);
12408
- CREATE INDEX IF NOT EXISTS team_message_undelivered_idx ON team_message(team_id, delivered)
12409
- WHERE delivered = 0;
12410
- `,
12411
- `ALTER TABLE team_message ADD COLUMN read INTEGER NOT NULL DEFAULT 0;
12412
- CREATE INDEX IF NOT EXISTS team_message_unread_idx ON team_message(team_id, read) WHERE read = 0;`,
12413
- `ALTER TABLE team_member ADD COLUMN worktree_dir TEXT;
12414
- ALTER TABLE team_member ADD COLUMN worktree_branch TEXT;`,
12415
- `ALTER TABLE team_member ADD COLUMN plan_approval TEXT NOT NULL DEFAULT 'none'
12416
- CHECK(plan_approval IN ('none', 'pending', 'approved', 'rejected'));`
12417
- ];
12418
- function applyMigrations(db) {
12419
- const { user_version: current } = db.query("PRAGMA user_version").get();
12420
- for (let i = current;i < MIGRATIONS.length; i++) {
12421
- db.exec(MIGRATIONS[i]);
12422
- db.exec(`PRAGMA user_version = ${i + 1}`);
12457
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/pathSerializer.gen.js
12458
+ var separatorArrayExplode = (style) => {
12459
+ switch (style) {
12460
+ case "label":
12461
+ return ".";
12462
+ case "matrix":
12463
+ return ";";
12464
+ case "simple":
12465
+ return ",";
12466
+ default:
12467
+ return "&";
12423
12468
  }
12424
- }
12425
-
12426
- // src/db.ts
12427
- var instance;
12428
- function getDbPath(env = process.env) {
12429
- const home = env.HOME ?? env.USERPROFILE ?? "~";
12430
- return path.join(home, ".config", "opencode", "ensemble.db");
12431
- }
12432
- function createDb(path2) {
12433
- const db = new Database(path2);
12434
- db.exec("PRAGMA journal_mode=WAL");
12435
- db.exec("PRAGMA foreign_keys=ON");
12436
- applyMigrations(db);
12437
- instance = db;
12438
- return db;
12439
- }
12440
-
12441
- // src/util.ts
12442
- var NAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
12443
- var counter = 0;
12444
- function generateId(prefix) {
12445
- const time3 = Date.now().toString(36);
12446
- const count = (counter++).toString(36).padStart(4, "0");
12447
- const rand = Math.random().toString(36).slice(2, 8);
12448
- return `${prefix}_${time3}_${count}_${rand}`;
12449
- }
12450
- function validateTeamName(name) {
12451
- if (name.length < 1 || name.length > 64)
12452
- return "Team name must be 1-64 characters";
12453
- if (!NAME_PATTERN.test(name))
12454
- return "Team name must be lowercase alphanumeric with hyphens only";
12455
- return;
12456
- }
12457
- function validateMemberName(name) {
12458
- if (name.toLowerCase() === "lead")
12459
- return `Name "lead" is reserved`;
12460
- if (name.length < 1 || name.length > 64)
12461
- return "Member name must be 1-64 characters";
12462
- if (!NAME_PATTERN.test(name))
12463
- return "Member name must be lowercase alphanumeric with hyphens only";
12464
- return;
12465
- }
12466
-
12467
- // src/messaging.ts
12468
- var MAX_CONTENT_BYTES = 10 * 1024;
12469
- function sendMessage(db, input) {
12470
- if (new TextEncoder().encode(input.content).length > MAX_CONTENT_BYTES) {
12471
- throw new Error("Message content exceeds 10KB limit");
12469
+ };
12470
+ var separatorArrayNoExplode = (style) => {
12471
+ switch (style) {
12472
+ case "form":
12473
+ return ",";
12474
+ case "pipeDelimited":
12475
+ return "|";
12476
+ case "spaceDelimited":
12477
+ return "%20";
12478
+ default:
12479
+ return ",";
12472
12480
  }
12473
- const id = generateId("msg");
12474
- db.run("INSERT INTO team_message (id, team_id, from_name, to_name, content, delivered, time_created) VALUES (?, ?, ?, ?, ?, 0, ?)", [id, input.teamId, input.from, input.to, input.content, Date.now()]);
12475
- return id;
12476
- }
12477
- function broadcastMessage(db, input) {
12478
- if (new TextEncoder().encode(input.content).length > MAX_CONTENT_BYTES) {
12479
- throw new Error("Message content exceeds 10KB limit");
12481
+ };
12482
+ var separatorObjectExplode = (style) => {
12483
+ switch (style) {
12484
+ case "label":
12485
+ return ".";
12486
+ case "matrix":
12487
+ return ";";
12488
+ case "simple":
12489
+ return ",";
12490
+ default:
12491
+ return "&";
12480
12492
  }
12481
- const id = generateId("msg");
12482
- db.run("INSERT INTO team_message (id, team_id, from_name, to_name, content, delivered, time_created) VALUES (?, ?, ?, NULL, ?, 0, ?)", [id, input.teamId, input.from, input.content, Date.now()]);
12483
- return id;
12484
- }
12485
- function getUndeliveredMessages(db, teamId) {
12486
- return db.query("SELECT * FROM team_message WHERE team_id = ? AND delivered = 0 ORDER BY time_created ASC").all(teamId);
12487
- }
12488
- function markDelivered(db, messageId) {
12489
- db.run("UPDATE team_message SET delivered = 1 WHERE id = ?", [messageId]);
12490
- }
12491
-
12492
- // src/recovery.ts
12493
- async function recoverStaleMembers(db, client) {
12494
- const stale = db.query(`SELECT tm.session_id FROM team_member tm
12495
- JOIN team t ON tm.team_id = t.id
12496
- WHERE tm.status = 'busy' AND t.status = 'active'`).all();
12497
- const result = db.run(`UPDATE team_member SET status = 'error', execution_status = 'idle', time_updated = ?
12498
- WHERE status = 'busy'
12499
- AND team_id IN (SELECT id FROM team WHERE status = 'active')`, [Date.now()]);
12500
- if (client) {
12501
- for (const member of stale) {
12502
- try {
12503
- await client.session.abort({ path: { id: member.session_id } });
12504
- } catch {}
12493
+ };
12494
+ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
12495
+ if (!explode) {
12496
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
12497
+ switch (style) {
12498
+ case "label":
12499
+ return `.${joinedValues2}`;
12500
+ case "matrix":
12501
+ return `;${name}=${joinedValues2}`;
12502
+ case "simple":
12503
+ return joinedValues2;
12504
+ default:
12505
+ return `${name}=${joinedValues2}`;
12505
12506
  }
12506
12507
  }
12507
- return { interrupted: result.changes };
12508
- }
12509
- async function recoverOrphanedWorktrees(db, client) {
12510
- let removed = 0;
12511
- try {
12512
- const worktrees = await client.worktree.list();
12513
- if (!worktrees.data)
12514
- return { removed: 0 };
12515
- const activeWorktrees = new Set(db.query(`SELECT tm.worktree_dir FROM team_member tm
12516
- JOIN team t ON tm.team_id = t.id
12517
- WHERE tm.worktree_dir IS NOT NULL AND t.status = 'active'`).all().map((r) => r.worktree_dir));
12518
- for (const wt of worktrees.data) {
12519
- if (!wt.name.startsWith("ensemble-"))
12508
+ const separator = separatorArrayExplode(style);
12509
+ const joinedValues = value.map((v) => {
12510
+ if (style === "label" || style === "simple") {
12511
+ return allowReserved ? v : encodeURIComponent(v);
12512
+ }
12513
+ return serializePrimitiveParam({
12514
+ allowReserved,
12515
+ name,
12516
+ value: v
12517
+ });
12518
+ }).join(separator);
12519
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
12520
+ };
12521
+ var serializePrimitiveParam = ({ allowReserved, name, value }) => {
12522
+ if (value === undefined || value === null) {
12523
+ return "";
12524
+ }
12525
+ if (typeof value === "object") {
12526
+ throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
12527
+ }
12528
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
12529
+ };
12530
+ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
12531
+ if (value instanceof Date) {
12532
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
12533
+ }
12534
+ if (style !== "deepObject" && !explode) {
12535
+ let values = [];
12536
+ Object.entries(value).forEach(([key, v]) => {
12537
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
12538
+ });
12539
+ const joinedValues2 = values.join(",");
12540
+ switch (style) {
12541
+ case "form":
12542
+ return `${name}=${joinedValues2}`;
12543
+ case "label":
12544
+ return `.${joinedValues2}`;
12545
+ case "matrix":
12546
+ return `;${name}=${joinedValues2}`;
12547
+ default:
12548
+ return joinedValues2;
12549
+ }
12550
+ }
12551
+ const separator = separatorObjectExplode(style);
12552
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
12553
+ allowReserved,
12554
+ name: style === "deepObject" ? `${name}[${key}]` : key,
12555
+ value: v
12556
+ })).join(separator);
12557
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
12558
+ };
12559
+
12560
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
12561
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
12562
+ var defaultPathSerializer = ({ path, url: _url2 }) => {
12563
+ let url2 = _url2;
12564
+ const matches = _url2.match(PATH_PARAM_RE);
12565
+ if (matches) {
12566
+ for (const match of matches) {
12567
+ let explode = false;
12568
+ let name = match.substring(1, match.length - 1);
12569
+ let style = "simple";
12570
+ if (name.endsWith("*")) {
12571
+ explode = true;
12572
+ name = name.substring(0, name.length - 1);
12573
+ }
12574
+ if (name.startsWith(".")) {
12575
+ name = name.substring(1);
12576
+ style = "label";
12577
+ } else if (name.startsWith(";")) {
12578
+ name = name.substring(1);
12579
+ style = "matrix";
12580
+ }
12581
+ const value = path[name];
12582
+ if (value === undefined || value === null) {
12520
12583
  continue;
12521
- if (activeWorktrees.has(wt.directory))
12584
+ }
12585
+ if (Array.isArray(value)) {
12586
+ url2 = url2.replace(match, serializeArrayParam({ explode, name, style, value }));
12522
12587
  continue;
12523
- try {
12524
- await client.worktree.remove({ worktreeRemoveInput: { directory: wt.directory } });
12525
- removed++;
12526
- } catch {}
12527
- }
12528
- } catch {}
12529
- return { removed };
12530
- }
12531
- async function recoverUndeliveredMessages(db, client, registry2) {
12532
- const teams = db.query("SELECT id, lead_session_id FROM team WHERE status = 'active'").all();
12533
- let redelivered = 0;
12534
- for (const team of teams) {
12535
- const messages = getUndeliveredMessages(db, team.id);
12536
- for (const msg of messages) {
12537
- let recipientSessionId;
12538
- if (msg.to_name === "lead") {
12539
- recipientSessionId = team.lead_session_id;
12540
- } else if (msg.to_name) {
12541
- const entry = registry2.getByName(team.id, msg.to_name);
12542
- recipientSessionId = entry?.sessionId;
12543
- } else {
12588
+ }
12589
+ if (typeof value === "object") {
12590
+ url2 = url2.replace(match, serializeObjectParam({
12591
+ explode,
12592
+ name,
12593
+ style,
12594
+ value,
12595
+ valueOnly: true
12596
+ }));
12544
12597
  continue;
12545
12598
  }
12546
- if (!recipientSessionId)
12599
+ if (style === "matrix") {
12600
+ url2 = url2.replace(match, `;${serializePrimitiveParam({
12601
+ name,
12602
+ value
12603
+ })}`);
12547
12604
  continue;
12548
- try {
12549
- await client.session.promptAsync({
12550
- path: { id: recipientSessionId },
12551
- body: { parts: [{ type: "text", text: `[Recovered team message from ${msg.from_name}]: ${msg.content}` }] }
12552
- });
12553
- markDelivered(db, msg.id);
12554
- redelivered++;
12555
- } catch {}
12605
+ }
12606
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
12607
+ url2 = url2.replace(match, replaceValue);
12556
12608
  }
12557
12609
  }
12558
- return { redelivered };
12610
+ return url2;
12611
+ };
12612
+ var getUrl = ({ baseUrl, path, query, querySerializer, url: _url2 }) => {
12613
+ const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
12614
+ let url2 = (baseUrl ?? "") + pathUrl;
12615
+ if (path) {
12616
+ url2 = defaultPathSerializer({ path, url: url2 });
12617
+ }
12618
+ let search = query ? querySerializer(query) : "";
12619
+ if (search.startsWith("?")) {
12620
+ search = search.substring(1);
12621
+ }
12622
+ if (search) {
12623
+ url2 += `?${search}`;
12624
+ }
12625
+ return url2;
12626
+ };
12627
+ function getValidRequestBody(options) {
12628
+ const hasBody = options.body !== undefined;
12629
+ const isSerializedBody = hasBody && options.bodySerializer;
12630
+ if (isSerializedBody) {
12631
+ if ("serializedBody" in options) {
12632
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
12633
+ return hasSerializedBody ? options.serializedBody : null;
12634
+ }
12635
+ return options.body !== "" ? options.body : null;
12636
+ }
12637
+ if (hasBody) {
12638
+ return options.body;
12639
+ }
12640
+ return;
12641
+ }
12642
+
12643
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/auth.gen.js
12644
+ var getAuthToken = async (auth, callback) => {
12645
+ const token = typeof callback === "function" ? await callback(auth) : callback;
12646
+ if (!token) {
12647
+ return;
12648
+ }
12649
+ if (auth.scheme === "bearer") {
12650
+ return `Bearer ${token}`;
12651
+ }
12652
+ if (auth.scheme === "basic") {
12653
+ return `Basic ${btoa(token)}`;
12654
+ }
12655
+ return token;
12656
+ };
12657
+
12658
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/bodySerializer.gen.js
12659
+ var jsonBodySerializer = {
12660
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
12661
+ };
12662
+
12663
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/client/utils.gen.js
12664
+ var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
12665
+ const querySerializer = (queryParams) => {
12666
+ const search = [];
12667
+ if (queryParams && typeof queryParams === "object") {
12668
+ for (const name in queryParams) {
12669
+ const value = queryParams[name];
12670
+ if (value === undefined || value === null) {
12671
+ continue;
12672
+ }
12673
+ const options = parameters[name] || args;
12674
+ if (Array.isArray(value)) {
12675
+ const serializedArray = serializeArrayParam({
12676
+ allowReserved: options.allowReserved,
12677
+ explode: true,
12678
+ name,
12679
+ style: "form",
12680
+ value,
12681
+ ...options.array
12682
+ });
12683
+ if (serializedArray)
12684
+ search.push(serializedArray);
12685
+ } else if (typeof value === "object") {
12686
+ const serializedObject = serializeObjectParam({
12687
+ allowReserved: options.allowReserved,
12688
+ explode: true,
12689
+ name,
12690
+ style: "deepObject",
12691
+ value,
12692
+ ...options.object
12693
+ });
12694
+ if (serializedObject)
12695
+ search.push(serializedObject);
12696
+ } else {
12697
+ const serializedPrimitive = serializePrimitiveParam({
12698
+ allowReserved: options.allowReserved,
12699
+ name,
12700
+ value
12701
+ });
12702
+ if (serializedPrimitive)
12703
+ search.push(serializedPrimitive);
12704
+ }
12705
+ }
12706
+ }
12707
+ return search.join("&");
12708
+ };
12709
+ return querySerializer;
12710
+ };
12711
+ var getParseAs = (contentType) => {
12712
+ if (!contentType) {
12713
+ return "stream";
12714
+ }
12715
+ const cleanContent = contentType.split(";")[0]?.trim();
12716
+ if (!cleanContent) {
12717
+ return;
12718
+ }
12719
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
12720
+ return "json";
12721
+ }
12722
+ if (cleanContent === "multipart/form-data") {
12723
+ return "formData";
12724
+ }
12725
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
12726
+ return "blob";
12727
+ }
12728
+ if (cleanContent.startsWith("text/")) {
12729
+ return "text";
12730
+ }
12731
+ return;
12732
+ };
12733
+ var checkForExistence = (options, name) => {
12734
+ if (!name) {
12735
+ return false;
12736
+ }
12737
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
12738
+ return true;
12739
+ }
12740
+ return false;
12741
+ };
12742
+ var setAuthParams = async ({ security, ...options }) => {
12743
+ for (const auth of security) {
12744
+ if (checkForExistence(options, auth.name)) {
12745
+ continue;
12746
+ }
12747
+ const token = await getAuthToken(auth, options.auth);
12748
+ if (!token) {
12749
+ continue;
12750
+ }
12751
+ const name = auth.name ?? "Authorization";
12752
+ switch (auth.in) {
12753
+ case "query":
12754
+ if (!options.query) {
12755
+ options.query = {};
12756
+ }
12757
+ options.query[name] = token;
12758
+ break;
12759
+ case "cookie":
12760
+ options.headers.append("Cookie", `${name}=${token}`);
12761
+ break;
12762
+ case "header":
12763
+ default:
12764
+ options.headers.set(name, token);
12765
+ break;
12766
+ }
12767
+ }
12768
+ };
12769
+ var buildUrl = (options) => getUrl({
12770
+ baseUrl: options.baseUrl,
12771
+ path: options.path,
12772
+ query: options.query,
12773
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
12774
+ url: options.url
12775
+ });
12776
+ var mergeConfigs = (a, b) => {
12777
+ const config2 = { ...a, ...b };
12778
+ if (config2.baseUrl?.endsWith("/")) {
12779
+ config2.baseUrl = config2.baseUrl.substring(0, config2.baseUrl.length - 1);
12780
+ }
12781
+ config2.headers = mergeHeaders(a.headers, b.headers);
12782
+ return config2;
12783
+ };
12784
+ var headersEntries = (headers) => {
12785
+ const entries = [];
12786
+ headers.forEach((value, key) => {
12787
+ entries.push([key, value]);
12788
+ });
12789
+ return entries;
12790
+ };
12791
+ var mergeHeaders = (...headers) => {
12792
+ const mergedHeaders = new Headers;
12793
+ for (const header of headers) {
12794
+ if (!header) {
12795
+ continue;
12796
+ }
12797
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
12798
+ for (const [key, value] of iterator) {
12799
+ if (value === null) {
12800
+ mergedHeaders.delete(key);
12801
+ } else if (Array.isArray(value)) {
12802
+ for (const v of value) {
12803
+ mergedHeaders.append(key, v);
12804
+ }
12805
+ } else if (value !== undefined) {
12806
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
12807
+ }
12808
+ }
12809
+ }
12810
+ return mergedHeaders;
12811
+ };
12812
+
12813
+ class Interceptors {
12814
+ fns = [];
12815
+ clear() {
12816
+ this.fns = [];
12817
+ }
12818
+ eject(id) {
12819
+ const index = this.getInterceptorIndex(id);
12820
+ if (this.fns[index]) {
12821
+ this.fns[index] = null;
12822
+ }
12823
+ }
12824
+ exists(id) {
12825
+ const index = this.getInterceptorIndex(id);
12826
+ return Boolean(this.fns[index]);
12827
+ }
12828
+ getInterceptorIndex(id) {
12829
+ if (typeof id === "number") {
12830
+ return this.fns[id] ? id : -1;
12831
+ }
12832
+ return this.fns.indexOf(id);
12833
+ }
12834
+ update(id, fn) {
12835
+ const index = this.getInterceptorIndex(id);
12836
+ if (this.fns[index]) {
12837
+ this.fns[index] = fn;
12838
+ return id;
12839
+ }
12840
+ return false;
12841
+ }
12842
+ use(fn) {
12843
+ this.fns.push(fn);
12844
+ return this.fns.length - 1;
12845
+ }
12846
+ }
12847
+ var createInterceptors = () => ({
12848
+ error: new Interceptors,
12849
+ request: new Interceptors,
12850
+ response: new Interceptors
12851
+ });
12852
+ var defaultQuerySerializer = createQuerySerializer({
12853
+ allowReserved: false,
12854
+ array: {
12855
+ explode: true,
12856
+ style: "form"
12857
+ },
12858
+ object: {
12859
+ explode: true,
12860
+ style: "deepObject"
12861
+ }
12862
+ });
12863
+ var defaultHeaders = {
12864
+ "Content-Type": "application/json"
12865
+ };
12866
+ var createConfig = (override = {}) => ({
12867
+ ...jsonBodySerializer,
12868
+ headers: defaultHeaders,
12869
+ parseAs: "auto",
12870
+ querySerializer: defaultQuerySerializer,
12871
+ ...override
12872
+ });
12873
+
12874
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/client/client.gen.js
12875
+ var createClient = (config2 = {}) => {
12876
+ let _config = mergeConfigs(createConfig(), config2);
12877
+ const getConfig = () => ({ ..._config });
12878
+ const setConfig = (config3) => {
12879
+ _config = mergeConfigs(_config, config3);
12880
+ return getConfig();
12881
+ };
12882
+ const interceptors = createInterceptors();
12883
+ const beforeRequest = async (options) => {
12884
+ const opts = {
12885
+ ..._config,
12886
+ ...options,
12887
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
12888
+ headers: mergeHeaders(_config.headers, options.headers),
12889
+ serializedBody: undefined
12890
+ };
12891
+ if (opts.security) {
12892
+ await setAuthParams({
12893
+ ...opts,
12894
+ security: opts.security
12895
+ });
12896
+ }
12897
+ if (opts.requestValidator) {
12898
+ await opts.requestValidator(opts);
12899
+ }
12900
+ if (opts.body !== undefined && opts.bodySerializer) {
12901
+ opts.serializedBody = opts.bodySerializer(opts.body);
12902
+ }
12903
+ if (opts.body === undefined || opts.serializedBody === "") {
12904
+ opts.headers.delete("Content-Type");
12905
+ }
12906
+ const url2 = buildUrl(opts);
12907
+ return { opts, url: url2 };
12908
+ };
12909
+ const request = async (options) => {
12910
+ const { opts, url: url2 } = await beforeRequest(options);
12911
+ const requestInit = {
12912
+ redirect: "follow",
12913
+ ...opts,
12914
+ body: getValidRequestBody(opts)
12915
+ };
12916
+ let request2 = new Request(url2, requestInit);
12917
+ for (const fn of interceptors.request.fns) {
12918
+ if (fn) {
12919
+ request2 = await fn(request2, opts);
12920
+ }
12921
+ }
12922
+ const _fetch = opts.fetch;
12923
+ let response;
12924
+ try {
12925
+ response = await _fetch(request2);
12926
+ } catch (error46) {
12927
+ let finalError2 = error46;
12928
+ for (const fn of interceptors.error.fns) {
12929
+ if (fn) {
12930
+ finalError2 = await fn(error46, undefined, request2, opts);
12931
+ }
12932
+ }
12933
+ finalError2 = finalError2 || {};
12934
+ if (opts.throwOnError) {
12935
+ throw finalError2;
12936
+ }
12937
+ return opts.responseStyle === "data" ? undefined : {
12938
+ error: finalError2,
12939
+ request: request2,
12940
+ response: undefined
12941
+ };
12942
+ }
12943
+ for (const fn of interceptors.response.fns) {
12944
+ if (fn) {
12945
+ response = await fn(response, request2, opts);
12946
+ }
12947
+ }
12948
+ const result = {
12949
+ request: request2,
12950
+ response
12951
+ };
12952
+ if (response.ok) {
12953
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
12954
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
12955
+ let emptyData;
12956
+ switch (parseAs) {
12957
+ case "arrayBuffer":
12958
+ case "blob":
12959
+ case "text":
12960
+ emptyData = await response[parseAs]();
12961
+ break;
12962
+ case "formData":
12963
+ emptyData = new FormData;
12964
+ break;
12965
+ case "stream":
12966
+ emptyData = response.body;
12967
+ break;
12968
+ case "json":
12969
+ default:
12970
+ emptyData = {};
12971
+ break;
12972
+ }
12973
+ return opts.responseStyle === "data" ? emptyData : {
12974
+ data: emptyData,
12975
+ ...result
12976
+ };
12977
+ }
12978
+ let data;
12979
+ switch (parseAs) {
12980
+ case "arrayBuffer":
12981
+ case "blob":
12982
+ case "formData":
12983
+ case "text":
12984
+ data = await response[parseAs]();
12985
+ break;
12986
+ case "json": {
12987
+ const text = await response.text();
12988
+ data = text ? JSON.parse(text) : {};
12989
+ break;
12990
+ }
12991
+ case "stream":
12992
+ return opts.responseStyle === "data" ? response.body : {
12993
+ data: response.body,
12994
+ ...result
12995
+ };
12996
+ }
12997
+ if (parseAs === "json") {
12998
+ if (opts.responseValidator) {
12999
+ await opts.responseValidator(data);
13000
+ }
13001
+ if (opts.responseTransformer) {
13002
+ data = await opts.responseTransformer(data);
13003
+ }
13004
+ }
13005
+ return opts.responseStyle === "data" ? data : {
13006
+ data,
13007
+ ...result
13008
+ };
13009
+ }
13010
+ const textError = await response.text();
13011
+ let jsonError;
13012
+ try {
13013
+ jsonError = JSON.parse(textError);
13014
+ } catch {}
13015
+ const error45 = jsonError ?? textError;
13016
+ let finalError = error45;
13017
+ for (const fn of interceptors.error.fns) {
13018
+ if (fn) {
13019
+ finalError = await fn(error45, response, request2, opts);
13020
+ }
13021
+ }
13022
+ finalError = finalError || {};
13023
+ if (opts.throwOnError) {
13024
+ throw finalError;
13025
+ }
13026
+ return opts.responseStyle === "data" ? undefined : {
13027
+ error: finalError,
13028
+ ...result
13029
+ };
13030
+ };
13031
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
13032
+ const makeSseFn = (method) => async (options) => {
13033
+ const { opts, url: url2 } = await beforeRequest(options);
13034
+ return createSseClient({
13035
+ ...opts,
13036
+ body: opts.body,
13037
+ headers: opts.headers,
13038
+ method,
13039
+ onRequest: async (url3, init) => {
13040
+ let request2 = new Request(url3, init);
13041
+ for (const fn of interceptors.request.fns) {
13042
+ if (fn) {
13043
+ request2 = await fn(request2, opts);
13044
+ }
13045
+ }
13046
+ return request2;
13047
+ },
13048
+ serializedBody: getValidRequestBody(opts),
13049
+ url: url2
13050
+ });
13051
+ };
13052
+ return {
13053
+ buildUrl,
13054
+ connect: makeMethodFn("CONNECT"),
13055
+ delete: makeMethodFn("DELETE"),
13056
+ get: makeMethodFn("GET"),
13057
+ getConfig,
13058
+ head: makeMethodFn("HEAD"),
13059
+ interceptors,
13060
+ options: makeMethodFn("OPTIONS"),
13061
+ patch: makeMethodFn("PATCH"),
13062
+ post: makeMethodFn("POST"),
13063
+ put: makeMethodFn("PUT"),
13064
+ request,
13065
+ setConfig,
13066
+ sse: {
13067
+ connect: makeSseFn("CONNECT"),
13068
+ delete: makeSseFn("DELETE"),
13069
+ get: makeSseFn("GET"),
13070
+ head: makeSseFn("HEAD"),
13071
+ options: makeSseFn("OPTIONS"),
13072
+ patch: makeSseFn("PATCH"),
13073
+ post: makeSseFn("POST"),
13074
+ put: makeSseFn("PUT"),
13075
+ trace: makeSseFn("TRACE")
13076
+ },
13077
+ trace: makeMethodFn("TRACE")
13078
+ };
13079
+ };
13080
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/params.gen.js
13081
+ var extraPrefixesMap = {
13082
+ $body_: "body",
13083
+ $headers_: "headers",
13084
+ $path_: "path",
13085
+ $query_: "query"
13086
+ };
13087
+ var extraPrefixes = Object.entries(extraPrefixesMap);
13088
+ var buildKeyMap = (fields, map2) => {
13089
+ if (!map2) {
13090
+ map2 = new Map;
13091
+ }
13092
+ for (const config2 of fields) {
13093
+ if ("in" in config2) {
13094
+ if (config2.key) {
13095
+ map2.set(config2.key, {
13096
+ in: config2.in,
13097
+ map: config2.map
13098
+ });
13099
+ }
13100
+ } else if ("key" in config2) {
13101
+ map2.set(config2.key, {
13102
+ map: config2.map
13103
+ });
13104
+ } else if (config2.args) {
13105
+ buildKeyMap(config2.args, map2);
13106
+ }
13107
+ }
13108
+ return map2;
13109
+ };
13110
+ var stripEmptySlots = (params) => {
13111
+ for (const [slot, value] of Object.entries(params)) {
13112
+ if (value && typeof value === "object" && !Object.keys(value).length) {
13113
+ delete params[slot];
13114
+ }
13115
+ }
13116
+ };
13117
+ var buildClientParams = (args, fields) => {
13118
+ const params = {
13119
+ body: {},
13120
+ headers: {},
13121
+ path: {},
13122
+ query: {}
13123
+ };
13124
+ const map2 = buildKeyMap(fields);
13125
+ let config2;
13126
+ for (const [index, arg] of args.entries()) {
13127
+ if (fields[index]) {
13128
+ config2 = fields[index];
13129
+ }
13130
+ if (!config2) {
13131
+ continue;
13132
+ }
13133
+ if ("in" in config2) {
13134
+ if (config2.key) {
13135
+ const field = map2.get(config2.key);
13136
+ const name = field.map || config2.key;
13137
+ if (field.in) {
13138
+ params[field.in][name] = arg;
13139
+ }
13140
+ } else {
13141
+ params.body = arg;
13142
+ }
13143
+ } else {
13144
+ for (const [key, value] of Object.entries(arg ?? {})) {
13145
+ const field = map2.get(key);
13146
+ if (field) {
13147
+ if (field.in) {
13148
+ const name = field.map || key;
13149
+ params[field.in][name] = value;
13150
+ } else {
13151
+ params[field.map] = value;
13152
+ }
13153
+ } else {
13154
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
13155
+ if (extra) {
13156
+ const [prefix, slot] = extra;
13157
+ params[slot][key.slice(prefix.length)] = value;
13158
+ } else if ("allowExtra" in config2 && config2.allowExtra) {
13159
+ for (const [slot, allowed] of Object.entries(config2.allowExtra)) {
13160
+ if (allowed) {
13161
+ params[slot][key] = value;
13162
+ break;
13163
+ }
13164
+ }
13165
+ }
13166
+ }
13167
+ }
13168
+ }
13169
+ }
13170
+ stripEmptySlots(params);
13171
+ return params;
13172
+ };
13173
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/client.gen.js
13174
+ var client = createClient(createConfig({ baseUrl: "http://localhost:4096" }));
13175
+
13176
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/sdk.gen.js
13177
+ class HeyApiClient {
13178
+ client;
13179
+ constructor(args) {
13180
+ this.client = args?.client ?? client;
13181
+ }
13182
+ }
13183
+
13184
+ class HeyApiRegistry {
13185
+ defaultKey = "default";
13186
+ instances = new Map;
13187
+ get(key) {
13188
+ const instance = this.instances.get(key ?? this.defaultKey);
13189
+ if (!instance) {
13190
+ throw new Error(`No SDK client found. Create one with "new OpencodeClient()" to fix this error.`);
13191
+ }
13192
+ return instance;
13193
+ }
13194
+ set(value, key) {
13195
+ this.instances.set(key ?? this.defaultKey, value);
13196
+ }
13197
+ }
13198
+
13199
+ class Config extends HeyApiClient {
13200
+ get(options) {
13201
+ return (options?.client ?? this.client).get({
13202
+ url: "/global/config",
13203
+ ...options
13204
+ });
13205
+ }
13206
+ update(parameters, options) {
13207
+ const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }]);
13208
+ return (options?.client ?? this.client).patch({
13209
+ url: "/global/config",
13210
+ ...options,
13211
+ ...params,
13212
+ headers: {
13213
+ "Content-Type": "application/json",
13214
+ ...options?.headers,
13215
+ ...params.headers
13216
+ }
13217
+ });
13218
+ }
13219
+ }
13220
+
13221
+ class Global extends HeyApiClient {
13222
+ health(options) {
13223
+ return (options?.client ?? this.client).get({
13224
+ url: "/global/health",
13225
+ ...options
13226
+ });
13227
+ }
13228
+ event(options) {
13229
+ return (options?.client ?? this.client).sse.get({
13230
+ url: "/global/event",
13231
+ ...options
13232
+ });
13233
+ }
13234
+ dispose(options) {
13235
+ return (options?.client ?? this.client).post({
13236
+ url: "/global/dispose",
13237
+ ...options
13238
+ });
13239
+ }
13240
+ upgrade(parameters, options) {
13241
+ const params = buildClientParams([parameters], [{ args: [{ in: "body", key: "target" }] }]);
13242
+ return (options?.client ?? this.client).post({
13243
+ url: "/global/upgrade",
13244
+ ...options,
13245
+ ...params,
13246
+ headers: {
13247
+ "Content-Type": "application/json",
13248
+ ...options?.headers,
13249
+ ...params.headers
13250
+ }
13251
+ });
13252
+ }
13253
+ _config;
13254
+ get config() {
13255
+ return this._config ??= new Config({ client: this.client });
13256
+ }
13257
+ }
13258
+
13259
+ class Auth extends HeyApiClient {
13260
+ remove(parameters, options) {
13261
+ const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "providerID" }] }]);
13262
+ return (options?.client ?? this.client).delete({
13263
+ url: "/auth/{providerID}",
13264
+ ...options,
13265
+ ...params
13266
+ });
13267
+ }
13268
+ set(parameters, options) {
13269
+ const params = buildClientParams([parameters], [
13270
+ {
13271
+ args: [
13272
+ { in: "path", key: "providerID" },
13273
+ { key: "auth", map: "body" }
13274
+ ]
13275
+ }
13276
+ ]);
13277
+ return (options?.client ?? this.client).put({
13278
+ url: "/auth/{providerID}",
13279
+ ...options,
13280
+ ...params,
13281
+ headers: {
13282
+ "Content-Type": "application/json",
13283
+ ...options?.headers,
13284
+ ...params.headers
13285
+ }
13286
+ });
13287
+ }
13288
+ }
13289
+
13290
+ class Project extends HeyApiClient {
13291
+ list(parameters, options) {
13292
+ const params = buildClientParams([parameters], [
13293
+ {
13294
+ args: [
13295
+ { in: "query", key: "directory" },
13296
+ { in: "query", key: "workspace" }
13297
+ ]
13298
+ }
13299
+ ]);
13300
+ return (options?.client ?? this.client).get({
13301
+ url: "/project",
13302
+ ...options,
13303
+ ...params
13304
+ });
13305
+ }
13306
+ current(parameters, options) {
13307
+ const params = buildClientParams([parameters], [
13308
+ {
13309
+ args: [
13310
+ { in: "query", key: "directory" },
13311
+ { in: "query", key: "workspace" }
13312
+ ]
13313
+ }
13314
+ ]);
13315
+ return (options?.client ?? this.client).get({
13316
+ url: "/project/current",
13317
+ ...options,
13318
+ ...params
13319
+ });
13320
+ }
13321
+ initGit(parameters, options) {
13322
+ const params = buildClientParams([parameters], [
13323
+ {
13324
+ args: [
13325
+ { in: "query", key: "directory" },
13326
+ { in: "query", key: "workspace" }
13327
+ ]
13328
+ }
13329
+ ]);
13330
+ return (options?.client ?? this.client).post({
13331
+ url: "/project/git/init",
13332
+ ...options,
13333
+ ...params
13334
+ });
13335
+ }
13336
+ update(parameters, options) {
13337
+ const params = buildClientParams([parameters], [
13338
+ {
13339
+ args: [
13340
+ { in: "path", key: "projectID" },
13341
+ { in: "query", key: "directory" },
13342
+ { in: "query", key: "workspace" },
13343
+ { in: "body", key: "name" },
13344
+ { in: "body", key: "icon" },
13345
+ { in: "body", key: "commands" }
13346
+ ]
13347
+ }
13348
+ ]);
13349
+ return (options?.client ?? this.client).patch({
13350
+ url: "/project/{projectID}",
13351
+ ...options,
13352
+ ...params,
13353
+ headers: {
13354
+ "Content-Type": "application/json",
13355
+ ...options?.headers,
13356
+ ...params.headers
13357
+ }
13358
+ });
13359
+ }
13360
+ }
13361
+
13362
+ class Pty extends HeyApiClient {
13363
+ list(parameters, options) {
13364
+ const params = buildClientParams([parameters], [
13365
+ {
13366
+ args: [
13367
+ { in: "query", key: "directory" },
13368
+ { in: "query", key: "workspace" }
13369
+ ]
13370
+ }
13371
+ ]);
13372
+ return (options?.client ?? this.client).get({
13373
+ url: "/pty",
13374
+ ...options,
13375
+ ...params
13376
+ });
13377
+ }
13378
+ create(parameters, options) {
13379
+ const params = buildClientParams([parameters], [
13380
+ {
13381
+ args: [
13382
+ { in: "query", key: "directory" },
13383
+ { in: "query", key: "workspace" },
13384
+ { in: "body", key: "command" },
13385
+ { in: "body", key: "args" },
13386
+ { in: "body", key: "cwd" },
13387
+ { in: "body", key: "title" },
13388
+ { in: "body", key: "env" }
13389
+ ]
13390
+ }
13391
+ ]);
13392
+ return (options?.client ?? this.client).post({
13393
+ url: "/pty",
13394
+ ...options,
13395
+ ...params,
13396
+ headers: {
13397
+ "Content-Type": "application/json",
13398
+ ...options?.headers,
13399
+ ...params.headers
13400
+ }
13401
+ });
13402
+ }
13403
+ remove(parameters, options) {
13404
+ const params = buildClientParams([parameters], [
13405
+ {
13406
+ args: [
13407
+ { in: "path", key: "ptyID" },
13408
+ { in: "query", key: "directory" },
13409
+ { in: "query", key: "workspace" }
13410
+ ]
13411
+ }
13412
+ ]);
13413
+ return (options?.client ?? this.client).delete({
13414
+ url: "/pty/{ptyID}",
13415
+ ...options,
13416
+ ...params
13417
+ });
13418
+ }
13419
+ get(parameters, options) {
13420
+ const params = buildClientParams([parameters], [
13421
+ {
13422
+ args: [
13423
+ { in: "path", key: "ptyID" },
13424
+ { in: "query", key: "directory" },
13425
+ { in: "query", key: "workspace" }
13426
+ ]
13427
+ }
13428
+ ]);
13429
+ return (options?.client ?? this.client).get({
13430
+ url: "/pty/{ptyID}",
13431
+ ...options,
13432
+ ...params
13433
+ });
13434
+ }
13435
+ update(parameters, options) {
13436
+ const params = buildClientParams([parameters], [
13437
+ {
13438
+ args: [
13439
+ { in: "path", key: "ptyID" },
13440
+ { in: "query", key: "directory" },
13441
+ { in: "query", key: "workspace" },
13442
+ { in: "body", key: "title" },
13443
+ { in: "body", key: "size" }
13444
+ ]
13445
+ }
13446
+ ]);
13447
+ return (options?.client ?? this.client).put({
13448
+ url: "/pty/{ptyID}",
13449
+ ...options,
13450
+ ...params,
13451
+ headers: {
13452
+ "Content-Type": "application/json",
13453
+ ...options?.headers,
13454
+ ...params.headers
13455
+ }
13456
+ });
13457
+ }
13458
+ connect(parameters, options) {
13459
+ const params = buildClientParams([parameters], [
13460
+ {
13461
+ args: [
13462
+ { in: "path", key: "ptyID" },
13463
+ { in: "query", key: "directory" },
13464
+ { in: "query", key: "workspace" }
13465
+ ]
13466
+ }
13467
+ ]);
13468
+ return (options?.client ?? this.client).get({
13469
+ url: "/pty/{ptyID}/connect",
13470
+ ...options,
13471
+ ...params
13472
+ });
13473
+ }
13474
+ }
13475
+
13476
+ class Config2 extends HeyApiClient {
13477
+ get(parameters, options) {
13478
+ const params = buildClientParams([parameters], [
13479
+ {
13480
+ args: [
13481
+ { in: "query", key: "directory" },
13482
+ { in: "query", key: "workspace" }
13483
+ ]
13484
+ }
13485
+ ]);
13486
+ return (options?.client ?? this.client).get({
13487
+ url: "/config",
13488
+ ...options,
13489
+ ...params
13490
+ });
13491
+ }
13492
+ update(parameters, options) {
13493
+ const params = buildClientParams([parameters], [
13494
+ {
13495
+ args: [
13496
+ { in: "query", key: "directory" },
13497
+ { in: "query", key: "workspace" },
13498
+ { key: "config", map: "body" }
13499
+ ]
13500
+ }
13501
+ ]);
13502
+ return (options?.client ?? this.client).patch({
13503
+ url: "/config",
13504
+ ...options,
13505
+ ...params,
13506
+ headers: {
13507
+ "Content-Type": "application/json",
13508
+ ...options?.headers,
13509
+ ...params.headers
13510
+ }
13511
+ });
13512
+ }
13513
+ providers(parameters, options) {
13514
+ const params = buildClientParams([parameters], [
13515
+ {
13516
+ args: [
13517
+ { in: "query", key: "directory" },
13518
+ { in: "query", key: "workspace" }
13519
+ ]
13520
+ }
13521
+ ]);
13522
+ return (options?.client ?? this.client).get({
13523
+ url: "/config/providers",
13524
+ ...options,
13525
+ ...params
13526
+ });
13527
+ }
13528
+ }
13529
+
13530
+ class Tool extends HeyApiClient {
13531
+ ids(parameters, options) {
13532
+ const params = buildClientParams([parameters], [
13533
+ {
13534
+ args: [
13535
+ { in: "query", key: "directory" },
13536
+ { in: "query", key: "workspace" }
13537
+ ]
13538
+ }
13539
+ ]);
13540
+ return (options?.client ?? this.client).get({
13541
+ url: "/experimental/tool/ids",
13542
+ ...options,
13543
+ ...params
13544
+ });
13545
+ }
13546
+ list(parameters, options) {
13547
+ const params = buildClientParams([parameters], [
13548
+ {
13549
+ args: [
13550
+ { in: "query", key: "directory" },
13551
+ { in: "query", key: "workspace" },
13552
+ { in: "query", key: "provider" },
13553
+ { in: "query", key: "model" }
13554
+ ]
13555
+ }
13556
+ ]);
13557
+ return (options?.client ?? this.client).get({
13558
+ url: "/experimental/tool",
13559
+ ...options,
13560
+ ...params
13561
+ });
13562
+ }
13563
+ }
13564
+
13565
+ class Workspace extends HeyApiClient {
13566
+ list(parameters, options) {
13567
+ const params = buildClientParams([parameters], [
13568
+ {
13569
+ args: [
13570
+ { in: "query", key: "directory" },
13571
+ { in: "query", key: "workspace" }
13572
+ ]
13573
+ }
13574
+ ]);
13575
+ return (options?.client ?? this.client).get({
13576
+ url: "/experimental/workspace",
13577
+ ...options,
13578
+ ...params
13579
+ });
13580
+ }
13581
+ create(parameters, options) {
13582
+ const params = buildClientParams([parameters], [
13583
+ {
13584
+ args: [
13585
+ { in: "query", key: "directory" },
13586
+ { in: "query", key: "workspace" },
13587
+ { in: "body", key: "id" },
13588
+ { in: "body", key: "type" },
13589
+ { in: "body", key: "branch" },
13590
+ { in: "body", key: "extra" }
13591
+ ]
13592
+ }
13593
+ ]);
13594
+ return (options?.client ?? this.client).post({
13595
+ url: "/experimental/workspace",
13596
+ ...options,
13597
+ ...params,
13598
+ headers: {
13599
+ "Content-Type": "application/json",
13600
+ ...options?.headers,
13601
+ ...params.headers
13602
+ }
13603
+ });
13604
+ }
13605
+ remove(parameters, options) {
13606
+ const params = buildClientParams([parameters], [
13607
+ {
13608
+ args: [
13609
+ { in: "path", key: "id" },
13610
+ { in: "query", key: "directory" },
13611
+ { in: "query", key: "workspace" }
13612
+ ]
13613
+ }
13614
+ ]);
13615
+ return (options?.client ?? this.client).delete({
13616
+ url: "/experimental/workspace/{id}",
13617
+ ...options,
13618
+ ...params
13619
+ });
13620
+ }
13621
+ }
13622
+
13623
+ class Session extends HeyApiClient {
13624
+ list(parameters, options) {
13625
+ const params = buildClientParams([parameters], [
13626
+ {
13627
+ args: [
13628
+ { in: "query", key: "directory" },
13629
+ { in: "query", key: "workspace" },
13630
+ { in: "query", key: "roots" },
13631
+ { in: "query", key: "start" },
13632
+ { in: "query", key: "cursor" },
13633
+ { in: "query", key: "search" },
13634
+ { in: "query", key: "limit" },
13635
+ { in: "query", key: "archived" }
13636
+ ]
13637
+ }
13638
+ ]);
13639
+ return (options?.client ?? this.client).get({
13640
+ url: "/experimental/session",
13641
+ ...options,
13642
+ ...params
13643
+ });
13644
+ }
13645
+ }
13646
+
13647
+ class Resource extends HeyApiClient {
13648
+ list(parameters, options) {
13649
+ const params = buildClientParams([parameters], [
13650
+ {
13651
+ args: [
13652
+ { in: "query", key: "directory" },
13653
+ { in: "query", key: "workspace" }
13654
+ ]
13655
+ }
13656
+ ]);
13657
+ return (options?.client ?? this.client).get({
13658
+ url: "/experimental/resource",
13659
+ ...options,
13660
+ ...params
13661
+ });
13662
+ }
13663
+ }
13664
+
13665
+ class Experimental extends HeyApiClient {
13666
+ _workspace;
13667
+ get workspace() {
13668
+ return this._workspace ??= new Workspace({ client: this.client });
13669
+ }
13670
+ _session;
13671
+ get session() {
13672
+ return this._session ??= new Session({ client: this.client });
13673
+ }
13674
+ _resource;
13675
+ get resource() {
13676
+ return this._resource ??= new Resource({ client: this.client });
13677
+ }
13678
+ }
13679
+
13680
+ class Worktree extends HeyApiClient {
13681
+ remove(parameters, options) {
13682
+ const params = buildClientParams([parameters], [
13683
+ {
13684
+ args: [
13685
+ { in: "query", key: "directory" },
13686
+ { in: "query", key: "workspace" },
13687
+ { key: "worktreeRemoveInput", map: "body" }
13688
+ ]
13689
+ }
13690
+ ]);
13691
+ return (options?.client ?? this.client).delete({
13692
+ url: "/experimental/worktree",
13693
+ ...options,
13694
+ ...params,
13695
+ headers: {
13696
+ "Content-Type": "application/json",
13697
+ ...options?.headers,
13698
+ ...params.headers
13699
+ }
13700
+ });
13701
+ }
13702
+ list(parameters, options) {
13703
+ const params = buildClientParams([parameters], [
13704
+ {
13705
+ args: [
13706
+ { in: "query", key: "directory" },
13707
+ { in: "query", key: "workspace" }
13708
+ ]
13709
+ }
13710
+ ]);
13711
+ return (options?.client ?? this.client).get({
13712
+ url: "/experimental/worktree",
13713
+ ...options,
13714
+ ...params
13715
+ });
13716
+ }
13717
+ create(parameters, options) {
13718
+ const params = buildClientParams([parameters], [
13719
+ {
13720
+ args: [
13721
+ { in: "query", key: "directory" },
13722
+ { in: "query", key: "workspace" },
13723
+ { key: "worktreeCreateInput", map: "body" }
13724
+ ]
13725
+ }
13726
+ ]);
13727
+ return (options?.client ?? this.client).post({
13728
+ url: "/experimental/worktree",
13729
+ ...options,
13730
+ ...params,
13731
+ headers: {
13732
+ "Content-Type": "application/json",
13733
+ ...options?.headers,
13734
+ ...params.headers
13735
+ }
13736
+ });
13737
+ }
13738
+ reset(parameters, options) {
13739
+ const params = buildClientParams([parameters], [
13740
+ {
13741
+ args: [
13742
+ { in: "query", key: "directory" },
13743
+ { in: "query", key: "workspace" },
13744
+ { key: "worktreeResetInput", map: "body" }
13745
+ ]
13746
+ }
13747
+ ]);
13748
+ return (options?.client ?? this.client).post({
13749
+ url: "/experimental/worktree/reset",
13750
+ ...options,
13751
+ ...params,
13752
+ headers: {
13753
+ "Content-Type": "application/json",
13754
+ ...options?.headers,
13755
+ ...params.headers
13756
+ }
13757
+ });
13758
+ }
13759
+ }
13760
+
13761
+ class Session2 extends HeyApiClient {
13762
+ list(parameters, options) {
13763
+ const params = buildClientParams([parameters], [
13764
+ {
13765
+ args: [
13766
+ { in: "query", key: "directory" },
13767
+ { in: "query", key: "workspace" },
13768
+ { in: "query", key: "roots" },
13769
+ { in: "query", key: "start" },
13770
+ { in: "query", key: "search" },
13771
+ { in: "query", key: "limit" }
13772
+ ]
13773
+ }
13774
+ ]);
13775
+ return (options?.client ?? this.client).get({
13776
+ url: "/session",
13777
+ ...options,
13778
+ ...params
13779
+ });
13780
+ }
13781
+ create(parameters, options) {
13782
+ const params = buildClientParams([parameters], [
13783
+ {
13784
+ args: [
13785
+ { in: "query", key: "directory" },
13786
+ { in: "query", key: "workspace" },
13787
+ { in: "body", key: "parentID" },
13788
+ { in: "body", key: "title" },
13789
+ { in: "body", key: "permission" },
13790
+ { in: "body", key: "workspaceID" }
13791
+ ]
13792
+ }
13793
+ ]);
13794
+ return (options?.client ?? this.client).post({
13795
+ url: "/session",
13796
+ ...options,
13797
+ ...params,
13798
+ headers: {
13799
+ "Content-Type": "application/json",
13800
+ ...options?.headers,
13801
+ ...params.headers
13802
+ }
13803
+ });
13804
+ }
13805
+ status(parameters, options) {
13806
+ const params = buildClientParams([parameters], [
13807
+ {
13808
+ args: [
13809
+ { in: "query", key: "directory" },
13810
+ { in: "query", key: "workspace" }
13811
+ ]
13812
+ }
13813
+ ]);
13814
+ return (options?.client ?? this.client).get({
13815
+ url: "/session/status",
13816
+ ...options,
13817
+ ...params
13818
+ });
13819
+ }
13820
+ delete(parameters, options) {
13821
+ const params = buildClientParams([parameters], [
13822
+ {
13823
+ args: [
13824
+ { in: "path", key: "sessionID" },
13825
+ { in: "query", key: "directory" },
13826
+ { in: "query", key: "workspace" }
13827
+ ]
13828
+ }
13829
+ ]);
13830
+ return (options?.client ?? this.client).delete({
13831
+ url: "/session/{sessionID}",
13832
+ ...options,
13833
+ ...params
13834
+ });
13835
+ }
13836
+ get(parameters, options) {
13837
+ const params = buildClientParams([parameters], [
13838
+ {
13839
+ args: [
13840
+ { in: "path", key: "sessionID" },
13841
+ { in: "query", key: "directory" },
13842
+ { in: "query", key: "workspace" }
13843
+ ]
13844
+ }
13845
+ ]);
13846
+ return (options?.client ?? this.client).get({
13847
+ url: "/session/{sessionID}",
13848
+ ...options,
13849
+ ...params
13850
+ });
13851
+ }
13852
+ update(parameters, options) {
13853
+ const params = buildClientParams([parameters], [
13854
+ {
13855
+ args: [
13856
+ { in: "path", key: "sessionID" },
13857
+ { in: "query", key: "directory" },
13858
+ { in: "query", key: "workspace" },
13859
+ { in: "body", key: "title" },
13860
+ { in: "body", key: "time" }
13861
+ ]
13862
+ }
13863
+ ]);
13864
+ return (options?.client ?? this.client).patch({
13865
+ url: "/session/{sessionID}",
13866
+ ...options,
13867
+ ...params,
13868
+ headers: {
13869
+ "Content-Type": "application/json",
13870
+ ...options?.headers,
13871
+ ...params.headers
13872
+ }
13873
+ });
13874
+ }
13875
+ children(parameters, options) {
13876
+ const params = buildClientParams([parameters], [
13877
+ {
13878
+ args: [
13879
+ { in: "path", key: "sessionID" },
13880
+ { in: "query", key: "directory" },
13881
+ { in: "query", key: "workspace" }
13882
+ ]
13883
+ }
13884
+ ]);
13885
+ return (options?.client ?? this.client).get({
13886
+ url: "/session/{sessionID}/children",
13887
+ ...options,
13888
+ ...params
13889
+ });
13890
+ }
13891
+ todo(parameters, options) {
13892
+ const params = buildClientParams([parameters], [
13893
+ {
13894
+ args: [
13895
+ { in: "path", key: "sessionID" },
13896
+ { in: "query", key: "directory" },
13897
+ { in: "query", key: "workspace" }
13898
+ ]
13899
+ }
13900
+ ]);
13901
+ return (options?.client ?? this.client).get({
13902
+ url: "/session/{sessionID}/todo",
13903
+ ...options,
13904
+ ...params
13905
+ });
13906
+ }
13907
+ init(parameters, options) {
13908
+ const params = buildClientParams([parameters], [
13909
+ {
13910
+ args: [
13911
+ { in: "path", key: "sessionID" },
13912
+ { in: "query", key: "directory" },
13913
+ { in: "query", key: "workspace" },
13914
+ { in: "body", key: "modelID" },
13915
+ { in: "body", key: "providerID" },
13916
+ { in: "body", key: "messageID" }
13917
+ ]
13918
+ }
13919
+ ]);
13920
+ return (options?.client ?? this.client).post({
13921
+ url: "/session/{sessionID}/init",
13922
+ ...options,
13923
+ ...params,
13924
+ headers: {
13925
+ "Content-Type": "application/json",
13926
+ ...options?.headers,
13927
+ ...params.headers
13928
+ }
13929
+ });
13930
+ }
13931
+ fork(parameters, options) {
13932
+ const params = buildClientParams([parameters], [
13933
+ {
13934
+ args: [
13935
+ { in: "path", key: "sessionID" },
13936
+ { in: "query", key: "directory" },
13937
+ { in: "query", key: "workspace" },
13938
+ { in: "body", key: "messageID" }
13939
+ ]
13940
+ }
13941
+ ]);
13942
+ return (options?.client ?? this.client).post({
13943
+ url: "/session/{sessionID}/fork",
13944
+ ...options,
13945
+ ...params,
13946
+ headers: {
13947
+ "Content-Type": "application/json",
13948
+ ...options?.headers,
13949
+ ...params.headers
13950
+ }
13951
+ });
13952
+ }
13953
+ abort(parameters, options) {
13954
+ const params = buildClientParams([parameters], [
13955
+ {
13956
+ args: [
13957
+ { in: "path", key: "sessionID" },
13958
+ { in: "query", key: "directory" },
13959
+ { in: "query", key: "workspace" }
13960
+ ]
13961
+ }
13962
+ ]);
13963
+ return (options?.client ?? this.client).post({
13964
+ url: "/session/{sessionID}/abort",
13965
+ ...options,
13966
+ ...params
13967
+ });
13968
+ }
13969
+ unshare(parameters, options) {
13970
+ const params = buildClientParams([parameters], [
13971
+ {
13972
+ args: [
13973
+ { in: "path", key: "sessionID" },
13974
+ { in: "query", key: "directory" },
13975
+ { in: "query", key: "workspace" }
13976
+ ]
13977
+ }
13978
+ ]);
13979
+ return (options?.client ?? this.client).delete({
13980
+ url: "/session/{sessionID}/share",
13981
+ ...options,
13982
+ ...params
13983
+ });
13984
+ }
13985
+ share(parameters, options) {
13986
+ const params = buildClientParams([parameters], [
13987
+ {
13988
+ args: [
13989
+ { in: "path", key: "sessionID" },
13990
+ { in: "query", key: "directory" },
13991
+ { in: "query", key: "workspace" }
13992
+ ]
13993
+ }
13994
+ ]);
13995
+ return (options?.client ?? this.client).post({
13996
+ url: "/session/{sessionID}/share",
13997
+ ...options,
13998
+ ...params
13999
+ });
14000
+ }
14001
+ diff(parameters, options) {
14002
+ const params = buildClientParams([parameters], [
14003
+ {
14004
+ args: [
14005
+ { in: "path", key: "sessionID" },
14006
+ { in: "query", key: "directory" },
14007
+ { in: "query", key: "workspace" },
14008
+ { in: "query", key: "messageID" }
14009
+ ]
14010
+ }
14011
+ ]);
14012
+ return (options?.client ?? this.client).get({
14013
+ url: "/session/{sessionID}/diff",
14014
+ ...options,
14015
+ ...params
14016
+ });
14017
+ }
14018
+ summarize(parameters, options) {
14019
+ const params = buildClientParams([parameters], [
14020
+ {
14021
+ args: [
14022
+ { in: "path", key: "sessionID" },
14023
+ { in: "query", key: "directory" },
14024
+ { in: "query", key: "workspace" },
14025
+ { in: "body", key: "providerID" },
14026
+ { in: "body", key: "modelID" },
14027
+ { in: "body", key: "auto" }
14028
+ ]
14029
+ }
14030
+ ]);
14031
+ return (options?.client ?? this.client).post({
14032
+ url: "/session/{sessionID}/summarize",
14033
+ ...options,
14034
+ ...params,
14035
+ headers: {
14036
+ "Content-Type": "application/json",
14037
+ ...options?.headers,
14038
+ ...params.headers
14039
+ }
14040
+ });
14041
+ }
14042
+ messages(parameters, options) {
14043
+ const params = buildClientParams([parameters], [
14044
+ {
14045
+ args: [
14046
+ { in: "path", key: "sessionID" },
14047
+ { in: "query", key: "directory" },
14048
+ { in: "query", key: "workspace" },
14049
+ { in: "query", key: "limit" },
14050
+ { in: "query", key: "before" }
14051
+ ]
14052
+ }
14053
+ ]);
14054
+ return (options?.client ?? this.client).get({
14055
+ url: "/session/{sessionID}/message",
14056
+ ...options,
14057
+ ...params
14058
+ });
14059
+ }
14060
+ prompt(parameters, options) {
14061
+ const params = buildClientParams([parameters], [
14062
+ {
14063
+ args: [
14064
+ { in: "path", key: "sessionID" },
14065
+ { in: "query", key: "directory" },
14066
+ { in: "query", key: "workspace" },
14067
+ { in: "body", key: "messageID" },
14068
+ { in: "body", key: "model" },
14069
+ { in: "body", key: "agent" },
14070
+ { in: "body", key: "noReply" },
14071
+ { in: "body", key: "tools" },
14072
+ { in: "body", key: "format" },
14073
+ { in: "body", key: "system" },
14074
+ { in: "body", key: "variant" },
14075
+ { in: "body", key: "parts" }
14076
+ ]
14077
+ }
14078
+ ]);
14079
+ return (options?.client ?? this.client).post({
14080
+ url: "/session/{sessionID}/message",
14081
+ ...options,
14082
+ ...params,
14083
+ headers: {
14084
+ "Content-Type": "application/json",
14085
+ ...options?.headers,
14086
+ ...params.headers
14087
+ }
14088
+ });
14089
+ }
14090
+ deleteMessage(parameters, options) {
14091
+ const params = buildClientParams([parameters], [
14092
+ {
14093
+ args: [
14094
+ { in: "path", key: "sessionID" },
14095
+ { in: "path", key: "messageID" },
14096
+ { in: "query", key: "directory" },
14097
+ { in: "query", key: "workspace" }
14098
+ ]
14099
+ }
14100
+ ]);
14101
+ return (options?.client ?? this.client).delete({
14102
+ url: "/session/{sessionID}/message/{messageID}",
14103
+ ...options,
14104
+ ...params
14105
+ });
14106
+ }
14107
+ message(parameters, options) {
14108
+ const params = buildClientParams([parameters], [
14109
+ {
14110
+ args: [
14111
+ { in: "path", key: "sessionID" },
14112
+ { in: "path", key: "messageID" },
14113
+ { in: "query", key: "directory" },
14114
+ { in: "query", key: "workspace" }
14115
+ ]
14116
+ }
14117
+ ]);
14118
+ return (options?.client ?? this.client).get({
14119
+ url: "/session/{sessionID}/message/{messageID}",
14120
+ ...options,
14121
+ ...params
14122
+ });
14123
+ }
14124
+ promptAsync(parameters, options) {
14125
+ const params = buildClientParams([parameters], [
14126
+ {
14127
+ args: [
14128
+ { in: "path", key: "sessionID" },
14129
+ { in: "query", key: "directory" },
14130
+ { in: "query", key: "workspace" },
14131
+ { in: "body", key: "messageID" },
14132
+ { in: "body", key: "model" },
14133
+ { in: "body", key: "agent" },
14134
+ { in: "body", key: "noReply" },
14135
+ { in: "body", key: "tools" },
14136
+ { in: "body", key: "format" },
14137
+ { in: "body", key: "system" },
14138
+ { in: "body", key: "variant" },
14139
+ { in: "body", key: "parts" }
14140
+ ]
14141
+ }
14142
+ ]);
14143
+ return (options?.client ?? this.client).post({
14144
+ url: "/session/{sessionID}/prompt_async",
14145
+ ...options,
14146
+ ...params,
14147
+ headers: {
14148
+ "Content-Type": "application/json",
14149
+ ...options?.headers,
14150
+ ...params.headers
14151
+ }
14152
+ });
14153
+ }
14154
+ command(parameters, options) {
14155
+ const params = buildClientParams([parameters], [
14156
+ {
14157
+ args: [
14158
+ { in: "path", key: "sessionID" },
14159
+ { in: "query", key: "directory" },
14160
+ { in: "query", key: "workspace" },
14161
+ { in: "body", key: "messageID" },
14162
+ { in: "body", key: "agent" },
14163
+ { in: "body", key: "model" },
14164
+ { in: "body", key: "arguments" },
14165
+ { in: "body", key: "command" },
14166
+ { in: "body", key: "variant" },
14167
+ { in: "body", key: "parts" }
14168
+ ]
14169
+ }
14170
+ ]);
14171
+ return (options?.client ?? this.client).post({
14172
+ url: "/session/{sessionID}/command",
14173
+ ...options,
14174
+ ...params,
14175
+ headers: {
14176
+ "Content-Type": "application/json",
14177
+ ...options?.headers,
14178
+ ...params.headers
14179
+ }
14180
+ });
14181
+ }
14182
+ shell(parameters, options) {
14183
+ const params = buildClientParams([parameters], [
14184
+ {
14185
+ args: [
14186
+ { in: "path", key: "sessionID" },
14187
+ { in: "query", key: "directory" },
14188
+ { in: "query", key: "workspace" },
14189
+ { in: "body", key: "agent" },
14190
+ { in: "body", key: "model" },
14191
+ { in: "body", key: "command" }
14192
+ ]
14193
+ }
14194
+ ]);
14195
+ return (options?.client ?? this.client).post({
14196
+ url: "/session/{sessionID}/shell",
14197
+ ...options,
14198
+ ...params,
14199
+ headers: {
14200
+ "Content-Type": "application/json",
14201
+ ...options?.headers,
14202
+ ...params.headers
14203
+ }
14204
+ });
14205
+ }
14206
+ revert(parameters, options) {
14207
+ const params = buildClientParams([parameters], [
14208
+ {
14209
+ args: [
14210
+ { in: "path", key: "sessionID" },
14211
+ { in: "query", key: "directory" },
14212
+ { in: "query", key: "workspace" },
14213
+ { in: "body", key: "messageID" },
14214
+ { in: "body", key: "partID" }
14215
+ ]
14216
+ }
14217
+ ]);
14218
+ return (options?.client ?? this.client).post({
14219
+ url: "/session/{sessionID}/revert",
14220
+ ...options,
14221
+ ...params,
14222
+ headers: {
14223
+ "Content-Type": "application/json",
14224
+ ...options?.headers,
14225
+ ...params.headers
14226
+ }
14227
+ });
14228
+ }
14229
+ unrevert(parameters, options) {
14230
+ const params = buildClientParams([parameters], [
14231
+ {
14232
+ args: [
14233
+ { in: "path", key: "sessionID" },
14234
+ { in: "query", key: "directory" },
14235
+ { in: "query", key: "workspace" }
14236
+ ]
14237
+ }
14238
+ ]);
14239
+ return (options?.client ?? this.client).post({
14240
+ url: "/session/{sessionID}/unrevert",
14241
+ ...options,
14242
+ ...params
14243
+ });
14244
+ }
14245
+ }
14246
+
14247
+ class Part extends HeyApiClient {
14248
+ delete(parameters, options) {
14249
+ const params = buildClientParams([parameters], [
14250
+ {
14251
+ args: [
14252
+ { in: "path", key: "sessionID" },
14253
+ { in: "path", key: "messageID" },
14254
+ { in: "path", key: "partID" },
14255
+ { in: "query", key: "directory" },
14256
+ { in: "query", key: "workspace" }
14257
+ ]
14258
+ }
14259
+ ]);
14260
+ return (options?.client ?? this.client).delete({
14261
+ url: "/session/{sessionID}/message/{messageID}/part/{partID}",
14262
+ ...options,
14263
+ ...params
14264
+ });
14265
+ }
14266
+ update(parameters, options) {
14267
+ const params = buildClientParams([parameters], [
14268
+ {
14269
+ args: [
14270
+ { in: "path", key: "sessionID" },
14271
+ { in: "path", key: "messageID" },
14272
+ { in: "path", key: "partID" },
14273
+ { in: "query", key: "directory" },
14274
+ { in: "query", key: "workspace" },
14275
+ { key: "part", map: "body" }
14276
+ ]
14277
+ }
14278
+ ]);
14279
+ return (options?.client ?? this.client).patch({
14280
+ url: "/session/{sessionID}/message/{messageID}/part/{partID}",
14281
+ ...options,
14282
+ ...params,
14283
+ headers: {
14284
+ "Content-Type": "application/json",
14285
+ ...options?.headers,
14286
+ ...params.headers
14287
+ }
14288
+ });
14289
+ }
14290
+ }
14291
+
14292
+ class Permission extends HeyApiClient {
14293
+ respond(parameters, options) {
14294
+ const params = buildClientParams([parameters], [
14295
+ {
14296
+ args: [
14297
+ { in: "path", key: "sessionID" },
14298
+ { in: "path", key: "permissionID" },
14299
+ { in: "query", key: "directory" },
14300
+ { in: "query", key: "workspace" },
14301
+ { in: "body", key: "response" }
14302
+ ]
14303
+ }
14304
+ ]);
14305
+ return (options?.client ?? this.client).post({
14306
+ url: "/session/{sessionID}/permissions/{permissionID}",
14307
+ ...options,
14308
+ ...params,
14309
+ headers: {
14310
+ "Content-Type": "application/json",
14311
+ ...options?.headers,
14312
+ ...params.headers
14313
+ }
14314
+ });
14315
+ }
14316
+ reply(parameters, options) {
14317
+ const params = buildClientParams([parameters], [
14318
+ {
14319
+ args: [
14320
+ { in: "path", key: "requestID" },
14321
+ { in: "query", key: "directory" },
14322
+ { in: "query", key: "workspace" },
14323
+ { in: "body", key: "reply" },
14324
+ { in: "body", key: "message" }
14325
+ ]
14326
+ }
14327
+ ]);
14328
+ return (options?.client ?? this.client).post({
14329
+ url: "/permission/{requestID}/reply",
14330
+ ...options,
14331
+ ...params,
14332
+ headers: {
14333
+ "Content-Type": "application/json",
14334
+ ...options?.headers,
14335
+ ...params.headers
14336
+ }
14337
+ });
14338
+ }
14339
+ list(parameters, options) {
14340
+ const params = buildClientParams([parameters], [
14341
+ {
14342
+ args: [
14343
+ { in: "query", key: "directory" },
14344
+ { in: "query", key: "workspace" }
14345
+ ]
14346
+ }
14347
+ ]);
14348
+ return (options?.client ?? this.client).get({
14349
+ url: "/permission",
14350
+ ...options,
14351
+ ...params
14352
+ });
14353
+ }
14354
+ }
14355
+
14356
+ class Question extends HeyApiClient {
14357
+ list(parameters, options) {
14358
+ const params = buildClientParams([parameters], [
14359
+ {
14360
+ args: [
14361
+ { in: "query", key: "directory" },
14362
+ { in: "query", key: "workspace" }
14363
+ ]
14364
+ }
14365
+ ]);
14366
+ return (options?.client ?? this.client).get({
14367
+ url: "/question",
14368
+ ...options,
14369
+ ...params
14370
+ });
14371
+ }
14372
+ reply(parameters, options) {
14373
+ const params = buildClientParams([parameters], [
14374
+ {
14375
+ args: [
14376
+ { in: "path", key: "requestID" },
14377
+ { in: "query", key: "directory" },
14378
+ { in: "query", key: "workspace" },
14379
+ { in: "body", key: "answers" }
14380
+ ]
14381
+ }
14382
+ ]);
14383
+ return (options?.client ?? this.client).post({
14384
+ url: "/question/{requestID}/reply",
14385
+ ...options,
14386
+ ...params,
14387
+ headers: {
14388
+ "Content-Type": "application/json",
14389
+ ...options?.headers,
14390
+ ...params.headers
14391
+ }
14392
+ });
14393
+ }
14394
+ reject(parameters, options) {
14395
+ const params = buildClientParams([parameters], [
14396
+ {
14397
+ args: [
14398
+ { in: "path", key: "requestID" },
14399
+ { in: "query", key: "directory" },
14400
+ { in: "query", key: "workspace" }
14401
+ ]
14402
+ }
14403
+ ]);
14404
+ return (options?.client ?? this.client).post({
14405
+ url: "/question/{requestID}/reject",
14406
+ ...options,
14407
+ ...params
14408
+ });
14409
+ }
14410
+ }
14411
+
14412
+ class Oauth extends HeyApiClient {
14413
+ authorize(parameters, options) {
14414
+ const params = buildClientParams([parameters], [
14415
+ {
14416
+ args: [
14417
+ { in: "path", key: "providerID" },
14418
+ { in: "query", key: "directory" },
14419
+ { in: "query", key: "workspace" },
14420
+ { in: "body", key: "method" },
14421
+ { in: "body", key: "inputs" }
14422
+ ]
14423
+ }
14424
+ ]);
14425
+ return (options?.client ?? this.client).post({
14426
+ url: "/provider/{providerID}/oauth/authorize",
14427
+ ...options,
14428
+ ...params,
14429
+ headers: {
14430
+ "Content-Type": "application/json",
14431
+ ...options?.headers,
14432
+ ...params.headers
14433
+ }
14434
+ });
14435
+ }
14436
+ callback(parameters, options) {
14437
+ const params = buildClientParams([parameters], [
14438
+ {
14439
+ args: [
14440
+ { in: "path", key: "providerID" },
14441
+ { in: "query", key: "directory" },
14442
+ { in: "query", key: "workspace" },
14443
+ { in: "body", key: "method" },
14444
+ { in: "body", key: "code" }
14445
+ ]
14446
+ }
14447
+ ]);
14448
+ return (options?.client ?? this.client).post({
14449
+ url: "/provider/{providerID}/oauth/callback",
14450
+ ...options,
14451
+ ...params,
14452
+ headers: {
14453
+ "Content-Type": "application/json",
14454
+ ...options?.headers,
14455
+ ...params.headers
14456
+ }
14457
+ });
14458
+ }
14459
+ }
14460
+
14461
+ class Provider extends HeyApiClient {
14462
+ list(parameters, options) {
14463
+ const params = buildClientParams([parameters], [
14464
+ {
14465
+ args: [
14466
+ { in: "query", key: "directory" },
14467
+ { in: "query", key: "workspace" }
14468
+ ]
14469
+ }
14470
+ ]);
14471
+ return (options?.client ?? this.client).get({
14472
+ url: "/provider",
14473
+ ...options,
14474
+ ...params
14475
+ });
14476
+ }
14477
+ auth(parameters, options) {
14478
+ const params = buildClientParams([parameters], [
14479
+ {
14480
+ args: [
14481
+ { in: "query", key: "directory" },
14482
+ { in: "query", key: "workspace" }
14483
+ ]
14484
+ }
14485
+ ]);
14486
+ return (options?.client ?? this.client).get({
14487
+ url: "/provider/auth",
14488
+ ...options,
14489
+ ...params
14490
+ });
14491
+ }
14492
+ _oauth;
14493
+ get oauth() {
14494
+ return this._oauth ??= new Oauth({ client: this.client });
14495
+ }
14496
+ }
14497
+
14498
+ class Find extends HeyApiClient {
14499
+ text(parameters, options) {
14500
+ const params = buildClientParams([parameters], [
14501
+ {
14502
+ args: [
14503
+ { in: "query", key: "directory" },
14504
+ { in: "query", key: "workspace" },
14505
+ { in: "query", key: "pattern" }
14506
+ ]
14507
+ }
14508
+ ]);
14509
+ return (options?.client ?? this.client).get({
14510
+ url: "/find",
14511
+ ...options,
14512
+ ...params
14513
+ });
14514
+ }
14515
+ files(parameters, options) {
14516
+ const params = buildClientParams([parameters], [
14517
+ {
14518
+ args: [
14519
+ { in: "query", key: "directory" },
14520
+ { in: "query", key: "workspace" },
14521
+ { in: "query", key: "query" },
14522
+ { in: "query", key: "dirs" },
14523
+ { in: "query", key: "type" },
14524
+ { in: "query", key: "limit" }
14525
+ ]
14526
+ }
14527
+ ]);
14528
+ return (options?.client ?? this.client).get({
14529
+ url: "/find/file",
14530
+ ...options,
14531
+ ...params
14532
+ });
14533
+ }
14534
+ symbols(parameters, options) {
14535
+ const params = buildClientParams([parameters], [
14536
+ {
14537
+ args: [
14538
+ { in: "query", key: "directory" },
14539
+ { in: "query", key: "workspace" },
14540
+ { in: "query", key: "query" }
14541
+ ]
14542
+ }
14543
+ ]);
14544
+ return (options?.client ?? this.client).get({
14545
+ url: "/find/symbol",
14546
+ ...options,
14547
+ ...params
14548
+ });
14549
+ }
14550
+ }
14551
+
14552
+ class File2 extends HeyApiClient {
14553
+ list(parameters, options) {
14554
+ const params = buildClientParams([parameters], [
14555
+ {
14556
+ args: [
14557
+ { in: "query", key: "directory" },
14558
+ { in: "query", key: "workspace" },
14559
+ { in: "query", key: "path" }
14560
+ ]
14561
+ }
14562
+ ]);
14563
+ return (options?.client ?? this.client).get({
14564
+ url: "/file",
14565
+ ...options,
14566
+ ...params
14567
+ });
14568
+ }
14569
+ read(parameters, options) {
14570
+ const params = buildClientParams([parameters], [
14571
+ {
14572
+ args: [
14573
+ { in: "query", key: "directory" },
14574
+ { in: "query", key: "workspace" },
14575
+ { in: "query", key: "path" }
14576
+ ]
14577
+ }
14578
+ ]);
14579
+ return (options?.client ?? this.client).get({
14580
+ url: "/file/content",
14581
+ ...options,
14582
+ ...params
14583
+ });
14584
+ }
14585
+ status(parameters, options) {
14586
+ const params = buildClientParams([parameters], [
14587
+ {
14588
+ args: [
14589
+ { in: "query", key: "directory" },
14590
+ { in: "query", key: "workspace" }
14591
+ ]
14592
+ }
14593
+ ]);
14594
+ return (options?.client ?? this.client).get({
14595
+ url: "/file/status",
14596
+ ...options,
14597
+ ...params
14598
+ });
14599
+ }
14600
+ }
14601
+
14602
+ class Event extends HeyApiClient {
14603
+ subscribe(parameters, options) {
14604
+ const params = buildClientParams([parameters], [
14605
+ {
14606
+ args: [
14607
+ { in: "query", key: "directory" },
14608
+ { in: "query", key: "workspace" }
14609
+ ]
14610
+ }
14611
+ ]);
14612
+ return (options?.client ?? this.client).sse.get({
14613
+ url: "/event",
14614
+ ...options,
14615
+ ...params
14616
+ });
14617
+ }
14618
+ }
14619
+
14620
+ class Auth2 extends HeyApiClient {
14621
+ remove(parameters, options) {
14622
+ const params = buildClientParams([parameters], [
14623
+ {
14624
+ args: [
14625
+ { in: "path", key: "name" },
14626
+ { in: "query", key: "directory" },
14627
+ { in: "query", key: "workspace" }
14628
+ ]
14629
+ }
14630
+ ]);
14631
+ return (options?.client ?? this.client).delete({
14632
+ url: "/mcp/{name}/auth",
14633
+ ...options,
14634
+ ...params
14635
+ });
14636
+ }
14637
+ start(parameters, options) {
14638
+ const params = buildClientParams([parameters], [
14639
+ {
14640
+ args: [
14641
+ { in: "path", key: "name" },
14642
+ { in: "query", key: "directory" },
14643
+ { in: "query", key: "workspace" }
14644
+ ]
14645
+ }
14646
+ ]);
14647
+ return (options?.client ?? this.client).post({
14648
+ url: "/mcp/{name}/auth",
14649
+ ...options,
14650
+ ...params
14651
+ });
14652
+ }
14653
+ callback(parameters, options) {
14654
+ const params = buildClientParams([parameters], [
14655
+ {
14656
+ args: [
14657
+ { in: "path", key: "name" },
14658
+ { in: "query", key: "directory" },
14659
+ { in: "query", key: "workspace" },
14660
+ { in: "body", key: "code" }
14661
+ ]
14662
+ }
14663
+ ]);
14664
+ return (options?.client ?? this.client).post({
14665
+ url: "/mcp/{name}/auth/callback",
14666
+ ...options,
14667
+ ...params,
14668
+ headers: {
14669
+ "Content-Type": "application/json",
14670
+ ...options?.headers,
14671
+ ...params.headers
14672
+ }
14673
+ });
14674
+ }
14675
+ authenticate(parameters, options) {
14676
+ const params = buildClientParams([parameters], [
14677
+ {
14678
+ args: [
14679
+ { in: "path", key: "name" },
14680
+ { in: "query", key: "directory" },
14681
+ { in: "query", key: "workspace" }
14682
+ ]
14683
+ }
14684
+ ]);
14685
+ return (options?.client ?? this.client).post({
14686
+ url: "/mcp/{name}/auth/authenticate",
14687
+ ...options,
14688
+ ...params
14689
+ });
14690
+ }
14691
+ }
14692
+
14693
+ class Mcp extends HeyApiClient {
14694
+ status(parameters, options) {
14695
+ const params = buildClientParams([parameters], [
14696
+ {
14697
+ args: [
14698
+ { in: "query", key: "directory" },
14699
+ { in: "query", key: "workspace" }
14700
+ ]
14701
+ }
14702
+ ]);
14703
+ return (options?.client ?? this.client).get({
14704
+ url: "/mcp",
14705
+ ...options,
14706
+ ...params
14707
+ });
14708
+ }
14709
+ add(parameters, options) {
14710
+ const params = buildClientParams([parameters], [
14711
+ {
14712
+ args: [
14713
+ { in: "query", key: "directory" },
14714
+ { in: "query", key: "workspace" },
14715
+ { in: "body", key: "name" },
14716
+ { in: "body", key: "config" }
14717
+ ]
14718
+ }
14719
+ ]);
14720
+ return (options?.client ?? this.client).post({
14721
+ url: "/mcp",
14722
+ ...options,
14723
+ ...params,
14724
+ headers: {
14725
+ "Content-Type": "application/json",
14726
+ ...options?.headers,
14727
+ ...params.headers
14728
+ }
14729
+ });
14730
+ }
14731
+ connect(parameters, options) {
14732
+ const params = buildClientParams([parameters], [
14733
+ {
14734
+ args: [
14735
+ { in: "path", key: "name" },
14736
+ { in: "query", key: "directory" },
14737
+ { in: "query", key: "workspace" }
14738
+ ]
14739
+ }
14740
+ ]);
14741
+ return (options?.client ?? this.client).post({
14742
+ url: "/mcp/{name}/connect",
14743
+ ...options,
14744
+ ...params
14745
+ });
14746
+ }
14747
+ disconnect(parameters, options) {
14748
+ const params = buildClientParams([parameters], [
14749
+ {
14750
+ args: [
14751
+ { in: "path", key: "name" },
14752
+ { in: "query", key: "directory" },
14753
+ { in: "query", key: "workspace" }
14754
+ ]
14755
+ }
14756
+ ]);
14757
+ return (options?.client ?? this.client).post({
14758
+ url: "/mcp/{name}/disconnect",
14759
+ ...options,
14760
+ ...params
14761
+ });
14762
+ }
14763
+ _auth;
14764
+ get auth() {
14765
+ return this._auth ??= new Auth2({ client: this.client });
14766
+ }
14767
+ }
14768
+
14769
+ class Control extends HeyApiClient {
14770
+ next(parameters, options) {
14771
+ const params = buildClientParams([parameters], [
14772
+ {
14773
+ args: [
14774
+ { in: "query", key: "directory" },
14775
+ { in: "query", key: "workspace" }
14776
+ ]
14777
+ }
14778
+ ]);
14779
+ return (options?.client ?? this.client).get({
14780
+ url: "/tui/control/next",
14781
+ ...options,
14782
+ ...params
14783
+ });
14784
+ }
14785
+ response(parameters, options) {
14786
+ const params = buildClientParams([parameters], [
14787
+ {
14788
+ args: [
14789
+ { in: "query", key: "directory" },
14790
+ { in: "query", key: "workspace" },
14791
+ { key: "body", map: "body" }
14792
+ ]
14793
+ }
14794
+ ]);
14795
+ return (options?.client ?? this.client).post({
14796
+ url: "/tui/control/response",
14797
+ ...options,
14798
+ ...params,
14799
+ headers: {
14800
+ "Content-Type": "application/json",
14801
+ ...options?.headers,
14802
+ ...params.headers
14803
+ }
14804
+ });
14805
+ }
14806
+ }
14807
+
14808
+ class Tui extends HeyApiClient {
14809
+ appendPrompt(parameters, options) {
14810
+ const params = buildClientParams([parameters], [
14811
+ {
14812
+ args: [
14813
+ { in: "query", key: "directory" },
14814
+ { in: "query", key: "workspace" },
14815
+ { in: "body", key: "text" }
14816
+ ]
14817
+ }
14818
+ ]);
14819
+ return (options?.client ?? this.client).post({
14820
+ url: "/tui/append-prompt",
14821
+ ...options,
14822
+ ...params,
14823
+ headers: {
14824
+ "Content-Type": "application/json",
14825
+ ...options?.headers,
14826
+ ...params.headers
14827
+ }
14828
+ });
14829
+ }
14830
+ openHelp(parameters, options) {
14831
+ const params = buildClientParams([parameters], [
14832
+ {
14833
+ args: [
14834
+ { in: "query", key: "directory" },
14835
+ { in: "query", key: "workspace" }
14836
+ ]
14837
+ }
14838
+ ]);
14839
+ return (options?.client ?? this.client).post({
14840
+ url: "/tui/open-help",
14841
+ ...options,
14842
+ ...params
14843
+ });
14844
+ }
14845
+ openSessions(parameters, options) {
14846
+ const params = buildClientParams([parameters], [
14847
+ {
14848
+ args: [
14849
+ { in: "query", key: "directory" },
14850
+ { in: "query", key: "workspace" }
14851
+ ]
14852
+ }
14853
+ ]);
14854
+ return (options?.client ?? this.client).post({
14855
+ url: "/tui/open-sessions",
14856
+ ...options,
14857
+ ...params
14858
+ });
14859
+ }
14860
+ openThemes(parameters, options) {
14861
+ const params = buildClientParams([parameters], [
14862
+ {
14863
+ args: [
14864
+ { in: "query", key: "directory" },
14865
+ { in: "query", key: "workspace" }
14866
+ ]
14867
+ }
14868
+ ]);
14869
+ return (options?.client ?? this.client).post({
14870
+ url: "/tui/open-themes",
14871
+ ...options,
14872
+ ...params
14873
+ });
14874
+ }
14875
+ openModels(parameters, options) {
14876
+ const params = buildClientParams([parameters], [
14877
+ {
14878
+ args: [
14879
+ { in: "query", key: "directory" },
14880
+ { in: "query", key: "workspace" }
14881
+ ]
14882
+ }
14883
+ ]);
14884
+ return (options?.client ?? this.client).post({
14885
+ url: "/tui/open-models",
14886
+ ...options,
14887
+ ...params
14888
+ });
14889
+ }
14890
+ submitPrompt(parameters, options) {
14891
+ const params = buildClientParams([parameters], [
14892
+ {
14893
+ args: [
14894
+ { in: "query", key: "directory" },
14895
+ { in: "query", key: "workspace" }
14896
+ ]
14897
+ }
14898
+ ]);
14899
+ return (options?.client ?? this.client).post({
14900
+ url: "/tui/submit-prompt",
14901
+ ...options,
14902
+ ...params
14903
+ });
14904
+ }
14905
+ clearPrompt(parameters, options) {
14906
+ const params = buildClientParams([parameters], [
14907
+ {
14908
+ args: [
14909
+ { in: "query", key: "directory" },
14910
+ { in: "query", key: "workspace" }
14911
+ ]
14912
+ }
14913
+ ]);
14914
+ return (options?.client ?? this.client).post({
14915
+ url: "/tui/clear-prompt",
14916
+ ...options,
14917
+ ...params
14918
+ });
14919
+ }
14920
+ executeCommand(parameters, options) {
14921
+ const params = buildClientParams([parameters], [
14922
+ {
14923
+ args: [
14924
+ { in: "query", key: "directory" },
14925
+ { in: "query", key: "workspace" },
14926
+ { in: "body", key: "command" }
14927
+ ]
14928
+ }
14929
+ ]);
14930
+ return (options?.client ?? this.client).post({
14931
+ url: "/tui/execute-command",
14932
+ ...options,
14933
+ ...params,
14934
+ headers: {
14935
+ "Content-Type": "application/json",
14936
+ ...options?.headers,
14937
+ ...params.headers
14938
+ }
14939
+ });
14940
+ }
14941
+ showToast(parameters, options) {
14942
+ const params = buildClientParams([parameters], [
14943
+ {
14944
+ args: [
14945
+ { in: "query", key: "directory" },
14946
+ { in: "query", key: "workspace" },
14947
+ { in: "body", key: "title" },
14948
+ { in: "body", key: "message" },
14949
+ { in: "body", key: "variant" },
14950
+ { in: "body", key: "duration" }
14951
+ ]
14952
+ }
14953
+ ]);
14954
+ return (options?.client ?? this.client).post({
14955
+ url: "/tui/show-toast",
14956
+ ...options,
14957
+ ...params,
14958
+ headers: {
14959
+ "Content-Type": "application/json",
14960
+ ...options?.headers,
14961
+ ...params.headers
14962
+ }
14963
+ });
14964
+ }
14965
+ publish(parameters, options) {
14966
+ const params = buildClientParams([parameters], [
14967
+ {
14968
+ args: [
14969
+ { in: "query", key: "directory" },
14970
+ { in: "query", key: "workspace" },
14971
+ { key: "body", map: "body" }
14972
+ ]
14973
+ }
14974
+ ]);
14975
+ return (options?.client ?? this.client).post({
14976
+ url: "/tui/publish",
14977
+ ...options,
14978
+ ...params,
14979
+ headers: {
14980
+ "Content-Type": "application/json",
14981
+ ...options?.headers,
14982
+ ...params.headers
14983
+ }
14984
+ });
14985
+ }
14986
+ selectSession(parameters, options) {
14987
+ const params = buildClientParams([parameters], [
14988
+ {
14989
+ args: [
14990
+ { in: "query", key: "directory" },
14991
+ { in: "query", key: "workspace" },
14992
+ { in: "body", key: "sessionID" }
14993
+ ]
14994
+ }
14995
+ ]);
14996
+ return (options?.client ?? this.client).post({
14997
+ url: "/tui/select-session",
14998
+ ...options,
14999
+ ...params,
15000
+ headers: {
15001
+ "Content-Type": "application/json",
15002
+ ...options?.headers,
15003
+ ...params.headers
15004
+ }
15005
+ });
15006
+ }
15007
+ _control;
15008
+ get control() {
15009
+ return this._control ??= new Control({ client: this.client });
15010
+ }
15011
+ }
15012
+
15013
+ class Instance extends HeyApiClient {
15014
+ dispose(parameters, options) {
15015
+ const params = buildClientParams([parameters], [
15016
+ {
15017
+ args: [
15018
+ { in: "query", key: "directory" },
15019
+ { in: "query", key: "workspace" }
15020
+ ]
15021
+ }
15022
+ ]);
15023
+ return (options?.client ?? this.client).post({
15024
+ url: "/instance/dispose",
15025
+ ...options,
15026
+ ...params
15027
+ });
15028
+ }
15029
+ }
15030
+
15031
+ class Path extends HeyApiClient {
15032
+ get(parameters, options) {
15033
+ const params = buildClientParams([parameters], [
15034
+ {
15035
+ args: [
15036
+ { in: "query", key: "directory" },
15037
+ { in: "query", key: "workspace" }
15038
+ ]
15039
+ }
15040
+ ]);
15041
+ return (options?.client ?? this.client).get({
15042
+ url: "/path",
15043
+ ...options,
15044
+ ...params
15045
+ });
15046
+ }
15047
+ }
15048
+
15049
+ class Vcs extends HeyApiClient {
15050
+ get(parameters, options) {
15051
+ const params = buildClientParams([parameters], [
15052
+ {
15053
+ args: [
15054
+ { in: "query", key: "directory" },
15055
+ { in: "query", key: "workspace" }
15056
+ ]
15057
+ }
15058
+ ]);
15059
+ return (options?.client ?? this.client).get({
15060
+ url: "/vcs",
15061
+ ...options,
15062
+ ...params
15063
+ });
15064
+ }
15065
+ }
15066
+
15067
+ class Command extends HeyApiClient {
15068
+ list(parameters, options) {
15069
+ const params = buildClientParams([parameters], [
15070
+ {
15071
+ args: [
15072
+ { in: "query", key: "directory" },
15073
+ { in: "query", key: "workspace" }
15074
+ ]
15075
+ }
15076
+ ]);
15077
+ return (options?.client ?? this.client).get({
15078
+ url: "/command",
15079
+ ...options,
15080
+ ...params
15081
+ });
15082
+ }
15083
+ }
15084
+
15085
+ class App extends HeyApiClient {
15086
+ log(parameters, options) {
15087
+ const params = buildClientParams([parameters], [
15088
+ {
15089
+ args: [
15090
+ { in: "query", key: "directory" },
15091
+ { in: "query", key: "workspace" },
15092
+ { in: "body", key: "service" },
15093
+ { in: "body", key: "level" },
15094
+ { in: "body", key: "message" },
15095
+ { in: "body", key: "extra" }
15096
+ ]
15097
+ }
15098
+ ]);
15099
+ return (options?.client ?? this.client).post({
15100
+ url: "/log",
15101
+ ...options,
15102
+ ...params,
15103
+ headers: {
15104
+ "Content-Type": "application/json",
15105
+ ...options?.headers,
15106
+ ...params.headers
15107
+ }
15108
+ });
15109
+ }
15110
+ agents(parameters, options) {
15111
+ const params = buildClientParams([parameters], [
15112
+ {
15113
+ args: [
15114
+ { in: "query", key: "directory" },
15115
+ { in: "query", key: "workspace" }
15116
+ ]
15117
+ }
15118
+ ]);
15119
+ return (options?.client ?? this.client).get({
15120
+ url: "/agent",
15121
+ ...options,
15122
+ ...params
15123
+ });
15124
+ }
15125
+ skills(parameters, options) {
15126
+ const params = buildClientParams([parameters], [
15127
+ {
15128
+ args: [
15129
+ { in: "query", key: "directory" },
15130
+ { in: "query", key: "workspace" }
15131
+ ]
15132
+ }
15133
+ ]);
15134
+ return (options?.client ?? this.client).get({
15135
+ url: "/skill",
15136
+ ...options,
15137
+ ...params
15138
+ });
15139
+ }
15140
+ }
15141
+
15142
+ class Lsp extends HeyApiClient {
15143
+ status(parameters, options) {
15144
+ const params = buildClientParams([parameters], [
15145
+ {
15146
+ args: [
15147
+ { in: "query", key: "directory" },
15148
+ { in: "query", key: "workspace" }
15149
+ ]
15150
+ }
15151
+ ]);
15152
+ return (options?.client ?? this.client).get({
15153
+ url: "/lsp",
15154
+ ...options,
15155
+ ...params
15156
+ });
15157
+ }
15158
+ }
15159
+
15160
+ class Formatter extends HeyApiClient {
15161
+ status(parameters, options) {
15162
+ const params = buildClientParams([parameters], [
15163
+ {
15164
+ args: [
15165
+ { in: "query", key: "directory" },
15166
+ { in: "query", key: "workspace" }
15167
+ ]
15168
+ }
15169
+ ]);
15170
+ return (options?.client ?? this.client).get({
15171
+ url: "/formatter",
15172
+ ...options,
15173
+ ...params
15174
+ });
15175
+ }
15176
+ }
15177
+
15178
+ class OpencodeClient extends HeyApiClient {
15179
+ static __registry = new HeyApiRegistry;
15180
+ constructor(args) {
15181
+ super(args);
15182
+ OpencodeClient.__registry.set(this, args?.key);
15183
+ }
15184
+ _global;
15185
+ get global() {
15186
+ return this._global ??= new Global({ client: this.client });
15187
+ }
15188
+ _auth;
15189
+ get auth() {
15190
+ return this._auth ??= new Auth({ client: this.client });
15191
+ }
15192
+ _project;
15193
+ get project() {
15194
+ return this._project ??= new Project({ client: this.client });
15195
+ }
15196
+ _pty;
15197
+ get pty() {
15198
+ return this._pty ??= new Pty({ client: this.client });
15199
+ }
15200
+ _config;
15201
+ get config() {
15202
+ return this._config ??= new Config2({ client: this.client });
15203
+ }
15204
+ _tool;
15205
+ get tool() {
15206
+ return this._tool ??= new Tool({ client: this.client });
15207
+ }
15208
+ _experimental;
15209
+ get experimental() {
15210
+ return this._experimental ??= new Experimental({ client: this.client });
15211
+ }
15212
+ _worktree;
15213
+ get worktree() {
15214
+ return this._worktree ??= new Worktree({ client: this.client });
15215
+ }
15216
+ _session;
15217
+ get session() {
15218
+ return this._session ??= new Session2({ client: this.client });
15219
+ }
15220
+ _part;
15221
+ get part() {
15222
+ return this._part ??= new Part({ client: this.client });
15223
+ }
15224
+ _permission;
15225
+ get permission() {
15226
+ return this._permission ??= new Permission({ client: this.client });
15227
+ }
15228
+ _question;
15229
+ get question() {
15230
+ return this._question ??= new Question({ client: this.client });
15231
+ }
15232
+ _provider;
15233
+ get provider() {
15234
+ return this._provider ??= new Provider({ client: this.client });
15235
+ }
15236
+ _find;
15237
+ get find() {
15238
+ return this._find ??= new Find({ client: this.client });
15239
+ }
15240
+ _file;
15241
+ get file() {
15242
+ return this._file ??= new File2({ client: this.client });
15243
+ }
15244
+ _event;
15245
+ get event() {
15246
+ return this._event ??= new Event({ client: this.client });
15247
+ }
15248
+ _mcp;
15249
+ get mcp() {
15250
+ return this._mcp ??= new Mcp({ client: this.client });
15251
+ }
15252
+ _tui;
15253
+ get tui() {
15254
+ return this._tui ??= new Tui({ client: this.client });
15255
+ }
15256
+ _instance;
15257
+ get instance() {
15258
+ return this._instance ??= new Instance({ client: this.client });
15259
+ }
15260
+ _path;
15261
+ get path() {
15262
+ return this._path ??= new Path({ client: this.client });
15263
+ }
15264
+ _vcs;
15265
+ get vcs() {
15266
+ return this._vcs ??= new Vcs({ client: this.client });
15267
+ }
15268
+ _command;
15269
+ get command() {
15270
+ return this._command ??= new Command({ client: this.client });
15271
+ }
15272
+ _app;
15273
+ get app() {
15274
+ return this._app ??= new App({ client: this.client });
15275
+ }
15276
+ _lsp;
15277
+ get lsp() {
15278
+ return this._lsp ??= new Lsp({ client: this.client });
15279
+ }
15280
+ _formatter;
15281
+ get formatter() {
15282
+ return this._formatter ??= new Formatter({ client: this.client });
15283
+ }
15284
+ }
15285
+ // src/index.ts
15286
+ import path3 from "path";
15287
+ import { mkdirSync } from "fs";
15288
+
15289
+ // src/db.ts
15290
+ import { Database } from "bun:sqlite";
15291
+ import path from "path";
15292
+
15293
+ // src/schema.ts
15294
+ var MIGRATIONS = [
15295
+ `
15296
+ CREATE TABLE IF NOT EXISTS team (
15297
+ id TEXT PRIMARY KEY,
15298
+ name TEXT NOT NULL UNIQUE,
15299
+ lead_session_id TEXT NOT NULL,
15300
+ status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active', 'archived')),
15301
+ delegate INTEGER NOT NULL DEFAULT 0,
15302
+ time_created INTEGER NOT NULL,
15303
+ time_updated INTEGER NOT NULL
15304
+ );
15305
+ CREATE INDEX IF NOT EXISTS team_lead_idx ON team(lead_session_id);
15306
+ CREATE INDEX IF NOT EXISTS team_status_idx ON team(status);
15307
+
15308
+ CREATE TABLE IF NOT EXISTS team_member (
15309
+ team_id TEXT NOT NULL REFERENCES team(id) ON DELETE CASCADE,
15310
+ name TEXT NOT NULL,
15311
+ session_id TEXT NOT NULL,
15312
+ agent TEXT NOT NULL,
15313
+ status TEXT NOT NULL DEFAULT 'ready'
15314
+ CHECK(status IN ('ready', 'busy', 'shutdown_requested', 'shutdown', 'error')),
15315
+ execution_status TEXT NOT NULL DEFAULT 'idle'
15316
+ CHECK(execution_status IN ('idle', 'starting', 'running',
15317
+ 'cancel_requested', 'cancelling', 'cancelled',
15318
+ 'completing', 'completed', 'failed', 'timed_out')),
15319
+ model TEXT,
15320
+ prompt TEXT,
15321
+ time_created INTEGER NOT NULL,
15322
+ time_updated INTEGER NOT NULL,
15323
+ PRIMARY KEY (team_id, name)
15324
+ );
15325
+ CREATE INDEX IF NOT EXISTS team_member_session_idx ON team_member(session_id);
15326
+ CREATE INDEX IF NOT EXISTS team_member_status_idx ON team_member(team_id, status);
15327
+
15328
+ CREATE TABLE IF NOT EXISTS team_task (
15329
+ id TEXT PRIMARY KEY,
15330
+ team_id TEXT NOT NULL REFERENCES team(id) ON DELETE CASCADE,
15331
+ content TEXT NOT NULL,
15332
+ status TEXT NOT NULL DEFAULT 'pending'
15333
+ CHECK(status IN ('pending', 'in_progress', 'completed', 'cancelled', 'blocked')),
15334
+ priority TEXT NOT NULL DEFAULT 'medium'
15335
+ CHECK(priority IN ('high', 'medium', 'low')),
15336
+ assignee TEXT,
15337
+ depends_on TEXT,
15338
+ time_created INTEGER NOT NULL,
15339
+ time_updated INTEGER NOT NULL
15340
+ );
15341
+ CREATE INDEX IF NOT EXISTS team_task_team_idx ON team_task(team_id);
15342
+ CREATE INDEX IF NOT EXISTS team_task_assignee_idx ON team_task(assignee);
15343
+ CREATE INDEX IF NOT EXISTS team_task_status_idx ON team_task(team_id, status);
15344
+
15345
+ CREATE TABLE IF NOT EXISTS team_message (
15346
+ id TEXT PRIMARY KEY,
15347
+ team_id TEXT NOT NULL REFERENCES team(id) ON DELETE CASCADE,
15348
+ from_name TEXT NOT NULL,
15349
+ to_name TEXT,
15350
+ content TEXT NOT NULL,
15351
+ delivered INTEGER NOT NULL DEFAULT 0,
15352
+ time_created INTEGER NOT NULL
15353
+ );
15354
+ CREATE INDEX IF NOT EXISTS team_message_team_idx ON team_message(team_id);
15355
+ CREATE INDEX IF NOT EXISTS team_message_to_idx ON team_message(to_name);
15356
+ CREATE INDEX IF NOT EXISTS team_message_undelivered_idx ON team_message(team_id, delivered)
15357
+ WHERE delivered = 0;
15358
+ `,
15359
+ `ALTER TABLE team_message ADD COLUMN read INTEGER NOT NULL DEFAULT 0;
15360
+ CREATE INDEX IF NOT EXISTS team_message_unread_idx ON team_message(team_id, read) WHERE read = 0;`,
15361
+ `ALTER TABLE team_member ADD COLUMN worktree_dir TEXT;
15362
+ ALTER TABLE team_member ADD COLUMN worktree_branch TEXT;`,
15363
+ `ALTER TABLE team_member ADD COLUMN plan_approval TEXT NOT NULL DEFAULT 'none'
15364
+ CHECK(plan_approval IN ('none', 'pending', 'approved', 'rejected'));`,
15365
+ `ALTER TABLE team ADD COLUMN lead_agent TEXT;`
15366
+ ];
15367
+ function applyMigrations(db) {
15368
+ const { user_version: current } = db.query("PRAGMA user_version").get();
15369
+ for (let i = current;i < MIGRATIONS.length; i++) {
15370
+ db.exec(MIGRATIONS[i]);
15371
+ db.exec(`PRAGMA user_version = ${i + 1}`);
15372
+ }
15373
+ }
15374
+
15375
+ // src/db.ts
15376
+ var instance;
15377
+ function getDbPath(env = process.env) {
15378
+ const home = env.HOME ?? env.USERPROFILE ?? "~";
15379
+ return path.join(home, ".config", "opencode", "ensemble.db");
15380
+ }
15381
+ function createDb(path2) {
15382
+ const db = new Database(path2);
15383
+ db.exec("PRAGMA journal_mode=WAL");
15384
+ db.exec("PRAGMA foreign_keys=ON");
15385
+ applyMigrations(db);
15386
+ instance = db;
15387
+ return db;
15388
+ }
15389
+
15390
+ // src/client.ts
15391
+ function extractError(err) {
15392
+ if (err && typeof err === "object" && "message" in err)
15393
+ return String(err.message);
15394
+ return String(err);
15395
+ }
15396
+ function throwing(fn) {
15397
+ return async (...args) => {
15398
+ const result = await fn(...args);
15399
+ if (result && typeof result === "object" && "error" in result && result.error !== undefined) {
15400
+ throw new Error(extractError(result.error));
15401
+ }
15402
+ return result;
15403
+ };
15404
+ }
15405
+ function wrapThrowingClient(raw) {
15406
+ const r = raw;
15407
+ return {
15408
+ session: {
15409
+ create: throwing(r.session.create.bind(r.session)),
15410
+ promptAsync: throwing(r.session.promptAsync.bind(r.session)),
15411
+ abort: throwing(r.session.abort.bind(r.session)),
15412
+ status: throwing(r.session.status.bind(r.session))
15413
+ },
15414
+ tui: {
15415
+ showToast: throwing(r.tui.showToast.bind(r.tui)),
15416
+ selectSession: throwing(r.tui.selectSession.bind(r.tui))
15417
+ },
15418
+ worktree: {
15419
+ create: throwing(r.worktree.create.bind(r.worktree)),
15420
+ remove: throwing(r.worktree.remove.bind(r.worktree)),
15421
+ list: throwing(r.worktree.list.bind(r.worktree)),
15422
+ reset: throwing(r.worktree.reset.bind(r.worktree))
15423
+ }
15424
+ };
15425
+ }
15426
+
15427
+ // src/util.ts
15428
+ var NAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
15429
+ var counter = 0;
15430
+ function generateId(prefix) {
15431
+ const time3 = Date.now().toString(36);
15432
+ const count = (counter++).toString(36).padStart(4, "0");
15433
+ const rand = Math.random().toString(36).slice(2, 8);
15434
+ return `${prefix}_${time3}_${count}_${rand}`;
15435
+ }
15436
+ function validateTeamName(name) {
15437
+ if (name.length < 1 || name.length > 64)
15438
+ return "Team name must be 1-64 characters";
15439
+ if (!NAME_PATTERN.test(name))
15440
+ return "Team name must be lowercase alphanumeric with hyphens only";
15441
+ return;
15442
+ }
15443
+ function validateMemberName(name) {
15444
+ if (name.toLowerCase() === "lead")
15445
+ return `Name "lead" is reserved`;
15446
+ if (name.length < 1 || name.length > 64)
15447
+ return "Member name must be 1-64 characters";
15448
+ if (!NAME_PATTERN.test(name))
15449
+ return "Member name must be lowercase alphanumeric with hyphens only";
15450
+ return;
15451
+ }
15452
+
15453
+ // src/messaging.ts
15454
+ var MAX_CONTENT_BYTES = 10 * 1024;
15455
+ function sendMessage(db, input) {
15456
+ if (new TextEncoder().encode(input.content).length > MAX_CONTENT_BYTES) {
15457
+ throw new Error("Message content exceeds 10KB limit");
15458
+ }
15459
+ const id = generateId("msg");
15460
+ db.run("INSERT INTO team_message (id, team_id, from_name, to_name, content, delivered, time_created) VALUES (?, ?, ?, ?, ?, 0, ?)", [id, input.teamId, input.from, input.to, input.content, Date.now()]);
15461
+ return id;
15462
+ }
15463
+ function broadcastMessage(db, input) {
15464
+ if (new TextEncoder().encode(input.content).length > MAX_CONTENT_BYTES) {
15465
+ throw new Error("Message content exceeds 10KB limit");
15466
+ }
15467
+ const id = generateId("msg");
15468
+ db.run("INSERT INTO team_message (id, team_id, from_name, to_name, content, delivered, time_created) VALUES (?, ?, ?, NULL, ?, 0, ?)", [id, input.teamId, input.from, input.content, Date.now()]);
15469
+ return id;
15470
+ }
15471
+ function getUndeliveredMessages(db, teamId) {
15472
+ return db.query("SELECT * FROM team_message WHERE team_id = ? AND delivered = 0 ORDER BY time_created ASC").all(teamId);
15473
+ }
15474
+ function markDelivered(db, messageId) {
15475
+ db.run("UPDATE team_message SET delivered = 1 WHERE id = ?", [messageId]);
15476
+ }
15477
+
15478
+ // src/recovery.ts
15479
+ async function recoverStaleMembers(db, client3) {
15480
+ const stale = db.query(`SELECT tm.session_id FROM team_member tm
15481
+ JOIN team t ON tm.team_id = t.id
15482
+ WHERE tm.status = 'busy' AND t.status = 'active'`).all();
15483
+ const result = db.run(`UPDATE team_member SET status = 'error', execution_status = 'idle', time_updated = ?
15484
+ WHERE status = 'busy'
15485
+ AND team_id IN (SELECT id FROM team WHERE status = 'active')`, [Date.now()]);
15486
+ if (client3) {
15487
+ for (const member of stale) {
15488
+ try {
15489
+ await client3.session.abort({ sessionID: member.session_id });
15490
+ } catch {}
15491
+ }
15492
+ }
15493
+ return { interrupted: result.changes };
15494
+ }
15495
+ async function recoverOrphanedWorktrees(db, client3) {
15496
+ let removed = 0;
15497
+ try {
15498
+ const worktrees = await client3.worktree.list();
15499
+ if (!worktrees.data)
15500
+ return { removed: 0 };
15501
+ const activeWorktrees = new Set(db.query(`SELECT tm.worktree_dir FROM team_member tm
15502
+ JOIN team t ON tm.team_id = t.id
15503
+ WHERE tm.worktree_dir IS NOT NULL AND t.status = 'active'`).all().map((r) => r.worktree_dir));
15504
+ for (const wt of worktrees.data) {
15505
+ if (!wt.name.startsWith("ensemble-"))
15506
+ continue;
15507
+ if (activeWorktrees.has(wt.directory))
15508
+ continue;
15509
+ try {
15510
+ await client3.worktree.remove({ worktreeRemoveInput: { directory: wt.directory } });
15511
+ removed++;
15512
+ } catch {}
15513
+ }
15514
+ } catch {}
15515
+ return { removed };
15516
+ }
15517
+ async function recoverUndeliveredMessages(db, client3, registry2) {
15518
+ const teams = db.query("SELECT id, lead_session_id FROM team WHERE status = 'active'").all();
15519
+ let redelivered = 0;
15520
+ for (const team of teams) {
15521
+ const messages = getUndeliveredMessages(db, team.id);
15522
+ for (const msg of messages) {
15523
+ let recipientSessionId;
15524
+ if (msg.to_name === "lead") {
15525
+ recipientSessionId = team.lead_session_id;
15526
+ } else if (msg.to_name) {
15527
+ const entry = registry2.getByName(team.id, msg.to_name);
15528
+ recipientSessionId = entry?.sessionId;
15529
+ } else {
15530
+ continue;
15531
+ }
15532
+ if (!recipientSessionId)
15533
+ continue;
15534
+ try {
15535
+ await client3.session.promptAsync({
15536
+ sessionID: recipientSessionId,
15537
+ parts: [{ type: "text", text: `[Recovered team message from ${msg.from_name}]: ${msg.content}` }]
15538
+ });
15539
+ markDelivered(db, msg.id);
15540
+ redelivered++;
15541
+ } catch {}
15542
+ }
15543
+ }
15544
+ return { redelivered };
12559
15545
  }
12560
15546
 
12561
15547
  // src/state.ts
@@ -12697,10 +15683,10 @@ function formatMessage(type, data) {
12697
15683
  return `${data.memberName} shut down`;
12698
15684
  }
12699
15685
  }
12700
- async function notifyTeamEvent(client, type, data) {
15686
+ async function notifyTeamEvent(client3, type, data) {
12701
15687
  const config2 = TOAST_CONFIG[type];
12702
15688
  try {
12703
- await client.tui.showToast({
15689
+ await client3.tui.showToast({
12704
15690
  title: "Team",
12705
15691
  message: formatMessage(type, data),
12706
15692
  variant: config2.variant,
@@ -12708,14 +15694,14 @@ async function notifyTeamEvent(client, type, data) {
12708
15694
  });
12709
15695
  } catch {}
12710
15696
  }
12711
- async function notifyWorkingProgress(client, db, teamId) {
15697
+ async function notifyWorkingProgress(client3, db, teamId) {
12712
15698
  const members = db.query("SELECT name, status FROM team_member WHERE team_id = ? ORDER BY time_created ASC").all(teamId);
12713
15699
  if (members.length === 0)
12714
15700
  return;
12715
15701
  const busy = members.filter((m) => m.status === "busy");
12716
15702
  try {
12717
15703
  if (busy.length === 0) {
12718
- await client.tui.showToast({
15704
+ await client3.tui.showToast({
12719
15705
  title: "Team",
12720
15706
  message: "All teammates finished",
12721
15707
  variant: "success",
@@ -12723,7 +15709,7 @@ async function notifyWorkingProgress(client, db, teamId) {
12723
15709
  });
12724
15710
  } else {
12725
15711
  const names = busy.map((m) => m.name).join(", ");
12726
- await client.tui.showToast({
15712
+ await client3.tui.showToast({
12727
15713
  title: "Team",
12728
15714
  message: `Working: ${names} (${busy.length}/${members.length})`,
12729
15715
  variant: "info",
@@ -12858,7 +15844,7 @@ async function executeTeamSpawn(deps, args, sessionId) {
12858
15844
  if (useWorktree) {
12859
15845
  const worktreeName = `ensemble-${teamInfo.teamName}-${args.name}`;
12860
15846
  try {
12861
- const result = await deps.client.worktree.create({ name: worktreeName });
15847
+ const result = await deps.client.worktree.create({ worktreeCreateInput: { name: worktreeName } });
12862
15848
  if (result.data) {
12863
15849
  worktreeDir = result.data.directory;
12864
15850
  worktreeBranch = result.data.branch;
@@ -12874,15 +15860,21 @@ async function executeTeamSpawn(deps, args, sessionId) {
12874
15860
  } catch {}
12875
15861
  }
12876
15862
  }
12877
- const createOpts = {
12878
- body: { parentID: sessionId, title: `${args.name} (@${args.agent} teammate)` }
12879
- };
12880
- if (worktreeDir) {
12881
- createOpts.directory = worktreeDir;
12882
- }
15863
+ const isReadOnly = args.agent === "plan" || args.agent === "explore";
15864
+ const TEAM_TOOLS = ["team_message", "team_broadcast", "team_tasks_list", "team_tasks_add", "team_tasks_complete", "team_claim"];
15865
+ const permission = isReadOnly ? [
15866
+ { permission: "edit", pattern: "*", action: "deny" },
15867
+ { permission: "bash", pattern: "*", action: "deny" },
15868
+ ...TEAM_TOOLS.map((t) => ({ permission: t, pattern: "*", action: "allow" }))
15869
+ ] : undefined;
12883
15870
  let childSessionId;
12884
15871
  try {
12885
- const createResult = await deps.client.session.create(createOpts);
15872
+ const createResult = await deps.client.session.create({
15873
+ parentID: sessionId,
15874
+ title: `${args.name} (@${args.agent} teammate)`,
15875
+ ...permission ? { permission } : {},
15876
+ ...worktreeDir ? { directory: worktreeDir } : {}
15877
+ });
12886
15878
  childSessionId = createResult.data?.id;
12887
15879
  } catch (err) {
12888
15880
  if (worktreeDir) {
@@ -12934,14 +15926,15 @@ async function executeTeamSpawn(deps, args, sessionId) {
12934
15926
  `);
12935
15927
  try {
12936
15928
  await deps.client.session.promptAsync({
12937
- path: { id: childSessionId },
12938
- body: { parts: [{ type: "text", text: contextStr }] }
15929
+ sessionID: childSessionId,
15930
+ parts: [{ type: "text", text: contextStr }],
15931
+ agent: args.agent
12939
15932
  });
12940
15933
  } catch (err) {
12941
15934
  deps.db.run("DELETE FROM team_member WHERE team_id = ? AND name = ?", [teamInfo.teamId, args.name]);
12942
15935
  deps.registry.unregister(childSessionId);
12943
15936
  try {
12944
- await deps.client.session.abort({ path: { id: childSessionId } });
15937
+ await deps.client.session.abort({ sessionID: childSessionId });
12945
15938
  } catch {}
12946
15939
  if (worktreeDir) {
12947
15940
  try {
@@ -13000,8 +15993,8 @@ async function executeTeamMessage(deps, args, sessionId) {
13000
15993
  deliveryText = `[Team message from ${senderName}]: ${messageText}`;
13001
15994
  }
13002
15995
  await deps.client.session.promptAsync({
13003
- path: { id: recipientSessionId },
13004
- body: { parts: [{ type: "text", text: deliveryText }] }
15996
+ sessionID: recipientSessionId,
15997
+ parts: [{ type: "text", text: deliveryText }]
13005
15998
  });
13006
15999
  markDelivered(deps.db, msgId);
13007
16000
  return `Message sent to ${args.to}.`;
@@ -13034,8 +16027,8 @@ async function executeTeamBroadcast(deps, args, sessionId) {
13034
16027
  for (const recipient of recipients) {
13035
16028
  try {
13036
16029
  await deps.client.session.promptAsync({
13037
- path: { id: recipient.sessionId },
13038
- body: { parts: [{ type: "text", text: `[Team broadcast from ${senderName}]: ${args.text}` }] }
16030
+ sessionID: recipient.sessionId,
16031
+ parts: [{ type: "text", text: `[Team broadcast from ${senderName}]: ${args.text}` }]
13039
16032
  });
13040
16033
  delivered++;
13041
16034
  } catch {}
@@ -13077,13 +16070,11 @@ async function executeTeamShutdown(deps, args, sessionId) {
13077
16070
  }
13078
16071
  try {
13079
16072
  await deps.client.session.promptAsync({
13080
- path: { id: member.session_id },
13081
- body: {
13082
- parts: [{
13083
- type: "text",
13084
- text: `[Shutdown requested]: The lead has requested you shut down. Finish your current task, send your final findings to the lead via team_message, then stop.`
13085
- }]
13086
- }
16073
+ sessionID: member.session_id,
16074
+ parts: [{
16075
+ type: "text",
16076
+ text: `[Shutdown requested]: The lead has requested you shut down. Finish your current task, send your final findings to the lead via team_message, then stop.`
16077
+ }]
13087
16078
  });
13088
16079
  } catch {}
13089
16080
  deps.db.run("UPDATE team_member SET status = 'shutdown_requested', time_updated = ? WHERE team_id = ? AND name = ?", [Date.now(), teamInfo.teamId, args.member]);
@@ -13091,7 +16082,7 @@ async function executeTeamShutdown(deps, args, sessionId) {
13091
16082
  }
13092
16083
  async function abortAndShutdown(deps, teamId, memberName, sessionId) {
13093
16084
  try {
13094
- await deps.client.session.abort({ path: { id: sessionId } });
16085
+ await deps.client.session.abort({ sessionID: sessionId });
13095
16086
  } catch {}
13096
16087
  deps.db.run("UPDATE team_member SET status = 'shutdown', execution_status = 'idle', time_updated = ? WHERE team_id = ? AND name = ?", [Date.now(), teamId, memberName]);
13097
16088
  }
@@ -13112,7 +16103,7 @@ async function executeTeamCleanup(deps, args, sessionId) {
13112
16103
  if (args.force) {
13113
16104
  for (const member of active) {
13114
16105
  try {
13115
- await deps.client.session.abort({ path: { id: member.session_id } });
16106
+ await deps.client.session.abort({ sessionID: member.session_id });
13116
16107
  } catch {}
13117
16108
  }
13118
16109
  }
@@ -13417,7 +16408,7 @@ class Watchdog {
13417
16408
  for (const member of stale) {
13418
16409
  this.db.run("UPDATE team_member SET status = 'error', execution_status = 'timed_out', time_updated = ? WHERE team_id = ? AND name = ?", [Date.now(), member.team_id, member.name]);
13419
16410
  try {
13420
- await this.client.session.abort({ path: { id: member.session_id } });
16411
+ await this.client.session.abort({ sessionID: member.session_id });
13421
16412
  } catch {}
13422
16413
  try {
13423
16414
  await this.client.tui.showToast({
@@ -13459,17 +16450,18 @@ var plugin = async (input) => {
13459
16450
  const db = createDb(dbPath);
13460
16451
  const registry2 = new MemberRegistry;
13461
16452
  const tracker = new DescendantTracker;
13462
- const client = input.client;
13463
- const deps = { db, registry: registry2, tracker, client, directory: input.directory };
13464
- const recovery = await recoverStaleMembers(db, client);
16453
+ const rawClient = new OpencodeClient({ client: input.client._client });
16454
+ const client3 = wrapThrowingClient(rawClient);
16455
+ const deps = { db, registry: registry2, tracker, client: client3, directory: input.directory };
16456
+ const recovery = await recoverStaleMembers(db, client3);
13465
16457
  if (recovery.interrupted > 0) {
13466
16458
  const members = db.query("SELECT tm.team_id, tm.name, tm.session_id FROM team_member tm JOIN team t ON tm.team_id = t.id WHERE t.status = 'active'").all();
13467
16459
  for (const m of members) {
13468
16460
  registry2.register(m.team_id, m.name, m.session_id);
13469
16461
  }
13470
16462
  }
13471
- recoverUndeliveredMessages(db, client, registry2).catch(() => {});
13472
- recoverOrphanedWorktrees(db, client).catch(() => {});
16463
+ recoverUndeliveredMessages(db, client3, registry2).catch(() => {});
16464
+ recoverOrphanedWorktrees(db, client3).catch(() => {});
13473
16465
  const rateLimitEnv = process.env.OPENCODE_ENSEMBLE_RATE_LIMIT;
13474
16466
  const rateLimitCapacity = rateLimitEnv === "0" ? 0 : parseInt(rateLimitEnv ?? "", 10) || DEFAULT_RATE_LIMIT_CAPACITY;
13475
16467
  const rateLimiter = new TokenBucket({
@@ -13481,7 +16473,7 @@ var plugin = async (input) => {
13481
16473
  const watchdogTtl = timeoutEnv === "0" ? 0 : parseInt(timeoutEnv ?? "", 10) || DEFAULT_WATCHDOG_TTL_MS;
13482
16474
  const watchdog = new Watchdog({
13483
16475
  db,
13484
- client,
16476
+ client: client3,
13485
16477
  registry: registry2,
13486
16478
  ttlMs: watchdogTtl,
13487
16479
  checkIntervalMs: DEFAULT_WATCHDOG_CHECK_MS
@@ -13495,14 +16487,14 @@ var plugin = async (input) => {
13495
16487
  const transition = handleSessionStatusEvent(db, registry2, sessionID, statusType);
13496
16488
  if (transition) {
13497
16489
  if (transition.to === "shutdown") {
13498
- notifyTeamEvent(client, "shutdown", { memberName: transition.memberName });
16490
+ notifyTeamEvent(client3, "shutdown", { memberName: transition.memberName });
13499
16491
  } else if (transition.to === "ready" && transition.from === "busy") {
13500
- notifyTeamEvent(client, "completed", { memberName: transition.memberName });
16492
+ notifyTeamEvent(client3, "completed", { memberName: transition.memberName });
13501
16493
  } else if (transition.to === "error") {
13502
- notifyTeamEvent(client, "error", { memberName: transition.memberName });
16494
+ notifyTeamEvent(client3, "error", { memberName: transition.memberName });
13503
16495
  } else if (transition.to === "retry") {
13504
16496
  try {
13505
- await client.tui.showToast({
16497
+ await client3.tui.showToast({
13506
16498
  title: "Team",
13507
16499
  message: `${transition.memberName} is being rate-limited`,
13508
16500
  variant: "warning",
@@ -13513,11 +16505,11 @@ var plugin = async (input) => {
13513
16505
  const entry = registry2.getBySession(sessionID);
13514
16506
  if (entry) {
13515
16507
  try {
13516
- await client.session.abort({ path: { id: sessionID } });
16508
+ await client3.session.abort({ sessionID });
13517
16509
  } catch {}
13518
16510
  }
13519
16511
  }
13520
- await notifyWorkingProgress(client, db, transition.teamId);
16512
+ await notifyWorkingProgress(client3, db, transition.teamId);
13521
16513
  }
13522
16514
  }
13523
16515
  if (event.type === "session.created") {
@@ -13708,9 +16700,10 @@ var plugin = async (input) => {
13708
16700
  args: {},
13709
16701
  async execute(_args, ctx) {
13710
16702
  const result = await executeTeamStatus(deps, ctx.sessionID);
13711
- const members = deps.db.query("SELECT status FROM team_member WHERE team_id IN (SELECT id FROM team WHERE lead_session_id = ? OR id IN (SELECT team_id FROM team_member WHERE session_id = ?))").all(ctx.sessionID, ctx.sessionID);
13712
- const busy = members.filter((m) => m.status === "busy").length;
13713
- ctx.metadata({ title: `Team: ${members.length} members (${busy} working)` });
16703
+ const statusMap = { busy: "working", ready: "idle", shutdown_requested: "stopping", shutdown: "done", error: "error" };
16704
+ const members = deps.db.query("SELECT name, status FROM team_member WHERE team_id IN (SELECT id FROM team WHERE lead_session_id = ? OR id IN (SELECT team_id FROM team_member WHERE session_id = ?))").all(ctx.sessionID, ctx.sessionID);
16705
+ const summary = members.map((m) => `${m.name}: ${statusMap[m.status] ?? m.status}`).join(", ");
16706
+ ctx.metadata({ title: summary || "No teammates" });
13714
16707
  return result;
13715
16708
  }
13716
16709
  }),