@cotal-ai/core 0.79.0 → 0.82.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/dist/channels.d.ts +9 -3
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +33 -15
- package/dist/channels.js.map +1 -1
- package/dist/connector.d.ts +7 -4
- package/dist/connector.d.ts.map +1 -1
- package/dist/connector.js.map +1 -1
- package/dist/delegated-recovery.d.ts +220 -0
- package/dist/delegated-recovery.d.ts.map +1 -0
- package/dist/delegated-recovery.js +277 -0
- package/dist/delegated-recovery.js.map +1 -0
- package/dist/endpoint-binding.d.ts +6 -0
- package/dist/endpoint-binding.d.ts.map +1 -1
- package/dist/endpoint-binding.js +14 -9
- package/dist/endpoint-binding.js.map +1 -1
- package/dist/endpoint-serve-kv.d.ts +2 -1
- package/dist/endpoint-serve-kv.d.ts.map +1 -1
- package/dist/endpoint-serve-kv.js +2 -1
- package/dist/endpoint-serve-kv.js.map +1 -1
- package/dist/endpoint-service.d.ts +2 -0
- package/dist/endpoint-service.d.ts.map +1 -1
- package/dist/endpoint-service.js.map +1 -1
- package/dist/endpoint.d.ts +4 -2
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +23 -8
- package/dist/endpoint.js.map +1 -1
- package/dist/environment-manager-grants.d.ts +19 -0
- package/dist/environment-manager-grants.d.ts.map +1 -0
- package/dist/environment-manager-grants.js +68 -0
- package/dist/environment-manager-grants.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/issued-authority.d.ts +2 -0
- package/dist/issued-authority.d.ts.map +1 -1
- package/dist/issued-authority.js +1 -1
- package/dist/issued-authority.js.map +1 -1
- package/dist/lifecycle-state.d.ts +3 -0
- package/dist/lifecycle-state.d.ts.map +1 -1
- package/dist/lifecycle-state.js +3 -1
- package/dist/lifecycle-state.js.map +1 -1
- package/dist/provision.d.ts +5 -1
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +32 -3
- package/dist/provision.js.map +1 -1
- package/dist/run-admission.d.ts.map +1 -1
- package/dist/run-admission.js +2 -2
- package/dist/run-admission.js.map +1 -1
- package/dist/runtime.d.ts +22 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/schema-profile.d.ts.map +1 -1
- package/dist/schema-profile.js +2 -0
- package/dist/schema-profile.js.map +1 -1
- package/dist/startup-confirm.d.ts +25 -13
- package/dist/startup-confirm.d.ts.map +1 -1
- package/dist/startup-confirm.js +69 -17
- package/dist/startup-confirm.js.map +1 -1
- package/package.json +6 -3
package/dist/endpoint.js
CHANGED
|
@@ -27,7 +27,7 @@ import { Bucket, KvWatchInclude } from "@nats-io/kv/internal";
|
|
|
27
27
|
import { openMembersRegistry, commitMember, tombstoneMember, activateMember, readMember, listMembers, listLifecycleMemberChannels, durableEligible, StaleMembershipWrite, } from "./members.js";
|
|
28
28
|
import { openAclRegistry, readAcl, readAclForAlias, aclRetired, AmbiguousAclAlias, commitAcl as writeAclRecord, reissueAcl as writeAclReissue } from "./acls.js";
|
|
29
29
|
import { openDeliveryRegistry } from "./lease.js";
|
|
30
|
-
import { openChannelRegistry, effectiveReplay, effectiveReplayWindowMs, effectiveDeliveryClass, readChannelConfig, readChannelDefaults, } from "./channels.js";
|
|
30
|
+
import { openChannelRegistry, effectiveReplay, effectiveReplayWindowMs, effectiveDeliveryClass, readChannelConfig, readChannelDefaults, decodeChannelEntry, } from "./channels.js";
|
|
31
31
|
import { anycastSubject, assertValidRole, CHANNEL_DEFAULTS_KEY, chatStream, chatHistDurable, chatSubject, controlServiceSubject, livenessSubject, livenessServeFilter, CONTROL_DELIVERY, CONTROL_DELIVERY_ADMIN, dmStream, dmDurable, dlvStream, dlvDurable, dlvSubject, dinboxSubject, inboxStream, parseDinboxPrincipal, FANOUT_DURABLE, INBOX_READER_DURABLE, leaseKey, managerBucket, MANAGER_LEASE_KEY, MANAGER_RENEWAL_LEASE_KEY, managerLeaseKey, chatWildcard, assertValidChannel, channelInAllow, isConcreteChannel, normalizeMentions, parseSubject, isPrincipalOwnerToken, assertInboxConnId, presenceBucket, membershipBucket, MEMBERSHIP_FEED_KEY, principalKey, parsePrincipalKey, assertLifecycleToken, mintLifecycleUid, lifecycleNameKey, DEV_OWNER, spacePrefix, spaceWildcard, subjectMatches, taskStream, taskDurable, token, unicastSubject, unicastRecvFilter, } from "./subjects.js";
|
|
32
32
|
export const DEFAULT_SERVER = "nats://127.0.0.1:4222";
|
|
33
33
|
const PLANE3_FRAME_HEADER = "Cotal-Delivery-Frame";
|
|
@@ -512,7 +512,8 @@ export class CotalEndpoint extends EventEmitter {
|
|
|
512
512
|
// principalKey validates both tokens.
|
|
513
513
|
const principal = principalKey(this.owner, this.actor);
|
|
514
514
|
this.card = { ...opts.card, id: principal.key, owner: this.owner, actor: this.actor };
|
|
515
|
-
this.environment =
|
|
515
|
+
this.environment =
|
|
516
|
+
(opts.environment === undefined ? process.env.COTAL_ENVIRONMENT : opts.environment)?.trim() || undefined;
|
|
516
517
|
this.servers = opts.servers ?? DEFAULT_SERVER;
|
|
517
518
|
this.token = opts.token;
|
|
518
519
|
this.user = opts.user;
|
|
@@ -561,7 +562,14 @@ export class CotalEndpoint extends EventEmitter {
|
|
|
561
562
|
return flight;
|
|
562
563
|
}
|
|
563
564
|
async startOnce() {
|
|
564
|
-
|
|
565
|
+
// A stopped dial is not a teardown failure. The stopped fence still closes any late epoch.
|
|
566
|
+
try {
|
|
567
|
+
await this.connectAndBind();
|
|
568
|
+
}
|
|
569
|
+
catch (error) {
|
|
570
|
+
if (!this.stopped)
|
|
571
|
+
throw error;
|
|
572
|
+
}
|
|
565
573
|
// stop() can finish while the INITIAL connectAndBind is still awaiting its broker work. The
|
|
566
574
|
// rebuild path already closes that race; initial start needs the same fence or the late bind
|
|
567
575
|
// leaves a fresh nc, heartbeat, consumers, and presence live on an endpoint already stopped.
|
|
@@ -1449,9 +1457,16 @@ export class CotalEndpoint extends EventEmitter {
|
|
|
1449
1457
|
await this.closeWithoutLibraryReconnect(oldNc);
|
|
1450
1458
|
// stop() can arrive while the old epoch closes. Do not start another authentication
|
|
1451
1459
|
// handshake after it: a terminal credential may already have expired in that window.
|
|
1460
|
+
// Keep old-epoch and late-epoch close failures outside this dial-only catch.
|
|
1452
1461
|
if (this.stopped)
|
|
1453
1462
|
return;
|
|
1454
|
-
|
|
1463
|
+
try {
|
|
1464
|
+
await this.connectAndBind();
|
|
1465
|
+
}
|
|
1466
|
+
catch (error) {
|
|
1467
|
+
if (!this.stopped)
|
|
1468
|
+
throw error;
|
|
1469
|
+
}
|
|
1455
1470
|
// stop() may have run during the await — don't leave a live connection + heartbeat +
|
|
1456
1471
|
// supervisor on a stopped endpoint. (Reads this.nc in its own scope — a bare `this.nc`
|
|
1457
1472
|
// here in doRebuild narrows to `never` via TS inlining connectAndBind's assignment.)
|
|
@@ -6191,8 +6206,8 @@ export class CotalEndpoint extends EventEmitter {
|
|
|
6191
6206
|
})();
|
|
6192
6207
|
}
|
|
6193
6208
|
/** Watch the channel registry: replay existing keys, then stream updates, into the local
|
|
6194
|
-
* cache. A failed bind throws out of connect; an entry that does not decode
|
|
6195
|
-
* `warning` and dropped, so its channel resolves to the default policy. */
|
|
6209
|
+
* cache. A failed bind throws out of connect; an entry that does not decode or validate is
|
|
6210
|
+
* reported as a `warning` and dropped, so its channel resolves to the default policy. */
|
|
6196
6211
|
async startChannelWatch() {
|
|
6197
6212
|
if (!this.channelKv)
|
|
6198
6213
|
return;
|
|
@@ -6216,9 +6231,9 @@ export class CotalEndpoint extends EventEmitter {
|
|
|
6216
6231
|
return;
|
|
6217
6232
|
try {
|
|
6218
6233
|
if (isDefaults)
|
|
6219
|
-
this.channelDefaults = e
|
|
6234
|
+
this.channelDefaults = decodeChannelEntry(e);
|
|
6220
6235
|
else
|
|
6221
|
-
this.channelConfigs.set(e.key, e
|
|
6236
|
+
this.channelConfigs.set(e.key, decodeChannelEntry(e));
|
|
6222
6237
|
}
|
|
6223
6238
|
catch (err) {
|
|
6224
6239
|
this.emitRecoverable(new Error(`dropped channel registry entry for key ${JSON.stringify(e.key)}: ${err.message}`));
|