@meet-ai/cli 0.0.17 → 0.0.18

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 (2) hide show
  1. package/dist/index.js +1160 -1160
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14737,11 +14737,24 @@ function createClient(baseUrl, apiKey) {
14737
14737
  const tokenParam = apiKey ? `?token=${apiKey}` : "";
14738
14738
  let pingInterval = null;
14739
14739
  let reconnectAttempt = 0;
14740
+ let reconnectScheduled = false;
14741
+ const log = options?.silent ? () => {} : wsLog;
14740
14742
  function getReconnectDelay() {
14741
14743
  const delay = Math.min(1000 * 2 ** Math.min(reconnectAttempt, 4), 15000);
14742
14744
  reconnectAttempt++;
14743
14745
  return delay + delay * 0.5 * Math.random();
14744
14746
  }
14747
+ function scheduleReconnect() {
14748
+ if (reconnectScheduled)
14749
+ return;
14750
+ reconnectScheduled = true;
14751
+ const delay = getReconnectDelay();
14752
+ log({ event: "reconnecting", attempt: reconnectAttempt, delay_ms: Math.round(delay) });
14753
+ setTimeout(() => {
14754
+ reconnectScheduled = false;
14755
+ connect();
14756
+ }, delay);
14757
+ }
14745
14758
  function connect() {
14746
14759
  const ws = new WebSocket(`${wsUrl}/api/lobby/ws${tokenParam}`);
14747
14760
  const connectTimeout = setTimeout(() => {
@@ -14749,14 +14762,13 @@ function createClient(baseUrl, apiKey) {
14749
14762
  try {
14750
14763
  ws.close(4000, "connect timeout");
14751
14764
  } catch {}
14752
- const delay = getReconnectDelay();
14753
- setTimeout(connect, delay);
14765
+ scheduleReconnect();
14754
14766
  }
14755
14767
  }, 30000);
14756
14768
  ws.onopen = () => {
14757
14769
  clearTimeout(connectTimeout);
14758
14770
  reconnectAttempt = 0;
14759
- wsLog({ event: "lobby_connected" });
14771
+ log({ event: "lobby_connected" });
14760
14772
  if (pingInterval)
14761
14773
  clearInterval(pingInterval);
14762
14774
  pingInterval = setInterval(() => {
@@ -14774,6 +14786,9 @@ function createClient(baseUrl, apiKey) {
14774
14786
  if (data.type === "room_created" && data.id && data.name) {
14775
14787
  options?.onRoomCreated?.(data.id, data.name);
14776
14788
  }
14789
+ if (data.type === "spawn_request" && data.room_name) {
14790
+ options?.onSpawnRequest?.(data.room_name);
14791
+ }
14777
14792
  } catch {}
14778
14793
  };
14779
14794
  ws.onclose = (event) => {
@@ -14782,8 +14797,7 @@ function createClient(baseUrl, apiKey) {
14782
14797
  clearInterval(pingInterval);
14783
14798
  if (event.code === 1000)
14784
14799
  return;
14785
- const delay = getReconnectDelay();
14786
- setTimeout(connect, delay);
14800
+ scheduleReconnect();
14787
14801
  };
14788
14802
  ws.onerror = () => {};
14789
14803
  return ws;
@@ -53039,957 +53053,277 @@ var init_build2 = __esm(async () => {
53039
53053
  ]);
53040
53054
  });
53041
53055
 
53042
- // ../../node_modules/.bun/react@19.2.4/node_modules/react/cjs/react-jsx-dev-runtime.development.js
53043
- var require_react_jsx_dev_runtime_development = __commonJS((exports) => {
53044
- var React11 = __toESM(require_react());
53045
- (function() {
53046
- function getComponentNameFromType(type) {
53047
- if (type == null)
53048
- return null;
53049
- if (typeof type === "function")
53050
- return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
53051
- if (typeof type === "string")
53052
- return type;
53053
- switch (type) {
53054
- case REACT_FRAGMENT_TYPE:
53055
- return "Fragment";
53056
- case REACT_PROFILER_TYPE:
53057
- return "Profiler";
53058
- case REACT_STRICT_MODE_TYPE:
53059
- return "StrictMode";
53060
- case REACT_SUSPENSE_TYPE:
53061
- return "Suspense";
53062
- case REACT_SUSPENSE_LIST_TYPE:
53063
- return "SuspenseList";
53064
- case REACT_ACTIVITY_TYPE:
53065
- return "Activity";
53066
- }
53067
- if (typeof type === "object")
53068
- switch (typeof type.tag === "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
53069
- case REACT_PORTAL_TYPE:
53070
- return "Portal";
53071
- case REACT_CONTEXT_TYPE:
53072
- return type.displayName || "Context";
53073
- case REACT_CONSUMER_TYPE:
53074
- return (type._context.displayName || "Context") + ".Consumer";
53075
- case REACT_FORWARD_REF_TYPE:
53076
- var innerType = type.render;
53077
- type = type.displayName;
53078
- type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
53079
- return type;
53080
- case REACT_MEMO_TYPE:
53081
- return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
53082
- case REACT_LAZY_TYPE:
53083
- innerType = type._payload;
53084
- type = type._init;
53085
- try {
53086
- return getComponentNameFromType(type(innerType));
53087
- } catch (x) {}
53056
+ // ../../node_modules/.bun/@xterm+headless@6.0.0/node_modules/@xterm/headless/lib-headless/xterm-headless.js
53057
+ var require_xterm_headless = __commonJS((exports) => {
53058
+ (() => {
53059
+ var e = { 5639: (e2, t2, s2) => {
53060
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.CircularList = undefined;
53061
+ const i2 = s2(7150), r2 = s2(802);
53062
+
53063
+ class n2 extends i2.Disposable {
53064
+ constructor(e3) {
53065
+ super(), this._maxLength = e3, this.onDeleteEmitter = this._register(new r2.Emitter), this.onDelete = this.onDeleteEmitter.event, this.onInsertEmitter = this._register(new r2.Emitter), this.onInsert = this.onInsertEmitter.event, this.onTrimEmitter = this._register(new r2.Emitter), this.onTrim = this.onTrimEmitter.event, this._array = new Array(this._maxLength), this._startIndex = 0, this._length = 0;
53066
+ }
53067
+ get maxLength() {
53068
+ return this._maxLength;
53069
+ }
53070
+ set maxLength(e3) {
53071
+ if (this._maxLength === e3)
53072
+ return;
53073
+ const t3 = new Array(e3);
53074
+ for (let s3 = 0;s3 < Math.min(e3, this.length); s3++)
53075
+ t3[s3] = this._array[this._getCyclicIndex(s3)];
53076
+ this._array = t3, this._maxLength = e3, this._startIndex = 0;
53077
+ }
53078
+ get length() {
53079
+ return this._length;
53080
+ }
53081
+ set length(e3) {
53082
+ if (e3 > this._length)
53083
+ for (let t3 = this._length;t3 < e3; t3++)
53084
+ this._array[t3] = undefined;
53085
+ this._length = e3;
53086
+ }
53087
+ get(e3) {
53088
+ return this._array[this._getCyclicIndex(e3)];
53089
+ }
53090
+ set(e3, t3) {
53091
+ this._array[this._getCyclicIndex(e3)] = t3;
53092
+ }
53093
+ push(e3) {
53094
+ this._array[this._getCyclicIndex(this._length)] = e3, this._length === this._maxLength ? (this._startIndex = ++this._startIndex % this._maxLength, this.onTrimEmitter.fire(1)) : this._length++;
53095
+ }
53096
+ recycle() {
53097
+ if (this._length !== this._maxLength)
53098
+ throw new Error("Can only recycle when the buffer is full");
53099
+ return this._startIndex = ++this._startIndex % this._maxLength, this.onTrimEmitter.fire(1), this._array[this._getCyclicIndex(this._length - 1)];
53100
+ }
53101
+ get isFull() {
53102
+ return this._length === this._maxLength;
53103
+ }
53104
+ pop() {
53105
+ return this._array[this._getCyclicIndex(this._length-- - 1)];
53106
+ }
53107
+ splice(e3, t3, ...s3) {
53108
+ if (t3) {
53109
+ for (let s4 = e3;s4 < this._length - t3; s4++)
53110
+ this._array[this._getCyclicIndex(s4)] = this._array[this._getCyclicIndex(s4 + t3)];
53111
+ this._length -= t3, this.onDeleteEmitter.fire({ index: e3, amount: t3 });
53112
+ }
53113
+ for (let t4 = this._length - 1;t4 >= e3; t4--)
53114
+ this._array[this._getCyclicIndex(t4 + s3.length)] = this._array[this._getCyclicIndex(t4)];
53115
+ for (let t4 = 0;t4 < s3.length; t4++)
53116
+ this._array[this._getCyclicIndex(e3 + t4)] = s3[t4];
53117
+ if (s3.length && this.onInsertEmitter.fire({ index: e3, amount: s3.length }), this._length + s3.length > this._maxLength) {
53118
+ const e4 = this._length + s3.length - this._maxLength;
53119
+ this._startIndex += e4, this._length = this._maxLength, this.onTrimEmitter.fire(e4);
53120
+ } else
53121
+ this._length += s3.length;
53122
+ }
53123
+ trimStart(e3) {
53124
+ e3 > this._length && (e3 = this._length), this._startIndex += e3, this._length -= e3, this.onTrimEmitter.fire(e3);
53125
+ }
53126
+ shiftElements(e3, t3, s3) {
53127
+ if (!(t3 <= 0)) {
53128
+ if (e3 < 0 || e3 >= this._length)
53129
+ throw new Error("start argument out of range");
53130
+ if (e3 + s3 < 0)
53131
+ throw new Error("Cannot shift elements in list beyond index 0");
53132
+ if (s3 > 0) {
53133
+ for (let i4 = t3 - 1;i4 >= 0; i4--)
53134
+ this.set(e3 + i4 + s3, this.get(e3 + i4));
53135
+ const i3 = e3 + t3 + s3 - this._length;
53136
+ if (i3 > 0)
53137
+ for (this._length += i3;this._length > this._maxLength; )
53138
+ this._length--, this._startIndex++, this.onTrimEmitter.fire(1);
53139
+ } else
53140
+ for (let i3 = 0;i3 < t3; i3++)
53141
+ this.set(e3 + i3 + s3, this.get(e3 + i3));
53142
+ }
53143
+ }
53144
+ _getCyclicIndex(e3) {
53145
+ return (this._startIndex + e3) % this._maxLength;
53088
53146
  }
53089
- return null;
53090
- }
53091
- function testStringCoercion(value) {
53092
- return "" + value;
53093
- }
53094
- function checkKeyStringCoercion(value) {
53095
- try {
53096
- testStringCoercion(value);
53097
- var JSCompiler_inline_result = false;
53098
- } catch (e) {
53099
- JSCompiler_inline_result = true;
53100
- }
53101
- if (JSCompiler_inline_result) {
53102
- JSCompiler_inline_result = console;
53103
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
53104
- var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
53105
- JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
53106
- return testStringCoercion(value);
53107
- }
53108
- }
53109
- function getTaskName(type) {
53110
- if (type === REACT_FRAGMENT_TYPE)
53111
- return "<>";
53112
- if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
53113
- return "<...>";
53114
- try {
53115
- var name = getComponentNameFromType(type);
53116
- return name ? "<" + name + ">" : "<...>";
53117
- } catch (x) {
53118
- return "<...>";
53119
- }
53120
- }
53121
- function getOwner() {
53122
- var dispatcher = ReactSharedInternals.A;
53123
- return dispatcher === null ? null : dispatcher.getOwner();
53124
- }
53125
- function UnknownOwner() {
53126
- return Error("react-stack-top-frame");
53127
- }
53128
- function hasValidKey(config2) {
53129
- if (hasOwnProperty.call(config2, "key")) {
53130
- var getter = Object.getOwnPropertyDescriptor(config2, "key").get;
53131
- if (getter && getter.isReactWarning)
53132
- return false;
53133
- }
53134
- return config2.key !== undefined;
53135
- }
53136
- function defineKeyPropWarningGetter(props, displayName) {
53137
- function warnAboutAccessingKey() {
53138
- specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", displayName));
53139
53147
  }
53140
- warnAboutAccessingKey.isReactWarning = true;
53141
- Object.defineProperty(props, "key", {
53142
- get: warnAboutAccessingKey,
53143
- configurable: true
53144
- });
53145
- }
53146
- function elementRefGetterWithDeprecationWarning() {
53147
- var componentName = getComponentNameFromType(this.type);
53148
- didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
53149
- componentName = this.props.ref;
53150
- return componentName !== undefined ? componentName : null;
53151
- }
53152
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
53153
- var refProp = props.ref;
53154
- type = {
53155
- $$typeof: REACT_ELEMENT_TYPE,
53156
- type,
53157
- key,
53158
- props,
53159
- _owner: owner
53148
+ t2.CircularList = n2;
53149
+ }, 7453: (e2, t2) => {
53150
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.clone = function e3(t3, s2 = 5) {
53151
+ if (typeof t3 != "object")
53152
+ return t3;
53153
+ const i2 = Array.isArray(t3) ? [] : {};
53154
+ for (const r2 in t3)
53155
+ i2[r2] = s2 <= 1 ? t3[r2] : t3[r2] && e3(t3[r2], s2 - 1);
53156
+ return i2;
53160
53157
  };
53161
- (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
53162
- enumerable: false,
53163
- get: elementRefGetterWithDeprecationWarning
53164
- }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
53165
- type._store = {};
53166
- Object.defineProperty(type._store, "validated", {
53167
- configurable: false,
53168
- enumerable: false,
53169
- writable: true,
53170
- value: 0
53171
- });
53172
- Object.defineProperty(type, "_debugInfo", {
53173
- configurable: false,
53174
- enumerable: false,
53175
- writable: true,
53176
- value: null
53177
- });
53178
- Object.defineProperty(type, "_debugStack", {
53179
- configurable: false,
53180
- enumerable: false,
53181
- writable: true,
53182
- value: debugStack
53183
- });
53184
- Object.defineProperty(type, "_debugTask", {
53185
- configurable: false,
53186
- enumerable: false,
53187
- writable: true,
53188
- value: debugTask
53189
- });
53190
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
53191
- return type;
53192
- }
53193
- function jsxDEVImpl(type, config2, maybeKey, isStaticChildren, debugStack, debugTask) {
53194
- var children = config2.children;
53195
- if (children !== undefined)
53196
- if (isStaticChildren)
53197
- if (isArrayImpl(children)) {
53198
- for (isStaticChildren = 0;isStaticChildren < children.length; isStaticChildren++)
53199
- validateChildKeys(children[isStaticChildren]);
53200
- Object.freeze && Object.freeze(children);
53201
- } else
53202
- console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
53203
- else
53204
- validateChildKeys(children);
53205
- if (hasOwnProperty.call(config2, "key")) {
53206
- children = getComponentNameFromType(type);
53207
- var keys = Object.keys(config2).filter(function(k) {
53208
- return k !== "key";
53209
- });
53210
- isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
53211
- didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(`A props object containing a "key" prop is being spread into JSX:
53212
- let props = %s;
53213
- <%s {...props} />
53214
- React keys must be passed directly to JSX without using spread:
53215
- let props = %s;
53216
- <%s key={someKey} {...props} />`, isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = true);
53158
+ }, 5777: (e2, t2, s2) => {
53159
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.CoreTerminal = undefined;
53160
+ const i2 = s2(6501), r2 = s2(6025), n2 = s2(7276), o = s2(9640), a = s2(56), h = s2(4071), c = s2(7792), l = s2(6415), u = s2(5746), d = s2(5882), f = s2(2486), _ = s2(3562), p = s2(8811), g = s2(802), v = s2(7150);
53161
+ let m = false;
53162
+
53163
+ class b extends v.Disposable {
53164
+ get onScroll() {
53165
+ return this._onScrollApi || (this._onScrollApi = this._register(new g.Emitter), this._onScroll.event((e3) => {
53166
+ this._onScrollApi?.fire(e3.position);
53167
+ })), this._onScrollApi.event;
53168
+ }
53169
+ get cols() {
53170
+ return this._bufferService.cols;
53171
+ }
53172
+ get rows() {
53173
+ return this._bufferService.rows;
53174
+ }
53175
+ get buffers() {
53176
+ return this._bufferService.buffers;
53177
+ }
53178
+ get options() {
53179
+ return this.optionsService.options;
53180
+ }
53181
+ set options(e3) {
53182
+ for (const t3 in e3)
53183
+ this.optionsService.options[t3] = e3[t3];
53184
+ }
53185
+ constructor(e3) {
53186
+ super(), this._windowsWrappingHeuristics = this._register(new v.MutableDisposable), this._onBinary = this._register(new g.Emitter), this.onBinary = this._onBinary.event, this._onData = this._register(new g.Emitter), this.onData = this._onData.event, this._onLineFeed = this._register(new g.Emitter), this.onLineFeed = this._onLineFeed.event, this._onResize = this._register(new g.Emitter), this.onResize = this._onResize.event, this._onWriteParsed = this._register(new g.Emitter), this.onWriteParsed = this._onWriteParsed.event, this._onScroll = this._register(new g.Emitter), this._instantiationService = new r2.InstantiationService, this.optionsService = this._register(new a.OptionsService(e3)), this._instantiationService.setService(i2.IOptionsService, this.optionsService), this._bufferService = this._register(this._instantiationService.createInstance(o.BufferService)), this._instantiationService.setService(i2.IBufferService, this._bufferService), this._logService = this._register(this._instantiationService.createInstance(n2.LogService)), this._instantiationService.setService(i2.ILogService, this._logService), this.coreService = this._register(this._instantiationService.createInstance(h.CoreService)), this._instantiationService.setService(i2.ICoreService, this.coreService), this.coreMouseService = this._register(this._instantiationService.createInstance(c.CoreMouseService)), this._instantiationService.setService(i2.ICoreMouseService, this.coreMouseService), this.unicodeService = this._register(this._instantiationService.createInstance(l.UnicodeService)), this._instantiationService.setService(i2.IUnicodeService, this.unicodeService), this._charsetService = this._instantiationService.createInstance(u.CharsetService), this._instantiationService.setService(i2.ICharsetService, this._charsetService), this._oscLinkService = this._instantiationService.createInstance(p.OscLinkService), this._instantiationService.setService(i2.IOscLinkService, this._oscLinkService), this._inputHandler = this._register(new f.InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService)), this._register(g.Event.forward(this._inputHandler.onLineFeed, this._onLineFeed)), this._register(this._inputHandler), this._register(g.Event.forward(this._bufferService.onResize, this._onResize)), this._register(g.Event.forward(this.coreService.onData, this._onData)), this._register(g.Event.forward(this.coreService.onBinary, this._onBinary)), this._register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom(true))), this._register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput())), this._register(this.optionsService.onMultipleOptionChange(["windowsMode", "windowsPty"], () => this._handleWindowsPtyOptionChange())), this._register(this._bufferService.onScroll(() => {
53187
+ this._onScroll.fire({ position: this._bufferService.buffer.ydisp }), this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
53188
+ })), this._writeBuffer = this._register(new _.WriteBuffer((e4, t3) => this._inputHandler.parse(e4, t3))), this._register(g.Event.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
53189
+ }
53190
+ write(e3, t3) {
53191
+ this._writeBuffer.write(e3, t3);
53192
+ }
53193
+ writeSync(e3, t3) {
53194
+ this._logService.logLevel <= i2.LogLevelEnum.WARN && !m && (this._logService.warn("writeSync is unreliable and will be removed soon."), m = true), this._writeBuffer.writeSync(e3, t3);
53195
+ }
53196
+ input(e3, t3 = true) {
53197
+ this.coreService.triggerDataEvent(e3, t3);
53198
+ }
53199
+ resize(e3, t3) {
53200
+ isNaN(e3) || isNaN(t3) || (e3 = Math.max(e3, o.MINIMUM_COLS), t3 = Math.max(t3, o.MINIMUM_ROWS), this._bufferService.resize(e3, t3));
53201
+ }
53202
+ scroll(e3, t3 = false) {
53203
+ this._bufferService.scroll(e3, t3);
53204
+ }
53205
+ scrollLines(e3, t3) {
53206
+ this._bufferService.scrollLines(e3, t3);
53207
+ }
53208
+ scrollPages(e3) {
53209
+ this.scrollLines(e3 * (this.rows - 1));
53210
+ }
53211
+ scrollToTop() {
53212
+ this.scrollLines(-this._bufferService.buffer.ydisp);
53213
+ }
53214
+ scrollToBottom(e3) {
53215
+ this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp);
53216
+ }
53217
+ scrollToLine(e3) {
53218
+ const t3 = e3 - this._bufferService.buffer.ydisp;
53219
+ t3 !== 0 && this.scrollLines(t3);
53220
+ }
53221
+ registerEscHandler(e3, t3) {
53222
+ return this._inputHandler.registerEscHandler(e3, t3);
53223
+ }
53224
+ registerDcsHandler(e3, t3) {
53225
+ return this._inputHandler.registerDcsHandler(e3, t3);
53226
+ }
53227
+ registerCsiHandler(e3, t3) {
53228
+ return this._inputHandler.registerCsiHandler(e3, t3);
53229
+ }
53230
+ registerOscHandler(e3, t3) {
53231
+ return this._inputHandler.registerOscHandler(e3, t3);
53232
+ }
53233
+ _setup() {
53234
+ this._handleWindowsPtyOptionChange();
53235
+ }
53236
+ reset() {
53237
+ this._inputHandler.reset(), this._bufferService.reset(), this._charsetService.reset(), this.coreService.reset(), this.coreMouseService.reset();
53238
+ }
53239
+ _handleWindowsPtyOptionChange() {
53240
+ let e3 = false;
53241
+ const t3 = this.optionsService.rawOptions.windowsPty;
53242
+ t3 && t3.buildNumber !== undefined && t3.buildNumber !== undefined ? e3 = !!(t3.backend === "conpty" && t3.buildNumber < 21376) : this.optionsService.rawOptions.windowsMode && (e3 = true), e3 ? this._enableWindowsWrappingHeuristics() : this._windowsWrappingHeuristics.clear();
53243
+ }
53244
+ _enableWindowsWrappingHeuristics() {
53245
+ if (!this._windowsWrappingHeuristics.value) {
53246
+ const e3 = [];
53247
+ e3.push(this.onLineFeed(d.updateWindowsModeWrappedState.bind(null, this._bufferService))), e3.push(this.registerCsiHandler({ final: "H" }, () => ((0, d.updateWindowsModeWrappedState)(this._bufferService), false))), this._windowsWrappingHeuristics.value = (0, v.toDisposable)(() => {
53248
+ for (const t3 of e3)
53249
+ t3.dispose();
53250
+ });
53251
+ }
53252
+ }
53217
53253
  }
53218
- children = null;
53219
- maybeKey !== undefined && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
53220
- hasValidKey(config2) && (checkKeyStringCoercion(config2.key), children = "" + config2.key);
53221
- if ("key" in config2) {
53222
- maybeKey = {};
53223
- for (var propName in config2)
53224
- propName !== "key" && (maybeKey[propName] = config2[propName]);
53225
- } else
53226
- maybeKey = config2;
53227
- children && defineKeyPropWarningGetter(maybeKey, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
53228
- return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
53229
- }
53230
- function validateChildKeys(node) {
53231
- isValidElement(node) ? node._store && (node._store.validated = 1) : typeof node === "object" && node !== null && node.$$typeof === REACT_LAZY_TYPE && (node._payload.status === "fulfilled" ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
53232
- }
53233
- function isValidElement(object2) {
53234
- return typeof object2 === "object" && object2 !== null && object2.$$typeof === REACT_ELEMENT_TYPE;
53235
- }
53236
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React11.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
53237
- return null;
53238
- };
53239
- React11 = {
53240
- react_stack_bottom_frame: function(callStackForError) {
53241
- return callStackForError();
53254
+ t2.CoreTerminal = b;
53255
+ }, 2486: function(e2, t2, s2) {
53256
+ var i2 = this && this.__decorate || function(e3, t3, s3, i3) {
53257
+ var r3, n3 = arguments.length, o2 = n3 < 3 ? t3 : i3 === null ? i3 = Object.getOwnPropertyDescriptor(t3, s3) : i3;
53258
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
53259
+ o2 = Reflect.decorate(e3, t3, s3, i3);
53260
+ else
53261
+ for (var a2 = e3.length - 1;a2 >= 0; a2--)
53262
+ (r3 = e3[a2]) && (o2 = (n3 < 3 ? r3(o2) : n3 > 3 ? r3(t3, s3, o2) : r3(t3, s3)) || o2);
53263
+ return n3 > 3 && o2 && Object.defineProperty(t3, s3, o2), o2;
53264
+ }, r2 = this && this.__param || function(e3, t3) {
53265
+ return function(s3, i3) {
53266
+ t3(s3, i3, e3);
53267
+ };
53268
+ };
53269
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.InputHandler = t2.WindowsOptionsReportType = undefined, t2.isValidColorIndex = k;
53270
+ const n2 = s2(3534), o = s2(6760), a = s2(6717), h = s2(7150), c = s2(726), l = s2(6107), u = s2(8938), d = s2(3055), f = s2(5451), _ = s2(6501), p = s2(6415), g = s2(1346), v = s2(9823), m = s2(8693), b = s2(802), S = { "(": 0, ")": 1, "*": 2, "+": 3, "-": 1, ".": 2 }, y = 131072;
53271
+ function C(e3, t3) {
53272
+ if (e3 > 24)
53273
+ return t3.setWinLines || false;
53274
+ switch (e3) {
53275
+ case 1:
53276
+ return !!t3.restoreWin;
53277
+ case 2:
53278
+ return !!t3.minimizeWin;
53279
+ case 3:
53280
+ return !!t3.setWinPosition;
53281
+ case 4:
53282
+ return !!t3.setWinSizePixels;
53283
+ case 5:
53284
+ return !!t3.raiseWin;
53285
+ case 6:
53286
+ return !!t3.lowerWin;
53287
+ case 7:
53288
+ return !!t3.refreshWin;
53289
+ case 8:
53290
+ return !!t3.setWinSizeChars;
53291
+ case 9:
53292
+ return !!t3.maximizeWin;
53293
+ case 10:
53294
+ return !!t3.fullscreenWin;
53295
+ case 11:
53296
+ return !!t3.getWinState;
53297
+ case 13:
53298
+ return !!t3.getWinPosition;
53299
+ case 14:
53300
+ return !!t3.getWinSizePixels;
53301
+ case 15:
53302
+ return !!t3.getScreenSizePixels;
53303
+ case 16:
53304
+ return !!t3.getCellSizePixels;
53305
+ case 18:
53306
+ return !!t3.getWinSizeChars;
53307
+ case 19:
53308
+ return !!t3.getScreenSizeChars;
53309
+ case 20:
53310
+ return !!t3.getIconTitle;
53311
+ case 21:
53312
+ return !!t3.getWinTitle;
53313
+ case 22:
53314
+ return !!t3.pushTitle;
53315
+ case 23:
53316
+ return !!t3.popTitle;
53317
+ case 24:
53318
+ return !!t3.setWinLines;
53319
+ }
53320
+ return false;
53242
53321
  }
53243
- };
53244
- var specialPropKeyWarningShown;
53245
- var didWarnAboutElementRef = {};
53246
- var unknownOwnerDebugStack = React11.react_stack_bottom_frame.bind(React11, UnknownOwner)();
53247
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
53248
- var didWarnAboutKeySpread = {};
53249
- exports.Fragment = REACT_FRAGMENT_TYPE;
53250
- exports.jsxDEV = function(type, config2, maybeKey, isStaticChildren) {
53251
- var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
53252
- return jsxDEVImpl(type, config2, maybeKey, isStaticChildren, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
53253
- };
53254
- })();
53255
- });
53256
-
53257
- // ../../node_modules/.bun/react@19.2.4/node_modules/react/jsx-dev-runtime.js
53258
- var require_jsx_dev_runtime = __commonJS((exports, module) => {
53259
- var react_jsx_dev_runtime_development = __toESM(require_react_jsx_dev_runtime_development());
53260
- if (false) {} else {
53261
- module.exports = react_jsx_dev_runtime_development;
53262
- }
53263
- });
53264
-
53265
- // src/tui/pane.tsx
53266
- function Pane({ roomName, status, lines, focused, height }) {
53267
- const visibleLines = lines.slice(-(height - 2));
53268
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
53269
- flexDirection: "column",
53270
- flexGrow: 1,
53271
- borderStyle: focused ? "double" : "single",
53272
- borderColor: focused ? "cyan" : "gray",
53273
- height,
53274
- children: [
53275
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
53276
- children: [
53277
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
53278
- bold: true,
53279
- color: focused ? "cyan" : "white",
53280
- children: [
53281
- " ",
53282
- roomName,
53283
- " "
53284
- ]
53285
- }, undefined, true, undefined, this),
53286
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
53287
- dimColor: true,
53288
- children: STATUS_ICONS[status]
53289
- }, undefined, false, undefined, this)
53290
- ]
53291
- }, undefined, true, undefined, this),
53292
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
53293
- flexDirection: "column",
53294
- flexGrow: 1,
53295
- paddingX: 1,
53296
- children: visibleLines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
53297
- wrap: "truncate",
53298
- children: line
53299
- }, i, false, undefined, this))
53300
- }, undefined, false, undefined, this)
53301
- ]
53302
- }, undefined, true, undefined, this);
53303
- }
53304
- var jsx_dev_runtime, STATUS_ICONS;
53305
- var init_pane = __esm(async () => {
53306
- await init_build2();
53307
- jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
53308
- STATUS_ICONS = {
53309
- starting: "...",
53310
- running: ">>>",
53311
- exited: "[done]",
53312
- error: "[err]"
53313
- };
53314
- });
53315
-
53316
- // src/tui/dashboard.tsx
53317
- function Dashboard({ teams, focusedIndex, height }) {
53318
- if (teams.length === 0) {
53319
- return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
53320
- flexGrow: 1,
53321
- alignItems: "center",
53322
- justifyContent: "center",
53323
- children: [
53324
- /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
53325
- dimColor: true,
53326
- children: "No teams running. Press "
53327
- }, undefined, false, undefined, this),
53328
- /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
53329
- bold: true,
53330
- color: "green",
53331
- children: "n"
53332
- }, undefined, false, undefined, this),
53333
- /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
53334
- dimColor: true,
53335
- children: " to spawn a new team."
53336
- }, undefined, false, undefined, this)
53337
- ]
53338
- }, undefined, true, undefined, this);
53339
- }
53340
- return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
53341
- flexGrow: 1,
53342
- flexDirection: "row",
53343
- children: teams.map((team, index) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Pane, {
53344
- roomName: team.roomName,
53345
- status: team.status,
53346
- lines: team.lines,
53347
- focused: index === focusedIndex,
53348
- height
53349
- }, team.roomId, false, undefined, this))
53350
- }, undefined, false, undefined, this);
53351
- }
53352
- var jsx_dev_runtime2;
53353
- var init_dashboard = __esm(async () => {
53354
- await __promiseAll([
53355
- init_build2(),
53356
- init_pane()
53357
- ]);
53358
- jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
53359
- });
53360
-
53361
- // src/tui/status-bar.tsx
53362
- function StatusBar({
53363
- teamCount,
53364
- focusedRoom,
53365
- showingSpawnDialog
53366
- }) {
53367
- if (showingSpawnDialog) {
53368
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
53369
- children: [
53370
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53371
- dimColor: true,
53372
- children: "Enter room name and prompt. Press "
53373
- }, undefined, false, undefined, this),
53374
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53375
- bold: true,
53376
- children: "Escape"
53377
- }, undefined, false, undefined, this),
53378
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53379
- dimColor: true,
53380
- children: " to cancel."
53381
- }, undefined, false, undefined, this)
53382
- ]
53383
- }, undefined, true, undefined, this);
53384
- }
53385
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
53386
- justifyContent: "space-between",
53387
- children: [
53388
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
53389
- gap: 2,
53390
- children: [
53391
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53392
- children: [
53393
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53394
- dimColor: true,
53395
- children: "["
53396
- }, undefined, false, undefined, this),
53397
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53398
- bold: true,
53399
- color: "green",
53400
- children: "n"
53401
- }, undefined, false, undefined, this),
53402
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53403
- dimColor: true,
53404
- children: "]ew"
53405
- }, undefined, false, undefined, this)
53406
- ]
53407
- }, undefined, true, undefined, this),
53408
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53409
- children: [
53410
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53411
- dimColor: true,
53412
- children: "["
53413
- }, undefined, false, undefined, this),
53414
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53415
- bold: true,
53416
- color: "red",
53417
- children: "k"
53418
- }, undefined, false, undefined, this),
53419
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53420
- dimColor: true,
53421
- children: "]ill"
53422
- }, undefined, false, undefined, this)
53423
- ]
53424
- }, undefined, true, undefined, this),
53425
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53426
- children: [
53427
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53428
- dimColor: true,
53429
- children: "["
53430
- }, undefined, false, undefined, this),
53431
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53432
- bold: true,
53433
- children: "<->"
53434
- }, undefined, false, undefined, this),
53435
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53436
- dimColor: true,
53437
- children: "]focus"
53438
- }, undefined, false, undefined, this)
53439
- ]
53440
- }, undefined, true, undefined, this),
53441
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53442
- children: [
53443
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53444
- dimColor: true,
53445
- children: "["
53446
- }, undefined, false, undefined, this),
53447
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53448
- bold: true,
53449
- color: "yellow",
53450
- children: "q"
53451
- }, undefined, false, undefined, this),
53452
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53453
- dimColor: true,
53454
- children: "]uit"
53455
- }, undefined, false, undefined, this)
53456
- ]
53457
- }, undefined, true, undefined, this)
53458
- ]
53459
- }, undefined, true, undefined, this),
53460
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
53461
- gap: 2,
53462
- children: [
53463
- focusedRoom && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53464
- color: "cyan",
53465
- children: focusedRoom
53466
- }, undefined, false, undefined, this),
53467
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
53468
- dimColor: true,
53469
- children: [
53470
- teamCount,
53471
- " team",
53472
- teamCount !== 1 ? "s" : ""
53473
- ]
53474
- }, undefined, true, undefined, this)
53475
- ]
53476
- }, undefined, true, undefined, this)
53477
- ]
53478
- }, undefined, true, undefined, this);
53479
- }
53480
- var jsx_dev_runtime3;
53481
- var init_status_bar = __esm(async () => {
53482
- await init_build2();
53483
- jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
53484
- });
53485
-
53486
- // src/tui/spawn-dialog.tsx
53487
- function SpawnDialog({ onSubmit, onCancel }) {
53488
- const [roomName, setRoomName] = import_react29.useState("");
53489
- const [cursor, setCursor] = import_react29.useState(0);
53490
- use_input_default((input, key) => {
53491
- if (key.escape) {
53492
- onCancel();
53493
- return;
53494
- }
53495
- if (key.return && roomName.trim()) {
53496
- onSubmit(roomName.trim());
53497
- return;
53498
- }
53499
- if (key.leftArrow) {
53500
- setCursor((c) => Math.max(0, c - 1));
53501
- return;
53502
- }
53503
- if (key.rightArrow) {
53504
- setCursor((c) => Math.min(roomName.length, c + 1));
53505
- return;
53506
- }
53507
- if (key.backspace || key.delete) {
53508
- if (cursor > 0) {
53509
- setRoomName((v) => v.slice(0, cursor - 1) + v.slice(cursor));
53510
- setCursor((c) => c - 1);
53511
- }
53512
- return;
53513
- }
53514
- if (input && !key.ctrl && !key.meta && !key.upArrow && !key.downArrow) {
53515
- setRoomName((v) => v.slice(0, cursor) + input + v.slice(cursor));
53516
- setCursor((c) => c + input.length);
53517
- }
53518
- });
53519
- const before = roomName.slice(0, cursor);
53520
- const at = roomName[cursor] ?? " ";
53521
- const after = roomName.slice(cursor + 1);
53522
- return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
53523
- flexDirection: "column",
53524
- borderStyle: "round",
53525
- borderColor: "green",
53526
- paddingX: 1,
53527
- children: [
53528
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
53529
- bold: true,
53530
- color: "green",
53531
- children: "New Team"
53532
- }, undefined, false, undefined, this),
53533
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
53534
- children: [
53535
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
53536
- children: "Room name: "
53537
- }, undefined, false, undefined, this),
53538
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
53539
- color: "cyan",
53540
- children: before
53541
- }, undefined, false, undefined, this),
53542
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
53543
- backgroundColor: "cyan",
53544
- color: "black",
53545
- children: at
53546
- }, undefined, false, undefined, this),
53547
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
53548
- color: "cyan",
53549
- children: after
53550
- }, undefined, false, undefined, this)
53551
- ]
53552
- }, undefined, true, undefined, this)
53553
- ]
53554
- }, undefined, true, undefined, this);
53555
- }
53556
- var import_react29, jsx_dev_runtime4;
53557
- var init_spawn_dialog = __esm(async () => {
53558
- await init_build2();
53559
- import_react29 = __toESM(require_react(), 1);
53560
- jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
53561
- });
53562
-
53563
- // src/lib/control-room.ts
53564
- function parseControlMessage(raw) {
53565
- try {
53566
- const data = typeof raw === "string" ? JSON.parse(raw) : raw;
53567
- if (!data?.type)
53568
- return null;
53569
- if (data.type === "spawn_request") {
53570
- const result = SpawnRequestSchema.safeParse(data);
53571
- return result.success ? result.data : null;
53572
- }
53573
- if (data.type === "kill_request") {
53574
- const result = KillRequestSchema.safeParse(data);
53575
- return result.success ? result.data : null;
53576
- }
53577
- return null;
53578
- } catch {
53579
- return null;
53580
- }
53581
- }
53582
- var SpawnRequestSchema, KillRequestSchema;
53583
- var init_control_room = __esm(() => {
53584
- init_zod();
53585
- SpawnRequestSchema = exports_external.object({
53586
- type: exports_external.literal("spawn_request"),
53587
- room_name: exports_external.string().min(1),
53588
- prompt: exports_external.string().min(1),
53589
- model: exports_external.string().optional()
53590
- });
53591
- KillRequestSchema = exports_external.object({
53592
- type: exports_external.literal("kill_request"),
53593
- room_id: exports_external.string().min(1)
53594
- });
53595
- });
53596
-
53597
- // src/tui/app.tsx
53598
- function App2({ processManager, client }) {
53599
- const { exit } = use_app_default();
53600
- const { stdout } = use_stdout_default();
53601
- const [teams, setTeams] = import_react30.useState(processManager.list());
53602
- const [focusedIndex, setFocusedIndex] = import_react30.useState(0);
53603
- const [showSpawn, setShowSpawn] = import_react30.useState(false);
53604
- const terminalHeight = stdout?.rows ?? 24;
53605
- const dashboardHeight = terminalHeight - 2;
53606
- const refreshTeams = import_react30.useCallback(() => {
53607
- setTeams([...processManager.list()]);
53608
- }, [processManager]);
53609
- const handleSpawnForRoom = import_react30.useCallback((roomId, roomName) => {
53610
- if (processManager.list().some((t) => t.roomId === roomId))
53611
- return;
53612
- processManager.spawn(roomId, roomName);
53613
- refreshTeams();
53614
- }, [processManager, refreshTeams]);
53615
- const handleSpawn = import_react30.useCallback(async (roomName) => {
53616
- try {
53617
- const room = await client.createRoom(roomName);
53618
- processManager.spawn(room.id, roomName);
53619
- refreshTeams();
53620
- } catch (error48) {
53621
- const msg = error48 instanceof Error ? error48.message : String(error48);
53622
- const errorId = `error-${Date.now()}`;
53623
- processManager.addError(errorId, roomName, msg);
53624
- refreshTeams();
53625
- }
53626
- }, [client, processManager, refreshTeams]);
53627
- const handleKillById = import_react30.useCallback((roomId) => {
53628
- processManager.kill(roomId);
53629
- refreshTeams();
53630
- }, [processManager, refreshTeams]);
53631
- const handleSpawnForRoomRef = import_react30.useRef(handleSpawnForRoom);
53632
- handleSpawnForRoomRef.current = handleSpawnForRoom;
53633
- const handleKillByIdRef = import_react30.useRef(handleKillById);
53634
- handleKillByIdRef.current = handleKillById;
53635
- import_react30.useEffect(() => {
53636
- const ws = client.listenLobby({
53637
- onRoomCreated: async (roomId, _roomName) => {
53638
- try {
53639
- const messages = await client.getMessages(roomId);
53640
- for (const msg of messages) {
53641
- const cmd = parseControlMessage(msg.content);
53642
- if (cmd?.type === "spawn_request") {
53643
- handleSpawnForRoomRef.current(roomId, cmd.room_name);
53644
- return;
53645
- }
53646
- }
53647
- } catch {}
53648
- }
53649
- });
53650
- return () => {
53651
- ws.close();
53652
- };
53653
- }, [client]);
53654
- import_react30.useEffect(() => {
53655
- const interval = setInterval(refreshTeams, 200);
53656
- return () => clearInterval(interval);
53657
- }, [refreshTeams]);
53658
- use_input_default((input, key) => {
53659
- if (showSpawn)
53660
- return;
53661
- if (input === "q") {
53662
- processManager.killAll();
53663
- exit();
53664
- return;
53665
- }
53666
- if (input === "n") {
53667
- setShowSpawn(true);
53668
- return;
53669
- }
53670
- if (input === "k" && teams.length > 0) {
53671
- const team = teams[focusedIndex];
53672
- if (team)
53673
- handleKillById(team.roomId);
53674
- if (focusedIndex >= teams.length - 1) {
53675
- setFocusedIndex(Math.max(0, focusedIndex - 1));
53676
- }
53677
- return;
53678
- }
53679
- if (key.leftArrow) {
53680
- setFocusedIndex((i) => Math.max(0, i - 1));
53681
- }
53682
- if (key.rightArrow) {
53683
- setFocusedIndex((i) => Math.min(teams.length - 1, i + 1));
53684
- }
53685
- });
53686
- return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53687
- flexDirection: "column",
53688
- height: terminalHeight,
53689
- children: [
53690
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Dashboard, {
53691
- teams,
53692
- focusedIndex,
53693
- height: dashboardHeight
53694
- }, undefined, false, undefined, this),
53695
- showSpawn ? /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(SpawnDialog, {
53696
- onSubmit: (name) => {
53697
- setShowSpawn(false);
53698
- handleSpawn(name);
53699
- },
53700
- onCancel: () => setShowSpawn(false)
53701
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(StatusBar, {
53702
- teamCount: teams.length,
53703
- focusedRoom: teams[focusedIndex]?.roomName ?? null,
53704
- showingSpawnDialog: false
53705
- }, undefined, false, undefined, this)
53706
- ]
53707
- }, undefined, true, undefined, this);
53708
- }
53709
- var import_react30, jsx_dev_runtime5;
53710
- var init_app = __esm(async () => {
53711
- init_control_room();
53712
- await __promiseAll([
53713
- init_build2(),
53714
- init_dashboard(),
53715
- init_status_bar(),
53716
- init_spawn_dialog()
53717
- ]);
53718
- import_react30 = __toESM(require_react(), 1);
53719
- jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
53720
- });
53721
-
53722
- // ../../node_modules/.bun/@xterm+headless@6.0.0/node_modules/@xterm/headless/lib-headless/xterm-headless.js
53723
- var require_xterm_headless = __commonJS((exports) => {
53724
- (() => {
53725
- var e = { 5639: (e2, t2, s2) => {
53726
- Object.defineProperty(t2, "__esModule", { value: true }), t2.CircularList = undefined;
53727
- const i2 = s2(7150), r2 = s2(802);
53728
-
53729
- class n2 extends i2.Disposable {
53730
- constructor(e3) {
53731
- super(), this._maxLength = e3, this.onDeleteEmitter = this._register(new r2.Emitter), this.onDelete = this.onDeleteEmitter.event, this.onInsertEmitter = this._register(new r2.Emitter), this.onInsert = this.onInsertEmitter.event, this.onTrimEmitter = this._register(new r2.Emitter), this.onTrim = this.onTrimEmitter.event, this._array = new Array(this._maxLength), this._startIndex = 0, this._length = 0;
53732
- }
53733
- get maxLength() {
53734
- return this._maxLength;
53735
- }
53736
- set maxLength(e3) {
53737
- if (this._maxLength === e3)
53738
- return;
53739
- const t3 = new Array(e3);
53740
- for (let s3 = 0;s3 < Math.min(e3, this.length); s3++)
53741
- t3[s3] = this._array[this._getCyclicIndex(s3)];
53742
- this._array = t3, this._maxLength = e3, this._startIndex = 0;
53743
- }
53744
- get length() {
53745
- return this._length;
53746
- }
53747
- set length(e3) {
53748
- if (e3 > this._length)
53749
- for (let t3 = this._length;t3 < e3; t3++)
53750
- this._array[t3] = undefined;
53751
- this._length = e3;
53752
- }
53753
- get(e3) {
53754
- return this._array[this._getCyclicIndex(e3)];
53755
- }
53756
- set(e3, t3) {
53757
- this._array[this._getCyclicIndex(e3)] = t3;
53758
- }
53759
- push(e3) {
53760
- this._array[this._getCyclicIndex(this._length)] = e3, this._length === this._maxLength ? (this._startIndex = ++this._startIndex % this._maxLength, this.onTrimEmitter.fire(1)) : this._length++;
53761
- }
53762
- recycle() {
53763
- if (this._length !== this._maxLength)
53764
- throw new Error("Can only recycle when the buffer is full");
53765
- return this._startIndex = ++this._startIndex % this._maxLength, this.onTrimEmitter.fire(1), this._array[this._getCyclicIndex(this._length - 1)];
53766
- }
53767
- get isFull() {
53768
- return this._length === this._maxLength;
53769
- }
53770
- pop() {
53771
- return this._array[this._getCyclicIndex(this._length-- - 1)];
53772
- }
53773
- splice(e3, t3, ...s3) {
53774
- if (t3) {
53775
- for (let s4 = e3;s4 < this._length - t3; s4++)
53776
- this._array[this._getCyclicIndex(s4)] = this._array[this._getCyclicIndex(s4 + t3)];
53777
- this._length -= t3, this.onDeleteEmitter.fire({ index: e3, amount: t3 });
53778
- }
53779
- for (let t4 = this._length - 1;t4 >= e3; t4--)
53780
- this._array[this._getCyclicIndex(t4 + s3.length)] = this._array[this._getCyclicIndex(t4)];
53781
- for (let t4 = 0;t4 < s3.length; t4++)
53782
- this._array[this._getCyclicIndex(e3 + t4)] = s3[t4];
53783
- if (s3.length && this.onInsertEmitter.fire({ index: e3, amount: s3.length }), this._length + s3.length > this._maxLength) {
53784
- const e4 = this._length + s3.length - this._maxLength;
53785
- this._startIndex += e4, this._length = this._maxLength, this.onTrimEmitter.fire(e4);
53786
- } else
53787
- this._length += s3.length;
53788
- }
53789
- trimStart(e3) {
53790
- e3 > this._length && (e3 = this._length), this._startIndex += e3, this._length -= e3, this.onTrimEmitter.fire(e3);
53791
- }
53792
- shiftElements(e3, t3, s3) {
53793
- if (!(t3 <= 0)) {
53794
- if (e3 < 0 || e3 >= this._length)
53795
- throw new Error("start argument out of range");
53796
- if (e3 + s3 < 0)
53797
- throw new Error("Cannot shift elements in list beyond index 0");
53798
- if (s3 > 0) {
53799
- for (let i4 = t3 - 1;i4 >= 0; i4--)
53800
- this.set(e3 + i4 + s3, this.get(e3 + i4));
53801
- const i3 = e3 + t3 + s3 - this._length;
53802
- if (i3 > 0)
53803
- for (this._length += i3;this._length > this._maxLength; )
53804
- this._length--, this._startIndex++, this.onTrimEmitter.fire(1);
53805
- } else
53806
- for (let i3 = 0;i3 < t3; i3++)
53807
- this.set(e3 + i3 + s3, this.get(e3 + i3));
53808
- }
53809
- }
53810
- _getCyclicIndex(e3) {
53811
- return (this._startIndex + e3) % this._maxLength;
53812
- }
53813
- }
53814
- t2.CircularList = n2;
53815
- }, 7453: (e2, t2) => {
53816
- Object.defineProperty(t2, "__esModule", { value: true }), t2.clone = function e3(t3, s2 = 5) {
53817
- if (typeof t3 != "object")
53818
- return t3;
53819
- const i2 = Array.isArray(t3) ? [] : {};
53820
- for (const r2 in t3)
53821
- i2[r2] = s2 <= 1 ? t3[r2] : t3[r2] && e3(t3[r2], s2 - 1);
53822
- return i2;
53823
- };
53824
- }, 5777: (e2, t2, s2) => {
53825
- Object.defineProperty(t2, "__esModule", { value: true }), t2.CoreTerminal = undefined;
53826
- const i2 = s2(6501), r2 = s2(6025), n2 = s2(7276), o = s2(9640), a = s2(56), h = s2(4071), c = s2(7792), l = s2(6415), u = s2(5746), d = s2(5882), f = s2(2486), _ = s2(3562), p = s2(8811), g = s2(802), v = s2(7150);
53827
- let m = false;
53828
-
53829
- class b extends v.Disposable {
53830
- get onScroll() {
53831
- return this._onScrollApi || (this._onScrollApi = this._register(new g.Emitter), this._onScroll.event((e3) => {
53832
- this._onScrollApi?.fire(e3.position);
53833
- })), this._onScrollApi.event;
53834
- }
53835
- get cols() {
53836
- return this._bufferService.cols;
53837
- }
53838
- get rows() {
53839
- return this._bufferService.rows;
53840
- }
53841
- get buffers() {
53842
- return this._bufferService.buffers;
53843
- }
53844
- get options() {
53845
- return this.optionsService.options;
53846
- }
53847
- set options(e3) {
53848
- for (const t3 in e3)
53849
- this.optionsService.options[t3] = e3[t3];
53850
- }
53851
- constructor(e3) {
53852
- super(), this._windowsWrappingHeuristics = this._register(new v.MutableDisposable), this._onBinary = this._register(new g.Emitter), this.onBinary = this._onBinary.event, this._onData = this._register(new g.Emitter), this.onData = this._onData.event, this._onLineFeed = this._register(new g.Emitter), this.onLineFeed = this._onLineFeed.event, this._onResize = this._register(new g.Emitter), this.onResize = this._onResize.event, this._onWriteParsed = this._register(new g.Emitter), this.onWriteParsed = this._onWriteParsed.event, this._onScroll = this._register(new g.Emitter), this._instantiationService = new r2.InstantiationService, this.optionsService = this._register(new a.OptionsService(e3)), this._instantiationService.setService(i2.IOptionsService, this.optionsService), this._bufferService = this._register(this._instantiationService.createInstance(o.BufferService)), this._instantiationService.setService(i2.IBufferService, this._bufferService), this._logService = this._register(this._instantiationService.createInstance(n2.LogService)), this._instantiationService.setService(i2.ILogService, this._logService), this.coreService = this._register(this._instantiationService.createInstance(h.CoreService)), this._instantiationService.setService(i2.ICoreService, this.coreService), this.coreMouseService = this._register(this._instantiationService.createInstance(c.CoreMouseService)), this._instantiationService.setService(i2.ICoreMouseService, this.coreMouseService), this.unicodeService = this._register(this._instantiationService.createInstance(l.UnicodeService)), this._instantiationService.setService(i2.IUnicodeService, this.unicodeService), this._charsetService = this._instantiationService.createInstance(u.CharsetService), this._instantiationService.setService(i2.ICharsetService, this._charsetService), this._oscLinkService = this._instantiationService.createInstance(p.OscLinkService), this._instantiationService.setService(i2.IOscLinkService, this._oscLinkService), this._inputHandler = this._register(new f.InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService)), this._register(g.Event.forward(this._inputHandler.onLineFeed, this._onLineFeed)), this._register(this._inputHandler), this._register(g.Event.forward(this._bufferService.onResize, this._onResize)), this._register(g.Event.forward(this.coreService.onData, this._onData)), this._register(g.Event.forward(this.coreService.onBinary, this._onBinary)), this._register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom(true))), this._register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput())), this._register(this.optionsService.onMultipleOptionChange(["windowsMode", "windowsPty"], () => this._handleWindowsPtyOptionChange())), this._register(this._bufferService.onScroll(() => {
53853
- this._onScroll.fire({ position: this._bufferService.buffer.ydisp }), this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
53854
- })), this._writeBuffer = this._register(new _.WriteBuffer((e4, t3) => this._inputHandler.parse(e4, t3))), this._register(g.Event.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
53855
- }
53856
- write(e3, t3) {
53857
- this._writeBuffer.write(e3, t3);
53858
- }
53859
- writeSync(e3, t3) {
53860
- this._logService.logLevel <= i2.LogLevelEnum.WARN && !m && (this._logService.warn("writeSync is unreliable and will be removed soon."), m = true), this._writeBuffer.writeSync(e3, t3);
53861
- }
53862
- input(e3, t3 = true) {
53863
- this.coreService.triggerDataEvent(e3, t3);
53864
- }
53865
- resize(e3, t3) {
53866
- isNaN(e3) || isNaN(t3) || (e3 = Math.max(e3, o.MINIMUM_COLS), t3 = Math.max(t3, o.MINIMUM_ROWS), this._bufferService.resize(e3, t3));
53867
- }
53868
- scroll(e3, t3 = false) {
53869
- this._bufferService.scroll(e3, t3);
53870
- }
53871
- scrollLines(e3, t3) {
53872
- this._bufferService.scrollLines(e3, t3);
53873
- }
53874
- scrollPages(e3) {
53875
- this.scrollLines(e3 * (this.rows - 1));
53876
- }
53877
- scrollToTop() {
53878
- this.scrollLines(-this._bufferService.buffer.ydisp);
53879
- }
53880
- scrollToBottom(e3) {
53881
- this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp);
53882
- }
53883
- scrollToLine(e3) {
53884
- const t3 = e3 - this._bufferService.buffer.ydisp;
53885
- t3 !== 0 && this.scrollLines(t3);
53886
- }
53887
- registerEscHandler(e3, t3) {
53888
- return this._inputHandler.registerEscHandler(e3, t3);
53889
- }
53890
- registerDcsHandler(e3, t3) {
53891
- return this._inputHandler.registerDcsHandler(e3, t3);
53892
- }
53893
- registerCsiHandler(e3, t3) {
53894
- return this._inputHandler.registerCsiHandler(e3, t3);
53895
- }
53896
- registerOscHandler(e3, t3) {
53897
- return this._inputHandler.registerOscHandler(e3, t3);
53898
- }
53899
- _setup() {
53900
- this._handleWindowsPtyOptionChange();
53901
- }
53902
- reset() {
53903
- this._inputHandler.reset(), this._bufferService.reset(), this._charsetService.reset(), this.coreService.reset(), this.coreMouseService.reset();
53904
- }
53905
- _handleWindowsPtyOptionChange() {
53906
- let e3 = false;
53907
- const t3 = this.optionsService.rawOptions.windowsPty;
53908
- t3 && t3.buildNumber !== undefined && t3.buildNumber !== undefined ? e3 = !!(t3.backend === "conpty" && t3.buildNumber < 21376) : this.optionsService.rawOptions.windowsMode && (e3 = true), e3 ? this._enableWindowsWrappingHeuristics() : this._windowsWrappingHeuristics.clear();
53909
- }
53910
- _enableWindowsWrappingHeuristics() {
53911
- if (!this._windowsWrappingHeuristics.value) {
53912
- const e3 = [];
53913
- e3.push(this.onLineFeed(d.updateWindowsModeWrappedState.bind(null, this._bufferService))), e3.push(this.registerCsiHandler({ final: "H" }, () => ((0, d.updateWindowsModeWrappedState)(this._bufferService), false))), this._windowsWrappingHeuristics.value = (0, v.toDisposable)(() => {
53914
- for (const t3 of e3)
53915
- t3.dispose();
53916
- });
53917
- }
53918
- }
53919
- }
53920
- t2.CoreTerminal = b;
53921
- }, 2486: function(e2, t2, s2) {
53922
- var i2 = this && this.__decorate || function(e3, t3, s3, i3) {
53923
- var r3, n3 = arguments.length, o2 = n3 < 3 ? t3 : i3 === null ? i3 = Object.getOwnPropertyDescriptor(t3, s3) : i3;
53924
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
53925
- o2 = Reflect.decorate(e3, t3, s3, i3);
53926
- else
53927
- for (var a2 = e3.length - 1;a2 >= 0; a2--)
53928
- (r3 = e3[a2]) && (o2 = (n3 < 3 ? r3(o2) : n3 > 3 ? r3(t3, s3, o2) : r3(t3, s3)) || o2);
53929
- return n3 > 3 && o2 && Object.defineProperty(t3, s3, o2), o2;
53930
- }, r2 = this && this.__param || function(e3, t3) {
53931
- return function(s3, i3) {
53932
- t3(s3, i3, e3);
53933
- };
53934
- };
53935
- Object.defineProperty(t2, "__esModule", { value: true }), t2.InputHandler = t2.WindowsOptionsReportType = undefined, t2.isValidColorIndex = k;
53936
- const n2 = s2(3534), o = s2(6760), a = s2(6717), h = s2(7150), c = s2(726), l = s2(6107), u = s2(8938), d = s2(3055), f = s2(5451), _ = s2(6501), p = s2(6415), g = s2(1346), v = s2(9823), m = s2(8693), b = s2(802), S = { "(": 0, ")": 1, "*": 2, "+": 3, "-": 1, ".": 2 }, y = 131072;
53937
- function C(e3, t3) {
53938
- if (e3 > 24)
53939
- return t3.setWinLines || false;
53940
- switch (e3) {
53941
- case 1:
53942
- return !!t3.restoreWin;
53943
- case 2:
53944
- return !!t3.minimizeWin;
53945
- case 3:
53946
- return !!t3.setWinPosition;
53947
- case 4:
53948
- return !!t3.setWinSizePixels;
53949
- case 5:
53950
- return !!t3.raiseWin;
53951
- case 6:
53952
- return !!t3.lowerWin;
53953
- case 7:
53954
- return !!t3.refreshWin;
53955
- case 8:
53956
- return !!t3.setWinSizeChars;
53957
- case 9:
53958
- return !!t3.maximizeWin;
53959
- case 10:
53960
- return !!t3.fullscreenWin;
53961
- case 11:
53962
- return !!t3.getWinState;
53963
- case 13:
53964
- return !!t3.getWinPosition;
53965
- case 14:
53966
- return !!t3.getWinSizePixels;
53967
- case 15:
53968
- return !!t3.getScreenSizePixels;
53969
- case 16:
53970
- return !!t3.getCellSizePixels;
53971
- case 18:
53972
- return !!t3.getWinSizeChars;
53973
- case 19:
53974
- return !!t3.getScreenSizeChars;
53975
- case 20:
53976
- return !!t3.getIconTitle;
53977
- case 21:
53978
- return !!t3.getWinTitle;
53979
- case 22:
53980
- return !!t3.pushTitle;
53981
- case 23:
53982
- return !!t3.popTitle;
53983
- case 24:
53984
- return !!t3.setWinLines;
53985
- }
53986
- return false;
53987
- }
53988
- var w;
53989
- (function(e3) {
53990
- e3[e3.GET_WIN_SIZE_PIXELS = 0] = "GET_WIN_SIZE_PIXELS", e3[e3.GET_CELL_SIZE_PIXELS = 1] = "GET_CELL_SIZE_PIXELS";
53991
- })(w || (t2.WindowsOptionsReportType = w = {}));
53992
- let E = 0;
53322
+ var w;
53323
+ (function(e3) {
53324
+ e3[e3.GET_WIN_SIZE_PIXELS = 0] = "GET_WIN_SIZE_PIXELS", e3[e3.GET_CELL_SIZE_PIXELS = 1] = "GET_CELL_SIZE_PIXELS";
53325
+ })(w || (t2.WindowsOptionsReportType = w = {}));
53326
+ let E = 0;
53993
53327
 
53994
53328
  class A extends h.Disposable {
53995
53329
  getAttrData() {
@@ -59361,234 +58695,876 @@ function rowToAnsi(row, cell) {
59361
58695
  const ch = c.getChars();
59362
58696
  out += ch || " ";
59363
58697
  }
59364
- if (prevSgr !== "")
59365
- out += RESET;
59366
- return out;
58698
+ if (prevSgr !== "")
58699
+ out += RESET;
58700
+ return out;
58701
+ }
58702
+
58703
+ class ProcessManager {
58704
+ teams = new Map;
58705
+ terminals = new Map;
58706
+ opts;
58707
+ constructor(opts) {
58708
+ this.opts = opts;
58709
+ }
58710
+ syncLines(team) {
58711
+ const term = this.terminals.get(team.roomId);
58712
+ if (!term)
58713
+ return;
58714
+ const buf = term.buffer.active;
58715
+ const lines = [];
58716
+ const cell = buf.getNullCell();
58717
+ for (let i = 0;i < buf.length; i++) {
58718
+ const row = buf.getLine(i);
58719
+ if (row) {
58720
+ lines.push(rowToAnsi(row, cell));
58721
+ }
58722
+ }
58723
+ while (lines.length > 0 && lines[lines.length - 1] === "") {
58724
+ lines.pop();
58725
+ }
58726
+ team.lines = lines;
58727
+ }
58728
+ spawned = 0;
58729
+ spawn(roomId, roomName) {
58730
+ const team = {
58731
+ roomId,
58732
+ roomName,
58733
+ pid: null,
58734
+ process: null,
58735
+ status: "starting",
58736
+ exitCode: null,
58737
+ lines: []
58738
+ };
58739
+ this.teams.set(roomId, team);
58740
+ if (this.opts.dryRun)
58741
+ return team;
58742
+ const term = new import_headless.Terminal({
58743
+ cols: TERM_COLS,
58744
+ rows: TERM_ROWS,
58745
+ scrollback: 100,
58746
+ allowProposedApi: true
58747
+ });
58748
+ this.terminals.set(roomId, term);
58749
+ const fullPrompt = [
58750
+ `ROOM_ID: ${roomId}`,
58751
+ ``,
58752
+ `You are a team lead. IMMEDIATELY:`,
58753
+ `1. Create a team of agents to work on the task`,
58754
+ `2. Connect to the meet-ai room using the /meet-ai skill`
58755
+ ].join(`
58756
+ `);
58757
+ const claudeArgs = [
58758
+ "--dangerously-skip-permissions",
58759
+ "--model",
58760
+ this.opts.model ?? "opus",
58761
+ fullPrompt
58762
+ ];
58763
+ const { CLAUDECODE: _, ...envWithoutClaude } = process.env;
58764
+ const childEnv = {
58765
+ ...envWithoutClaude,
58766
+ ...this.opts.env,
58767
+ DISABLE_AUTOUPDATER: "1"
58768
+ };
58769
+ const spawnCmd = "/usr/bin/script";
58770
+ const spawnArgs = ["-q", "/dev/null", this.opts.claudePath, ...claudeArgs];
58771
+ if (this.opts.debug) {
58772
+ team.lines.push(`[debug] CMD: ${this.opts.claudePath} ${claudeArgs.join(" ").slice(0, 200)}`);
58773
+ team.lines.push(`[debug] ENV: ${Object.keys(this.opts.env ?? {}).join(", ") || "(none)"}`);
58774
+ }
58775
+ this.spawned++;
58776
+ const child = spawn(spawnCmd, spawnArgs, {
58777
+ stdio: ["ignore", "pipe", "pipe"],
58778
+ env: childEnv,
58779
+ detached: false
58780
+ });
58781
+ team.process = child;
58782
+ team.pid = child.pid ?? null;
58783
+ team.status = "running";
58784
+ this.opts.onStatusChange?.(roomId, "running");
58785
+ child.stdout?.on("data", (chunk) => {
58786
+ term.write(chunk.toString());
58787
+ this.syncLines(team);
58788
+ if (team.status === "starting") {
58789
+ team.status = "running";
58790
+ this.opts.onStatusChange?.(roomId, "running");
58791
+ }
58792
+ });
58793
+ child.stderr?.on("data", (chunk) => {
58794
+ const text = chunk.toString().trim();
58795
+ if (text) {
58796
+ team.lines.push(`[stderr] ${text}`);
58797
+ }
58798
+ });
58799
+ child.on("exit", (code, signal) => {
58800
+ this.syncLines(team);
58801
+ if (this.opts.debug) {
58802
+ team.lines.push(`[debug] exit code=${code} signal=${signal}`);
58803
+ }
58804
+ team.exitCode = code;
58805
+ team.status = code === 0 || code === null ? "exited" : "error";
58806
+ team.process = null;
58807
+ term.dispose();
58808
+ this.terminals.delete(roomId);
58809
+ this.opts.onStatusChange?.(roomId, team.status, code);
58810
+ });
58811
+ child.on("error", (err2) => {
58812
+ team.status = "error";
58813
+ team.lines.push(`[error] ${err2.message}`);
58814
+ team.process = null;
58815
+ term.dispose();
58816
+ this.terminals.delete(roomId);
58817
+ this.opts.onStatusChange?.(roomId, "error");
58818
+ });
58819
+ return team;
58820
+ }
58821
+ addError(roomId, roomName, message) {
58822
+ this.teams.set(roomId, {
58823
+ roomId,
58824
+ roomName,
58825
+ pid: null,
58826
+ process: null,
58827
+ status: "error",
58828
+ exitCode: null,
58829
+ lines: [`[error] ${message}`]
58830
+ });
58831
+ }
58832
+ get(roomId) {
58833
+ return this.teams.get(roomId);
58834
+ }
58835
+ list() {
58836
+ return [...this.teams.values()];
58837
+ }
58838
+ kill(roomId) {
58839
+ const team = this.teams.get(roomId);
58840
+ if (team?.process) {
58841
+ team.process.kill("SIGTERM");
58842
+ const proc = team.process;
58843
+ setTimeout(() => {
58844
+ try {
58845
+ proc.kill("SIGKILL");
58846
+ } catch {}
58847
+ }, 3000);
58848
+ }
58849
+ const term = this.terminals.get(roomId);
58850
+ if (term) {
58851
+ term.dispose();
58852
+ this.terminals.delete(roomId);
58853
+ }
58854
+ this.teams.delete(roomId);
58855
+ }
58856
+ killAll() {
58857
+ for (const roomId of this.teams.keys()) {
58858
+ this.kill(roomId);
58859
+ }
58860
+ }
58861
+ }
58862
+ var import_headless, TERM_COLS = 120, TERM_ROWS = 120, ESC2 = "\x1B[", RESET;
58863
+ var init_process_manager = __esm(() => {
58864
+ import_headless = __toESM(require_xterm_headless(), 1);
58865
+ RESET = `${ESC2}0m`;
58866
+ });
58867
+
58868
+ // src/spawner.ts
58869
+ import { execSync } from "node:child_process";
58870
+ import { existsSync as existsSync3 } from "node:fs";
58871
+ import { homedir as homedir2, platform as platform2 } from "node:os";
58872
+ import { join as join2 } from "node:path";
58873
+ function findClaudeCli() {
58874
+ try {
58875
+ const command = platform2() === "win32" ? "where claude" : "which claude";
58876
+ const result = execSync(command, { encoding: "utf8", stdio: ["pipe", "pipe", "ignore"] }).trim();
58877
+ const claudePath = result.split(`
58878
+ `)[0].trim();
58879
+ if (claudePath && existsSync3(claudePath)) {
58880
+ return claudePath;
58881
+ }
58882
+ } catch {}
58883
+ const envPath = process.env.MEET_AI_CLAUDE_PATH;
58884
+ if (envPath && existsSync3(envPath)) {
58885
+ return envPath;
58886
+ }
58887
+ const home = homedir2();
58888
+ const commonPaths = [
58889
+ join2(home, ".bun", "bin", "claude"),
58890
+ "/opt/homebrew/bin/claude",
58891
+ "/usr/local/bin/claude",
58892
+ join2(home, ".local", "bin", "claude")
58893
+ ];
58894
+ for (const path of commonPaths) {
58895
+ if (existsSync3(path)) {
58896
+ return path;
58897
+ }
58898
+ }
58899
+ throw new Error(`
58900
+ Claude Code is not installed
58901
+
58902
+ Please install Claude Code:
58903
+ bun add -g @anthropic-ai/claude-code
58904
+
58905
+ Or set MEET_AI_CLAUDE_PATH to the Claude Code CLI path.
58906
+ `.trim());
58907
+ }
58908
+ var init_spawner = () => {};
58909
+
58910
+ // ../../node_modules/.bun/react@19.2.4/node_modules/react/cjs/react-jsx-dev-runtime.development.js
58911
+ var require_react_jsx_dev_runtime_development = __commonJS((exports) => {
58912
+ var React11 = __toESM(require_react());
58913
+ (function() {
58914
+ function getComponentNameFromType(type) {
58915
+ if (type == null)
58916
+ return null;
58917
+ if (typeof type === "function")
58918
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
58919
+ if (typeof type === "string")
58920
+ return type;
58921
+ switch (type) {
58922
+ case REACT_FRAGMENT_TYPE:
58923
+ return "Fragment";
58924
+ case REACT_PROFILER_TYPE:
58925
+ return "Profiler";
58926
+ case REACT_STRICT_MODE_TYPE:
58927
+ return "StrictMode";
58928
+ case REACT_SUSPENSE_TYPE:
58929
+ return "Suspense";
58930
+ case REACT_SUSPENSE_LIST_TYPE:
58931
+ return "SuspenseList";
58932
+ case REACT_ACTIVITY_TYPE:
58933
+ return "Activity";
58934
+ }
58935
+ if (typeof type === "object")
58936
+ switch (typeof type.tag === "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
58937
+ case REACT_PORTAL_TYPE:
58938
+ return "Portal";
58939
+ case REACT_CONTEXT_TYPE:
58940
+ return type.displayName || "Context";
58941
+ case REACT_CONSUMER_TYPE:
58942
+ return (type._context.displayName || "Context") + ".Consumer";
58943
+ case REACT_FORWARD_REF_TYPE:
58944
+ var innerType = type.render;
58945
+ type = type.displayName;
58946
+ type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
58947
+ return type;
58948
+ case REACT_MEMO_TYPE:
58949
+ return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
58950
+ case REACT_LAZY_TYPE:
58951
+ innerType = type._payload;
58952
+ type = type._init;
58953
+ try {
58954
+ return getComponentNameFromType(type(innerType));
58955
+ } catch (x) {}
58956
+ }
58957
+ return null;
58958
+ }
58959
+ function testStringCoercion(value) {
58960
+ return "" + value;
58961
+ }
58962
+ function checkKeyStringCoercion(value) {
58963
+ try {
58964
+ testStringCoercion(value);
58965
+ var JSCompiler_inline_result = false;
58966
+ } catch (e) {
58967
+ JSCompiler_inline_result = true;
58968
+ }
58969
+ if (JSCompiler_inline_result) {
58970
+ JSCompiler_inline_result = console;
58971
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
58972
+ var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
58973
+ JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
58974
+ return testStringCoercion(value);
58975
+ }
58976
+ }
58977
+ function getTaskName(type) {
58978
+ if (type === REACT_FRAGMENT_TYPE)
58979
+ return "<>";
58980
+ if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
58981
+ return "<...>";
58982
+ try {
58983
+ var name = getComponentNameFromType(type);
58984
+ return name ? "<" + name + ">" : "<...>";
58985
+ } catch (x) {
58986
+ return "<...>";
58987
+ }
58988
+ }
58989
+ function getOwner() {
58990
+ var dispatcher = ReactSharedInternals.A;
58991
+ return dispatcher === null ? null : dispatcher.getOwner();
58992
+ }
58993
+ function UnknownOwner() {
58994
+ return Error("react-stack-top-frame");
58995
+ }
58996
+ function hasValidKey(config2) {
58997
+ if (hasOwnProperty.call(config2, "key")) {
58998
+ var getter = Object.getOwnPropertyDescriptor(config2, "key").get;
58999
+ if (getter && getter.isReactWarning)
59000
+ return false;
59001
+ }
59002
+ return config2.key !== undefined;
59003
+ }
59004
+ function defineKeyPropWarningGetter(props, displayName) {
59005
+ function warnAboutAccessingKey() {
59006
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", displayName));
59007
+ }
59008
+ warnAboutAccessingKey.isReactWarning = true;
59009
+ Object.defineProperty(props, "key", {
59010
+ get: warnAboutAccessingKey,
59011
+ configurable: true
59012
+ });
59013
+ }
59014
+ function elementRefGetterWithDeprecationWarning() {
59015
+ var componentName = getComponentNameFromType(this.type);
59016
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
59017
+ componentName = this.props.ref;
59018
+ return componentName !== undefined ? componentName : null;
59019
+ }
59020
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
59021
+ var refProp = props.ref;
59022
+ type = {
59023
+ $$typeof: REACT_ELEMENT_TYPE,
59024
+ type,
59025
+ key,
59026
+ props,
59027
+ _owner: owner
59028
+ };
59029
+ (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
59030
+ enumerable: false,
59031
+ get: elementRefGetterWithDeprecationWarning
59032
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
59033
+ type._store = {};
59034
+ Object.defineProperty(type._store, "validated", {
59035
+ configurable: false,
59036
+ enumerable: false,
59037
+ writable: true,
59038
+ value: 0
59039
+ });
59040
+ Object.defineProperty(type, "_debugInfo", {
59041
+ configurable: false,
59042
+ enumerable: false,
59043
+ writable: true,
59044
+ value: null
59045
+ });
59046
+ Object.defineProperty(type, "_debugStack", {
59047
+ configurable: false,
59048
+ enumerable: false,
59049
+ writable: true,
59050
+ value: debugStack
59051
+ });
59052
+ Object.defineProperty(type, "_debugTask", {
59053
+ configurable: false,
59054
+ enumerable: false,
59055
+ writable: true,
59056
+ value: debugTask
59057
+ });
59058
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
59059
+ return type;
59060
+ }
59061
+ function jsxDEVImpl(type, config2, maybeKey, isStaticChildren, debugStack, debugTask) {
59062
+ var children = config2.children;
59063
+ if (children !== undefined)
59064
+ if (isStaticChildren)
59065
+ if (isArrayImpl(children)) {
59066
+ for (isStaticChildren = 0;isStaticChildren < children.length; isStaticChildren++)
59067
+ validateChildKeys(children[isStaticChildren]);
59068
+ Object.freeze && Object.freeze(children);
59069
+ } else
59070
+ console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
59071
+ else
59072
+ validateChildKeys(children);
59073
+ if (hasOwnProperty.call(config2, "key")) {
59074
+ children = getComponentNameFromType(type);
59075
+ var keys = Object.keys(config2).filter(function(k) {
59076
+ return k !== "key";
59077
+ });
59078
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
59079
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(`A props object containing a "key" prop is being spread into JSX:
59080
+ let props = %s;
59081
+ <%s {...props} />
59082
+ React keys must be passed directly to JSX without using spread:
59083
+ let props = %s;
59084
+ <%s key={someKey} {...props} />`, isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = true);
59085
+ }
59086
+ children = null;
59087
+ maybeKey !== undefined && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
59088
+ hasValidKey(config2) && (checkKeyStringCoercion(config2.key), children = "" + config2.key);
59089
+ if ("key" in config2) {
59090
+ maybeKey = {};
59091
+ for (var propName in config2)
59092
+ propName !== "key" && (maybeKey[propName] = config2[propName]);
59093
+ } else
59094
+ maybeKey = config2;
59095
+ children && defineKeyPropWarningGetter(maybeKey, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
59096
+ return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
59097
+ }
59098
+ function validateChildKeys(node) {
59099
+ isValidElement(node) ? node._store && (node._store.validated = 1) : typeof node === "object" && node !== null && node.$$typeof === REACT_LAZY_TYPE && (node._payload.status === "fulfilled" ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
59100
+ }
59101
+ function isValidElement(object2) {
59102
+ return typeof object2 === "object" && object2 !== null && object2.$$typeof === REACT_ELEMENT_TYPE;
59103
+ }
59104
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React11.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
59105
+ return null;
59106
+ };
59107
+ React11 = {
59108
+ react_stack_bottom_frame: function(callStackForError) {
59109
+ return callStackForError();
59110
+ }
59111
+ };
59112
+ var specialPropKeyWarningShown;
59113
+ var didWarnAboutElementRef = {};
59114
+ var unknownOwnerDebugStack = React11.react_stack_bottom_frame.bind(React11, UnknownOwner)();
59115
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
59116
+ var didWarnAboutKeySpread = {};
59117
+ exports.Fragment = REACT_FRAGMENT_TYPE;
59118
+ exports.jsxDEV = function(type, config2, maybeKey, isStaticChildren) {
59119
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
59120
+ return jsxDEVImpl(type, config2, maybeKey, isStaticChildren, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
59121
+ };
59122
+ })();
59123
+ });
59124
+
59125
+ // ../../node_modules/.bun/react@19.2.4/node_modules/react/jsx-dev-runtime.js
59126
+ var require_jsx_dev_runtime = __commonJS((exports, module) => {
59127
+ var react_jsx_dev_runtime_development = __toESM(require_react_jsx_dev_runtime_development());
59128
+ if (false) {} else {
59129
+ module.exports = react_jsx_dev_runtime_development;
59130
+ }
59131
+ });
59132
+
59133
+ // src/tui/pane.tsx
59134
+ function Pane({ roomName, status, lines, focused, height }) {
59135
+ const visibleLines = lines.slice(-(height - 2));
59136
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
59137
+ flexDirection: "column",
59138
+ flexGrow: 1,
59139
+ borderStyle: focused ? "double" : "single",
59140
+ borderColor: focused ? "cyan" : "gray",
59141
+ height,
59142
+ children: [
59143
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
59144
+ children: [
59145
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
59146
+ bold: true,
59147
+ color: focused ? "cyan" : "white",
59148
+ children: [
59149
+ " ",
59150
+ roomName,
59151
+ " "
59152
+ ]
59153
+ }, undefined, true, undefined, this),
59154
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
59155
+ dimColor: true,
59156
+ children: STATUS_ICONS[status]
59157
+ }, undefined, false, undefined, this)
59158
+ ]
59159
+ }, undefined, true, undefined, this),
59160
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
59161
+ flexDirection: "column",
59162
+ flexGrow: 1,
59163
+ paddingX: 1,
59164
+ children: visibleLines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
59165
+ wrap: "truncate",
59166
+ children: line
59167
+ }, i, false, undefined, this))
59168
+ }, undefined, false, undefined, this)
59169
+ ]
59170
+ }, undefined, true, undefined, this);
59171
+ }
59172
+ var jsx_dev_runtime, STATUS_ICONS;
59173
+ var init_pane = __esm(async () => {
59174
+ await init_build2();
59175
+ jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
59176
+ STATUS_ICONS = {
59177
+ starting: "...",
59178
+ running: ">>>",
59179
+ exited: "[done]",
59180
+ error: "[err]"
59181
+ };
59182
+ });
59183
+
59184
+ // src/tui/dashboard.tsx
59185
+ function Dashboard({ teams, focusedIndex, height }) {
59186
+ if (teams.length === 0) {
59187
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
59188
+ flexGrow: 1,
59189
+ alignItems: "center",
59190
+ justifyContent: "center",
59191
+ children: [
59192
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
59193
+ dimColor: true,
59194
+ children: "No teams running. Press "
59195
+ }, undefined, false, undefined, this),
59196
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
59197
+ bold: true,
59198
+ color: "green",
59199
+ children: "n"
59200
+ }, undefined, false, undefined, this),
59201
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
59202
+ dimColor: true,
59203
+ children: " to spawn a new team."
59204
+ }, undefined, false, undefined, this)
59205
+ ]
59206
+ }, undefined, true, undefined, this);
59207
+ }
59208
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
59209
+ flexGrow: 1,
59210
+ flexDirection: "row",
59211
+ children: teams.map((team, index) => /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Pane, {
59212
+ roomName: team.roomName,
59213
+ status: team.status,
59214
+ lines: team.lines,
59215
+ focused: index === focusedIndex,
59216
+ height
59217
+ }, team.roomId, false, undefined, this))
59218
+ }, undefined, false, undefined, this);
59367
59219
  }
