@datalayer/agent-runtimes 1.5.50 → 1.5.51
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.
|
@@ -36,6 +36,15 @@ export interface AgentClient<P> {
|
|
|
36
36
|
startTurn(request: HostTurnRequest<P>): Promise<TurnStream>;
|
|
37
37
|
stopTurn(sessionId: string, request: HostTurnRequest<P>): Promise<void>;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Maps a session to its host place again, once the place changed after the
|
|
41
|
+
* turn started (plans/DISCORD.md §3.2: Discord's answer thread exists only
|
|
42
|
+
* once the answer is shown, so the target is PUT again with it).
|
|
43
|
+
*/
|
|
44
|
+
export interface SessionBinder<P> {
|
|
45
|
+
/** Whether the session was mapped: `false` where nothing binds (development's credentials). */
|
|
46
|
+
bindSession(sessionId: string, request: HostTurnRequest<P>): Promise<boolean>;
|
|
47
|
+
}
|
|
39
48
|
/** Where a host asks from (`exchange.optional_request.place`): a channel, or a direct conversation. */
|
|
40
49
|
export type Place = Readonly<{
|
|
41
50
|
kind: 'channel' | 'direct';
|
|
@@ -160,7 +169,7 @@ export declare function agUiEventsOf(body: ReadableStream<Uint8Array>): AsyncIte
|
|
|
160
169
|
* stream reduced to semantic events, and its session mapped to the host's
|
|
161
170
|
* thread so that approvals and completions are delivered (§4.3, 3).
|
|
162
171
|
*/
|
|
163
|
-
export declare class HttpAgentClient<P> implements AgentClient<P> {
|
|
172
|
+
export declare class HttpAgentClient<P> implements AgentClient<P>, SessionBinder<P> {
|
|
164
173
|
#private;
|
|
165
174
|
readonly apiUrl: string;
|
|
166
175
|
readonly credentials: HostCredentials<P>;
|
|
@@ -169,6 +178,11 @@ export declare class HttpAgentClient<P> implements AgentClient<P> {
|
|
|
169
178
|
readonly hostKeyFor?: HostKeyLookup<P> | undefined;
|
|
170
179
|
constructor(apiUrl: string, credentials: HostCredentials<P>, shape: HostShape<P>, fetchImplementation?: typeof fetch, hostKeyFor?: HostKeyLookup<P> | undefined);
|
|
171
180
|
startTurn(request: HostTurnRequest<P>): Promise<TurnStream>;
|
|
181
|
+
/**
|
|
182
|
+
* The session mapped again with the shape's target for `request`, as the
|
|
183
|
+
* speaker (a fresh exchange): the binding is replaced, never doubled.
|
|
184
|
+
*/
|
|
185
|
+
bindSession(sessionId: string, request: HostTurnRequest<P>): Promise<boolean>;
|
|
172
186
|
stopTurn(sessionId: string, request: HostTurnRequest<P>): Promise<void>;
|
|
173
187
|
}
|
|
174
188
|
/**
|
|
@@ -266,6 +266,20 @@ export class HttpAgentClient {
|
|
|
266
266
|
updates: this.#updates(response.body, host, sessionId, run),
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* The session mapped again with the shape's target for `request`, as the
|
|
271
|
+
* speaker (a fresh exchange): the binding is replaced, never doubled.
|
|
272
|
+
*/
|
|
273
|
+
async bindSession(sessionId, request) {
|
|
274
|
+
const host = await this.credentials.forTurn(request);
|
|
275
|
+
const hostKey = host.bindable && this.hostKeyFor
|
|
276
|
+
? await this.hostKeyFor(request)
|
|
277
|
+
: undefined;
|
|
278
|
+
if (!hostKey)
|
|
279
|
+
return false;
|
|
280
|
+
await this.#bind(request, host, sessionId, hostKey);
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
269
283
|
async stopTurn(sessionId, request) {
|
|
270
284
|
const host = await this.credentials.forTurn(request);
|
|
271
285
|
assertTrustedStreamUrl(this.apiUrl, host.sessionApiUrl);
|
|
@@ -22,7 +22,7 @@ export * from '../semantic';
|
|
|
22
22
|
export { askQuestionOf, semanticOf, turnOf, type TurnInfo, } from '../semanticOfAgUi';
|
|
23
23
|
export * from './contracts';
|
|
24
24
|
export { DatalayerHostClient, HostRefusedError, type BoundHost, type HostSelf, } from './client';
|
|
25
|
-
export { agUiEventsOf, assertTrustedStreamUrl, DevelopmentCredentials, HostKeyCredentials, hostSessionOf, HostStarters, HttpAgentClient, InstallationCredentials, lastAnswer, type AgentClient, type HostCredentials, type HostKeyLookup, type HostSession, type HostShape, type HostTurnRequest, type Place, type Starter, type StarterSource, type TurnProvenance, type TurnStream, } from './agentClient';
|
|
25
|
+
export { agUiEventsOf, assertTrustedStreamUrl, DevelopmentCredentials, HostKeyCredentials, hostSessionOf, HostStarters, HttpAgentClient, InstallationCredentials, lastAnswer, type AgentClient, type HostCredentials, type HostKeyLookup, type HostSession, type HostShape, type HostTurnRequest, type Place, type SessionBinder, type Starter, type StarterSource, type TurnProvenance, type TurnStream, } from './agentClient';
|
|
26
26
|
export { hostSessionUid } from './sessionUid';
|
|
27
27
|
export { DATALAYER_ONLY, MAIL_WORDS, RENDERERS, renderApproval, type RenderedAction, type RenderedField, } from './approvalRenderers';
|
|
28
28
|
export { DELIVERY_PATH, DELIVERY_ROUTE, DeliveryPoller, deliveryRoute, receiveDelivery, type BoundHostKey, type DeliveryClaimStore, type DeliveryJob, type DeliverySink, } from './deliveries';
|