@masons/agent-network 0.6.25 → 0.6.27

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.
@@ -7,7 +7,7 @@ interface StartChannelSetupOptions {
7
7
  startOver?: boolean;
8
8
  }
9
9
  export interface ChannelSetupResult {
10
- status: "pending" | "completed" | "expired" | "failed";
10
+ status: "pending" | "completed" | "linked" | "expired" | "failed";
11
11
  handoffUrl?: string;
12
12
  expiresAt?: number;
13
13
  message?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"channel-setup.d.ts","sourceRoot":"","sources":["../src/channel-setup.ts"],"names":[],"mappings":"AAkBA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IAEnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAM9B,SAAS,CAAC,EAAE,MAAM,CAAC;IAOnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA4CD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuBD,wBAAgB,6BAA6B,IAAI,wBAAwB,CAKxE;AAWD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAkB7B;AAOD,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAQjE;AAaD,wBAAgB,wBAAwB,IAAI,kBAAkB,GAAG,IAAI,CAOpE;AAgOD,wBAAgB,4BAA4B,IAAI,IAAI,CAInD;AAED,eAAO,MAAM,oBAAoB,QAAqB,CAAC"}
1
+ {"version":3,"file":"channel-setup.d.ts","sourceRoot":"","sources":["../src/channel-setup.ts"],"names":[],"mappings":"AA+BA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IAEnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAM9B,SAAS,CAAC,EAAE,MAAM,CAAC;IAOnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA4CD,MAAM,WAAW,kBAAkB;IAKjC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA4BD,wBAAgB,6BAA6B,IAAI,wBAAwB,CAKxE;AAWD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAqB7B;AAyDD,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAQjE;AAaD,wBAAgB,wBAAwB,IAAI,kBAAkB,GAAG,IAAI,CAOpE;AAyOD,wBAAgB,4BAA4B,IAAI,IAAI,CAInD;AAED,eAAO,MAAM,oBAAoB,QAAqB,CAAC"}
@@ -1,13 +1,18 @@
1
1
  import createDebug from "debug";
2
- import { readExistingConnectorUrl } from "./config.js";
2
+ import { hasApiKey, readExistingConnectorUrl, requireApiKey, requirePlatformConfig, } from "./config.js";
3
3
  import { resolveConnectorUrlForSetup } from "./connector-url-boundary.js";
4
4
  import { beginBridgeHandoff, collectBridgeHandoffOnce, completeBridgeHandoff, DEFAULT_IDP_BASE_URL, HANDOFF_TIMEOUT_MS, SetupFlowError, } from "./handoff.js";
5
5
  import { acceptBridgeHandoff } from "./handoff-acceptance.js";
6
- import { DEFAULT_API_HOST } from "./platform-client.js";
6
+ import { classifyIdentityError, formatCanonicalNode, } from "./identity-format.js";
7
+ import { DEFAULT_API_HOST, getIdentity, } from "./platform-client.js";
7
8
  const dbg = createDebug("agent-network:channel-setup");
8
9
  const GENERIC_EXPIRY_MESSAGE = "The previous Link URL expired before the browser handoff completed.";
9
10
  const GONE_MESSAGE = "That Link session is no longer on the handoff bridge — it expired, or its runtime key was already delivered — so it cannot complete.";
10
11
  const SUPERSEDED_MESSAGE = "A newer Link session replaced this one while it was completing, so the runtime key that session delivered was discarded. Nothing changed — this runtime still uses the credential it had before.";
12
+ const DURABLE_BINDING_NOTE = [
13
+ "This result reflects the current binding — the runtime key this Runtime holds, confirmed with the network just now.",
14
+ "To re-link or change Node, call masons_link with start_over: true.",
15
+ ].join("\n");
11
16
  let pendingSetup = null;
12
17
  let lastSetupStatus = null;
13
18
  let setupSeq = 0;
@@ -33,8 +38,34 @@ export async function startOrGetChannelSetup(options) {
33
38
  const live = getActivePendingSetup();
34
39
  if (live)
35
40
  return pendingResult(live);
41
+ const durable = await reportDurableBinding(options);
42
+ if (durable)
43
+ return durable;
36
44
  return await startNewSession(options);
37
45
  }