59220
+ var jsx_dev_runtime2;
59221
+ var init_dashboard = __esm(async () => {
59222
+ await __promiseAll([
59223
+ init_build2(),
59224
+ init_pane()
59225
+ ]);
59226
+ jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
59227
+ });
59368
59228
 
59369
- class ProcessManager {
59370
- teams = new Map;
59371
- terminals = new Map;
59372
- opts;
59373
- constructor(opts) {
59374
- this.opts = opts;
59375
- }
59376
- syncLines(team) {
59377
- const term = this.terminals.get(team.roomId);
59378
- if (!term)
59229
+ // src/tui/spawn-dialog.tsx
59230
+ function SpawnDialog({ onSubmit, onCancel }) {
59231
+ const [roomName, setRoomName] = import_react29.useState("");
59232
+ const [cursor, setCursor] = import_react29.useState(0);
59233
+ use_input_default((input, key) => {
59234
+ if (key.escape) {
59235
+ onCancel();
59379
59236
  return;
59380
- const buf = term.buffer.active;
59381
- const lines = [];
59382
- const cell = buf.getNullCell();
59383
- for (let i = 0;i < buf.length; i++) {
59384
- const row = buf.getLine(i);
59385
- if (row) {
59386
- lines.push(rowToAnsi(row, cell));
59387
- }
59388
59237
  }
59389
- while (lines.length > 0 && lines[lines.length - 1] === "") {
59390
- lines.pop();
59238
+ if (key.return && roomName.trim()) {
59239
+ onSubmit(roomName.trim());
59240
+ return;
59391
59241
  }
59392
- team.lines = lines;
59393
- }
59394
- spawn(roomId, roomName) {
59395
- const team = {
59396
- roomId,
59397
- roomName,
59398
- pid: null,
59399
- process: null,
59400
- status: "starting",
59401
- exitCode: null,
59402
- lines: []
59403
- };
59404
- this.teams.set(roomId, team);
59405
- if (this.opts.dryRun)
59406
- return team;
59407
- const term = new import_headless.Terminal({
59408
- cols: TERM_COLS,
59409
- rows: TERM_ROWS,
59410
- scrollback: 500,
59411
- allowProposedApi: true
59412
- });
59413
- this.terminals.set(roomId, term);
59414
- const fullPrompt = [
59415
- `MEET_AI_ROOM_ID: ${roomId}`,
59416
- `MEET_AI_AGENT_NAME: team-lead`,
59417
- ``,
59418
- `You are a team lead. IMMEDIATELY:`,
59419
- `1. Create a team of agents to work on the task`,
59420
- `2. Connect to the meet-ai room using the /meet-ai skill`,
59421
- `3. Delegate work to your teammates`,
59422
- ``,
59423
- `Do NOT wait — start the team right away, then use the room for communication.`,
59424
- ``,
59425
- `Start listening for human messages in the background:`,
59426
- ` meet-ai listen "${roomId}" --sender-type human --team "${roomName}" --inbox team-lead`
59427
- ].join(`
59428
- `);
59429
- const claudeArgs = [
59430
- "--dangerously-skip-permissions",
59431
- "--model",
59432
- this.opts.model ?? "opus",
59433
- fullPrompt
59434
- ];
59435
- const { CLAUDECODE: _, ...envWithoutClaude } = process.env;
59436
- const childEnv = {
59437
- ...envWithoutClaude,
59438
- ...this.opts.env,
59439
- DISABLE_AUTOUPDATER: "1"
59440
- };
59441
- const spawnCmd = "/usr/bin/script";
59442
- const spawnArgs = [
59443
- "-q",
59444
- "/dev/null",
59445
- this.opts.claudePath,
59446
- ...claudeArgs
59447
- ];
59448
- if (this.opts.debug) {
59449
- team.lines.push(`[debug] CMD: ${this.opts.claudePath} ${claudeArgs.join(" ").slice(0, 200)}`);
59450
- team.lines.push(`[debug] ENV: ${Object.keys(this.opts.env ?? {}).join(", ") || "(none)"}`);
59242
+ if (key.leftArrow) {
59243
+ setCursor((c) => Math.max(0, c - 1));
59244
+ return;
59451
59245
  }
59452
- const child = spawn(spawnCmd, spawnArgs, {
59453
- stdio: ["ignore", "pipe", "pipe"],
59454
- env: childEnv,
59455
- detached: false
59456
- });
59457
- team.process = child;
59458
- team.pid = child.pid ?? null;
59459
- team.status = "running";
59460
- this.opts.onStatusChange?.(roomId, "running");
59461
- child.stdout?.on("data", (chunk) => {
59462
- term.write(chunk.toString());
59463
- this.syncLines(team);
59464
- if (team.status === "starting") {
59465
- team.status = "running";
59466
- this.opts.onStatusChange?.(roomId, "running");
59467
- }
59468
- });
59469
- child.stderr?.on("data", (chunk) => {
59470
- const text = chunk.toString().trim();
59471
- if (text) {
59472
- team.lines.push(`[stderr] ${text}`);
59473
- }
59474
- });
59475
- child.on("exit", (code, signal) => {
59476
- this.syncLines(team);
59477
- if (this.opts.debug) {
59478
- team.lines.push(`[debug] exit code=${code} signal=${signal}`);
59479
- }
59480
- team.exitCode = code;
59481
- team.status = code === 0 || code === null ? "exited" : "error";
59482
- team.process = null;
59483
- term.dispose();
59484
- this.terminals.delete(roomId);
59485
- this.opts.onStatusChange?.(roomId, team.status, code);
59486
- });
59487
- child.on("error", (err2) => {
59488
- team.status = "error";
59489
- team.lines.push(`[error] ${err2.message}`);
59490
- team.process = null;
59491
- term.dispose();
59492
- this.terminals.delete(roomId);
59493
- this.opts.onStatusChange?.(roomId, "error");
59494
- });
59495
- return team;
59496
- }
59497
- addError(roomId, roomName, message) {
59498
- this.teams.set(roomId, {
59499
- roomId,
59500
- roomName,
59501
- pid: null,
59502
- process: null,
59503
- status: "error",
59504
- exitCode: null,
59505
- lines: [`[error] ${message}`]
59506
- });
59507
- }
59508
- get(roomId) {
59509
- return this.teams.get(roomId);
59510
- }
59511
- list() {
59512
- return [...this.teams.values()];
59513
- }
59514
- kill(roomId) {
59515
- const team = this.teams.get(roomId);
59516
- if (team?.process) {
59517
- team.process.kill("SIGTERM");
59518
- const proc = team.process;
59519
- setTimeout(() => {
59520
- try {
59521
- proc.kill("SIGKILL");
59522
- } catch {}
59523
- }, 3000);
59246
+ if (key.rightArrow) {
59247
+ setCursor((c) => Math.min(roomName.length, c + 1));
59248
+ return;
59524
59249
  }
59525
- const term = this.terminals.get(roomId);
59526
- if (term) {
59527
- term.dispose();
59528
- this.terminals.delete(roomId);
59250
+ if (key.backspace || key.delete) {
59251
+ if (cursor > 0) {
59252
+ setRoomName((v) => v.slice(0, cursor - 1) + v.slice(cursor));
59253
+ setCursor((c) => c - 1);
59254
+ }
59255
+ return;
59529
59256
  }
59530
- this.teams.delete(roomId);
59531
- }
59532
- killAll() {
59533
- for (const roomId of this.teams.keys()) {
59534
- this.kill(roomId);
59257
+ if (input && !key.ctrl && !key.meta && !key.upArrow && !key.downArrow) {
59258
+ setRoomName((v) => v.slice(0, cursor) + input + v.slice(cursor));
59259
+ setCursor((c) => c + input.length);
59535
59260
  }
59261
+ });
59262
+ const before = roomName.slice(0, cursor);
59263
+ const at = roomName[cursor] ?? " ";
59264
+ const after = roomName.slice(cursor + 1);
59265
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
59266
+ flexDirection: "column",
59267
+ borderStyle: "round",
59268
+ borderColor: "green",
59269
+ paddingX: 1,
59270
+ children: [
59271
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
59272
+ bold: true,
59273
+ color: "green",
59274
+ children: "New Team"
59275
+ }, undefined, false, undefined, this),
59276
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
59277
+ children: [
59278
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
59279
+ children: "Room name: "
59280
+ }, undefined, false, undefined, this),
59281
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
59282
+ color: "cyan",
59283
+ children: before
59284
+ }, undefined, false, undefined, this),
59285
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
59286
+ backgroundColor: "cyan",
59287
+ color: "black",
59288
+ children: at
59289
+ }, undefined, false, undefined, this),
59290
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
59291
+ color: "cyan",
59292
+ children: after
59293
+ }, undefined, false, undefined, this)
59294
+ ]
59295
+ }, undefined, true, undefined, this)
59296
+ ]
59297
+ }, undefined, true, undefined, this);
59298
+ }
59299
+ var import_react29, jsx_dev_runtime3;
59300
+ var init_spawn_dialog = __esm(async () => {
59301
+ await init_build2();
59302
+ import_react29 = __toESM(require_react(), 1);
59303
+ jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
59304
+ });
59305
+
59306
+ // src/tui/status-bar.tsx
59307
+ function StatusBar({
59308
+ teamCount,
59309
+ focusedRoom,
59310
+ showingSpawnDialog
59311
+ }) {
59312
+ if (showingSpawnDialog) {
59313
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
59314
+ children: [
59315
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59316
+ dimColor: true,
59317
+ children: "Enter room name and prompt. Press "
59318
+ }, undefined, false, undefined, this),
59319
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59320
+ bold: true,
59321
+ children: "Escape"
59322
+ }, undefined, false, undefined, this),
59323
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59324
+ dimColor: true,
59325
+ children: " to cancel."
59326
+ }, undefined, false, undefined, this)
59327
+ ]
59328
+ }, undefined, true, undefined, this);
59536
59329
  }
