@dudousxd/nestjs-agent-core 0.19.0 → 0.21.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 +3 -1
- package/dist/guardrails/index.d.cts +1 -1
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/index.cjs +622 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -5
- package/dist/index.d.ts +151 -5
- package/dist/index.js +609 -42
- package/dist/index.js.map +1 -1
- package/dist/{tool-Q2rmGeaG.d.cts → tool-CwXibnce.d.cts} +164 -3
- package/dist/{tool-Q2rmGeaG.d.ts → tool-CwXibnce.d.ts} +164 -3
- package/package.json +1 -1
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Typed answers for a question set: a question that asks for a number, a date, an email or a
|
|
5
|
+
* sentence instead of offering options to pick.
|
|
6
|
+
*
|
|
7
|
+
* Answers stay `string[]` on the wire whatever the type — the signal that carries them, the row that
|
|
8
|
+
* records them and the model that reads them back all see strings — so this module fixes ONE
|
|
9
|
+
* canonical string per type and validates against it:
|
|
10
|
+
*
|
|
11
|
+
* | `type` | canonical value |
|
|
12
|
+
* |------------|----------------------------------------------|
|
|
13
|
+
* | `text` | the text |
|
|
14
|
+
* | `textarea` | the text (newlines kept) |
|
|
15
|
+
* | `number` | a finite decimal, e.g. `"42"`, `"-1.5"` |
|
|
16
|
+
* | `boolean` | `"true"` or `"false"` |
|
|
17
|
+
* | `date` | `YYYY-MM-DD` |
|
|
18
|
+
* | `email` | an address with one `@` and a dotted domain |
|
|
19
|
+
* | `url` | an absolute `http:`/`https:` URL |
|
|
20
|
+
* | `select` | one of the question's `options[].value` |
|
|
21
|
+
*
|
|
22
|
+
* Pure and dependency-free, so the loop (which filters what it settles on), the HTTP surface (which
|
|
23
|
+
* refuses what it cannot settle) and a client (which says so before sending) all agree.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
declare const ELICITATION_INPUT_TYPES: readonly ["text", "textarea", "number", "boolean", "date", "email", "url", "select"];
|
|
27
|
+
type ElicitationInputType = (typeof ELICITATION_INPUT_TYPES)[number];
|
|
28
|
+
/** How a question takes its answer when it is not (only) a pick from `options`. */
|
|
29
|
+
interface ElicitationInput {
|
|
30
|
+
type: ElicitationInputType;
|
|
31
|
+
/** Hint shown in an empty field. Advisory. */
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
/** Submitting without a value is refused. Skipping the whole set is still allowed. */
|
|
34
|
+
required?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Lower bound: the smallest number for `number`, the shortest length for `text`/`textarea`, the
|
|
37
|
+
* earliest `YYYY-MM-DD` for `date`. Ignored for the other types.
|
|
38
|
+
*/
|
|
39
|
+
min?: number | string;
|
|
40
|
+
/** Upper bound, read like {@link min}. */
|
|
41
|
+
max?: number | string;
|
|
42
|
+
/** A regular expression the WHOLE value must match (`text`, `textarea`, `email`, `url`). */
|
|
43
|
+
pattern?: string;
|
|
44
|
+
}
|
|
45
|
+
/** The question's options, or none — `options` may be omitted on a typed question. */
|
|
46
|
+
declare function questionOptions(question: ElicitationQuestion): ElicitationOption[];
|
|
47
|
+
/** A question answered by a typed value rather than by picking one of its options. */
|
|
48
|
+
declare function isTypedQuestion(question: ElicitationQuestion): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Why `value` is not an acceptable answer to `question`, or `null` when it is. Checks ONE value;
|
|
51
|
+
* {@link validateElicitationAnswer} checks the list (required, single choice).
|
|
52
|
+
*/
|
|
53
|
+
declare function validateElicitationValue(question: ElicitationQuestion, value: string): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Why `values` is not an acceptable answer to `question`, or `null` when it is: a `required`
|
|
56
|
+
* question left empty, more than one value for a single-choice question, or any value
|
|
57
|
+
* {@link validateElicitationValue} refuses. An empty string counts as no value.
|
|
58
|
+
*/
|
|
59
|
+
declare function validateElicitationAnswer(question: ElicitationQuestion, values: readonly string[]): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Read an {@link ElicitationInput} from untrusted JSON, or `undefined` when it is not one. Unknown
|
|
62
|
+
* keys are dropped; a malformed optional field is dropped rather than failing the input.
|
|
63
|
+
*/
|
|
64
|
+
declare function readElicitationInput(raw: unknown): ElicitationInput | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The questions a parked call carries, read leniently from its recorded input (`{ questions }` —
|
|
67
|
+
* what both an intake and an `ask` persist). Used where a reply is checked against the questions it
|
|
68
|
+
* answers; a question that cannot be read is left out rather than failing the rest.
|
|
69
|
+
*/
|
|
70
|
+
declare function readElicitationQuestions(input: unknown): ElicitationQuestion[];
|
|
71
|
+
|
|
3
72
|
/**
|
|
4
73
|
* Asking the USER a structured question, and waiting for the answer.
|
|
5
74
|
*
|
|
@@ -27,7 +96,19 @@ interface ElicitationQuestion {
|
|
|
27
96
|
/** Unique within its request; the key answers come back under. */
|
|
28
97
|
id: string;
|
|
29
98
|
prompt: string;
|
|
30
|
-
|
|
99
|
+
/** A line of help under the prompt. */
|
|
100
|
+
description?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The choices. Required unless {@link input} asks for a typed value — then optional, and a UI may
|
|
103
|
+
* offer them as suggestions. An `input` of type `select` still picks from these.
|
|
104
|
+
*/
|
|
105
|
+
options?: ElicitationOption[];
|
|
106
|
+
/**
|
|
107
|
+
* Ask for a typed value (a number, a date, a sentence…) instead of — or, for `select`, on top of —
|
|
108
|
+
* a pick from `options`. The answer is still a `string[]`, in the type's canonical form; see
|
|
109
|
+
* `elicitation-input.ts`.
|
|
110
|
+
*/
|
|
111
|
+
input?: ElicitationInput;
|
|
31
112
|
/** More than one option may be chosen. Omit → single choice. */
|
|
32
113
|
multiple?: boolean;
|
|
33
114
|
/**
|
|
@@ -323,6 +404,25 @@ interface AgentApprovalRequest {
|
|
|
323
404
|
/** Why this call needs a person, in words for that person. */
|
|
324
405
|
reason?: string;
|
|
325
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* How an approval settled — the other half of {@link AgentApprovalRequest}, under the same `id`.
|
|
409
|
+
* Metadata again: the call's own outcome still arrives as `tool-output` (approved and ran),
|
|
410
|
+
* `tool-output-error` (approved and failed) or `tool-output-denied` (rejected or expired).
|
|
411
|
+
*/
|
|
412
|
+
interface AgentApprovalSettlement {
|
|
413
|
+
id: string;
|
|
414
|
+
status: 'approved' | 'rejected' | 'expired';
|
|
415
|
+
/** Repeated from the request, for a call approved without one being streamed (a remembered approval). */
|
|
416
|
+
approver?: string;
|
|
417
|
+
/** Opaque ref of who decided. Absent on an expiry. */
|
|
418
|
+
decidedBy?: string;
|
|
419
|
+
/** The surface the decision came through: `'web'`, `'slack'`, `'remembered'`, … */
|
|
420
|
+
decidedVia?: string;
|
|
421
|
+
/** The approval also covers later calls of this tool in this thread. */
|
|
422
|
+
remember?: boolean;
|
|
423
|
+
/** What the person said when declining. */
|
|
424
|
+
reason?: string;
|
|
425
|
+
}
|
|
326
426
|
type AgentStreamEvent = {
|
|
327
427
|
kind: 'step-start';
|
|
328
428
|
}
|
|
@@ -414,6 +514,14 @@ type AgentStreamEvent = {
|
|
|
414
514
|
| ({
|
|
415
515
|
kind: 'approval-requested';
|
|
416
516
|
} & AgentApprovalRequest)
|
|
517
|
+
/**
|
|
518
|
+
* A parked action call was decided (or lapsed). Optional, like `approval-requested`: it adds WHO
|
|
519
|
+
* decided, THROUGH WHAT and whether the approval is REMEMBERED; the outcome itself rides the
|
|
520
|
+
* call's own output frame. See {@link AgentApprovalSettlement}.
|
|
521
|
+
*/
|
|
522
|
+
| ({
|
|
523
|
+
kind: 'approval-settled';
|
|
524
|
+
} & AgentApprovalSettlement)
|
|
417
525
|
/**
|
|
418
526
|
* Server-pushed generative UI, positioned in the message where it arrives. Not tied to a tool
|
|
419
527
|
* call. See {@link AgentUiComponent}.
|
|
@@ -738,6 +846,12 @@ interface ToolResult {
|
|
|
738
846
|
* tool's outcome on; this flag is what everything else reads.
|
|
739
847
|
*/
|
|
740
848
|
denied?: true;
|
|
849
|
+
/**
|
|
850
|
+
* The approval request lapsed before anyone decided, so the tool never ran. Always set together
|
|
851
|
+
* with {@link denied}: an expiry IS a refusal to every consumer that only knows that much, and this
|
|
852
|
+
* flag is for the ones that tell "nobody answered" from "someone said no".
|
|
853
|
+
*/
|
|
854
|
+
expired?: true;
|
|
741
855
|
id: string;
|
|
742
856
|
name: string;
|
|
743
857
|
output: unknown;
|
|
@@ -817,6 +931,22 @@ interface Decision {
|
|
|
817
931
|
* (the chat flow).
|
|
818
932
|
*/
|
|
819
933
|
executedByRef?: string;
|
|
934
|
+
/**
|
|
935
|
+
* Approve later calls of the SAME tool in the SAME thread without asking again. Read only on an
|
|
936
|
+
* approval; the loop answers it through {@link import('./spi/agent-store.js').AgentStore.rememberedApprovals}.
|
|
937
|
+
*/
|
|
938
|
+
remember?: boolean;
|
|
939
|
+
/**
|
|
940
|
+
* The surface the decision came through — `'web'`, `'slack'`, `'console'`, anything the caller
|
|
941
|
+
* names. Provenance only: persisted with the call, never authorized against.
|
|
942
|
+
*/
|
|
943
|
+
decidedVia?: string;
|
|
944
|
+
/**
|
|
945
|
+
* Nobody decided before the request lapsed. Set by the RUNNER when the approval wait times out
|
|
946
|
+
* (see `AgentLoopHooks.awaitApproval`'s `timeoutMs`), never by a person — the HTTP surface does not
|
|
947
|
+
* accept it. Read as a denial the model is told expired.
|
|
948
|
+
*/
|
|
949
|
+
expired?: true;
|
|
820
950
|
}
|
|
821
951
|
type MessageRole = 'user' | 'assistant' | 'system';
|
|
822
952
|
/**
|
|
@@ -1044,13 +1174,44 @@ interface StoredMessage {
|
|
|
1044
1174
|
* props for each `id` — a reloaded thread replays them as `data-ui` parts.
|
|
1045
1175
|
*/
|
|
1046
1176
|
ui?: AgentUiComponent[];
|
|
1177
|
+
/**
|
|
1178
|
+
* The approval record of every call on this message that was put to a person under an
|
|
1179
|
+
* {@link import('./spi/approval-policy.js').ApprovalPolicy} — who had to decide, until when, and how
|
|
1180
|
+
* it settled. Read off the tool-call rows by the store; absent when no call on the message asked
|
|
1181
|
+
* for one, or on a store that does not record approvals.
|
|
1182
|
+
*/
|
|
1183
|
+
approvals?: ToolCallApproval[];
|
|
1047
1184
|
createdAt: string;
|
|
1048
1185
|
}
|
|
1186
|
+
/**
|
|
1187
|
+
* How one approval stands. `pending` → still parked; `approved` → someone said yes (or a remembered
|
|
1188
|
+
* approval did); `rejected` → someone said no; `expired` → nobody answered before `expiresAt`.
|
|
1189
|
+
*/
|
|
1190
|
+
type ToolCallApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
1191
|
+
/** The persisted approval metadata of one action tool call. See {@link StoredMessage.approvals}. */
|
|
1192
|
+
interface ToolCallApproval {
|
|
1193
|
+
toolCallId: string;
|
|
1194
|
+
/** Who may decide: `'requester'` (the thread's own actor) or a role name. */
|
|
1195
|
+
approver: string;
|
|
1196
|
+
/** ISO-8601 instant the request lapses; absent → it never does. */
|
|
1197
|
+
expiresAt?: string;
|
|
1198
|
+
status: ToolCallApprovalStatus;
|
|
1199
|
+
/** The decision asked for later calls of this tool in this thread to be approved automatically. */
|
|
1200
|
+
remember?: boolean;
|
|
1201
|
+
/** Opaque ref of who decided. Absent while pending and on an expiry. */
|
|
1202
|
+
decidedBy?: string;
|
|
1203
|
+
/** The surface the decision came through (`'web'`, `'slack'`, `'remembered'`, …). */
|
|
1204
|
+
decidedVia?: string;
|
|
1205
|
+
/** What the person said when declining. */
|
|
1206
|
+
reason?: string;
|
|
1207
|
+
}
|
|
1049
1208
|
interface ThreadDetail extends ThreadSummary {
|
|
1050
1209
|
messages: StoredMessage[];
|
|
1051
1210
|
activeStreamId?: string;
|
|
1052
1211
|
}
|
|
1053
|
-
type ToolCallStatus = 'auto_executed' | 'pending_approval' | 'executed' | 'rejected' | 'failed'
|
|
1212
|
+
type ToolCallStatus = 'auto_executed' | 'pending_approval' | 'executed' | 'rejected' | 'failed'
|
|
1213
|
+
/** An approval request lapsed before anyone decided; the tool never ran. */
|
|
1214
|
+
| 'expired';
|
|
1054
1215
|
/**
|
|
1055
1216
|
* Serializable input for a dispatched model-turn step. Carries only data — the serving worker
|
|
1056
1217
|
* re-resolves the model/sink/registry from its own DI via AGENT_DEPS_FACTORY.forAgent(agentName).
|
|
@@ -1305,4 +1466,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1305
1466
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1306
1467
|
}
|
|
1307
1468
|
|
|
1308
|
-
export { type
|
|
1469
|
+
export { type ElicitationInputType as $, type Actor as A, ASK_TOOL_DESCRIPTION as B, ASK_TOOL_NAME as C, type DetachedDelivery as D, type ElicitationRequest as E, type AgentApprovalRequest as F, type AgentApprovalSettlement as G, type HumanReply as H, type InputProcessor as I, type AgentCatalogEntry as J, type AgentHistoryWindow as K, type LlmStepEnvelope as L, type ModelMessage as M, type AgentStreamEvent as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, type AskToolInput as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as V, DEFAULT_INTAKE_PREAMBLE as W, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as X, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as Y, ELICITATION_INPUT_TYPES as Z, type ElicitationInput as _, type ToolDefinition as a, type ElicitationOption as a0, type ElicitationOutcome as a1, type ElicitationQuestion as a2, type ElicitationReply as a3, type ElicitationResult as a4, type HistoryPolicyContext as a5, type HistorySelection as a6, type HistorySummary as a7, type IncrementalGating as a8, type InvokeWithTransientRetryOptions as a9, readElicitationInput as aA, readElicitationQuestions as aB, renderElicitationAnswers as aC, resolveElicitation as aD, resolveToolTransientRetryNumbers as aE, settleElicitation as aF, validateElicitationAnswer as aG, validateElicitationValue as aH, MAX_ASK_QUESTIONS as aa, type MessageRole as ab, OutputRejectedError as ac, type OutputVerdict as ad, ProcessorFailedError as ae, type PromptContext as af, type QuotaView as ag, type ToolCallApprovalStatus as ah, type ToolCatalogEntry as ai, type ToolConfirmation as aj, type ToolPresentation as ak, type ToolPresentationTone as al, type ToolResultField as am, type ToolResultView as an, type ToolStepCtx as ao, type ToolTransientRetryNumbers as ap, type ToolTransientRetryOptions as aq, askInputSchema as ar, askToolDefinition as as, decodeStreamEvent as at, encodeStreamEvent as au, invokeWithTransientRetry as av, isTransientToolError as aw, isTypedQuestion as ax, normalizeElicitationReply as ay, questionOptions as az, type ToolCallRequest as b, type MessageUsage as c, type AgentUiComponent as d, type ThreadSummary as e, type ThreadDetail as f, type ToolResult as g, type MessageAttachment as h, type ToolCallStatus as i, type ToolSpec as j, type AgentRunInput as k, type ToolKind as l, type ToolCallApproval as m, type HistoryPolicy as n, type ProcessedPrompt as o, type ModelAnswer as p, type PageContext as q, type AgentDefinition as r, type AgentDelegation as s, type AiToolCtx as t, type PromptBuilder as u, type PromptContributor as v, type ToolTransientRetrySetting as w, type AgentIntake as x, type Decision as y, type ToolStepEnvelope as z };
|
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Typed answers for a question set: a question that asks for a number, a date, an email or a
|
|
5
|
+
* sentence instead of offering options to pick.
|
|
6
|
+
*
|
|
7
|
+
* Answers stay `string[]` on the wire whatever the type — the signal that carries them, the row that
|
|
8
|
+
* records them and the model that reads them back all see strings — so this module fixes ONE
|
|
9
|
+
* canonical string per type and validates against it:
|
|
10
|
+
*
|
|
11
|
+
* | `type` | canonical value |
|
|
12
|
+
* |------------|----------------------------------------------|
|
|
13
|
+
* | `text` | the text |
|
|
14
|
+
* | `textarea` | the text (newlines kept) |
|
|
15
|
+
* | `number` | a finite decimal, e.g. `"42"`, `"-1.5"` |
|
|
16
|
+
* | `boolean` | `"true"` or `"false"` |
|
|
17
|
+
* | `date` | `YYYY-MM-DD` |
|
|
18
|
+
* | `email` | an address with one `@` and a dotted domain |
|
|
19
|
+
* | `url` | an absolute `http:`/`https:` URL |
|
|
20
|
+
* | `select` | one of the question's `options[].value` |
|
|
21
|
+
*
|
|
22
|
+
* Pure and dependency-free, so the loop (which filters what it settles on), the HTTP surface (which
|
|
23
|
+
* refuses what it cannot settle) and a client (which says so before sending) all agree.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
declare const ELICITATION_INPUT_TYPES: readonly ["text", "textarea", "number", "boolean", "date", "email", "url", "select"];
|
|
27
|
+
type ElicitationInputType = (typeof ELICITATION_INPUT_TYPES)[number];
|
|
28
|
+
/** How a question takes its answer when it is not (only) a pick from `options`. */
|
|
29
|
+
interface ElicitationInput {
|
|
30
|
+
type: ElicitationInputType;
|
|
31
|
+
/** Hint shown in an empty field. Advisory. */
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
/** Submitting without a value is refused. Skipping the whole set is still allowed. */
|
|
34
|
+
required?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Lower bound: the smallest number for `number`, the shortest length for `text`/`textarea`, the
|
|
37
|
+
* earliest `YYYY-MM-DD` for `date`. Ignored for the other types.
|
|
38
|
+
*/
|
|
39
|
+
min?: number | string;
|
|
40
|
+
/** Upper bound, read like {@link min}. */
|
|
41
|
+
max?: number | string;
|
|
42
|
+
/** A regular expression the WHOLE value must match (`text`, `textarea`, `email`, `url`). */
|
|
43
|
+
pattern?: string;
|
|
44
|
+
}
|
|
45
|
+
/** The question's options, or none — `options` may be omitted on a typed question. */
|
|
46
|
+
declare function questionOptions(question: ElicitationQuestion): ElicitationOption[];
|
|
47
|
+
/** A question answered by a typed value rather than by picking one of its options. */
|
|
48
|
+
declare function isTypedQuestion(question: ElicitationQuestion): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Why `value` is not an acceptable answer to `question`, or `null` when it is. Checks ONE value;
|
|
51
|
+
* {@link validateElicitationAnswer} checks the list (required, single choice).
|
|
52
|
+
*/
|
|
53
|
+
declare function validateElicitationValue(question: ElicitationQuestion, value: string): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Why `values` is not an acceptable answer to `question`, or `null` when it is: a `required`
|
|
56
|
+
* question left empty, more than one value for a single-choice question, or any value
|
|
57
|
+
* {@link validateElicitationValue} refuses. An empty string counts as no value.
|
|
58
|
+
*/
|
|
59
|
+
declare function validateElicitationAnswer(question: ElicitationQuestion, values: readonly string[]): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Read an {@link ElicitationInput} from untrusted JSON, or `undefined` when it is not one. Unknown
|
|
62
|
+
* keys are dropped; a malformed optional field is dropped rather than failing the input.
|
|
63
|
+
*/
|
|
64
|
+
declare function readElicitationInput(raw: unknown): ElicitationInput | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The questions a parked call carries, read leniently from its recorded input (`{ questions }` —
|
|
67
|
+
* what both an intake and an `ask` persist). Used where a reply is checked against the questions it
|
|
68
|
+
* answers; a question that cannot be read is left out rather than failing the rest.
|
|
69
|
+
*/
|
|
70
|
+
declare function readElicitationQuestions(input: unknown): ElicitationQuestion[];
|
|
71
|
+
|
|
3
72
|
/**
|
|
4
73
|
* Asking the USER a structured question, and waiting for the answer.
|
|
5
74
|
*
|
|
@@ -27,7 +96,19 @@ interface ElicitationQuestion {
|
|
|
27
96
|
/** Unique within its request; the key answers come back under. */
|
|
28
97
|
id: string;
|
|
29
98
|
prompt: string;
|
|
30
|
-
|
|
99
|
+
/** A line of help under the prompt. */
|
|
100
|
+
description?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The choices. Required unless {@link input} asks for a typed value — then optional, and a UI may
|
|
103
|
+
* offer them as suggestions. An `input` of type `select` still picks from these.
|
|
104
|
+
*/
|
|
105
|
+
options?: ElicitationOption[];
|
|
106
|
+
/**
|
|
107
|
+
* Ask for a typed value (a number, a date, a sentence…) instead of — or, for `select`, on top of —
|
|
108
|
+
* a pick from `options`. The answer is still a `string[]`, in the type's canonical form; see
|
|
109
|
+
* `elicitation-input.ts`.
|
|
110
|
+
*/
|
|
111
|
+
input?: ElicitationInput;
|
|
31
112
|
/** More than one option may be chosen. Omit → single choice. */
|
|
32
113
|
multiple?: boolean;
|
|
33
114
|
/**
|
|
@@ -323,6 +404,25 @@ interface AgentApprovalRequest {
|
|
|
323
404
|
/** Why this call needs a person, in words for that person. */
|
|
324
405
|
reason?: string;
|
|
325
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* How an approval settled — the other half of {@link AgentApprovalRequest}, under the same `id`.
|
|
409
|
+
* Metadata again: the call's own outcome still arrives as `tool-output` (approved and ran),
|
|
410
|
+
* `tool-output-error` (approved and failed) or `tool-output-denied` (rejected or expired).
|
|
411
|
+
*/
|
|
412
|
+
interface AgentApprovalSettlement {
|
|
413
|
+
id: string;
|
|
414
|
+
status: 'approved' | 'rejected' | 'expired';
|
|
415
|
+
/** Repeated from the request, for a call approved without one being streamed (a remembered approval). */
|
|
416
|
+
approver?: string;
|
|
417
|
+
/** Opaque ref of who decided. Absent on an expiry. */
|
|
418
|
+
decidedBy?: string;
|
|
419
|
+
/** The surface the decision came through: `'web'`, `'slack'`, `'remembered'`, … */
|
|
420
|
+
decidedVia?: string;
|
|
421
|
+
/** The approval also covers later calls of this tool in this thread. */
|
|
422
|
+
remember?: boolean;
|
|
423
|
+
/** What the person said when declining. */
|
|
424
|
+
reason?: string;
|
|
425
|
+
}
|
|
326
426
|
type AgentStreamEvent = {
|
|
327
427
|
kind: 'step-start';
|
|
328
428
|
}
|
|
@@ -414,6 +514,14 @@ type AgentStreamEvent = {
|
|
|
414
514
|
| ({
|
|
415
515
|
kind: 'approval-requested';
|
|
416
516
|
} & AgentApprovalRequest)
|
|
517
|
+
/**
|
|
518
|
+
* A parked action call was decided (or lapsed). Optional, like `approval-requested`: it adds WHO
|
|
519
|
+
* decided, THROUGH WHAT and whether the approval is REMEMBERED; the outcome itself rides the
|
|
520
|
+
* call's own output frame. See {@link AgentApprovalSettlement}.
|
|
521
|
+
*/
|
|
522
|
+
| ({
|
|
523
|
+
kind: 'approval-settled';
|
|
524
|
+
} & AgentApprovalSettlement)
|
|
417
525
|
/**
|
|
418
526
|
* Server-pushed generative UI, positioned in the message where it arrives. Not tied to a tool
|
|
419
527
|
* call. See {@link AgentUiComponent}.
|
|
@@ -738,6 +846,12 @@ interface ToolResult {
|
|
|
738
846
|
* tool's outcome on; this flag is what everything else reads.
|
|
739
847
|
*/
|
|
740
848
|
denied?: true;
|
|
849
|
+
/**
|
|
850
|
+
* The approval request lapsed before anyone decided, so the tool never ran. Always set together
|
|
851
|
+
* with {@link denied}: an expiry IS a refusal to every consumer that only knows that much, and this
|
|
852
|
+
* flag is for the ones that tell "nobody answered" from "someone said no".
|
|
853
|
+
*/
|
|
854
|
+
expired?: true;
|
|
741
855
|
id: string;
|
|
742
856
|
name: string;
|
|
743
857
|
output: unknown;
|
|
@@ -817,6 +931,22 @@ interface Decision {
|
|
|
817
931
|
* (the chat flow).
|
|
818
932
|
*/
|
|
819
933
|
executedByRef?: string;
|
|
934
|
+
/**
|
|
935
|
+
* Approve later calls of the SAME tool in the SAME thread without asking again. Read only on an
|
|
936
|
+
* approval; the loop answers it through {@link import('./spi/agent-store.js').AgentStore.rememberedApprovals}.
|
|
937
|
+
*/
|
|
938
|
+
remember?: boolean;
|
|
939
|
+
/**
|
|
940
|
+
* The surface the decision came through — `'web'`, `'slack'`, `'console'`, anything the caller
|
|
941
|
+
* names. Provenance only: persisted with the call, never authorized against.
|
|
942
|
+
*/
|
|
943
|
+
decidedVia?: string;
|
|
944
|
+
/**
|
|
945
|
+
* Nobody decided before the request lapsed. Set by the RUNNER when the approval wait times out
|
|
946
|
+
* (see `AgentLoopHooks.awaitApproval`'s `timeoutMs`), never by a person — the HTTP surface does not
|
|
947
|
+
* accept it. Read as a denial the model is told expired.
|
|
948
|
+
*/
|
|
949
|
+
expired?: true;
|
|
820
950
|
}
|
|
821
951
|
type MessageRole = 'user' | 'assistant' | 'system';
|
|
822
952
|
/**
|
|
@@ -1044,13 +1174,44 @@ interface StoredMessage {
|
|
|
1044
1174
|
* props for each `id` — a reloaded thread replays them as `data-ui` parts.
|
|
1045
1175
|
*/
|
|
1046
1176
|
ui?: AgentUiComponent[];
|
|
1177
|
+
/**
|
|
1178
|
+
* The approval record of every call on this message that was put to a person under an
|
|
1179
|
+
* {@link import('./spi/approval-policy.js').ApprovalPolicy} — who had to decide, until when, and how
|
|
1180
|
+
* it settled. Read off the tool-call rows by the store; absent when no call on the message asked
|
|
1181
|
+
* for one, or on a store that does not record approvals.
|
|
1182
|
+
*/
|
|
1183
|
+
approvals?: ToolCallApproval[];
|
|
1047
1184
|
createdAt: string;
|
|
1048
1185
|
}
|
|
1186
|
+
/**
|
|
1187
|
+
* How one approval stands. `pending` → still parked; `approved` → someone said yes (or a remembered
|
|
1188
|
+
* approval did); `rejected` → someone said no; `expired` → nobody answered before `expiresAt`.
|
|
1189
|
+
*/
|
|
1190
|
+
type ToolCallApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
1191
|
+
/** The persisted approval metadata of one action tool call. See {@link StoredMessage.approvals}. */
|
|
1192
|
+
interface ToolCallApproval {
|
|
1193
|
+
toolCallId: string;
|
|
1194
|
+
/** Who may decide: `'requester'` (the thread's own actor) or a role name. */
|
|
1195
|
+
approver: string;
|
|
1196
|
+
/** ISO-8601 instant the request lapses; absent → it never does. */
|
|
1197
|
+
expiresAt?: string;
|
|
1198
|
+
status: ToolCallApprovalStatus;
|
|
1199
|
+
/** The decision asked for later calls of this tool in this thread to be approved automatically. */
|
|
1200
|
+
remember?: boolean;
|
|
1201
|
+
/** Opaque ref of who decided. Absent while pending and on an expiry. */
|
|
1202
|
+
decidedBy?: string;
|
|
1203
|
+
/** The surface the decision came through (`'web'`, `'slack'`, `'remembered'`, …). */
|
|
1204
|
+
decidedVia?: string;
|
|
1205
|
+
/** What the person said when declining. */
|
|
1206
|
+
reason?: string;
|
|
1207
|
+
}
|
|
1049
1208
|
interface ThreadDetail extends ThreadSummary {
|
|
1050
1209
|
messages: StoredMessage[];
|
|
1051
1210
|
activeStreamId?: string;
|
|
1052
1211
|
}
|
|
1053
|
-
type ToolCallStatus = 'auto_executed' | 'pending_approval' | 'executed' | 'rejected' | 'failed'
|
|
1212
|
+
type ToolCallStatus = 'auto_executed' | 'pending_approval' | 'executed' | 'rejected' | 'failed'
|
|
1213
|
+
/** An approval request lapsed before anyone decided; the tool never ran. */
|
|
1214
|
+
| 'expired';
|
|
1054
1215
|
/**
|
|
1055
1216
|
* Serializable input for a dispatched model-turn step. Carries only data — the serving worker
|
|
1056
1217
|
* re-resolves the model/sink/registry from its own DI via AGENT_DEPS_FACTORY.forAgent(agentName).
|
|
@@ -1305,4 +1466,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1305
1466
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1306
1467
|
}
|
|
1307
1468
|
|
|
1308
|
-
export { type
|
|
1469
|
+
export { type ElicitationInputType as $, type Actor as A, ASK_TOOL_DESCRIPTION as B, ASK_TOOL_NAME as C, type DetachedDelivery as D, type ElicitationRequest as E, type AgentApprovalRequest as F, type AgentApprovalSettlement as G, type HumanReply as H, type InputProcessor as I, type AgentCatalogEntry as J, type AgentHistoryWindow as K, type LlmStepEnvelope as L, type ModelMessage as M, type AgentStreamEvent as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, type AskToolInput as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as V, DEFAULT_INTAKE_PREAMBLE as W, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as X, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as Y, ELICITATION_INPUT_TYPES as Z, type ElicitationInput as _, type ToolDefinition as a, type ElicitationOption as a0, type ElicitationOutcome as a1, type ElicitationQuestion as a2, type ElicitationReply as a3, type ElicitationResult as a4, type HistoryPolicyContext as a5, type HistorySelection as a6, type HistorySummary as a7, type IncrementalGating as a8, type InvokeWithTransientRetryOptions as a9, readElicitationInput as aA, readElicitationQuestions as aB, renderElicitationAnswers as aC, resolveElicitation as aD, resolveToolTransientRetryNumbers as aE, settleElicitation as aF, validateElicitationAnswer as aG, validateElicitationValue as aH, MAX_ASK_QUESTIONS as aa, type MessageRole as ab, OutputRejectedError as ac, type OutputVerdict as ad, ProcessorFailedError as ae, type PromptContext as af, type QuotaView as ag, type ToolCallApprovalStatus as ah, type ToolCatalogEntry as ai, type ToolConfirmation as aj, type ToolPresentation as ak, type ToolPresentationTone as al, type ToolResultField as am, type ToolResultView as an, type ToolStepCtx as ao, type ToolTransientRetryNumbers as ap, type ToolTransientRetryOptions as aq, askInputSchema as ar, askToolDefinition as as, decodeStreamEvent as at, encodeStreamEvent as au, invokeWithTransientRetry as av, isTransientToolError as aw, isTypedQuestion as ax, normalizeElicitationReply as ay, questionOptions as az, type ToolCallRequest as b, type MessageUsage as c, type AgentUiComponent as d, type ThreadSummary as e, type ThreadDetail as f, type ToolResult as g, type MessageAttachment as h, type ToolCallStatus as i, type ToolSpec as j, type AgentRunInput as k, type ToolKind as l, type ToolCallApproval as m, type HistoryPolicy as n, type ProcessedPrompt as o, type ModelAnswer as p, type PageContext as q, type AgentDefinition as r, type AgentDelegation as s, type AiToolCtx as t, type PromptBuilder as u, type PromptContributor as v, type ToolTransientRetrySetting as w, type AgentIntake as x, type Decision as y, type ToolStepEnvelope as z };
|