@cotal-ai/core 0.171.4 → 0.171.5

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.
Files changed (35) hide show
  1. package/dist/control-exchange.d.ts.map +1 -1
  2. package/dist/control-exchange.js +3 -4
  3. package/dist/control-exchange.js.map +1 -1
  4. package/dist/endpoint-anycast.d.ts +110 -0
  5. package/dist/endpoint-anycast.d.ts.map +1 -0
  6. package/dist/endpoint-anycast.js +316 -0
  7. package/dist/endpoint-anycast.js.map +1 -0
  8. package/dist/endpoint-consumers.d.ts +147 -0
  9. package/dist/endpoint-consumers.d.ts.map +1 -0
  10. package/dist/endpoint-consumers.js +459 -0
  11. package/dist/endpoint-consumers.js.map +1 -0
  12. package/dist/endpoint-dial.d.ts +3 -1
  13. package/dist/endpoint-dial.d.ts.map +1 -1
  14. package/dist/endpoint-dial.js +5 -2
  15. package/dist/endpoint-dial.js.map +1 -1
  16. package/dist/endpoint-durable.d.ts +82 -0
  17. package/dist/endpoint-durable.d.ts.map +1 -0
  18. package/dist/endpoint-durable.js +164 -0
  19. package/dist/endpoint-durable.js.map +1 -0
  20. package/dist/endpoint-principal-serve.d.ts +110 -0
  21. package/dist/endpoint-principal-serve.d.ts.map +1 -0
  22. package/dist/endpoint-principal-serve.js +233 -0
  23. package/dist/endpoint-principal-serve.js.map +1 -0
  24. package/dist/endpoint.d.ts +30 -189
  25. package/dist/endpoint.d.ts.map +1 -1
  26. package/dist/endpoint.js +201 -1089
  27. package/dist/endpoint.js.map +1 -1
  28. package/dist/launch-artifacts.d.ts.map +1 -1
  29. package/dist/launch-artifacts.js +17 -9
  30. package/dist/launch-artifacts.js.map +1 -1
  31. package/dist/websocket-dial.d.ts +9 -0
  32. package/dist/websocket-dial.d.ts.map +1 -0
  33. package/dist/websocket-dial.js +121 -0
  34. package/dist/websocket-dial.js.map +1 -0
  35. package/package.json +1 -1
