@yuriai/web 0.1.22 → 0.1.24

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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{AssistantView-B-vEm0jN.js → AssistantView-C6Kq4IeV.js} +3 -3
  3. package/dist/assets/{DiagramView-DT5CPdtn.js → DiagramView-BWNMrLgm.js} +1 -1
  4. package/dist/assets/{MarkdownRenderer-kDYymiH3.js → MarkdownRenderer-AHl_m1Rf.js} +2 -2
  5. package/dist/assets/{MarkdownRendererImpl-cS5FXxon.js → MarkdownRendererImpl-B3bYtK9r.js} +1 -1
  6. package/dist/assets/{MarkstreamRendererImpl-CO1AzJsB.js → MarkstreamRendererImpl-B5rxhwTp.js} +1 -1
  7. package/dist/assets/{MobileDetailNavigation-RLH6AQBN.js → MobileDetailNavigation-CkdmjMHv.js} +1 -1
  8. package/dist/assets/{MobileShareBridge-CijqYDMo.js → MobileShareBridge-D4h2_ZOI.js} +1 -1
  9. package/dist/assets/{MobileTabPageHeader-BZKymEeY.js → MobileTabPageHeader-CgwEhDEc.js} +1 -1
  10. package/dist/assets/{MultiRunWindow-BBADn01m.js → MultiRunWindow-C8ifF6MX.js} +1 -1
  11. package/dist/assets/{OverlayScrollbar-Dxdkid6A.js → OverlayScrollbar-eBG-DXgX.js} +1 -1
  12. package/dist/assets/{SettingsView-BDw1UGgS.js → SettingsView-DinNQMES.js} +1 -1
  13. package/dist/assets/{SettingsWindow-DQz1f-kO.js → SettingsWindow-BqQxUO8Z.js} +1 -1
  14. package/dist/assets/{TerminalView-CpGeHiw4.js → TerminalView-LwaxVKh2.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-qF2onmML.js → ToolOutputDialog-CrMx7040.js} +1 -1
  16. package/dist/assets/{appThemeRegistry-DmRKfJL3.js → appThemeRegistry-BrxlsRZv.js} +1 -1
  17. package/dist/assets/{capgoAdapter-BmTEnR2_.js → capgoAdapter-DjiN4gU-.js} +1 -1
  18. package/dist/assets/{dropdown-menu.styles-BXRbrWW5.js → dropdown-menu.styles-BqAI_N66.js} +1 -1
  19. package/dist/assets/{fileMentionTouchSelection-FDObhofW.js → fileMentionTouchSelection-BSbG3aaI.js} +1 -1
  20. package/dist/assets/{gitApi-D8IPglEo.js → gitApi-BrFpwjIz.js} +1 -1
  21. package/dist/assets/{insertionBoundaries-DE8RyJf4.js → insertionBoundaries-jA5oY6Eg.js} +1 -1
  22. package/dist/assets/{main-BLMeK7Ed.js → main-Vmy68zzS.js} +4 -4
  23. package/dist/assets/{main-Bh0kUjiw.js → main-sy9tIrXv.js} +2 -2
  24. package/dist/assets/{mcpQueries-BFkB-7V_.js → mcpQueries-B6p3UNY7.js} +1 -1
  25. package/dist/assets/{miniChat-Ciy0u8ci.js → miniChat-D9RYlfJj.js} +2 -2
  26. package/dist/assets/{mobile-Bm0sCDXq.js → mobile-DJ8Ongip.js} +2 -2
  27. package/dist/assets/{mobileBackNavigation-BwxOTY4b.js → mobileBackNavigation-B8L0Vy1I.js} +1 -1
  28. package/dist/assets/{multirun-CyHj2_Qf.js → multirun-COWU8JRo.js} +1 -1
  29. package/dist/assets/{native-config-BDst1Okm.js → native-config-DYPGnxUZ.js} +1 -1
  30. package/dist/assets/{platform-7bX6qtBV.js → platform-CCTs9UKZ.js} +1 -1
  31. package/dist/assets/{projectMeta-C75m7wMM.js → projectMeta-BKzhp80G.js} +1 -1
  32. package/dist/assets/{renderElectronMiniChatApp-BSX59NyD.js → renderElectronMiniChatApp-DmmSvxer.js} +2 -2
  33. package/dist/assets/{renderMobileApp-BM8Bg3sb.js → renderMobileApp-B6mlgiIP.js} +4 -4
  34. package/dist/assets/{runtimeConfig-D0UDGecm.js → runtimeConfig-D-qLdzVy.js} +1 -1
  35. package/dist/assets/{runtimeEndpointReset-Df4Jlmne.js → runtimeEndpointReset-C2av6bqy.js} +1 -1
  36. package/dist/assets/{scheduledTaskNavigation-BE3Okq7X.js → scheduledTaskNavigation-FME9NQYP.js} +1 -1
  37. package/dist/assets/{sessionChangeSummary-DkIJkqeG.js → sessionChangeSummary-DKOy397B.js} +1 -1
  38. package/dist/assets/{sessionLookup-DhcUVJQR.js → sessionLookup-BxxDvke8.js} +1 -1
  39. package/dist/assets/{sortable-tabs-strip-CQR5TsUS.js → sortable-tabs-strip-DiXAHgws.js} +1 -1
  40. package/dist/assets/{speechSettingsQueries-BWIoMe5c.js → speechSettingsQueries-B3JrnqTj.js} +1 -1
  41. package/dist/assets/{terminalApi-BHXvha-U.js → terminalApi-DhXTmxps.js} +1 -1
  42. package/dist/assets/{textarea-pQCq-iLS.js → textarea-BZhmG_bD.js} +1 -1
  43. package/dist/assets/{types-2CUEL3Ja.js → types-D4VbzvCO.js} +1 -1
  44. package/dist/assets/{useAppFontEffects-C9CPKD-1.js → useAppFontEffects-lFrC_5Vj.js} +5 -5
  45. package/dist/assets/{useDesktopWindowControlsLayout-Cw3ZRPXc.js → useDesktopWindowControlsLayout-BPujMjYn.js} +1 -1
  46. package/dist/assets/{useEffectiveDirectory-Cw-vfohq.js → useEffectiveDirectory-DfD8BFNR.js} +1 -1
  47. package/dist/assets/{useFontPreferences-D9PX5t6Y.js → useFontPreferences-CMyrMAmq.js} +1 -1
  48. package/dist/assets/{useMobileNavigationStore-K23K6qFK.js → useMobileNavigationStore-DllieJnH.js} +5 -5
  49. package/dist/assets/{useWorkerHighlightedLines-U3DE5CRZ.js → useWorkerHighlightedLines-mc6QKH2H.js} +1 -1
  50. package/dist/assets/vendor-opencode-client-XDI8AfPJ.js +12 -0
  51. package/dist/index.html +8 -8
  52. package/dist/mini-chat.html +8 -8
  53. package/dist/mobile.html +8 -8
  54. package/package.json +3 -3
  55. package/server/lib/content-search/DOCUMENTATION.md +17 -11
  56. package/server/lib/content-search/index.js +1 -0
  57. package/server/lib/content-search/runtime.js +50 -9
  58. package/server/lib/content-search/runtime.test.js +72 -1
  59. package/server/lib/content-search/service.js +12 -1
  60. package/server/lib/opencode/DOCUMENTATION.md +9 -9
  61. package/server/lib/opencode/ensure-cli.js +12 -14
  62. package/server/lib/opencode/ensure-cli.test.js +8 -8
  63. package/server/lib/opencode/env-runtime.test.js +1 -1
  64. package/server/lib/opencode/opencode2-pin.js +3 -4
  65. package/server/lib/opencode/opencode2-pin.test.js +5 -4
  66. package/server/lib/opencode/owned-runtime-upgrade.js +4 -11
  67. package/server/lib/opencode/owned-runtime-upgrade.test.js +4 -0
  68. package/server/lib/opencode/routes.js +2 -1
  69. package/server/lib/opencode/routes.test.js +1 -1
  70. package/server/lib/opencode/runtime-contract.js +3 -4
  71. package/server/lib/opencode/session-directory-runtime.js +2 -13
  72. package/server/lib/opencode/session-directory-runtime.test.js +69 -4
  73. package/server/lib/opencode/upgrade-screen.js +9 -5
  74. package/server/lib/opencode/upgrade-screen.test.js +20 -0
  75. package/server/lib/opencode/version-alignment.test.js +6 -6
  76. package/server/lib/session-index/DOCUMENTATION.md +18 -8
  77. package/server/lib/session-index/routes.js +3 -1
  78. package/server/lib/session-index/routes.test.js +2 -0
  79. package/server/lib/session-index/service.js +23 -0
  80. package/server/lib/session-index/sync-runtime.js +75 -20
  81. package/server/lib/session-index/sync-runtime.test.js +5 -5
  82. package/dist/assets/vendor-opencode-client-MF2GBrFx.js +0 -12