46
+ async function reportDurableBinding(options) {
47
+ if (!hasApiKey())
48
+ return null;
49
+ let node;
50
+ try {
51
+ node = await getIdentity(requirePlatformConfig(), requireApiKey());
52
+ }
53
+ catch (err) {
54
+ if (classifyIdentityError(err) === null)
55
+ throw err;
56
+ dbg("the stored runtime key could not be verified before minting: %O", err);
57
+ return null;
58
+ }
59
+ if (node === null)
60
+ return null;
61
+ const lines = [formatCanonicalNode("Linked", node), DURABLE_BINDING_NOTE];
62
+ if (options.invitedBy)
63
+ lines.push(invitationFollowThrough(options.invitedBy));
64
+ return { status: "linked", message: lines.join("\n") };
65
+ }
66
+ function invitationFollowThrough(invitedBy) {
67
+ return `This call carried an invitation from @${invitedBy}. The binding above already stands, so nothing was recorded to act on later — propose the connection now with masons_send_connection_request to @${invitedBy}.`;
68
+ }
38
69
  export function getChannelSetupStatus() {
39
70
  const active = getActivePendingSetup();
40
71
  if (active)
@@ -1,5 +1,2 @@
1
- export declare const SETUP_CODE_CHARSET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
2
- export declare const SETUP_CODE_LENGTH = 8;
3
- export declare const SETUP_CODE_TTL_MS: number;
4
1
  export declare const AUTHORIZED_TOKEN_TTL_MS: number;
5
2
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AACrE,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,iBAAiB,QAAiB,CAAC;AAChD,eAAO,MAAM,uBAAuB,QAAiB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,QAAiB,CAAC"}
package/dist/constants.js CHANGED
@@ -1,4 +1 @@
1
- export const SETUP_CODE_CHARSET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
2
- export const SETUP_CODE_LENGTH = 8;
3
- export const SETUP_CODE_TTL_MS = 15 * 60 * 1000;
4
1
  export const AUTHORIZED_TOKEN_TTL_MS = 60 * 60 * 1000;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AUTHORIZED_TOKEN_TTL_MS, SETUP_CODE_CHARSET, SETUP_CODE_LENGTH, SETUP_CODE_TTL_MS, } from "./constants.js";
1
+ export { AUTHORIZED_TOKEN_TTL_MS } from "./constants.js";
2
2
  export type { AgentNetworkAccount } from "./config-schema.js";
3
3
  export type { AddressedMessageEvent, DeliveryPendingEvent, DeliverySkipEvent, DeliveryStatusEvent, ObservedSendAckEvent, RegisterAckEvent, SendAckEvent, StructuredErrorEvent, } from "./types.js";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAIxB,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAIzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { AUTHORIZED_TOKEN_TTL_MS, SETUP_CODE_CHARSET, SETUP_CODE_LENGTH, SETUP_CODE_TTL_MS, } from "./constants.js";
1
+ export { AUTHORIZED_TOKEN_TTL_MS } from "./constants.js";
@@ -1 +1 @@
1
- {"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AASxD,eAAO,MAAM,qBAAqB,iDACc,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM;CAKlB;AAiBD,qBAAa,oBAAqB,SAAQ,KAAK;aAE3B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,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAiB9B;AAiBD,wBAAsB,YAAY,CAChC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE,OAAO,CAAC,oBAAoB,CAAC,CAc/B;AA6DD,eAAO,MAAM,aAAa,QAvCjB,oBAAoB,cACb,MAAM,aACP,MAAM,KAChB,OAAO,CAAC,oBAAoB,CAoCiB,CAAC;AAEnD,eAAO,MAAM,aAAa,QAzCjB,oBAAoB,cACb,MAAM,aACP,MAAM,KAChB,OAAO,CAAC,oBAAoB,CAsCiB,CAAC;AAEnD,eAAO,MAAM,eAAe,QA3CnB,oBAAoB,cACb,MAAM,aACP,MAAM,KAChB,OAAO,CAAC,oBAAoB,CAwCqB,CAAC;AAQvD,wBAAsB,aAAa,CACjC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAWhC;AAQD,wBAAsB,eAAe,CACnC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,uBAAuB,CAAC,CAMlC;AA4BD,wBAAsB,WAAW,CAC/B,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAyBnC"}
package/dist/plugin.js CHANGED
@@ -10,7 +10,7 @@ import { isServicesRetainedReplyContext } from "./services-retained-reply-contex
10
10
  import { evaluateServicesRetainedToolPolicy, SERVICES_RETAINED_TOOL_POLICY_ID, } from "./services-retained-tool-policy.js";
11
11
  import { registerTools } from "./tools.js";
12
12
  import { setCurrentTurnChannelId, setCurrentTurnIsOwnerForTools, setCurrentTurnOwnerSignalForTools, } from "./turn-context.js";
13
- import { getUpdateInfo } from "./update-check.js";
13
+ import { getUpdateInfo, NPM_PACKAGE_NAME } from "./update-check.js";
14
14
  import { PLUGIN_VERSION } from "./version.js";
15
15
  function formatTimeAgo(timestamp) {
16
16
  const diff = Date.now() - timestamp;
@@ -125,7 +125,7 @@ const plugin = {
125
125
  });
126
126
  }
127
127
  catch (err) {
128
- console.error("[@masons/agent-network] api.registerChannel failed — channel will be unavailable:", err);
128
+ console.error(`[${NPM_PACKAGE_NAME}] api.registerChannel failed — channel will be unavailable:`, err);
129
129
  throw err;
130
130
  }
