@dudousxd/nestjs-agent-core 0.39.0 → 0.41.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/README.md +7 -0
- package/dist/ag-ui/index.cjs +123 -9
- package/dist/ag-ui/index.cjs.map +1 -1
- package/dist/ag-ui/index.d.cts +19 -3
- package/dist/ag-ui/index.d.ts +19 -3
- package/dist/ag-ui/index.js +122 -9
- package/dist/ag-ui/index.js.map +1 -1
- package/dist/{catalog-CrzetM3_.d.cts → catalog-BKS3Yxo6.d.cts} +2 -0
- package/dist/{catalog-CrzetM3_.d.ts → catalog-BKS3Yxo6.d.ts} +2 -0
- package/dist/genui/builtins.cjs +2 -0
- package/dist/genui/builtins.cjs.map +1 -1
- package/dist/genui/builtins.d.cts +1 -1
- package/dist/genui/builtins.d.ts +1 -1
- package/dist/genui/builtins.js +2 -0
- package/dist/genui/builtins.js.map +1 -1
- package/dist/genui/index.cjs +780 -106
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +5 -5
- package/dist/genui/index.d.ts +5 -5
- package/dist/genui/index.js +770 -105
- package/dist/genui/index.js.map +1 -1
- package/dist/guardrails/index.cjs +3 -1
- package/dist/guardrails/index.cjs.map +1 -1
- package/dist/guardrails/index.d.cts +5 -4
- package/dist/guardrails/index.d.ts +5 -4
- package/dist/guardrails/index.js +3 -1
- package/dist/guardrails/index.js.map +1 -1
- package/dist/index.cjs +3324 -380
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +388 -96
- package/dist/index.d.ts +388 -96
- package/dist/index.js +3279 -377
- package/dist/index.js.map +1 -1
- package/dist/{processors-6p9nrqEi.d.cts → processors-BXM-MNga.d.cts} +1 -1
- package/dist/{processors-Bp5XmF6V.d.ts → processors-ByDr5POu.d.ts} +1 -1
- package/dist/{stream-events-CbVEowYb.d.cts → stream-events-BGKLD6RX.d.ts} +664 -86
- package/dist/{stream-events-CbVEowYb.d.ts → stream-events-CF-6-Y6L.d.cts} +664 -86
- package/package.json +1 -1
- package/dist/tool-DZYLEKnl.d.cts +0 -121
- package/dist/tool-_iq4xRyk.d.ts +0 -121
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { a as Catalog, C as ComponentDefinition, J as JsonSchema, d as CatalogOptions } from './catalog-BKS3Yxo6.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Typed answers for a question set: a question that asks for a number, a date, an email or a
|
|
@@ -69,6 +70,419 @@ declare function readElicitationInput(raw: unknown): ElicitationInput | undefine
|
|
|
69
70
|
*/
|
|
70
71
|
declare function readElicitationQuestions(input: unknown): ElicitationQuestion[];
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
* How a person-facing surface talks about a tool WITHOUT ever naming it. Declared on the server,
|
|
75
|
+
* beside the tool's input schema, because whoever changes the input is the one who has to re-word
|
|
76
|
+
* the sentence that mentions it — and a client that shipped its own name-to-sentence map would go
|
|
77
|
+
* stale the moment a tool was renamed. A tool name is an identifier, never copy.
|
|
78
|
+
*
|
|
79
|
+
* `running` / `done` (and `confirm.title`, `confirm.detail`, `result.text`) are templates:
|
|
80
|
+
* `{dotted.path}` placeholders are filled from the call's INPUT (or, for `result`, its OUTPUT), so one
|
|
81
|
+
* declaration covers every call the tool will ever receive and replays identically from history.
|
|
82
|
+
* A placeholder with nothing behind it collapses along with the space before it.
|
|
83
|
+
*/
|
|
84
|
+
interface ToolPresentation {
|
|
85
|
+
/** Noun phrase, for counts and headings: "Database query", "Knowledge base". */
|
|
86
|
+
label: string;
|
|
87
|
+
/** Present progressive, while the call is in flight: "Reading {bucket}". */
|
|
88
|
+
running: string;
|
|
89
|
+
/** Settled, once the output is in: "Read {bucket}". */
|
|
90
|
+
done: string;
|
|
91
|
+
/** A key into the client's own glyph map (`database`, `search`, …). Unknown keys fall back to a generic glyph there. */
|
|
92
|
+
icon?: string;
|
|
93
|
+
/** One line naming what the tool reaches, for when the activity line is opened. */
|
|
94
|
+
detail?: string;
|
|
95
|
+
/** `destructive` earns the warning treatment on an approval prompt. */
|
|
96
|
+
tone?: ToolPresentationTone;
|
|
97
|
+
/** What a person is being asked to allow when an `action` call parks for approval. */
|
|
98
|
+
confirm?: ToolConfirmation;
|
|
99
|
+
/** How the call's OUTPUT reads as content. */
|
|
100
|
+
result?: ToolResultView;
|
|
101
|
+
}
|
|
102
|
+
type ToolPresentationTone = 'neutral' | 'destructive';
|
|
103
|
+
interface ToolConfirmation {
|
|
104
|
+
/** "Delete {count} files?" */
|
|
105
|
+
title: string;
|
|
106
|
+
/** The button: "Delete". */
|
|
107
|
+
verb: string;
|
|
108
|
+
/** A sentence under the title, when the title alone does not say what changes. */
|
|
109
|
+
detail?: string;
|
|
110
|
+
}
|
|
111
|
+
/** A value read out of a tool's output by dotted path, with the words to put next to it. */
|
|
112
|
+
interface ToolResultField {
|
|
113
|
+
path: string;
|
|
114
|
+
label: string;
|
|
115
|
+
unit?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* How a tool's output reads as content. Every variant names dotted paths into the output rather
|
|
119
|
+
* than shapes, so a renderer never has to recognise which tool it is drawing: it receives
|
|
120
|
+
* `{ view, output }` and draws it.
|
|
121
|
+
*/
|
|
122
|
+
type ToolResultView =
|
|
123
|
+
/** A row of labelled readings — one result, several facets. */
|
|
124
|
+
{
|
|
125
|
+
kind: 'metrics';
|
|
126
|
+
fields: ToolResultField[];
|
|
127
|
+
}
|
|
128
|
+
/** `rows` is a path to an array; each column's `path` is read WITHIN a row. */
|
|
129
|
+
| {
|
|
130
|
+
kind: 'table';
|
|
131
|
+
columns: ToolResultField[];
|
|
132
|
+
rows: string;
|
|
133
|
+
empty?: string;
|
|
134
|
+
}
|
|
135
|
+
/** `lines` is a path to an array of strings, drawn as a log tail. */
|
|
136
|
+
| {
|
|
137
|
+
kind: 'log';
|
|
138
|
+
lines: string;
|
|
139
|
+
}
|
|
140
|
+
/** One sentence, templated over the output. */
|
|
141
|
+
| {
|
|
142
|
+
kind: 'note';
|
|
143
|
+
text: string;
|
|
144
|
+
}
|
|
145
|
+
/** The output is drawn somewhere else on the screen already (a pushed component, a side panel). */
|
|
146
|
+
| {
|
|
147
|
+
kind: 'elsewhere';
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* `GET <base>/tools?agent=*` (and `useToolCatalog({ agent: ALL_AGENTS })`): every tool the actor
|
|
151
|
+
* reaches through ANY agent, each once — for a surface that shows several agents' conversations.
|
|
152
|
+
*/
|
|
153
|
+
declare const ALL_AGENTS = "*";
|
|
154
|
+
/**
|
|
155
|
+
* One tool as `GET <base>/tools` reports it: the tools THIS actor may be offered by the chosen agent,
|
|
156
|
+
* with how each is spoken about. `presentation` is absent for a tool that declared none — a client
|
|
157
|
+
* then narrates it generically rather than falling back to its name.
|
|
158
|
+
*/
|
|
159
|
+
interface ToolCatalogEntry {
|
|
160
|
+
/** The wire name tool parts carry (`tool-<name>`) — the key a client looks a call up by. */
|
|
161
|
+
name: string;
|
|
162
|
+
kind: ToolKind;
|
|
163
|
+
presentation?: ToolPresentation;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The approver that means "the person the run is acting for" — the thread's own actor. */
|
|
167
|
+
declare const REQUESTER_APPROVER = "requester";
|
|
168
|
+
/** The tool a requirement is asked about. `spec` is absent where this process cannot resolve it. */
|
|
169
|
+
interface ApprovalToolRef {
|
|
170
|
+
name: string;
|
|
171
|
+
kind: ToolKind;
|
|
172
|
+
spec?: ToolSpec;
|
|
173
|
+
}
|
|
174
|
+
/** Where the call is being made. */
|
|
175
|
+
interface ApprovalThreadRef {
|
|
176
|
+
threadId: string;
|
|
177
|
+
runId: string;
|
|
178
|
+
agentName?: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* What an action tool call needs before it runs.
|
|
182
|
+
*
|
|
183
|
+
* - `required: false` → the call runs without asking anyone (it is still recorded as an action).
|
|
184
|
+
* - `approver` → who may decide: {@link REQUESTER_APPROVER} (the thread's own actor — the default)
|
|
185
|
+
* or any other string, which the default {@link ApprovalPolicy.canDecide} reads as a ROLE the
|
|
186
|
+
* decider must hold. Streamed on `approval-requested` and persisted on the call.
|
|
187
|
+
* - `ttlMs` → how long the request stays open. When it lapses the call settles `expired` and the
|
|
188
|
+
* model is told nobody approved it. Absent → it waits indefinitely.
|
|
189
|
+
*/
|
|
190
|
+
interface ApprovalRequirement {
|
|
191
|
+
required: boolean;
|
|
192
|
+
approver: string;
|
|
193
|
+
ttlMs?: number;
|
|
194
|
+
}
|
|
195
|
+
/** A decision about to be taken on a call, as {@link ApprovalPolicy.canDecide} sees it. */
|
|
196
|
+
interface ApprovalDecisionRef {
|
|
197
|
+
toolCallId: string;
|
|
198
|
+
/** The approver recorded on the call when it was put to a person. */
|
|
199
|
+
approver: string;
|
|
200
|
+
/** The actorRef the run is acting for — the owner of the call's thread. */
|
|
201
|
+
requesterRef: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Who has to approve an action tool call, and for how long the request stays open.
|
|
205
|
+
*
|
|
206
|
+
* Consulted by the LOOP once per `action` call, inside the call's `persist:toolcall` checkpoint — so
|
|
207
|
+
* a durable run reads the answer back on every replay instead of re-deciding it against a policy
|
|
208
|
+
* that may have changed while it was parked. Only `action` calls are asked about: a policy cannot
|
|
209
|
+
* put a `read` behind an approval, and an `ask` (a question set) is always the requester's.
|
|
210
|
+
*/
|
|
211
|
+
interface ApprovalPolicy {
|
|
212
|
+
requirementFor(tool: ApprovalToolRef, actor: Actor, thread: ApprovalThreadRef): ApprovalRequirement | Promise<ApprovalRequirement>;
|
|
213
|
+
/**
|
|
214
|
+
* May `actor` settle this call? Checked by the approve/reject routes before a decision is
|
|
215
|
+
* signalled. Absent → {@link defaultCanDecide}: the requester approver means the thread's own
|
|
216
|
+
* actor, anything else is a role the actor must hold. Plug an authz Gate here for abilities.
|
|
217
|
+
*/
|
|
218
|
+
canDecide?(actor: Actor, decision: ApprovalDecisionRef): boolean | Promise<boolean>;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The behaviour the lib always had: every `action` call waits on the person who asked, with no
|
|
222
|
+
* expiry.
|
|
223
|
+
*/
|
|
224
|
+
declare class DefaultApprovalPolicy implements ApprovalPolicy {
|
|
225
|
+
requirementFor(tool: ApprovalToolRef): ApprovalRequirement;
|
|
226
|
+
}
|
|
227
|
+
/** The default decider rule — see {@link ApprovalPolicy.canDecide}. */
|
|
228
|
+
declare function defaultCanDecide(actor: Actor, decision: ApprovalDecisionRef): boolean;
|
|
229
|
+
/** Resolve whether `actor` may decide, through the policy's own rule when it has one. */
|
|
230
|
+
declare function mayDecideApproval(policy: ApprovalPolicy | undefined, actor: Actor, decision: ApprovalDecisionRef): Promise<boolean>;
|
|
231
|
+
/** The columns a store keeps for one call's approval, however it names them. */
|
|
232
|
+
interface ToolCallApprovalColumns {
|
|
233
|
+
proposalId?: string | null;
|
|
234
|
+
confirmation?: ToolConfirmation | null | undefined;
|
|
235
|
+
toolCallId: string;
|
|
236
|
+
status: ToolCallStatus;
|
|
237
|
+
approver: string | null | undefined;
|
|
238
|
+
expiresAt: string | Date | null | undefined;
|
|
239
|
+
remember: boolean | null | undefined;
|
|
240
|
+
executedByRef: string | null | undefined;
|
|
241
|
+
decidedVia: string | null | undefined;
|
|
242
|
+
error: string | null | undefined;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Read a tool-call row back as the {@link ToolCallApproval} a thread carries, or `null` for a call
|
|
246
|
+
* no policy put to anyone (no approver recorded). Shared by every store so they agree on the
|
|
247
|
+
* status mapping: a call that ran — or ran and failed — after a decision was APPROVED.
|
|
248
|
+
*/
|
|
249
|
+
declare function toolCallApprovalFromRow(row: ToolCallApprovalColumns): ToolCallApproval | null;
|
|
250
|
+
|
|
251
|
+
type ClaimedActionApproval = {
|
|
252
|
+
mode: 'auto';
|
|
253
|
+
} | {
|
|
254
|
+
mode: 'remembered';
|
|
255
|
+
approver: string;
|
|
256
|
+
} | {
|
|
257
|
+
mode: 'ask';
|
|
258
|
+
approver: string;
|
|
259
|
+
ttlMs?: number;
|
|
260
|
+
expiresAt?: string;
|
|
261
|
+
};
|
|
262
|
+
interface ResolveActionProposalApprovalInput {
|
|
263
|
+
actor: Actor;
|
|
264
|
+
thread: ApprovalThreadRef;
|
|
265
|
+
tool: ApprovalToolRef;
|
|
266
|
+
store: {
|
|
267
|
+
rememberedApprovals?(threadId: string): Promise<string[]>;
|
|
268
|
+
};
|
|
269
|
+
policy?: ApprovalPolicy;
|
|
270
|
+
clock?: () => number;
|
|
271
|
+
}
|
|
272
|
+
/** Journal this result on the trusted producer before choosing strict proposal preparation. */
|
|
273
|
+
declare function resolveActionProposalApproval(input: ResolveActionProposalApprovalInput): Promise<ClaimedActionApproval>;
|
|
274
|
+
|
|
275
|
+
/** Renderer support only. Component definitions and authorization remain server-owned. */
|
|
276
|
+
interface UiCapabilities {
|
|
277
|
+
components: Array<{
|
|
278
|
+
name: string;
|
|
279
|
+
version: number;
|
|
280
|
+
}>;
|
|
281
|
+
}
|
|
282
|
+
declare function validateUiCapabilities(value: unknown): UiCapabilities;
|
|
283
|
+
declare function negotiateCatalog(catalog: Catalog, capabilities?: UiCapabilities): Catalog;
|
|
284
|
+
type PreparedUiEmission = {
|
|
285
|
+
kind: 'ui';
|
|
286
|
+
component: string;
|
|
287
|
+
props: Record<string, unknown>;
|
|
288
|
+
version: number;
|
|
289
|
+
fallbackText: string;
|
|
290
|
+
componentVersions?: Record<string, number>;
|
|
291
|
+
} | {
|
|
292
|
+
kind: 'text';
|
|
293
|
+
text: string;
|
|
294
|
+
};
|
|
295
|
+
/** Validate against current trusted definitions before drawing or generating complete text. */
|
|
296
|
+
declare function prepareUiEmission(catalog: Catalog, capabilities: UiCapabilities | undefined, component: string, props: Record<string, unknown>, version?: number): Promise<PreparedUiEmission>;
|
|
297
|
+
|
|
298
|
+
interface ActionProposalScope {
|
|
299
|
+
/** Explicit null or string; scope strings have at most 255 UTF-16 code units. */
|
|
300
|
+
tenantRef: string | null;
|
|
301
|
+
actorRef: string;
|
|
302
|
+
threadId: string;
|
|
303
|
+
}
|
|
304
|
+
/** Persisted JSON execution descriptor; identity is resolved fresh from proposal scope. */
|
|
305
|
+
interface ActionProposalExecutionContext {
|
|
306
|
+
agentName?: string;
|
|
307
|
+
persona?: string;
|
|
308
|
+
requestId: string;
|
|
309
|
+
uiCapabilities?: UiCapabilities;
|
|
310
|
+
pageContext?: PageContext;
|
|
311
|
+
}
|
|
312
|
+
interface CreateActionProposal extends ActionProposalScope {
|
|
313
|
+
/** Globally unique deterministic identifier, at most 255 UTF-16 code units. */
|
|
314
|
+
id: string;
|
|
315
|
+
originRunId: string;
|
|
316
|
+
originMessageId: string;
|
|
317
|
+
originToolCallId: string;
|
|
318
|
+
toolName: string;
|
|
319
|
+
/** JSON-serializable immutable snapshot. */
|
|
320
|
+
input: unknown;
|
|
321
|
+
/** Original JSON before schema parsing; absence on legacy rows falls back to input. Null is present. */
|
|
322
|
+
preparationInput?: unknown;
|
|
323
|
+
/** Original execution address, never requester roles or transport/host handles. */
|
|
324
|
+
executionContext?: ActionProposalExecutionContext;
|
|
325
|
+
confirmation: ToolConfirmation;
|
|
326
|
+
approver: string;
|
|
327
|
+
/** Milliseconds since epoch; null means no expiry. */
|
|
328
|
+
expiresAt: number | null;
|
|
329
|
+
/** Stable across claims and crash recovery; tools must honor this key. */
|
|
330
|
+
idempotencyKey: string;
|
|
331
|
+
/** Explicit tool-authored replacement identity; never inferred from model text. */
|
|
332
|
+
replacementKey?: string;
|
|
333
|
+
}
|
|
334
|
+
type ActionProposalDecision = 'pending' | 'approved' | 'rejected' | 'expired' | 'superseded';
|
|
335
|
+
interface ActionProposalDecisionCommand {
|
|
336
|
+
decision: 'approved' | 'rejected' | 'expired';
|
|
337
|
+
actorRef: string;
|
|
338
|
+
via: string;
|
|
339
|
+
reason?: string;
|
|
340
|
+
remember?: boolean;
|
|
341
|
+
}
|
|
342
|
+
interface ActionProposalDecisionAudit extends Omit<ActionProposalDecisionCommand, 'decision'> {
|
|
343
|
+
at: number;
|
|
344
|
+
replacementProposalId?: string;
|
|
345
|
+
}
|
|
346
|
+
interface ActionProposalLease {
|
|
347
|
+
token: string;
|
|
348
|
+
generation: number;
|
|
349
|
+
workerId: string;
|
|
350
|
+
expiresAt: number;
|
|
351
|
+
}
|
|
352
|
+
interface ActionProposalExecution {
|
|
353
|
+
status: 'queued' | 'executing' | 'succeeded' | 'failed';
|
|
354
|
+
generation: number;
|
|
355
|
+
lease: ActionProposalLease | null;
|
|
356
|
+
result?: unknown;
|
|
357
|
+
error?: string;
|
|
358
|
+
}
|
|
359
|
+
interface ActionProposal extends CreateActionProposal {
|
|
360
|
+
decision: ActionProposalDecision;
|
|
361
|
+
decisionAudit: ActionProposalDecisionAudit | null;
|
|
362
|
+
/** Embedded durable execution work: created atomically with approval, absent before it. */
|
|
363
|
+
execution: ActionProposalExecution | null;
|
|
364
|
+
supersededBy?: string;
|
|
365
|
+
outcome?: ActionProposalOutcome;
|
|
366
|
+
outcomeDelivery?: ActionProposalOutcomeDelivery;
|
|
367
|
+
createdAt: number;
|
|
368
|
+
updatedAt: number;
|
|
369
|
+
}
|
|
370
|
+
interface CreateActionProposalResult {
|
|
371
|
+
status: 'created' | 'unchanged' | 'conflict';
|
|
372
|
+
proposal?: ActionProposal;
|
|
373
|
+
}
|
|
374
|
+
interface ActionProposalMutationResult {
|
|
375
|
+
status: 'applied' | 'unchanged' | 'conflict' | 'not_found' | 'expired';
|
|
376
|
+
/** Snapshot observed after the operation; concurrent operations may advance it. */
|
|
377
|
+
proposal?: ActionProposal;
|
|
378
|
+
}
|
|
379
|
+
interface ClaimActionProposal {
|
|
380
|
+
workerId: string;
|
|
381
|
+
leaseMs: number;
|
|
382
|
+
}
|
|
383
|
+
interface ExtendActionProposalLease {
|
|
384
|
+
token: string;
|
|
385
|
+
generation: number;
|
|
386
|
+
leaseMs: number;
|
|
387
|
+
}
|
|
388
|
+
type SettleActionProposal = {
|
|
389
|
+
token: string;
|
|
390
|
+
generation: number;
|
|
391
|
+
ui?: AgentUiComponent[];
|
|
392
|
+
text?: string;
|
|
393
|
+
} & ({
|
|
394
|
+
status: 'succeeded';
|
|
395
|
+
result?: unknown;
|
|
396
|
+
error?: never;
|
|
397
|
+
} | {
|
|
398
|
+
status: 'failed';
|
|
399
|
+
error: string;
|
|
400
|
+
result?: never;
|
|
401
|
+
});
|
|
402
|
+
interface ListActionProposals {
|
|
403
|
+
/** Default 100; integer 1..1000. Ties order by UTF-16 lexical logical id. */
|
|
404
|
+
limit?: number;
|
|
405
|
+
decision?: ActionProposalDecision;
|
|
406
|
+
/** Exclusive cursor in the same creation-time / exact logical-id order. */
|
|
407
|
+
after?: {
|
|
408
|
+
createdAt: number;
|
|
409
|
+
id: string;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
interface ActionProposalStoreOptions {
|
|
413
|
+
/** Server-configured trusted clock, never a timestamp from a request. */
|
|
414
|
+
clock?: () => number;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Independent capability; AgentStore implementations are not required to implement it.
|
|
418
|
+
* All identifiers are looked up within the complete scope. Creation must compare the original
|
|
419
|
+
* immutable payload on replay and reject mismatches without disclosing a differently scoped row.
|
|
420
|
+
* Decisions are first-wins CAS; approving atomically queues durable execution work. At now >=
|
|
421
|
+
* expiresAt a pending proposal expires and cannot be approved or rejected. An explicit expiry
|
|
422
|
+
* before that instant conflicts. Duplicate matching decisions are unchanged without replacing
|
|
423
|
+
* audit data. Lease claims and recovery are atomic and fenced by token AND generation. Settlement
|
|
424
|
+
* and renewal require a matching, unexpired lease; leaseMs must be a positive safe integer.
|
|
425
|
+
* Execution recovery preserves the idempotency key (delivery is at least once, not exactly once).
|
|
426
|
+
*/
|
|
427
|
+
interface ActionProposalStore {
|
|
428
|
+
createActionProposal(input: CreateActionProposal): Promise<CreateActionProposalResult>;
|
|
429
|
+
getActionProposal(scope: ActionProposalScope, id: string): Promise<ActionProposal | null>;
|
|
430
|
+
listActionProposals(scope: ActionProposalScope, query?: ListActionProposals): Promise<ActionProposal[]>;
|
|
431
|
+
decideActionProposal(scope: ActionProposalScope, id: string, command: ActionProposalDecisionCommand): Promise<ActionProposalMutationResult>;
|
|
432
|
+
claimActionProposal(scope: ActionProposalScope, id: string, command: ClaimActionProposal): Promise<ActionProposalMutationResult>;
|
|
433
|
+
extendActionProposalLease(scope: ActionProposalScope, id: string, command: ExtendActionProposalLease): Promise<ActionProposalMutationResult>;
|
|
434
|
+
settleActionProposal(scope: ActionProposalScope, id: string, command: SettleActionProposal): Promise<ActionProposalMutationResult>;
|
|
435
|
+
}
|
|
436
|
+
interface ActionProposalSupersessionStore {
|
|
437
|
+
createReplacingActionProposal(input: CreateActionProposal): Promise<CreateActionProposalResult>;
|
|
438
|
+
supersedeActionProposal(scope: ActionProposalScope, id: string, command: {
|
|
439
|
+
replacementProposalId: string;
|
|
440
|
+
actorRef: string;
|
|
441
|
+
via: string;
|
|
442
|
+
}): Promise<ActionProposalMutationResult>;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
interface ActionProposalOutcome extends ActionProposalScope {
|
|
446
|
+
id: string;
|
|
447
|
+
proposalId: string;
|
|
448
|
+
outcomeVersion: 1;
|
|
449
|
+
originRunId: string;
|
|
450
|
+
originToolCallId: string;
|
|
451
|
+
toolName: string;
|
|
452
|
+
decision: ActionProposalDecision;
|
|
453
|
+
executionStatus?: 'succeeded' | 'failed';
|
|
454
|
+
result?: unknown;
|
|
455
|
+
error?: string;
|
|
456
|
+
ui: AgentUiComponent[];
|
|
457
|
+
text?: string;
|
|
458
|
+
createdAt: number;
|
|
459
|
+
}
|
|
460
|
+
interface ActionProposalOutcomeDelivery {
|
|
461
|
+
status: 'pending' | 'admitted' | 'discarded';
|
|
462
|
+
generation: number;
|
|
463
|
+
lease: ActionProposalLease | null;
|
|
464
|
+
messageId?: string;
|
|
465
|
+
}
|
|
466
|
+
interface ActionProposalOutcomeLease {
|
|
467
|
+
outcomeId: string;
|
|
468
|
+
token: string;
|
|
469
|
+
generation: number;
|
|
470
|
+
}
|
|
471
|
+
interface ActionProposalOutcomeStore {
|
|
472
|
+
getThreadActionProposalScope(threadId: string): Promise<ActionProposalScope | null>;
|
|
473
|
+
claimNextActionProposalOutcome(command: {
|
|
474
|
+
workerId: string;
|
|
475
|
+
leaseMs: number;
|
|
476
|
+
}): Promise<{
|
|
477
|
+
outcome: ActionProposalOutcome;
|
|
478
|
+
lease: ActionProposalOutcomeLease;
|
|
479
|
+
} | null>;
|
|
480
|
+
admitActionProposalOutcome(command: ActionProposalOutcomeLease): Promise<{
|
|
481
|
+
status: 'applied' | 'unchanged' | 'busy' | 'conflict' | 'not_found' | 'discarded';
|
|
482
|
+
messageId?: string;
|
|
483
|
+
}>;
|
|
484
|
+
}
|
|
485
|
+
|
|
72
486
|
/**
|
|
73
487
|
* What a store knows about a tool call, read back when its message carries no result for it — see
|
|
74
488
|
* {@link import('./spi/agent-store.js').AgentStore.toolCallOutcomes}.
|
|
@@ -119,6 +533,7 @@ interface CreateThreadInput {
|
|
|
119
533
|
persona?: string;
|
|
120
534
|
}
|
|
121
535
|
interface AppendMessageInput {
|
|
536
|
+
actionProposalOutcome?: ActionProposalOutcome;
|
|
122
537
|
threadId: string;
|
|
123
538
|
role: StoredMessage['role'];
|
|
124
539
|
content: string;
|
|
@@ -148,6 +563,9 @@ interface AppendMessageInput {
|
|
|
148
563
|
ui?: AgentUiComponent[];
|
|
149
564
|
}
|
|
150
565
|
interface RecordToolCallInput {
|
|
566
|
+
proposalId?: string;
|
|
567
|
+
/** Resolved confirmation from the action preflight; overrides presentation templates. */
|
|
568
|
+
confirmation?: ToolConfirmation;
|
|
151
569
|
toolCallId: string;
|
|
152
570
|
messageId: string;
|
|
153
571
|
toolName: string;
|
|
@@ -500,6 +918,7 @@ interface QueuedMessage {
|
|
|
500
918
|
persona?: string;
|
|
501
919
|
model?: string;
|
|
502
920
|
pageContext?: PageContext;
|
|
921
|
+
uiCapabilities?: UiCapabilities;
|
|
503
922
|
/**
|
|
504
923
|
* Queued by an interrupt (`POST chat { mode: 'interrupt' }`): the running turn was cancelled to
|
|
505
924
|
* make room for it, so the cancel starts it instead of pausing the queue.
|
|
@@ -538,6 +957,7 @@ interface EnqueueMessageInput {
|
|
|
538
957
|
persona?: string;
|
|
539
958
|
model?: string;
|
|
540
959
|
pageContext?: PageContext;
|
|
960
|
+
uiCapabilities?: UiCapabilities;
|
|
541
961
|
interrupt?: boolean;
|
|
542
962
|
/** `'tail'` (default) runs it after everything already waiting; `'head'` runs it next. */
|
|
543
963
|
at?: 'tail' | 'head';
|
|
@@ -702,97 +1122,214 @@ interface AgentHistoryWindow {
|
|
|
702
1122
|
summarize?: boolean;
|
|
703
1123
|
}
|
|
704
1124
|
|
|
705
|
-
/**
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
/** One line naming what the tool reaches, for when the activity line is opened. */
|
|
726
|
-
detail?: string;
|
|
727
|
-
/** `destructive` earns the warning treatment on an approval prompt. */
|
|
728
|
-
tone?: ToolPresentationTone;
|
|
729
|
-
/** What a person is being asked to allow when an `action` call parks for approval. */
|
|
730
|
-
confirm?: ToolConfirmation;
|
|
731
|
-
/** How the call's OUTPUT reads as content. */
|
|
732
|
-
result?: ToolResultView;
|
|
733
|
-
}
|
|
734
|
-
type ToolPresentationTone = 'neutral' | 'destructive';
|
|
735
|
-
interface ToolConfirmation {
|
|
736
|
-
/** "Delete {count} files?" */
|
|
1125
|
+
/** Plain, durable data. Renderer functions and binary attachments never enter a UI frame. */
|
|
1126
|
+
interface ComponentPresentation<P = Record<string, unknown>> {
|
|
1127
|
+
component: string;
|
|
1128
|
+
props: P;
|
|
1129
|
+
version: number;
|
|
1130
|
+
fallbackText: string;
|
|
1131
|
+
}
|
|
1132
|
+
interface ComponentFactory<Input, Output = Input> {
|
|
1133
|
+
(props: Input): Promise<ComponentPresentation<Output>>;
|
|
1134
|
+
readonly definition: ComponentDefinition<Output>;
|
|
1135
|
+
}
|
|
1136
|
+
/** Reject values JSON would silently discard/coerce, and detach from caller-owned objects. */
|
|
1137
|
+
declare function snapshotComponentPresentation<T>(value: T): T;
|
|
1138
|
+
declare function createComponent<S extends StandardSchemaV1>(definition: Omit<ComponentDefinition<StandardSchemaV1.InferOutput<S>>, 'props'> & {
|
|
1139
|
+
props: S;
|
|
1140
|
+
}, options?: CatalogOptions): ComponentFactory<StandardSchemaV1.InferInput<S>, StandardSchemaV1.InferOutput<S>>;
|
|
1141
|
+
declare function createComponent<P = Record<string, unknown>>(definition: ComponentDefinition<P>, options?: CatalogOptions): ComponentFactory<P>;
|
|
1142
|
+
type ComponentRenderer<P = Record<string, unknown>, Context = unknown> = (props: P, context?: Context) => unknown | Promise<unknown>;
|
|
1143
|
+
interface ComponentManifest {
|
|
1144
|
+
name: string;
|
|
737
1145
|
title: string;
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
1146
|
+
description: string;
|
|
1147
|
+
version: number;
|
|
1148
|
+
props?: JsonSchema;
|
|
1149
|
+
}
|
|
1150
|
+
interface ComponentRegistry<Context = unknown> {
|
|
1151
|
+
readonly catalog: Catalog;
|
|
1152
|
+
readonly manifest: readonly ComponentManifest[];
|
|
1153
|
+
register<P>(definition: ComponentDefinition<P>, renderers: Record<string, ComponentRenderer<P, Context>>): this;
|
|
1154
|
+
/** Revalidate against the app's authoritative definition and regenerate trusted fallback text. */
|
|
1155
|
+
prepare(presentation: ComponentPresentation): Promise<ComponentPresentation>;
|
|
1156
|
+
render(presentation: ComponentPresentation, channel: string, context?: Context): Promise<unknown>;
|
|
1157
|
+
}
|
|
1158
|
+
/** A registry is owned by one app/tenant; registering never mutates a shared singleton. */
|
|
1159
|
+
declare function createComponentRegistry<Context = unknown>(options?: CatalogOptions): ComponentRegistry<Context>;
|
|
1160
|
+
type TableCell = string | number | boolean | null;
|
|
1161
|
+
interface TableProps {
|
|
1162
|
+
title?: string;
|
|
1163
|
+
columns: {
|
|
1164
|
+
key: string;
|
|
1165
|
+
label: string;
|
|
1166
|
+
align?: 'left' | 'right' | 'center';
|
|
1167
|
+
format?: 'text' | 'number' | 'currency' | 'percent' | 'date' | 'link';
|
|
1168
|
+
}[];
|
|
1169
|
+
rows: Record<string, TableCell>[];
|
|
1170
|
+
}
|
|
1171
|
+
interface ChartProps {
|
|
1172
|
+
type: 'bar' | 'line';
|
|
1173
|
+
title?: string;
|
|
1174
|
+
xKey: string;
|
|
1175
|
+
series: {
|
|
1176
|
+
key: string;
|
|
1177
|
+
label?: string;
|
|
1178
|
+
}[];
|
|
1179
|
+
data: Record<string, TableCell>[];
|
|
747
1180
|
unit?: string;
|
|
748
1181
|
}
|
|
1182
|
+
declare const table: ComponentFactory<TableProps, TableProps>;
|
|
1183
|
+
declare const chart: ComponentFactory<ChartProps, ChartProps>;
|
|
1184
|
+
/** Prepare all JSON emissions before any sink receives a partial batch. Factories validate schemas. */
|
|
1185
|
+
declare function validatePresentationBatch(presentations: ComponentPresentation<object> | readonly ComponentPresentation<object>[]): ComponentPresentation[];
|
|
1186
|
+
|
|
749
1187
|
/**
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
1188
|
+
* Per-invocation context handed to a tool handler. Host-supplied bits are optional. Identity lives
|
|
1189
|
+
* on {@link AiToolCtx.actor} — read `ctx.actor.id` / `ctx.actor.tenantRef` (single source of truth;
|
|
1190
|
+
* no denormalized copies).
|
|
753
1191
|
*/
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
{
|
|
757
|
-
|
|
758
|
-
|
|
1192
|
+
interface AiToolCtx {
|
|
1193
|
+
/** Reports presentation failures separately from successful domain execution. */
|
|
1194
|
+
onPresentationError?(error: unknown, details: {
|
|
1195
|
+
toolName: string;
|
|
1196
|
+
}): void | Promise<void>;
|
|
1197
|
+
uiCapabilities?: UiCapabilities;
|
|
1198
|
+
actor: Actor;
|
|
1199
|
+
threadId: string;
|
|
1200
|
+
runId: string;
|
|
1201
|
+
requestId: string;
|
|
1202
|
+
/**
|
|
1203
|
+
* The id of the tool call this invocation serves. Absent where a tool is invoked outside a turn
|
|
1204
|
+
* (the MCP server, a direct `registry.invoke`).
|
|
1205
|
+
*/
|
|
1206
|
+
toolCallId?: string;
|
|
1207
|
+
/**
|
|
1208
|
+
* `<runId>:<toolCallId>` — the same value for every execution of THIS call, and for no other.
|
|
1209
|
+
*
|
|
1210
|
+
* A tool's side effect and the checkpoint that records it are two writes. Under the durable
|
|
1211
|
+
* runner a worker that dies between them leaves a call the journal does not know ran, and the
|
|
1212
|
+
* runtime's recovery runs it again; an in-step transient retry (a deadlock, a lock-wait timeout)
|
|
1213
|
+
* re-invokes it too. The library cannot make your write atomic with its journal — so it hands you
|
|
1214
|
+
* the key that makes the second attempt recognisable: pass it to whatever you call as its
|
|
1215
|
+
* idempotency key (a payment provider's `Idempotency-Key`, a unique column on the row you insert,
|
|
1216
|
+
* a workflow's `id`), and a re-execution lands on the first one's result instead of doing it
|
|
1217
|
+
* twice. Stable across replays and across pods: the run id is the run's own, and the call id
|
|
1218
|
+
* comes out of the journaled model step.
|
|
1219
|
+
*
|
|
1220
|
+
* Absent where a tool is invoked outside a turn (the MCP server, a direct `registry.invoke`).
|
|
1221
|
+
*/
|
|
1222
|
+
idempotencyKey?: string;
|
|
1223
|
+
/** The name of the agent running this turn — provenance a tool can scope on (e.g. capability sets). */
|
|
1224
|
+
agentName?: string;
|
|
1225
|
+
/** The persona of {@link agentName} the turn runs under, when it runs under one. */
|
|
1226
|
+
persona?: string;
|
|
1227
|
+
pageContext?: PageContext;
|
|
1228
|
+
/** Optional host handle (e.g. an ORM EntityManager) the app threads through options. */
|
|
1229
|
+
host?: unknown;
|
|
1230
|
+
/**
|
|
1231
|
+
* Push a component into the assistant message: streamed live as a `ui` frame and persisted on
|
|
1232
|
+
* the message, so a reload shows it where the live stream did. Resolves to the component's id.
|
|
1233
|
+
*
|
|
1234
|
+
* `id` defaults to `<toolCallId>:ui:<n>` (the n-th push without an `id` in this invocation), so a retried or
|
|
1235
|
+
* re-executed call REPLACES what it pushed before instead of adding a second copy; pass your own
|
|
1236
|
+
* `id` to update one component across pushes (streaming rows into a table). `props` must be
|
|
1237
|
+
* JSON; it is snapshotted when pushed.
|
|
1238
|
+
*
|
|
1239
|
+
* Replay-safe under the durable runner: the pushed components ride the tool step's journaled
|
|
1240
|
+
* result, so a replay neither streams nor persists them again.
|
|
1241
|
+
*
|
|
1242
|
+
* Always present. On a surface with no conversation to push into (the MCP server, a direct
|
|
1243
|
+
* `registry.invoke` without one) it is a no-op that still resolves to an id, so a tool calls
|
|
1244
|
+
* `ctx.emitUi(…)` unconditionally.
|
|
1245
|
+
*/
|
|
1246
|
+
emitUi(component: string, props: Record<string, unknown>, options?: EmitUiOptions): Promise<{
|
|
1247
|
+
id: string;
|
|
1248
|
+
}>;
|
|
759
1249
|
}
|
|
760
|
-
/**
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
columns: ToolResultField[];
|
|
764
|
-
rows: string;
|
|
765
|
-
empty?: string;
|
|
1250
|
+
/** When the action state is being checked. */
|
|
1251
|
+
interface ToolPreflightOptions {
|
|
1252
|
+
phase: 'prepare' | 'execute';
|
|
766
1253
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
1254
|
+
type ToolPreflightResult<O = unknown> = {
|
|
1255
|
+
status: 'ready';
|
|
1256
|
+
confirmation?: ToolConfirmation;
|
|
1257
|
+
} | {
|
|
1258
|
+
status: 'denied';
|
|
1259
|
+
reason: string;
|
|
1260
|
+
} | {
|
|
1261
|
+
status: 'completed';
|
|
1262
|
+
output: O;
|
|
1263
|
+
};
|
|
1264
|
+
/** A tool implementation. `I` is the input parsed by its registered Standard Schema. */
|
|
1265
|
+
interface ToolHandler<I = unknown, O = unknown> {
|
|
1266
|
+
execute(input: I, ctx: AiToolCtx): Promise<O>;
|
|
1267
|
+
/** Optional UI derived from successful domain output; errors never fail the domain action. */
|
|
1268
|
+
present?(output: O, ctx: AiToolCtx): ComponentPresentation<object> | readonly ComponentPresentation<object>[] | undefined | Promise<ComponentPresentation<object> | readonly ComponentPresentation<object>[] | undefined>;
|
|
1269
|
+
/** Read-only action check. Runs after authorization and validation, before approval and again
|
|
1270
|
+
* immediately before execution. Confirmation strings are resolved, never templates. */
|
|
1271
|
+
preflight?(input: I, ctx: AiToolCtx, options: ToolPreflightOptions): ToolPreflightResult<O> | Promise<ToolPreflightResult<O>>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Whether this tool exists in this deployment at all — evaluated per turn, BEFORE the roles
|
|
1274
|
+
* policy, so a `false` here means the model is never shown the tool rather than being shown one
|
|
1275
|
+
* it will be refused. Omit → always enabled.
|
|
1276
|
+
*
|
|
1277
|
+
* This is the seam for a feature flag or a licensing tier: the handler is an ordinary provider,
|
|
1278
|
+
* so it can read injected config (`this.config.featureX`) that a decorator, evaluated at import
|
|
1279
|
+
* time, cannot. Answering "does this capability exist here?"; `roles`/`RolesPolicy` answers the
|
|
1280
|
+
* separate question "may THIS actor use it?", and both still run.
|
|
1281
|
+
*
|
|
1282
|
+
* Prefer this over conditionally registering the provider: registration happens while the
|
|
1283
|
+
* `@Module` metadata is built, which in most apps is before configuration is loaded.
|
|
1284
|
+
*/
|
|
1285
|
+
isEnabled?(): boolean | Promise<boolean>;
|
|
1286
|
+
/**
|
|
1287
|
+
* Whether THIS actor may use the tool, decided per turn. Omit → the role gate alone decides.
|
|
1288
|
+
*
|
|
1289
|
+
* The three existing gates all answer the question somewhere else: `roles` is static data,
|
|
1290
|
+
* `RolesPolicy` is one app-wide rule for every tool, and an agent's `tools` allow-list is fixed
|
|
1291
|
+
* when the agent is declared. This one lives on the tool and runs with DI, so it can ask the
|
|
1292
|
+
* questions only the tool knows to ask — is this user's org on the plan that includes it, does
|
|
1293
|
+
* this actor own the base being queried, is the per-user override in the DB set today.
|
|
1294
|
+
*
|
|
1295
|
+
* Runs AFTER {@link isEnabled} and the `RolesPolicy`, and all of them must pass. Applied both
|
|
1296
|
+
* when the turn's tool list is built (a denied actor is never shown it) and again on invoke.
|
|
1297
|
+
*/
|
|
1298
|
+
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1299
|
+
/**
|
|
1300
|
+
* What the model is told about this tool for THIS turn — a description and/or input schema that
|
|
1301
|
+
* depend on who is asking (a per-tenant component catalog, a per-plan list of options). Called
|
|
1302
|
+
* when the turn's tool list is built, after every gate has passed; whatever it returns replaces
|
|
1303
|
+
* the registered spec's `description` / `inputSchema` in the definition the model sees. Omit, or
|
|
1304
|
+
* return `undefined`, to use the registered spec as is.
|
|
1305
|
+
*
|
|
1306
|
+
* It shapes what the model is SHOWN only: the registry still validates a call against the
|
|
1307
|
+
* registered `inputSchema`, so a tool whose accepted input varies per turn registers a permissive
|
|
1308
|
+
* schema and validates in `execute`.
|
|
1309
|
+
*/
|
|
1310
|
+
describe?(scope: ToolDescribeScope): ToolDescription | undefined | Promise<ToolDescription | undefined>;
|
|
771
1311
|
}
|
|
772
|
-
/**
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
1312
|
+
/** Who a turn's tool list is being built for — what {@link ToolHandler.describe} can vary on. */
|
|
1313
|
+
interface ToolDescribeScope {
|
|
1314
|
+
uiCapabilities?: UiCapabilities;
|
|
1315
|
+
actor: Actor;
|
|
1316
|
+
/** Absent where the list is built outside a conversation (the MCP server's `tools/list`). */
|
|
1317
|
+
threadId?: string;
|
|
1318
|
+
agentName?: string;
|
|
776
1319
|
}
|
|
777
|
-
/**
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
*/
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
*/
|
|
791
|
-
interface ToolCatalogEntry {
|
|
792
|
-
/** The wire name tool parts carry (`tool-<name>`) — the key a client looks a call up by. */
|
|
793
|
-
name: string;
|
|
794
|
-
kind: ToolKind;
|
|
795
|
-
presentation?: ToolPresentation;
|
|
1320
|
+
/** A per-turn override of a tool's model-facing definition ({@link ToolHandler.describe}). */
|
|
1321
|
+
interface ToolDescription {
|
|
1322
|
+
/** False removes this tool from the current model-facing catalog. */
|
|
1323
|
+
available?: boolean;
|
|
1324
|
+
description?: string;
|
|
1325
|
+
inputSchema?: StandardSchemaV1;
|
|
1326
|
+
}
|
|
1327
|
+
/** Metadata recorded with a pushed UI component. */
|
|
1328
|
+
interface EmitUiOptions {
|
|
1329
|
+
id?: string;
|
|
1330
|
+
version?: number;
|
|
1331
|
+
fallbackText?: string;
|
|
1332
|
+
componentVersions?: Record<string, number>;
|
|
796
1333
|
}
|
|
797
1334
|
|
|
798
1335
|
/**
|
|
@@ -911,6 +1448,8 @@ interface DetachedDelivery {
|
|
|
911
1448
|
* remedy is the read-back that lets them delete it.
|
|
912
1449
|
*/
|
|
913
1450
|
interface ToolSpec {
|
|
1451
|
+
/** Explicit domain identity for pending-only replacement; evaluated on approved normalized input. */
|
|
1452
|
+
replacementKey?: string | ((input: unknown, ctx: AiToolCtx) => string | undefined | Promise<string | undefined>);
|
|
914
1453
|
name: string;
|
|
915
1454
|
kind: ToolKind;
|
|
916
1455
|
description: string;
|
|
@@ -966,8 +1505,9 @@ interface ToolSpec {
|
|
|
966
1505
|
enabled?: boolean | (() => boolean | Promise<boolean>);
|
|
967
1506
|
/**
|
|
968
1507
|
* An authorization ability name (e.g. 'cache.purge'). Consumed by an ability-aware RolesPolicy
|
|
969
|
-
* such as the `@dudousxd/nestjs-agent-authz` Gate adapter.
|
|
970
|
-
*
|
|
1508
|
+
* such as the `@dudousxd/nestjs-agent-authz` Gate adapter. A policy that can't evaluate one (the
|
|
1509
|
+
* role-based default) refuses a tool that names an `ability` and no `roles` — fail closed rather
|
|
1510
|
+
* than open; a tool naming both falls back to its `roles` there.
|
|
971
1511
|
*/
|
|
972
1512
|
ability?: string;
|
|
973
1513
|
}
|
|
@@ -980,6 +1520,19 @@ interface ToolDefinition {
|
|
|
980
1520
|
}
|
|
981
1521
|
/** A tool call the model asked for during a turn. */
|
|
982
1522
|
interface ToolCallRequest {
|
|
1523
|
+
actionApproval?: ClaimedActionApproval;
|
|
1524
|
+
prepared?: {
|
|
1525
|
+
preparationInput: unknown;
|
|
1526
|
+
input: unknown;
|
|
1527
|
+
preflight: ToolPreflightResult;
|
|
1528
|
+
replacementKey?: string;
|
|
1529
|
+
};
|
|
1530
|
+
/** Trusted action preparation from the dispatched model worker, journaled with its turn.
|
|
1531
|
+
* Model-provider supplied values are overwritten by the worker. Absent on legacy turns. */
|
|
1532
|
+
preflight?: ToolPreflightResult | {
|
|
1533
|
+
status: 'failed';
|
|
1534
|
+
error: string;
|
|
1535
|
+
};
|
|
983
1536
|
id: string;
|
|
984
1537
|
name: string;
|
|
985
1538
|
input: unknown;
|
|
@@ -1149,6 +1702,7 @@ interface PromptContext {
|
|
|
1149
1702
|
/** The selected agent's name. */
|
|
1150
1703
|
agentName: string;
|
|
1151
1704
|
pageContext?: PageContext;
|
|
1705
|
+
uiCapabilities?: UiCapabilities;
|
|
1152
1706
|
/**
|
|
1153
1707
|
* The persona this turn runs under, when it runs under one — so an agent's own `@SystemPrompt`
|
|
1154
1708
|
* (or a contributor) can vary by persona without the persona carrying a prompt of its own.
|
|
@@ -1236,6 +1790,7 @@ interface AgentRunInput {
|
|
|
1236
1790
|
/** Files attached to the latest user message (image/PDF). Persisted with it and sent to the model. */
|
|
1237
1791
|
attachments?: MessageAttachment[];
|
|
1238
1792
|
pageContext?: PageContext;
|
|
1793
|
+
uiCapabilities?: UiCapabilities;
|
|
1239
1794
|
/** YYYY-MM-DD stamped by the runner so quota/day stays deterministic under durable replay. */
|
|
1240
1795
|
day?: string;
|
|
1241
1796
|
/** Which named agent runs this turn. Omitted → the default/single agent. */
|
|
@@ -1411,6 +1966,7 @@ interface ThreadSummary {
|
|
|
1411
1966
|
persona?: string | null;
|
|
1412
1967
|
}
|
|
1413
1968
|
interface StoredMessage {
|
|
1969
|
+
actionProposalOutcome?: ActionProposalOutcome;
|
|
1414
1970
|
id: string;
|
|
1415
1971
|
role: MessageRole;
|
|
1416
1972
|
content: string;
|
|
@@ -1476,6 +2032,14 @@ interface MessageFeedback {
|
|
|
1476
2032
|
type ToolCallApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
1477
2033
|
/** The persisted approval metadata of one action tool call. See {@link StoredMessage.approvals}. */
|
|
1478
2034
|
interface ToolCallApproval {
|
|
2035
|
+
target?: {
|
|
2036
|
+
kind: 'proposal';
|
|
2037
|
+
proposalId: string;
|
|
2038
|
+
threadId?: string;
|
|
2039
|
+
};
|
|
2040
|
+
proposalId?: string;
|
|
2041
|
+
/** Resolved confirmation from the action preflight; overrides presentation templates. */
|
|
2042
|
+
confirmation?: ToolConfirmation;
|
|
1479
2043
|
toolCallId: string;
|
|
1480
2044
|
/** Who may decide: `'requester'` (the thread's own actor) or a role name. */
|
|
1481
2045
|
approver: string;
|
|
@@ -1500,7 +2064,7 @@ interface ThreadDetail extends ThreadSummary {
|
|
|
1500
2064
|
*/
|
|
1501
2065
|
queue?: ChatQueueState;
|
|
1502
2066
|
}
|
|
1503
|
-
type ToolCallStatus = 'auto_executed' | 'pending_approval' | 'executed' | 'rejected' | 'failed'
|
|
2067
|
+
type ToolCallStatus = 'proposed' | 'auto_executed' | 'pending_approval' | 'executed' | 'rejected' | 'failed'
|
|
1504
2068
|
/** An approval request lapsed before anyone decided; the tool never ran. */
|
|
1505
2069
|
| 'expired';
|
|
1506
2070
|
/**
|
|
@@ -1508,6 +2072,9 @@ type ToolCallStatus = 'auto_executed' | 'pending_approval' | 'executed' | 'rejec
|
|
|
1508
2072
|
* re-resolves the model/sink/registry from its own DI via AGENT_DEPS_FACTORY.forAgent(agentName).
|
|
1509
2073
|
*/
|
|
1510
2074
|
interface LlmStepEnvelope {
|
|
2075
|
+
actionApprovalMode?: 'blocking' | 'independent';
|
|
2076
|
+
/** Full invocation identity for action preparation at the worker. Optional for old envelopes. */
|
|
2077
|
+
preflightContext?: ToolStepCtx;
|
|
1511
2078
|
/** Undefined = default agent (same semantics as {@link AgentRunInput.agentName}). */
|
|
1512
2079
|
agentName?: string;
|
|
1513
2080
|
system: string;
|
|
@@ -1547,6 +2114,7 @@ interface ToolStepCtx {
|
|
|
1547
2114
|
/** The persona the turn runs under ({@link AiToolCtx.persona}). */
|
|
1548
2115
|
persona?: string;
|
|
1549
2116
|
pageContext?: PageContext;
|
|
2117
|
+
uiCapabilities?: UiCapabilities;
|
|
1550
2118
|
}
|
|
1551
2119
|
/** Serializable input for a dispatched tool-execution step. */
|
|
1552
2120
|
interface ToolStepEnvelope {
|
|
@@ -1839,6 +2407,10 @@ interface AgentUiComponent {
|
|
|
1839
2407
|
props: Record<string, unknown>;
|
|
1840
2408
|
/** Schema version of `props`, so a client can keep rendering components persisted by an older server. */
|
|
1841
2409
|
version?: number;
|
|
2410
|
+
/** Validated readable fallback retained for clients without this renderer. */
|
|
2411
|
+
fallbackText?: string;
|
|
2412
|
+
/** Trusted schema versions for every component in a persisted tree. */
|
|
2413
|
+
componentVersions?: Record<string, number>;
|
|
1842
2414
|
/**
|
|
1843
2415
|
* The tool call that pushed the component (`ctx.emitUi`), when one did. Lets a client place it
|
|
1844
2416
|
* with that call — a reloaded message puts it right after the call's tool part, where the live
|
|
@@ -1851,6 +2423,12 @@ interface AgentUiComponent {
|
|
|
1851
2423
|
* settled through the tool-call approve/reject routes, by its `toolCallId`.
|
|
1852
2424
|
*/
|
|
1853
2425
|
interface AgentApprovalRequest {
|
|
2426
|
+
target?: {
|
|
2427
|
+
kind: 'proposal';
|
|
2428
|
+
proposalId: string;
|
|
2429
|
+
};
|
|
2430
|
+
/** Resolved confirmation from the action preflight; overrides presentation templates. */
|
|
2431
|
+
confirmation?: ToolConfirmation;
|
|
1854
2432
|
/** The tool call awaiting the decision — the `id` of a call already announced on this stream. */
|
|
1855
2433
|
id: string;
|
|
1856
2434
|
/**
|
|
@@ -2066,4 +2644,4 @@ type AgentStreamErrorCode = 'quota_exceeded' | 'output_rejected' | 'structured_o
|
|
|
2066
2644
|
/** A model call ended without producing anything. */
|
|
2067
2645
|
| 'model_no_output' | 'run_failed';
|
|
2068
2646
|
|
|
2069
|
-
export {
|
|
2647
|
+
export { type Decision as $, type AgentStreamEvent as A, type ActionProposalMutationResult as B, type ChartProps as C, type ActionProposal as D, type ActionProposalExecution as E, type ActionProposalOutcomeDelivery as F, type AgentDefinition as G, type HumanReply as H, type Persona as I, type PersonaCatalogEntry as J, type HistoryPolicy as K, type PageContext as L, type ModelMessage as M, type AgentStore as N, type AgentDelegation as O, type PreparedUiEmission as P, type QuotaState as Q, type DetachedDelivery as R, type ToolDescribeScope as S, type ToolSpec as T, type UiCapabilities as U, type ToolPreflightResult as V, type ApprovalPolicy as W, type PromptBuilder as X, type PromptContributor as Y, type ToolTransientRetrySetting as Z, type AgentIntake as _, type Actor as a, ELICITATION_INPUT_TYPES as a$, type ElicitationRequest as a0, type LlmStepEnvelope as a1, type ToolStepEnvelope as a2, type ClaimActionProposal as a3, type ActionProposalStore as a4, type ActionProposalStoreOptions as a5, type CreateActionProposal as a6, type CreateActionProposalResult as a7, type ActionProposalScope as a8, type ListActionProposals as a9, type ToolConfirmation as aA, type ActionProposalDecision as aB, type ActionProposalSupersessionStore as aC, ALL_AGENTS as aD, ASK_TOOL_DESCRIPTION as aE, ASK_TOOL_NAME as aF, type ActionProposalDecisionAudit as aG, type ActionProposalExecutionContext as aH, type ActionProposalLease as aI, type AgentApprovalRequest as aJ, type AgentApprovalSettlement as aK, type AgentAttachmentConfig as aL, type AgentCatalogEntry as aM, type AgentClientConfig as aN, type AgentHistoryWindow as aO, type AgentStreamErrorCode as aP, type ApprovalDecisionRef as aQ, type ApprovalRequirement as aR, type ApprovalThreadRef as aS, type ApprovalToolRef as aT, type AskToolInput as aU, type ChatQueueState as aV, type ClaimedActionApproval as aW, DEFAULT_INTAKE_PREAMBLE as aX, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as aY, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as aZ, DefaultApprovalPolicy as a_, type ActionProposalDecisionCommand as aa, type ExtendActionProposalLease as ab, type SettleActionProposal as ac, type ActionProposalOutcome as ad, type ActionProposalOutcomeLease as ae, type ToolCallStatus as af, type ChatQueueStore as ag, type ActionProposalOutcomeStore as ah, type CreateThreadInput as ai, type ThreadSummary as aj, type ThreadDetail as ak, type ToolCallApprovalState as al, type UpdateThreadInput as am, type RecordRunStartInput as an, type EnqueueMessageInput as ao, type QueuedMessage as ap, type QueuedMessagePatch as aq, type QueuePause as ar, type AppendMessageInput as as, type StoredMessage as at, type ToolResult as au, type MessageFeedback as av, type RecordToolCallInput as aw, type ToolCallOutcome as ax, type UpdateToolCallInput as ay, type RecordUsageInput as az, type ToolHandler as b, resolveToolTransientRetryNumbers as b$, type ElicitationInput as b0, type ElicitationInputType as b1, type ElicitationOption as b2, type ElicitationOutcome as b3, type ElicitationQuestion as b4, type ElicitationReply as b5, type ElicitationResult as b6, type EmitUiOptions as b7, type HistoryPolicyContext as b8, type HistorySelection as b9, type ToolResultView as bA, type ToolStepCtx as bB, type ToolTransientRetryNumbers as bC, type ToolTransientRetryOptions as bD, type TurnPersona as bE, UNFINISHED_TOOL_CALL as bF, type UsagePurpose as bG, askInputSchema as bH, askToolDefinition as bI, danglingToolCallIds as bJ, decodeStreamEvent as bK, defaultCanDecide as bL, encodeStreamEvent as bM, invokeWithTransientRetry as bN, isChatQueueStore as bO, isTransientToolError as bP, isTypedQuestion as bQ, mayDecideApproval as bR, normalizeElicitationReply as bS, questionOptions as bT, queuedMessageView as bU, readElicitationInput as bV, readElicitationQuestions as bW, releaseThreadRun as bX, renderElicitationAnswers as bY, resolveActionProposalApproval as bZ, resolveElicitation as b_, type HistorySummary as ba, type InvokeWithTransientRetryOptions as bb, MAX_ASK_QUESTIONS as bc, type MessageFeedbackValue as bd, type MessageRole as be, type PersonaRef as bf, type PromptContext as bg, type QueuePauseReason as bh, type QueuedMessageView as bi, type QuotaView as bj, REQUESTER_APPROVER as bk, RUN_ENDED_BEFORE_TOOL_CALL as bl, type RecordRunEndInput as bm, type ResolveActionProposalApprovalInput as bn, type ThreadTurnPage as bo, type ThreadTurnQuery as bp, type ThreadTurnReader as bq, type ToolCallApproval as br, type ToolCallApprovalColumns as bs, type ToolCallApprovalStatus as bt, type ToolCatalogEntry as bu, type ToolDescription as bv, type ToolKind as bw, type ToolPreflightOptions as bx, type ToolPresentationTone as by, type ToolResultField as bz, type ToolPresentation as c, settleDanglingToolCalls as c0, settleElicitation as c1, toolCallApprovalFromRow as c2, validateElicitationAnswer as c3, validateElicitationValue as c4, type ComponentFactory as d, type ComponentManifest as e, type ComponentPresentation as f, type ComponentRegistry as g, type ComponentRenderer as h, type TableCell as i, type TableProps as j, chart as k, createComponent as l, createComponentRegistry as m, negotiateCatalog as n, validateUiCapabilities as o, prepareUiEmission as p, type ToolDefinition as q, type ToolCallRequest as r, snapshotComponentPresentation as s, table as t, type MessageUsage as u, validatePresentationBatch as v, type AgentUiComponent as w, type AiToolCtx as x, type AgentRunInput as y, type MessageAttachment as z };
|