@wrongstack/core 0.283.0 → 0.284.0

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 (79) hide show
  1. package/dist/{compactor-BxddyCFu.d.ts → compactor-DQLL4HTo.d.ts} +1 -1
  2. package/dist/{config-DkCbA3Bw.d.ts → config-MRqn1V-u.d.ts} +130 -22
  3. package/dist/coordination/index.d.ts +43 -20
  4. package/dist/coordination/index.js +1744 -912
  5. package/dist/coordination/index.js.map +1 -1
  6. package/dist/{default-config-Buho8yge.d.ts → default-config-B79_gJYv.d.ts} +7 -0
  7. package/dist/defaults/index.d.ts +25 -29
  8. package/dist/defaults/index.js +2546 -7396
  9. package/dist/defaults/index.js.map +1 -1
  10. package/dist/{director-state-B_GPa78Q.d.ts → director-state-CMS_bMs4.d.ts} +2 -0
  11. package/dist/{events-KmxSmvho.d.ts → events-Bgnh43r9.d.ts} +27 -10
  12. package/dist/execution/index.d.ts +15 -16
  13. package/dist/execution/index.js +534 -140
  14. package/dist/execution/index.js.map +1 -1
  15. package/dist/execution/prompt-enhancer.d.ts +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/{global-mailbox-rWVt8YlO.d.ts → global-mailbox-sZwyI6CS.d.ts} +13 -2
  18. package/dist/{goal-store-8owBXJT2.d.ts → goal-store-Datpp-ar.d.ts} +1 -1
  19. package/dist/hq/index.d.ts +35 -9
  20. package/dist/hq/index.js +80 -7
  21. package/dist/hq/index.js.map +1 -1
  22. package/dist/{index-BhCteHAF.d.ts → index--Gm41aBJ.d.ts} +26 -11
  23. package/dist/{index-BEFWNZYs.d.ts → index-CbyuOE5y.d.ts} +5 -1
  24. package/dist/index.d.ts +52 -1017
  25. package/dist/index.js +21053 -27778
  26. package/dist/index.js.map +1 -1
  27. package/dist/infrastructure/index.d.ts +9 -7
  28. package/dist/infrastructure/index.js +7 -2
  29. package/dist/infrastructure/index.js.map +1 -1
  30. package/dist/kernel/index.d.ts +11 -11
  31. package/dist/kernel/index.js.map +1 -1
  32. package/dist/{mcp-servers-BUx9A_AQ.d.ts → mcp-servers-DEV4s6Ks.d.ts} +3 -3
  33. package/dist/models/index.d.ts +4 -4
  34. package/dist/models/index.js +18 -3
  35. package/dist/models/index.js.map +1 -1
  36. package/dist/{agent-subagent-runner-BsuWhB28.d.ts → multi-agent-coordinator-4RCRZKjN.d.ts} +417 -9
  37. package/dist/{null-fleet-bus-D4e9R7Qc.d.ts → null-fleet-bus-CFoNVQEK.d.ts} +53 -12
  38. package/dist/observability/index.d.ts +3 -3
  39. package/dist/{parallel-eternal-engine-iY2uxocj.d.ts → parallel-eternal-engine-HUrtePLd.d.ts} +4 -5
  40. package/dist/{permission-B6YAtNFz.d.ts → permission-ByDKXEcG.d.ts} +1 -1
  41. package/dist/{pipeline-ixSFe5jg.d.ts → pipeline-DGDyIohT.d.ts} +28 -7
  42. package/dist/{provider-model-resolve-DIxKL_T-.d.ts → provider-model-resolve-o2hHLs79.d.ts} +3 -3
  43. package/dist/{provider-runner-oQhDaZmH.d.ts → provider-runner-ChL-kVg6.d.ts} +3 -3
  44. package/dist/{retry-policy-V67lBOJz.d.ts → retry-policy-CQ7KwXJa.d.ts} +2 -2
  45. package/dist/{secret-vault-D7jeyXUQ.d.ts → secret-vault-DxohkUBc.d.ts} +3 -2
  46. package/dist/security/index.d.ts +4 -4
  47. package/dist/security/index.js +232 -2
  48. package/dist/security/index.js.map +1 -1
  49. package/dist/{selector-Bx2HgUkU.d.ts → selector-D8O6B_Rm.d.ts} +1 -1
  50. package/dist/{session-event-bridge-Bkp7ORfc.d.ts → session-event-bridge-D_z_mBwk.d.ts} +3 -3
  51. package/dist/{session-reader-B-Fi9L6I.d.ts → session-reader-7Esxrkpw.d.ts} +1 -1
  52. package/dist/storage/index.d.ts +77 -39
  53. package/dist/storage/index.js +1223 -288
  54. package/dist/storage/index.js.map +1 -1
  55. package/dist/tasking/index.d.ts +124 -0
  56. package/dist/tasking/index.js +492 -0
  57. package/dist/tasking/index.js.map +1 -0
  58. package/dist/{todos-checkpoint-BwCrj4Cb.d.ts → todos-checkpoint-FY7PjmMx.d.ts} +13 -4
  59. package/dist/{tool-LVSLiE1s.d.ts → tool-BNlnIJvo.d.ts} +216 -17
  60. package/dist/{tool-executor-kElSEgO0.d.ts → tool-executor-CckSCM5E.d.ts} +12 -15
  61. package/dist/tools/index.d.ts +2 -2
  62. package/dist/tools/index.js.map +1 -1
  63. package/dist/types/index.d.ts +94 -19
  64. package/dist/types/index.js +76 -12
  65. package/dist/types/index.js.map +1 -1
  66. package/dist/utils/index.d.ts +44 -10
  67. package/dist/utils/index.js +106 -17
  68. package/dist/utils/index.js.map +1 -1
  69. package/dist/{worktree-manager-BjyAW30D.d.ts → worktree-manager-DzwxKE35.d.ts} +1 -1
  70. package/instructions/coordination/subagent-baseline.md +5 -0
  71. package/instructions/llm/autonomy-brain.md +3 -2
  72. package/instructions/system.md +4 -0
  73. package/package.json +10 -3
  74. package/skills/mailbox-bridge/SKILL.md +33 -0
  75. package/dist/multi-agent-coordinator-CrjeTB9i.d.ts +0 -357
  76. package/dist/sdd/index.d.ts +0 -1993
  77. package/dist/sdd/index.js +0 -9500
  78. package/dist/sdd/index.js.map +0 -1
  79. package/dist/spec-TBi3Jr6T.d.ts +0 -78