59330
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
59331
+ justifyContent: "space-between",
59332
+ children: [
59333
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
59334
+ gap: 2,
59335
+ children: [
59336
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59337
+ children: [
59338
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59339
+ dimColor: true,
59340
+ children: "["
59341
+ }, undefined, false, undefined, this),
59342
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59343
+ bold: true,
59344
+ color: "green",
59345
+ children: "n"
59346
+ }, undefined, false, undefined, this),
59347
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59348
+ dimColor: true,
59349
+ children: "]ew"
59350
+ }, undefined, false, undefined, this)
59351
+ ]
59352
+ }, undefined, true, undefined, this),
59353
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59354
+ children: [
59355
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59356
+ dimColor: true,
59357
+ children: "["
59358
+ }, undefined, false, undefined, this),
59359
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59360
+ bold: true,
59361
+ color: "red",
59362
+ children: "k"
59363
+ }, undefined, false, undefined, this),
59364
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59365
+ dimColor: true,
59366
+ children: "]ill"
59367
+ }, undefined, false, undefined, this)
59368
+ ]
59369
+ }, undefined, true, undefined, this),
59370
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59371
+ children: [
59372
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59373
+ dimColor: true,
59374
+ children: "["
59375
+ }, undefined, false, undefined, this),
59376
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59377
+ bold: true,
59378
+ children: "<->"
59379
+ }, undefined, false, undefined, this),
59380
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59381
+ dimColor: true,
59382
+ children: "]focus"
59383
+ }, undefined, false, undefined, this)
59384
+ ]
59385
+ }, undefined, true, undefined, this),
59386
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59387
+ children: [
59388
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59389
+ dimColor: true,
59390
+ children: "["
59391
+ }, undefined, false, undefined, this),
59392
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59393
+ bold: true,
59394
+ color: "yellow",
59395
+ children: "q"
59396
+ }, undefined, false, undefined, this),
59397
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59398
+ dimColor: true,
59399
+ children: "]uit"
59400
+ }, undefined, false, undefined, this)
59401
+ ]
59402
+ }, undefined, true, undefined, this)
59403
+ ]
59404
+ }, undefined, true, undefined, this),
59405
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
59406
+ gap: 2,
59407
+ children: [
59408
+ focusedRoom && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59409
+ color: "cyan",
59410
+ children: focusedRoom
59411
+ }, undefined, false, undefined, this),
59412
+ /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
59413
+ dimColor: true,
59414
+ children: [
59415
+ teamCount,
59416
+ " team",
59417
+ teamCount !== 1 ? "s" : ""
59418
+ ]
59419
+ }, undefined, true, undefined, this)
59420
+ ]
59421
+ }, undefined, true, undefined, this)
59422
+ ]
59423
+ }, undefined, true, undefined, this);
59537
59424
  }
