agl 43.0.5 → 43.1.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/changelog.md +18 -0
- package/dist_serve/bundle.js +5186 -4683
- package/dist_serve/bundle.js.map +2 -2
- package/dist_serve/bundle.js.third-party-notices.json +29 -29
- package/dist_serve/bundle.js.third-party-notices.txt +29 -29
- package/dist_serve/third-party-notices.md +1 -1
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/aglapisurface.document.js +475 -4
- package/dist_ts/aglapi/interfaces.d.ts +10 -0
- package/dist_ts/aglapi/interfaces.js +3 -1
- package/dist_ts/classes.claudeharness.d.ts +14 -5
- package/dist_ts/classes.claudeharness.js +62 -2
- package/dist_ts/classes.codexclientadapter.d.ts +7 -5
- package/dist_ts/classes.codexclientadapter.js +38 -3
- package/dist_ts/classes.controller.d.ts +9 -2
- package/dist_ts/classes.controller.js +116 -24
- package/dist_ts/classes.inferencegateway.d.ts +8 -5
- package/dist_ts/classes.inferencegateway.js +62 -19
- package/dist_ts/classes.inferencespend.d.ts +9 -3
- package/dist_ts/classes.inferencespend.js +44 -16
- package/dist_ts/classes.mcpclient.d.ts +6 -4
- package/dist_ts/classes.mcpclient.js +6 -2
- package/dist_ts/classes.mcpcontrollerhost.js +5 -1
- package/dist_ts/classes.mcptools.d.ts +1 -1
- package/dist_ts/classes.mcptools.js +17 -4
- package/dist_ts/classes.opencodeclient.js +3 -1
- package/dist_ts/classes.proxycontrol.d.ts +22 -11
- package/dist_ts/classes.proxycontrol.js +6 -3
- package/dist_ts/classes.proxycontrolclient.d.ts +6 -5
- package/dist_ts/classes.proxycontrolclient.js +8 -6
- package/dist_ts/classes.proxydaemon.d.ts +8 -6
- package/dist_ts/classes.proxydaemon.js +35 -21
- package/dist_ts/classes.proxyleaseholder.d.ts +12 -4
- package/dist_ts/classes.proxyleaseholder.js +39 -9
- package/dist_ts/classes.proxystore.d.ts +4 -3
- package/dist_ts/classes.proxystore.js +17 -7
- package/dist_ts/classes.sessionfeed.d.ts +1 -1
- package/dist_ts/classes.validation.d.ts +7 -0
- package/dist_ts/classes.validation.js +49 -2
- package/dist_ts/driver/functions.drivertools.js +2 -2
- package/dist_ts/fleet/classes.codexworkers.d.ts +4 -11
- package/dist_ts/fleet/classes.codexworkers.js +6 -3
- package/dist_ts/fleet/classes.workers.d.ts +25 -13
- package/dist_ts/fleet/classes.workers.js +105 -9
- package/dist_ts/fleet/functions.workervalidation.d.ts +26 -1
- package/dist_ts/fleet/functions.workervalidation.js +40 -11
- package/dist_ts/fleet/interfaces.workers.d.ts +17 -11
- package/dist_ts/fleet/interfaces.workers.js +10 -1
- package/dist_ts/functions.confinedrelay.d.ts +21 -0
- package/dist_ts/functions.confinedrelay.js +65 -0
- package/dist_ts/functions.deviceapi.d.ts +4 -2
- package/dist_ts/functions.deviceapi.js +20 -2
- package/dist_ts/functions.elicitation.d.ts +49 -0
- package/dist_ts/functions.elicitation.js +418 -0
- package/dist_ts/functions.inferencecli.d.ts +3 -3
- package/dist_ts/functions.inferencecli.js +33 -10
- package/dist_ts/functions.inferencecliarguments.d.ts +2 -1
- package/dist_ts/functions.inferencecliarguments.js +29 -8
- package/dist_ts/functions.inferencelaunch.d.ts +35 -7
- package/dist_ts/functions.inferencelaunch.js +143 -16
- package/dist_ts/functions.mcpfleetworkertools.d.ts +63 -70
- package/dist_ts/functions.mcpfleetworkertools.js +32 -4
- package/dist_ts/functions.proxycontract.d.ts +21 -4
- package/dist_ts/functions.proxycontract.js +12 -5
- package/dist_ts/functions.proxyharnessconfig.d.ts +7 -0
- package/dist_ts/functions.proxyharnessconfig.js +11 -1
- package/dist_ts/interfaces.auth.d.ts +1 -1
- package/dist_ts/interfaces.auth.js +2 -1
- package/dist_ts_interfaces/devices.d.ts +133 -3
- package/dist_ts_interfaces/devices.js +3 -2
- package/dist_ts_interfaces/elicitations.d.ts +125 -0
- package/dist_ts_interfaces/elicitations.js +7 -0
- package/dist_ts_interfaces/fleetworkers.d.ts +119 -5
- package/dist_ts_interfaces/fleetworkers.js +14 -2
- package/dist_ts_interfaces/index.d.ts +1 -0
- package/dist_ts_interfaces/index.js +2 -1
- package/dist_ts_interfaces/interfaces.d.ts +3 -1
- package/dist_ts_interfaces/interfaces.js +2 -2
- package/dist_ts_interfaces/mcprequests.d.ts +5 -1
- package/dist_ts_interfaces/mcprequests.js +2 -1
- package/dist_ts_interfaces/nativesessions.d.ts +14 -0
- package/dist_ts_interfaces/requests.d.ts +3 -3
- package/dist_ts_interfaces/requests.fleetworkers.js +2 -2
- package/dist_ts_interfaces/requests.js +1 -1
- package/dist_ts_interfaces/requests.promptreply.d.ts +18 -0
- package/dist_ts_interfaces/sessionfeed.d.ts +3 -2
- package/dist_ts_interfaces/sessionfeed.js +1 -1
- package/package.json +3 -3
- package/readme.md +191 -24
- package/third-party-notices.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +474 -3
- package/ts/aglapi/interfaces.ts +2 -0
- package/ts/classes.claudeharness.ts +80 -9
- package/ts/classes.codexclientadapter.ts +41 -5
- package/ts/classes.controller.ts +142 -29
- package/ts/classes.inferencegateway.ts +69 -23
- package/ts/classes.inferencespend.ts +46 -13
- package/ts/classes.mcpclient.ts +8 -4
- package/ts/classes.mcpcontrollerhost.ts +4 -0
- package/ts/classes.mcptools.ts +17 -3
- package/ts/classes.opencodeclient.ts +2 -0
- package/ts/classes.proxycontrol.ts +27 -13
- package/ts/classes.proxycontrolclient.ts +9 -6
- package/ts/classes.proxydaemon.ts +49 -27
- package/ts/classes.proxyleaseholder.ts +43 -11
- package/ts/classes.proxystore.ts +21 -8
- package/ts/classes.sessionfeed.ts +1 -1
- package/ts/classes.validation.ts +52 -0
- package/ts/driver/functions.drivertools.ts +1 -1
- package/ts/fleet/classes.codexworkers.ts +8 -6
- package/ts/fleet/classes.workers.ts +101 -17
- package/ts/fleet/functions.workervalidation.ts +35 -9
- package/ts/fleet/interfaces.workers.ts +11 -4
- package/ts/functions.confinedrelay.ts +65 -0
- package/ts/functions.deviceapi.ts +24 -1
- package/ts/functions.elicitation.ts +443 -0
- package/ts/functions.inferencecli.ts +38 -13
- package/ts/functions.inferencecliarguments.ts +26 -5
- package/ts/functions.inferencelaunch.ts +143 -16
- package/ts/functions.mcpfleetworkertools.ts +34 -4
- package/ts/functions.proxycontract.ts +17 -4
- package/ts/functions.proxyharnessconfig.ts +11 -0
- package/ts/interfaces.auth.ts +1 -0
- package/ts_interfaces/devices.schema.json +476 -2
- package/ts_interfaces/devices.ts +146 -2
- package/ts_interfaces/elicitations.ts +148 -0
- package/ts_interfaces/fleetworkers.ts +96 -4
- package/ts_interfaces/index.ts +1 -0
- package/ts_interfaces/interfaces.ts +3 -1
- package/ts_interfaces/mcprequests.ts +1 -0
- package/ts_interfaces/nativesessions.ts +16 -0
- package/ts_interfaces/requests.fleetworkers.ts +1 -1
- package/ts_interfaces/requests.promptreply.ts +22 -0
- package/ts_interfaces/requests.ts +4 -0
- package/ts_interfaces/sessionfeed.ts +3 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/classes.elicitationcards.ts +106 -0
- package/ts_web/classes.nativesessionstate.ts +38 -1
- package/ts_web/elements.fleetworker.ts +27 -2
- package/ts_web/elements.harnesscontrollerapp.ts +68 -1
- package/ts_web/functions.sessionchat.ts +5 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { IControllerPermission, IControllerQuestion, IControllerRuntimeId } from './interfaces.js';
|
|
2
|
+
|
|
3
|
+
/** What every elicitation card carries, whatever it asks for. */
|
|
4
|
+
interface IControllerElicitationBase {
|
|
5
|
+
id: IControllerRuntimeId;
|
|
6
|
+
sessionId: IControllerRuntimeId;
|
|
7
|
+
/** The MCP server that asks, as the harness names it. */
|
|
8
|
+
serverName: string;
|
|
9
|
+
/** What the server asks, in its words. */
|
|
10
|
+
message: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** A form AGL collects on the card: every field the server asked for, in its order. */
|
|
15
|
+
export interface IControllerElicitationForm extends IControllerElicitationBase {
|
|
16
|
+
mode: 'form';
|
|
17
|
+
schema: IControllerElicitationSchema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The server asks the owner to visit `url`, which AGL shows as plain text and never opens or fetches; accepting
|
|
22
|
+
* reports that the owner has done it and carries no content.
|
|
23
|
+
*/
|
|
24
|
+
export interface IControllerElicitationUrl extends IControllerElicitationBase {
|
|
25
|
+
mode: 'url';
|
|
26
|
+
url: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A request AGL cannot collect (another mode, a nested or otherwise unknown field, a form too large to show), with
|
|
31
|
+
* the reason in AGL's words. Only decline or cancel answer it; it is never answered for the owner.
|
|
32
|
+
*/
|
|
33
|
+
export interface IControllerElicitationUnsupported extends IControllerElicitationBase {
|
|
34
|
+
mode: 'unsupported';
|
|
35
|
+
reason: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* MCP elicitation (`elicitation/create`, MCP 2025-11-25): an MCP server of a Claude Code or Codex session asks the
|
|
40
|
+
* owner for input. AGL holds the request as a card beside the session's permissions and questions until the owner
|
|
41
|
+
* answers it; nothing answers one on the owner's behalf, auto-accept included. A form takes MCP's flat primitive
|
|
42
|
+
* subset only: text, numbers, a yes or no, and a single or multiple choice of strings; everything else is
|
|
43
|
+
* `unsupported`, never a form with a field left out.
|
|
44
|
+
*/
|
|
45
|
+
export type TControllerElicitation = IControllerElicitationForm | IControllerElicitationUrl | IControllerElicitationUnsupported;
|
|
46
|
+
|
|
47
|
+
/** A form's fields in the order the server lists them. */
|
|
48
|
+
export interface IControllerElicitationSchema {
|
|
49
|
+
fields: TControllerElicitationField[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type TControllerElicitationField =
|
|
53
|
+
| IControllerElicitationTextField
|
|
54
|
+
| IControllerElicitationNumberField
|
|
55
|
+
| IControllerElicitationBooleanField
|
|
56
|
+
| IControllerElicitationChoiceField
|
|
57
|
+
| IControllerElicitationChoicesField;
|
|
58
|
+
|
|
59
|
+
interface IControllerElicitationFieldBase {
|
|
60
|
+
/** The property name the answer carries the value under. */
|
|
61
|
+
name: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
/** The answer must carry a value for it. */
|
|
65
|
+
required: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The string formats MCP names; a value is checked against its format before it is sent. */
|
|
69
|
+
export type TControllerElicitationTextFormat = 'email' | 'uri' | 'date' | 'date-time';
|
|
70
|
+
|
|
71
|
+
export interface IControllerElicitationTextField extends IControllerElicitationFieldBase {
|
|
72
|
+
kind: 'text';
|
|
73
|
+
format?: TControllerElicitationTextFormat;
|
|
74
|
+
/** In characters (Unicode code points), as JSON Schema counts them. */
|
|
75
|
+
minLength?: number;
|
|
76
|
+
maxLength?: number;
|
|
77
|
+
default?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface IControllerElicitationNumberField extends IControllerElicitationFieldBase {
|
|
81
|
+
kind: 'number';
|
|
82
|
+
/** Whole numbers only (JSON Schema `integer`). */
|
|
83
|
+
integer: boolean;
|
|
84
|
+
/** Inclusive bounds. */
|
|
85
|
+
minimum?: number;
|
|
86
|
+
maximum?: number;
|
|
87
|
+
default?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface IControllerElicitationBooleanField extends IControllerElicitationFieldBase {
|
|
91
|
+
kind: 'boolean';
|
|
92
|
+
default?: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** One choice: the value the answer carries, and the label the server gave it (its value when it gave none). */
|
|
96
|
+
export interface IControllerElicitationOption {
|
|
97
|
+
value: string;
|
|
98
|
+
label: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A single choice among strings. */
|
|
102
|
+
export interface IControllerElicitationChoiceField extends IControllerElicitationFieldBase {
|
|
103
|
+
kind: 'choice';
|
|
104
|
+
options: IControllerElicitationOption[];
|
|
105
|
+
default?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Several choices among strings, each at most once. */
|
|
109
|
+
export interface IControllerElicitationChoicesField extends IControllerElicitationFieldBase {
|
|
110
|
+
kind: 'choices';
|
|
111
|
+
options: IControllerElicitationOption[];
|
|
112
|
+
minItems?: number;
|
|
113
|
+
maxItems?: number;
|
|
114
|
+
default?: string[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A value of a form's field: text or a single choice, a number, a yes or no, or several choices. */
|
|
118
|
+
export type TControllerElicitationValue = string | number | boolean | string[];
|
|
119
|
+
|
|
120
|
+
/** A form's answer: one value per field the owner filled in, by field name. */
|
|
121
|
+
export type TControllerElicitationContent = Record<string, TControllerElicitationValue>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The owner's answer. `accept` sends a form's `content` (every field it carries is checked against the form first; a
|
|
125
|
+
* mismatch is refused, nothing is sent) or, in URL mode, reports the visit done without content; an unsupported
|
|
126
|
+
* request refuses it. `decline` refuses what the server asks; `cancel` dismisses it without a decision.
|
|
127
|
+
*/
|
|
128
|
+
export type TControllerElicitationReply =
|
|
129
|
+
| { action: 'accept'; content?: TControllerElicitationContent }
|
|
130
|
+
| { action: 'decline' }
|
|
131
|
+
| { action: 'cancel' };
|
|
132
|
+
|
|
133
|
+
/** At most this many fields, choices per field and bytes of UTF-8 JSON in one answer. */
|
|
134
|
+
export const controllerElicitationMaxFields = 64;
|
|
135
|
+
export const controllerElicitationMaxOptions = 256;
|
|
136
|
+
export const controllerElicitationMaxContentBytes = 64 * 1024;
|
|
137
|
+
|
|
138
|
+
/** The requests of a conversation that wait for the owner's answer. */
|
|
139
|
+
export interface IControllerAttention {
|
|
140
|
+
permissions: IControllerPermission[];
|
|
141
|
+
questions: IControllerQuestion[];
|
|
142
|
+
elicitations: TControllerElicitation[];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** A session waits for the owner while any of its requests does. */
|
|
146
|
+
export const controllerAttentionPending = (attentionArg: IControllerAttention): boolean => (
|
|
147
|
+
attentionArg.permissions.length > 0 || attentionArg.questions.length > 0 || attentionArg.elicitations.length > 0
|
|
148
|
+
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { IControllerSystemMetrics, TControllerModelLimitKind } from './interfaces.js';
|
|
1
|
+
import type { IControllerNativeWait, IControllerSystemMetrics, TControllerModelLimitKind } from './interfaces.js';
|
|
2
2
|
import type { ITicketActor } from './tickets.js';
|
|
3
3
|
import type { IFleetTicketSync } from './fleet.js';
|
|
4
|
+
import type { IControllerFleetWorkerView } from './requests.fleetworkers.js';
|
|
4
5
|
|
|
5
6
|
export type TFleetWorkerHarness = 'claude' | 'codex';
|
|
6
7
|
export interface IFleetWorkerDispatchHolder {
|
|
@@ -186,8 +187,21 @@ export interface IFleetWorkerRequests {
|
|
|
186
187
|
*/
|
|
187
188
|
refresh: { name: string; nextName: string; profile?: string; handoff: string; note?: string; ticketKey: string };
|
|
188
189
|
move: { name: string; nextName: string; profile: string; handoff: string; note?: string; ticketKey: string };
|
|
189
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Lists the owner's workers. `view` `full` (the default of this request) returns every matching public record at
|
|
192
|
+
* once; `summary` returns pages of `limit` (1-100, default 50) `IFleetWorkerSummary` rows, newest first, continued
|
|
193
|
+
* with the `cursor` of the page before. MCP `fleet_worker_list` asks for `summary` unless told otherwise. `state` and
|
|
194
|
+
* `harness` narrow either view; archived workers are listed only with `archived`.
|
|
195
|
+
*/
|
|
196
|
+
list: { archived?: boolean; ticketKey?: string; view?: TFleetWorkerListView; limit?: number; cursor?: string; state?: IFleetWorker['state']; harness?: TFleetWorkerHarness };
|
|
197
|
+
/** One worker of the owner by its `name` or its `id`, archived ones included. */
|
|
198
|
+
get: ({ name: string; id?: never } | { id: string; name?: never }) & { /** A point read names no ticket. */ ticketKey?: never };
|
|
190
199
|
status: { id: string; ticketKey?: string };
|
|
200
|
+
/**
|
|
201
|
+
* Waits until the fleet worker job `id` succeeded or failed, at most `timeoutMs` (0-240000). Waiting, timing out
|
|
202
|
+
* or abandoning the wait never cancels the job.
|
|
203
|
+
*/
|
|
204
|
+
'job-wait': { id: string; timeoutMs: number; /** Jobs are the owner's; the wait names no ticket. */ ticketKey?: never };
|
|
191
205
|
watch: { cursor?: IFleetEventCursor; timeoutMs?: number; ticketKey?: string };
|
|
192
206
|
/**
|
|
193
207
|
* Wakes a settled Claude Code background job that no fleet worker binds with an attributed message, through Claude
|
|
@@ -197,7 +211,68 @@ export interface IFleetWorkerRequests {
|
|
|
197
211
|
'native-message': { nativeId: string; text: string; sender: string; /** A native wake belongs to no ticket. */ ticketKey?: never };
|
|
198
212
|
}
|
|
199
213
|
export type TFleetWorkerAction = keyof IFleetWorkerRequests;
|
|
200
|
-
|
|
214
|
+
/** The actions that read and never start a job. */
|
|
215
|
+
export const fleetWorkerReadActions = ['list', 'get', 'status', 'job-wait', 'watch'] as const satisfies readonly TFleetWorkerAction[];
|
|
216
|
+
export type TFleetWorkerJobAction = Exclude<TFleetWorkerAction, (typeof fleetWorkerReadActions)[number]>;
|
|
217
|
+
export type TFleetWorkerListView = 'summary' | 'full';
|
|
218
|
+
/** The longest fleet worker job wait one request asks for. */
|
|
219
|
+
export const fleetWorkerJobWaitMaximumMs = 240_000;
|
|
220
|
+
/**
|
|
221
|
+
* A worker as a summary list shows it: identity, binding, what the controller observed and which fences it holds,
|
|
222
|
+
* without attribution, proof or error bodies; `fleet_worker_get` returns the whole record.
|
|
223
|
+
*/
|
|
224
|
+
export interface IFleetWorkerSummary {
|
|
225
|
+
id: string;
|
|
226
|
+
name: string;
|
|
227
|
+
harness: TFleetWorkerHarness;
|
|
228
|
+
profileId: string;
|
|
229
|
+
ticketKey?: string;
|
|
230
|
+
state: IFleetWorker['state'];
|
|
231
|
+
nativeId?: string;
|
|
232
|
+
cwd: string;
|
|
233
|
+
updatedAt: string;
|
|
234
|
+
observed: {
|
|
235
|
+
/** The native status the controller last observed; absent until it observed the worker. */
|
|
236
|
+
status?: IFleetWorkerReport['status'];
|
|
237
|
+
/** How the newest observed turn ended; see `IFleetWorkerReport.outcome`. */
|
|
238
|
+
outcome?: IFleetWorkerTurnOutcome;
|
|
239
|
+
/** The wait for a person in the harness's own client the controller last observed; see `IControllerFleetWorkerView.nativeWait`. */
|
|
240
|
+
nativeWait?: IControllerNativeWait;
|
|
241
|
+
};
|
|
242
|
+
fence: {
|
|
243
|
+
/** An unresolved dispatch: its action and since when it holds the worker. */
|
|
244
|
+
pending?: { action: string; since: string };
|
|
245
|
+
/** The worker holds an attributed lost-dispatch resolution (`lostDispatch`). */
|
|
246
|
+
lostDispatch?: true;
|
|
247
|
+
/** The worker holds an attributed reconfirmation of a steer fence (`reconfirmedDispatch`). */
|
|
248
|
+
reconfirmed?: true;
|
|
249
|
+
/** The worker records an error (`error`). */
|
|
250
|
+
error?: true;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* One page of a summary list. `total`, `fenced` (workers with an unresolved dispatch) and `failed` (workers that
|
|
255
|
+
* record an error or whose newest observed turn failed) count the whole filtered set, not the page. `nextCursor` continues after the page's last row and
|
|
256
|
+
* is absent on the last page.
|
|
257
|
+
*/
|
|
258
|
+
export interface IFleetWorkerSummaryPage {
|
|
259
|
+
view: 'summary';
|
|
260
|
+
workers: IFleetWorkerSummary[];
|
|
261
|
+
total: number;
|
|
262
|
+
fenced: number;
|
|
263
|
+
failed: number;
|
|
264
|
+
nextCursor?: string;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The refusals of the fleet worker reads, passed to the caller with their message: `job_unavailable`, the controller
|
|
268
|
+
* holds no such job of the owner (jobs are transient: a controller restart or eviction drops them; read the worker
|
|
269
|
+
* with `fleet_worker_get`); `worker_not_found`, the owner has no worker of that name or id; `list_cursor_mismatch`, the
|
|
270
|
+
* cursor belongs to another filter; `list_cursor_stale`, the worker the cursor continues after is no longer held as
|
|
271
|
+
* it was; `list_cursor_invalid`, the cursor is not one a summary list returned (a `limit` or `cursor` with the full view is
|
|
272
|
+
* refused by request validation instead).
|
|
273
|
+
*/
|
|
274
|
+
export const fleetWorkerErrorCodes = ['job_unavailable', 'worker_not_found', 'list_cursor_mismatch', 'list_cursor_stale', 'list_cursor_invalid'] as const;
|
|
275
|
+
export type TFleetWorkerErrorCode = (typeof fleetWorkerErrorCodes)[number];
|
|
201
276
|
export type TFleetWorkerRequest<T extends TFleetWorkerAction> = IFleetWorkerRequests[T];
|
|
202
277
|
export interface IFleetWorkerJob {
|
|
203
278
|
id: string;
|
|
@@ -286,7 +361,24 @@ export interface IFleetWorkerResponses {
|
|
|
286
361
|
steer: { job: IFleetWorkerJob };
|
|
287
362
|
report: { job: IFleetWorkerJob }; stop: { job: IFleetWorkerJob }; archive: { job: IFleetWorkerJob };
|
|
288
363
|
refresh: { job: IFleetWorkerJob }; move: { job: IFleetWorkerJob };
|
|
289
|
-
|
|
364
|
+
/** The full view returns `{ workers }`, the summary view one page. */
|
|
365
|
+
list: IFleetWorkerFullList | IFleetWorkerSummaryPage;
|
|
366
|
+
/** The public record and the native status and excerpt the controller last observed. */
|
|
367
|
+
get: IControllerFleetWorkerView;
|
|
368
|
+
status: { job: IFleetWorkerJob };
|
|
369
|
+
/** The job as it is when it settled or the wait ended; `timedOut`, it still runs. */
|
|
370
|
+
'job-wait': { job: IFleetWorkerJob; timedOut: boolean };
|
|
371
|
+
watch: IFleetWatchResult;
|
|
290
372
|
'native-message': { job: IFleetWorkerJob };
|
|
291
373
|
}
|
|
292
374
|
export type TFleetWorkerResponse<T extends TFleetWorkerAction> = IFleetWorkerResponses[T];
|
|
375
|
+
/** Every matching public record of a full list. */
|
|
376
|
+
export interface IFleetWorkerFullList { workers: IFleetWorker[] }
|
|
377
|
+
/**
|
|
378
|
+
* What the request `R` of `T` gets back: a list answers a summary page to `view: 'summary'` and the full records to a
|
|
379
|
+
* request without `view` (the private request's default) or with `view: 'full'`.
|
|
380
|
+
*/
|
|
381
|
+
export type TFleetWorkerResponseTo<T extends TFleetWorkerAction, R> = T extends 'list'
|
|
382
|
+
? 'view' extends keyof R ? R extends { view: 'summary' } ? IFleetWorkerSummaryPage : R extends { view: 'full' } ? IFleetWorkerFullList : TFleetWorkerResponse<'list'>
|
|
383
|
+
: IFleetWorkerFullList
|
|
384
|
+
: TFleetWorkerResponse<T>;
|
package/ts_interfaces/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
TControllerBrowserPaintAvailability,
|
|
6
6
|
TControllerBrowserPaintTermination,
|
|
7
7
|
} from './browserpaint.js';
|
|
8
|
-
export const controllerProtocolVersion =
|
|
8
|
+
export const controllerProtocolVersion = 52 as const;
|
|
9
9
|
export const controllerUpgradeManagementVersion = 2 as const;
|
|
10
10
|
export const controllerPackageName = 'agl' as const;
|
|
11
11
|
/** The systemd user unit `agl service install` writes; a controller it runs reports it in its status. */
|
|
@@ -1555,6 +1555,8 @@ export interface IControllerSessionDetail {
|
|
|
1555
1555
|
pendingPrompts: IControllerPendingPrompt[];
|
|
1556
1556
|
permissions: IControllerPermission[];
|
|
1557
1557
|
questions: IControllerQuestion[];
|
|
1558
|
+
/** MCP elicitations of a Claude Code or Codex conversation; empty for every other harness. */
|
|
1559
|
+
elicitations: import('./elicitations.js').TControllerElicitation[];
|
|
1558
1560
|
todos: IControllerTodo[];
|
|
1559
1561
|
scratchpad: IControllerSessionScratchpad;
|
|
1560
1562
|
intelligenceExchanges: IControllerIntelligenceExchange[];
|
|
@@ -105,6 +105,7 @@ export const controllerMcpSessionDetailFields = {
|
|
|
105
105
|
pendingPrompts: { kind: 'array', optional: false },
|
|
106
106
|
permissions: { kind: 'array', optional: false },
|
|
107
107
|
questions: { kind: 'array', optional: false },
|
|
108
|
+
elicitations: { kind: 'array', optional: false },
|
|
108
109
|
todos: { kind: 'array', optional: false },
|
|
109
110
|
scratchpad: { kind: 'record', optional: false },
|
|
110
111
|
intelligenceExchanges: { kind: 'array', optional: false },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as plugins from './plugins.js';
|
|
2
|
+
import type { TControllerElicitation, TControllerElicitationReply } from './elicitations.js';
|
|
2
3
|
import type {
|
|
3
4
|
IControllerDraftAttachment,
|
|
4
5
|
TControllerPermissionReply,
|
|
@@ -71,6 +72,7 @@ export interface IReq_ControllerNativeSessionRead extends plugins.typedrequestIn
|
|
|
71
72
|
/** Requests of a turn AGL runs in the session that wait for the owner. */
|
|
72
73
|
permissions: IControllerPermission[];
|
|
73
74
|
questions: IControllerQuestion[];
|
|
75
|
+
elicitations: TControllerElicitation[];
|
|
74
76
|
todos: IControllerTodo[];
|
|
75
77
|
scratchpad: IControllerSessionScratchpad;
|
|
76
78
|
intelligenceExchanges: IControllerIntelligenceExchange[];
|
|
@@ -157,3 +159,17 @@ export interface IReq_ControllerNativeSessionQuestionReply extends plugins.typed
|
|
|
157
159
|
};
|
|
158
160
|
response: { success: boolean };
|
|
159
161
|
}
|
|
162
|
+
|
|
163
|
+
/** Answers an MCP elicitation of a turn AGL runs in a native session. */
|
|
164
|
+
export interface IReq_ControllerNativeSessionElicitationReply extends plugins.typedrequestInterfaces.implementsTR<
|
|
165
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
166
|
+
IReq_ControllerNativeSessionElicitationReply
|
|
167
|
+
> {
|
|
168
|
+
method: 'controller.nativesession.elicitation.reply';
|
|
169
|
+
request: {
|
|
170
|
+
session: IControllerNativeSessionRef;
|
|
171
|
+
requestId: IControllerRuntimeId;
|
|
172
|
+
reply: TControllerElicitationReply;
|
|
173
|
+
};
|
|
174
|
+
response: { success: boolean };
|
|
175
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as plugins from './plugins.js';
|
|
2
2
|
import type { IFleetWorker, IFleetWorkerJob, IFleetWorkerReport, IFleetWorkerTurnOutcome, TFleetWorkerAction, TFleetWorkerRequest, TFleetWorkerResponse } from './fleetworkers.js';
|
|
3
3
|
import type { IControllerDraftAttachment, IControllerMessageBundle, IControllerNativeWait } from './interfaces.js';
|
|
4
|
-
export const controllerMcpFleetWorkerMethods = ['start', 'adopt', 'resolve-lost', 'reconfirm', 'steer', 'report', 'stop', 'archive', 'refresh', 'move', 'list', 'status', 'watch', 'native-message'].map(
|
|
4
|
+
export const controllerMcpFleetWorkerMethods = ['start', 'adopt', 'resolve-lost', 'reconfirm', 'steer', 'report', 'stop', 'archive', 'refresh', 'move', 'list', 'get', 'status', 'job-wait', 'watch', 'native-message'].map(
|
|
5
5
|
(action) => `agl.mcp.fleet.worker.${action}`,
|
|
6
6
|
) as Array<`agl.mcp.fleet.worker.${TFleetWorkerAction}`>;
|
|
7
7
|
export type TControllerMcpFleetWorkerRequest<T extends TFleetWorkerAction> = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
2
|
import type { IControllerRuntimeId, TControllerPermissionReply } from './interfaces.js';
|
|
3
|
+
import type { TControllerElicitationReply } from './elicitations.js';
|
|
3
4
|
|
|
4
5
|
export interface IReq_ControllerPermissionReply extends plugins.typedrequestInterfaces.implementsTR<
|
|
5
6
|
plugins.typedrequestInterfaces.ITypedRequest,
|
|
@@ -34,3 +35,24 @@ export interface IReq_ControllerQuestionReply extends plugins.typedrequestInterf
|
|
|
34
35
|
success: boolean;
|
|
35
36
|
};
|
|
36
37
|
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Answers an MCP elicitation of a Claude Code or Codex conversation. An accepted form's content is checked against the
|
|
41
|
+
* form before anything is sent; a mismatch is refused with `invalid_request`, a request no longer pending with
|
|
42
|
+
* `not_found`.
|
|
43
|
+
*/
|
|
44
|
+
export interface IReq_ControllerElicitationReply extends plugins.typedrequestInterfaces.implementsTR<
|
|
45
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
46
|
+
IReq_ControllerElicitationReply
|
|
47
|
+
> {
|
|
48
|
+
method: 'controller.elicitation.reply';
|
|
49
|
+
request: {
|
|
50
|
+
projectId: string;
|
|
51
|
+
sessionId: IControllerRuntimeId;
|
|
52
|
+
requestId: IControllerRuntimeId;
|
|
53
|
+
reply: TControllerElicitationReply;
|
|
54
|
+
};
|
|
55
|
+
response: {
|
|
56
|
+
success: boolean;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -62,6 +62,7 @@ import type { IReq_ControllerSessionFeedAcknowledge, IReq_ControllerSessionFeedL
|
|
|
62
62
|
import type { TControllerDeployTypedRequest } from './deployments.js';
|
|
63
63
|
import type {
|
|
64
64
|
IReq_ControllerNativeSessionAuxiliaryGet,
|
|
65
|
+
IReq_ControllerNativeSessionElicitationReply,
|
|
65
66
|
IReq_ControllerNativeSessionIntelligenceAsk,
|
|
66
67
|
IReq_ControllerNativeSessionPermissionReply,
|
|
67
68
|
IReq_ControllerNativeSessionQuestionReply,
|
|
@@ -148,6 +149,7 @@ import type {
|
|
|
148
149
|
IReq_ControllerSessionYolo,
|
|
149
150
|
} from './requests.session.js';
|
|
150
151
|
import type {
|
|
152
|
+
IReq_ControllerElicitationReply,
|
|
151
153
|
IReq_ControllerPermissionReply,
|
|
152
154
|
IReq_ControllerQuestionReply,
|
|
153
155
|
} from './requests.promptreply.js';
|
|
@@ -277,6 +279,7 @@ export type TControllerRequest =
|
|
|
277
279
|
| IReq_ControllerNativeSessionIntelligenceAsk
|
|
278
280
|
| IReq_ControllerNativeSessionPermissionReply
|
|
279
281
|
| IReq_ControllerNativeSessionQuestionReply
|
|
282
|
+
| IReq_ControllerNativeSessionElicitationReply
|
|
280
283
|
| IReq_ControllerUsageWatch
|
|
281
284
|
| IReq_ControllerUsageUnwatch
|
|
282
285
|
| IReq_ControllerSystemMetrics
|
|
@@ -351,6 +354,7 @@ export type TControllerRequest =
|
|
|
351
354
|
| IReq_ControllerSessionPendingPromptAction
|
|
352
355
|
| IReq_ControllerPermissionReply
|
|
353
356
|
| IReq_ControllerQuestionReply
|
|
357
|
+
| IReq_ControllerElicitationReply
|
|
354
358
|
| IReq_ControllerSessionRename
|
|
355
359
|
| IReq_ControllerSessionArchive
|
|
356
360
|
| IReq_ControllerSessionGroupsGet
|
|
@@ -46,8 +46,9 @@ export interface IControllerSessionFeedRow {
|
|
|
46
46
|
updatedAt: number;
|
|
47
47
|
open: TControllerSessionFeedOpen;
|
|
48
48
|
/**
|
|
49
|
-
* On a `needs_input` row AGL holds no question or
|
|
50
|
-
* cannot answer, for `reason`. A `needs_input` row without it holds a request the owner answers in
|
|
49
|
+
* On a `needs_input` row AGL holds no question, permission or MCP elicitation for: the harness waits in its own
|
|
50
|
+
* client, which AGL cannot answer, for `reason`. A `needs_input` row without it holds a request the owner answers in
|
|
51
|
+
* AGL.
|
|
51
52
|
*/
|
|
52
53
|
nativeWait?: IControllerNativeWait;
|
|
53
54
|
/** On a `completed` row: its newest turn was interrupted. */
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import type * as interfaces from '../ts_interfaces/index.js';
|
|
3
|
+
|
|
4
|
+
type TElicitationCard = plugins.deesCatalog.IHarnessElicitationRequest;
|
|
5
|
+
type TElicitationRefusals = readonly plugins.deesCatalog.IHarnessElicitationRefusal[];
|
|
6
|
+
|
|
7
|
+
/** A pending request, the card the chat shows for it, and the controller's refusal that stands on it. */
|
|
8
|
+
interface IElicitationCardEntry {
|
|
9
|
+
request: interfaces.TControllerElicitation;
|
|
10
|
+
/** The request as the controller sent it, to tell a changed request from the same one read again. */
|
|
11
|
+
signature: string;
|
|
12
|
+
refusals?: TElicitationRefusals;
|
|
13
|
+
card: TElicitationCard;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** An MCP elicitation as its card: the same union on `mode`, under the card id `idArg`. */
|
|
17
|
+
export const elicitationCard = (
|
|
18
|
+
idArg: string,
|
|
19
|
+
requestArg: interfaces.TControllerElicitation,
|
|
20
|
+
refusalsArg?: TElicitationRefusals,
|
|
21
|
+
): TElicitationCard => {
|
|
22
|
+
const shared = {
|
|
23
|
+
id: idArg,
|
|
24
|
+
serverName: requestArg.serverName,
|
|
25
|
+
message: requestArg.message,
|
|
26
|
+
createdAt: requestArg.createdAt,
|
|
27
|
+
...(refusalsArg ? { refusals: refusalsArg } : {}),
|
|
28
|
+
};
|
|
29
|
+
switch (requestArg.mode) {
|
|
30
|
+
case 'form': return { ...shared, mode: 'form', fields: requestArg.schema.fields };
|
|
31
|
+
case 'url': return { ...shared, mode: 'url', url: requestArg.url };
|
|
32
|
+
case 'unsupported': return { ...shared, mode: 'unsupported', reason: requestArg.reason };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The owner's answer from a card's `harness-elicitation-response` as the controller takes it; `undefined` for an
|
|
38
|
+
* action the card does not send. Only an accept carries content, and only the reply request carries the reply: the
|
|
39
|
+
* caller sends it and keeps nothing of it.
|
|
40
|
+
*/
|
|
41
|
+
export const elicitationReply = (
|
|
42
|
+
detailArg: plugins.deesCatalog.IHarnessElicitationResponseDetail | undefined,
|
|
43
|
+
): interfaces.TControllerElicitationReply | undefined => {
|
|
44
|
+
switch (detailArg?.action) {
|
|
45
|
+
case 'accept': return detailArg.content === undefined ? { action: 'accept' } : { action: 'accept', content: detailArg.content };
|
|
46
|
+
case 'decline': return { action: 'decline' };
|
|
47
|
+
case 'cancel': return { action: 'cancel' };
|
|
48
|
+
default: return undefined;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The MCP elicitation cards of the session on screen. A card keeps its object while its request and the refusal on it
|
|
54
|
+
* stay, and the list its array while every card does, so a render or another read of the session changes nothing the
|
|
55
|
+
* card compares. A refusal of the controller is a new array each time, even one that reads as the last (the controller
|
|
56
|
+
* refused a new answer the same way), and the same array while it stands: that is how the card tells a refused new
|
|
57
|
+
* answer, which it takes again, from a render. A request that leaves the list takes its refusal along. What the owner
|
|
58
|
+
* enters stays in the card; nothing here holds it.
|
|
59
|
+
*/
|
|
60
|
+
export class ElicitationCards {
|
|
61
|
+
private entries = new Map<string, IElicitationCardEntry>();
|
|
62
|
+
private list: TElicitationCard[] = [];
|
|
63
|
+
|
|
64
|
+
/** `keyOfArg` names a card by its request id, unique among the requests of one session. */
|
|
65
|
+
constructor(private readonly keyOfArg: (idArg: interfaces.IControllerRuntimeId) => string) {}
|
|
66
|
+
|
|
67
|
+
/** The cards of the controller's pending requests, in their order: the same array while none of them changed. */
|
|
68
|
+
public cards(pendingArg: readonly interfaces.TControllerElicitation[]): TElicitationCard[] {
|
|
69
|
+
const entries = new Map<string, IElicitationCardEntry>();
|
|
70
|
+
for (const request of pendingArg) {
|
|
71
|
+
const key = this.keyOfArg(request.id);
|
|
72
|
+
const signature = JSON.stringify(request);
|
|
73
|
+
const previous = this.entries.get(key);
|
|
74
|
+
entries.set(key, previous?.signature === signature
|
|
75
|
+
? previous
|
|
76
|
+
// Another request under the same id is another question: the refusal of the last one does not stand on it.
|
|
77
|
+
: { request, signature, card: elicitationCard(key, request) });
|
|
78
|
+
}
|
|
79
|
+
this.entries = entries;
|
|
80
|
+
const cards = [...entries.values()].map((entryArg) => entryArg.card);
|
|
81
|
+
if (cards.length !== this.list.length || cards.some((cardArg, indexArg) => cardArg !== this.list[indexArg])) this.list = cards;
|
|
82
|
+
return this.list;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The pending request a card answers, as the last `cards` read it. */
|
|
86
|
+
public request(cardIdArg: string): interfaces.TControllerElicitation | undefined {
|
|
87
|
+
return this.entries.get(cardIdArg)?.request;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The controller refused the answer to a card, or it could not be sent: the card shows why under a new refusal and
|
|
92
|
+
* takes an answer again. A card no longer pending has nothing to show it on.
|
|
93
|
+
*/
|
|
94
|
+
public refuse(cardIdArg: string, reasonArg: string): void {
|
|
95
|
+
const entry = this.entries.get(cardIdArg);
|
|
96
|
+
if (!entry) return;
|
|
97
|
+
const refusals: TElicitationRefusals = [{ reason: reasonArg }];
|
|
98
|
+
this.entries.set(cardIdArg, { ...entry, refusals, card: elicitationCard(cardIdArg, entry.request, refusals) });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Forgets every card, for another session or connection. */
|
|
102
|
+
public clear(): void {
|
|
103
|
+
this.entries = new Map();
|
|
104
|
+
this.list = [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -3,6 +3,7 @@ import * as interfaces from '../ts_interfaces/index.js';
|
|
|
3
3
|
import type { ISessionChatHandlers, ISessionChatView } from './functions.sessionchat.js';
|
|
4
4
|
import { sessionIntelligenceAvailabilityAction } from './functions.sessionchat.js';
|
|
5
5
|
import { errorText, type IFleetWorkerSender } from './elements.fleetworker.js';
|
|
6
|
+
import { ElicitationCards, elicitationReply } from './classes.elicitationcards.js';
|
|
6
7
|
|
|
7
8
|
/** The element a session's state belongs to: it renders the state and hears the settings remedy. */
|
|
8
9
|
export interface INativeSessionStateHost {
|
|
@@ -61,6 +62,8 @@ export class NativeSessionState {
|
|
|
61
62
|
private intelligenceAction: plugins.deesCatalog.IHarnessIntelligenceAvailabilityAction | undefined;
|
|
62
63
|
private permissionCards: plugins.deesCatalog.IHarnessPermissionRequest[] = [];
|
|
63
64
|
private questionCards: plugins.deesCatalog.IHarnessQuestionRequest[] = [];
|
|
65
|
+
private readonly elicitations = new ElicitationCards((idArg) => idArg.nativeId);
|
|
66
|
+
private elicitationCards: plugins.deesCatalog.IHarnessElicitationRequest[] = [];
|
|
64
67
|
private readonly answeredPermissions = new Map<string, plugins.deesCatalog.IHarnessPermissionRequest>();
|
|
65
68
|
private readonly answeredQuestions = new Map<string, plugins.deesCatalog.IHarnessQuestionRequest>();
|
|
66
69
|
private readonly questionBatches = new Map<string, Map<number, string[]>>();
|
|
@@ -118,6 +121,8 @@ export class NativeSessionState {
|
|
|
118
121
|
this.questionBatches.clear();
|
|
119
122
|
this.permissionCards = [];
|
|
120
123
|
this.questionCards = [];
|
|
124
|
+
this.elicitations.clear();
|
|
125
|
+
this.elicitationCards = [];
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
/** Reads the session again; a read under way reads once more after it. */
|
|
@@ -205,13 +210,14 @@ export class NativeSessionState {
|
|
|
205
210
|
: ''),
|
|
206
211
|
permissions: this.permissionCards,
|
|
207
212
|
questions: this.questionCards,
|
|
213
|
+
elicitations: this.elicitationCards,
|
|
208
214
|
};
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
/** The chat events of the session state. */
|
|
212
218
|
public readonly handlers: Pick<
|
|
213
219
|
ISessionChatHandlers,
|
|
214
|
-
'scratchpadSave' | 'intelligenceAsk' | 'intelligenceAvailabilityAction' | 'permissionResponse' | 'questionResponse'
|
|
220
|
+
'scratchpadSave' | 'intelligenceAsk' | 'intelligenceAvailabilityAction' | 'permissionResponse' | 'questionResponse' | 'elicitationResponse'
|
|
215
221
|
> = {
|
|
216
222
|
scratchpadSave: (eventArg: CustomEvent<plugins.deesCatalog.IHarnessScratchpadSaveDetail>) => {
|
|
217
223
|
const detail = eventArg.detail;
|
|
@@ -269,6 +275,12 @@ export class NativeSessionState {
|
|
|
269
275
|
return;
|
|
270
276
|
}
|
|
271
277
|
},
|
|
278
|
+
elicitationResponse: (eventArg: CustomEvent<plugins.deesCatalog.IHarnessElicitationResponseDetail>) => {
|
|
279
|
+
const cardId = eventArg.detail?.requestId;
|
|
280
|
+
if (typeof cardId !== 'string') return;
|
|
281
|
+
const request = this.elicitations.request(cardId), reply = elicitationReply(eventArg.detail);
|
|
282
|
+
if (request && reply) void this.answerElicitation(cardId, request.id, reply);
|
|
283
|
+
},
|
|
272
284
|
};
|
|
273
285
|
|
|
274
286
|
private async read(generationArg: number): Promise<void> {
|
|
@@ -369,6 +381,30 @@ export class NativeSessionState {
|
|
|
369
381
|
if (generation === this.generation) void this.refresh();
|
|
370
382
|
}
|
|
371
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Sends the owner's answer to an MCP elicitation and reads the session again. A refusal, or an answer that did not
|
|
386
|
+
* reach the controller, shows on the card, which takes an answer again; the answer itself is kept nowhere.
|
|
387
|
+
*/
|
|
388
|
+
private async answerElicitation(
|
|
389
|
+
cardIdArg: string,
|
|
390
|
+
requestIdArg: interfaces.IControllerRuntimeId,
|
|
391
|
+
replyArg: interfaces.TControllerElicitationReply,
|
|
392
|
+
): Promise<void> {
|
|
393
|
+
const { ref, sender, generation } = this;
|
|
394
|
+
if (!ref || !sender) return;
|
|
395
|
+
try {
|
|
396
|
+
await sender.fire<interfaces.IReq_ControllerNativeSessionElicitationReply>(
|
|
397
|
+
'controller.nativesession.elicitation.reply',
|
|
398
|
+
{ session: ref, requestId: requestIdArg, reply: replyArg },
|
|
399
|
+
);
|
|
400
|
+
} catch (errorArg) {
|
|
401
|
+
if (generation !== this.generation) return;
|
|
402
|
+
this.elicitations.refuse(cardIdArg, errorText(errorArg));
|
|
403
|
+
this.rebuildCards();
|
|
404
|
+
}
|
|
405
|
+
if (generation === this.generation) void this.refresh();
|
|
406
|
+
}
|
|
407
|
+
|
|
372
408
|
/** The request cards: pending ones as asked, or as answered while the reply is on its way. */
|
|
373
409
|
private rebuildCards(): void {
|
|
374
410
|
const response = this.response;
|
|
@@ -394,6 +430,7 @@ export class NativeSessionState {
|
|
|
394
430
|
}
|
|
395
431
|
for (const id of this.answeredQuestions.keys()) if (!pendingQuestions.has(id)) this.answeredQuestions.delete(id);
|
|
396
432
|
this.questionCards = cards;
|
|
433
|
+
this.elicitationCards = this.elicitations.cards(response?.elicitations ?? []);
|
|
397
434
|
this.host.requestUpdate();
|
|
398
435
|
}
|
|
399
436
|
|