@@ -8,15 +8,15 @@ with an empty result. Remote upstreams never use the Host filesystem as evidence
8
8
  permission and I/O errors are not deletion. Checks are not negatively cached, so
9
9
  a recreated directory participates in the next requested sync.
10
10
 
11
- Once at startup, the sync runtime checks empty, exhausted indexed
12
- directories. It removes only directory shells with no summary rows, no child rows,
11
+ Startup does not probe indexed directories. An explicitly requested directory
12
+ refresh removes only missing directory shells with no summary rows, no child rows,
13
13
  and no more pages, using one conditional SQLite deletion. Session history and pins
14
14
  are preserved. This maintenance does not touch code files or upstream projects.
15
15
  Runtime switches and shutdown discard pending checks; successful cleanup publishes
16
16
  a revision tip. Snapshot GETs do not perform filesystem scans. Old project paths
17
17
  may still be submitted by clients, but pre-scan checks prevent recreating empty
18
18
  shells for missing paths. App or external worktree deletion is picked up by the
19
- next requested sync or startup pass; there is no periodic filesystem polling.
19
+ next requested sync; there is no startup or periodic filesystem polling.
20
20
 
21
21
  ## Physical directory identity
22
22
 
@@ -33,8 +33,8 @@ child membership follows the directory, and the merged head stays bounded to 20.
33
33
  Reconciliation failure rolls back the entire index conversion. Rechecking on reads
