@nice-code/commander 0.90.0 → 0.91.0
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/build/cli.cjs +66 -8
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +66 -8
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-Caho-x2i.js +23 -0
- package/build/client/assets/{index-BgRBLnvt.js.map → index-Caho-x2i.js.map} +1 -1
- package/build/client/index.html +1 -1
- package/package.json +6 -6
- package/build/client/assets/index-BgRBLnvt.js +0 -23
package/build/cli.cjs
CHANGED
|
@@ -4922,6 +4922,22 @@ var RuntimeCoordinate = class RuntimeCoordinate {
|
|
|
4922
4922
|
withPersistentId(perId) {
|
|
4923
4923
|
return this.specify({ perId });
|
|
4924
4924
|
}
|
|
4925
|
+
/**
|
|
4926
|
+
* Derive a **per-connection** identity: same env and persistent id, with `connectionId` folded into
|
|
4927
|
+
* the per-boot `insId`. For a runtime that opens *several duplex links to the same peer* — a store
|
|
4928
|
+
* socket and a jobs socket on one backend — where one identity for both is a silent misroute: an
|
|
4929
|
+
* acceptor binds a connection by the full coordinate string, so two links presenting the same one
|
|
4930
|
+
* are indistinguishable and the peer's return path picks whichever bound first.
|
|
4931
|
+
*
|
|
4932
|
+
* Folding rather than replacing is the point: the runtime's `insId` stays the per-boot epoch
|
|
4933
|
+
* reliable delivery needs (see {@link IRuntimeCoordinateSpecifics.insId}), so a per-connection id may
|
|
4934
|
+
* safely be a *stable* label (`"jobs"`) — it discriminates connections without pinning the epoch.
|
|
4935
|
+
* Reached from `connectChannel`'s `connectionId` option; rarely called directly.
|
|
4936
|
+
*/
|
|
4937
|
+
withConnectionId(connectionId) {
|
|
4938
|
+
if (connectionId.length === 0 || /[[\]:~]/.test(connectionId)) throw new Error(`RuntimeCoordinate.withConnectionId: "${connectionId}" is not a usable connection id — it must be non-empty and free of \`[\`, \`]\`, \`:\` and \`~\` (the coordinate's own string-form separators).`);
|
|
4939
|
+
return this.specify({ insId: `${this.insId ?? "_"}~${connectionId}` });
|
|
4940
|
+
}
|
|
4925
4941
|
constructor({ envId, perId, insId }) {
|
|
4926
4942
|
this.envId = envId;
|
|
4927
4943
|
this.perId = perId;
|
|
@@ -13120,6 +13136,13 @@ const RELIABLE_CONNECT_RETRY_MS = 1e3;
|
|
|
13120
13136
|
* (so `connectChannel` and a realm-only `createWireClient` are one connection implementation).
|
|
13121
13137
|
*/
|
|
13122
13138
|
var ChannelConnector = class extends PeerLink {
|
|
13139
|
+
/**
|
|
13140
|
+
* This connection's own identity when it was given one (`connectChannel`'s `connectionId`), used
|
|
13141
|
+
* in place of the local runtime's coordinate as the origin stamped on outgoing frames — matching
|
|
13142
|
+
* the identity the handshake bound, so the peer's return path finds *this* socket. `undefined` ⇒
|
|
13143
|
+
* the connection speaks as the runtime, which is the single-link default.
|
|
13144
|
+
*/
|
|
13145
|
+
_connectionIdentity;
|
|
13123
13146
|
_defaultTimeout;
|
|
13124
13147
|
_reliableTimeout;
|
|
13125
13148
|
/**
|
|
@@ -13197,15 +13220,16 @@ var ChannelConnector = class extends PeerLink {
|
|
|
13197
13220
|
_controlMethods;
|
|
13198
13221
|
/** Stream-level reliable-delivery observers (see {@link TReliableStreamEvent}). */
|
|
13199
13222
|
_reliableEventListeners = /* @__PURE__ */ new Set();
|
|
13200
|
-
constructor({ runtimeCoordinate: peerSpecifier, transports, defaultTimeout, reliableActionTimeout, wireMux, localCoordinate, securityLevel, keepLinkAlive }) {
|
|
13223
|
+
constructor({ runtimeCoordinate: peerSpecifier, transports, defaultTimeout, reliableActionTimeout, wireMux, localCoordinate, connectionIdentity, securityLevel, keepLinkAlive }) {
|
|
13201
13224
|
super(peerSpecifier);
|
|
13225
|
+
this._connectionIdentity = connectionIdentity;
|
|
13202
13226
|
this._defaultTimeout = defaultTimeout ?? 1e4;
|
|
13203
13227
|
this._reliableTimeout = reliableActionTimeout ?? DEFAULT_RELIABLE_ACTION_TIMEOUT;
|
|
13204
13228
|
this._wire = new WireClient({
|
|
13205
13229
|
createManager: (cache) => new ConnectionTransportManager(cache),
|
|
13206
13230
|
mux: wireMux,
|
|
13207
13231
|
peer: this.peerClient,
|
|
13208
|
-
localCoordinate,
|
|
13232
|
+
localCoordinate: connectionIdentity ?? localCoordinate,
|
|
13209
13233
|
securityLevel,
|
|
13210
13234
|
canPush: transports.some((transport) => transport.type === "duplex"),
|
|
13211
13235
|
keepLinkAlive,
|
|
@@ -13243,7 +13267,7 @@ var ChannelConnector = class extends PeerLink {
|
|
|
13243
13267
|
* `err_wire_connect`).
|
|
13244
13268
|
*/
|
|
13245
13269
|
async connect(config) {
|
|
13246
|
-
await this._wire.connect({ localCoordinate: config?.targetLocalRuntime?.coordinate });
|
|
13270
|
+
await this._wire.connect({ localCoordinate: this._connectionIdentity ?? config?.targetLocalRuntime?.coordinate });
|
|
13247
13271
|
}
|
|
13248
13272
|
/**
|
|
13249
13273
|
* Tear down the (possibly half-open) duplex link and immediately re-dial it (DESYNC F6 / Phase
|
|
@@ -13263,7 +13287,8 @@ var ChannelConnector = class extends PeerLink {
|
|
|
13263
13287
|
}
|
|
13264
13288
|
async handleActionRequest(action, config) {
|
|
13265
13289
|
const localRuntime = config?.targetLocalRuntime ?? ActionRuntime.getDefault();
|
|
13266
|
-
const localClient = localRuntime.coordinate;
|
|
13290
|
+
const localClient = this._connectionIdentity ?? localRuntime.coordinate;
|
|
13291
|
+
if (this._connectionIdentity != null) action.context._setOriginClient(this._connectionIdentity);
|
|
13267
13292
|
const incomingTimeout = config?.timeout ?? this._defaultTimeout;
|
|
13268
13293
|
const parentCuid = peekHandlerCuid();
|
|
13269
13294
|
const callSite = action._callSite ?? (/* @__PURE__ */ new Error()).stack;
|
|
@@ -13563,7 +13588,7 @@ var ChannelConnector = class extends PeerLink {
|
|
|
13563
13588
|
* Returns `true` if the payload was sent, `false` if no suitable transport was available.
|
|
13564
13589
|
*/
|
|
13565
13590
|
async sendReturnPayload(payload, config) {
|
|
13566
|
-
const localClient = config.targetLocalRuntime.coordinate;
|
|
13591
|
+
const localClient = this._connectionIdentity ?? config.targetLocalRuntime.coordinate;
|
|
13567
13592
|
try {
|
|
13568
13593
|
const { methods } = await this._wire.getReadyTransport({
|
|
13569
13594
|
action: payload,
|
|
@@ -13819,6 +13844,7 @@ var ActionRuntime = class {
|
|
|
13819
13844
|
reliableActionTimeout: options.reliableActionTimeout,
|
|
13820
13845
|
wireMux: options.wireMux,
|
|
13821
13846
|
localCoordinate: this.coordinate,
|
|
13847
|
+
connectionIdentity: options.connectionIdentity,
|
|
13822
13848
|
securityLevel: options.securityLevel,
|
|
13823
13849
|
keepLinkAlive: options.keepLinkAlive
|
|
13824
13850
|
});
|
|
@@ -15904,7 +15930,7 @@ function transport(options) {
|
|
|
15904
15930
|
security = {
|
|
15905
15931
|
securityLevel: options.securityLevel ?? "authenticated",
|
|
15906
15932
|
link,
|
|
15907
|
-
localCoordinate: options.runtime.coordinate.toJsonObject(),
|
|
15933
|
+
localCoordinate: (options.identity ?? options.runtime.coordinate).toJsonObject(),
|
|
15908
15934
|
dictionaryVersion: channel.dictionaryVersion,
|
|
15909
15935
|
channelTags: channel.tags,
|
|
15910
15936
|
mux: options.mux
|
|
@@ -15985,6 +16011,34 @@ function defineChannel(options = {}) {
|
|
|
15985
16011
|
};
|
|
15986
16012
|
}
|
|
15987
16013
|
/**
|
|
16014
|
+
* Identities already dialled per (runtime, peer) — the check behind the several-links-one-identity
|
|
16015
|
+
* warning below. Keyed off the runtime weakly so a torn-down runtime takes its entry with it.
|
|
16016
|
+
*/
|
|
16017
|
+
const dialledIdentities = /* @__PURE__ */ new WeakMap();
|
|
16018
|
+
/**
|
|
16019
|
+
* The several-duplex-links trap (Vibenode feedback §1): a second `connectChannel` from one runtime to
|
|
16020
|
+
* one peer presenting the *same* identity is invisible to the acceptor — it binds connections by the
|
|
16021
|
+
* full coordinate string — so replies and pushes for both links go back over whichever bound first and
|
|
16022
|
+
* the other socket's traffic hangs until it times out. Silent, and it looks like a backend stall.
|
|
16023
|
+
*
|
|
16024
|
+
* Warn at dial time rather than at the misroute: this fires deterministically at setup, before any
|
|
16025
|
+
* traffic, and names the fix. Duplex connections only — the caller gates on that.
|
|
16026
|
+
*/
|
|
16027
|
+
function warnOnSharedConnectionIdentity(runtime, peer, identity) {
|
|
16028
|
+
let byPeer = dialledIdentities.get(runtime);
|
|
16029
|
+
if (byPeer == null) {
|
|
16030
|
+
byPeer = /* @__PURE__ */ new Map();
|
|
16031
|
+
dialledIdentities.set(runtime, byPeer);
|
|
16032
|
+
}
|
|
16033
|
+
const identities = byPeer.get(peer.stringId) ?? /* @__PURE__ */ new Set();
|
|
16034
|
+
byPeer.set(peer.stringId, identities);
|
|
16035
|
+
if (identities.has(identity.stringId)) {
|
|
16036
|
+
console.warn(`connectChannel: this runtime already has a connection to [${peer.stringId}] dialling as [${identity.stringId}]. The peer binds each connection by that identity, so it cannot tell the two apart: every reply and push for both goes back over whichever connected first, and the other link's traffic hangs until it times out. Give each connection its own \`connectionId\` (e.g. \`connectChannel(runtime, jobsChannel, { connectionId: "jobs", … })\`) — or, if they carry the same routes over one link, use \`connectChannels\`.`);
|
|
16037
|
+
return;
|
|
16038
|
+
}
|
|
16039
|
+
identities.add(identity.stringId);
|
|
16040
|
+
}
|
|
16041
|
+
/**
|
|
15988
16042
|
* Open a connection to a peer from a single call — the dial-out dual of `serveChannel`. The channel is
|
|
15989
16043
|
* the single source of truth for *what* is routed (`toAcceptor` domains forwarded to the peer,
|
|
15990
16044
|
* `toConnector` pushes handled locally from `onPush`); the call binds the shared facts — the channel's
|
|
@@ -16004,10 +16058,12 @@ function defineChannel(options = {}) {
|
|
|
16004
16058
|
function connectChannel(runtime, channel, options) {
|
|
16005
16059
|
const securityLevel = options.securityLevel ?? "authenticated";
|
|
16006
16060
|
const anySecure = options.transports.some((transport) => transport.secure ?? true);
|
|
16061
|
+
const connectionIdentity = options.connectionId != null ? runtime.coordinate.withConnectionId(options.connectionId) : void 0;
|
|
16062
|
+
if (options.transports.some((descriptor) => !isExchangeCarrierSource(descriptor.carrier))) warnOnSharedConnectionIdentity(runtime, options.peer, connectionIdentity ?? runtime.coordinate);
|
|
16007
16063
|
const { mux: wireMux, link, resolveLinkKeepalive, wireTap } = assembleWireConnectionParts({
|
|
16008
16064
|
callerName: "connectChannel",
|
|
16009
16065
|
peer: options.peer,
|
|
16010
|
-
identity: runtime.coordinate,
|
|
16066
|
+
identity: connectionIdentity ?? runtime.coordinate,
|
|
16011
16067
|
mux: options.wireMux,
|
|
16012
16068
|
protocols: options.protocols,
|
|
16013
16069
|
anySecure,
|
|
@@ -16023,6 +16079,7 @@ function connectChannel(runtime, channel, options) {
|
|
|
16023
16079
|
carrier: descriptor.carrier,
|
|
16024
16080
|
channel,
|
|
16025
16081
|
runtime,
|
|
16082
|
+
identity: connectionIdentity,
|
|
16026
16083
|
secure: descriptor.secure ?? true,
|
|
16027
16084
|
link,
|
|
16028
16085
|
securityLevel: descriptor.securityLevel ?? securityLevel,
|
|
@@ -16044,7 +16101,8 @@ function connectChannel(runtime, channel, options) {
|
|
|
16044
16101
|
reliableActionTimeout: options.reliableActionTimeout,
|
|
16045
16102
|
wireMux,
|
|
16046
16103
|
securityLevel: connectionSecurityLevel,
|
|
16047
|
-
keepLinkAlive: options.keepLinkAlive
|
|
16104
|
+
keepLinkAlive: options.keepLinkAlive,
|
|
16105
|
+
connectionIdentity
|
|
16048
16106
|
});
|
|
16049
16107
|
if (options.onReliableEvent != null) handler.addReliableEventListener(options.onReliableEvent);
|
|
16050
16108
|
if (options.onLinkEvent != null) handler.addLinkEventListener(options.onLinkEvent);
|