@@ -1,4 +1,4 @@
1
- import { P as Provider, R as ReasoningRequest, a as ReasoningConfig, M as Message } from '../tool-LVSLiE1s.js';
1
+ import { P as Provider, R as ReasoningRequest, a as ReasoningConfig, M as Message } from '../tool-BNlnIJvo.js';
2
2
 
3
3
  /**
4
4
  * Prompt refinement ("did you mean this?").
@@ -1,10 +1,10 @@
1
- export { j as AfterIterationHook, k as AfterRunHook, l as AfterToolExecutionHook, i as AgentExtension, B as BeforeIterationHook, m as BeforeRunHook, n as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, v as ProviderRunnerFn, t as ProviderRunnerWrapper } from '../index-BhCteHAF.js';
2
- import '../tool-LVSLiE1s.js';
1
+ export { k as AfterIterationHook, l as AfterRunHook, m as AfterToolExecutionHook, j as AgentExtension, B as BeforeIterationHook, n as BeforeRunHook, o as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, w as ProviderRunnerFn, u as ProviderRunnerWrapper } from '../index--Gm41aBJ.js';
2
+ import '../tool-BNlnIJvo.js';
3
3
  import '../logger-B63L5bTg.js';
4
- import '../pipeline-ixSFe5jg.js';
4
+ import '../pipeline-DGDyIohT.js';
5
5
  import '../mailbox-types-BGZWrYTJ.js';
6
- import '../config-DkCbA3Bw.js';
7
- import '../permission-B6YAtNFz.js';
6
+ import '../config-MRqn1V-u.js';
7
+ import '../permission-ByDKXEcG.js';
8
8
  import '../observability-D-HZN_mF.js';
9
- import '../events-KmxSmvho.js';
9
+ import '../events-Bgnh43r9.js';
10
10
  import '../secret-scrubber-3MHDDAtm.js';
@@ -1,5 +1,5 @@
1
1
  import { M as MailboxMessage, a as MailboxAgentStatus, b as Mailbox, c as MailboxSendInput, d as MailboxQuery, e as MailboxAckInput, f as MailboxAckBatchInput, A as AgentRegistrationInput, g as AgentHeartbeatInput, C as ClientRegistrationInput, h as ClientHeartbeatInput, i as ClientStatus, P as PurgeOptions, j as PurgeResult } from './mailbox-types-BGZWrYTJ.js';
2
- import { E as EventBus } from './events-KmxSmvho.js';
2
+ import { E as EventBus } from './events-Bgnh43r9.js';
3
3
 
4
4
  declare const HQ_PROTOCOL_VERSION: 1;
5
5
  type HqProtocolVersion = typeof HQ_PROTOCOL_VERSION;
@@ -230,7 +230,7 @@ interface HqSessionSnapshotPayload {
230
230
  agentCount: number;
231
231
  agents: readonly HqSessionAgentSummary[];
232
232
  }
233
- type HqTranscriptRole = 'user' | 'assistant' | 'tool' | 'system' | 'error';
233
+ type HqTranscriptRole = 'user' | 'assistant' | 'thinking' | 'tool' | 'system' | 'error';
234
234
  /** One rendered conversation turn. Canonical shape shared by client streaming
235
235
  * and server-side JSONL replay so both planes agree. */