59538
- var import_headless, TERM_COLS = 120, TERM_ROWS = 50, ESC2 = "\x1B[", RESET;
59539
- var init_process_manager = __esm(() => {
59540
- import_headless = __toESM(require_xterm_headless(), 1);
59541
- RESET = `${ESC2}0m`;
59425
+ var jsx_dev_runtime4;
59426
+ var init_status_bar = __esm(async () => {
59427
+ await init_build2();
59428
+ jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
59542
59429
  });
59543
59430
 
59544
- // src/spawner.ts
59545
- import { spawn as spawn2, execSync } from "node:child_process";
59546
- import { existsSync as existsSync3 } from "node:fs";
59547
- import { join as join2 } from "node:path";
59548
- import { homedir as homedir2, platform as platform2 } from "node:os";
59549
- function findClaudeCli() {
59550
- try {
59551
- const command = platform2() === "win32" ? "where claude" : "which claude";
59552
- const result = execSync(command, { encoding: "utf8", stdio: ["pipe", "pipe", "ignore"] }).trim();
59553
- const claudePath = result.split(`
59554
- `)[0].trim();
59555
- if (claudePath && existsSync3(claudePath)) {
59556
- return claudePath;
59431
+ // src/tui/app.tsx
59432
+ function AppInner({ processManager, client }) {
59433
+ const { exit } = use_app_default();
59434
+ const { stdout } = use_stdout_default();
59435
+ const [teams, setTeams] = import_react30.useState(processManager.list());
59436
+ const [focusedIndex, setFocusedIndex] = import_react30.useState(0);
59437
+ const [showSpawn, setShowSpawn] = import_react30.useState(false);
59438
+ const terminalHeight = stdout?.rows ?? 24;
59439
+ const dashboardHeight = terminalHeight - 2;
59440
+ const refreshTeams = import_react30.useCallback(() => {
59441
+ setTeams([...processManager.list()]);
59442
+ }, [processManager]);
59443
+ const handleSpawn = import_react30.useCallback(async (roomName) => {
59444
+ try {
59445
+ const room = await client.createRoom(roomName);
59446
+ processManager.spawn(room.id, roomName);
59447
+ refreshTeams();
59448
+ } catch (error48) {
59449
+ const msg = error48 instanceof Error ? error48.message : String(error48);
59450
+ const errorId = `error-${Date.now()}`;
59451
+ processManager.addError(errorId, roomName, msg);
59452
+ refreshTeams();
59557
59453
  }
59558
- } catch {}
59559
- const envPath = process.env.MEET_AI_CLAUDE_PATH;
59560
- if (envPath && existsSync3(envPath)) {
59561
- return envPath;
59562
- }
59563
- const home = homedir2();
59564
- const commonPaths = [
59565
- join2(home, ".bun", "bin", "claude"),
59566
- "/opt/homebrew/bin/claude",
59567
- "/usr/local/bin/claude",
59568
- join2(home, ".local", "bin", "claude")
59569
- ];
59570
- for (const path of commonPaths) {
59571
- if (existsSync3(path)) {
59572
- return path;
59454
+ }, [client, processManager, refreshTeams]);
59455
+ const handleKillById = import_react30.useCallback((roomId) => {
59456
+ processManager.kill(roomId);
59457
+ refreshTeams();
59458
+ }, [processManager, refreshTeams]);
59459
+ import_react30.useEffect(() => {
59460
+ const interval = setInterval(refreshTeams, 200);
59461
+ return () => clearInterval(interval);
59462
+ }, [refreshTeams]);
59463
+ use_input_default((input, key) => {
59464
+ if (showSpawn)
59465
+ return;
59466
+ if (input === "q") {
59467
+ processManager.killAll();
59468
+ exit();
59469
+ return;
59573
59470
  }
59574
- }
59575
- throw new Error(`
59576
- Claude Code is not installed
59577
-
59578
- Please install Claude Code:
59579
- bun add -g @anthropic-ai/claude-code
59580
-
59581
- Or set MEET_AI_CLAUDE_PATH to the Claude Code CLI path.
59582
- `.trim());
59471
+ if (input === "n") {
59472
+ setShowSpawn(true);
59473
+ return;
59474
+ }
59475
+ if (input === "k" && teams.length > 0) {
59476
+ const team = teams[focusedIndex];
59477
+ if (team)
59478
+ handleKillById(team.roomId);
59479
+ if (focusedIndex >= teams.length - 1) {
59480
+ setFocusedIndex(Math.max(0, focusedIndex - 1));
59481
+ }
59482
+ return;
59483
+ }
59484
+ if (key.leftArrow) {
59485
+ setFocusedIndex((i) => Math.max(0, i - 1));
59486
+ }
59487
+ if (key.rightArrow) {
59488
+ setFocusedIndex((i) => Math.min(teams.length - 1, i + 1));
59489
+ }
59490
+ });
59491
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
59492
+ flexDirection: "column",
59493
+ height: terminalHeight,
59494
+ children: [
59495
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Dashboard, {
59496
+ teams,
59497
+ focusedIndex,
59498
+ height: dashboardHeight
59499
+ }, undefined, false, undefined, this),
59500
+ showSpawn ? /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(SpawnDialog, {
59501
+ onSubmit: (name) => {
59502
+ setShowSpawn(false);
59503
+ handleSpawn(name);
59504
+ },
59505
+ onCancel: () => setShowSpawn(false)
59506
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(StatusBar, {
59507
+ teamCount: teams.length,
59508
+ focusedRoom: teams[focusedIndex]?.roomName ?? null,
59509
+ showingSpawnDialog: false
59510
+ }, undefined, false, undefined, this)
59511
+ ]
59512
+ }, undefined, true, undefined, this);
59583
59513
  }
59584
- var init_spawner = () => {};
59514
+ function App2(props) {
59515
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ErrorBoundary2, {
59516
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(AppInner, {
59517
+ ...props
59518
+ }, undefined, false, undefined, this)
59519
+ }, undefined, false, undefined, this);
59520
+ }
59521
+ var import_react30, jsx_dev_runtime5, ErrorBoundary2;
59522
+ var init_app = __esm(async () => {
59523
+ await __promiseAll([
59524
+ init_build2(),
59525
+ init_dashboard(),
59526
+ init_spawn_dialog(),
59527
+ init_status_bar()
59528
+ ]);
59529
+ import_react30 = __toESM(require_react(), 1);
59530
+ jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
59531
+ ErrorBoundary2 = class ErrorBoundary2 extends import_react30.Component {
59532
+ state = { error: null };
59533
+ static getDerivedStateFromError(error48) {
59534
+ return { error: error48 };
59535
+ }
59536
+ render() {
59537
+ if (this.state.error) {
59538
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
59539
+ flexDirection: "column",
59540
+ paddingX: 1,
59541
+ children: [
59542
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
59543
+ color: "red",
59544
+ bold: true,
59545
+ children: [
59546
+ "TUI crashed: ",
59547
+ this.state.error.message
59548
+ ]
59549
+ }, undefined, true, undefined, this),
59550
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
59551
+ dimColor: true,
59552
+ children: "Press Ctrl+C to exit"
59553
+ }, undefined, false, undefined, this)
59554
+ ]
59555
+ }, undefined, true, undefined, this);
59556
+ }
59557
+ return this.props.children;
59558
+ }
59559
+ };
59560
+ });
59585
59561
 
