@masons/agent-network 0.4.0 → 0.4.2
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/plugin.d.ts.map +1 -1
- package/dist/plugin.js +10 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +91 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/agent-network/SKILL.md +4 -16
- package/skills/agent-network/references/maintenance.md +1 -8
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,IAAI,CAAC;CACnE;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;kBA4BI,iBAAiB;CAuHhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { agentNetworkChannel } from "./channel.js";
|
|
|
5
5
|
import { configureInteractive } from "./cli-setup.js";
|
|
6
6
|
import { detectPendingState, initPluginRuntime } from "./config.js";
|
|
7
7
|
import { registerTools } from "./tools.js";
|
|
8
|
+
import { getUpdateInfo } from "./update-check.js";
|
|
8
9
|
import { PLUGIN_VERSION } from "./version.js";
|
|
9
10
|
const plugin = {
|
|
10
11
|
id: "agent-network",
|
|
@@ -120,6 +121,15 @@ const plugin = {
|
|
|
120
121
|
"Always try these tools first for network operations. " +
|
|
121
122
|
"If a tool call fails or a tool is not available, report the error to the user — do not silently work around it.";
|
|
122
123
|
}
|
|
124
|
+
// Post-upgrade verification: if an update is still available after
|
|
125
|
+
// a gateway restart, the previous upgrade attempt may have failed.
|
|
126
|
+
const updateInfo = getUpdateInfo();
|
|
127
|
+
if (updateInfo?.updateAvailable) {
|
|
128
|
+
const upgradeHint = ` Plugin update to v${updateInfo.latestVersion} is available.` +
|
|
129
|
+
` Call masons_upgrade to update — it handles everything automatically.` +
|
|
130
|
+
` Do NOT search ClawHub or run manual npm/openclaw commands.`;
|
|
131
|
+
context = (context ?? "") + upgradeHint;
|
|
132
|
+
}
|
|
123
133
|
if (context) {
|
|
124
134
|
return { prependContext: context };
|
|
125
135
|
}
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAwCH,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,OAAO;IACf,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACzE;AAoCD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAsFD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAsyBhD"}
|
package/dist/tools.js
CHANGED
|
@@ -19,22 +19,38 @@
|
|
|
19
19
|
* - `masons_end_session` — DEPRECATED SHIM (one release cycle)
|
|
20
20
|
*/
|
|
21
21
|
import { Type } from "@sinclair/typebox";
|
|
22
|
-
import { clearTargetHandle, getPendingTarget, markProfileComplete, markProfileNeeded, requireApiKey, requireConversationManager, requirePlatformConfig, writeCredentials, } from "./config.js";
|
|
22
|
+
import { clearTargetHandle, getOpenClawHome, getPendingTarget, markProfileComplete, markProfileNeeded, requireApiKey, requireConversationManager, requirePlatformConfig, writeCredentials, } from "./config.js";
|
|
23
23
|
import { acceptRequest, declineRequest, getConnectionStatus, initSetup, listConnections, listRequests, onboard, PlatformApiError, pollSetup, reconnect, requestConnection, SetupExpiredError, SetupPendingError, updateProfile, } from "./platform-client.js";
|
|
24
|
-
import { getUpdateInfo } from "./update-check.js";
|
|
24
|
+
import { fetchLatestVersion, getPluginVersion, getUpdateInfo, } from "./update-check.js";
|
|
25
25
|
// ---------------------------------------------------------------------------
|
|
26
26
|
// Constants
|
|
27
27
|
// ---------------------------------------------------------------------------
|
|
28
28
|
/** Accepted field names for masons_update_profile — reject anything else. */
|
|
29
29
|
const PROFILE_FIELDS = new Set(["name", "scope", "about", "audience"]);
|
|
30
|
+
/** CLI command to update the plugin via OpenClaw. */
|
|
31
|
+
const UPGRADE_CMD = "openclaw plugins update agent-network";
|
|
32
|
+
/** Fallback: remove + fresh install. `{version}` is replaced at runtime. */
|
|
33
|
+
const FALLBACK_UPGRADE_CMD = "rm -rf {home}/extensions/agent-network && openclaw plugins install @masons/agent-network@{version}";
|
|
34
|
+
/** CLI command to restart the gateway. */
|
|
35
|
+
const GATEWAY_RESTART_CMD = "openclaw gateway restart";
|
|
36
|
+
/** Simple semver regex — validates x.y.z before inserting into shell commands. */
|
|
37
|
+
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
30
38
|
// ---------------------------------------------------------------------------
|
|
31
39
|
// Module-level state (not persisted across process restarts)
|
|
32
40
|
// ---------------------------------------------------------------------------
|
|
33
41
|
let storedSetupToken = null;
|
|
42
|
+
/**
|
|
43
|
+
* Tracks the version we already tried to upgrade to this session.
|
|
44
|
+
* null = no attempt yet. Set to the target version string on the first
|
|
45
|
+
* normal-path attempt. If the tool is called again while current version
|
|
46
|
+
* still differs, the fallback path is returned instead.
|
|
47
|
+
*/
|
|
48
|
+
let upgradeAttemptedVersion = null;
|
|
34
49
|
/** @internal Reset module state for test isolation. */
|
|
35
50
|
export function _resetToolsForTesting() {
|
|
36
51
|
storedSetupToken = null;
|
|
37
52
|
updateNoticeShown = false;
|
|
53
|
+
upgradeAttemptedVersion = null;
|
|
38
54
|
}
|
|
39
55
|
// ---------------------------------------------------------------------------
|
|
40
56
|
// Format helpers
|
|
@@ -60,9 +76,7 @@ function maybeAppendUpdateNotice(result) {
|
|
|
60
76
|
if (last?.type === "text") {
|
|
61
77
|
last.text +=
|
|
62
78
|
`\n\n[Update available: v${info.latestVersion} (current: v${info.currentVersion}).` +
|
|
63
|
-
`
|
|
64
|
-
` — then restart using the gateway tool.` +
|
|
65
|
-
` IMPORTANT: "plugins" is plural. Do NOT use "plugin" (singular), "install", or "npm install".]`;
|
|
79
|
+
` Call \`masons_upgrade\` to update.]`;
|
|
66
80
|
}
|
|
67
81
|
return result;
|
|
68
82
|
}
|
|
@@ -613,6 +627,78 @@ export function registerTools(api) {
|
|
|
613
627
|
return textResult("Conversation ended.");
|
|
614
628
|
}),
|
|
615
629
|
});
|
|
630
|
+
// --- masons_upgrade -------------------------------------------------------
|
|
631
|
+
api.registerTool({
|
|
632
|
+
name: "masons_upgrade",
|
|
633
|
+
description: "Check for and install plugin updates. This is the ONLY correct way to upgrade — do not use ClawHub or manual npm commands.",
|
|
634
|
+
parameters: Type.Object({}),
|
|
635
|
+
// NOT wrapped with withUpdateNotice — this tool IS the upgrade path.
|
|
636
|
+
// Wrapping would create a circular reference in the update notice text.
|
|
637
|
+
execute: async () => {
|
|
638
|
+
const currentVersion = getPluginVersion();
|
|
639
|
+
// 1. Determine latest version.
|
|
640
|
+
// Normal path: use cached getUpdateInfo() (populated at startup).
|
|
641
|
+
// Fallback path (upgradeAttemptedVersion set): bypass cache, fetch directly.
|
|
642
|
+
let latestVersion = null;
|
|
643
|
+
if (upgradeAttemptedVersion !== null) {
|
|
644
|
+
// Previous attempt didn't succeed — fetch directly to bypass stale cache.
|
|
645
|
+
latestVersion = await fetchLatestVersion();
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
const info = getUpdateInfo();
|
|
649
|
+
if (info) {
|
|
650
|
+
latestVersion = info.latestVersion;
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
// No cached info (startup check didn't run or failed) — fetch directly.
|
|
654
|
+
latestVersion = await fetchLatestVersion();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// 2. Network error — can't determine latest version.
|
|
658
|
+
if (!latestVersion) {
|
|
659
|
+
return textResult("Could not check for updates (network issue). Try again later.");
|
|
660
|
+
}
|
|
661
|
+
// 3. Already up to date.
|
|
662
|
+
if (latestVersion === currentVersion) {
|
|
663
|
+
upgradeAttemptedVersion = null; // Reset on success
|
|
664
|
+
return textResult(`You're on the latest version (v${currentVersion}). No update needed.`);
|
|
665
|
+
}
|
|
666
|
+
// 4. Semver validation — never insert unvalidated strings into shell commands.
|
|
667
|
+
if (!SEMVER_RE.test(latestVersion)) {
|
|
668
|
+
return textResult(`Registry returned an unexpected version format: "${latestVersion}". Try again later.`);
|
|
669
|
+
}
|
|
670
|
+
// 5. Determine path: normal vs fallback.
|
|
671
|
+
const useFallback = upgradeAttemptedVersion === latestVersion;
|
|
672
|
+
if (useFallback) {
|
|
673
|
+
// Fallback path — previous normal-path attempt for this version didn't work.
|
|
674
|
+
upgradeAttemptedVersion = null; // Reset so next call starts fresh
|
|
675
|
+
const home = getOpenClawHome();
|
|
676
|
+
const fallbackCmd = FALLBACK_UPGRADE_CMD.replace("{home}", home).replace("{version}", latestVersion);
|
|
677
|
+
return textResult([
|
|
678
|
+
`Update to v${latestVersion} — using alternative method (previous attempt may have failed).`,
|
|
679
|
+
"",
|
|
680
|
+
"Run this command using the exec tool:",
|
|
681
|
+
fallbackCmd,
|
|
682
|
+
"",
|
|
683
|
+
`Then restart the gateway using the gateway tool.`,
|
|
684
|
+
`If you cannot run commands, tell the user to run in Terminal:`,
|
|
685
|
+
`${fallbackCmd} && ${GATEWAY_RESTART_CMD}`,
|
|
686
|
+
].join("\n"));
|
|
687
|
+
}
|
|
688
|
+
// Normal path — first attempt for this version.
|
|
689
|
+
upgradeAttemptedVersion = latestVersion;
|
|
690
|
+
return textResult([
|
|
691
|
+
`Update available: v${currentVersion} → v${latestVersion}`,
|
|
692
|
+
"",
|
|
693
|
+
"Run this command using the exec tool:",
|
|
694
|
+
UPGRADE_CMD,
|
|
695
|
+
"",
|
|
696
|
+
"Then restart the gateway using the gateway tool.",
|
|
697
|
+
"If you cannot run commands, tell the user to run in Terminal:",
|
|
698
|
+
`${UPGRADE_CMD} && ${GATEWAY_RESTART_CMD}`,
|
|
699
|
+
].join("\n"));
|
|
700
|
+
},
|
|
701
|
+
});
|
|
616
702
|
// =========================================================================
|
|
617
703
|
// DEPRECATED SHIMS — kept for one release cycle for backward compatibility
|
|
618
704
|
// =========================================================================
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Plugin version — must match package.json. Validated by prepublishOnly. */
|
|
2
|
-
export const PLUGIN_VERSION = "0.4.
|
|
2
|
+
export const PLUGIN_VERSION = "0.4.2";
|
package/package.json
CHANGED
|
@@ -269,25 +269,13 @@ Incoming messages from other agents appear automatically. Each includes:
|
|
|
269
269
|
|
|
270
270
|
## Upgrade
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
**Important:** This plugin is installed via npm (`@masons/agent-network`), NOT ClawHub. Do not search ClawHub for updates.
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
When a tool output mentions an update is available, or when the user asks to upgrade:
|
|
275
275
|
|
|
276
|
-
**
|
|
276
|
+
**Say to user:** "A newer version of the agent network plugin is available. Want me to update?"
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
2. Restart the gateway (use the `gateway` tool with `action: "restart"`, or tell the user to run `openclaw gateway restart`)
|
|
280
|
-
|
|
281
|
-
**Common mistakes — do NOT use any of these:**
|
|
282
|
-
- `openclaw plugin update` — wrong: `plugin` must be **`plugins`** (plural)
|
|
283
|
-
- `openclaw plugins install` — wrong: `install` may reject with "already exists"
|
|
284
|
-
- `npm install -g @masons/agent-network` — wrong: npm global install does not register with OpenClaw
|
|
285
|
-
|
|
286
|
-
**If the command fails:** Re-read this section and verify the exact spelling. Do NOT guess alternative commands.
|
|
287
|
-
|
|
288
|
-
Your configuration, credentials, agent identity, and connections are all preserved — no setup needed after upgrade.
|
|
289
|
-
|
|
290
|
-
**Then:** If a reply is needed, call `masons_send_message` with the agent's handle.
|
|
278
|
+
**If they agree:** Call `masons_upgrade` — it handles everything automatically. Do not run manual commands.
|
|
291
279
|
|
|
292
280
|
### Connection Status
|
|
293
281
|
|
|
@@ -41,17 +41,10 @@ The user's agent identity, handle, and connections are preserved on the server
|
|
|
41
41
|
|
|
42
42
|
## Upgrade
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
1. Use the `exec` tool to run: `openclaw plugins update agent-network`
|
|
47
|
-
2. Restart using the `gateway` tool: `{ action: "restart", reason: "Apply agent-network update", note: "Agent network plugin updated." }`
|
|
48
|
-
3. **Fallback**: If the `exec` tool is not available, tell the user to run in Terminal: `openclaw plugins update agent-network`. Then restart using the `gateway` tool.
|
|
49
|
-
4. **Double fallback**: If neither `exec` nor `gateway` tool is available, tell the user to run in Terminal: `openclaw plugins update agent-network && openclaw gateway restart`
|
|
44
|
+
Call `masons_upgrade` — it checks for updates and returns the exact command to run. Follow its instructions.
|
|
50
45
|
|
|
51
46
|
The user's configuration, credentials, agent identity, and connections are all preserved. No setup needed — the new version picks up where the old one left off.
|
|
52
47
|
|
|
53
|
-
Note: Use `plugins update` (with plugin ID `agent-network`), not `plugins install` (which may reject with "already exists").
|
|
54
|
-
|
|
55
48
|
## Reinstall
|
|
56
49
|
|
|
57
50
|
To reinstall after a previous uninstall:
|