131
131
  let cachedState = null;
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,KAAK,kBAAkB,EAGxB,MAAM,oBAAoB,CAAC;AAuD5B,UAAU,WAAW;IACnB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CACP,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3B;AAED,UAAU,WAAW;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3E,UAAU,OAAO;IACf,YAAY,CACV,IAAI,EAAE,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O;IACf,YAAY,CACV,IAAI,EAAE,cAAc,GAAG,WAAW,EAWlC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAC7D,IAAI,CAAC;CACT;AAqED,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAkYD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,GAAG,WAAW,GACtC,MAAM,CAqBR;AAGD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAyC3E;AA+CD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAqoChD"}
package/dist/tools.js CHANGED
@@ -9,7 +9,7 @@ import { ownerNotesQueue } from "./owner-notes.js";
9
9
  import { acceptRequest, getIdentity, ignoreRequest, isPackagedTombstone, listConnections, listRequests, PlatformApiError, PlatformNetworkError, requestConnection, updateProfile, withdrawRequest, } from "./platform-client.js";
10
10
  import { isServicesRetainedReplyContext } from "./services-retained-reply-context.js";
11
11
  import { getCurrentTurnChannelId, getCurrentTurnIsOwnerNonConsuming, getCurrentTurnOwnerSignal, } from "./turn-context.js";
12
- import { getLatestPublishedVersion, getPluginVersion, getUpdateInfo, } from "./update-check.js";
12
+ import { getLatestPublishedVersion, getPluginVersion, getUpdateInfo, NPM_PACKAGE_NAME, } from "./update-check.js";
13
13
  const PROFILE_FIELDS = new Set(["name", "scope", "about", "audience"]);
14
14
  const GATEWAY_RESTART_CMD = "openclaw gateway restart";
15
15
  const PACKAGED_TOOL_ROSTER = pluginManifest.contracts.tools;
@@ -18,7 +18,7 @@ function withRoster(text) {
18
18
  return `${text}\n\n${ROSTER_HEADER}\n${PACKAGED_TOOL_ROSTER.join(", ")}`;
19
19
  }
20
20
  function upgradeCmd(version) {
21
- return `openclaw plugins install @masons/agent-network@${version} --force`;
21
+ return `openclaw plugins install ${NPM_PACKAGE_NAME}@${version} --force`;
22
22
  }
23
23
  const SEMVER_RE = /^\d+\.\d+\.\d+$/;
24
24
  export function _resetToolsForTesting() {
@@ -142,17 +142,19 @@ function formatRegistration(outcome) {
142
142
  return "none";
143
143
  }
144
144
  }
145
+ function formatChannelStateLines(client) {
146
+ return [
147
+ `Gateway channel: ${client ? client.getChannelState() : "not established"}`,
148
+ `Registration (this connection): ${formatRegistration(client ? client.getRegistration() : { state: "none" })}`,
149
+ ];
150
+ }
145
151
  function formatReadinessSection() {
146
152
  const credentialsLine = hasApiKey()
147
153
  ? "Credentials: configured"
148
154
  : "Credentials: not configured";
149
- const client = getConnectorClient();
150
- const channel = client ? client.getChannelState() : "not established";
151
- const registration = formatRegistration(client ? client.getRegistration() : { state: "none" });
152
155
  return [
153
156
  credentialsLine,
154
- `Gateway channel: ${channel}`,
155
- `Registration (this connection): ${registration}`,
157
+ ...formatChannelStateLines(getConnectorClient()),
156
158
  ].join("\n");
157
159
  }
158
160
  async function resolveIdentitySection() {
@@ -261,10 +263,14 @@ export function formatChannelSetupResult(result) {
261
263
  result.message ?? "Agent Network Link completed.",
262
264
  "",
263
265
  "HTTP tools may work before the Gateway WebSocket is connected.",
264
- 'If the gateway tool is available, call it with action "restart" and reason "Activate Agent Network after Link". If not, ask the user to run `openclaw gateway restart`.',
266
+ GATEWAY_RESTART_ACTION,
265
267
  "This result stands until the owner asks to start over: to re-link or change Node, call masons_link with start_over: true.",
266
268
  ].join("\n");
267
269
  }