@@ -0,0 +1,233 @@
1
+ // The principal serve and prompts of CotalEndpoint, as an internal component: binding and arming each
2
+ // principal-route serve, confirming it, re-binding it on a new connection, ending and stopping it, the
3
+ // `prompts` presence field and its `seq`, and calling a principal. Moved verbatim from endpoint.ts; the
4
+ // endpoint keeps servePrincipal, which a smoke replaces, and the fields, and forwards to these. Not
5
+ // re-exported by the index.
6
+ import { AGENT_CONTRACTS, AGENT_ENDPOINT } from "./agent-endpoint.js";
7
+ import { epPrincipalCall } from "./endpoint-call.js";
8
+ import { EpEnvelopeError } from "./endpoint-envelope.js";
9
+ import { servePrincipalRoute, describeContracts } from "./endpoint-serve.js";
10
+ import { processRuntime } from "./process-runtime.js";
11
+ import { spacePrefix } from "./subjects.js";
12
+ /** The highest `prompts` presence `seq` this process used under each runtime id (SPEC §6). A reader
13
+ * orders lists by `seq` within one `runtime.id`, and a runtime id lives as long as the process, so
14
+ * this does too: across a stopped serve, a stopped endpoint and a new endpoint for the lifecycle. */
15
+ const promptsSeqs = new Map();
16
+ /** One endpoint's principal serve and prompts. Internal: `CotalEndpoint` keeps the fields and forwards to it. */
17
+ export class EndpointPrincipalServe {
18
+ deps;
19
+ constructor(deps) {
20
+ this.deps = deps;
21
+ }
22
+ get space() { return this.deps.space(); }
23
+ get nc() { return this.deps.nc(); }
24
+ get owner() { return this.deps.owner(); }
25
+ get actor() { return this.deps.actor(); }
26
+ get card() { return this.deps.card(); }
27
+ get principalServes() { return this.deps.principalServes(); }
28
+ get principalServers() { return this.deps.principalServers(); }
29
+ get promptsPresence() { return this.deps.promptsPresence(); }
30
+ set promptsPresence(value) { this.deps.setPromptsPresence(value); }
31
+ publishPresence() { return this.deps.publishPresence(); }
32
+ emitRecoverable(err) { return this.deps.emitRecoverable(err); }
33
+ requireLifecycleUid(what) { return this.deps.requireLifecycleUid(what); }
34
+ notLiveMsg() { return this.deps.notLiveMsg(); }
35
+ /** Subscribe `intent` on `nc`. */
36
+ bindPrincipalHandle(intent, nc) {
37
+ return servePrincipalRoute(nc, this.space, intent.self, intent.serve);
38
+ }
39
+ /** A principal-route refusal a call or a serve reports itself: a request publish, a serve
40
+ * subscription or a reply read. Only a reply publish is left, which no call or serve awaits. */
41
+ ownedPrincipalRouteRefusal(err) {
42
+ const p = `${spacePrefix(this.space)}.ep.`;
43
+ if (err.operation === "publish")
44
+ return err.subject.startsWith(`${p}prin.`);
45
+ return err.subject.startsWith(`${p}prin.`) || err.subject.startsWith(`${p}prin-reply.`);
46
+ }
47
+ /** Track one binding: a refusal ends the serve, and an accepted subscription on the current
48
+ * connection shows the presence field. */
49
+ async armPrincipalServe(intent, nc, handle) {
50
+ intent.binding = { nc, handle };
51
+ // Every earlier binding is on a replaced connection: retire it once its handlers finish.
52
+ for (const old of intent.handles)
53
+ void old.stop().finally(() => {
54
+ const i = intent.handles.indexOf(old);
55
+ if (i >= 0)
56
+ intent.handles.splice(i, 1);
57
+ });
58
+ intent.handles.push(handle);
59
+ intent.readyOn = undefined;
60
+ void handle.refused.then((err) => {
61
+ if (!intent.ended && intent.binding?.handle === handle)
62
+ this.endPrincipalServe(intent, err);
63
+ });
64
+ try {
65
+ await handle.ready;
66
+ }
67
+ catch {
68
+ // A refusal ends the serve through `refused`. A flush that failed because the connection
69
+ // went away is answered by the binding the next connection makes.
70
+ return;
71
+ }
72
+ this.principalServeConfirmed(intent, nc, handle);
73
+ }
74
+ /** The broker accepted `handle` on `nc`. When that is still the current binding, the serve is
75
+ * ready there. */
76
+ principalServeConfirmed(intent, nc, handle) {
77
+ if (intent.ended || intent.binding?.handle !== handle || this.nc !== nc)
78
+ return;
79
+ intent.readyOn = nc;
80
+ if (!intent.readySettled) {
81
+ intent.readySettled = true;
82
+ intent.resolveReady();
83
+ }
84
+ if (intent.serve.endpoint === AGENT_ENDPOINT)
85
+ this.publishPresence().catch((e) => this.emitRecoverable(e));
86
+ }
87
+ /** Re-bind every principal serve on a replaced connection (a rebuild), or re-run the check on the
88
+ * connection the library reconnected and re-subscribed itself. */
89
+ rebindPrincipalServes(reconnected) {
90
+ const nc = this.nc;
91
+ if (!nc)
92
+ return;
93
+ for (const intent of this.principalServes.values()) {
94
+ if (intent.ended)
95
+ continue;
96
+ const bound = intent.binding;
97
+ if (bound && bound.nc === nc) {
98
+ if (!reconnected)
99
+ continue;
100
+ intent.readyOn = undefined;
101
+ void bound.handle.check().then(() => this.principalServeConfirmed(intent, nc, bound.handle), () => { });
102
+ continue;
103
+ }
104
+ let handle;
105
+ try {
106
+ handle = this.bindPrincipalHandle(intent, nc);
107
+ }
108
+ catch (e) {
109
+ this.endPrincipalServe(intent, e);
110
+ continue;
111
+ }
112
+ void this.armPrincipalServe(intent, nc, handle);
113
+ }
114
+ }
115
+ /** End a serve the broker refused: no more serving, `failed` resolves, the presence field goes. */
116
+ endPrincipalServe(intent, err) {
117
+ if (intent.ended)
118
+ return;
119
+ this.forgetPrincipalServe(intent);
120
+ const wasReady = intent.readySettled;
121
+ if (!intent.readySettled) {
122
+ intent.readySettled = true;
123
+ intent.rejectReady(err);
124
+ }
125
+ intent.resolveFailed(err);
126
+ for (const handle of intent.handles)
127
+ void handle.stop();
128
+ if (intent.serve.endpoint === AGENT_ENDPOINT) {
129
+ this.promptsPresence = undefined;
130
+ this.publishPresence().catch((e) => this.emitRecoverable(e));
131
+ }
132
+ // `ready` already carried a refusal that came before it settled; a later one is reported here.
133
+ if (wasReady)
134
+ this.emitRecoverable(new Error(`stopped serving "${intent.serve.endpoint}" on the principal route: ${err.message}`, { cause: err }));
135
+ }
136
+ /** Mark `intent` ended and release what it holds in this endpoint and in this process. */
137
+ forgetPrincipalServe(intent) {
138
+ intent.ended = true;
139
+ intent.readyOn = undefined;
140
+ if (this.principalServes.get(intent.serve.endpoint) === intent)
141
+ this.principalServes.delete(intent.serve.endpoint);
142
+ if (this.principalServers.get(intent.serverKey) === intent)
143
+ this.principalServers.delete(intent.serverKey);
144
+ }
145
+ /** Stop serving `intent` and wait for its handlers in flight, each until its request's deadline
146
+ * at most. The ending is synchronous, so a
147
+ * `ready` still waiting for the broker rejects before the caller's next step. `republish` writes
148
+ * presence without the `prompts` field; the endpoint's own stop writes it offline instead. */
149
+ async stopPrincipalServe(intent, republish = true) {
150
+ if (!intent.ended) {
151
+ this.forgetPrincipalServe(intent);
152
+ if (!intent.readySettled) {
153
+ intent.readySettled = true;
154
+ intent.rejectReady(new Error(`stopped serving "${intent.serve.endpoint}" before the broker confirmed the subscription`));
155
+ }
156
+ if (intent.serve.endpoint === AGENT_ENDPOINT) {
157
+ this.promptsPresence = undefined;
158
+ if (republish)
159
+ this.publishPresence().catch((e) => this.emitRecoverable(e));
160
+ }
161
+ }
162
+ await Promise.all(intent.handles.map((handle) => handle.stop()));
163
+ }
164
+ /**
165
+ * Set this process's `prompts` presence field and write presence at once (SPEC §6): how many
166
+ * prompts it holds `open` or `sent`, and a counter that goes up by one each time a prompt opens or
167
+ * changes state. The field shows only while the `agent` endpoint is served and the broker accepted
168
+ * its subscription on the current connection. Until this is called it shows `open: 0` with the
169
+ * fresh `seq` the serve took from {@link nextPromptsSeq} when it started. Throws when the `agent`
170
+ * endpoint is not served, and a RangeError for a `seq` below one this runtime already used.
171
+ */
172
+ async setPromptsPresence(prompts) {
173
+ for (const k of ["open", "seq"])
174
+ if (!Number.isSafeInteger(prompts?.[k]) || prompts[k] < 0)
175
+ throw new TypeError(`prompts.${k} must be a non-negative safe integer`);
176
+ const intent = this.principalServes.get(AGENT_ENDPOINT);
177
+ if (!intent)
178
+ throw new Error(`the prompts presence field belongs to a served "${AGENT_ENDPOINT}" endpoint: call servePrincipal first (SPEC §6)`);
179
+ const used = promptsSeqs.get(intent.self.runtimeId) ?? 0;
180
+ if (prompts.seq < used)
181
+ throw new RangeError(`prompts.seq ${prompts.seq} is below ${used}, which this process already used under runtime ${intent.self.runtimeId}: seq never goes back under one runtime id (SPEC §6)`);
182
+ promptsSeqs.set(intent.self.runtimeId, prompts.seq);
183
+ this.promptsPresence = { open: prompts.open, seq: prompts.seq };
184
+ await this.publishPresence();
185
+ }
186
+ /**
187
+ * Take the next `prompts` `seq` for this process's runtime (SPEC §6): 0 the first time, then one
188
+ * above every `seq` this process used under its runtime id, whichever endpoint object used it. A
189
+ * prompt desk takes every `seq` it shows from here. Throws without a lifecycle UID.
190
+ */
191
+ nextPromptsSeq() {
192
+ const runtimeId = processRuntime(this.requireLifecycleUid("nextPromptsSeq")).id;
193
+ const used = promptsSeqs.get(runtimeId);
194
+ const next = used === undefined ? 0 : used + 1;
195
+ promptsSeqs.set(runtimeId, next);
196
+ return next;
197
+ }
198
+ /** The `prompts` field this process's presence carries now, or none. */
199
+ servedPrompts() {
200
+ const intent = this.principalServes.get(AGENT_ENDPOINT);
201
+ if (!intent || intent.ended || !this.nc || intent.readyOn !== this.nc)
202
+ return undefined;
203
+ return this.promptsPresence;
204
+ }
205
+ /**
206
+ * Call one command of a principal's own endpoint on the principal route (SPEC 13.21), as this
207
+ * endpoint's caller triple with the authority word its row covers. `principal` is the addressed
208
+ * process: owner, actor, lifecycle UID and the `runtime.id` its presence publishes. Presence is
209
+ * advisory, and a wrong value reaches a subject nobody serves or one this caller's row does not
210
+ * cover. It cannot widen authority.
211
+ *
212
+ * The `agent` endpoint's contracts and `describe`'s are built in; any other endpoint needs
213
+ * `contract`. Resolves the reply, whose `ok: false` is the agent's own refusal; throws
214
+ * `unavailable` (`not-executed`) when nothing serves that process, `permission-denied`
215
+ * (`not-executed`) when this credential holds no row for the request, and `deadline-exceeded`
216
+ * (`unknown`) when no reply came. See {@link epPrincipalCall}.
217
+ */
218
+ async callPrincipal(call) {
219
+ const nc = this.nc;
220
+ if (!nc)
221
+ throw new Error(this.notLiveMsg());
222
+ const contract = call.contract
223
+ ?? (call.command === "describe" ? describeContracts() : call.endpoint === AGENT_ENDPOINT ? AGENT_CONTRACTS[call.command] : undefined);
224
+ if (contract === undefined)
225
+ throw new EpEnvelopeError("bad-request", `no contract is built in for ${call.endpoint}.${call.command}; pass one`, undefined, "not-executed");
226
+ const caller = { owner: this.owner, actor: this.actor, uid: this.requireLifecycleUid("callPrincipal") };
227
+ return epPrincipalCall(nc, this.space, { principal: call.principal, authority: call.authority }, {
228
+ endpoint: call.endpoint, command: call.command, contract, caller, name: this.card.name,
229
+ ...(call.args !== undefined ? { args: call.args } : {}),
230
+ }, { deadlineMs: call.deadlineMs, ...(call.signal ? { signal: call.signal } : {}) });
231
+ }
232
+ }
233
+ //# sourceMappingURL=endpoint-principal-serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-principal-serve.js","sourceRoot":"","sources":["../src/endpoint-principal-serve.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,uGAAuG;AACvG,wGAAwG;AACxG,oGAAoG;AACpG,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAA+B,MAAM,qBAAqB,CAAC;AAE1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;sGAEsG;AACtG,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAqB9C,iHAAiH;AACjH,MAAM,OAAO,sBAAsB;IACJ;IAA7B,YAA6B,IAAgC;QAAhC,SAAI,GAAJ,IAAI,CAA4B;IAAG,CAAC;IAEjE,IAAY,KAAK,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjD,IAAY,EAAE,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3C,IAAY,KAAK,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjD,IAAY,KAAK,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,E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