@testdriverai/agent 7.9.0-canary.4 → 7.9.0-canary.5

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.
@@ -117,7 +117,13 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
117
117
 
118
118
  this._sessionChannel = this._ably.channels.get(channelName);
119
119
 
120
- logger.debug(`[realtime] Channel initialized: ${channelName}`);
120
+ // Explicitly attach the session channel BEFORE entering presence on the
121
+ // members channel. Entering members-presence triggers the API's waitpoint
122
+ // completion → claim-slot task → publishes slot-approved on the session
123
+ // channel. If the session channel isn't attached yet, that message lands
124
+ // before our attachment point and historyBeforeSubscribe() won't see it.
125
+ await this._sessionChannel.attach();
126
+ logger.debug(`[realtime] Channel attached: ${channelName}`);
121
127
 
122
128
  // Enter presence on the team members channel so the API can count
123
129
  // connected SDK clients with a single direct lookup per team.
@@ -541,6 +547,8 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
541
547
  timeout,
542
548
  );
543
549
 
550
+ logger.debug(`[sandbox] authenticate response: success=${reply.success} status=${reply.status || 'none'} sandboxId=${reply.sandboxId || 'none'}`);
551
+
544
552
  if (!reply.success) {
545
553
  var err = new Error(
546
554
  reply.errorMessage || "Failed to allocate sandbox",
@@ -553,6 +561,7 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
553
561
  this._teamId = reply.teamId;
554
562
 
555
563
  if (reply.ably && reply.ably.token) {
564
+ logger.debug(`[sandbox] Initializing Ably with channel=${reply.ably.channel}, membersChannel=${reply.ably.membersChannel || '(derived)'}`);
556
565
  await this._initAbly(reply.ably.token, reply.ably.channel, reply.ably.membersChannel);
557
566
  this.instanceSocketConnected = true;
558
567
 
@@ -578,6 +587,7 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
578
587
  var slotPollStart = Date.now();
579
588
  while (reply.status === 'pending') {
580
589
  logger.log('Slot claim pending — waiting for approval via Ably...');
590
+ logger.debug(`[slots] sandboxId=${this._sandboxId} channel=${this._channelName} membersChannel=${this._membersChannelName}`);
581
591
 
582
592
  var self = this;
583
593
  var slotResolved = false;
@@ -618,24 +628,32 @@ const createSandbox = function (emitter, analytics, sessionInstance) {
618
628
  // The claim-slot task fires in response to presence enter, so the
619
629
  // decision may already be published by the time we get here.
620
630
  var slotControlSub = await self._sessionChannel.subscribe('control', onSlotControl);
631
+ logger.debug(`[slots] Subscribed to control channel for slot decision (sandboxId=${this._sandboxId})`);
621
632
 
622
633
  // Check for decisions published before this subscription was active
623
634
  if (!slotResolved && slotControlSub) {
624
635
  try {
636
+ logger.debug(`[slots] Checking history for pre-subscription slot decisions (sandboxId=${this._sandboxId})`);
637
+ logger.debug(`[slots] Checking history for pre-subscription slot decisions (sandboxId=${this._sandboxId})`);
625
638
  var histPage = await slotControlSub.historyBeforeSubscribe({ limit: 10 });
639
+ var histItemCount = 0;
626
640
  while (histPage && !slotResolved) {
627
641
  for (var hi = 0; hi < histPage.items.length; hi++) {
642
+ histItemCount++;
643
+ logger.debug(`[slots] History item: type=${histPage.items[hi].data && histPage.items[hi].data.type} (sandboxId=${this._sandboxId})`);
628
644
  onSlotControl(histPage.items[hi]);
629
645
  if (slotResolved) break;
630
646
  }
631
647
  histPage = (!slotResolved && histPage.hasNext()) ? await histPage.next() : null;
632
648
  }
649
+ logger.debug(`[slots] History check done: ${histItemCount} items checked, resolved=${slotResolved} (sandboxId=${this._sandboxId})`);
633
650
  } catch (histErr) {
634
651
  logger.warn('[slots] Failed to check history for slot decision: ' + (histErr.message || histErr));
635
652
  }
636
653
  }
637
654
 
638
655
  var slotDecision = await slotDecisionPromise;
656
+ logger.debug(`[slots] Slot decision received: approved=${slotDecision.approved} sandboxId=${this._sandboxId} elapsedMs=${Date.now() - slotPollStart}`);
639
657
 
640
658
  if (!slotDecision.approved) {
641
659
  // Slot denied — disconnect Ably and re-try the full authenticate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testdriverai/agent",
3
- "version": "7.9.0-canary.4",
3
+ "version": "7.9.0-canary.5",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",