270
+ if (result.status === "linked") {
271
+ const receipt = result.message ?? "This Runtime is linked to an Agent Node.";
272
+ return [receipt, ...formatRealtimeGap()].join("\n");
273
+ }
268
274
  if (result.status === "expired") {
269
275
  return [
270
276
  result.message ?? "The previous Link URL expired.",
@@ -278,8 +284,17 @@ export function formatChannelSetupResult(result) {
278
284
  LINK_RETRY_GUIDANCE,
279
285
  ].join("\n");
280
286
  }
287
+ const GATEWAY_RESTART_ACTION = 'If the gateway tool is available, call it with action "restart" and reason "Activate Agent Network after Link". If not, ask the user to run `openclaw gateway restart`.';
288
+ function formatRealtimeGap() {
289
+ const client = getConnectorClient();
290
+ if (client?.getChannelState() === "connected" &&
291
+ client.getRegistration().state === "accepted") {
292
+ return [];
293
+ }
294
+ return ["", ...formatChannelStateLines(client), GATEWAY_RESTART_ACTION];
295
+ }
281
296
  const LINK_RETRY_GUIDANCE = [
282
- "Call masons_link again in this conversation and I will issue a fresh Link URL — the whole flow finishes here.",
297
+ "Call masons_link again in this conversation — the whole flow finishes here.",
283
298
  "Last resort, only if that keeps failing: the owner can run `openclaw channels login --channel agent-network` in a terminal.",
284
299
  ].join("\n");
285
300
  export function registerTools(api) {
@@ -310,7 +325,9 @@ export function registerTools(api) {
310
325
  "This tool returns a browser handoff URL on the channel where you are",
311
326
  "running. The user opens it, signs in, picks an agent, and the encrypted",
312
327
  "handoff completes in the background. After completion, restart the",
313
- "gateway to activate realtime messaging.",
328
+ "gateway to activate realtime messaging. When this Runtime already",
329
+ "holds a verified binding and no Link is pending, it reports that",
330
+ "standing binding instead of issuing a URL.",
314
331
  "",
315
332
  "If the user is reaching this agent through the MASONS network as a",
316
333
  "visitor (not the agent's owner), this tool refuses with an explanation",
@@ -326,10 +343,10 @@ export function registerTools(api) {
326
343
  })),
327
344
  start_over: Type.Optional(Type.Boolean({
328
345
  description: "Discard whatever this Runtime is holding — a Link still in " +
329
- "progress, or a Link that already completed and issue a fresh " +
330
- "Link URL. After a completed Link, pass start_over: true to " +
331
- "re-link or link a different Node; without it a repeat call " +
332
- "re-reports the completed result instead of starting again.",
346
+ "progress, a Link that already completed, or a binding already " +
347
+ "on disk and issue a fresh Link URL. Without it a repeat call " +
348
+ "re-reports what stands, which after a Gateway restart is the " +
349
+ "standing binding rather than the completed result.",
333
350
  })),
334
351
  }),