34
34
  also recovers paths unavailable during startup.
35
35
 
36
- Directory lists resolve the upstream location/project, fetch project-scoped pages
37
- and retain only records whose physical directory matches the requested directory.
36
+ Explicit directory lists fetch session pages without initializing an upstream
37
+ Location and retain only records whose physical directory matches the request.
38
38
  This discovers old aliases outside the index without admitting sibling worktrees.
39
39
  Opaque next/previous cursors stay upstream-owned; filtered short/empty pages with
40
40
  a continuation are partial, not exhausted. The existing five-page sync budget and
@@ -121,9 +121,19 @@ Repeated session summary events whose bounded root summary or child membership
121
121
  is unchanged leave directory recency and the public revision unchanged. Root
122
122
  events that remain outside the newest-20 bound follow the same no-op path.
123
123
 
124
- `sync-runtime.js` owns cold-start synchronization. The renderer submits all
125
- known project directories once to `POST /api/yuri/session-index/sync`.
126
- The runtime processes them sequentially. OpenCode 2.x list is cursor-only (no
124
+ `sync-runtime.js` owns cold-start synchronization. The renderer sends
125
+ `{ startup: true }` to `POST /api/yuri/session-index/sync`, without project paths.
126
+ The Host backfills sessions updated within the last 30 days using a single global
127
+ descending session-list cursor, stopping at the time boundary. It never requests
128
+ Location/config/plugin APIs or probes project paths. Each page and its cursor are
129
+ committed atomically in SQLite under the runtime key; empty success also records
130
+ completion. Subsequent launches perform no upstream history reads after completion.
131
+ Failure/shutdown preserves the last committed cursor for retry. Existing summaries
132
+ win over backfill, and normal create/update/archive/delete events maintain the index.
133
+ Existing databases without this marker receive one bounded backfill without being
134
+ cleared. Manual directory refresh remains a separate explicit operation.
135
+
136
+ The runtime processes explicit directory refreshes sequentially. OpenCode 2.x list is cursor-only (no
127
137
  `start` incremental); each directory fetches active-only pages (`limit=20`)
128
138
  after optional Host `projectSessions` overlay. Consecutive archived rows may
129
139
  consume further pages within a small page budget so the newest-20 **active**
@@ -55,7 +55,9 @@ export const registerSessionIndexRoutes = (app, {
55
55
  app.post('/api/yuri/session-index/sync', async (req, res) => {
56
56
  if (!sessionIndexSyncRuntime) return unsupported(res);
57
57
  const directories = Array.isArray(req.body?.directories) ? req.body.directories : [];
58
- const base = sessionIndexSyncRuntime.enqueue(directories);
58
+ const base = req.body?.startup === true
59
+ ? sessionIndexSyncRuntime.enqueue([], { startup: true })
60
+ : sessionIndexSyncRuntime.enqueue(directories);
59
61
  if (!hostStoreWired) return res.status(202).json(base);
60
62
  // Clients apply this body as a snapshot: same Host archive gate as GET.
61
63
  const host = await readHostMap();
@@ -79,6 +79,8 @@ describe('session index routes', () => {
79
79
  expect(res.statusCode).toBe(202);
80
80
  expect(enqueue).toHaveBeenCalledWith(['/repo/a', '/repo/b']);
81
81
  expect(res.body).toMatchObject({ revision: 1, sync: { active: true } });
82
+ route('POST', '/api/yuri/session-index/sync')({ body: { startup: true, directories: ['/ignored'] } }, res);
83
+ expect(enqueue).toHaveBeenLastCalledWith([], { startup: true });
82
84
  });
83
85
 
84
86
  it('does not register a long-poll changes route', () => {
@@ -688,7 +688,30 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
688
688
  `).run(runtimeKey(), directory).changes > 0;
689
689
 
690
690
  try { reconcileDirectoryAliases(runtimeKey()); } catch (error) { db.close(); throw error; }
691
+ const historyKey = () => `history_backfill:${runtimeKey()}`;
692
+ const getHistoryBackfill = () => {
693
+ const row = db.prepare('SELECT value FROM session_index_meta WHERE key = ?').get(historyKey());
694
+ return row ? JSON.parse(row.value) : null;
695
+ };
696
+ const commitHistoryPage = db.transaction(({ sessions, progress, expectedRuntimeKey }) => {
697
+ if (expectedRuntimeKey !== runtimeKey()) return false;
698
+ for (const session of sessions) {
699
+ // Live events and already indexed summaries win over historical reads.
700
+ if (!findBySessionId(session.id)) {
701
+ upsert(session);
702
+ const directory = normalizeDirectory(session?.location?.directory ?? session?.directory);
703
+ // The bounded 30-day import is not proof that older history is empty.
704
+ db.prepare('UPDATE runtime_directory SET has_more = 1 WHERE runtime_key = ? AND directory = ? AND last_full_synced_at = 0')
705
+ .run(expectedRuntimeKey, directory);
706
+ }
707
+ }
708
+ db.prepare('INSERT OR REPLACE INTO session_index_meta(key, value) VALUES (?, ?)')
709
+ .run(historyKey(), JSON.stringify(progress));
710
+ return true;
711
+ });
691
712
  return {
713
+ getHistoryBackfill,
714
+ commitHistoryPage,
692
715
  replaceDirectory,
693
716
  removeEmptyDirectory,
694
717
  replaceDirectories,
@@ -106,6 +106,7 @@ export const createSessionIndexSyncRuntime = ({
106
106
  const waiters = new Set();
107
107
  let batchDirectories = new Set();
108
108
  let revisionTipTimer;
109
+ let historyQueued = false;
109
110
 
110
111
  const syncState = () => ({
111
112
  active: !stopped && (running || queue.length > 0),
@@ -331,6 +332,52 @@ export const createSessionIndexSyncRuntime = ({
331
332
  }
332
333
  };
333
334
 
335
+ const fetchHistory = async (task) => {
336
+ if (stopped || task.runtimeKey !== sessionIndexService.getRuntimeKey()) return 'discarded';
337
+ const progress = sessionIndexService.getHistoryBackfill() ?? {
338
+ cutoff: now() - 30 * 24 * 60 * 60 * 1000, cursor: null, complete: false,
339
+ };
340
+ if (progress.complete) return 'completed';
341
+ const controller = new AbortController();
342
+ currentController = controller;
343
+ currentWasPreempted = false;
344
+ const timeout = setTimer(() => controller.abort(), FETCH_TIMEOUT_MS);
345
+ try {
346
+ const url = new URL(buildOpenCodeUrl('/session'));
347
+ url.searchParams.set('limit', '100');
348
+ url.searchParams.set('order', 'desc');
349
+ if (progress.cursor) url.searchParams.set('cursor', progress.cursor);
350
+ const response = await fetchFn(url, {
351
+ headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() }, signal: controller.signal,
352
+ });
353
+ if (!response.ok) throw new Error(`OpenCode history list failed (${response.status})`);
354
+ const payload = await response.json();
355
+ if (!Array.isArray(payload?.data)) throw new Error('Invalid OpenCode history page');
356
+ if (stopped || task.runtimeKey !== sessionIndexService.getRuntimeKey()) return 'discarded';
357
+ if (payload.data.some((session) => !session?.id || updatedAt(session) <= 0)) {
358
+ throw new Error('Invalid OpenCode history session');
359
+ }
360
+ const recent = payload.data.filter((session) => updatedAt(session) >= progress.cutoff);
361
+ const cursor = extractSessionListCursorToken(payload.cursor);
362
+ const complete = recent.length !== payload.data.length || !cursor || payload.data.length === 0;
363
+ if (!complete && cursor === progress.cursor) throw new Error('Repeated OpenCode history cursor');
364
+ const sessions = typeof projectSessions === 'function' ? projectSessions(recent) : recent;
365
+ if (!Array.isArray(sessions)) throw new Error('Invalid history projection');
366
+ sessionIndexService.commitHistoryPage({
367
+ sessions, progress: { ...progress, cursor, complete }, expectedRuntimeKey: task.runtimeKey,
368
+ });
369
+ return complete ? 'completed' : 'more';
370
+ } catch (error) {
371
+ if (stopped || task.runtimeKey !== sessionIndexService.getRuntimeKey()) return 'discarded';
372
+ if (currentWasPreempted) return 'preempted';
373
+ throw error;
374
+ } finally {
375
+ clearTimer(timeout);
376
+ if (currentController === controller) currentController = null;
377
+ currentWasPreempted = false;
378
+ }
379
+ };
380
+
334
381
  const fetchChildFlag = async (task) => {
335
382
  if (isDirectoryMissing && await isDirectoryMissing(task.directory)) return 'discarded';
336
383
  if (stopped || task.runtimeKey !== sessionIndexService.getRuntimeKey()) return 'discarded';
@@ -419,16 +466,32 @@ export const createSessionIndexSyncRuntime = ({
419
466
  const task = queue.shift();
420
467
  if (!task) break;
421
468
  try {
422
- const result = await fetchDirectory(task);
469
+ const result = task.history ? await fetchHistory(task) : await fetchDirectory(task);
470
+ if (result === 'more') {
471
+ queue.push(task);
472
+ notify();
473
+ continue;
474
+ }
423
475
  if (result === 'preempted') {
424
476
  queue.unshift(task);
425
477
  await delay(Math.max(0, interactiveUntil - now()));
426
478
  continue;
427
479
  }
428
480
  if (result === 'discarded' || stopped) continue;
481
+ if (task.history) {
482
+ historyQueued = false;
483
+ notify();
484
+ continue;
485
+ }
429
486
  queuedDirectories.delete(task.directory);
430
487
  completedDirectories.add(task.directory);
431
488
  } catch (error) {
489
+ if (task.history) {
490
+ historyQueued = false;
491
+ console.warn('[SessionIndex] History backfill paused:', error);
492
+ notify();
493
+ continue;
494
+ }
432
495
  queuedDirectories.delete(task.directory);
433
496
  failedDirectories.add(task.directory);
434
497
  console.warn(`[SessionIndex] Background sync failed for ${task.directory}:`, error);
@@ -437,6 +500,7 @@ export const createSessionIndexSyncRuntime = ({
437
500
  }
438
501
  } catch (error) {
439
502
  for (const task of queue.splice(0)) {
503
+ if (task.history) { historyQueued = false; continue; }
440
504
  queuedDirectories.delete(task.directory);
441
505
  failedDirectories.add(task.directory);
442
506
  }
@@ -450,7 +514,7 @@ export const createSessionIndexSyncRuntime = ({
450
514
  }
451
515
  };
452
516
 
453
- const enqueue = (directories) => {
517
+ const enqueue = (directories, { startup = false } = {}) => {
454
518
  if (stopped) return snapshot();
455
519
  const nextRuntimeKey = sessionIndexService.getRuntimeKey();
456
520
  if (nextRuntimeKey !== runtimeKey) {
@@ -464,6 +528,15 @@ export const createSessionIndexSyncRuntime = ({
464
528
  completedDirectories.clear();
465
529
  failedDirectories.clear();
466
530
  batchDirectories = new Set();
531
+ historyQueued = false;
532
+ }
533
+ if (startup) {
534
+ if (!historyQueued && !sessionIndexService.getHistoryBackfill()?.complete) {
535
+ historyQueued = true;
536
+ queue.push({ history: true, runtimeKey });
537
+ void run();
538
+ }
539
+ return snapshot();
467
540
  }
468
541
  const newBatch = !running && queue.length === 0;
469
542
  if (newBatch) {
@@ -532,23 +605,5 @@ export const createSessionIndexSyncRuntime = ({
532
605
  notify(true);
533
606
  };
534
607
 
535
- const cleanupMissingDirectories = async () => {
536
- const key = sessionIndexService.getRuntimeKey();
537
- let changed = false;
538
- try {
539
- for (const entry of sessionIndexService.snapshot().directories) {
540
- if (stopped || key !== sessionIndexService.getRuntimeKey()) break;
541
- if (entry.sessions.length || entry.hasMore) continue;
542
- const missing = await isDirectoryMissing(entry.directory);
543
- if (stopped || key !== sessionIndexService.getRuntimeKey()) break;
544
- if (missing) changed = sessionIndexService.removeEmptyDirectory(entry.directory) || changed;
545
- }
546
- if (changed && !stopped && key === sessionIndexService.getRuntimeKey()) notify(true);
547
- } catch (error) {
548
- console.warn('[SessionIndex] Directory cleanup failed:', error);
549
- }
550
- };
551
- if (isDirectoryMissing) void cleanupMissingDirectories();
552
-
553
608
  return { enqueue, noteInteractiveRequest, publishChange, snapshot, waitForChange, stop };
554
609
  };
@@ -41,7 +41,7 @@ const isFullyIdle = (runtime) => (
41
41
  );
42
42
 
43
43
  describe('session index background sync runtime', () => {
44
- it('cleans missing directories once at startup without scheduling a poll', async () => {
44
+ it('does not probe indexed directories at startup', async () => {
45
45
  const service = createService([{ directory: '/repo', sessions: [], hasMore: false }]);
46
46
  service.removeEmptyDirectory = vi.fn(() => true);
47
47
  const isDirectoryMissing = vi.fn(async () => true);
@@ -53,11 +53,11 @@ describe('session index background sync runtime', () => {
53
53
  setTimer: (fn, ms) => { const timer = { fn, ms }; timers.push(timer); return timer; },
54
54
  clearTimer,
55
55
  });
56
- await waitUntil(() => runtime.snapshot().revision === 1);
57
- expect(service.removeEmptyDirectory).toHaveBeenCalledWith('/repo');
58
- expect(runtime.snapshot().revision).toBe(1);
56
+ await Promise.resolve();
57
+ expect(service.removeEmptyDirectory).not.toHaveBeenCalled();
58
+ expect(runtime.snapshot().revision).toBe(0);
59
59
  runtime.stop();
60
- expect(isDirectoryMissing).toHaveBeenCalledTimes(1);
60
+ expect(isDirectoryMissing).not.toHaveBeenCalled();
61
61
  expect(timers).toHaveLength(0);
62
62
  });
63
63
 
@@ -1,12 +0,0 @@
1
- var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i={};r(i,{SharedEvents:()=>i,make:()=>a});function a(e){let t,n=4096;function r(e){e.connected=void 0,e.controller.abort(),t===e&&(t=void 0)}async function i(t){let n,i={};try{if(t.controller.signal.aborted)return;for(n=e(t.controller.signal,()=>{t.subscribers.forEach(e=>e.activity?.())})[Symbol.asyncIterator]();!t.controller.signal.aborted;){let e=await n.next();if(e.done||t.controller.signal.aborted)break;e.value.type===`server.connected`&&(t.connected=e.value),t.subscribers.forEach(t=>t.push(e.value))}}catch(e){i={error:e}}finally{r(t);try{await n?.return?.()}catch(e){`error`in i||(i={error:e})}t.subscribers.forEach(e=>e.finish(i))}}return{subscribe(e){return{[Symbol.asyncIterator](){let a=[],o=[],s=!1,c,l;function u(t,n=!0){c=t,n&&(o.length=0),e?.signal?.removeEventListener(`abort`,d),l?.subscribers.delete(f)&&!l.subscribers.size&&r(l),a.splice(0).forEach(e=>{`error`in t?e.reject(t.error):e.resolve({done:!0,value:void 0})})}function d(){u({})}let f={activity:e?.onActivity,finish(e){u(e,!1)},push(e){if(c)return;let t=a.shift();if(t){t.resolve({done:!1,value:e});return}if(o.length===n){u({error:Error(`Event subscriber exceeded its ${n}-event capacity`)});return}o.push(e)}};function p(){if(c)return;let e=!t;l=t??{controller:new AbortController,subscribers:new Set},t=l,l.subscribers.add(f),l.connected&&f.push(l.connected),e&&i(l)}return{next(){let t=o.shift();if(t)return Promise.resolve({done:!1,value:t});if(c)return`error`in c?Promise.reject(c.error):Promise.resolve({done:!0,value:void 0});if(e?.signal?.aborted)return d(),Promise.resolve({done:!0,value:void 0});let n=Promise.withResolvers();return a.push(n),s||(s=!0,e?.signal?.addEventListener(`abort`,d,{once:!0}),p()),n.promise},return(){return u({}),Promise.resolve({done:!0,value:void 0})}}}}}}}var o=class extends Error{reason;name=`ClientError`;constructor(e,t){let n=t?.detail??(t?.cause instanceof Error?t.cause.message:void 0);super(n?`${e}: ${n}`:e,t),this.reason=e}};r({},{make:()=>c});var s=16777216;function c(e){let t=e.fetch??globalThis.fetch,n=(t,n)=>{let r=new URL(e.baseUrl);r.pathname.endsWith(`/`)||(r.pathname+=`/`);let i=new URL(t.path.slice(1),r);for(let[e,n]of Object.entries(t.query??{}))u(i.searchParams,e,n);let a=new Headers(e.headers);for(let[e,n]of Object.entries(t.headers??{}))n!=null&&a.set(e,String(n));for(let[e,t]of new Headers(n?.headers))a.set(e,t);return t.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,t.binaryBody?`application/octet-stream`:`application/json`),{url:i,init:{method:t.method,signal:n?.signal,headers:a,body:t.body===void 0?void 0:t.binaryBody?t.body:JSON.stringify(t.body)}}},r=async(e,r)=>{try{let i=n(e,r);return await t(i.url,i.init)}catch(e){throw new o(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw f(await d(e));try{await e.body?.cancel()}catch{}throw new o(`UnexpectedStatus`,{cause:{status:e.status},detail:String(e.status)})},a=async(e,t)=>{let n=await r(e,t);if(n.status!==e.successStatus)return i(n,e);if(e.binary)return new Uint8Array(await n.arrayBuffer());if(e.empty){try{await n.body?.cancel()}catch{}return}return await d(n)},c=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!p(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new o(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new o(`MalformedResponse`);let a=n.body.getReader(),c=new TextDecoder,l=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new o(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),l+=c.decode(e.value,{stream:!e.done}),l.length>s)throw new o(`SseEventTooLarge`);let n=!e.done&&l.endsWith(`\r`);n&&(l=l.slice(0,-1)),l=l.replaceAll(`\r
2
- `,`
3
- `).replaceAll(`\r`,`
4
- `),n&&(l+=`\r`),e.done&&l!==``&&(l+=`
5
-
6
- `);let r=l.indexOf(`
7
-
8
- `);for(;r>=0;){let e=l.slice(0,r);l=l.slice(r+2);let t=e.split(`
9
- `).flatMap(e=>e.startsWith(`data:`)?[e.slice(5).trimStart()]:[]).join(`
10
- `);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new o(`MalformedResponse`,{cause:e})}r=l.indexOf(`
11
-
12
- `)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}});return{server:{info:e=>a({method:`GET`,path:`/api/info`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),pair:e=>a({method:`POST`,path:`/api/pair`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),connect:(e,t)=>a({method:`GET`,path:`/auth/connect/${encodeURIComponent(e.code)}`,successStatus:200,declaredStatuses:[400,401],empty:!1},t)},location:{get:(e,t)=>a({method:`GET`,path:`/api/location`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),reload:e=>a({method:`POST`,path:`/api/location/reload`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e)},agent:{list:(e,t)=>a({method:`GET`,path:`/api/agent`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},plugin:{list:(e,t)=>a({method:`GET`,path:`/api/plugin`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),check:(e,t)=>a({method:`POST`,path:`/api/plugin/check`,query:{location:e?.location},body:{target:e?.target},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`POST`,path:`/api/plugin/update`,query:{location:e.location},body:{targets:e.targets},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t)},session:{list:(e,t)=>a({method:`GET`,path:`/api/session`,query:{limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),stats:(e,t)=>a({method:`GET`,path:`/api/experimental/session/stats`,query:{from:e?.from,to:e?.to,project:e?.project,timezone:e?.timezone,tools:e?.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session`,body:{id:e?.id,parentID:e?.parentID,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,metadata:e?.metadata,permissions:e?.permissions},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),import:(e,t)=>a({method:`POST`,path:`/api/experimental/session/import`,body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),export:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),active:e=>a({method:`GET`,path:`/api/session/active`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),fork:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{before:e.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),switchAgent:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),switchModel:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,body:{title:e.title,metadata:e.metadata,permissions:e.permissions},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),move:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),prompt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),command:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{name:e.name,text:e.text,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},t),skill:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,resume:e.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),synthetic:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),shell:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),compact:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id,delivery:e.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),revert:{stage:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},t).then(e=>e.data),clear:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},t),commit:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},context:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),diff:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/diff`,query:{from:e.from,to:e.to,context:e.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),inbox:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,body:{delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},instructions:{entry:{list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),put:(e,t)=>a({method:`PUT`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},generate:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),log:(e,t)=>c({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),interrupt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,query:{resume:e.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),background:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),message:{get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data)},form:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,query:{message:e.message},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},environment:(e,t)=>a({method:`PUT`,path:`/api/session/${encodeURIComponent(e.sessionID)}/environment`,body:{variables:e.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),view:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/view`,body:{idle:e.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},message:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor,type:e.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},model:{list:(e,t)=>a({method:`GET`,path:`/api/model`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),default:(e,t)=>a({method:`GET`,path:`/api/model/default`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},generate:{text:(e,t)=>a({method:`POST`,path:`/api/experimental/generate`,body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data)},provider:{list:(e,t)=>a({method:`GET`,path:`/api/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},integration:{list:(e,t)=>a({method:`GET`,path:`/api/integration`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),wellknown:{add:(e,t)=>a({method:`POST`,path:`/api/experimental/integration/wellknown`,query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},connect:{key:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},oauth:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),complete:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},mcp:{list:(e,t)=>a({method:`GET`,path:`/api/mcp`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),add:(e,t)=>a({method:`PUT`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),disconnect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)}},credential:{list:e=>a({method:`GET`,path:`/api/credential`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/credential`,body:{id:e.id,integrationID:e.integrationID,label:e.label,value:e.value,activate:e.activate},successStatus:200,declaredStatuses:[400,401,409],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,body:{label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t),activate:(e,t)=>a({method:`POST`,path:`/api/credential/${encodeURIComponent(e.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},project:{list:e=>a({method:`GET`,path:`/api/project`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/project/${encodeURIComponent(e.projectID)}`,body:{canonical:e.canonical,name:e.name,icon:e.icon,commands:e.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},form:{list:(e,t)=>a({method:`GET`,path:`/api/form`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},permission:{request:{list:(e,t)=>a({method:`GET`,path:`/api/permission/request`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},saved:{list:(e,t)=>a({method:`GET`,path:`/api/permission/saved`,query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{decision:e.decision,message:e.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},file:{read:(e,t)=>a({method:`GET`,path:`/api/fs/read/${l(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t),list:(e,t)=>a({method:`GET`,path:`/api/fs/list`,query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),find:(e,t)=>a({method:`GET`,path:`/api/fs/find`,query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),write:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/write`,query:{location:e.location,path:e.path},body:e.payload,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binaryBody:!0},t)},command:{list:(e,t)=>a({method:`GET`,path:`/api/command`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},skill:{list:(e,t)=>a({method:`GET`,path:`/api/skill`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},rpc:{call:(e,t)=>a({method:`POST`,path:`/api/rpc/${encodeURIComponent(e.rpcID)}/${encodeURIComponent(e.method)}`,query:{location:e.location},body:{input:e.input},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},event:{subscribe:e=>c({method:`GET`,path:`/api/event`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)},pty:{list:(e,t)=>a({method:`GET`,path:`/api/pty`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/pty`,query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`PUT`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:{token:(e,t)=>a({method:`POST`,path:`/api/pty/${encodeURIComponent(e.ptyID)}/connect-token`,query:{location:e.location},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},experimental:{persistentPty:{read:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal/read`,query:{lines:e.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,body:{command:e.command,args:e.args,cwd:e.cwd,title:e.title,env:e.env,size:e.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),shutdown:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/shutdown`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e),handoff:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/handoff`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},e),get:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PUT`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,body:{attachmentID:e.attachmentID,size:e.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),snapshot:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),connectToken:(e,t)=>a({method:`POST`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/connect-token`,headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},t).then(e=>e.data)}},shell:{list:(e,t)=>a({method:`GET`,path:`/api/shell`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/shell`,query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),output:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},reference:{list:(e,t)=>a({method:`GET`,path:`/api/reference`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},worktree:{list:(e,t)=>a({method:`GET`,path:`/api/worktree`,query:{projectID:e.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/worktree`,body:{projectID:e.projectID,from:e.from,branch:e.branch,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/worktree`,body:{projectID:e.projectID,directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),refresh:(e,t)=>a({method:`POST`,path:`/api/worktree/refresh`,body:{projectID:e.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},vcs:{init:(e,t)=>a({method:`POST`,path:`/api/vcs/init`,query:{location:e?.location,provider:e?.provider},successStatus:204,declaredStatuses:[400,401,404,409,501,503],empty:!0},t),get:(e,t)=>a({method:`GET`,path:`/api/vcs`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),base:(e,t)=>a({method:`GET`,path:`/api/vcs/base`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/vcs/status`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),branch:{list:(e,t)=>a({method:`GET`,path:`/api/vcs/branch`,query:{location:e?.location,search:e?.search,limit:e?.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},diff:(e,t)=>a({method:`GET`,path:`/api/vcs/diff`,query:{location:e.location,mode:e.mode,base:e.base,context:e.context},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},debug:{location:{list:e=>a({method:`GET`,path:`/api/debug/location`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),evict:(e,t)=>a({method:`DELETE`,path:`/api/debug/location`,query:{location:e?.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},websearch:{providers:(e,t)=>a({method:`GET`,path:`/api/websearch/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),query:(e,t)=>a({method:`POST`,path:`/api/websearch`,query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},config:{get:(e,t)=>a({method:`GET`,path:`/api/config`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),shells:e=>a({method:`GET`,path:`/api/config/shell`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}}}function l(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function u(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)u(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))u(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function d(e){if(!p(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new o(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new o(`Transport`,{cause:e})}if(t===``)throw new o(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new o(`MalformedResponse`,{cause:e})}}function f(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function p(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var m=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,h=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,g=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`;function _(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=v(n,e);return{[Symbol.asyncIterator](){let e=new AbortController,n=r?.signal?AbortSignal.any([e.signal,r.signal]):e.signal,a=async function*(){try{for await(let e of t.subscribe({signal:n})){if(n.aborted)return;e.type===i&&(yield e)}}catch(e){if(!n.aborted)throw e}finally{e.abort()}}();return{next:()=>a.next(),return:()=>(e.abort(),a.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(t=>[t,async(r,i)=>{try{return(await e.rpc.call({rpcID:n.id,method:t,input:r,location:i?.location},{signal:i?.signal,headers:i?.headers})).output}catch(e){throw!h(e)&&!g(e)?e:e.data===void 0?{type:e.type,message:e.message}:{type:e.type,message:e.message,data:e.data}}}])),{events:{subscribe:r,on:(e,t,n)=>{let i=new AbortController,a=n?.signal?AbortSignal.any([i.signal,n.signal]):i.signal,o=r(e,{signal:a});return(async()=>{for await(let e of o)await t(e)})().catch(e=>console.error(e)),()=>i.abort()}}})}}function v(e,t){return`rpc.${e.id}.${t}`}var y={};r(y,{OpenCode:()=>y,make:()=>b});function b(e){let t=c(e),n=a((e,n)=>t.event.subscribe({signal:e,onActivity:n}));return{...t,rpc:Object.assign(_(t,n),t.rpc),event:n}}export{m as n,o as r,y as t};