@adhdev/daemon-standalone 0.9.76-rc.51 → 0.9.76-rc.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9165,6 +9165,7 @@ var require_dist = __commonJS({
9165
9165
  DEFAULT_SESSION_HOST_COLS: () => DEFAULT_SESSION_HOST_COLS,
9166
9166
  DEFAULT_SESSION_HOST_ROWS: () => DEFAULT_SESSION_HOST_ROWS,
9167
9167
  DEFAULT_SESSION_RING_BUFFER_MAX_BYTES: () => DEFAULT_SESSION_RING_BUFFER_MAX_BYTES2,
9168
+ SESSION_HOST_SUPPORTED_REQUEST_TYPES: () => SESSION_HOST_SUPPORTED_REQUEST_TYPES,
9168
9169
  SessionHostClient: () => SessionHostClient2,
9169
9170
  SessionHostRegistry: () => SessionHostRegistry,
9170
9171
  SessionRingBuffer: () => SessionRingBuffer,
@@ -9189,6 +9190,27 @@ var require_dist = __commonJS({
9189
9190
  writeEnvelope: () => writeEnvelope
9190
9191
  });
9191
9192
  module2.exports = __toCommonJS2(index_exports);
9193
+ var SESSION_HOST_SUPPORTED_REQUEST_TYPES = [
9194
+ "create_session",
9195
+ "attach_session",
9196
+ "detach_session",
9197
+ "send_input",
9198
+ "resize_session",
9199
+ "stop_session",
9200
+ "delete_session",
9201
+ "resume_session",
9202
+ "acquire_write",
9203
+ "release_write",
9204
+ "get_snapshot",
9205
+ "clear_session_buffer",
9206
+ "update_session_meta",
9207
+ "get_host_diagnostics",
9208
+ "force_detach_client",
9209
+ "send_signal",
9210
+ "restart_session",
9211
+ "prune_duplicate_sessions",
9212
+ "list_sessions"
9213
+ ];
9192
9214
  var DEFAULT_SESSION_RING_BUFFER_MAX_BYTES2 = 4 * 1024 * 1024;
9193
9215
  var SessionRingBuffer = class {
9194
9216
  maxBytes;
@@ -61119,29 +61141,58 @@ data: ${JSON.stringify(msg.data)}
61119
61141
  var import_session_host_core4 = require_dist();
61120
61142
  var STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS2;
61121
61143
  var STARTUP_POLL_MS = 200;
61122
- async function canConnect(endpoint) {
61144
+ var SessionHostCompatibilityError = class extends Error {
61145
+ constructor(message) {
61146
+ super(message);
61147
+ this.name = "SessionHostCompatibilityError";
61148
+ }
61149
+ };
61150
+ function getMissingRequestTypes(diagnostics, requiredRequestTypes) {
61151
+ const supported = new Set(diagnostics?.supportedRequestTypes || []);
61152
+ return requiredRequestTypes.filter((requestType) => !supported.has(requestType));
61153
+ }
61154
+ async function assertRequiredRequestTypes(client, requiredRequestTypes) {
61155
+ if (requiredRequestTypes.length === 0) return;
61156
+ const response = await client.request({
61157
+ type: "get_host_diagnostics",
61158
+ payload: { includeSessions: false }
61159
+ });
61160
+ const missing = getMissingRequestTypes(response.success ? response.result : void 0, requiredRequestTypes);
61161
+ if (missing.length > 0) {
61162
+ const detail = response.success ? "" : ` (${response.error || "capability probe failed"})`;
61163
+ throw new SessionHostCompatibilityError(
61164
+ `Session host does not support required request types: ${missing.join(", ")}${detail}`
61165
+ );
61166
+ }
61167
+ }
61168
+ async function canConnect(endpoint, requiredRequestTypes = []) {
61123
61169
  const client = new import_session_host_core4.SessionHostClient({ endpoint });
61124
61170
  try {
61125
61171
  await client.connect();
61126
- await client.close();
61172
+ await assertRequiredRequestTypes(client, requiredRequestTypes);
61127
61173
  return true;
61128
- } catch {
61174
+ } catch (error48) {
61175
+ if (error48 instanceof SessionHostCompatibilityError) throw error48;
61129
61176
  return false;
61177
+ } finally {
61178
+ await client.close().catch(() => {
61179
+ });
61130
61180
  }
61131
61181
  }
61132
- async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
61182
+ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS, requiredRequestTypes = []) {
61133
61183
  const deadline = Date.now() + timeoutMs;
61134
61184
  while (Date.now() < deadline) {
61135
- if (await canConnect(endpoint)) return;
61185
+ if (await canConnect(endpoint, requiredRequestTypes)) return;
61136
61186
  await new Promise((resolve16) => setTimeout(resolve16, STARTUP_POLL_MS));
61137
61187
  }
61138
61188
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
61139
61189
  }
61140
61190
  async function ensureSessionHostReady2(options) {
61141
61191
  const endpoint = (0, import_session_host_core4.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
61142
- if (await canConnect(endpoint)) return endpoint;
61192
+ const requiredRequestTypes = options.requiredRequestTypes || [];
61193
+ if (await canConnect(endpoint, requiredRequestTypes)) return endpoint;
61143
61194
  options.spawnHost();
61144
- await waitForReady(endpoint, options.timeoutMs);
61195
+ await waitForReady(endpoint, options.timeoutMs, requiredRequestTypes);
61145
61196
  return endpoint;
61146
61197
  }
61147
61198
  async function listHostedCliRuntimes2(endpoint) {
@@ -61861,14 +61912,16 @@ async function ensureSessionHostReady() {
61861
61912
  return await (0, import_daemon_core.ensureSessionHostReady)({
61862
61913
  appName: SESSION_HOST_APP_NAME,
61863
61914
  spawnHost,
61864
- timeoutMs: SESSION_HOST_START_TIMEOUT_MS
61915
+ timeoutMs: SESSION_HOST_START_TIMEOUT_MS,
61916
+ requiredRequestTypes: ["delete_session"]
61865
61917
  });
61866
61918
  } catch (error48) {
61867
61919
  stopSessionHost();
61868
61920
  return (0, import_daemon_core.ensureSessionHostReady)({
61869
61921
  appName: SESSION_HOST_APP_NAME,
61870
61922
  spawnHost,
61871
- timeoutMs: SESSION_HOST_START_TIMEOUT_MS
61923
+ timeoutMs: SESSION_HOST_START_TIMEOUT_MS,
61924
+ requiredRequestTypes: ["delete_session"]
61872
61925
  }).catch((retryError) => {
61873
61926
  const initialMessage = error48 instanceof Error ? error48.message : String(error48);
61874
61927
  const retryMessage = retryError instanceof Error ? retryError.message : String(retryError);