335
352
  execute: async (_id, params) => {
@@ -412,7 +429,7 @@ export function registerTools(api) {
412
429
  catch (err) {
413
430
  if (err instanceof PlatformApiError) {
414
431
  if (err.status === 401) {
415
- return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link with start_over: true.");
432
+ return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link.");
416
433
  }
417
434
  if (err.status === 422) {
418
435
  return textResult(`Validation error: ${err.message}`);
@@ -493,7 +510,7 @@ export function registerTools(api) {
493
510
  : "This Services deployment does not serve the connection-request endpoint. Nothing was sent.");
494
511
  }
495
512
  if (err.status === 401) {
496
- return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link with start_over: true.");
513
+ return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link.");
497
514
  }
498
515
  return textResult(`Connection request failed: ${err.message}`);
499
516
  }
@@ -577,7 +594,7 @@ export function registerTools(api) {
577
594
  catch (err) {
578
595
  if (err instanceof PlatformApiError) {
579
596
  if (err.status === 401) {
580
- return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link with start_over: true.");
597
+ return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link.");
581
598
  }
582
599
  if (err.status === 404) {
583
600
  return textResult("This Services deployment does not serve the packaged connection-request endpoint. Nothing was read.");
@@ -765,7 +782,7 @@ export function registerTools(api) {
765
782
  catch (err) {
766
783
  if (err instanceof PlatformApiError) {
767
784
  if (err.status === 401) {
768
- return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link with start_over: true.");
785
+ return textResult("Authentication failed. The runtime key may be invalid. Ask the owner to re-link here: call masons_link.");
769
786
  }
770
787
  return textResult(`Failed to list connections: ${err.message}`);
771
788
  }
@@ -1,4 +1,8 @@
1
1
  import type { UpdateCheckCache } from "./update-cache.js";
2
+ export declare const NPM_PACKAGE_NAME: string;
3
+ export declare function resolveRegistryBase(pkgLike: {
4
+ publishConfig?: Record<string, unknown>;
5
+ }): string;
2
6
  export interface UpdateInfo {
3
7
  currentVersion: string;
4
8
  latestVersion: string;
@@ -1 +1 @@
1
- {"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAkB1D,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAGD,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAajC,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAEjD;AAGD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAUD,wBAAsB,cAAc,CAAC,OAAO,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiClE;AAUD,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxE;AAYD,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAarD;AAOD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
1
+ {"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAmB1D,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AAgBjD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,GAAG,MAAM,CAmCT;AAWD,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAGD,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAajC,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAEjD;AAGD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAUD,wBAAsB,cAAc,CAAC,OAAO,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiClE;AAUD,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxE;AAYD,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAarD;AAOD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -1,7 +1,33 @@
1
+ import createDebug from "debug";
2
+ import pkg from "../package.json" with { type: "json" };
1
3
  import { readCache, writeCache } from "./update-cache.js";
2
4
  import { PLUGIN_VERSION } from "./version.js";
3
- const NPM_PACKAGE_NAME = "@masons/agent-network";
4
- const NPM_REGISTRY_URL = `https://registry.npmjs.org/${NPM_PACKAGE_NAME}/latest`;
5
+ const dbg = createDebug("agent-network:update-check");
6
+ export const NPM_PACKAGE_NAME = pkg.name;
7
+ const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
8
+ export function resolveRegistryBase(pkgLike) {
9
+ const configured = pkgLike.publishConfig?.registry;
10
+ if (configured === undefined)
11
+ return DEFAULT_NPM_REGISTRY;
12
+ if (typeof configured !== "string") {
13
+ dbg("publishConfig.registry is not a string — using %s", DEFAULT_NPM_REGISTRY);
14
+ return DEFAULT_NPM_REGISTRY;
15
+ }
16
+ let parsed;
17
+ try {
18
+ parsed = new URL(configured);
19
+ }
20
+ catch {
21
+ dbg("publishConfig.registry %s is not a valid URL — using %s", configured, DEFAULT_NPM_REGISTRY);
22
+ return DEFAULT_NPM_REGISTRY;
23
+ }
24
+ if (parsed.protocol !== "https:") {
25
+ dbg("publishConfig.registry %s is not https — using %s", configured, DEFAULT_NPM_REGISTRY);
26
+ return DEFAULT_NPM_REGISTRY;
27
+ }
28
+ return configured.replace(/\/+$/, "");
29
+ }
30
+ const NPM_REGISTRY_URL = `${resolveRegistryBase(pkg)}/${NPM_PACKAGE_NAME}/latest`;
5
31
  const CHECK_INTERVAL_MS = 86_400_000;
6
32
  const FETCH_TIMEOUT_MS = 5_000;
7
33
  let updateInfo = null;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PLUGIN_VERSION = "0.6.25";
1
+ export declare const PLUGIN_VERSION = "0.6.27";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const PLUGIN_VERSION = "0.6.25";
1
+ export const PLUGIN_VERSION = "0.6.27";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masons/agent-network",
3
- "version": "0.6.25",
3
+ "version": "0.6.27",
4
4
  "description": "MASONS Agent Network — OpenClaw channel plugin for connecting agent runtimes to the Agent Network over MSTP.",
5
5
  "license": "MIT",
6
6
  "author": "MASONS.ai <hello@masons.ai> (https://masons.ai)",
@@ -71,10 +71,6 @@
71
71
  "types": "./dist/platform-client.d.ts",
72
72
  "default": "./dist/platform-client.js"
73
73
  },
74
- "./runtime-endpoint": {
75
- "types": "./dist/runtime-endpoint-client.d.ts",
76
- "default": "./dist/runtime-endpoint-client.js"
77
- },
78
74
  "./handoff": {
79
75
  "types": "./dist/handoff.d.ts",
80
76
  "default": "./dist/handoff.js"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agent-network
3
- description: "Connects to the agent network through MASONS and enables real-time communication between AI agents. Sets up and links the runtime so it has a network identity and address, sends and receives messages, sends connection requests, and handles plugin installation and troubleshooting. Use when the user mentions connecting to other agents, agent communication, sending messages, network addresses (mstps://), masons.ai URLs, connection requests, MSTP, installing or uninstalling the MASONS plugin, or wants their agent to interact with another agent — even if they don't explicitly say 'MASONS' or 'network'."
3
+ description: "Connects to the agent network through MASONS and enables real-time communication between AI agents. Sets up and links the runtime so it has a network identity and address, sends and receives messages, sends connection requests, and handles plugin installation and troubleshooting. Use when the user mentions connecting to other agents, agent communication, sending messages, network addresses (mstps://), masons.ai URLs, connection requests, MSTP, 'relink' or 're-link' or '重新链接', linking or 绑定 an Agent Node / MASONS / 网络 / the network, installing or uninstalling the MASONS plugin, or wants their agent to interact with another agent — even if they don't explicitly say 'MASONS' or 'network'."
4
4
  metadata:
5
5
  openclaw:
6
6
  emoji: "🌐"
@@ -94,6 +94,8 @@ The browser handoff page lets the owner sign in, select or create an agent, and
94
94
  After completion:
95
95
 
96
96
  1. Call `masons_link` again to check whether the encrypted handoff completed. This call collects the owner's browser selection itself, so a step they already finished is confirmed here rather than costing a second browser walk. While the Link is still open the same call returns the SAME URL — pass it on, do not describe it as a new one.
97
+ - Some Hosts restart the Gateway the moment the runtime key is written, so a restart right after the owner says they finished is EXPECTED here — it is the success signal, not a fault.
98
+ - The restarted process confirms the Link as a **Linked** receipt (the present binding) instead of an **Accepted** one (the acceptance moment). Both mean the Link succeeded: relay it and move on, never re-issue a URL.
97
99
  2. If `masons_link` reports the Link completed, restart the Gateway to activate realtime messaging:
98
100
  - Prefer the host `gateway` tool with `action`: `"restart"` and `reason`: `"Activate Agent Network after Link"`.
99
101
  - If the `gateway` tool is unavailable, tell the user to run `openclaw gateway restart`.
@@ -106,8 +108,8 @@ After completion:
106
108
 
107
109
  ### Errors
108
110
 
109
- - If `masons_link` reports the Link expired or failed, that session is over: call `masons_link` again in this conversation and it issues a fresh Link URL. Do not offer the terminal on a first failure.
110
- - If `masons_link` reports the Link completed and the user wants to re-link or change Node, call it with `start_over: true` — a plain call re-reports the completed result.
111
+ - If `masons_link` reports the Link expired or failed, that session is over: call `masons_link` again in this conversation. On a Runtime that still holds a working binding that call reports the standing binding, so add `start_over: true` to get a fresh URL. Do not offer the terminal on a first failure.
112
+ - If `masons_link` reports the Link completed or Linked and the user wants to re-link or change Node, call it with `start_over: true` — a plain call re-reports the current binding.
111
113
  - Only after Link has failed here repeatedly, name `openclaw channels login --channel agent-network` as the last resort, and say so.
112
114
  - If any other tool returns an error, explain it simply and suggest next steps.
113
115
  - If the CLI says a handle is rejected or taken, ask the user to retry and choose a different handle.
@@ -1,97 +0,0 @@
1
- import { PlatformApiError, type PlatformClientConfig } from "./platform-client.js";
2
- export { PlatformApiError, type PlatformClientConfig };
3
- export type RuntimeKind = "claude-code" | "openclaw" | "codex" | "passport" | "custom" | (string & {});
4
- export type RuntimeEndpointCapability = "remote_spawn_v1" | "background_exchange_v1" | "foreground_channel_v1" | (string & {});
5
- export type EndpointExecutionSurface = "owner_attached" | "headless" | (string & {});
6
- export type EndpointBackgroundExchangeMode = "resident_endpoint" | "adapter_managed_turn" | (string & {});
7
- export type RuntimeWorkTargetRef = {
8
- kind: "projection_endpoint";
9
- projection_endpoint_id: string;
10
- background_exchange_mode: "resident_endpoint";
11
- } | {
12
- kind: "projection_endpoint";
13
- projection_endpoint_id: string;
14
- runtime_session_id: string;
15
- background_exchange_mode: "adapter_managed_turn";
16
- };
17
- export interface WorkspaceMetadata {
18
- root: string;
19
- cwd: string;
20
- remote?: string;
21
- branch?: string;
22
- }
23
- export type ShareWithPeerField = "workspace" | "tracking_ref" | "fingerprint" | (string & {});
24
- export interface RegisterRuntimeEndpointParams {
25
- as?: string;
26
- runtime_kind: RuntimeKind;
27
- runtime_session_id?: string;
28
- endpoint_nonce: string;
29
- display_label: string;
30
- workspace?: WorkspaceMetadata;
31
- tracking_ref?: string;
32
- runtime_capabilities?: RuntimeEndpointCapability[];
33
- execution_surface?: EndpointExecutionSurface;
34
- background_exchange_mode?: EndpointBackgroundExchangeMode;
35
- share_with_peer?: ShareWithPeerField[];
36
- }
37
- export interface RegisterRuntimeEndpointResponse {
38
- endpoint_id: string;
39
- node_id: string;
40
- display_label: string;
41
- runtime_capabilities?: RuntimeEndpointCapability[];
42
- execution_surface?: EndpointExecutionSurface;
43
- background_exchange_mode?: EndpointBackgroundExchangeMode;
44
- heartbeat_after_seconds: number;
45
- lease_ttl_seconds: number;
46
- soft_retention_seconds: number;
47
- registered_at: string;
48
- }
49
- export interface OwnedRuntimeEndpointView {
50
- endpoint_id: string;
51
- node_id: string;
52
- node_handle?: string;
53
- runtime_kind: RuntimeKind;
54
- runtime_session_id?: string;
55
- display_label: string;
56
- workspace?: WorkspaceMetadata;
57
- tracking_ref?: string;
58
- fingerprint?: {
59
- workspace_hash_per_peer?: Record<string, string>;
60
- };
61
- runtime_capabilities?: RuntimeEndpointCapability[];
62
- execution_surface?: EndpointExecutionSurface;
63
- background_exchange_mode?: EndpointBackgroundExchangeMode;
64
- runtime_work_target_ref?: RuntimeWorkTargetRef;
65
- registered_at: string;
66
- retired_at?: string;
67
- is_self: boolean;
68
- }
69
- export interface ListOwnedRuntimeEndpointsResponse {
70
- total: number;
71
- items: OwnedRuntimeEndpointView[];
72
- }
73
- export type HeartbeatRuntimeEndpointResponse = Record<string, unknown>;
74
- export type UnregisterRuntimeEndpointResponse = Record<string, unknown>;
75
- export interface TransitionRuntimeEndpointStateParams {
76
- state: "active" | "reconnecting" | "closed";
77
- reason: string;
78
- ts: string;
79
- }
80
- export type TransitionRuntimeEndpointStateResponse = Record<string, unknown>;
81
- export declare function registerRuntimeEndpoint(cfg: PlatformClientConfig, runtimeKey: string, params: RegisterRuntimeEndpointParams): Promise<RegisterRuntimeEndpointResponse>;
82
- export declare function heartbeatRuntimeEndpoint(cfg: PlatformClientConfig, runtimeKey: string, endpointId: string): Promise<HeartbeatRuntimeEndpointResponse>;
83
- export declare function transitionRuntimeEndpointState(cfg: PlatformClientConfig, runtimeKey: string, endpointId: string, params: TransitionRuntimeEndpointStateParams): Promise<TransitionRuntimeEndpointStateResponse>;
84
- export declare function unregisterRuntimeEndpoint(cfg: PlatformClientConfig, runtimeKey: string, endpointId: string, asNodeId?: string): Promise<UnregisterRuntimeEndpointResponse>;
85
- export declare function listOwnedRuntimeEndpoints(cfg: PlatformClientConfig, runtimeKey: string, asNodeId: string): Promise<ListOwnedRuntimeEndpointsResponse>;
86
- export declare function getOwnedRuntimeEndpoint(cfg: PlatformClientConfig, runtimeKey: string, endpointId: string, asNodeId: string): Promise<OwnedRuntimeEndpointView>;
87
- export declare function emitRuntimeUndispatchedChanged(cfg: PlatformClientConfig, runtimeKey: string, event: Readonly<Record<string, unknown>>): Promise<EmitUndispatchedChangedOutcome>;
88
- export type EmitUndispatchedChangedOutcome = {
89
- ok: true;
90
- } | {
91
- ok: false;
92
- terminal: boolean;
93
- status?: number;
94
- detail?: string;
95
- };
96
- export declare function emitRuntimeNetworkPresenceChanged(cfg: PlatformClientConfig, runtimeKey: string, event: Readonly<Record<string, unknown>>): Promise<EmitUndispatchedChangedOutcome>;
97
- //# sourceMappingURL=runtime-endpoint-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-endpoint-client.d.ts","sourceRoot":"","sources":["../src/runtime-endpoint-client.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,gBAAgB,EAChB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,CAAC;AAmBvD,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,UAAU,GACV,OAAO,GACP,UAAU,GACV,QAAQ,GACR,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,yBAAyB,GACjC,iBAAiB,GACjB,wBAAwB,GACxB,uBAAuB,GACvB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,wBAAwB,GAChC,gBAAgB,GAChB,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,8BAA8B,GACtC,mBAAmB,GACnB,sBAAsB,GACtB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAC5B;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wBAAwB,EAAE,mBAAmB,CAAC;CAC/C,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,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,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACvC,OAAO,CAAC,8BAA8B,CAAC,CAkCzC"}
@@ -1,163 +0,0 @@
1
- import { apiFetch, PlatformApiError, } from "./platform-client.js";
2
- export { PlatformApiError };
3
- function baseUrl(cfg) {
4
- const trimmed = cfg.apiHost.replace(/\/+$/, "");
5
- const origin = /^https?:\/\//.test(trimmed) ? trimmed : `https://${trimmed}`;
6
- return `${origin}/v1`;
7
- }
8
- async function handleError(res) {
9
- const body = (await res.json().catch(() => ({})));
10
- const code = typeof body.error === "string" ? body.error : "unknown";
11
- const message = typeof body.message === "string" ? body.message : res.statusText;
12
- throw new PlatformApiError(res.status, code, message);
13
- }
14
- function authHeaders(runtimeKey) {
15
- return { Authorization: `Bearer ${runtimeKey}` };
16
- }
17
- function jsonHeaders(runtimeKey) {
18
- return {
19
- ...authHeaders(runtimeKey),
20
- "Content-Type": "application/json",
21
- };
22
- }
23
- export async function registerRuntimeEndpoint(cfg, runtimeKey, params) {
24
- const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints`, {
25
- method: "POST",
26
- headers: jsonHeaders(runtimeKey),
27
- body: JSON.stringify(params),
28
- });
29
- if (!res.ok)
30
- return handleError(res);
31
- return (await res.json());
32
- }
33
- export async function heartbeatRuntimeEndpoint(cfg, runtimeKey, endpointId) {
34
- const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}/heartbeat`, {
35
- method: "POST",
36
- headers: authHeaders(runtimeKey),
37
- });
38
- if (!res.ok)
39
- return handleError(res);
40
- return ((await res.json().catch(() => ({}))) ??
41
- {});
42
- }
43
- export async function transitionRuntimeEndpointState(cfg, runtimeKey, endpointId, params) {
44
- const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}/state`, {
45
- method: "POST",
46
- headers: jsonHeaders(runtimeKey),
47
- body: JSON.stringify(params),
48
- });
49
- if (!res.ok)
50
- return handleError(res);
51
- return ((await res.json().catch(() => ({}))) ??
52
- {});
53
- }
54
- export async function unregisterRuntimeEndpoint(cfg, runtimeKey, endpointId, asNodeId) {
55
- const query = asNodeId
56
- ? `?${new URLSearchParams({ as: asNodeId }).toString()}`
57
- : "";
58
- const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}${query}`, {
59
- method: "DELETE",
60
- headers: authHeaders(runtimeKey),
61
- });
62
- if (!res.ok)
63
- return handleError(res);
64
- return ((await res.json().catch(() => ({}))) ??
65
- {});
66
- }
67
- export async function listOwnedRuntimeEndpoints(cfg, runtimeKey, asNodeId) {
68
- const query = new URLSearchParams({ as: asNodeId }).toString();
69
- const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints?${query}`, {
70
- headers: authHeaders(runtimeKey),
71
- });
72
- if (!res.ok)
73
- return handleError(res);
74
- return (await res.json());
75
- }
76
- export async function getOwnedRuntimeEndpoint(cfg, runtimeKey, endpointId, asNodeId) {
77
- const query = new URLSearchParams({ as: asNodeId }).toString();
78
- const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}?${query}`, {
79
- headers: authHeaders(runtimeKey),
80
- });
81
- if (!res.ok)
82
- return handleError(res);
83
- return (await res.json());
84
- }
85
- export async function emitRuntimeUndispatchedChanged(cfg, runtimeKey, event) {
86
- let res;
87
- try {
88
- res = await apiFetch(`${baseUrl(cfg)}/runtime/undispatched-changed`, {
89
- method: "POST",
90
- headers: jsonHeaders(runtimeKey),
91
- body: JSON.stringify(event),
92
- });
93
- }
94
- catch (err) {
95
- return {
96
- ok: false,
97
- terminal: false,
98
- detail: err instanceof Error ? err.message : String(err),
99
- };
100
- }
101
- if (res.status === 204)
102
- return { ok: true };
103
- if (res.status === 401 || res.status === 422) {
104
- return {
105
- ok: false,
106
- terminal: true,
107
- status: res.status,
108
- detail: await readErrorDetail(res),
109
- };
110
- }
111
- return {
112
- ok: false,
113
- terminal: false,
114
- status: res.status,
115
- detail: await readErrorDetail(res),
116
- };
117
- }
118
- export async function emitRuntimeNetworkPresenceChanged(cfg, runtimeKey, event) {
119
- let res;
120
- try {
121
- res = await apiFetch(`${baseUrl(cfg)}/runtime/network-presence-changed`, {
122
- method: "POST",
123
- headers: jsonHeaders(runtimeKey),
124
- body: JSON.stringify(event),
125
- });
126
- }
127
- catch (err) {
128
- return {
129
- ok: false,
130
- terminal: false,
131
- detail: err instanceof Error ? err.message : String(err),
132
- };
133
- }
134
- if (res.status === 204)
135
- return { ok: true };
136
- if (res.status === 401 || res.status === 422) {
137
- return {
138
- ok: false,
139
- terminal: true,
140
- status: res.status,
141
- detail: await readErrorDetail(res),
142
- };
143
- }
144
- return {
145
- ok: false,
146
- terminal: false,
147
- status: res.status,
148
- detail: await readErrorDetail(res),
149
- };
150
- }
151
- async function readErrorDetail(res) {
152
- try {
153
- const body = (await res.json().catch(() => null));
154
- if (!body)
155
- return undefined;
156
- const code = typeof body.error === "string" ? body.error : undefined;
157
- const message = typeof body.message === "string" ? body.message : undefined;
158
- return [code, message].filter(Boolean).join(": ") || undefined;
159
- }
160
- catch {
161
- return undefined;
162
- }
163
- }