59586
59562
  // src/commands/dashboard/usecase.ts
59587
59563
  var exports_usecase = {};
59588
59564
  __export(exports_usecase, {
59589
59565
  startDashboard: () => startDashboard
59590
59566
  });
59591
- function startDashboard(client, config2, options) {
59567
+ async function startDashboard(client, config2, options) {
59592
59568
  const claudePath = findClaudeCli();
59593
59569
  const processManager = new ProcessManager({
59594
59570
  claudePath,
@@ -59598,14 +59574,35 @@ function startDashboard(client, config2, options) {
59598
59574
  ...config2.key ? { MEET_AI_KEY: config2.key } : {}
59599
59575
  }
59600
59576
  });
59577
+ let lobbyWs = null;
59578
+ const pendingSpawns = new Set;
59579
+ try {
59580
+ lobbyWs = client.listenLobby({
59581
+ silent: true,
59582
+ onSpawnRequest: async (roomName) => {
59583
+ if (pendingSpawns.has(roomName))
59584
+ return;
59585
+ pendingSpawns.add(roomName);
59586
+ try {
59587
+ const room = await client.createRoom(roomName);
59588
+ processManager.spawn(room.id, roomName);
59589
+ } catch {
59590
+ pendingSpawns.delete(roomName);
59591
+ }
59592
+ }
59593
+ });
59594
+ } catch {}
59601
59595
  function cleanup() {
59596
+ lobbyWs?.close();
59602
59597
  processManager.killAll();
59603
59598
  process.exit(0);
59604
59599
  }
59605
59600
  process.on("SIGINT", cleanup);
59606
59601
  process.on("SIGTERM", cleanup);
59607
59602
  const element = import_react31.default.createElement(App2, { processManager, client });
59608
- render_default(element);
59603
+ const instance = render_default(element);
59604
+ await instance.waitUntilExit();
59605
+ cleanup();
59609
59606
  }
59610
59607
  var import_react31;
59611
59608
  var init_usecase10 = __esm(async () => {
@@ -59661,7 +59658,7 @@ init_output();
59661
59658
  var main = defineCommand({
59662
59659
  meta: {
59663
59660
  name: "meet-ai",
59664
- version: "0.0.13",
59661
+ version: "0.0.18",
59665
59662
  description: "CLI for meet-ai chat rooms — create rooms, send messages, and stream via WebSocket"
59666
59663
  },
59667
59664
  args: {
@@ -59685,13 +59682,16 @@ var main = defineCommand({
59685
59682
  dashboard: () => init_command11().then(() => exports_command11).then((m) => m.default)
59686
59683
  },
59687
59684
  async run({ args }) {
59685
+ const hasSubcommand = process.argv.length > 2;
59686
+ if (hasSubcommand)
59687
+ return;
59688
59688
  try {
59689
59689
  const { getClient: getClient2 } = await Promise.resolve().then(() => (init_client_factory(), exports_client_factory));
59690
59690
  const { getMeetAiConfig: getMeetAiConfig2 } = await Promise.resolve().then(() => (init_config(), exports_config));
59691
59691
  const { startDashboard: startDashboard2 } = await init_usecase10().then(() => exports_usecase);
59692
59692
  const client = getClient2();
59693
59693
  const config2 = getMeetAiConfig2();
59694
- startDashboard2(client, config2, { debug: args.debug });
59694
+ await startDashboard2(client, config2, { debug: args.debug });
59695
59695
  } catch (error48) {
59696
59696
  err(error48 instanceof Error ? error48.message : String(error48));
59697
59697
  process.exit(1);