@masons/agent-network 0.6.26 → 0.6.28
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/_vendor/runtime-adapter-client/runtime-adapter-api.d.ts.map +1 -1
- package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.js +69 -20
- package/dist/_vendor/runtime-adapter-client/types.d.ts +21 -2
- package/dist/_vendor/runtime-adapter-client/types.d.ts.map +1 -1
- package/dist/_vendor/runtime-adapter-client/types.js +1 -0
- package/dist/channel-setup.d.ts.map +1 -1
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/platform-client.d.ts +28 -0
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/platform-client.js +60 -0
- package/dist/plugin.js +2 -2
- package/dist/tools.d.ts +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +234 -7
- package/dist/update-check.d.ts +4 -0
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +28 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/openclaw.plugin.json +2 -0
- package/package.json +1 -5
- package/skills/agent-network/SKILL.md +29 -1
- package/dist/runtime-endpoint-client.d.ts +0 -97
- package/dist/runtime-endpoint-client.d.ts.map +0 -1
- package/dist/runtime-endpoint-client.js +0 -163
|
@@ -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
|
-
}
|