@openscout/scout 0.2.42 → 0.2.44

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/main.mjs CHANGED
@@ -4536,7 +4536,7 @@ class ClaudeStreamJsonSession {
4536
4536
  sessionId: this.claudeSessionId
4537
4537
  };
4538
4538
  }
4539
- async invoke(prompt, timeoutMs = 5 * 60000) {
4539
+ async invoke(prompt, stallTimeoutMs = 10 * 60000) {
4540
4540
  await this.ensureStarted();
4541
4541
  if (!this.process?.stdin) {
4542
4542
  throw new Error(`Claude stream-json session for ${this.options.agentName} is not running.`);
@@ -4548,19 +4548,13 @@ class ClaudeStreamJsonSession {
4548
4548
  const turn = {
4549
4549
  id: randomUUID(),
4550
4550
  output: [],
4551
- timer: setTimeout(() => {
4552
- this.interrupt().catch(() => {
4553
- return;
4554
- });
4555
- if (this.activeTurn?.id === turn.id) {
4556
- this.activeTurn = null;
4557
- }
4558
- reject(new Error(`Timed out after ${timeoutMs}ms waiting for ${this.options.agentName}.`));
4559
- }, timeoutMs),
4551
+ timer: null,
4552
+ stallMs: stallTimeoutMs,
4560
4553
  resolve: resolve5,
4561
4554
  reject
4562
4555
  };
4563
4556
  this.activeTurn = turn;
4557
+ this.resetTurnWatchdog(turn);
4564
4558
  });
4565
4559
  const payload = JSON.stringify({
4566
4560
  type: "user",
@@ -4584,6 +4578,20 @@ class ClaudeStreamJsonSession {
4584
4578
  this.process.kill("SIGINT");
4585
4579
  }
4586
4580
  }
4581
+ resetTurnWatchdog(turn) {
4582
+ if (turn.timer) {
4583
+ clearTimeout(turn.timer);
4584
+ }
4585
+ turn.timer = setTimeout(() => {
4586
+ this.interrupt().catch(() => {
4587
+ return;
4588
+ });
4589
+ if (this.activeTurn?.id === turn.id) {
4590
+ this.activeTurn = null;
4591
+ }
4592
+ turn.reject(new Error(`${this.options.agentName} stalled \u2014 no stream event in ${turn.stallMs}ms`));
4593
+ }, turn.stallMs);
4594
+ }
4587
4595
  async shutdown(options = {}) {
4588
4596
  const turn = this.activeTurn;
4589
4597
  this.activeTurn = null;
@@ -4718,6 +4726,7 @@ class ClaudeStreamJsonSession {
4718
4726
  if (!turn) {
4719
4727
  return;
4720
4728
  }
4729
+ this.resetTurnWatchdog(turn);
4721
4730
  if (event.type === "assistant") {
4722
4731
  const content = event.message?.content ?? event.content ?? [];
4723
4732
  for (const part of content) {
@@ -8346,7 +8355,13 @@ async function askScoutQuestion(input) {
8346
8355
  targetDiagnostic: await describeScoutTargetAvailability(broker.snapshot, target, currentDirectory)
8347
8356
  };
8348
8357
  }
8349
- const conversation = await ensureBrokerConversation(broker.baseUrl, broker.snapshot, broker.node.id, input.channel, senderId, [target.agentId]);
8358
+ let conversation;
8359
+ if (!input.channel) {
8360
+ const dm = await ensureBrokerDirectConversationBetween(broker.baseUrl, broker.snapshot, broker.node.id, senderId, target.agentId);
8361
+ conversation = dm.conversation;
8362
+ } else {
8363
+ conversation = await ensureBrokerConversation(broker.baseUrl, broker.snapshot, broker.node.id, input.channel, senderId, [target.agentId]);
8364
+ }
8350
8365
  const messageId = `m-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
8351
8366
  const messageBody = input.body.trim().startsWith(target.label) ? input.body.trim() : `${target.label} ${input.body.trim()}`;
8352
8367
  const speechText = input.shouldSpeak ? stripScoutAgentSelectorLabels(messageBody) : "";
@@ -8369,7 +8384,7 @@ async function askScoutQuestion(input) {
8369
8384
  createdAt: input.createdAtMs ?? Date.now(),
8370
8385
  metadata: {
8371
8386
  source: "scout-cli",
8372
- relayChannel: input.channel ?? "shared",
8387
+ relayChannel: input.channel ?? (conversation.kind === "direct" ? "dm" : "shared"),
8373
8388
  relayTarget: target.agentId,
8374
8389
  returnAddress
8375
8390
  }
@@ -8389,7 +8404,7 @@ async function askScoutQuestion(input) {
8389
8404
  createdAt: Date.now(),
8390
8405
  metadata: {
8391
8406
  source: "scout-cli",
8392
- relayChannel: input.channel ?? "shared",
8407
+ relayChannel: input.channel ?? (conversation.kind === "direct" ? "dm" : "shared"),
8393
8408
  relayTarget: target.agentId,
8394
8409
  returnAddress
8395
8410
  }
@@ -4498,7 +4498,7 @@ class ClaudeStreamJsonSession {
4498
4498
  sessionId: this.claudeSessionId
4499
4499
  };
4500
4500
  }
4501
- async invoke(prompt, timeoutMs = 5 * 60000) {
4501
+ async invoke(prompt, stallTimeoutMs = 10 * 60000) {
4502
4502
  await this.ensureStarted();
4503
4503
  if (!this.process?.stdin) {
4504
4504
  throw new Error(`Claude stream-json session for ${this.options.agentName} is not running.`);
@@ -4510,19 +4510,13 @@ class ClaudeStreamJsonSession {
4510
4510
  const turn = {
4511
4511
  id: randomUUID(),
4512
4512
  output: [],
4513
- timer: setTimeout(() => {
4514
- this.interrupt().catch(() => {
4515
- return;
4516
- });
4517
- if (this.activeTurn?.id === turn.id) {
4518
- this.activeTurn = null;
4519
- }
4520
- reject(new Error(`Timed out after ${timeoutMs}ms waiting for ${this.options.agentName}.`));
4521
- }, timeoutMs),
4513
+ timer: null,
4514
+ stallMs: stallTimeoutMs,
4522
4515
  resolve: resolve3,
4523
4516
  reject
4524
4517
  };
4525
4518
  this.activeTurn = turn;
4519
+ this.resetTurnWatchdog(turn);
4526
4520
  });
4527
4521
  const payload = JSON.stringify({
4528
4522
  type: "user",
@@ -4546,6 +4540,20 @@ class ClaudeStreamJsonSession {
4546
4540
  this.process.kill("SIGINT");
4547
4541
  }
4548
4542
  }
4543
+ resetTurnWatchdog(turn) {
4544
+ if (turn.timer) {
4545
+ clearTimeout(turn.timer);
4546
+ }
4547
+ turn.timer = setTimeout(() => {
4548
+ this.interrupt().catch(() => {
4549
+ return;
4550
+ });
4551
+ if (this.activeTurn?.id === turn.id) {
4552
+ this.activeTurn = null;
4553
+ }
4554
+ turn.reject(new Error(`${this.options.agentName} stalled \u2014 no stream event in ${turn.stallMs}ms`));
4555
+ }, turn.stallMs);
4556
+ }
4549
4557
  async shutdown(options = {}) {
4550
4558
  const turn = this.activeTurn;
4551
4559
  this.activeTurn = null;
@@ -4680,6 +4688,7 @@ class ClaudeStreamJsonSession {
4680
4688
  if (!turn) {
4681
4689
  return;
4682
4690
  }
4691
+ this.resetTurnWatchdog(turn);
4683
4692
  if (event.type === "assistant") {
4684
4693
  const content = event.message?.content ?? event.content ?? [];
4685
4694
  for (const part of content) {
@@ -3941,7 +3941,7 @@ class ClaudeStreamJsonSession {
3941
3941
  sessionId: this.claudeSessionId
3942
3942
  };
3943
3943
  }
3944
- async invoke(prompt, timeoutMs = 5 * 60000) {
3944
+ async invoke(prompt, stallTimeoutMs = 10 * 60000) {
3945
3945
  await this.ensureStarted();
3946
3946
  if (!this.process?.stdin) {
3947
3947
  throw new Error(`Claude stream-json session for ${this.options.agentName} is not running.`);
@@ -3953,19 +3953,13 @@ class ClaudeStreamJsonSession {
3953
3953
  const turn = {
3954
3954
  id: randomUUID(),
3955
3955
  output: [],
3956
- timer: setTimeout(() => {
3957
- this.interrupt().catch(() => {
3958
- return;
3959
- });
3960
- if (this.activeTurn?.id === turn.id) {
3961
- this.activeTurn = null;
3962
- }
3963
- reject(new Error(`Timed out after ${timeoutMs}ms waiting for ${this.options.agentName}.`));
3964
- }, timeoutMs),
3956
+ timer: null,
3957
+ stallMs: stallTimeoutMs,
3965
3958
  resolve: resolve3,
3966
3959
  reject
3967
3960
  };
3968
3961
  this.activeTurn = turn;
3962
+ this.resetTurnWatchdog(turn);
3969
3963
  });
3970
3964
  const payload = JSON.stringify({
3971
3965
  type: "user",
@@ -3989,6 +3983,20 @@ class ClaudeStreamJsonSession {
3989
3983
  this.process.kill("SIGINT");
3990
3984
  }
3991
3985
  }
3986
+ resetTurnWatchdog(turn) {
3987
+ if (turn.timer) {
3988
+ clearTimeout(turn.timer);
3989
+ }
3990
+ turn.timer = setTimeout(() => {
3991
+ this.interrupt().catch(() => {
3992
+ return;
3993
+ });
3994
+ if (this.activeTurn?.id === turn.id) {
3995
+ this.activeTurn = null;
3996
+ }
3997
+ turn.reject(new Error(`${this.options.agentName} stalled \u2014 no stream event in ${turn.stallMs}ms`));
3998
+ }, turn.stallMs);
3999
+ }
3992
4000
  async shutdown(options = {}) {
3993
4001
  const turn = this.activeTurn;
3994
4002
  this.activeTurn = null;
@@ -4123,6 +4131,7 @@ class ClaudeStreamJsonSession {
4123
4131
  if (!turn) {
4124
4132
  return;
4125
4133
  }
4134
+ this.resetTurnWatchdog(turn);
4126
4135
  if (event.type === "assistant") {
4127
4136
  const content = event.message?.content ?? event.content ?? [];
4128
4137
  for (const part of content) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openscout/scout",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "description": "Published Scout package that installs the `scout` command",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -23,6 +23,6 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@openscout/runtime": "0.2.42"
26
+ "@openscout/runtime": "0.2.44"
27
27
  }
28
28
  }