@masons/agent-network 0.5.14 → 0.5.15
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/channel.d.ts +0 -7
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +3 -174
- package/dist/cli-setup.d.ts +0 -109
- package/dist/cli-setup.d.ts.map +1 -1
- package/dist/cli-setup.js +16 -570
- package/dist/config-fs.d.ts +4 -0
- package/dist/config-fs.d.ts.map +1 -0
- package/dist/config-fs.js +23 -0
- package/dist/config-schema.js +2 -2
- package/dist/config.d.ts +2 -210
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -334
- package/dist/connector-client.d.ts +0 -32
- package/dist/connector-client.d.ts.map +1 -1
- package/dist/connector-client.js +1 -89
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -3
- package/dist/conversation-manager.d.ts +0 -106
- package/dist/conversation-manager.d.ts.map +1 -1
- package/dist/conversation-manager.js +2 -131
- package/dist/environment-context.d.ts +0 -24
- package/dist/environment-context.d.ts.map +1 -1
- package/dist/environment-context.js +0 -42
- package/dist/handle-utils.d.ts +0 -14
- package/dist/handle-utils.d.ts.map +1 -1
- package/dist/handle-utils.js +0 -14
- package/dist/index.js +0 -9
- package/dist/owner-notes.d.ts +0 -33
- package/dist/owner-notes.d.ts.map +1 -1
- package/dist/owner-notes.js +2 -41
- package/dist/owner-session-state.d.ts +0 -26
- package/dist/owner-session-state.d.ts.map +1 -1
- package/dist/owner-session-state.js +0 -37
- package/dist/platform-client.d.ts +13 -202
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/platform-client.js +22 -171
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +3 -167
- package/dist/sent-message-buffer.d.ts +0 -36
- package/dist/sent-message-buffer.d.ts.map +1 -1
- package/dist/sent-message-buffer.js +1 -45
- package/dist/tools.d.ts +0 -28
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +36 -240
- package/dist/turn-context.d.ts +0 -45
- package/dist/turn-context.d.ts.map +1 -1
- package/dist/turn-context.js +0 -57
- package/dist/types.d.ts +0 -67
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -7
- package/dist/update-cache.d.ts +0 -17
- package/dist/update-cache.d.ts.map +1 -1
- package/dist/update-cache.js +1 -21
- package/dist/update-check.d.ts +1 -40
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +7 -66
- package/dist/version.d.ts +1 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -2
- package/openclaw.plugin.json +57 -3
- package/package.json +11 -10
- package/skills/agent-network/SKILL.md +21 -47
- package/skills/agent-network/references/troubleshooting.md +5 -5
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Pure HTTP functions wrapping `/runtime/v1/*` endpoints on the connector.
|
|
5
|
-
* Zero platform dependencies — only global fetch.
|
|
6
|
-
*
|
|
7
|
-
* Used by `tools.ts` (LLM path: tool execute functions).
|
|
8
|
-
*
|
|
9
|
-
* The pre-0.5.0 setup-flow functions (`initSetup`, `pollSetup`, `listAgents`,
|
|
10
|
-
* `onboard`, `reconnect`) were deleted in this version: onboarding moves to
|
|
11
|
-
* the OAuth Device Authorization Grant flow served by Better Auth at the IdP
|
|
12
|
-
* (#1253), not via bespoke MASONS endpoints on the runtime API.
|
|
13
|
-
*/
|
|
14
|
-
/** Default API host. */
|
|
15
|
-
export declare const DEFAULT_API_HOST = "preview-connectorapi.masons.ai";
|
|
1
|
+
export declare const DEFAULT_API_HOST = "preview-api.masons.ai";
|
|
2
|
+
export declare const DEFAULT_CONNECTOR_URL = "wss://preview-connectorapi.masons.ai/gateway";
|
|
16
3
|
export interface PlatformClientConfig {
|
|
17
4
|
apiHost: string;
|
|
18
5
|
}
|
|
@@ -25,12 +12,6 @@ export interface RequestConnectionResponse {
|
|
|
25
12
|
requestIds: string[];
|
|
26
13
|
status: string;
|
|
27
14
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Wire-level NodeRef view emitted by `apps/connector` on Connection
|
|
30
|
-
* responses (per `human-node-capability-obligations.md § 2`). Plugin uses
|
|
31
|
-
* this same shape consumer-side; it intentionally mirrors the
|
|
32
|
-
* `NodeRefView` interface in `./types.ts`.
|
|
33
|
-
*/
|
|
34
15
|
export interface ConnectionNodeRef {
|
|
35
16
|
kind: string;
|
|
36
17
|
mstpAddress: string;
|
|
@@ -38,31 +19,10 @@ export interface ConnectionNodeRef {
|
|
|
38
19
|
displayName?: string;
|
|
39
20
|
avatarUrl?: string;
|
|
40
21
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Back-compat counterparty shape on `ListRequestsItem.fromAgent` /
|
|
43
|
-
* `ListRequestsItem.toAgent`. Connector emits `{ handle, name }` only on
|
|
44
|
-
* these (per `apps/connector/src/routes/runtime/v1/connections/requests/`,
|
|
45
|
-
* NodeRef enrichment lives in `fromNode` / `toNode` instead). Marked
|
|
46
|
-
* `@deprecated` since #1450 Phase 1 — readers prefer `fromNode` / `toNode`.
|
|
47
|
-
*/
|
|
48
|
-
export interface BackCompatAgent {
|
|
49
|
-
handle: string;
|
|
50
|
-
name: string;
|
|
51
|
-
}
|
|
52
22
|
export interface ListRequestsItem {
|
|
53
23
|
id: string;
|
|
54
24
|
direction: "incoming" | "outgoing";
|
|
55
|
-
/** @deprecated since #1450 Phase 1 — use `fromNode` (NodeRef shape). */
|
|
56
|
-
fromAgent?: BackCompatAgent;
|
|
57
|
-
/** @deprecated since #1450 Phase 1 — use `toNode` (NodeRef shape). */
|
|
58
|
-
toAgent?: BackCompatAgent;
|
|
59
|
-
/** Present for incoming requests — the sender Node, NodeRef shape per
|
|
60
|
-
* `human-node-capability-obligations.md § 2`. Connector emits this
|
|
61
|
-
* alongside `fromAgent` since #1450 Phase 1. May be `null` when the
|
|
62
|
-
* Connector ran NodeRef enrichment but the entity record is missing. */
|
|
63
25
|
fromNode?: ConnectionNodeRef | null;
|
|
64
|
-
/** Present for outgoing requests — the target Node, NodeRef shape.
|
|
65
|
-
* Connector emits this alongside `toAgent` since #1450 Phase 1. */
|
|
66
26
|
toNode?: ConnectionNodeRef | null;
|
|
67
27
|
variant: string;
|
|
68
28
|
status: string;
|
|
@@ -79,15 +39,7 @@ export interface ListRequestsResponse {
|
|
|
79
39
|
}
|
|
80
40
|
export interface AcceptRequestResponse {
|
|
81
41
|
status: "accepted";
|
|
82
|
-
|
|
83
|
-
connection: {
|
|
84
|
-
handle: string;
|
|
85
|
-
name: string;
|
|
86
|
-
};
|
|
87
|
-
/** Counterparty NodeRef per `human-node-capability-obligations.md § 2`.
|
|
88
|
-
* Connector emits this alongside `connection` since #1450 Phase 1. May
|
|
89
|
-
* be `null` when enrichment fails. */
|
|
90
|
-
counterparty?: ConnectionNodeRef | null;
|
|
42
|
+
counterparty: ConnectionNodeRef | null;
|
|
91
43
|
}
|
|
92
44
|
export interface DeclineRequestResponse {
|
|
93
45
|
status: "declined";
|
|
@@ -109,165 +61,24 @@ export interface UpdateProfileResponse {
|
|
|
109
61
|
}
|
|
110
62
|
export interface ListConnectionsResponse {
|
|
111
63
|
total: number;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/** @deprecated since #1450 Phase 1 — use `counterparty.mstpAddress`. */
|
|
117
|
-
address: string;
|
|
118
|
-
/** Counterparty NodeRef per `human-node-capability-obligations.md § 2`.
|
|
119
|
-
* Connector emits this alongside `name + address` since #1450
|
|
120
|
-
* Phase 1. Plugin renderer prefers `counterparty.kind` /
|
|
121
|
-
* `displayName` over the legacy fields when present; falls back to
|
|
122
|
-
* `name + address` for back-compat with older Connector versions. */
|
|
123
|
-
counterparty?: ConnectionNodeRef | null;
|
|
64
|
+
connections: Array<{
|
|
65
|
+
counterparty: ConnectionNodeRef;
|
|
66
|
+
access: "mutual" | "outbound" | "inbound" | string;
|
|
67
|
+
createdAt: string | null;
|
|
124
68
|
}>;
|
|
125
69
|
}
|
|
126
|
-
export
|
|
127
|
-
status: "connected" | "pending" | "not_connected";
|
|
128
|
-
canCreateSession: boolean;
|
|
129
|
-
}
|
|
130
|
-
/** Successful onboard — returned by all three branches. */
|
|
131
|
-
export interface OnboardSuccess {
|
|
132
|
-
apiKey: string;
|
|
133
|
-
connectorUrl: string;
|
|
134
|
-
agentId: string;
|
|
135
|
-
handle: string;
|
|
136
|
-
}
|
|
137
|
-
export interface OnboardAgentSummary {
|
|
138
|
-
id: string;
|
|
139
|
-
handle: string;
|
|
140
|
-
name: string;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* 422 agent_required — user owns multiple agents and didn't pick one.
|
|
144
|
-
* Plugin should prompter.select() from `agents` and re-call with `{agentId}`.
|
|
145
|
-
*/
|
|
146
|
-
export interface OnboardAgentRequiredError {
|
|
147
|
-
status: 422;
|
|
148
|
-
code: "agent_required";
|
|
149
|
-
agents: OnboardAgentSummary[];
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* 412 no_agents — user owns zero agents. Plugin should prompt for handle
|
|
153
|
-
* and re-call with `{create: {handle}}`.
|
|
154
|
-
*/
|
|
155
|
-
export interface OnboardNoAgentsError {
|
|
156
|
-
status: 412;
|
|
157
|
-
code: "no_agents";
|
|
158
|
-
message: string;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* 409 handle_taken — handle conflict in create branch. Plugin should
|
|
162
|
-
* re-prompt for a different handle.
|
|
163
|
-
*/
|
|
164
|
-
export interface OnboardHandleTakenError {
|
|
165
|
-
status: 409;
|
|
166
|
-
code: "handle_taken";
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* 422 invalid_handle — handle failed server-side validation. Plugin should
|
|
170
|
-
* surface the message and re-prompt.
|
|
171
|
-
*/
|
|
172
|
-
export interface OnboardInvalidHandleError {
|
|
173
|
-
status: 422;
|
|
174
|
-
code: "invalid_handle";
|
|
175
|
-
message: string;
|
|
176
|
-
}
|
|
177
|
-
/** Body shape for the onboard endpoint. */
|
|
178
|
-
export type OnboardBody = Record<string, never> | {
|
|
179
|
-
agentId: string;
|
|
180
|
-
} | {
|
|
181
|
-
create: {
|
|
182
|
-
handle: string;
|
|
183
|
-
name?: string;
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Result discriminator. `kind: "ok"` carries the credentials; `kind: "error"`
|
|
188
|
-
* surfaces structured errors the plugin must handle in its CLI prompter loop
|
|
189
|
-
* (no-agents → prompt handle; agent-required → prompt picker; handle-taken
|
|
190
|
-
* → re-prompt; invalid-handle → re-prompt).
|
|
191
|
-
*
|
|
192
|
-
* Other failure shapes (401, 403, 404, 500) are thrown as `PlatformApiError`.
|
|
193
|
-
*/
|
|
194
|
-
export type OnboardResult = {
|
|
195
|
-
kind: "ok";
|
|
196
|
-
data: OnboardSuccess;
|
|
197
|
-
} | {
|
|
198
|
-
kind: "error";
|
|
199
|
-
data: OnboardAgentRequiredError | OnboardNoAgentsError | OnboardHandleTakenError | OnboardInvalidHandleError;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* `POST /connections/requests` — Send a connection request.
|
|
203
|
-
*
|
|
204
|
-
* Requires API Key in Authorization header.
|
|
205
|
-
* Idempotent: returns 201 with empty requestIds if already connected.
|
|
206
|
-
*/
|
|
207
|
-
export declare function requestConnection(cfg: PlatformClientConfig, apiKey: string, params: {
|
|
70
|
+
export declare function requestConnection(cfg: PlatformClientConfig, runtimeKey: string, params: {
|
|
208
71
|
targetHandle: string;
|
|
209
72
|
variants: ("distribute" | "receive")[];
|
|
210
73
|
}): Promise<RequestConnectionResponse>;
|
|
211
|
-
|
|
212
|
-
* `GET /connections/requests` — List connection requests.
|
|
213
|
-
*
|
|
214
|
-
* Requires API Key in Authorization header.
|
|
215
|
-
* @param params.direction - "incoming" (default), "outgoing", or "all"
|
|
216
|
-
*/
|
|
217
|
-
export declare function listRequests(cfg: PlatformClientConfig, apiKey: string, params?: {
|
|
74
|
+
export declare function listRequests(cfg: PlatformClientConfig, runtimeKey: string, params?: {
|
|
218
75
|
status?: string;
|
|
219
76
|
direction?: string;
|
|
220
77
|
page?: number;
|
|
221
78
|
limit?: number;
|
|
222
79
|
}): Promise<ListRequestsResponse>;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*/
|
|
228
|
-
export declare function acceptRequest(cfg: PlatformClientConfig, apiKey: string, requestId: string): Promise<AcceptRequestResponse>;
|
|
229
|
-
/**
|
|
230
|
-
* `POST /connections/requests/{id}/decline` — Decline a connection request.
|
|
231
|
-
*
|
|
232
|
-
* Requires API Key in Authorization header.
|
|
233
|
-
*/
|
|
234
|
-
export declare function declineRequest(cfg: PlatformClientConfig, apiKey: string, requestId: string): Promise<DeclineRequestResponse>;
|
|
235
|
-
/**
|
|
236
|
-
* `PATCH /me/profile` — Update the calling agent's profile.
|
|
237
|
-
*
|
|
238
|
-
* Requires API Key in Authorization header.
|
|
239
|
-
* Accepts partial updates — only provided fields are changed.
|
|
240
|
-
*/
|
|
241
|
-
export declare function updateProfile(cfg: PlatformClientConfig, apiKey: string, params: UpdateProfileParams): Promise<UpdateProfileResponse>;
|
|
242
|
-
/**
|
|
243
|
-
* `GET /connections` — List established connections for the calling agent.
|
|
244
|
-
*
|
|
245
|
-
* Requires API Key in Authorization header.
|
|
246
|
-
* Returns name + MSTP address for each connected agent.
|
|
247
|
-
*/
|
|
248
|
-
export declare function listConnections(cfg: PlatformClientConfig, apiKey: string): Promise<ListConnectionsResponse>;
|
|
249
|
-
/**
|
|
250
|
-
* `POST /onboard` — bind a device-class client to an agent.
|
|
251
|
-
*
|
|
252
|
-
* Three branches selected by body shape (#1264):
|
|
253
|
-
* - `{}` → list / auto-pick
|
|
254
|
-
* - `{agentId}` → select existing (rotates api_key)
|
|
255
|
-
* - `{create: {handle, name?}}` → mint new agent
|
|
256
|
-
*
|
|
257
|
-
* Auth: Bearer access_token from Better Auth's device-authorization plugin.
|
|
258
|
-
*
|
|
259
|
-
* Returns `{kind: "ok", data}` on 200. Returns `{kind: "error", data}` for
|
|
260
|
-
* the four structured errors the CLI prompter loop must handle. All other
|
|
261
|
-
* non-2xx responses throw `PlatformApiError`.
|
|
262
|
-
*/
|
|
263
|
-
export declare function onboard(cfg: PlatformClientConfig, sessionToken: string, body: OnboardBody): Promise<OnboardResult>;
|
|
264
|
-
/**
|
|
265
|
-
* `GET /connections/status?target={handle}` — Check connection status.
|
|
266
|
-
*
|
|
267
|
-
* Requires API Key in Authorization header.
|
|
268
|
-
* Returns connection status and whether session creation is possible.
|
|
269
|
-
*
|
|
270
|
-
* Returns null if the request fails (advisory — caller should degrade gracefully).
|
|
271
|
-
*/
|
|
272
|
-
export declare function getConnectionStatus(cfg: PlatformClientConfig, apiKey: string, targetHandle: string): Promise<ConnectionStatusResponse | null>;
|
|
80
|
+
export declare function acceptRequest(cfg: PlatformClientConfig, runtimeKey: string, requestId: string): Promise<AcceptRequestResponse>;
|
|
81
|
+
export declare function declineRequest(cfg: PlatformClientConfig, runtimeKey: string, requestId: string): Promise<DeclineRequestResponse>;
|
|
82
|
+
export declare function updateProfile(cfg: PlatformClientConfig, runtimeKey: string, params: UpdateProfileParams): Promise<UpdateProfileResponse>;
|
|
83
|
+
export declare function listConnections(cfg: PlatformClientConfig, runtimeKey: string): Promise<ListConnectionsResponse>;
|
|
273
84
|
//# sourceMappingURL=platform-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AAGxD,eAAO,MAAM,qBAAqB,iDACc,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACnC,OAAO,E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C,qBAAqB,CAAC,CAUhC;AAOD,wBAAsB,cAAc,CAClC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,sBAAsB,CAAC,CAUjC;AAQD,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"}
|
package/dist/platform-client.js
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Pure HTTP functions wrapping `/runtime/v1/*` endpoints on the connector.
|
|
5
|
-
* Zero platform dependencies — only global fetch.
|
|
6
|
-
*
|
|
7
|
-
* Used by `tools.ts` (LLM path: tool execute functions).
|
|
8
|
-
*
|
|
9
|
-
* The pre-0.5.0 setup-flow functions (`initSetup`, `pollSetup`, `listAgents`,
|
|
10
|
-
* `onboard`, `reconnect`) were deleted in this version: onboarding moves to
|
|
11
|
-
* the OAuth Device Authorization Grant flow served by Better Auth at the IdP
|
|
12
|
-
* (#1253), not via bespoke MASONS endpoints on the runtime API.
|
|
13
|
-
*/
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Config
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
/** Default API host. */
|
|
18
|
-
export const DEFAULT_API_HOST = "preview-connectorapi.masons.ai";
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Error classes
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
1
|
+
export const DEFAULT_API_HOST = "preview-api.masons.ai";
|
|
2
|
+
export const DEFAULT_CONNECTOR_URL = "wss://preview-connectorapi.masons.ai/gateway";
|
|
22
3
|
export class PlatformApiError extends Error {
|
|
23
4
|
status;
|
|
24
5
|
code;
|
|
@@ -29,14 +10,10 @@ export class PlatformApiError extends Error {
|
|
|
29
10
|
this.name = "PlatformApiError";
|
|
30
11
|
}
|
|
31
12
|
}
|
|
32
|
-
// ---------------------------------------------------------------------------
|
|
33
|
-
// Internal helpers
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
13
|
function baseUrl(cfg) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return `https://${cfg.apiHost}/runtime/v1`;
|
|
14
|
+
const trimmed = cfg.apiHost.replace(/\/+$/, "");
|
|
15
|
+
const origin = /^https?:\/\//.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
16
|
+
return `${origin}/v1`;
|
|
40
17
|
}
|
|
41
18
|
async function handleError(res) {
|
|
42
19
|
const body = (await res.json().catch(() => ({})));
|
|
@@ -44,21 +21,12 @@ async function handleError(res) {
|
|
|
44
21
|
const message = typeof body.message === "string" ? body.message : res.statusText;
|
|
45
22
|
throw new PlatformApiError(res.status, code, message);
|
|
46
23
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
/**
|
|
51
|
-
* `POST /connections/requests` — Send a connection request.
|
|
52
|
-
*
|
|
53
|
-
* Requires API Key in Authorization header.
|
|
54
|
-
* Idempotent: returns 201 with empty requestIds if already connected.
|
|
55
|
-
*/
|
|
56
|
-
export async function requestConnection(cfg, apiKey, params) {
|
|
57
|
-
const res = await fetch(`${baseUrl(cfg)}/connections/requests`, {
|
|
24
|
+
export async function requestConnection(cfg, runtimeKey, params) {
|
|
25
|
+
const res = await fetch(`${baseUrl(cfg)}/me/connections/requests`, {
|
|
58
26
|
method: "POST",
|
|
59
27
|
headers: {
|
|
60
28
|
"Content-Type": "application/json",
|
|
61
|
-
Authorization: `Bearer ${
|
|
29
|
+
Authorization: `Bearer ${runtimeKey}`,
|
|
62
30
|
},
|
|
63
31
|
body: JSON.stringify(params),
|
|
64
32
|
});
|
|
@@ -66,13 +34,7 @@ export async function requestConnection(cfg, apiKey, params) {
|
|
|
66
34
|
return handleError(res);
|
|
67
35
|
return (await res.json());
|
|
68
36
|
}
|
|
69
|
-
|
|
70
|
-
* `GET /connections/requests` — List connection requests.
|
|
71
|
-
*
|
|
72
|
-
* Requires API Key in Authorization header.
|
|
73
|
-
* @param params.direction - "incoming" (default), "outgoing", or "all"
|
|
74
|
-
*/
|
|
75
|
-
export async function listRequests(cfg, apiKey, params) {
|
|
37
|
+
export async function listRequests(cfg, runtimeKey, params) {
|
|
76
38
|
const query = new URLSearchParams();
|
|
77
39
|
if (params?.status != null)
|
|
78
40
|
query.set("status", params.status);
|
|
@@ -83,54 +45,38 @@ export async function listRequests(cfg, apiKey, params) {
|
|
|
83
45
|
if (params?.limit != null)
|
|
84
46
|
query.set("limit", String(params.limit));
|
|
85
47
|
const qs = query.toString();
|
|
86
|
-
const url = `${baseUrl(cfg)}/connections/requests${qs ? `?${qs}` : ""}`;
|
|
48
|
+
const url = `${baseUrl(cfg)}/me/connections/requests${qs ? `?${qs}` : ""}`;
|
|
87
49
|
const res = await fetch(url, {
|
|
88
|
-
headers: { Authorization: `Bearer ${
|
|
50
|
+
headers: { Authorization: `Bearer ${runtimeKey}` },
|
|
89
51
|
});
|
|
90
52
|
if (!res.ok)
|
|
91
53
|
return handleError(res);
|
|
92
54
|
return (await res.json());
|
|
93
55
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
* Requires API Key in Authorization header.
|
|
98
|
-
*/
|
|
99
|
-
export async function acceptRequest(cfg, apiKey, requestId) {
|
|
100
|
-
const res = await fetch(`${baseUrl(cfg)}/connections/requests/${encodeURIComponent(requestId)}/accept`, {
|
|
56
|
+
export async function acceptRequest(cfg, runtimeKey, requestId) {
|
|
57
|
+
const res = await fetch(`${baseUrl(cfg)}/me/connections/requests/${encodeURIComponent(requestId)}/accept`, {
|
|
101
58
|
method: "POST",
|
|
102
|
-
headers: { Authorization: `Bearer ${
|
|
59
|
+
headers: { Authorization: `Bearer ${runtimeKey}` },
|
|
103
60
|
});
|
|
104
61
|
if (!res.ok)
|
|
105
62
|
return handleError(res);
|
|
106
63
|
return (await res.json());
|
|
107
64
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
* Requires API Key in Authorization header.
|
|
112
|
-
*/
|
|
113
|
-
export async function declineRequest(cfg, apiKey, requestId) {
|
|
114
|
-
const res = await fetch(`${baseUrl(cfg)}/connections/requests/${encodeURIComponent(requestId)}/decline`, {
|
|
65
|
+
export async function declineRequest(cfg, runtimeKey, requestId) {
|
|
66
|
+
const res = await fetch(`${baseUrl(cfg)}/me/connections/requests/${encodeURIComponent(requestId)}/decline`, {
|
|
115
67
|
method: "POST",
|
|
116
|
-
headers: { Authorization: `Bearer ${
|
|
68
|
+
headers: { Authorization: `Bearer ${runtimeKey}` },
|
|
117
69
|
});
|
|
118
70
|
if (!res.ok)
|
|
119
71
|
return handleError(res);
|
|
120
72
|
return (await res.json());
|
|
121
73
|
}
|
|
122
|
-
|
|
123
|
-
* `PATCH /me/profile` — Update the calling agent's profile.
|
|
124
|
-
*
|
|
125
|
-
* Requires API Key in Authorization header.
|
|
126
|
-
* Accepts partial updates — only provided fields are changed.
|
|
127
|
-
*/
|
|
128
|
-
export async function updateProfile(cfg, apiKey, params) {
|
|
74
|
+
export async function updateProfile(cfg, runtimeKey, params) {
|
|
129
75
|
const res = await fetch(`${baseUrl(cfg)}/me/profile`, {
|
|
130
76
|
method: "PATCH",
|
|
131
77
|
headers: {
|
|
132
78
|
"Content-Type": "application/json",
|
|
133
|
-
Authorization: `Bearer ${
|
|
79
|
+
Authorization: `Bearer ${runtimeKey}`,
|
|
134
80
|
},
|
|
135
81
|
body: JSON.stringify(params),
|
|
136
82
|
});
|
|
@@ -138,106 +84,11 @@ export async function updateProfile(cfg, apiKey, params) {
|
|
|
138
84
|
return handleError(res);
|
|
139
85
|
return (await res.json());
|
|
140
86
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
* Requires API Key in Authorization header.
|
|
145
|
-
* Returns name + MSTP address for each connected agent.
|
|
146
|
-
*/
|
|
147
|
-
export async function listConnections(cfg, apiKey) {
|
|
148
|
-
const res = await fetch(`${baseUrl(cfg)}/connections`, {
|
|
149
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
87
|
+
export async function listConnections(cfg, runtimeKey) {
|
|
88
|
+
const res = await fetch(`${baseUrl(cfg)}/me/connections`, {
|
|
89
|
+
headers: { Authorization: `Bearer ${runtimeKey}` },
|
|
150
90
|
});
|
|
151
91
|
if (!res.ok)
|
|
152
92
|
return handleError(res);
|
|
153
93
|
return (await res.json());
|
|
154
94
|
}
|
|
155
|
-
/**
|
|
156
|
-
* `POST /onboard` — bind a device-class client to an agent.
|
|
157
|
-
*
|
|
158
|
-
* Three branches selected by body shape (#1264):
|
|
159
|
-
* - `{}` → list / auto-pick
|
|
160
|
-
* - `{agentId}` → select existing (rotates api_key)
|
|
161
|
-
* - `{create: {handle, name?}}` → mint new agent
|
|
162
|
-
*
|
|
163
|
-
* Auth: Bearer access_token from Better Auth's device-authorization plugin.
|
|
164
|
-
*
|
|
165
|
-
* Returns `{kind: "ok", data}` on 200. Returns `{kind: "error", data}` for
|
|
166
|
-
* the four structured errors the CLI prompter loop must handle. All other
|
|
167
|
-
* non-2xx responses throw `PlatformApiError`.
|
|
168
|
-
*/
|
|
169
|
-
export async function onboard(cfg, sessionToken, body) {
|
|
170
|
-
const res = await fetch(`${baseUrl(cfg)}/onboard`, {
|
|
171
|
-
method: "POST",
|
|
172
|
-
headers: {
|
|
173
|
-
"Content-Type": "application/json",
|
|
174
|
-
Authorization: `Bearer ${sessionToken}`,
|
|
175
|
-
},
|
|
176
|
-
body: JSON.stringify(body),
|
|
177
|
-
});
|
|
178
|
-
if (res.ok) {
|
|
179
|
-
const data = (await res.json());
|
|
180
|
-
return { kind: "ok", data };
|
|
181
|
-
}
|
|
182
|
-
// Branch on the structured-error codes the prompter loop knows how to
|
|
183
|
-
// recover from. Anything else → throw PlatformApiError.
|
|
184
|
-
const raw = (await res.json().catch(() => ({})));
|
|
185
|
-
const code = typeof raw.error === "string" ? raw.error : "unknown";
|
|
186
|
-
const message = typeof raw.message === "string" ? raw.message : res.statusText;
|
|
187
|
-
if (res.status === 412 && code === "no_agents") {
|
|
188
|
-
return {
|
|
189
|
-
kind: "error",
|
|
190
|
-
data: { status: 412, code: "no_agents", message },
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if (res.status === 422 && code === "agent_required") {
|
|
194
|
-
const agents = Array.isArray(raw.agents)
|
|
195
|
-
? raw.agents
|
|
196
|
-
: [];
|
|
197
|
-
return {
|
|
198
|
-
kind: "error",
|
|
199
|
-
data: { status: 422, code: "agent_required", agents },
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
if (res.status === 422 && code === "invalid_handle") {
|
|
203
|
-
return {
|
|
204
|
-
kind: "error",
|
|
205
|
-
data: { status: 422, code: "invalid_handle", message },
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
if (res.status === 409 && code === "handle_taken") {
|
|
209
|
-
return {
|
|
210
|
-
kind: "error",
|
|
211
|
-
data: { status: 409, code: "handle_taken" },
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
// 401 unauthorized, 403 forbidden, 404 agent_not_found, 500 internal —
|
|
215
|
-
// these are programming errors at this stage, propagate via the standard
|
|
216
|
-
// throw path so the CLI prompter loop sees them as fatal.
|
|
217
|
-
throw new PlatformApiError(res.status, code, message);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* `GET /connections/status?target={handle}` — Check connection status.
|
|
221
|
-
*
|
|
222
|
-
* Requires API Key in Authorization header.
|
|
223
|
-
* Returns connection status and whether session creation is possible.
|
|
224
|
-
*
|
|
225
|
-
* Returns null if the request fails (advisory — caller should degrade gracefully).
|
|
226
|
-
*/
|
|
227
|
-
export async function getConnectionStatus(cfg, apiKey, targetHandle) {
|
|
228
|
-
try {
|
|
229
|
-
const controller = new AbortController();
|
|
230
|
-
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
231
|
-
const res = await fetch(`${baseUrl(cfg)}/connections/status?target=${encodeURIComponent(targetHandle)}`, {
|
|
232
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
233
|
-
signal: controller.signal,
|
|
234
|
-
});
|
|
235
|
-
clearTimeout(timeout);
|
|
236
|
-
if (!res.ok)
|
|
237
|
-
return null; // Advisory — degrade gracefully
|
|
238
|
-
return (await res.json());
|
|
239
|
-
}
|
|
240
|
-
catch {
|
|
241
|
-
return null; // Network error or timeout — degrade gracefully
|
|
242
|
-
}
|
|
243
|
-
}
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAiJA,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
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAiJA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAaI,iBAAiB;CA0XhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|