@wrongstack/core 0.283.1 → 0.284.1
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/{compactor-BxddyCFu.d.ts → compactor-DQLL4HTo.d.ts} +1 -1
- package/dist/{config-DkCbA3Bw.d.ts → config-MRqn1V-u.d.ts} +130 -22
- package/dist/coordination/index.d.ts +43 -20
- package/dist/coordination/index.js +1744 -912
- package/dist/coordination/index.js.map +1 -1
- package/dist/{default-config-Buho8yge.d.ts → default-config-B79_gJYv.d.ts} +7 -0
- package/dist/defaults/index.d.ts +25 -29
- package/dist/defaults/index.js +2546 -7396
- package/dist/defaults/index.js.map +1 -1
- package/dist/{director-state-B_GPa78Q.d.ts → director-state-CMS_bMs4.d.ts} +2 -0
- package/dist/{events-KmxSmvho.d.ts → events-Bgnh43r9.d.ts} +27 -10
- package/dist/execution/index.d.ts +15 -16
- package/dist/execution/index.js +534 -140
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/{global-mailbox-rWVt8YlO.d.ts → global-mailbox-sZwyI6CS.d.ts} +13 -2
- package/dist/{goal-store-8owBXJT2.d.ts → goal-store-Datpp-ar.d.ts} +1 -1
- package/dist/hq/index.d.ts +6 -6
- package/dist/hq/index.js +58 -7
- package/dist/hq/index.js.map +1 -1
- package/dist/{index-BhCteHAF.d.ts → index--Gm41aBJ.d.ts} +26 -11
- package/dist/{index-BEFWNZYs.d.ts → index-CbyuOE5y.d.ts} +5 -1
- package/dist/index.d.ts +50 -1015
- package/dist/index.js +21028 -27775
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +9 -7
- package/dist/infrastructure/index.js +7 -2
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +11 -11
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-BUx9A_AQ.d.ts → mcp-servers-DEV4s6Ks.d.ts} +3 -3
- package/dist/models/index.d.ts +4 -4
- package/dist/models/index.js +18 -3
- package/dist/models/index.js.map +1 -1
- package/dist/{agent-subagent-runner-BsuWhB28.d.ts → multi-agent-coordinator-4RCRZKjN.d.ts} +417 -9
- package/dist/{null-fleet-bus-D4e9R7Qc.d.ts → null-fleet-bus-CFoNVQEK.d.ts} +53 -12
- package/dist/observability/index.d.ts +3 -3
- package/dist/{parallel-eternal-engine-iY2uxocj.d.ts → parallel-eternal-engine-HUrtePLd.d.ts} +4 -5
- package/dist/{permission-B6YAtNFz.d.ts → permission-ByDKXEcG.d.ts} +1 -1
- package/dist/{pipeline-ixSFe5jg.d.ts → pipeline-DGDyIohT.d.ts} +28 -7
- package/dist/{provider-model-resolve-DIxKL_T-.d.ts → provider-model-resolve-o2hHLs79.d.ts} +3 -3
- package/dist/{provider-runner-oQhDaZmH.d.ts → provider-runner-ChL-kVg6.d.ts} +3 -3
- package/dist/{retry-policy-V67lBOJz.d.ts → retry-policy-CQ7KwXJa.d.ts} +2 -2
- package/dist/{secret-vault-D7jeyXUQ.d.ts → secret-vault-DxohkUBc.d.ts} +3 -2
- package/dist/security/index.d.ts +4 -4
- package/dist/security/index.js +232 -2
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-Bx2HgUkU.d.ts → selector-D8O6B_Rm.d.ts} +1 -1
- package/dist/{session-event-bridge-Bkp7ORfc.d.ts → session-event-bridge-D_z_mBwk.d.ts} +3 -3
- package/dist/{session-reader-B-Fi9L6I.d.ts → session-reader-7Esxrkpw.d.ts} +1 -1
- package/dist/storage/index.d.ts +77 -39
- package/dist/storage/index.js +1223 -288
- package/dist/storage/index.js.map +1 -1
- package/dist/tasking/index.d.ts +124 -0
- package/dist/tasking/index.js +492 -0
- package/dist/tasking/index.js.map +1 -0
- package/dist/{todos-checkpoint-BwCrj4Cb.d.ts → todos-checkpoint-FY7PjmMx.d.ts} +13 -4
- package/dist/{tool-LVSLiE1s.d.ts → tool-BNlnIJvo.d.ts} +216 -17
- package/dist/{tool-executor-kElSEgO0.d.ts → tool-executor-CckSCM5E.d.ts} +12 -15
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +94 -19
- package/dist/types/index.js +76 -12
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +44 -10
- package/dist/utils/index.js +106 -17
- package/dist/utils/index.js.map +1 -1
- package/dist/{worktree-manager-BjyAW30D.d.ts → worktree-manager-DzwxKE35.d.ts} +1 -1
- package/instructions/coordination/subagent-baseline.md +5 -0
- package/instructions/llm/autonomy-brain.md +3 -2
- package/instructions/system.md +4 -0
- package/package.json +10 -3
- package/dist/multi-agent-coordinator-CrjeTB9i.d.ts +0 -357
- package/dist/sdd/index.d.ts +0 -1993
- package/dist/sdd/index.js +0 -9500
- package/dist/sdd/index.js.map +0 -1
- 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-
|
|
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 {
|
|
2
|
-
import '../tool-
|
|
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-
|
|
4
|
+
import '../pipeline-DGDyIohT.js';
|
|
5
5
|
import '../mailbox-types-BGZWrYTJ.js';
|
|
6
|
-
import '../config-
|
|
7
|
-
import '../permission-
|
|
6
|
+
import '../config-MRqn1V-u.js';
|
|
7
|
+
import '../permission-ByDKXEcG.js';
|
|
8
8
|
import '../observability-D-HZN_mF.js';
|
|
9
|
-
import '../events-
|
|
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-
|
|
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
|
package/dist/hq/index.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
3
|
-
import { E as EventBus, T as TrackedAgentSnapshot } from '../events-
|
|
4
|
-
import {
|
|
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-
|
|
7
|
-
import '../permission-
|
|
6
|
+
import '../tool-BNlnIJvo.js';
|
|
7
|
+
import '../permission-ByDKXEcG.js';
|
|
8
8
|
|
|
9
9
|
interface HqRedactOptions {
|
|
10
10
|
policy?: Partial<HqRedactionPolicy>;
|
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([
|
|
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
|
|
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") {
|