@masons/agent-network 0.5.11 → 0.5.13
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.map +1 -1
- package/dist/channel.js +125 -23
- package/dist/cli-setup.d.ts +57 -23
- package/dist/cli-setup.d.ts.map +1 -1
- package/dist/cli-setup.js +435 -39
- package/dist/platform-client.d.ts +50 -10
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +62 -8
- package/dist/types.d.ts +50 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/session-lifecycle.d.ts +0 -89
- package/dist/session-lifecycle.d.ts.map +0 -1
- package/dist/session-lifecycle.js +0 -348
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAkC9D,oEAAoE;AACpE,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAED,8EAA8E;AAC9E,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAUD,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,oBAAoB,CAAC,CAAC;IAC9B,cAAc,CAAC,GAAG,EAAE,MAAM,CA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WD,eAAO,MAAM,mBAAmB,EAAE,yBAyNjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -44,7 +44,61 @@ export function _setNudgePendingForTesting(value) {
|
|
|
44
44
|
}
|
|
45
45
|
// --- Sender identity ---
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Project a NodeRef view from `MESSAGE_RECEIVED.metadata.sender` when the
|
|
48
|
+
* Connector has projected a NodeRef onto the inbound envelope (Full Node
|
|
49
|
+
* sender path per `docs/concepts/human-node-capability-obligations.md § 2`
|
|
50
|
+
* + `apps/connector/src/routes/root.ts` § Piece 2 projection).
|
|
51
|
+
*
|
|
52
|
+
* Wire shape (the Connector's `metadata.sender = senderNodeRef` projection):
|
|
53
|
+
* ```
|
|
54
|
+
* metadata: {
|
|
55
|
+
* visitor_name?: string; // legacy back-compat
|
|
56
|
+
* is_owner?: boolean; // legacy back-compat
|
|
57
|
+
* client_type?: string; // legacy back-compat
|
|
58
|
+
* sender?: { // NEW under (b) Full Node
|
|
59
|
+
* kind: string;
|
|
60
|
+
* mstpAddress: string;
|
|
61
|
+
* handle?: string;
|
|
62
|
+
* displayName?: string;
|
|
63
|
+
* avatarUrl?: string;
|
|
64
|
+
* };
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* Returns the NodeRef view when `metadata.sender` is an object with
|
|
69
|
+
* `kind` and `mstpAddress` both string. Returns null otherwise — the
|
|
70
|
+
* caller falls back to the Client-side metadata shape (`visitor_name`,
|
|
71
|
+
* `is_owner`, `client_type`).
|
|
72
|
+
*
|
|
73
|
+
* Per `human-node-capability-obligations.md § 5`, consumers MUST accept
|
|
74
|
+
* future `kind` values (e.g., `"team"`); this projector treats `kind` as
|
|
75
|
+
* opaque and surfaces the value as-is.
|
|
76
|
+
*/
|
|
77
|
+
function tryProjectNodeRef(metadata) {
|
|
78
|
+
if (!metadata)
|
|
79
|
+
return null;
|
|
80
|
+
const sender = metadata.sender;
|
|
81
|
+
// Defensive: reject non-objects, null, and arrays. `typeof [] === "object"`
|
|
82
|
+
// and `[] !== null`, so an array would otherwise pass the next guard and
|
|
83
|
+
// produce undefined when indexed by `kind` / `mstpAddress`. Explicit
|
|
84
|
+
// rejection makes the contract self-documenting.
|
|
85
|
+
if (typeof sender !== "object" || sender === null || Array.isArray(sender))
|
|
86
|
+
return null;
|
|
87
|
+
const senderObj = sender;
|
|
88
|
+
const kind = senderObj.kind;
|
|
89
|
+
const mstpAddress = senderObj.mstpAddress;
|
|
90
|
+
if (typeof kind !== "string" || typeof mstpAddress !== "string")
|
|
91
|
+
return null;
|
|
92
|
+
const handle = typeof senderObj.handle === "string" ? senderObj.handle : undefined;
|
|
93
|
+
const displayName = typeof senderObj.displayName === "string"
|
|
94
|
+
? senderObj.displayName
|
|
95
|
+
: undefined;
|
|
96
|
+
const avatarUrl = typeof senderObj.avatarUrl === "string" ? senderObj.avatarUrl : undefined;
|
|
97
|
+
return { kind, mstpAddress, handle, displayName, avatarUrl };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Derive the sender display name for the visitor / Identified-Client /
|
|
101
|
+
* anonymous path (no NodeRef projection on metadata).
|
|
48
102
|
*
|
|
49
103
|
* Resolution order:
|
|
50
104
|
* 1. `metadata.visitor_name` — display name for Passport browser visitors
|
|
@@ -59,6 +113,26 @@ function deriveSenderName(event) {
|
|
|
59
113
|
// Extract handle from `from` address
|
|
60
114
|
return extractHandleFromAddress(event.from);
|
|
61
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Derive the sender display name for the Full Node sender path. Walks the
|
|
118
|
+
* fallback chain `displayName → handle → mstpAddress`-derived handle per
|
|
119
|
+
* `docs/concepts/human-node-capability-obligations.md § 2`.
|
|
120
|
+
*
|
|
121
|
+
* Note: the spec's terminal fallback is `mstpAddress` itself. This
|
|
122
|
+
* implementation uses `extractHandleFromAddress(fromAddress)` instead —
|
|
123
|
+
* the `from` field is already a routable address (the same one
|
|
124
|
+
* `mstpAddress` would parse to a handle from), and a parsed handle is
|
|
125
|
+
* higher-fidelity for display than the full URI. When `nodeRef.handle`
|
|
126
|
+
* is absent and `from` does not parse to a handle, both forms degrade
|
|
127
|
+
* equivalently to "unknown"-style strings.
|
|
128
|
+
*/
|
|
129
|
+
function deriveNodeName(nodeRef, fromAddress) {
|
|
130
|
+
if (nodeRef.displayName)
|
|
131
|
+
return nodeRef.displayName;
|
|
132
|
+
if (nodeRef.handle)
|
|
133
|
+
return nodeRef.handle;
|
|
134
|
+
return extractHandleFromAddress(fromAddress);
|
|
135
|
+
}
|
|
62
136
|
/**
|
|
63
137
|
* Extract the Connector host from a connectorUrl.
|
|
64
138
|
* `wss://preview.masons.ai/gw` -> `preview.masons.ai`
|
|
@@ -110,31 +184,59 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
110
184
|
dbg("duplicate message suppressed from=%s sentAt=%s", fromAddress, event.sentAt);
|
|
111
185
|
return;
|
|
112
186
|
}
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
187
|
+
// Sender shape disambiguation per `docs/openclaw/program-demo-runbook.md § 4.2`:
|
|
188
|
+
// - Full Node sender (Node ↔ Node): `metadata.sender` is a NodeRef
|
|
189
|
+
// (`kind`, `mstpAddress`, optional `handle` / `displayName` /
|
|
190
|
+
// `avatarUrl`) per `docs/concepts/human-node-capability-obligations.md
|
|
191
|
+
// § 2` + Connector Piece 2 projection at
|
|
192
|
+
// `apps/connector/src/routes/root.ts`.
|
|
193
|
+
// Right-Fix lock per #1455 issuecomment-4354081096: route via standard
|
|
194
|
+
// Node-peer path; do NOT consult `metadata.is_owner`. `is_owner` is an
|
|
195
|
+
// ownership signal, not a routing signal — owner-self-chat walks the
|
|
196
|
+
// same wire as stranger-chat.
|
|
197
|
+
// - Visitor / Identified Client / Anonymous (Client → Node):
|
|
198
|
+
// `metadata.sender` is absent; only `visitor_name`, `is_owner`,
|
|
199
|
+
// `client_type` per
|
|
200
|
+
// `docs/concepts/client-to-node-capability-obligations.md § 2`.
|
|
201
|
+
// Existing visitor-mode owner-routing applies.
|
|
202
|
+
const nodeRef = tryProjectNodeRef(event.metadata);
|
|
203
|
+
if (nodeRef) {
|
|
204
|
+
// Full Node sender — standard Node-peer path. Skip is_owner consultation,
|
|
205
|
+
// owner-address marking, and the identity-linking nudge (those all key off
|
|
206
|
+
// the visitor-mode owner concept).
|
|
207
|
+
setCurrentTurnIsOwner(false);
|
|
208
|
+
dbg("Full Node sender: kind=%s mstpAddress=%s handle=%s", nodeRef.kind, nodeRef.mstpAddress, nodeRef.handle ?? "(absent)");
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// Visitor-mode path — preserved behavior.
|
|
212
|
+
// Owner detection: first-message-sets, subsequent-inherits.
|
|
213
|
+
// Connector includes is_owner in metadata for Passport visitors.
|
|
214
|
+
if (event.metadata?.is_owner === true) {
|
|
215
|
+
markOwnerAddress(fromAddress);
|
|
216
|
+
// Record Passport address for tool auto-include (first visit only)
|
|
217
|
+
if (!storedOwnerPassportAddress) {
|
|
218
|
+
storedOwnerPassportAddress = fromAddress;
|
|
219
|
+
dbg("recorded owner Passport address: %s", fromAddress);
|
|
220
|
+
}
|
|
221
|
+
// --- dmScope-aware identity linking nudge (#986 redesign, #1158 fix) ---
|
|
222
|
+
// Detect that identity linking is available but not configured.
|
|
223
|
+
// Sets a flag (NOT enqueued into ownerNotesQueue) for delivery on the
|
|
224
|
+
// owner's next non-Passport turn, where the linking action is relevant.
|
|
225
|
+
// Separated from the queue to avoid the Passport drain deadlock (#1158).
|
|
226
|
+
if (getDmScope() !== "main" &&
|
|
227
|
+
!isIdentityLinksConfigured() &&
|
|
228
|
+
!notificationAttempted) {
|
|
229
|
+
notificationAttempted = true;
|
|
230
|
+
identityLinkingNudgePending = true;
|
|
231
|
+
dbg("identity linking nudge pending (dmScope=%s)", getDmScope());
|
|
232
|
+
}
|
|
133
233
|
}
|
|
234
|
+
setCurrentTurnIsOwner(isOwnerAddress(fromAddress));
|
|
134
235
|
}
|
|
135
|
-
setCurrentTurnIsOwner(isOwnerAddress(fromAddress));
|
|
136
236
|
// Resolve contact from address. Register inbound conversation if new.
|
|
137
|
-
const contact =
|
|
237
|
+
const contact = nodeRef
|
|
238
|
+
? deriveNodeName(nodeRef, fromAddress)
|
|
239
|
+
: deriveSenderName(event);
|
|
138
240
|
if (!conversationManager.getContactByAddress(fromAddress)) {
|
|
139
241
|
conversationManager.registerInbound(contact, fromAddress);
|
|
140
242
|
}
|
package/dist/cli-setup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CLI Login Path —
|
|
2
|
+
* CLI Login Path — Stripe-style browser-mediated loopback handoff.
|
|
3
3
|
*
|
|
4
4
|
* Implements `login()` hook for OpenClaw's 2026.4.x channel-plugin contract:
|
|
5
5
|
* api.registerChannel({ plugin: { ..., auth: { login } } })
|
|
@@ -9,28 +9,50 @@
|
|
|
9
9
|
* `"Channel ... does not support login"` if absent. See WhatsApp + Feishu
|
|
10
10
|
* bundled extensions for reference implementations of the same contract.
|
|
11
11
|
*
|
|
12
|
-
* Flow:
|
|
13
|
-
* 1. POST {idpBaseUrl}/api/auth/device/code with client_id + scope
|
|
14
|
-
* → display user_code + verification_uri to the user
|
|
15
|
-
* 2. Poll {idpBaseUrl}/api/auth/device/token until access_token issued
|
|
16
|
-
* → handles `expired_token`, `authorization_pending`, `slow_down`
|
|
17
|
-
* 3. POST {apiHost}/runtime/v1/onboard with Bearer access_token
|
|
18
|
-
* → list / select existing agent / create new (terminal prompter)
|
|
19
|
-
* 4. Persist credentials directly via `writeCredentials()` into
|
|
20
|
-
* `openclaw.json`. (The CLI does NOT auto-persist after login returns —
|
|
21
|
-
* unlike the legacy `configureInteractive` contract — so the plugin
|
|
22
|
-
* owns the file write; see `runChannelLogin` in channels-cli source.)
|
|
12
|
+
* Flow (W4 PR 3 — `loopbackHandoffFlow`):
|
|
23
13
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
14
|
+
* 1. Bind a one-shot HTTP listener on `127.0.0.1:0` (OS-assigned ephemeral
|
|
15
|
+
* port). The listener serves a single `POST /handoff` plus the matching
|
|
16
|
+
* CORS preflight, then closes.
|
|
17
|
+
* 2. Generate a 24-byte (32-char base64url) URL-safe random nonce. The
|
|
18
|
+
* nonce travels in the URL fragment (`#nonce=…`), never the query
|
|
19
|
+
* string — fragments do not reach `apps/web` access logs nor referer
|
|
20
|
+
* headers (Alt W4-B2 lock).
|
|
21
|
+
* 3. Open the user's browser to the handoff URL (no-handle path uses
|
|
22
|
+
* `${idpBaseUrl}/console/handoff?port=<port>#nonce=<nonce>`; with
|
|
23
|
+
* `--handle` the per-handle deep-link variant is the entry).
|
|
24
|
+
* 4. The user authenticates against Better Auth on `apps/web`, picks (or
|
|
25
|
+
* creates) an agent, and the page POSTs `{token, agent, key, nonce}`
|
|
26
|
+
* to the listener. The listener verifies the body's `nonce` matches
|
|
27
|
+
* the value it placed in the fragment, accepts the token, and closes.
|
|
28
|
+
* 5. Persist `{connectorUrl, token}` to `openclaw.json` via
|
|
29
|
+
* `writeCredentials()`. `connectorUrl` is derived from `apiHost`
|
|
30
|
+
* (`wss://<apiHost>/gateway`) for cloud / preview deployments; self-
|
|
31
|
+
* hosted users keep an explicit `connectorUrl` in their `openclaw.json`
|
|
32
|
+
* and the legacy value is preserved across the handoff (see
|
|
33
|
+
* `loadExistingConnectorUrl()`).
|
|
31
34
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
35
|
+
* Why move off device flow:
|
|
36
|
+
*
|
|
37
|
+
* - One step shorter (no `user_code` to type into the browser).
|
|
38
|
+
* - No periodic IdP polling (was 5s default, 5+s on `slow_down`).
|
|
39
|
+
* - Browser remains fully authenticated across login and key issuance —
|
|
40
|
+
* same Better Auth session is reused, so the user never re-types their
|
|
41
|
+
* password mid-flow.
|
|
42
|
+
* - The runtime API key carrier (`masons_rt_…`) replaces the legacy
|
|
43
|
+
* connector-minted `sk-…` carrier; W4 PR 1 substrate plus the connector
|
|
44
|
+
* mirror wiring earlier in this PR make both carriers verifiable through
|
|
45
|
+
* plugin v0.5.13's life until the W6 cleanup retires the legacy path.
|
|
46
|
+
*
|
|
47
|
+
* The legacy device-flow helpers (`deviceCodeFlow`, `pollUntilAuthorized`,
|
|
48
|
+
* `agentSetup`, `createAgentLoop`) remain in this file as
|
|
49
|
+
* `@deprecated` references for the W6 cleanup window. They have no call
|
|
50
|
+
* site after the migration and should not be invoked by any new code.
|
|
51
|
+
*
|
|
52
|
+
* See #1264 for original design rationale (single-driver Node semantic —
|
|
53
|
+
* re-running this flow rotates the runtime key and evicts any previously-
|
|
54
|
+
* connected Runtime); see the W4 strategic-pass at
|
|
55
|
+
* `#1466 issuecomment-4362892782` for the loopback handoff lock.
|
|
34
56
|
*/
|
|
35
57
|
/**
|
|
36
58
|
* Minimal OpenClaw runtime surface passed to `auth.login`. Exposed as
|
|
@@ -67,8 +89,20 @@ interface AuthLoginContext {
|
|
|
67
89
|
* and bumps the state-cache generation so Layer B's dynamic context re-reads
|
|
68
90
|
* on the next turn.
|
|
69
91
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
92
|
+
* Flow (W4 PR 3):
|
|
93
|
+
* 1. Run `loopbackHandoffFlow` against `apps/web` — a Stripe-style
|
|
94
|
+
* browser-mediated runtime-key issuance that delivers the plaintext
|
|
95
|
+
* `masons_rt_…` token to a one-shot loopback listener bound at
|
|
96
|
+
* `127.0.0.1:0` with a fragment-nonce cross-origin discipline.
|
|
97
|
+
* 2. Resolve the connector URL — preserve any user-set
|
|
98
|
+
* `accounts.default.connectorUrl` from `openclaw.json` (for self-
|
|
99
|
+
* hosted topologies); fall back to the cloud derivation
|
|
100
|
+
* `wss://<apiHost>/gateway` matching the connector's
|
|
101
|
+
* `CONNECTOR_PLUGIN_URL` env default.
|
|
102
|
+
* 3. Persist `{connectorUrl, token}` atomically.
|
|
103
|
+
*
|
|
104
|
+
* Errors during the handoff are surfaced via `ctx.runtime.error` (not
|
|
105
|
+
* thrown) so OpenClaw CLI doesn't display a stack trace — matches the
|
|
72
106
|
* WhatsApp/Feishu pattern.
|
|
73
107
|
*/
|
|
74
108
|
export declare function login(ctx: AuthLoginContext): Promise<void>;
|
package/dist/cli-setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-setup.d.ts","sourceRoot":"","sources":["../src/cli-setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli-setup.d.ts","sourceRoot":"","sources":["../src/cli-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AA2CH;;;;;GAKG;AACH,UAAU,eAAe;IACvB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;GAIG;AACH,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAw2BD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDhE"}
|