@cydm/happy-elves 0.1.0-beta.306 → 0.1.0-beta.307

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/happy-elves-cli",
3
- "version": "0.1.0-beta.306",
3
+ "version": "0.1.0-beta.307",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }
@@ -240,16 +240,17 @@ async function admitGatewayPromptWithMappingRecovery(config, channel, mapping, i
240
240
  catch (error) {
241
241
  if (!canRecoverGatewayMapping(channel, error))
242
242
  throw error;
243
- const recovered = await recoverGatewayMapping(config, channel, mapping, input.externalConversationId);
243
+ const recovered = await recoverGatewayMapping(config, channel, mapping, input.externalConversationId, input.requestId);
244
244
  return await admitGatewayPromptNow(config, channel, {
245
245
  ...input,
246
246
  sessionId: recovered.sessionId,
247
247
  });
248
248
  }
249
249
  }
250
- async function recoverGatewayMapping(config, channel, staleMapping, externalConversationId) {
251
- const createRequestId = stableGatewayId("gw_create", channel.id, externalConversationId);
252
- const mapping = await createGatewayMapping(config, channel, externalConversationId, createRequestId);
250
+ async function recoverGatewayMapping(config, channel, staleMapping, externalConversationId, recoverySeed) {
251
+ const createRequestId = stableGatewayId("gw_create", channel.id, externalConversationId, "recover", recoverySeed);
252
+ const sessionId = stableGatewayId("ses_gw", channel.id, externalConversationId, "recover", recoverySeed);
253
+ const mapping = await createGatewayMapping(config, channel, externalConversationId, createRequestId, sessionId);
253
254
  if (mapping.sessionId === staleMapping.sessionId)
254
255
  return mapping;
255
256
  const now = new Date().toISOString();
@@ -266,9 +267,9 @@ function canRecoverGatewayMapping(channel, error) {
266
267
  return false;
267
268
  if (!channel.targetCwd)
268
269
  return false;
269
- return errorCode(error) === "SESSION_NOT_FOUND";
270
+ return errorCode(error) === "SESSION_NOT_FOUND" || errorCode(error) === "SESSION_CLOSED";
270
271
  }
271
- async function createGatewayMapping(config, channel, externalConversationId, createRequestId) {
272
+ async function createGatewayMapping(config, channel, externalConversationId, createRequestId, recoveredSessionId) {
272
273
  if (channel.targetSessionId) {
273
274
  const now = new Date().toISOString();
274
275
  const mapping = {
@@ -287,7 +288,7 @@ async function createGatewayMapping(config, channel, externalConversationId, cre
287
288
  }
288
289
  if (!channel.targetCwd)
289
290
  throw gatewayError("Gateway channel needs target cwd or target session", "GATEWAY_TARGET_MISSING", 400);
290
- const sessionId = stableGatewayId("ses_gw", channel.id, externalConversationId);
291
+ const sessionId = recoveredSessionId ?? stableGatewayId("ses_gw", channel.id, externalConversationId);
291
292
  const create = await admitMachineCreateSession(config, {
292
293
  requestId: createRequestId,
293
294
  sessionId,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/happy-elves-daemon",
3
- "version": "0.1.0-beta.306",
3
+ "version": "0.1.0-beta.307",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/happy-elves",
3
- "version": "0.1.0-beta.306",
3
+ "version": "0.1.0-beta.307",
4
4
  "description": "Remote controller for local coding agents with hosted or self-hosted relay support.",
5
5
  "type": "module",
6
6
  "bin": {