agent-relay 10.6.2 → 10.6.3

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 (2) hide show
  1. package/dist/index.cjs +69 -7
  2. package/package.json +7 -7
package/dist/index.cjs CHANGED
@@ -283,7 +283,7 @@ __export(index_exports, {
283
283
  module.exports = __toCommonJS(index_exports);
284
284
 
285
285
  // ../../node_modules/@relaycast/sdk/dist/version.js
286
- var SDK_VERSION = "6.1.0";
286
+ var SDK_VERSION = "6.2.0";
287
287
 
288
288
  // ../../node_modules/@relaycast/types/node_modules/zod/v4/classic/external.js
289
289
  var external_exports = {};
@@ -15462,6 +15462,25 @@ var AgentStatusChangedEventSchema = external_exports.object({
15462
15462
  agent: external_exports.object({ name: external_exports.string() }),
15463
15463
  status: external_exports.enum(["active", "idle", "blocked", "waiting", "offline"])
15464
15464
  });
15465
+ var AgentExitedEventSchema = external_exports.object({
15466
+ type: external_exports.literal("agent.exited"),
15467
+ agent_id: external_exports.string(),
15468
+ agent_name: external_exports.string(),
15469
+ node_id: external_exports.string().nullable(),
15470
+ invocation_id: external_exports.string().nullable(),
15471
+ reason: external_exports.enum(["deregistered", "missing_from_inventory", "released"])
15472
+ });
15473
+ var NodeStatusOnlineEventSchema = external_exports.object({
15474
+ type: external_exports.literal("node.status.online"),
15475
+ node_id: external_exports.string(),
15476
+ node_name: external_exports.string().nullable()
15477
+ });
15478
+ var NodeStatusOfflineEventSchema = external_exports.object({
15479
+ type: external_exports.literal("node.status.offline"),
15480
+ node_id: external_exports.string(),
15481
+ node_name: external_exports.string().nullable(),
15482
+ reason: external_exports.enum(["liveness_timeout", "disconnected", "deregistered"]).optional()
15483
+ });
15465
15484
  var ChannelCreatedEventSchema = external_exports.object({
15466
15485
  type: external_exports.literal("channel.created"),
15467
15486
  channel: external_exports.object({ name: external_exports.string(), topic: external_exports.string().nullable() })
@@ -15617,6 +15636,9 @@ var ServerEventSchema = external_exports.discriminatedUnion("type", [
15617
15636
  AgentStatusWaitingEventSchema,
15618
15637
  AgentStatusOfflineEventSchema,
15619
15638
  AgentStatusChangedEventSchema,
15639
+ AgentExitedEventSchema,
15640
+ NodeStatusOnlineEventSchema,
15641
+ NodeStatusOfflineEventSchema,
15620
15642
  ChannelCreatedEventSchema,
15621
15643
  ChannelUpdatedEventSchema,
15622
15644
  ChannelArchivedEventSchema,
@@ -15658,6 +15680,9 @@ var WsClientEventSchema = external_exports.discriminatedUnion("type", [
15658
15680
  AgentStatusWaitingEventSchema,
15659
15681
  AgentStatusOfflineEventSchema,
15660
15682
  AgentStatusChangedEventSchema,
15683
+ AgentExitedEventSchema,
15684
+ NodeStatusOnlineEventSchema,
15685
+ NodeStatusOfflineEventSchema,
15661
15686
  ChannelCreatedEventSchema,
15662
15687
  ChannelUpdatedEventSchema,
15663
15688
  ChannelArchivedEventSchema,
@@ -15773,6 +15798,9 @@ var SubscribableEventTypeSchema = external_exports.enum([
15773
15798
  "agent.status.blocked",
15774
15799
  "agent.status.waiting",
15775
15800
  "agent.status.offline",
15801
+ "agent.exited",
15802
+ "node.status.online",
15803
+ "node.status.offline",
15776
15804
  "channel.created",
15777
15805
  "channel.updated",
15778
15806
  "channel.archived",
@@ -16208,6 +16236,15 @@ function toCamelKey(key) {
16208
16236
  function toSnakeKey(key) {
16209
16237
  return key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
16210
16238
  }
16239
+ var VERBATIM_VALUE_KEYS = /* @__PURE__ */ new Set([
16240
+ "headers",
16241
+ "input",
16242
+ "output",
16243
+ "input_schema",
16244
+ "inputSchema",
16245
+ "output_schema",
16246
+ "outputSchema"
16247
+ ]);
16211
16248
  function camelizeKeys(value) {
16212
16249
  if (Array.isArray(value)) {
16213
16250
  return value.map((item) => camelizeKeys(item));
@@ -16215,7 +16252,7 @@ function camelizeKeys(value) {
16215
16252
  if (isPlainObject2(value)) {
16216
16253
  const out = {};
16217
16254
  for (const [key, val] of Object.entries(value)) {
16218
- out[toCamelKey(key)] = camelizeKeys(val);
16255
+ out[toCamelKey(key)] = VERBATIM_VALUE_KEYS.has(key) ? val : camelizeKeys(val);
16219
16256
  }
16220
16257
  return out;
16221
16258
  }
@@ -16228,7 +16265,7 @@ function decamelizeKeys(value) {
16228
16265
  if (isPlainObject2(value)) {
16229
16266
  const out = {};
16230
16267
  for (const [key, val] of Object.entries(value)) {
16231
- out[toSnakeKey(key)] = key === "headers" && isPlainObject2(val) ? val : decamelizeKeys(val);
16268
+ out[toSnakeKey(key)] = VERBATIM_VALUE_KEYS.has(key) ? val : decamelizeKeys(val);
16232
16269
  }
16233
16270
  return out;
16234
16271
  }
@@ -16892,9 +16929,22 @@ var AgentClient = class {
16892
16929
  heartbeat: async () => {
16893
16930
  await this.client.post("/v1/agents/heartbeat", {});
16894
16931
  },
16895
- markOffline: async () => {
16932
+ /**
16933
+ * Mark this agent offline.
16934
+ *
16935
+ * By default this is a presence-only signal: a node-hosted (broker) agent
16936
+ * keeps its node binding, so a session still running on its node keeps
16937
+ * receiving deliveries through that node and the binding stays usable for
16938
+ * later reconnection. Pass `{ deregister: true }` to also tear down the
16939
+ * node binding and re-home the agent to its implicit direct node.
16940
+ */
16941
+ markOffline: async (options) => {
16896
16942
  this.stopAutoHeartbeat();
16897
- await this.client.post("/v1/agents/disconnect", {});
16943
+ if (this.pendingHeartbeat) {
16944
+ await this.pendingHeartbeat;
16945
+ this.pendingHeartbeat = null;
16946
+ }
16947
+ await this.client.post("/v1/agents/disconnect", options?.deregister ? { deregister: true } : {});
16898
16948
  }
16899
16949
  };
16900
16950
  startAutoHeartbeat() {
@@ -16902,6 +16952,8 @@ var AgentClient = class {
16902
16952
  if (this.autoHeartbeatMs === false)
16903
16953
  return;
16904
16954
  this.autoHeartbeatTimer = setInterval(() => {
16955
+ if (this.pendingHeartbeat)
16956
+ return;
16905
16957
  this.pendingHeartbeat = this.presence.heartbeat().catch(() => {
16906
16958
  }).finally(() => {
16907
16959
  this.pendingHeartbeat = null;
@@ -16972,7 +17024,17 @@ var AgentClient = class {
16972
17024
  async heartbeat() {
16973
17025
  await this.presence.heartbeat();
16974
17026
  }
16975
- async disconnect() {
17027
+ /**
17028
+ * Tear down this client's WebSocket and mark the agent offline.
17029
+ *
17030
+ * By default the HTTP disconnect is presence-only for node-hosted (broker)
17031
+ * agents: the node binding is preserved, so an agent process still running
17032
+ * on its node keeps receiving deliveries through that node, and the binding
17033
+ * remains usable for later reconnection. Pass `{ deregister: true }` to also
17034
+ * deregister the node binding and re-home the agent to its implicit direct
17035
+ * node.
17036
+ */
17037
+ async disconnect(options) {
16976
17038
  this.stopAutoHeartbeat();
16977
17039
  if (this.pendingHeartbeat) {
16978
17040
  await this.pendingHeartbeat;
@@ -16990,7 +17052,7 @@ var AgentClient = class {
16990
17052
  this.ws = null;
16991
17053
  }
16992
17054
  this.activeWsChannels.clear();
16993
- await this.client.post("/v1/agents/disconnect", {}).catch(() => {
17055
+ await this.client.post("/v1/agents/disconnect", options?.deregister ? { deregister: true } : {}).catch(() => {
16994
17056
  });
16995
17057
  }
16996
17058
  subscribe(channels, onMessage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay",
3
- "version": "10.6.2",
3
+ "version": "10.6.3",
4
4
  "description": "Real-time agent-to-agent communication system",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -43,12 +43,12 @@
43
43
  "pack:validate": "npm pack --dry-run"
44
44
  },
45
45
  "dependencies": {
46
- "@agent-relay/cloud": "10.6.2",
47
- "@agent-relay/config": "10.6.2",
48
- "@agent-relay/fleet": "10.6.2",
49
- "@agent-relay/harness-driver": "10.6.2",
50
- "@agent-relay/sdk": "10.6.2",
51
- "@agent-relay/utils": "10.6.2",
46
+ "@agent-relay/cloud": "10.6.3",
47
+ "@agent-relay/config": "10.6.3",
48
+ "@agent-relay/fleet": "10.6.3",
49
+ "@agent-relay/harness-driver": "10.6.3",
50
+ "@agent-relay/sdk": "10.6.3",
51
+ "@agent-relay/utils": "10.6.3",
52
52
  "@modelcontextprotocol/sdk": "^1.0.0",
53
53
  "@relayfile/client": "^0.10.21",
54
54
  "@relayflows/cli": "^1.0.1",