236
236
  interface HqTranscriptEntry {
@@ -622,6 +622,14 @@ interface HqPublisherOptions {
622
622
  } | undefined;
623
623
  /** Dormant re-check interval while `resolveEndpoint` yields nothing. Default 5s. */
624
624
  discoveryPollMs?: number;
625
+ /**
626
+ * Diagnostic sink for the one-time consecutive-connect-failure warning.
627
+ * The publisher is otherwise deliberately silent (dormant queueing), which
628
+ * made auth failures invisible: a token the server rejects — e.g. a wrong
629
+ * `WRONGSTACK_HQ_TOKEN` against a remote HQ — looked exactly like "HQ not
630
+ * running". Defaults to a single structured `console.warn` line.
631
+ */
632
+ warn?: (message: string) => void;
625
633
  }
626
634
  interface HqPublishEventOptions {
627
635
  type: HqEventType | (string & {});
@@ -645,6 +653,8 @@ declare class HqPublisher {
645
653
  private queue;
646
654
  private stopped;
647
655
  private reconnectAttempt;
656
+ private connectWarningEmitted;
657
+ private lastAttempt;
648
658
  private reconnectTimer;
649
659
  private commandPollTimer;
650
660
  private lastCommandId;
@@ -705,6 +715,7 @@ declare class HqPublisher {
705
715
  private extractMessageData;
706
716
  private handleCommandBatch;
707
717
  private scheduleReconnect;
718
+ private emitConnectWarning;
708
719
  /**
709
720
  * Dormant re-check while no HQ endpoint is discoverable. Uses a FIXED
710
721
  * interval (not the exponential reconnect backoff): the check is a cheap
@@ -1,4 +1,4 @@
1
- import { E as EventBus } from './events-KmxSmvho.js';
1
+ import { E as EventBus } from './events-Bgnh43r9.js';
2
2
 
3
3
  /**
4
4
  * Long-running autonomous mission. A goal survives across sessions and
@@ -1,10 +1,10 @@
1
- import { $ as HqRedactionPolicy, t as HqEventEnvelope, W as HqPublisher, p as HqClientIdentity, ac as HqSocketFactory, i as HqClientCapability, X as HqPublisherCommandHandler, G as GlobalMailbox, ab as HqSnapshot, _ as HqQueuedCommand, c as HqAlertMessage, aj as HqTranscriptEntry } from '../global-mailbox-rWVt8YlO.js';
2
- export { D as DEFAULT_HQ_REDACTION_POLICY, H as HQ_PROTOCOL_VERSION, a as HqAgentMessagePayload, b as HqAgentStatusPayload, d as HqBrainEventKind, e as HqBrainEventPayload, f as HqBrowserEventMessage, g as HqBrowserMessage, h as HqBrowserSnapshotMessage, j as HqClientCommandAckMessage, k as HqClientCommandPollMessage, l as HqClientEventMessage, m as HqClientHeartbeatPayload, n as HqClientHelloMessage, o as HqClientHelloPayload, q as HqClientKind, r as HqClientMessage, s as HqClientRecord, u as HqEventPayloadResult, v as HqEventType, w as HqFleetEventPayload, x as HqFleetSnapshotPayload, y as HqFleetSummary, z as HqGitSnapshotPayload, A as HqMachineRecord, B as HqMailboxAgentStatus, C as HqMailboxAgentSummary, E as HqMailboxEventAction, F as HqMailboxEventPayload, I as HqMailboxMappingOptions, J as HqMailboxMessageSummary, K as HqMailboxMessageType, L as HqMailboxPriority, M as HqMailboxSnapshotOptions, N as HqMailboxSnapshotPayload, O as HqMailboxSummary, P as HqParseResult, Q as HqPathPolicy, R as HqProjectIdentity, S as HqProjectRecord, T as HqProjectStatus, U as HqProtocolVersion, V as HqPublishEventOptions, Y as HqPublisherCommandResult, Z as HqPublisherOptions, a0 as HqServerCommandBatchMessage, a1 as HqServerMessage, a2 as HqSessionAgentLiveStatus, a3 as HqSessionAgentSummary, a4 as HqSessionEndedPayload, a5 as HqSessionLiveStatus, a6 as HqSessionSnapshotPayload, a7 as HqSessionStartedPayload, a8 as HqSessionStatus, a9 as HqSessionStatusPayload, aa as HqSessionSummary, ad as HqSocketLike, ae as HqSubagentSummary, af as HqToolArgsPolicy, ag as HqToolCompletedPayload, ah as HqToolStartedPayload, ai as HqTranscriptAppendPayload, ak as HqTranscriptRole, al as HqUsagePayload, am as HqWelcomePayload, an as HqWorklistCounts, ao as HqWorklistSnapshotPayload, ap as HqWorkspaceKind, aq as HqWorktreeEventKind, ar as HqWorktreeEventPayload, as as createHqEventEnvelope, at as createMailboxEventPayload, au as createMailboxSnapshotPayload, av as createMailboxSnapshotPayloadFromMailbox, aw as mapMailboxAgentToHqSummary, ax as mapMailboxMessageToHqSummary, ay as parseHqEventPayload, az as parseHqFrame } from '../global-mailbox-rWVt8YlO.js';
3
- import { E as EventBus, T as TrackedAgentSnapshot } from '../events-KmxSmvho.js';
4
- import { K as HqClientConfig } from '../config-DkCbA3Bw.js';
1
+ import { $ as HqRedactionPolicy, t as HqEventEnvelope, W as HqPublisher, p as HqClientIdentity, ac as HqSocketFactory, i as HqClientCapability, X as HqPublisherCommandHandler, G as GlobalMailbox, ab as HqSnapshot, _ as HqQueuedCommand, c as HqAlertMessage, aj as HqTranscriptEntry } from '../global-mailbox-sZwyI6CS.js';
2
+ export { D as DEFAULT_HQ_REDACTION_POLICY, H as HQ_PROTOCOL_VERSION, a as HqAgentMessagePayload, b as HqAgentStatusPayload, d as HqBrainEventKind, e as HqBrainEventPayload, f as HqBrowserEventMessage, g as HqBrowserMessage, h as HqBrowserSnapshotMessage, j as HqClientCommandAckMessage, k as HqClientCommandPollMessage, l as HqClientEventMessage, m as HqClientHeartbeatPayload, n as HqClientHelloMessage, o as HqClientHelloPayload, q as HqClientKind, r as HqClientMessage, s as HqClientRecord, u as HqEventPayloadResult, v as HqEventType, w as HqFleetEventPayload, x as HqFleetSnapshotPayload, y as HqFleetSummary, z as HqGitSnapshotPayload, A as HqMachineRecord, B as HqMailboxAgentStatus, C as HqMailboxAgentSummary, E as HqMailboxEventAction, F as HqMailboxEventPayload, I as HqMailboxMappingOptions, J as HqMailboxMessageSummary, K as HqMailboxMessageType, L as HqMailboxPriority, M as HqMailboxSnapshotOptions, N as HqMailboxSnapshotPayload, O as HqMailboxSummary, P as HqParseResult, Q as HqPathPolicy, R as HqProjectIdentity, S as HqProjectRecord, T as HqProjectStatus, U as HqProtocolVersion, V as HqPublishEventOptions, Y as HqPublisherCommandResult, Z as HqPublisherOptions, a0 as HqServerCommandBatchMessage, a1 as HqServerMessage, a2 as HqSessionAgentLiveStatus, a3 as HqSessionAgentSummary, a4 as HqSessionEndedPayload, a5 as HqSessionLiveStatus, a6 as HqSessionSnapshotPayload, a7 as HqSessionStartedPayload, a8 as HqSessionStatus, a9 as HqSessionStatusPayload, aa as HqSessionSummary, ad as HqSocketLike, ae as HqSubagentSummary, af as HqToolArgsPolicy, ag as HqToolCompletedPayload, ah as HqToolStartedPayload, ai as HqTranscriptAppendPayload, ak as HqTranscriptRole, al as HqUsagePayload, am as HqWelcomePayload, an as HqWorklistCounts, ao as HqWorklistSnapshotPayload, ap as HqWorkspaceKind, aq as HqWorktreeEventKind, ar as HqWorktreeEventPayload, as as createHqEventEnvelope, at as createMailboxEventPayload, au as createMailboxSnapshotPayload, av as createMailboxSnapshotPayloadFromMailbox, aw as mapMailboxAgentToHqSummary, ax as mapMailboxMessageToHqSummary, ay as parseHqEventPayload, az as parseHqFrame } from '../global-mailbox-sZwyI6CS.js';
3
+ import { E as EventBus, T as TrackedAgentSnapshot } from '../events-Bgnh43r9.js';
4
+ import { V as HqClientConfig } from '../config-MRqn1V-u.js';
5
5
  import '../mailbox-types-BGZWrYTJ.js';
6
- import '../tool-LVSLiE1s.js';
7
- import '../permission-B6YAtNFz.js';
6
+ import '../tool-BNlnIJvo.js';
7
+ import '../permission-ByDKXEcG.js';
8
8
 
9
9
  interface HqRedactOptions {
10
10
  policy?: Partial<HqRedactionPolicy>;
@@ -607,7 +607,7 @@ declare function createHqPersistence(dataDir: string): HqPersistence;
607
607
  */
608
608
 
609
609
  /** HQ_COMMAND_TYPES — the full set of recognized command `type` strings. */
610
- declare const HQ_COMMAND_TYPES: readonly ["steer", "abort", "spawn", "broadcast", "run-command"];
610
+ declare const HQ_COMMAND_TYPES: readonly ["steer", "btw", "queue", "abort", "spawn", "broadcast", "run-command"];
611
611
  type HqCommandType = (typeof HQ_COMMAND_TYPES)[number];
612
612
  /** Inject a steer text into a target agent's conversation. */
613
613
  interface HqSteerCommand {
@@ -618,6 +618,32 @@ interface HqSteerCommand {
618
618
  body: string;
619
619
  priority?: 'low' | 'normal' | 'high';
620
620
  }
621
+ /**
622
+ * Post a non-urgent FYI (`btw`) into a target agent's mailbox. Unlike a steer,
623
+ * a btw is absorbed as context — it does not demand the agent change course.
624
+ * Same wire shape as steer; only the emitted mailbox `type` differs.
625
+ */
626
+ interface HqBtwCommand {
627
+ type: 'btw';
628
+ /** Target agent address: a unique id (`leader@<tag>`), an alias (`leader`), or `*` for all. */
629
+ to: string;
630
+ subject: string;
631
+ body: string;
632
+ priority?: 'low' | 'normal' | 'high';
633
+ }
634
+ /**
635
+ * Queue a prompt/note (`queue`) for a target agent. Delivered as a plain
636
+ * `note` mailbox message the agent picks up before its next step — used when
637
+ * the prompt should wait its turn rather than steer the current operation.
638
+ */
639
+ interface HqQueueCommand {
640
+ type: 'queue';
641
+ /** Target agent address: a unique id (`leader@<tag>`), an alias (`leader`), or `*` for all. */
642
+ to: string;
643
+ subject: string;
644
+ body: string;
645
+ priority?: 'low' | 'normal' | 'high';
646
+ }
621
647
  /** Abort a running agent run or fleet. */
622
648
  interface HqAbortCommand {
623
649
  type: 'abort';
@@ -646,7 +672,7 @@ interface HqRunCommandCommand {
646
672
  /** Optional working directory (defaults to the agent's project root). */
647
673
  cwd?: string;
648
674
  }
649
- type HqCommand = HqSteerCommand | HqAbortCommand | HqSpawnCommand | HqBroadcastCommand | HqRunCommandCommand;
675
+ type HqCommand = HqSteerCommand | HqBtwCommand | HqQueueCommand | HqAbortCommand | HqSpawnCommand | HqBroadcastCommand | HqRunCommandCommand;
650
676
  /**
651
677
  * Validate that an inbound `HqQueuedCommand` has a recognized `type` and a
652
678
  * minimally well-formed payload. Returns the narrowed command on success, or
@@ -787,4 +813,4 @@ declare function mergeToolResults(flat: readonly HqTranscriptEntry[]): HqTranscr
787
813
  */
788
814
  declare function buildTranscriptFromEvents(events: Iterable<Record<string, unknown>>): HqTranscriptEntry[];
789
815
 
790
- export { type AgentMonitorEventBridgeOptions, type BrainTelemetryBridgeOptions, type CostTelemetryBridgeOptions, type CreateGlobalMailboxOptions, type CreateHqPublisherOptions, type EnsureHqFirstRunAuthResult, type FleetTelemetryBridgeOptions, HQ_AUTH_FILE_VERSION, HQ_COMMAND_TYPES, type HqAbortCommand, type HqAgentEventPublisher, type HqAlert, HqAlertEngine, HqAlertMessage, type HqAlertRuleConfig, type HqAlertSeverity, type HqAuthFile, type HqBroadcastCommand, type HqBrowserToken, HqClientCapability, HqClientIdentity, type HqCommand, type HqCommandAuditEntry, HqCommandAuditLog, type HqCommandType, HqEventEnvelope, HqEventLog, type HqEventLogOptions, type HqPersistence, HqPublisher, HqPublisherCommandHandler, type HqPublisherEnvConfig, HqQueuedCommand, type HqRedactOptions, HqRedactionPolicy, type HqRedactionResult, type HqRunCommandCommand, type HqRuntimeFile, HqSnapshot, HqSnapshotStore, type HqSnapshotStoreOptions, HqSocketFactory, type HqSpawnCommand, type HqSteerCommand, type HqTimeseriesSample, HqTimeseriesStore, type HqTimeseriesStoreOptions, type HqToken, HqTranscriptEntry, type SessionTelemetryBridgeOptions, type ToolTelemetryBridgeOptions, type WorktreeTelemetryBridgeOptions, buildTranscriptFromEvents, createGlobalMailbox, createHqPersistence, createHqPublisherFromEnv, defaultHqDataDir, discoverLocalHqEndpoint, emptyHqAuthFile, ensureHqFirstRunAuthFile, hqAuthFilePath, hqRuntimeFilePath, mapSessionEventToEntries, mergeToolResults, mintHqBrowserToken, mintHqToken, mutateHqAuthFile, readHqAuthFile, readHqRuntimeFileSync, redactHqEvent, redactHqValue, resolveHqConfig, resolveHqConfigFromEnv, resolveHqDataDir, scrubAndTruncateHqPreview, startAgentMonitorEventBridge, startBrainTelemetryBridge, startCostTelemetryBridge, startFleetTelemetryBridge, startSessionTelemetryBridge, startToolTelemetryBridge, startWorktreeTelemetryBridge, summarizeHqToolArgs, toAlertMessage, tokenHasCapability, validateHqCommand, watchHqAuthFile, writeHqAuthFile, writeHqRuntimeFile };
816
+ export { type AgentMonitorEventBridgeOptions, type BrainTelemetryBridgeOptions, type CostTelemetryBridgeOptions, type CreateGlobalMailboxOptions, type CreateHqPublisherOptions, type EnsureHqFirstRunAuthResult, type FleetTelemetryBridgeOptions, HQ_AUTH_FILE_VERSION, HQ_COMMAND_TYPES, type HqAbortCommand, type HqAgentEventPublisher, type HqAlert, HqAlertEngine, HqAlertMessage, type HqAlertRuleConfig, type HqAlertSeverity, type HqAuthFile, type HqBroadcastCommand, type HqBrowserToken, type HqBtwCommand, HqClientCapability, HqClientIdentity, type HqCommand, type HqCommandAuditEntry, HqCommandAuditLog, type HqCommandType, HqEventEnvelope, HqEventLog, type HqEventLogOptions, type HqPersistence, HqPublisher, HqPublisherCommandHandler, type HqPublisherEnvConfig, type HqQueueCommand, HqQueuedCommand, type HqRedactOptions, HqRedactionPolicy, type HqRedactionResult, type HqRunCommandCommand, type HqRuntimeFile, HqSnapshot, HqSnapshotStore, type HqSnapshotStoreOptions, HqSocketFactory, type HqSpawnCommand, type HqSteerCommand, type HqTimeseriesSample, HqTimeseriesStore, type HqTimeseriesStoreOptions, type HqToken, HqTranscriptEntry, type SessionTelemetryBridgeOptions, type ToolTelemetryBridgeOptions, type WorktreeTelemetryBridgeOptions, buildTranscriptFromEvents, createGlobalMailbox, createHqPersistence, createHqPublisherFromEnv, defaultHqDataDir, discoverLocalHqEndpoint, emptyHqAuthFile, ensureHqFirstRunAuthFile, hqAuthFilePath, hqRuntimeFilePath, mapSessionEventToEntries, mergeToolResults, mintHqBrowserToken, mintHqToken, mutateHqAuthFile, readHqAuthFile, readHqRuntimeFileSync, redactHqEvent, redactHqValue, resolveHqConfig, resolveHqConfigFromEnv, resolveHqDataDir, scrubAndTruncateHqPreview, startAgentMonitorEventBridge, startBrainTelemetryBridge, startCostTelemetryBridge, startFleetTelemetryBridge, startSessionTelemetryBridge, startToolTelemetryBridge, startWorktreeTelemetryBridge, summarizeHqToolArgs, toAlertMessage, tokenHasCapability, validateHqCommand, watchHqAuthFile, writeHqAuthFile, writeHqRuntimeFile };
package/dist/hq/index.js CHANGED
@@ -191,7 +191,14 @@ function isHqSessionSnapshotPayload(x) {
191
191
  }
192
192
  return true;
193
193
  }
194
- var HQ_TRANSCRIPT_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "error"]);
194
+ var HQ_TRANSCRIPT_ROLES = /* @__PURE__ */ new Set([
195
+ "user",
196
+ "assistant",
197
+ "thinking",
198
+ "tool",
199
+ "system",
200
+ "error"
201
+ ]);
195
202
  function isHqTranscriptEntry(x) {
196
203
  if (typeof x !== "object" || x === null) return false;
197
204
  const v = x;
@@ -817,6 +824,7 @@ function createMailboxEventPayload(input) {
817
824
  };
818
825
  }
819
826
  var OPEN_STATE = 1;
827
+ var CONNECT_WARN_AFTER_FAILURES = 5;
820
828
  var DEFAULT_RECONNECT_BASE_MS = 1e3;
821
829
  var DEFAULT_RECONNECT_MAX_MS = 3e4;
822
830
  var DEFAULT_DISCOVERY_POLL_MS = 5e3;
@@ -884,6 +892,8 @@ var HqPublisher = class {
884
892
  queue = [];
885
893
  stopped = false;
886
894
  reconnectAttempt = 0;
895
+ connectWarningEmitted = false;
896
+ lastAttempt = null;
887
897
  reconnectTimer = null;
888
898
  commandPollTimer = null;
889
899
  lastCommandId;
@@ -901,6 +911,7 @@ var HqPublisher = class {
901
911
  url = endpoint.url;
902
912
  token = endpoint.token ?? token;
903
913
  }
914
+ this.lastAttempt = { url, hadToken: token !== void 0 };
904
915
  let socket;
905
916
  try {
906
917
  socket = this.socketFactory(toClientUrl(url, token), {
@@ -1162,12 +1173,32 @@ var HqPublisher = class {
1162
1173
  if (this.stopped || !this.reconnect || this.reconnectTimer !== null) return;
1163
1174
  const delay = Math.min(this.reconnectMaxMs, this.reconnectBaseMs * 2 ** this.reconnectAttempt);
1164
1175
  this.reconnectAttempt += 1;
1176
+ if (!this.connectWarningEmitted && this.reconnectAttempt >= CONNECT_WARN_AFTER_FAILURES) {
1177
+ this.connectWarningEmitted = true;
1178
+ this.emitConnectWarning();
1179
+ }
1165
1180
  this.reconnectTimer = setTimeout(() => {
1166
1181
  this.reconnectTimer = null;
1167
1182
  this.connect();
1168
1183
  }, delay);
1169
1184
  this.reconnectTimer.unref?.();
1170
1185
  }
1186
+ emitConnectWarning() {
1187
+ const attempt = this.lastAttempt;
1188
+ const message = `WrongStack HQ publisher: ${this.reconnectAttempt} consecutive connection failures${attempt !== null ? ` to ${attempt.url} (client token ${attempt.hadToken ? "present" : "absent"})` : ""}. Either the HQ server is unreachable or it rejected the token (401). If HQ runs in client-token mode, verify WRONGSTACK_HQ_TOKEN / auth.json. Retries continue with backoff.`;
1189
+ const warn = this.options.warn ?? ((msg) => console.warn(
1190
+ JSON.stringify({
1191
+ level: "warn",
1192
+ event: "hq.publisher.connect_failed",
1193
+ message: msg,
1194
+ timestamp: this.now()
1195
+ })
1196
+ ));
1197
+ try {
1198
+ warn(message);
1199
+ } catch {
1200
+ }
1201
+ }
1171
1202
  /**
1172
1203
  * Dormant re-check while no HQ endpoint is discoverable. Uses a FIXED
1173
1204
  * interval (not the exponential reconnect backoff): the check is a cheap
@@ -2521,6 +2552,14 @@ function readFirstClientTokenFromAuthFile(dataDir) {
2521
2552
  return void 0;
2522
2553
  }
2523
2554
  }
2555
+ function isLoopbackHqUrl(url) {
2556
+ try {
2557
+ const host = new URL(url).hostname.toLowerCase();
2558
+ return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]" || host === "0.0.0.0";
2559
+ } catch {
2560
+ return false;
2561
+ }
2562
+ }
2524
2563
  function resolveHqConfigFromEnv(env = process.env) {
2525
2564
  return resolveHqConfig({ env });
2526
2565
  }
@@ -2534,9 +2573,11 @@ function resolveHqConfig(options = {}) {
2534
2573
  const envEnabledRaw = env["WRONGSTACK_HQ_ENABLED"]?.trim();
2535
2574
  const enabled = envEnabledRaw !== void 0 && envEnabledRaw.length > 0 ? envEnabledRaw !== "0" : fileConfig?.enabled;
2536
2575
  const dataDir = resolveHqDataDir(fileConfig?.dataDir, env);
2537
- const token = envToken || configToken || readFirstClientTokenFromAuthFile(dataDir);
2576
+ const explicitToken = envToken || configToken;
2538
2577
  const runtimeUrl = readHqRuntimeFileSync(dataDir)?.url.trim();
2539
2578
  const url = envUrl || configUrl;
2579
+ const localFallbackToken = !url || isLoopbackHqUrl(url) ? readFirstClientTokenFromAuthFile(dataDir) : void 0;
2580
+ const token = explicitToken || localFallbackToken;
2540
2581
  if (!url) {
2541
2582
  if (enabled === false) return void 0;
2542
2583
  return {
@@ -2616,7 +2657,7 @@ function startAgentMonitorEventBridge(opts) {
2616
2657
  seq.current += 1;
2617
2658
  return seq.current;
2618
2659
  }
2619
- function buildEnvelope(type, payload) {
2660
+ function buildEnvelope(type, payload, sessionId) {
2620
2661
  return createHqEventEnvelope({
2621
2662
  id: `${Date.now().toString(36)}-${nextSeq()}`,
2622
2663
  type,
@@ -2624,7 +2665,11 @@ function startAgentMonitorEventBridge(opts) {
2624
2665
  clientId,
2625
2666
  projectId,
2626
2667
  seq: nextSeq(),
2627
- payload
2668
+ payload,
2669
+ // Carry the parent session id so HQ can scope per-agent transcripts by
2670
+ // (sessionId, subagentId) — without it, two sessions whose leaders both
2671
+ // use the default id 'leader' would collide into one shared ring.
2672
+ ...sessionId !== void 0 ? { sessionId } : {}
2628
2673
  });
2629
2674
  }
2630
2675
  const offMessage = events.on("agent.timeline.message", (payload) => {
@@ -2639,7 +2684,7 @@ function startAgentMonitorEventBridge(opts) {
2639
2684
  };
2640
2685
  if (payload.toolName !== void 0) msgPayload.toolName = payload.toolName;
2641
2686
  if (payload.costUsd !== void 0) msgPayload.costUsd = payload.costUsd;
2642
- publish(buildEnvelope("agent.message", msgPayload));
2687
+ publish(buildEnvelope("agent.message", msgPayload, payload.sessionId));
2643
2688
  });
2644
2689
  const offStatus = events.on("agent.status_changed", (payload) => {
2645
2690
  if (!publish) return;
@@ -2702,9 +2747,15 @@ function mapSessionEventToEntries(ev) {
2702
2747
  }
2703
2748
  case "llm_response": {
2704
2749
  const out = [];
2705
- const t = blocksToText(ev["content"]);
2706
- if (t.trim()) out.push(make("assistant", t));
2707
2750
  const content = ev["content"];
2751
+ if (Array.isArray(content)) {
2752
+ const thinking = content.filter(
2753
+ (b) => !!b && typeof b === "object" && b.type === "thinking" && typeof b.thinking === "string"
2754
+ ).map((b) => b.thinking).join("\n");
2755
+ if (thinking.trim()) out.push(make("thinking", thinking));
2756
+ }
2757
+ const t = blocksToText(content);
2758
+ if (t.trim()) out.push(make("assistant", t));
2708
2759
  if (Array.isArray(content)) {
2709
2760
  for (const b of content) {
2710
2761
  if (b && typeof b === "object" && b.type === "tool_use") {
@@ -3542,6 +3593,8 @@ function createHqPersistence(dataDir) {
3542
3593
  // src/hq/commands.ts
3543
3594
  var HQ_COMMAND_TYPES = [
3544
3595
  "steer",
3596
+ "btw",
3597
+ "queue",
3545
3598
  "abort",
3546
3599
  "spawn",
3547
3600
  "broadcast",
@@ -3563,6 +3616,26 @@ function validateHqCommand(queued) {
3563
3616
  }
3564
3617
  return result;
3565
3618
  }
3619
+ case "btw": {
3620
+ if (typeof p["to"] !== "string" || typeof p["subject"] !== "string" || typeof p["body"] !== "string") {
3621
+ return null;
3622
+ }
3623
+ const result = { type: "btw", to: p["to"], subject: p["subject"], body: p["body"] };
3624
+ if (p["priority"] === "low" || p["priority"] === "normal" || p["priority"] === "high") {
3625
+ result.priority = p["priority"];
3626
+ }
3627
+ return result;
3628
+ }
3629
+ case "queue": {
3630
+ if (typeof p["to"] !== "string" || typeof p["subject"] !== "string" || typeof p["body"] !== "string") {
3631
+ return null;
3632
+ }
3633
+ const result = { type: "queue", to: p["to"], subject: p["subject"], body: p["body"] };
3634
+ if (p["priority"] === "low" || p["priority"] === "normal" || p["priority"] === "high") {
3635
+ result.priority = p["priority"];
3636
+ }
3637
+ return result;
3638
+ }
3566
3639
  case "abort":
3567
3640
  if (typeof p["target"] !== "string") return null;
3568
3641
  return { type: "abort", target: p["target"] };