agent-relay 8.3.6 → 8.3.7
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,7 +1,8 @@
|
|
|
1
1
|
export interface RelaycastTelemetryOptions {
|
|
2
|
-
|
|
2
|
+
originActor?: string;
|
|
3
3
|
agentRelayDistinctId?: string;
|
|
4
4
|
}
|
|
5
|
+
export declare function resolveOriginActor(env?: NodeJS.ProcessEnv): string | undefined;
|
|
5
6
|
export declare function relaycastTelemetryOptions(env?: NodeJS.ProcessEnv): RelaycastTelemetryOptions;
|
|
6
7
|
export declare function relaycastWorkspaceTelemetryOptions(env?: NodeJS.ProcessEnv): Pick<RelaycastTelemetryOptions, 'agentRelayDistinctId'>;
|
|
7
8
|
export declare function withRelaycastTelemetry<T extends Record<string, unknown>>(options: T, env?: NodeJS.ProcessEnv): T & RelaycastTelemetryOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relaycast-telemetry.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/relaycast-telemetry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,
|
|
1
|
+
{"version":3,"file":"relaycast-telemetry.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/relaycast-telemetry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAwBD,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,GAAG,SAAS,CAO3F;AAED,wBAAgB,yBAAyB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,yBAAyB,CAQzG;AAED,wBAAgB,kCAAkC,CAChD,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,IAAI,CAAC,yBAAyB,EAAE,sBAAsB,CAAC,CAGzD;AAED,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtE,OAAO,EAAE,CAAC,EACV,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,CAAC,GAAG,yBAAyB,CAE/B"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit `origin_actor` path (`{app}/{type}[/{name}]`), set by the broker for
|
|
3
|
+
* each spawned agent (`agent-relay-cli/agent/<harness>`). See
|
|
4
|
+
* cloud/plans/origin-actor.md.
|
|
5
|
+
*/
|
|
6
|
+
const ORIGIN_ACTOR_ENV = 'AGENT_RELAY_ORIGIN_ACTOR';
|
|
7
|
+
/**
|
|
8
|
+
* Fallback: synthesize a path from the orchestrator harness when no explicit
|
|
9
|
+
* origin_actor is set (e.g. a standalone MCP running under a harness).
|
|
10
|
+
*/
|
|
1
11
|
const HARNESS_ENV_KEYS = [
|
|
2
12
|
'AGENT_RELAY_HARNESS',
|
|
3
13
|
'AGENT_RELAY_ORCHESTRATOR_HARNESS',
|
|
@@ -8,11 +18,18 @@ function nonEmpty(value) {
|
|
|
8
18
|
const trimmed = value?.trim();
|
|
9
19
|
return trimmed ? trimmed : undefined;
|
|
10
20
|
}
|
|
11
|
-
export function
|
|
21
|
+
export function resolveOriginActor(env = process.env) {
|
|
22
|
+
const explicit = nonEmpty(env[ORIGIN_ACTOR_ENV]);
|
|
23
|
+
if (explicit)
|
|
24
|
+
return explicit;
|
|
12
25
|
const harness = HARNESS_ENV_KEYS.map((key) => nonEmpty(env[key])).find((value) => Boolean(value));
|
|
26
|
+
return harness ? `agent-relay-cli/agent/${harness}` : undefined;
|
|
27
|
+
}
|
|
28
|
+
export function relaycastTelemetryOptions(env = process.env) {
|
|
29
|
+
const originActor = resolveOriginActor(env);
|
|
13
30
|
const agentRelayDistinctId = nonEmpty(env.AGENT_RELAY_DISTINCT_ID);
|
|
14
31
|
return {
|
|
15
|
-
...(
|
|
32
|
+
...(originActor ? { originActor } : {}),
|
|
16
33
|
...(agentRelayDistinctId ? { agentRelayDistinctId } : {}),
|
|
17
34
|
};
|
|
18
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relaycast-telemetry.js","sourceRoot":"","sources":["../../../src/cli/lib/relaycast-telemetry.ts"],"names":[],"mappings":"AAKA,MAAM,gBAAgB,GAAG;IACvB,qBAAqB;IACrB,kCAAkC;IAClC,mBAAmB;IACnB,qBAAqB;CACb,CAAC;AAEX,SAAS,QAAQ,CAAC,KAAyB;IACzC,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"relaycast-telemetry.js","sourceRoot":"","sources":["../../../src/cli/lib/relaycast-telemetry.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD;;;GAGG;AACH,MAAM,gBAAgB,GAAG;IACvB,qBAAqB;IACrB,kCAAkC;IAClC,mBAAmB;IACnB,qBAAqB;CACb,CAAC;AAEX,SAAS,QAAQ,CAAC,KAAyB;IACzC,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACrE,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACjD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAmB,EAAE,CAChG,OAAO,CAAC,KAAK,CAAC,CACf,CAAC;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC5E,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAEnE,OAAO;QACL,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,EAAE,oBAAoB,EAAE,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAC;IAChE,OAAO,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAU,EACV,MAAyB,OAAO,CAAC,GAAG;IAEpC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,yBAAyB,CAAC,GAAG,CAAC,EAAE,CAAC;AAC3D,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -275,7 +275,7 @@ __export(index_exports, {
|
|
|
275
275
|
module.exports = __toCommonJS(index_exports);
|
|
276
276
|
|
|
277
277
|
// ../../node_modules/@relaycast/sdk/dist/version.js
|
|
278
|
-
var SDK_VERSION = "
|
|
278
|
+
var SDK_VERSION = "3.1.1";
|
|
279
279
|
|
|
280
280
|
// ../../node_modules/@relaycast/types/node_modules/zod/v4/classic/external.js
|
|
281
281
|
var external_exports = {};
|
|
@@ -15313,10 +15313,16 @@ var UnsubscribeEventSchema = external_exports.object({
|
|
|
15313
15313
|
var PingEventSchema = external_exports.object({
|
|
15314
15314
|
type: external_exports.literal("ping")
|
|
15315
15315
|
});
|
|
15316
|
+
var ResyncEventSchema = external_exports.object({
|
|
15317
|
+
type: external_exports.literal("resync"),
|
|
15318
|
+
last_seen_seq: external_exports.number(),
|
|
15319
|
+
since: external_exports.string().optional()
|
|
15320
|
+
});
|
|
15316
15321
|
var ClientEventSchema = external_exports.discriminatedUnion("type", [
|
|
15317
15322
|
SubscribeEventSchema,
|
|
15318
15323
|
UnsubscribeEventSchema,
|
|
15319
|
-
PingEventSchema
|
|
15324
|
+
PingEventSchema,
|
|
15325
|
+
ResyncEventSchema
|
|
15320
15326
|
]);
|
|
15321
15327
|
var ChannelMessagePayloadSchema = CoreMessagePayloadSchema.extend({
|
|
15322
15328
|
attachments: external_exports.array(FileAttachmentSchema)
|
|
@@ -15450,6 +15456,13 @@ var FileUploadedEventSchema = external_exports.object({
|
|
|
15450
15456
|
var PongEventSchema = external_exports.object({
|
|
15451
15457
|
type: external_exports.literal("pong")
|
|
15452
15458
|
});
|
|
15459
|
+
var ResyncAckEventSchema = external_exports.object({
|
|
15460
|
+
type: external_exports.literal("resync_ack"),
|
|
15461
|
+
last_seen_seq: external_exports.number(),
|
|
15462
|
+
current_seq: external_exports.number(),
|
|
15463
|
+
replayed: external_exports.number(),
|
|
15464
|
+
gap_detected: external_exports.boolean()
|
|
15465
|
+
});
|
|
15453
15466
|
var WebhookReceivedEventSchema = external_exports.object({
|
|
15454
15467
|
type: external_exports.literal("webhook.received"),
|
|
15455
15468
|
webhook_id: external_exports.string(),
|
|
@@ -15542,6 +15555,11 @@ var WsPermanentlyDisconnectedEventSchema = external_exports.object({
|
|
|
15542
15555
|
var WsCloseEventSchema = external_exports.object({
|
|
15543
15556
|
type: external_exports.literal("close")
|
|
15544
15557
|
});
|
|
15558
|
+
var WsResyncedEventSchema = external_exports.object({
|
|
15559
|
+
type: external_exports.literal("resynced"),
|
|
15560
|
+
replayed: external_exports.number(),
|
|
15561
|
+
gap_detected: external_exports.boolean()
|
|
15562
|
+
});
|
|
15545
15563
|
var ServerEventSchema = external_exports.discriminatedUnion("type", [
|
|
15546
15564
|
MessageCreatedEventSchema,
|
|
15547
15565
|
MessageUpdatedEventSchema,
|
|
@@ -15576,7 +15594,8 @@ var ServerEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
15576
15594
|
DeliveryDeliveredEventSchema,
|
|
15577
15595
|
DeliveryDeferredEventSchema,
|
|
15578
15596
|
DeliveryFailedEventSchema,
|
|
15579
|
-
PongEventSchema
|
|
15597
|
+
PongEventSchema,
|
|
15598
|
+
ResyncAckEventSchema
|
|
15580
15599
|
]);
|
|
15581
15600
|
var RelaycastMessageEventSchema = external_exports.discriminatedUnion("type", [
|
|
15582
15601
|
MessageCreatedEventSchema,
|
|
@@ -15620,12 +15639,14 @@ var WsClientEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
15620
15639
|
DeliveryDeferredEventSchema,
|
|
15621
15640
|
DeliveryFailedEventSchema,
|
|
15622
15641
|
PongEventSchema,
|
|
15642
|
+
ResyncAckEventSchema,
|
|
15623
15643
|
// Client-only events
|
|
15624
15644
|
WsOpenEventSchema,
|
|
15625
15645
|
WsErrorEventSchema,
|
|
15626
15646
|
WsReconnectingEventSchema,
|
|
15627
15647
|
WsPermanentlyDisconnectedEventSchema,
|
|
15628
|
-
WsCloseEventSchema
|
|
15648
|
+
WsCloseEventSchema,
|
|
15649
|
+
WsResyncedEventSchema
|
|
15629
15650
|
]);
|
|
15630
15651
|
|
|
15631
15652
|
// ../../node_modules/@relaycast/types/dist/api.js
|
|
@@ -15923,22 +15944,22 @@ var SDK_ORIGIN = Object.freeze({
|
|
|
15923
15944
|
client: "@relaycast/sdk",
|
|
15924
15945
|
version: SDK_VERSION
|
|
15925
15946
|
});
|
|
15926
|
-
var
|
|
15947
|
+
var ORIGIN_ACTOR_HEADER = "X-Relaycast-Origin-Actor";
|
|
15927
15948
|
var AGENT_RELAY_DISTINCT_ID_HEADER = "X-Agent-Relay-Distinct-Id";
|
|
15928
15949
|
var AGENT_RELAY_DISTINCT_ID_QUERY = "agent_relay_distinct_id";
|
|
15929
|
-
var
|
|
15950
|
+
var ORIGIN_ACTOR_MAX_LENGTH = 128;
|
|
15930
15951
|
var AGENT_RELAY_DISTINCT_ID_MAX_LENGTH = 128;
|
|
15931
|
-
var
|
|
15952
|
+
var ORIGIN_ACTOR_ALLOWED = /^[a-z0-9 ._\-/():=;,+@]+$/i;
|
|
15932
15953
|
var AGENT_RELAY_DISTINCT_ID_ALLOWED = /^[a-z0-9._:-]+$/i;
|
|
15933
|
-
function
|
|
15954
|
+
function sanitizeOriginActor(raw) {
|
|
15934
15955
|
if (!raw)
|
|
15935
15956
|
return void 0;
|
|
15936
15957
|
const trimmed = raw.trim();
|
|
15937
15958
|
if (!trimmed)
|
|
15938
15959
|
return void 0;
|
|
15939
|
-
if (!
|
|
15960
|
+
if (!ORIGIN_ACTOR_ALLOWED.test(trimmed))
|
|
15940
15961
|
return void 0;
|
|
15941
|
-
return trimmed.slice(0,
|
|
15962
|
+
return trimmed.slice(0, ORIGIN_ACTOR_MAX_LENGTH).toLowerCase();
|
|
15942
15963
|
}
|
|
15943
15964
|
function sanitizeAgentRelayDistinctId(raw) {
|
|
15944
15965
|
if (!raw)
|
|
@@ -15995,6 +16016,7 @@ function decamelizeKey(key) {
|
|
|
15995
16016
|
}
|
|
15996
16017
|
|
|
15997
16018
|
// ../../node_modules/@relaycast/sdk/dist/ws.js
|
|
16019
|
+
var SEEN_EVENT_IDS_MAX = 2048;
|
|
15998
16020
|
var INTERNAL_WS_ORIGIN = /* @__PURE__ */ Symbol("relaycast.internal.ws-origin");
|
|
15999
16021
|
function readInternalWsOrigin(options) {
|
|
16000
16022
|
return options[INTERNAL_WS_ORIGIN];
|
|
@@ -16031,8 +16053,14 @@ var WsClient = class {
|
|
|
16031
16053
|
originSurface;
|
|
16032
16054
|
originClient;
|
|
16033
16055
|
originVersion;
|
|
16034
|
-
|
|
16056
|
+
originActor;
|
|
16035
16057
|
agentRelayDistinctId;
|
|
16058
|
+
/** Highest `agent_seq` observed across delivered events; null until the first stamped event. */
|
|
16059
|
+
lastSeenSeq = null;
|
|
16060
|
+
/** Receive time of the last seq-stamped event, used as `since` for DB-backed replay. */
|
|
16061
|
+
lastEventAt = null;
|
|
16062
|
+
/** Recently dispatched event ids (insertion-ordered for LRU eviction) for replay dedupe. */
|
|
16063
|
+
seenEventIds = /* @__PURE__ */ new Set();
|
|
16036
16064
|
constructor(options) {
|
|
16037
16065
|
const origin = readInternalWsOrigin(options) ?? SDK_ORIGIN;
|
|
16038
16066
|
this.token = options.token;
|
|
@@ -16047,7 +16075,7 @@ var WsClient = class {
|
|
|
16047
16075
|
this.originSurface = origin.surface;
|
|
16048
16076
|
this.originClient = origin.client;
|
|
16049
16077
|
this.originVersion = origin.version;
|
|
16050
|
-
this.
|
|
16078
|
+
this.originActor = sanitizeOriginActor(origin.originActor ?? options.originActor);
|
|
16051
16079
|
this.agentRelayDistinctId = sanitizeAgentRelayDistinctId(origin.agentRelayDistinctId ?? options.agentRelayDistinctId);
|
|
16052
16080
|
}
|
|
16053
16081
|
connect() {
|
|
@@ -16060,8 +16088,8 @@ var WsClient = class {
|
|
|
16060
16088
|
wsUrl.searchParams.set(decamelizeKey("originSurface"), this.originSurface);
|
|
16061
16089
|
wsUrl.searchParams.set(decamelizeKey("originClient"), this.originClient);
|
|
16062
16090
|
wsUrl.searchParams.set(decamelizeKey("originVersion"), this.originVersion);
|
|
16063
|
-
if (this.
|
|
16064
|
-
wsUrl.searchParams.set("
|
|
16091
|
+
if (this.originActor) {
|
|
16092
|
+
wsUrl.searchParams.set("origin_actor", this.originActor);
|
|
16065
16093
|
}
|
|
16066
16094
|
if (this.agentRelayDistinctId) {
|
|
16067
16095
|
wsUrl.searchParams.set(AGENT_RELAY_DISTINCT_ID_QUERY, this.agentRelayDistinctId);
|
|
@@ -16089,12 +16117,34 @@ var WsClient = class {
|
|
|
16089
16117
|
this.startPing();
|
|
16090
16118
|
const openEvent = { type: "open" };
|
|
16091
16119
|
this.emit("open", openEvent);
|
|
16120
|
+
this.sendResync();
|
|
16092
16121
|
};
|
|
16093
16122
|
ws.onmessage = (event) => {
|
|
16094
16123
|
if (this.ws !== ws)
|
|
16095
16124
|
return;
|
|
16096
16125
|
try {
|
|
16097
16126
|
const parsed = JSON.parse(String(event.data));
|
|
16127
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
16128
|
+
if (typeof parsed.agent_seq === "number" && Number.isFinite(parsed.agent_seq)) {
|
|
16129
|
+
this.lastSeenSeq = parsed.agent_seq;
|
|
16130
|
+
this.lastEventAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
16131
|
+
}
|
|
16132
|
+
if (parsed.type === "resync_ack") {
|
|
16133
|
+
const resyncedEvent = {
|
|
16134
|
+
type: "resynced",
|
|
16135
|
+
replayed: typeof parsed.replayed === "number" ? parsed.replayed : 0,
|
|
16136
|
+
gapDetected: parsed.gap_detected === true
|
|
16137
|
+
};
|
|
16138
|
+
this.emit("resynced", resyncedEvent);
|
|
16139
|
+
return;
|
|
16140
|
+
}
|
|
16141
|
+
if (typeof parsed.id === "string" && parsed.id.length > 0 && typeof parsed.type === "string") {
|
|
16142
|
+
const dedupeKey = `${parsed.type}:${parsed.id}`;
|
|
16143
|
+
if (this.seenEventIds.has(dedupeKey))
|
|
16144
|
+
return;
|
|
16145
|
+
this.rememberEventId(dedupeKey);
|
|
16146
|
+
}
|
|
16147
|
+
}
|
|
16098
16148
|
const result = ServerEventSchema.safeParse(parsed);
|
|
16099
16149
|
if (result.success) {
|
|
16100
16150
|
this.emit(result.data.type, camelizeKeys(result.data));
|
|
@@ -16214,6 +16264,29 @@ var WsClient = class {
|
|
|
16214
16264
|
this.ws.send(JSON.stringify(data));
|
|
16215
16265
|
}
|
|
16216
16266
|
}
|
|
16267
|
+
/**
|
|
16268
|
+
* Request replay of events missed while disconnected. The server replays its
|
|
16269
|
+
* resync ring past `last_seen_seq`, falls back to a DB-backed replay from
|
|
16270
|
+
* `since` when the gap exceeds the ring, and answers with `resync_ack`.
|
|
16271
|
+
* No-op until at least one seq-stamped event has been received.
|
|
16272
|
+
*/
|
|
16273
|
+
sendResync() {
|
|
16274
|
+
if (this.lastSeenSeq === null)
|
|
16275
|
+
return;
|
|
16276
|
+
this.sendJson({
|
|
16277
|
+
type: "resync",
|
|
16278
|
+
last_seen_seq: this.lastSeenSeq,
|
|
16279
|
+
...this.lastEventAt ? { since: this.lastEventAt } : {}
|
|
16280
|
+
});
|
|
16281
|
+
}
|
|
16282
|
+
rememberEventId(key) {
|
|
16283
|
+
this.seenEventIds.add(key);
|
|
16284
|
+
if (this.seenEventIds.size > SEEN_EVENT_IDS_MAX) {
|
|
16285
|
+
const oldest = this.seenEventIds.values().next().value;
|
|
16286
|
+
if (oldest !== void 0)
|
|
16287
|
+
this.seenEventIds.delete(oldest);
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16217
16290
|
startPing() {
|
|
16218
16291
|
this.stopPing();
|
|
16219
16292
|
this.pingTimer = setInterval(() => {
|
|
@@ -16425,7 +16498,7 @@ var AgentClient = class {
|
|
|
16425
16498
|
surface: this.client.originSurface,
|
|
16426
16499
|
client: this.client.originClient,
|
|
16427
16500
|
version: this.client.originVersion,
|
|
16428
|
-
...this.client.
|
|
16501
|
+
...this.client.originActor ? { originActor: this.client.originActor } : {},
|
|
16429
16502
|
...this.client.agentRelayDistinctId ? { agentRelayDistinctId: this.client.agentRelayDistinctId } : {}
|
|
16430
16503
|
}));
|
|
16431
16504
|
this.ws.on("open", () => {
|
|
@@ -16581,6 +16654,15 @@ var AgentClient = class {
|
|
|
16581
16654
|
}
|
|
16582
16655
|
return this.ws.on("permanently_disconnected", (e) => handler(e.attempt));
|
|
16583
16656
|
},
|
|
16657
|
+
resynced: (handler) => {
|
|
16658
|
+
if (!this.ws) {
|
|
16659
|
+
throw new Error("WebSocket not connected. Call connect() first.");
|
|
16660
|
+
}
|
|
16661
|
+
return this.ws.on("resynced", (e) => {
|
|
16662
|
+
const event = e;
|
|
16663
|
+
handler({ replayed: event.replayed, gapDetected: event.gapDetected });
|
|
16664
|
+
});
|
|
16665
|
+
},
|
|
16584
16666
|
// Wildcard
|
|
16585
16667
|
any: (handler) => {
|
|
16586
16668
|
if (!this.ws) {
|
|
@@ -31494,7 +31576,7 @@ var HttpClient = class _HttpClient {
|
|
|
31494
31576
|
_originSurface;
|
|
31495
31577
|
_originClient;
|
|
31496
31578
|
_originVersion;
|
|
31497
|
-
|
|
31579
|
+
_originActor;
|
|
31498
31580
|
_agentRelayDistinctId;
|
|
31499
31581
|
_retryPolicy;
|
|
31500
31582
|
constructor(options) {
|
|
@@ -31504,7 +31586,7 @@ var HttpClient = class _HttpClient {
|
|
|
31504
31586
|
this._originSurface = origin.surface;
|
|
31505
31587
|
this._originClient = origin.client;
|
|
31506
31588
|
this._originVersion = origin.version;
|
|
31507
|
-
this.
|
|
31589
|
+
this._originActor = sanitizeOriginActor(origin.originActor ?? options.originActor);
|
|
31508
31590
|
this._agentRelayDistinctId = sanitizeAgentRelayDistinctId(origin.agentRelayDistinctId ?? options.agentRelayDistinctId);
|
|
31509
31591
|
this._retryPolicy = normalizeRetryPolicy(options.retryPolicy);
|
|
31510
31592
|
}
|
|
@@ -31523,9 +31605,9 @@ var HttpClient = class _HttpClient {
|
|
|
31523
31605
|
get originVersion() {
|
|
31524
31606
|
return this._originVersion;
|
|
31525
31607
|
}
|
|
31526
|
-
/** Sanitized
|
|
31527
|
-
get
|
|
31528
|
-
return this.
|
|
31608
|
+
/** Sanitized originActor identifier, or `undefined` when none was supplied. */
|
|
31609
|
+
get originActor() {
|
|
31610
|
+
return this._originActor;
|
|
31529
31611
|
}
|
|
31530
31612
|
/** Sanitized Agent Relay distinct id, or `undefined` when none was supplied. */
|
|
31531
31613
|
get agentRelayDistinctId() {
|
|
@@ -31539,7 +31621,7 @@ var HttpClient = class _HttpClient {
|
|
|
31539
31621
|
surface: this._originSurface,
|
|
31540
31622
|
client: this._originClient,
|
|
31541
31623
|
version: this._originVersion,
|
|
31542
|
-
...this.
|
|
31624
|
+
...this._originActor ? { originActor: this._originActor } : {},
|
|
31543
31625
|
...this._agentRelayDistinctId ? { agentRelayDistinctId: this._agentRelayDistinctId } : {}
|
|
31544
31626
|
}));
|
|
31545
31627
|
}
|
|
@@ -31557,7 +31639,7 @@ var HttpClient = class _HttpClient {
|
|
|
31557
31639
|
"X-Relaycast-Origin-Surface": this._originSurface,
|
|
31558
31640
|
"X-Relaycast-Origin-Client": this._originClient,
|
|
31559
31641
|
"X-Relaycast-Origin-Version": this._originVersion,
|
|
31560
|
-
...this.
|
|
31642
|
+
...this._originActor ? { [ORIGIN_ACTOR_HEADER]: this._originActor } : {},
|
|
31561
31643
|
...this._agentRelayDistinctId ? { [AGENT_RELAY_DISTINCT_ID_HEADER]: this._agentRelayDistinctId } : {},
|
|
31562
31644
|
...options?.headers || {}
|
|
31563
31645
|
};
|
|
@@ -31687,7 +31769,7 @@ var RelayCast = class _RelayCast {
|
|
|
31687
31769
|
surface: this.client.originSurface,
|
|
31688
31770
|
client: this.client.originClient,
|
|
31689
31771
|
version: this.client.originVersion,
|
|
31690
|
-
...this.client.
|
|
31772
|
+
...this.client.originActor ? { originActor: this.client.originActor } : {}
|
|
31691
31773
|
}));
|
|
31692
31774
|
}
|
|
31693
31775
|
connect() {
|
|
@@ -31732,6 +31814,10 @@ var RelayCast = class _RelayCast {
|
|
|
31732
31814
|
error: (handler) => this.onEvent("error", handler),
|
|
31733
31815
|
reconnecting: (handler) => this.ws.on("reconnecting", (e) => handler(e.attempt)),
|
|
31734
31816
|
permanentlyDisconnected: (handler) => this.ws.on("permanently_disconnected", (e) => handler(e.attempt)),
|
|
31817
|
+
resynced: (handler) => this.ws.on("resynced", (e) => {
|
|
31818
|
+
const event = e;
|
|
31819
|
+
handler({ replayed: event.replayed, gapDetected: event.gapDetected });
|
|
31820
|
+
}),
|
|
31735
31821
|
any: (handler) => this.ws.on("*", handler)
|
|
31736
31822
|
};
|
|
31737
31823
|
static async createWorkspace(name, options) {
|
|
@@ -32724,6 +32810,7 @@ function actionContext(input) {
|
|
|
32724
32810
|
}
|
|
32725
32811
|
|
|
32726
32812
|
// ../sdk/dist/relaycast-telemetry.js
|
|
32813
|
+
var ORIGIN_ACTOR_ENV = "AGENT_RELAY_ORIGIN_ACTOR";
|
|
32727
32814
|
var HARNESS_ENV_KEYS = [
|
|
32728
32815
|
"AGENT_RELAY_HARNESS",
|
|
32729
32816
|
"AGENT_RELAY_ORCHESTRATOR_HARNESS",
|
|
@@ -32737,11 +32824,18 @@ function nonEmpty(value) {
|
|
|
32737
32824
|
const trimmed = value?.trim();
|
|
32738
32825
|
return trimmed ? trimmed : void 0;
|
|
32739
32826
|
}
|
|
32827
|
+
function resolveOriginActor(env) {
|
|
32828
|
+
const explicit = nonEmpty(env[ORIGIN_ACTOR_ENV]);
|
|
32829
|
+
if (explicit)
|
|
32830
|
+
return explicit;
|
|
32831
|
+
const harness = HARNESS_ENV_KEYS.map((key) => nonEmpty(env[key])).find((value) => Boolean(value));
|
|
32832
|
+
return harness ? `agent-relay-cli/agent/${harness}` : void 0;
|
|
32833
|
+
}
|
|
32740
32834
|
function relaycastTelemetryOptions(explicit = {}, env = defaultEnv()) {
|
|
32741
|
-
const
|
|
32835
|
+
const originActor = nonEmpty(explicit.originActor) ?? resolveOriginActor(env);
|
|
32742
32836
|
const agentRelayDistinctId = nonEmpty(explicit.agentRelayDistinctId) ?? nonEmpty(env.AGENT_RELAY_DISTINCT_ID);
|
|
32743
32837
|
return {
|
|
32744
|
-
...
|
|
32838
|
+
...originActor ? { originActor } : {},
|
|
32745
32839
|
...agentRelayDistinctId ? { agentRelayDistinctId } : {}
|
|
32746
32840
|
};
|
|
32747
32841
|
}
|
|
@@ -33428,7 +33522,7 @@ function createRelaycastClient(options) {
|
|
|
33428
33522
|
baseUrl: options.baseUrl,
|
|
33429
33523
|
retryPolicy: options.retryPolicy,
|
|
33430
33524
|
...relaycastTelemetryOptions({
|
|
33431
|
-
|
|
33525
|
+
originActor: options.originActor,
|
|
33432
33526
|
agentRelayDistinctId: options.agentRelayDistinctId
|
|
33433
33527
|
})
|
|
33434
33528
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.7",
|
|
4
4
|
"description": "Real-time agent-to-agent communication system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"pack:validate": "npm pack --dry-run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@agent-relay/cloud": "8.3.
|
|
47
|
-
"@agent-relay/config": "8.3.
|
|
48
|
-
"@agent-relay/harness-driver": "8.3.
|
|
49
|
-
"@agent-relay/sdk": "8.3.
|
|
50
|
-
"@agent-relay/utils": "8.3.
|
|
46
|
+
"@agent-relay/cloud": "8.3.7",
|
|
47
|
+
"@agent-relay/config": "8.3.7",
|
|
48
|
+
"@agent-relay/harness-driver": "8.3.7",
|
|
49
|
+
"@agent-relay/sdk": "8.3.7",
|
|
50
|
+
"@agent-relay/utils": "8.3.7",
|
|
51
51
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
52
|
-
"@relaycast/sdk": "^
|
|
52
|
+
"@relaycast/sdk": "^3.1.1",
|
|
53
53
|
"@relayflows/cli": "^1.0.1",
|
|
54
54
|
"@xterm/headless": "^6.0.0",
|
|
55
55
|
"commander": "^12.1.0",
|