@robota-sdk/agent-core 3.0.0-beta.76 → 3.0.0-beta.78
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 +21 -1
- package/LICENSE +661 -21
- package/README.md +94 -16
- package/dist/browser/index.d.ts +481 -35
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +8 -7
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index-BKIUt9pk.d.ts +5387 -0
- package/dist/node/index-BKIUt9pk.d.ts.map +1 -0
- package/dist/node/index.cjs +8 -7
- package/dist/node/index.d.ts +2 -4941
- package/dist/node/index.js +8 -7
- package/dist/node/index.js.map +1 -1
- package/dist/node/testing/index.cjs +1 -0
- package/dist/node/testing/index.d.ts +65 -0
- package/dist/node/testing/index.d.ts.map +1 -0
- package/dist/node/testing/index.js +2 -0
- package/dist/node/testing/index.js.map +1 -0
- package/package.json +14 -2
- package/dist/node/index.d.ts.map +0 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TypeOf, ZodType } from "zod";
|
|
2
|
+
|
|
1
3
|
//#region src/interfaces/messages.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Message Contracts (Single Source of Truth)
|
|
@@ -275,6 +277,83 @@ interface ICacheOptions {
|
|
|
275
277
|
ttlMs: number;
|
|
276
278
|
}
|
|
277
279
|
//#endregion
|
|
280
|
+
//#region src/interfaces/interaction.d.ts
|
|
281
|
+
/**
|
|
282
|
+
* UI-agnostic "ask the user" contract (CMD-004).
|
|
283
|
+
*
|
|
284
|
+
* The SSOT for the interaction action lives in agent-core so every interaction *source* can reach it:
|
|
285
|
+
* command execution (`ICommandHostContext`, agent-framework) AND tool execution
|
|
286
|
+
* (`IToolExecutionContext`, agent-core, for model-issued questions — CMD-005). These are pure types
|
|
287
|
+
* with no runtime dependency, so the contract crosses a serialization/transport boundary unchanged
|
|
288
|
+
* (no function-valued fields).
|
|
289
|
+
*
|
|
290
|
+
* A single shape covers every interaction kind, parameterised by fields rather than split into
|
|
291
|
+
* variants:
|
|
292
|
+
* - confirm → two options, `maxSelect` 1
|
|
293
|
+
* - single → options, `maxSelect` 1
|
|
294
|
+
* - multi → options, `maxSelect` > 1
|
|
295
|
+
* - free text → no options, `allowFreeText` true
|
|
296
|
+
* - secret → free text with `masked` true
|
|
297
|
+
*/
|
|
298
|
+
/** One predefined option the user can choose. */
|
|
299
|
+
interface IActionOption {
|
|
300
|
+
value: string;
|
|
301
|
+
label: string;
|
|
302
|
+
description?: string;
|
|
303
|
+
}
|
|
304
|
+
/** Pre-selected option values and/or prefilled free text for an action request. */
|
|
305
|
+
interface IActionDefault {
|
|
306
|
+
values?: readonly string[];
|
|
307
|
+
text?: string;
|
|
308
|
+
}
|
|
309
|
+
/** One request for the user to answer. See the module doc for how the fields encode each kind. */
|
|
310
|
+
interface IActionRequest {
|
|
311
|
+
/** Correlation key; the ask port resolves a given id exactly once (idempotent, first-answer wins). */
|
|
312
|
+
id: string;
|
|
313
|
+
title: string;
|
|
314
|
+
description?: string;
|
|
315
|
+
/** Predefined options. Empty/omitted ⇒ pure free-text entry. */
|
|
316
|
+
options?: readonly IActionOption[];
|
|
317
|
+
/** Minimum selections required (default 1). */
|
|
318
|
+
minSelect?: number;
|
|
319
|
+
/** Maximum selections allowed (default 1 ⇒ single; > 1 ⇒ multi). */
|
|
320
|
+
maxSelect?: number;
|
|
321
|
+
/** Allow a typed custom answer in addition to / instead of the options. */
|
|
322
|
+
allowFreeText?: boolean;
|
|
323
|
+
/** Free-text entry is masked (secret entry such as an API key); the renderer hides input. */
|
|
324
|
+
masked?: boolean;
|
|
325
|
+
/** Allow submitting empty free text. */
|
|
326
|
+
allowEmpty?: boolean;
|
|
327
|
+
/** Placeholder shown in the free-text field. */
|
|
328
|
+
placeholder?: string;
|
|
329
|
+
/** Maximum options shown before scrolling (renderer hint). */
|
|
330
|
+
maxVisible?: number;
|
|
331
|
+
/** Pre-selected option values and/or prefilled free text. */
|
|
332
|
+
default?: IActionDefault;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The user's answer to an {@link IActionRequest}. `answer` carries the selected option values and/or
|
|
336
|
+
* the typed text; `cancelled` means the user dismissed the request, or no interactive renderer was
|
|
337
|
+
* available to answer it.
|
|
338
|
+
*/
|
|
339
|
+
type TActionResponse = {
|
|
340
|
+
type: 'answer';
|
|
341
|
+
values: readonly string[];
|
|
342
|
+
text?: string;
|
|
343
|
+
} | {
|
|
344
|
+
type: 'cancelled';
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* The injected "ask the user" port — a single seam reachable by every interaction source (command
|
|
348
|
+
* execution now; tool execution for model-issued questions later) and rendered per-environment by each
|
|
349
|
+
* transport. The concurrency model (broadcast to attached interactive channels, first answer wins,
|
|
350
|
+
* later answers for an already-resolved `id` ignored) is owned by the port implementation, not the
|
|
351
|
+
* contract.
|
|
352
|
+
*/
|
|
353
|
+
interface IUserInteraction {
|
|
354
|
+
ask(request: IActionRequest): Promise<TActionResponse>;
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
278
357
|
//#region src/interfaces/provider-capabilities.d.ts
|
|
279
358
|
interface IProviderFunctionCallingCapability {
|
|
280
359
|
supported: boolean;
|
|
@@ -452,6 +531,20 @@ type TProviderNativeRawPayloadCallback = (event: IProviderNativeRawPayloadEvent)
|
|
|
452
531
|
* native effort concept ignore it as a documented no-op.
|
|
453
532
|
*/
|
|
454
533
|
type TModelEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
534
|
+
/**
|
|
535
|
+
* Tool-invocation directive threaded per model invocation (CORE-017).
|
|
536
|
+
*
|
|
537
|
+
* Canonical SSOT for the union. `'auto'` lets the model decide (provider default),
|
|
538
|
+
* `'none'` suppresses tool calls for the invocation, `'required'` forces the model to call
|
|
539
|
+
* some tool, and `{ tool: name }` forces a call to the named tool. Core validates that a
|
|
540
|
+
* named tool exists in the invocation's tool list and that `'required'`/named forcing is
|
|
541
|
+
* only used when tools are present — a violation throws instead of degrading silently.
|
|
542
|
+
* Within a multi-round run, forcing directives apply to the FIRST model call only; rounds
|
|
543
|
+
* after tool results revert to `'auto'` so the model can consume the results and finish.
|
|
544
|
+
*/
|
|
545
|
+
type TToolChoice = 'auto' | 'none' | 'required' | {
|
|
546
|
+
tool: string;
|
|
547
|
+
};
|
|
455
548
|
/**
|
|
456
549
|
* Options for AI provider chat requests
|
|
457
550
|
*/
|
|
@@ -478,11 +571,20 @@ interface IChatOptions extends IProviderSpecificOptions {
|
|
|
478
571
|
onProviderNativeRawPayload?: TProviderNativeRawPayloadCallback;
|
|
479
572
|
/** AbortSignal for cancelling the provider call */
|
|
480
573
|
signal?: AbortSignal;
|
|
574
|
+
/**
|
|
575
|
+
* Tool-invocation directive for this call. Adapters map it onto their wire format
|
|
576
|
+
* (`tool_choice` / `functionCallingConfig`); omitted = provider default ('auto').
|
|
577
|
+
*/
|
|
578
|
+
toolChoice?: TToolChoice;
|
|
481
579
|
/** Provider-native hosted web tools requested for this call */
|
|
482
580
|
nativeWebTools?: IProviderNativeWebToolRequest;
|
|
483
|
-
/** Request structured output from the provider. */
|
|
581
|
+
/** Request structured output from the provider (CORE-015: `json_schema` carries the schema). */
|
|
484
582
|
responseFormat?: {
|
|
485
583
|
type: 'text' | 'json_object';
|
|
584
|
+
} | {
|
|
585
|
+
type: 'json_schema';
|
|
586
|
+
name?: string;
|
|
587
|
+
schema: Record<string, unknown>;
|
|
486
588
|
};
|
|
487
589
|
}
|
|
488
590
|
/**
|
|
@@ -1070,6 +1172,12 @@ interface IToolExecutionResult {
|
|
|
1070
1172
|
interface IToolExecutionContext {
|
|
1071
1173
|
toolName: string;
|
|
1072
1174
|
parameters: TToolParameters;
|
|
1175
|
+
/**
|
|
1176
|
+
* Run-scoped cancellation signal (CORE-018). Long-running tools MUST honor it: terminate
|
|
1177
|
+
* the underlying work (kill the child process, abort the network request) and return an
|
|
1178
|
+
* interrupted/failed result. Completing silently after an abort is a contract violation.
|
|
1179
|
+
*/
|
|
1180
|
+
signal?: AbortSignal;
|
|
1073
1181
|
executionId?: string;
|
|
1074
1182
|
userId?: string;
|
|
1075
1183
|
sessionId?: string;
|
|
@@ -1117,6 +1225,13 @@ interface IToolExecutionContext {
|
|
|
1117
1225
|
* Owner-bound instances must not be layered across different owners.
|
|
1118
1226
|
*/
|
|
1119
1227
|
baseEventService?: IEventService;
|
|
1228
|
+
/**
|
|
1229
|
+
* Injected "ask the user" port (CMD-004). Present when an interactive renderer is attached, letting
|
|
1230
|
+
* a tool solicit a structured answer from the user (the model-issued question seam consumed by
|
|
1231
|
+
* CMD-005). Absent in non-interactive contexts; a tool that asks must treat absence as "no human
|
|
1232
|
+
* available" (never a silent guess).
|
|
1233
|
+
*/
|
|
1234
|
+
ask?: IUserInteraction['ask'];
|
|
1120
1235
|
}
|
|
1121
1236
|
/**
|
|
1122
1237
|
* Parameter validation result
|
|
@@ -1300,6 +1415,12 @@ interface IPluginContract<TOptions extends IPluginOptions = IPluginOptions, TSta
|
|
|
1300
1415
|
category: PluginCategory;
|
|
1301
1416
|
priority: number;
|
|
1302
1417
|
initialize(options?: TOptions): Promise<void>;
|
|
1418
|
+
/**
|
|
1419
|
+
* CORE-022: the single component-level disposal entry point. The base implementation
|
|
1420
|
+
* unsubscribes module events; overrides release owned resources (timers, sockets,
|
|
1421
|
+
* storage) — always calling `super.dispose()`. Driven by `Robota.destroy()`.
|
|
1422
|
+
*/
|
|
1423
|
+
dispose(): Promise<void>;
|
|
1303
1424
|
cleanup?(): Promise<void>;
|
|
1304
1425
|
getData?(): IPluginData;
|
|
1305
1426
|
getStats?(): TStats;
|
|
@@ -1545,6 +1666,84 @@ declare abstract class AbstractTool<TParameters = TToolParameters, TResult = ITo
|
|
|
1545
1666
|
getName(): string;
|
|
1546
1667
|
}
|
|
1547
1668
|
//#endregion
|
|
1669
|
+
//#region src/schema/zod-schema-types.d.ts
|
|
1670
|
+
interface IZodParseResult {
|
|
1671
|
+
success: boolean;
|
|
1672
|
+
data?: unknown;
|
|
1673
|
+
error?: unknown;
|
|
1674
|
+
}
|
|
1675
|
+
interface IZodSchemaDef {
|
|
1676
|
+
typeName?: string;
|
|
1677
|
+
innerType?: IZodSchema;
|
|
1678
|
+
valueType?: IZodSchema;
|
|
1679
|
+
checks?: Array<{
|
|
1680
|
+
kind: string;
|
|
1681
|
+
value?: TUniversalValue;
|
|
1682
|
+
}>;
|
|
1683
|
+
shape?: () => Record<string, IZodSchema>;
|
|
1684
|
+
type?: IZodSchema;
|
|
1685
|
+
values?: TUniversalValue[];
|
|
1686
|
+
description?: string;
|
|
1687
|
+
unknownKeys?: 'passthrough' | 'strip' | 'strict';
|
|
1688
|
+
}
|
|
1689
|
+
interface IZodSchema {
|
|
1690
|
+
parse(value: unknown): unknown;
|
|
1691
|
+
safeParse(value: unknown): IZodParseResult;
|
|
1692
|
+
_def?: IZodSchemaDef;
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Schema conversion options
|
|
1696
|
+
*/
|
|
1697
|
+
interface ISchemaConversionOptions {
|
|
1698
|
+
includeDescription?: boolean;
|
|
1699
|
+
strictTypes?: boolean;
|
|
1700
|
+
allowAdditionalProperties?: boolean;
|
|
1701
|
+
}
|
|
1702
|
+
//#endregion
|
|
1703
|
+
//#region src/schema/structured-output.d.ts
|
|
1704
|
+
/** Explicit raw-JSON-schema form of `IRunOptions.output`. */
|
|
1705
|
+
interface IJsonSchemaOutput {
|
|
1706
|
+
/** JSON Schema (object root, universal subset) the response must match. */
|
|
1707
|
+
jsonSchema: IToolSchema['parameters'];
|
|
1708
|
+
/** Optional schema name forwarded to provider native surfaces. */
|
|
1709
|
+
name?: string;
|
|
1710
|
+
}
|
|
1711
|
+
/** Accepted `IRunOptions.output` values: a Zod schema or an explicit JSON-schema wrapper. */
|
|
1712
|
+
type TStructuredOutputSchema = IZodSchema | IJsonSchemaOutput;
|
|
1713
|
+
type TStructuredOutputValidation = {
|
|
1714
|
+
success: true;
|
|
1715
|
+
value: unknown;
|
|
1716
|
+
} | {
|
|
1717
|
+
success: false;
|
|
1718
|
+
issues: string[];
|
|
1719
|
+
};
|
|
1720
|
+
/** Internal SSOT representation every `output` value normalizes to. */
|
|
1721
|
+
interface IStructuredOutputSpec {
|
|
1722
|
+
name: string;
|
|
1723
|
+
jsonSchema: IToolSchema['parameters'];
|
|
1724
|
+
validate(value: unknown): TStructuredOutputValidation;
|
|
1725
|
+
}
|
|
1726
|
+
/** Normalize an accepted `output` value into the internal spec. */
|
|
1727
|
+
declare function normalizeStructuredOutput(output: TStructuredOutputSchema): IStructuredOutputSpec;
|
|
1728
|
+
/**
|
|
1729
|
+
* Validate a value against the universal JSON-schema subset used by tool
|
|
1730
|
+
* parameters (`IParameterSchema`). Covers type, required, enum, items, nested
|
|
1731
|
+
* properties, and numeric bounds — the full expressible surface of the subset.
|
|
1732
|
+
*/
|
|
1733
|
+
declare function validateAgainstJsonSchema(schema: IToolSchema['parameters'] | IParameterSchema, value: unknown, path: string): string[];
|
|
1734
|
+
/**
|
|
1735
|
+
* Parse the model's final text into a JSON value. Tolerates a fenced
|
|
1736
|
+
* ```json code block wrapper (providers without native enforcement commonly
|
|
1737
|
+
* emit one); the parsed value is still strictly schema-validated afterwards.
|
|
1738
|
+
*/
|
|
1739
|
+
declare function parseStructuredResponseText(text: string): {
|
|
1740
|
+
success: true;
|
|
1741
|
+
value: unknown;
|
|
1742
|
+
} | {
|
|
1743
|
+
success: false;
|
|
1744
|
+
issue: string;
|
|
1745
|
+
};
|
|
1746
|
+
//#endregion
|
|
1548
1747
|
//#region src/interfaces/agent.d.ts
|
|
1549
1748
|
/**
|
|
1550
1749
|
* IExecutionContextInjection
|
|
@@ -1597,9 +1796,9 @@ interface IAgentConfig {
|
|
|
1597
1796
|
model: string;
|
|
1598
1797
|
temperature?: number;
|
|
1599
1798
|
maxTokens?: number;
|
|
1600
|
-
topP?: number;
|
|
1601
|
-
|
|
1602
|
-
|
|
1799
|
+
topP?: number; /** Reasoning-effort dial threaded to the provider request builder per call. */
|
|
1800
|
+
effort?: TModelEffort; /** Default tool-invocation directive for every run (CORE-017). `IRunOptions.toolChoice` wins. */
|
|
1801
|
+
toolChoice?: TToolChoice;
|
|
1603
1802
|
};
|
|
1604
1803
|
tools?: Array<IToolWithEventService>;
|
|
1605
1804
|
plugins?: Array<IPluginContract<IPluginOptions, IPluginStats>>;
|
|
@@ -1609,6 +1808,17 @@ interface IAgentConfig {
|
|
|
1609
1808
|
conversationId?: string;
|
|
1610
1809
|
sessionId?: string;
|
|
1611
1810
|
userId?: string;
|
|
1811
|
+
/**
|
|
1812
|
+
* Run-isolated (stateless) mode (CORE-014). Default `true`: history accumulates for the
|
|
1813
|
+
* instance's lifetime and the FULL history is sent to the provider on EVERY call — token cost
|
|
1814
|
+
* grows every turn. Set `false` to make the conversation store ephemeral per run: a run executes
|
|
1815
|
+
* on whatever is currently in the store (system prompt + any injected context + the prompt), and
|
|
1816
|
+
* the store resets after the run settles, so nothing accumulates across runs (the system prompt
|
|
1817
|
+
* re-applies on the next run). Equivalent to calling `clearHistory()` around every run, but
|
|
1818
|
+
* declared once and immune to a missed clear. `getHistory()` after a run returns empty in this
|
|
1819
|
+
* mode — read the response from the run's return value or execution events.
|
|
1820
|
+
*/
|
|
1821
|
+
retainHistory?: boolean;
|
|
1612
1822
|
metadata?: TUniversalMessageMetadata;
|
|
1613
1823
|
context?: Record<string, TConfigValue>;
|
|
1614
1824
|
logging?: {
|
|
@@ -1618,11 +1828,13 @@ interface IAgentConfig {
|
|
|
1618
1828
|
destination?: string;
|
|
1619
1829
|
};
|
|
1620
1830
|
providerConfig?: IAgentProviderConfig;
|
|
1621
|
-
stream?: boolean;
|
|
1622
|
-
toolChoice?: 'auto' | 'none' | string;
|
|
1623
1831
|
responseFormat?: IResponseFormatConfig;
|
|
1624
1832
|
safetySettings?: ISafetySetting[];
|
|
1625
1833
|
timeout?: number;
|
|
1834
|
+
/**
|
|
1835
|
+
* Default maximum execution rounds per run (round = one model call + its requested tool
|
|
1836
|
+
* executions; see `IRunOptions.maxExecutionRounds` for the full semantics). 0 = no cap.
|
|
1837
|
+
*/
|
|
1626
1838
|
maxExecutionRounds?: number;
|
|
1627
1839
|
maxSameToolInputs?: number;
|
|
1628
1840
|
retryAttempts?: number;
|
|
@@ -1634,6 +1846,12 @@ interface IAgentConfig {
|
|
|
1634
1846
|
eventService?: IEventService;
|
|
1635
1847
|
executionContext?: IExecutionContextInjection;
|
|
1636
1848
|
cache?: ICacheOptions;
|
|
1849
|
+
/**
|
|
1850
|
+
* Injected "ask the user" port (CMD-005). When present, tool executions receive it as
|
|
1851
|
+
* `IToolExecutionContext.ask` so a model-invoked tool (AskUserQuestion) can solicit a structured
|
|
1852
|
+
* answer. Absent in headless/automation contexts.
|
|
1853
|
+
*/
|
|
1854
|
+
ask?: IUserInteraction['ask'];
|
|
1637
1855
|
}
|
|
1638
1856
|
/**
|
|
1639
1857
|
* Agent template interface
|
|
@@ -1654,10 +1872,18 @@ interface IAgentTemplate {
|
|
|
1654
1872
|
* Agent run options - type-safe interface for all agent execution options
|
|
1655
1873
|
*/
|
|
1656
1874
|
interface IRunOptions {
|
|
1875
|
+
/** Run-scoped temperature override — wins over `defaultModel.temperature` (CORE-016). */
|
|
1657
1876
|
temperature?: number;
|
|
1877
|
+
/** Run-scoped max output tokens override — wins over `defaultModel.maxTokens` (CORE-016). */
|
|
1658
1878
|
maxTokens?: number;
|
|
1659
|
-
|
|
1660
|
-
|
|
1879
|
+
/**
|
|
1880
|
+
* Run-scoped tool-invocation directive — wins over `defaultModel.toolChoice` (CORE-017).
|
|
1881
|
+
* `'auto'` (model decides), `'none'` (suppress tool calls), `'required'` (must call some
|
|
1882
|
+
* tool), or `{ tool: name }` (must call the named tool; the name is validated against the
|
|
1883
|
+
* run's tool list and a miss throws). Forcing applies to the run's first model call only;
|
|
1884
|
+
* rounds after tool results revert to `'auto'` (see `TToolChoice`).
|
|
1885
|
+
*/
|
|
1886
|
+
toolChoice?: TToolChoice;
|
|
1661
1887
|
sessionId?: string;
|
|
1662
1888
|
userId?: string;
|
|
1663
1889
|
metadata?: TMetadata;
|
|
@@ -1668,13 +1894,48 @@ interface IRunOptions {
|
|
|
1668
1894
|
/** Per-run replay event callback for provider/tool execution boundaries. */
|
|
1669
1895
|
onExecutionEvent?: TExecutionEventCallback;
|
|
1670
1896
|
/**
|
|
1671
|
-
* Maximum
|
|
1672
|
-
*
|
|
1897
|
+
* Maximum execution rounds for this run. A **round** is one provider (model) call plus the
|
|
1898
|
+
* execution of every tool call that reply requested; a reply with no tool calls ends the loop,
|
|
1899
|
+
* so a plain Q&A turn is exactly 1 round. This caps model/tool cycles within ONE `run()` — it is
|
|
1900
|
+
* not a tool-count limit and not a multi-turn conversation limit. When the cap is hit the run
|
|
1901
|
+
* stops after the current round. Use 0 for no core round cap. Defaults to
|
|
1902
|
+
* `IAgentConfig.maxExecutionRounds`.
|
|
1673
1903
|
*/
|
|
1674
1904
|
maxExecutionRounds?: number;
|
|
1675
1905
|
/** Max times the same tool may be called with identical input before aborting. Unset = no limit. */
|
|
1676
1906
|
maxSameToolInputs?: number;
|
|
1907
|
+
/**
|
|
1908
|
+
* Treat a turn that ends in tool calls (no trailing text) as a valid completion instead of
|
|
1909
|
+
* forcing one extra provider call to generate a summary (CORE-011). For decision-agent patterns
|
|
1910
|
+
* (router/orchestrator/classifier) the tool call IS the answer — this removes the one-call tax.
|
|
1911
|
+
* The run result's content may be empty; consumers read the outcome from the tool results.
|
|
1912
|
+
*/
|
|
1913
|
+
allowToolOnlyCompletion?: boolean;
|
|
1914
|
+
/**
|
|
1915
|
+
* Schema-enforced structured output (CORE-015). Accepts a Zod schema or an explicit
|
|
1916
|
+
* `{ jsonSchema }` wrapper. `run` then resolves to the validated, typed object instead of a
|
|
1917
|
+
* string: the schema is forwarded to the provider's native structured-output surface where one
|
|
1918
|
+
* exists, and the final response is always parsed and validated core-side; a violation triggers
|
|
1919
|
+
* a bounded retry with the validation issues fed back as the next turn's input. Every attempt is
|
|
1920
|
+
* a real conversation turn (history stays append-only). Exhausted retries throw
|
|
1921
|
+
* `StructuredOutputError`.
|
|
1922
|
+
*/
|
|
1923
|
+
output?: TStructuredOutputSchema;
|
|
1924
|
+
/**
|
|
1925
|
+
* Retry budget for structured output validation failures — the number of additional attempts
|
|
1926
|
+
* after the first (default 2). Only meaningful with `output` set.
|
|
1927
|
+
*/
|
|
1928
|
+
outputRetries?: number;
|
|
1677
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Run options whose `output` is pinned to a concrete schema type (CORE-015).
|
|
1932
|
+
* Built with `Omit` rather than an intersection on `output` because Zod v3 object
|
|
1933
|
+
* schemas are not assignable to intersections containing themselves (deepPartial
|
|
1934
|
+
* variance), which would silently knock out the typed overloads.
|
|
1935
|
+
*/
|
|
1936
|
+
type TRunOptionsWithOutput<TOutput> = Omit<IRunOptions, 'output'> & {
|
|
1937
|
+
output: TOutput;
|
|
1938
|
+
};
|
|
1678
1939
|
type TExecutionEventData = Record<string, unknown>;
|
|
1679
1940
|
type TExecutionEventCallback = (event: string, data: TExecutionEventData) => void;
|
|
1680
1941
|
/**
|
|
@@ -1710,8 +1971,11 @@ interface IAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUni
|
|
|
1710
1971
|
* Response format configuration
|
|
1711
1972
|
*/
|
|
1712
1973
|
interface IResponseFormatConfig {
|
|
1713
|
-
type?: 'text' | 'json_object';
|
|
1974
|
+
type?: 'text' | 'json_object' | 'json_schema';
|
|
1975
|
+
/** JSON schema payload; required when `type` is `'json_schema'` (CORE-015). */
|
|
1714
1976
|
schema?: Record<string, TConfigValue>;
|
|
1977
|
+
/** Schema name forwarded to provider native structured-output surfaces. */
|
|
1978
|
+
name?: string;
|
|
1715
1979
|
}
|
|
1716
1980
|
/**
|
|
1717
1981
|
* Safety setting configuration
|
|
@@ -1723,7 +1987,7 @@ interface ISafetySetting {
|
|
|
1723
1987
|
}
|
|
1724
1988
|
//#endregion
|
|
1725
1989
|
//#region src/interfaces/provider-definition.d.ts
|
|
1726
|
-
interface
|
|
1990
|
+
interface IProviderDefinitionConfig {
|
|
1727
1991
|
name: string;
|
|
1728
1992
|
model: string;
|
|
1729
1993
|
apiKey?: string;
|
|
@@ -1824,7 +2088,7 @@ interface IProviderDefinition {
|
|
|
1824
2088
|
setupSteps?: readonly IProviderSetupStepDefinition[];
|
|
1825
2089
|
credentialRequirement?: IProviderCredentialRequirement;
|
|
1826
2090
|
requiresApiKey?: boolean;
|
|
1827
|
-
createProvider: (config:
|
|
2091
|
+
createProvider: (config: IProviderDefinitionConfig) => IAIProvider;
|
|
1828
2092
|
probeProfile?: (profile: IProviderProfileConfig) => Promise<IProviderProbeResult>;
|
|
1829
2093
|
}
|
|
1830
2094
|
declare function findProviderDefinition(definitions: readonly IProviderDefinition[], type: string): IProviderDefinition | undefined;
|
|
@@ -2122,6 +2386,42 @@ interface IToolFactory {
|
|
|
2122
2386
|
createMCPTool(config: IMCPToolConfig): ITool;
|
|
2123
2387
|
}
|
|
2124
2388
|
//#endregion
|
|
2389
|
+
//#region src/interfaces/interaction-builders.d.ts
|
|
2390
|
+
/** Option value for the affirmative choice of a confirmation. */
|
|
2391
|
+
declare const CONFIRM_YES = "yes";
|
|
2392
|
+
/** Option value for the negative choice of a confirmation. */
|
|
2393
|
+
declare const CONFIRM_NO = "no";
|
|
2394
|
+
/** Build a yes/no confirmation action (two options, single selection). */
|
|
2395
|
+
declare function confirmAction(id: string, message: string, extra?: {
|
|
2396
|
+
description?: string;
|
|
2397
|
+
defaultYes?: boolean;
|
|
2398
|
+
}): IActionRequest;
|
|
2399
|
+
/** Build a single-select action (optionally allowing a typed custom answer). */
|
|
2400
|
+
declare function selectAction(id: string, title: string, options: readonly IActionOption[], extra?: {
|
|
2401
|
+
description?: string;
|
|
2402
|
+
allowFreeText?: boolean;
|
|
2403
|
+
maxVisible?: number;
|
|
2404
|
+
default?: IActionDefault;
|
|
2405
|
+
}): IActionRequest;
|
|
2406
|
+
/** Build a multi-select action (min/max selections; defaults: min 1, max = number of options). */
|
|
2407
|
+
declare function multiSelectAction(id: string, title: string, options: readonly IActionOption[], extra?: {
|
|
2408
|
+
description?: string;
|
|
2409
|
+
minSelect?: number;
|
|
2410
|
+
maxSelect?: number;
|
|
2411
|
+
maxVisible?: number;
|
|
2412
|
+
default?: IActionDefault;
|
|
2413
|
+
}): IActionRequest;
|
|
2414
|
+
/** Build a free-text action (optionally masked for secret entry such as an API key). */
|
|
2415
|
+
declare function textAction(id: string, title: string, extra?: {
|
|
2416
|
+
description?: string;
|
|
2417
|
+
masked?: boolean;
|
|
2418
|
+
allowEmpty?: boolean;
|
|
2419
|
+
placeholder?: string;
|
|
2420
|
+
default?: IActionDefault;
|
|
2421
|
+
}): IActionRequest;
|
|
2422
|
+
/** True when the user answered a {@link confirmAction} affirmatively (selected "Yes"). */
|
|
2423
|
+
declare function isConfirmed(response: TActionResponse): boolean;
|
|
2424
|
+
//#endregion
|
|
2125
2425
|
//#region src/interfaces/progress-reporting.d.ts
|
|
2126
2426
|
/**
|
|
2127
2427
|
* Execution step definition for tools that support step-by-step progress reporting
|
|
@@ -2248,6 +2548,8 @@ interface IToolExecutionRequest {
|
|
|
2248
2548
|
ownerPath?: IOwnerPathSegment[];
|
|
2249
2549
|
eventService?: IEventService;
|
|
2250
2550
|
baseEventService?: IEventService;
|
|
2551
|
+
/** Injected "ask the user" port propagated into the tool's execution context (CMD-005). */
|
|
2552
|
+
ask?: IUserInteraction['ask'];
|
|
2251
2553
|
}
|
|
2252
2554
|
/**
|
|
2253
2555
|
* Conversation context containing messages and metadata
|
|
@@ -2738,7 +3040,7 @@ type TProviderLoggingData = Record<string, string | number | boolean | Date | st
|
|
|
2738
3040
|
/**
|
|
2739
3041
|
* Provider configuration base interface
|
|
2740
3042
|
*/
|
|
2741
|
-
interface
|
|
3043
|
+
interface IProviderRuntimeConfig {
|
|
2742
3044
|
apiKey?: string;
|
|
2743
3045
|
baseUrl?: string;
|
|
2744
3046
|
timeout?: number;
|
|
@@ -2768,7 +3070,7 @@ interface IExecutorAwareProviderConfig {
|
|
|
2768
3070
|
*
|
|
2769
3071
|
* @template TConfig - Provider configuration type
|
|
2770
3072
|
*/
|
|
2771
|
-
declare abstract class AbstractAIProvider<TConfig =
|
|
3073
|
+
declare abstract class AbstractAIProvider<TConfig = IProviderRuntimeConfig> implements IAIProvider {
|
|
2772
3074
|
abstract readonly name: string;
|
|
2773
3075
|
abstract readonly version: string;
|
|
2774
3076
|
protected config?: TConfig;
|
|
@@ -3075,6 +3377,22 @@ declare class ValidationError extends RobotaError {
|
|
|
3075
3377
|
readonly recoverable = false;
|
|
3076
3378
|
constructor(message: string, field?: string | undefined, context?: TErrorContextData);
|
|
3077
3379
|
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Structured output validation exhausted its retry budget (CORE-015).
|
|
3382
|
+
*
|
|
3383
|
+
* Thrown by `run(input, { output })` when the model's final response still fails
|
|
3384
|
+
* schema validation after the configured number of retries. `issues` holds the
|
|
3385
|
+
* validation messages from the last attempt; `attempts` is the total number of
|
|
3386
|
+
* provider turns spent (initial + retries).
|
|
3387
|
+
*/
|
|
3388
|
+
declare class StructuredOutputError extends RobotaError {
|
|
3389
|
+
readonly issues: string[];
|
|
3390
|
+
readonly attempts: number;
|
|
3391
|
+
readonly code = "STRUCTURED_OUTPUT_ERROR";
|
|
3392
|
+
readonly category: "provider";
|
|
3393
|
+
readonly recoverable = true;
|
|
3394
|
+
constructor(message: string, issues: string[], attempts: number, context?: TErrorContextData);
|
|
3395
|
+
}
|
|
3078
3396
|
/**
|
|
3079
3397
|
* Provider related errors
|
|
3080
3398
|
*/
|
|
@@ -3209,6 +3527,45 @@ interface IPeriodicTaskOptions {
|
|
|
3209
3527
|
declare function startPeriodicTask(logger: ILogger, options: IPeriodicTaskOptions, task: () => Promise<void>): TTimerId;
|
|
3210
3528
|
declare function stopPeriodicTask(timer: TTimerId | undefined): void;
|
|
3211
3529
|
//#endregion
|
|
3530
|
+
//#region src/utils/platform-shell.d.ts
|
|
3531
|
+
/**
|
|
3532
|
+
* TERM-008: cross-platform shell resolution (SSOT).
|
|
3533
|
+
*
|
|
3534
|
+
* Single source of truth for "which shell do we spawn, and how", shared by every shell-running site
|
|
3535
|
+
* (the Shell tool, the hook `command` executor, and the interactive drop-to-shell). Resolution is a
|
|
3536
|
+
* pure function of `(env, platform)` so every branch is testable without touching the host shell.
|
|
3537
|
+
*/
|
|
3538
|
+
/** Shell family — drives non-interactive arg shape, quoting, and LLM syntax guidance. */
|
|
3539
|
+
type TShellKind = 'bash' | 'sh' | 'powershell' | 'cmd';
|
|
3540
|
+
/** The active shell resolved for a platform, plus the metadata callers need to drive and describe it. */
|
|
3541
|
+
interface IPlatformShell {
|
|
3542
|
+
/** Executable to spawn (e.g. `/bin/sh`, `powershell.exe`, or `$SHELL`). */
|
|
3543
|
+
readonly command: string;
|
|
3544
|
+
/** Shell family. */
|
|
3545
|
+
readonly kind: TShellKind;
|
|
3546
|
+
/** Node platform this was resolved for (`process.platform`). */
|
|
3547
|
+
readonly platform: NodeJS.Platform;
|
|
3548
|
+
/** Args to run a single command string non-interactively. */
|
|
3549
|
+
commandArgs(command: string): string[];
|
|
3550
|
+
/** Args for an interactive shell session (drop-to-shell). */
|
|
3551
|
+
readonly interactiveArgs: string[];
|
|
3552
|
+
/** Human label for the active shell, for tool/UI descriptions (e.g. `PowerShell (Windows)`). */
|
|
3553
|
+
readonly label: string;
|
|
3554
|
+
/** One-line syntax guidance for an LLM authoring commands. */
|
|
3555
|
+
readonly syntaxHint: string;
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* Resolve the shell to spawn for the current (or a given) platform.
|
|
3559
|
+
*
|
|
3560
|
+
* - `ROBOTA_SHELL` (if set) wins on every platform.
|
|
3561
|
+
* - **win32:** PowerShell.
|
|
3562
|
+
* - **posix:** `$SHELL` if set, else `/bin/sh`.
|
|
3563
|
+
*
|
|
3564
|
+
* @param env - Environment to read overrides from. Defaults to `process.env`.
|
|
3565
|
+
* @param platform - Platform to resolve for. Defaults to `process.platform`. Pass explicitly in tests.
|
|
3566
|
+
*/
|
|
3567
|
+
declare function resolvePlatformShell(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): IPlatformShell;
|
|
3568
|
+
//#endregion
|
|
3212
3569
|
//#region src/utils/index.d.ts
|
|
3213
3570
|
/**
|
|
3214
3571
|
* Cross-platform timer identifier type
|
|
@@ -3216,6 +3573,24 @@ declare function stopPeriodicTask(timer: TTimerId | undefined): void;
|
|
|
3216
3573
|
*/
|
|
3217
3574
|
type TTimerId = ReturnType<typeof setTimeout>;
|
|
3218
3575
|
//#endregion
|
|
3576
|
+
//#region src/schema/zod-to-json-schema.d.ts
|
|
3577
|
+
/**
|
|
3578
|
+
* Convert Zod schema to JSON Schema format with safe undefined handling
|
|
3579
|
+
*/
|
|
3580
|
+
declare function zodToJsonSchema(schema: IZodSchema, options?: ISchemaConversionOptions): IToolSchema['parameters'];
|
|
3581
|
+
/**
|
|
3582
|
+
* Safely extract enum values from Zod schema
|
|
3583
|
+
*/
|
|
3584
|
+
declare function extractEnumValues(schema: IZodSchema): TUniversalValue[];
|
|
3585
|
+
/**
|
|
3586
|
+
* Check if schema has validation constraints
|
|
3587
|
+
*/
|
|
3588
|
+
declare function hasValidationConstraints(schema: IZodSchema): boolean;
|
|
3589
|
+
/**
|
|
3590
|
+
* Safe schema type name extraction
|
|
3591
|
+
*/
|
|
3592
|
+
declare function getSchemaTypeName(schema: IZodSchema): string;
|
|
3593
|
+
//#endregion
|
|
3219
3594
|
//#region src/managers/conversation-store.d.ts
|
|
3220
3595
|
/** API message format for provider consumption */
|
|
3221
3596
|
interface IProviderApiMessage {
|
|
@@ -3243,6 +3618,11 @@ declare class ConversationStore implements IConversationHistory {
|
|
|
3243
3618
|
addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3244
3619
|
addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3245
3620
|
addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3621
|
+
/**
|
|
3622
|
+
* Set the single head system prompt (live instruction state). Replaces any existing system
|
|
3623
|
+
* message in place; idempotent and never appends. See agent-core SPEC → System Prompt (SSOT).
|
|
3624
|
+
*/
|
|
3625
|
+
setSystemPrompt(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3246
3626
|
addToolMessage(content: string, toolCallId: string, toolName?: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3247
3627
|
addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3248
3628
|
/** Add a raw history entry (events, etc.) */
|
|
@@ -3532,18 +3912,22 @@ declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptio
|
|
|
3532
3912
|
flushBuffer(): Promise<void>;
|
|
3533
3913
|
getStats(): IEventEmitterPluginStats;
|
|
3534
3914
|
clearAllListeners(): void;
|
|
3535
|
-
|
|
3915
|
+
/** CORE-022: dispose() is the single disposal entry point — releases the flush timer. */
|
|
3916
|
+
dispose(): Promise<void>;
|
|
3536
3917
|
}
|
|
3537
3918
|
//#endregion
|
|
3538
3919
|
//#region src/core/robota-types.d.ts
|
|
3539
|
-
/**
|
|
3920
|
+
/**
|
|
3921
|
+
* Shared model configuration shape used in setModel / getModel. The system prompt is intentionally
|
|
3922
|
+
* absent: it is an agent-level concern (top-level `config.systemMessage`), updated live via
|
|
3923
|
+
* `Robota.updateSystemPrompt`, not part of model config.
|
|
3924
|
+
*/
|
|
3540
3925
|
interface IModelConfig {
|
|
3541
3926
|
provider: string;
|
|
3542
3927
|
model: string;
|
|
3543
3928
|
temperature?: number;
|
|
3544
3929
|
maxTokens?: number;
|
|
3545
3930
|
topP?: number;
|
|
3546
|
-
systemMessage?: string;
|
|
3547
3931
|
/** Reasoning effort tier read per-call by the execution round (PRESET-013 live re-application channel). */
|
|
3548
3932
|
effort?: TModelEffort;
|
|
3549
3933
|
}
|
|
@@ -3815,6 +4199,19 @@ declare class Tools extends AbstractManager implements IToolManager {
|
|
|
3815
4199
|
/** Agent statistics metadata type */
|
|
3816
4200
|
type TAgentStatsMetadata = Record<string, string | number | boolean | Date | string[]>;
|
|
3817
4201
|
//#endregion
|
|
4202
|
+
//#region src/services/tool-execution-service.d.ts
|
|
4203
|
+
/**
|
|
4204
|
+
* ToolExecutionService owned events
|
|
4205
|
+
* Local event names only (no dots). Full names are composed at emit time.
|
|
4206
|
+
*/
|
|
4207
|
+
declare const TOOL_EVENTS: {
|
|
4208
|
+
readonly CALL_START: "call_start";
|
|
4209
|
+
readonly CALL_COMPLETE: "call_complete";
|
|
4210
|
+
readonly CALL_ERROR: "call_error";
|
|
4211
|
+
readonly CALL_RESPONSE_READY: "call_response_ready";
|
|
4212
|
+
};
|
|
4213
|
+
declare const TOOL_EVENT_PREFIX: "tool";
|
|
4214
|
+
//#endregion
|
|
3818
4215
|
//#region src/services/execution-constants.d.ts
|
|
3819
4216
|
/**
|
|
3820
4217
|
* ExecutionService owned events.
|
|
@@ -3860,6 +4257,10 @@ declare function buildAgentStats(deps: IRobotaStatsDeps): {
|
|
|
3860
4257
|
historyStats: TAgentStatsMetadata;
|
|
3861
4258
|
uptime: number;
|
|
3862
4259
|
};
|
|
4260
|
+
/** Result of a best-effort destroy: cleanup failures are collected, never thrown (CORE-013). */
|
|
4261
|
+
interface IDestroyResult {
|
|
4262
|
+
errors: Error[];
|
|
4263
|
+
}
|
|
3863
4264
|
//#endregion
|
|
3864
4265
|
//#region src/core/robota.d.ts
|
|
3865
4266
|
/** @public */
|
|
@@ -3879,6 +4280,8 @@ declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOpti
|
|
|
3879
4280
|
private conversationId;
|
|
3880
4281
|
private logger;
|
|
3881
4282
|
private initializationPromise?;
|
|
4283
|
+
/** Terminal state (CORE-022): once destroyed, run/runStream reject and re-init is impossible. */
|
|
4284
|
+
private destroyed;
|
|
3882
4285
|
private isFullyInitialized;
|
|
3883
4286
|
private startTime;
|
|
3884
4287
|
private configVersion;
|
|
@@ -3893,8 +4296,34 @@ declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOpti
|
|
|
3893
4296
|
* "must be fully initialized" guard.
|
|
3894
4297
|
*/
|
|
3895
4298
|
ensureReady(): Promise<void>;
|
|
4299
|
+
/**
|
|
4300
|
+
* Concurrency contract (CORE-012): a Robota instance owns ONE conversation history, so
|
|
4301
|
+
* concurrent `run`/`runStream` calls on the same instance are serialized on an internal queue —
|
|
4302
|
+
* a call issued while another is in flight waits its turn (its `signal` is honored while queued).
|
|
4303
|
+
* Interleaved histories are therefore impossible by construction.
|
|
4304
|
+
*
|
|
4305
|
+
* Structured output (CORE-015): with `options.output` set the promise resolves to the validated
|
|
4306
|
+
* object (typed `z.infer<S>` for a Zod schema) instead of a string. Note the structured typing
|
|
4307
|
+
* is visible on `Robota` directly; through the generic `IAgent` interface the return type stays
|
|
4308
|
+
* `Promise<string>`.
|
|
4309
|
+
*/
|
|
4310
|
+
run<S extends ZodType>(input: string, options: TRunOptionsWithOutput<S>): Promise<TypeOf<S>>;
|
|
4311
|
+
run(input: string, options: TRunOptionsWithOutput<IJsonSchemaOutput>): Promise<unknown>;
|
|
3896
4312
|
run(input: string, options?: IRunOptions): Promise<string>;
|
|
4313
|
+
runStream<S extends ZodType>(input: string, options: TRunOptionsWithOutput<S>): AsyncGenerator<string, TypeOf<S>, undefined>;
|
|
4314
|
+
runStream(input: string, options: TRunOptionsWithOutput<IJsonSchemaOutput>): AsyncGenerator<string, unknown, undefined>;
|
|
3897
4315
|
runStream(input: string, options?: IRunOptions): AsyncGenerator<string, void, undefined>;
|
|
4316
|
+
/**
|
|
4317
|
+
* Run-isolated mode (CORE-014): with `retainHistory: false` the conversation store is
|
|
4318
|
+
* ephemeral per run — reset after every run settles (success, abort, or error) so nothing
|
|
4319
|
+
* accumulates across runs. The system prompt re-applies on the next run (CORE-010).
|
|
4320
|
+
*/
|
|
4321
|
+
private resetEphemeralHistory;
|
|
4322
|
+
/** Tail of the internal run queue (CORE-012). */
|
|
4323
|
+
private runQueueTail;
|
|
4324
|
+
/** Wait for the previous run to settle, then hold the slot until `release` is called. */
|
|
4325
|
+
private acquireRunSlot;
|
|
4326
|
+
private enqueueRun;
|
|
3898
4327
|
private executionDeps;
|
|
3899
4328
|
getHistory(): TUniversalMessage[];
|
|
3900
4329
|
getFullHistory(): IHistoryEntry[];
|
|
@@ -3914,12 +4343,30 @@ declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOpti
|
|
|
3914
4343
|
getConfiguration(): Promise<IConfigurationSnapshot>;
|
|
3915
4344
|
setModel(mc: IModelConfig): void;
|
|
3916
4345
|
getModel(): IModelConfig;
|
|
4346
|
+
/**
|
|
4347
|
+
* Live system-prompt update (SSOT). Updates the agent's `config.systemMessage` and the active
|
|
4348
|
+
* conversation store's single head system message, so the next provider request carries the
|
|
4349
|
+
* change. This is the propagation path for a session's persona, self-verification toggle, and
|
|
4350
|
+
* AGENTS.md/CLAUDE.md staleness refresh. See agent-core SPEC → System Prompt (single source of
|
|
4351
|
+
* truth).
|
|
4352
|
+
*/
|
|
4353
|
+
updateSystemPrompt(content: string): void;
|
|
4354
|
+
/** Current live system prompt. */
|
|
4355
|
+
getSystemPrompt(): string | undefined;
|
|
3917
4356
|
registerTool(tool: AbstractTool): void;
|
|
3918
4357
|
unregisterTool(toolName: string): void;
|
|
3919
4358
|
getConfig(): IAgentConfig;
|
|
3920
4359
|
swapDefaultProvider(newProvider: IAIProvider, model: string): void;
|
|
3921
4360
|
getStats(): ReturnType<typeof buildAgentStats>;
|
|
3922
|
-
|
|
4361
|
+
/**
|
|
4362
|
+
* Best-effort disposal (CORE-013): never rejects for cleanup failures, so
|
|
4363
|
+
* `void agent.destroy()` is safe to fire-and-forget. Every cleanup step runs even if an
|
|
4364
|
+
* earlier one fails; failures are logged and returned in `errors` for callers that want a
|
|
4365
|
+
* hard signal.
|
|
4366
|
+
*/
|
|
4367
|
+
destroy(): Promise<IDestroyResult>;
|
|
4368
|
+
/** CORE-022: a destroyed agent never revives — reject before touching the run queue. */
|
|
4369
|
+
private assertNotDestroyed;
|
|
3923
4370
|
protected initialize(): Promise<void>;
|
|
3924
4371
|
private ensureFullyInitialized;
|
|
3925
4372
|
private doAsyncInit;
|
|
@@ -4124,6 +4571,18 @@ declare class AgentFactory {
|
|
|
4124
4571
|
}
|
|
4125
4572
|
//#endregion
|
|
4126
4573
|
//#region src/services/execution-usage.d.ts
|
|
4574
|
+
/** Aggregate token totals over a whole session/sub-session history. */
|
|
4575
|
+
interface ISessionUsageTotals {
|
|
4576
|
+
promptTokens: number;
|
|
4577
|
+
completionTokens: number;
|
|
4578
|
+
totalTokens: number;
|
|
4579
|
+
}
|
|
4580
|
+
/**
|
|
4581
|
+
* ANALYTICS-001 (Phase 2): sum assistant token usage across a history timeline — used to capture a
|
|
4582
|
+
* subagent / background task's total usage so it can be attributed to its source in the parent log.
|
|
4583
|
+
* Returns undefined when no usage was reported (so callers can skip recording an empty entry).
|
|
4584
|
+
*/
|
|
4585
|
+
declare function sumHistoryUsage(history: readonly IHistoryEntry[]): ISessionUsageTotals | undefined;
|
|
4127
4586
|
interface IAssistantUsageMetadata {
|
|
4128
4587
|
inputTokens: number;
|
|
4129
4588
|
outputTokens: number;
|
|
@@ -4149,19 +4608,6 @@ declare class EventHistoryModule implements IEventHistoryModule {
|
|
|
4149
4608
|
private nextSequenceId;
|
|
4150
4609
|
}
|
|
4151
4610
|
//#endregion
|
|
4152
|
-
//#region src/services/tool-execution-service.d.ts
|
|
4153
|
-
/**
|
|
4154
|
-
* ToolExecutionService owned events
|
|
4155
|
-
* Local event names only (no dots). Full names are composed at emit time.
|
|
4156
|
-
*/
|
|
4157
|
-
declare const TOOL_EVENTS: {
|
|
4158
|
-
readonly CALL_START: "call_start";
|
|
4159
|
-
readonly CALL_COMPLETE: "call_complete";
|
|
4160
|
-
readonly CALL_ERROR: "call_error";
|
|
4161
|
-
readonly CALL_RESPONSE_READY: "call_response_ready";
|
|
4162
|
-
};
|
|
4163
|
-
declare const TOOL_EVENT_PREFIX: "tool";
|
|
4164
|
-
//#endregion
|
|
4165
4611
|
//#region src/agents/constants.d.ts
|
|
4166
4612
|
/**
|
|
4167
4613
|
* Agent event constants
|
|
@@ -4693,7 +5139,7 @@ declare function evaluatePermission(toolName: string, toolArgs: TToolArgs, mode:
|
|
|
4693
5139
|
/**
|
|
4694
5140
|
* Tool names known to the permission system
|
|
4695
5141
|
*/
|
|
4696
|
-
type TKnownToolName = 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep' | 'WebFetch' | 'WebSearch';
|
|
5142
|
+
type TKnownToolName = 'Shell' | 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep' | 'WebFetch' | 'WebSearch' | 'AskUserQuestion';
|
|
4697
5143
|
/**
|
|
4698
5144
|
* Permission mode → tool policy matrix
|
|
4699
5145
|
* Maps each mode to a decision for each known tool.
|
|
@@ -4840,7 +5286,7 @@ interface IPromptHookDefinition {
|
|
|
4840
5286
|
prompt: string;
|
|
4841
5287
|
model?: string;
|
|
4842
5288
|
}
|
|
4843
|
-
/** Agent hook — delegates to a
|
|
5289
|
+
/** Agent hook — delegates to a subagent */
|
|
4844
5290
|
interface IAgentHookDefinition {
|
|
4845
5291
|
type: 'agent';
|
|
4846
5292
|
agent: string;
|
|
@@ -4937,5 +5383,5 @@ interface IRunHooksResult {
|
|
|
4937
5383
|
*/
|
|
4938
5384
|
declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput, executors?: IHookTypeExecutor[]): Promise<IRunHooksResult>;
|
|
4939
5385
|
//#endregion
|
|
4940
|
-
export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractEventService, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CLAUDE_MODELS, CONTEXT_ESTIMATE_CHARS_PER_TOKEN, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConsoleLogger, ConversationHistory, ConversationStore, DEFAULT_ABSTRACT_EVENT_SERVICE, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, DefaultEventService, ENV_REFERENCE_PREFIX, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, IAbstractTool, IAbstractToolOptions, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IAssistantUsageMetadata, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IConfigValidationResult, type IContextOptions, type IContextTokenEstimate, type IContextTokenEstimateOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IDirent, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventObjectValue, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, IExecutorAwareProviderConfig, type IFileSystem, type IFileSystemAsync, type IFunctionTool, type IHistoryEntry, type IHookGroup, type IHookInput, type IHookResult, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type ILocalExecutorConfig, ILogger, type IMCPToolConfig, type IMediaOutputRef, type IMessageTokenUsage, type IModelDefinition, type IModelPrice, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, type IPlugin, type IPluginConfig, IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderCapabilities,
|
|
5386
|
+
export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractEventService, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CLAUDE_MODELS, CONFIRM_NO, CONFIRM_YES, CONTEXT_ESTIMATE_CHARS_PER_TOKEN, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConsoleLogger, ConversationHistory, ConversationStore, DEFAULT_ABSTRACT_EVENT_SERVICE, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, DefaultEventService, ENV_REFERENCE_PREFIX, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, IAbstractTool, IAbstractToolOptions, type IActionDefault, type IActionOption, type IActionRequest, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IAssistantUsageMetadata, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IConfigValidationResult, type IContextOptions, type IContextTokenEstimate, type IContextTokenEstimateOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IDestroyResult, type IDirent, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventObjectValue, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, IExecutorAwareProviderConfig, type IFileSystem, type IFileSystemAsync, type IFunctionTool, type IHistoryEntry, type IHookGroup, type IHookInput, type IHookResult, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type IJsonSchemaOutput, type ILocalExecutorConfig, ILogger, type IMCPToolConfig, type IMediaOutputRef, type IMessageTokenUsage, type IModelDefinition, type IModelPrice, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, IPlatformShell, type IPlugin, type IPluginConfig, IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderCapabilities, type IProviderCredentialRequirement, type IProviderDefinition, type IProviderDefinitionConfig, type IProviderFunctionCallingCapability, type IProviderMediaError, type IProviderModelCatalog, type IProviderModelCatalogEntry, type IProviderModelCatalogRefreshOptions, type IProviderNativeRawPayloadEvent, type IProviderNativeWebToolCapabilities, type IProviderNativeWebToolCapability, type IProviderNativeWebToolRequest, type IProviderOptions, type IProviderProbeResult, type IProviderProfileConfig, type IProviderProfileDefaults, type IProviderRequest, IProviderRuntimeConfig, type IProviderSetupHelpLink, type IProviderSetupStepDefinition, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISchemaConversionOptions, type ISession, type ISessionUsageTotals, ISimpleValidationResult, type ISpinner, type IStats, type IStreamExecutionRequest, type IStreamingChunk, type IStructuredOutputSpec, type ISystemMessage, type ITemplateApplicationResult, type ITerminalOutput, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, IToolWithEventService, IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserInteraction, type IUserMessage, IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, type IZodParseResult, type IZodSchema, type IZodSchemaDef, InMemoryEventEmitterMetrics, LocalExecutor, MODEL_PRICES, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, ObservableEventService, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, StructuredEventService, StructuredOutputError, TASK_EVENTS, TASK_EVENT_PREFIX, type TActionResponse, type TAgentCreationMetadata, TComplexConfigValue, TConfigData, TConfigValue, TContextData, type TConversationContextMetadata, TErrorContextData, TErrorExternalInput, type TEventEmitterListener, type TEventExtensionValue, type TEventListener, type TEventLoggerData, type TEventName, type TEventUniversalValue, type TExecutionEventCallback, type TExecutionEventData, type TExecutionEventName, type TExecutionMetadata, type THookDefinition, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, TLoggerData, type TManagerToolParameters, TMessageConverterRegistry, TMessageFormatConverter, type TMessageState, TMetadata, TMetadataValue, type TModelEffort, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, TPrimitiveValue, type TProviderConfigValue, type TProviderCredentialField, TProviderLoggingData, type TProviderMediaResult, TProviderMessage, type TProviderModelCapability, type TProviderModelCatalogRefresh, type TProviderModelCatalogStatus, type TProviderModelLifecycle, type TProviderNativeRawPayload, type TProviderNativeRawPayloadCallback, type TProviderNativeRawPayloadKind, type TProviderOptionValueBase, type TProviderSetupField, type TProviderSetupHelpLinkKind, TRUST_TO_MODE, type TResponseMetadata, type TSessionEndReason, TShellKind, type TStructuredOutputSchema, type TStructuredOutputValidation, type TTextDeltaCallback, TTimerId, type TToolArgs, type TToolChoice, TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, TToolParameters, type TToolProgressCallback, type TTrustLevel, TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, TUniversalValue, type TUserEvent, TUtilLogLevel, ToolExecutionError, TypeUtils, UNKNOWN_TOOL_FALLBACK, USER_EVENTS, USER_EVENT_PREFIX, ValidationError, type ValidationSeverity, Validator, assertProviderNativeWebToolsAvailable, bindEventServiceOwner, bindWithOwnerPath, calculateModelCost, chatEntryToMessage, collectAssistantUsageMetadata, composeEventName, confirmAction, createAssistantMessage, createDefaultProviderCapabilities, createExecutionProxy, createLogger, createSystemMessage, createToolMessage, createUserMessage, estimateBlendedCostPer1000, estimateContextTokensFromMessages, estimateSerializedContextTokens, evaluatePermission, extractEnumValues, findProviderDefinition, formatEnvReference, formatSupportedProviderTypes, formatTokenCount, getGlobalLogLevel, getMessagesForAPI, getModelContextWindow, getModelMaxOutput, getModelName, getProviderCapabilities, getProviderCredentialRequirement, getSchemaTypeName, getToolEstimatedDuration, getToolExecutionSteps, hasUsableSecretReference, hasValidationConstraints, isAssistantMessage, isChatEntry, isConfirmed, isDefaultEventService, isEnvReference, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, lookupModelPrice, messageToHistoryEntry, multiSelectAction, normalizeStructuredOutput, parseStructuredResponseText, readTokenUsageFromMessage, readTokenUsageFromMetadata, resolveEnvReference, resolvePlatformShell, runHooks, selectAction, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, sumHistoryUsage, textAction, validateAgainstJsonSchema, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission, zodToJsonSchema };
|
|
4941
5387
|
//# sourceMappingURL=index.d.ts.map
|