@robota-sdk/agent-core 3.0.0-beta.75 → 3.0.0-beta.77
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 -0
- package/LICENSE +661 -21
- package/README.md +94 -16
- package/dist/browser/index.d.ts +516 -44
- 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 -4915
- 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;
|
|
@@ -1974,10 +2238,6 @@ interface IAIProviderManager {
|
|
|
1974
2238
|
* Check if provider is configured
|
|
1975
2239
|
*/
|
|
1976
2240
|
isConfigured(): boolean;
|
|
1977
|
-
/**
|
|
1978
|
-
* Get available models for a provider
|
|
1979
|
-
*/
|
|
1980
|
-
getAvailableModels(providerName: string): string[];
|
|
1981
2241
|
}
|
|
1982
2242
|
/**
|
|
1983
2243
|
* Tool Manager interface for tool registration and management
|
|
@@ -2126,6 +2386,42 @@ interface IToolFactory {
|
|
|
2126
2386
|
createMCPTool(config: IMCPToolConfig): ITool;
|
|
2127
2387
|
}
|
|
2128
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
|
|
2129
2425
|
//#region src/interfaces/progress-reporting.d.ts
|
|
2130
2426
|
/**
|
|
2131
2427
|
* Execution step definition for tools that support step-by-step progress reporting
|
|
@@ -2252,6 +2548,8 @@ interface IToolExecutionRequest {
|
|
|
2252
2548
|
ownerPath?: IOwnerPathSegment[];
|
|
2253
2549
|
eventService?: IEventService;
|
|
2254
2550
|
baseEventService?: IEventService;
|
|
2551
|
+
/** Injected "ask the user" port propagated into the tool's execution context (CMD-005). */
|
|
2552
|
+
ask?: IUserInteraction['ask'];
|
|
2255
2553
|
}
|
|
2256
2554
|
/**
|
|
2257
2555
|
* Conversation context containing messages and metadata
|
|
@@ -2742,7 +3040,7 @@ type TProviderLoggingData = Record<string, string | number | boolean | Date | st
|
|
|
2742
3040
|
/**
|
|
2743
3041
|
* Provider configuration base interface
|
|
2744
3042
|
*/
|
|
2745
|
-
interface
|
|
3043
|
+
interface IProviderRuntimeConfig {
|
|
2746
3044
|
apiKey?: string;
|
|
2747
3045
|
baseUrl?: string;
|
|
2748
3046
|
timeout?: number;
|
|
@@ -2772,7 +3070,7 @@ interface IExecutorAwareProviderConfig {
|
|
|
2772
3070
|
*
|
|
2773
3071
|
* @template TConfig - Provider configuration type
|
|
2774
3072
|
*/
|
|
2775
|
-
declare abstract class AbstractAIProvider<TConfig =
|
|
3073
|
+
declare abstract class AbstractAIProvider<TConfig = IProviderRuntimeConfig> implements IAIProvider {
|
|
2776
3074
|
abstract readonly name: string;
|
|
2777
3075
|
abstract readonly version: string;
|
|
2778
3076
|
protected config?: TConfig;
|
|
@@ -3079,6 +3377,22 @@ declare class ValidationError extends RobotaError {
|
|
|
3079
3377
|
readonly recoverable = false;
|
|
3080
3378
|
constructor(message: string, field?: string | undefined, context?: TErrorContextData);
|
|
3081
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
|
+
}
|
|
3082
3396
|
/**
|
|
3083
3397
|
* Provider related errors
|
|
3084
3398
|
*/
|
|
@@ -3213,6 +3527,45 @@ interface IPeriodicTaskOptions {
|
|
|
3213
3527
|
declare function startPeriodicTask(logger: ILogger, options: IPeriodicTaskOptions, task: () => Promise<void>): TTimerId;
|
|
3214
3528
|
declare function stopPeriodicTask(timer: TTimerId | undefined): void;
|
|
3215
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
|
|
3216
3569
|
//#region src/utils/index.d.ts
|
|
3217
3570
|
/**
|
|
3218
3571
|
* Cross-platform timer identifier type
|
|
@@ -3220,6 +3573,24 @@ declare function stopPeriodicTask(timer: TTimerId | undefined): void;
|
|
|
3220
3573
|
*/
|
|
3221
3574
|
type TTimerId = ReturnType<typeof setTimeout>;
|
|
3222
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
|
|
3223
3594
|
//#region src/managers/conversation-store.d.ts
|
|
3224
3595
|
/** API message format for provider consumption */
|
|
3225
3596
|
interface IProviderApiMessage {
|
|
@@ -3247,6 +3618,11 @@ declare class ConversationStore implements IConversationHistory {
|
|
|
3247
3618
|
addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3248
3619
|
addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3249
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;
|
|
3250
3626
|
addToolMessage(content: string, toolCallId: string, toolName?: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3251
3627
|
addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3252
3628
|
/** Add a raw history entry (events, etc.) */
|
|
@@ -3536,18 +3912,22 @@ declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptio
|
|
|
3536
3912
|
flushBuffer(): Promise<void>;
|
|
3537
3913
|
getStats(): IEventEmitterPluginStats;
|
|
3538
3914
|
clearAllListeners(): void;
|
|
3539
|
-
|
|
3915
|
+
/** CORE-022: dispose() is the single disposal entry point — releases the flush timer. */
|
|
3916
|
+
dispose(): Promise<void>;
|
|
3540
3917
|
}
|
|
3541
3918
|
//#endregion
|
|
3542
3919
|
//#region src/core/robota-types.d.ts
|
|
3543
|
-
/**
|
|
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
|
+
*/
|
|
3544
3925
|
interface IModelConfig {
|
|
3545
3926
|
provider: string;
|
|
3546
3927
|
model: string;
|
|
3547
3928
|
temperature?: number;
|
|
3548
3929
|
maxTokens?: number;
|
|
3549
3930
|
topP?: number;
|
|
3550
|
-
systemMessage?: string;
|
|
3551
3931
|
/** Reasoning effort tier read per-call by the execution round (PRESET-013 live re-application channel). */
|
|
3552
3932
|
effort?: TModelEffort;
|
|
3553
3933
|
}
|
|
@@ -3675,11 +4055,6 @@ declare class AIProviders extends AbstractManager implements IAIProviderManager
|
|
|
3675
4055
|
* Check if provider is configured
|
|
3676
4056
|
*/
|
|
3677
4057
|
isConfigured(): boolean;
|
|
3678
|
-
/**
|
|
3679
|
-
* Get available models for a provider
|
|
3680
|
-
* Note: In the new architecture, models are handled by each provider internally
|
|
3681
|
-
*/
|
|
3682
|
-
getAvailableModels(providerName: string): string[];
|
|
3683
4058
|
/**
|
|
3684
4059
|
* Get current provider instance
|
|
3685
4060
|
*/
|
|
@@ -3824,6 +4199,19 @@ declare class Tools extends AbstractManager implements IToolManager {
|
|
|
3824
4199
|
/** Agent statistics metadata type */
|
|
3825
4200
|
type TAgentStatsMetadata = Record<string, string | number | boolean | Date | string[]>;
|
|
3826
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
|
|
3827
4215
|
//#region src/services/execution-constants.d.ts
|
|
3828
4216
|
/**
|
|
3829
4217
|
* ExecutionService owned events.
|
|
@@ -3869,6 +4257,10 @@ declare function buildAgentStats(deps: IRobotaStatsDeps): {
|
|
|
3869
4257
|
historyStats: TAgentStatsMetadata;
|
|
3870
4258
|
uptime: number;
|
|
3871
4259
|
};
|
|
4260
|
+
/** Result of a best-effort destroy: cleanup failures are collected, never thrown (CORE-013). */
|
|
4261
|
+
interface IDestroyResult {
|
|
4262
|
+
errors: Error[];
|
|
4263
|
+
}
|
|
3872
4264
|
//#endregion
|
|
3873
4265
|
//#region src/core/robota.d.ts
|
|
3874
4266
|
/** @public */
|
|
@@ -3888,14 +4280,50 @@ declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOpti
|
|
|
3888
4280
|
private conversationId;
|
|
3889
4281
|
private logger;
|
|
3890
4282
|
private initializationPromise?;
|
|
4283
|
+
/** Terminal state (CORE-022): once destroyed, run/runStream reject and re-init is impossible. */
|
|
4284
|
+
private destroyed;
|
|
3891
4285
|
private isFullyInitialized;
|
|
3892
4286
|
private startTime;
|
|
3893
4287
|
private configVersion;
|
|
3894
4288
|
private configUpdatedAt;
|
|
3895
4289
|
private configManager;
|
|
3896
4290
|
constructor(config: IAgentConfig);
|
|
4291
|
+
/**
|
|
4292
|
+
* Ensure the agent is fully initialized (providers registered, current provider set, execution
|
|
4293
|
+
* service built) WITHOUT running a turn. Idempotent. Lets callers that mutate runtime
|
|
4294
|
+
* configuration before the first `run()` (e.g. live preset/model switching on a fresh
|
|
4295
|
+
* interactive session) bring the agent to a ready state first, instead of failing the
|
|
4296
|
+
* "must be fully initialized" guard.
|
|
4297
|
+
*/
|
|
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>;
|
|
3897
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>;
|
|
3898
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;
|
|
3899
4327
|
private executionDeps;
|
|
3900
4328
|
getHistory(): TUniversalMessage[];
|
|
3901
4329
|
getFullHistory(): IHistoryEntry[];
|
|
@@ -3915,12 +4343,30 @@ declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOpti
|
|
|
3915
4343
|
getConfiguration(): Promise<IConfigurationSnapshot>;
|
|
3916
4344
|
setModel(mc: IModelConfig): void;
|
|
3917
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;
|
|
3918
4356
|
registerTool(tool: AbstractTool): void;
|
|
3919
4357
|
unregisterTool(toolName: string): void;
|
|
3920
4358
|
getConfig(): IAgentConfig;
|
|
3921
4359
|
swapDefaultProvider(newProvider: IAIProvider, model: string): void;
|
|
3922
4360
|
getStats(): ReturnType<typeof buildAgentStats>;
|
|
3923
|
-
|
|
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;
|
|
3924
4370
|
protected initialize(): Promise<void>;
|
|
3925
4371
|
private ensureFullyInitialized;
|
|
3926
4372
|
private doAsyncInit;
|
|
@@ -4125,6 +4571,18 @@ declare class AgentFactory {
|
|
|
4125
4571
|
}
|
|
4126
4572
|
//#endregion
|
|
4127
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;
|
|
4128
4586
|
interface IAssistantUsageMetadata {
|
|
4129
4587
|
inputTokens: number;
|
|
4130
4588
|
outputTokens: number;
|
|
@@ -4150,19 +4608,6 @@ declare class EventHistoryModule implements IEventHistoryModule {
|
|
|
4150
4608
|
private nextSequenceId;
|
|
4151
4609
|
}
|
|
4152
4610
|
//#endregion
|
|
4153
|
-
//#region src/services/tool-execution-service.d.ts
|
|
4154
|
-
/**
|
|
4155
|
-
* ToolExecutionService owned events
|
|
4156
|
-
* Local event names only (no dots). Full names are composed at emit time.
|
|
4157
|
-
*/
|
|
4158
|
-
declare const TOOL_EVENTS: {
|
|
4159
|
-
readonly CALL_START: "call_start";
|
|
4160
|
-
readonly CALL_COMPLETE: "call_complete";
|
|
4161
|
-
readonly CALL_ERROR: "call_error";
|
|
4162
|
-
readonly CALL_RESPONSE_READY: "call_response_ready";
|
|
4163
|
-
};
|
|
4164
|
-
declare const TOOL_EVENT_PREFIX: "tool";
|
|
4165
|
-
//#endregion
|
|
4166
4611
|
//#region src/agents/constants.d.ts
|
|
4167
4612
|
/**
|
|
4168
4613
|
* Agent event constants
|
|
@@ -4694,7 +5139,7 @@ declare function evaluatePermission(toolName: string, toolArgs: TToolArgs, mode:
|
|
|
4694
5139
|
/**
|
|
4695
5140
|
* Tool names known to the permission system
|
|
4696
5141
|
*/
|
|
4697
|
-
type TKnownToolName = 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep' | 'WebFetch' | 'WebSearch';
|
|
5142
|
+
type TKnownToolName = 'Shell' | 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep' | 'WebFetch' | 'WebSearch' | 'AskUserQuestion';
|
|
4698
5143
|
/**
|
|
4699
5144
|
* Permission mode → tool policy matrix
|
|
4700
5145
|
* Maps each mode to a decision for each known tool.
|
|
@@ -4787,6 +5232,33 @@ declare function getModelName(modelId: string): string;
|
|
|
4787
5232
|
/** Format token count as human-readable (e.g., 200K, 1M, 1.2M). Minimum unit is K. */
|
|
4788
5233
|
declare function formatTokenCount(tokens: number): string;
|
|
4789
5234
|
//#endregion
|
|
5235
|
+
//#region src/context/model-pricing.d.ts
|
|
5236
|
+
/**
|
|
5237
|
+
* Model pricing — SSOT for per-model token cost.
|
|
5238
|
+
*
|
|
5239
|
+
* Sibling of `models.ts` (which owns context-window/output metadata). Consumers that need to
|
|
5240
|
+
* compute or estimate cost (cost display, budget/rate limiting) must read from here rather than
|
|
5241
|
+
* embedding their own price tables.
|
|
5242
|
+
*
|
|
5243
|
+
* Prices are USD per 1,000,000 tokens (as of May 2026 — update when providers change rates).
|
|
5244
|
+
*/
|
|
5245
|
+
interface IModelPrice {
|
|
5246
|
+
inputPerMillion: number;
|
|
5247
|
+
outputPerMillion: number;
|
|
5248
|
+
}
|
|
5249
|
+
/** Exact per-model prices, keyed by API model ID. */
|
|
5250
|
+
declare const MODEL_PRICES: Record<string, IModelPrice>;
|
|
5251
|
+
/** Resolve a model's price by exact ID, then family pattern. Returns undefined if unknown. */
|
|
5252
|
+
declare function lookupModelPrice(modelId: string): IModelPrice | undefined;
|
|
5253
|
+
/** Exact USD cost for an input/output token split, or undefined if the model is unknown. */
|
|
5254
|
+
declare function calculateModelCost(modelId: string, inputTokens: number, outputTokens: number): number | undefined;
|
|
5255
|
+
/**
|
|
5256
|
+
* Blended USD-per-1000-tokens rate for budget estimation when an input/output split is not
|
|
5257
|
+
* available (e.g. rate limiting). Averages the input and output per-million prices. Returns
|
|
5258
|
+
* undefined if the model is unknown so callers can apply their own fallback rate.
|
|
5259
|
+
*/
|
|
5260
|
+
declare function estimateBlendedCostPer1000(modelId: string): number | undefined;
|
|
5261
|
+
//#endregion
|
|
4790
5262
|
//#region src/hooks/types.d.ts
|
|
4791
5263
|
/**
|
|
4792
5264
|
* Hook system types — Claude Code compatible event/hook model.
|
|
@@ -4814,7 +5286,7 @@ interface IPromptHookDefinition {
|
|
|
4814
5286
|
prompt: string;
|
|
4815
5287
|
model?: string;
|
|
4816
5288
|
}
|
|
4817
|
-
/** Agent hook — delegates to a
|
|
5289
|
+
/** Agent hook — delegates to a subagent */
|
|
4818
5290
|
interface IAgentHookDefinition {
|
|
4819
5291
|
type: 'agent';
|
|
4820
5292
|
agent: string;
|
|
@@ -4911,5 +5383,5 @@ interface IRunHooksResult {
|
|
|
4911
5383
|
*/
|
|
4912
5384
|
declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput, executors?: IHookTypeExecutor[]): Promise<IRunHooksResult>;
|
|
4913
5385
|
//#endregion
|
|
4914
|
-
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 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 };
|
|
4915
5387
|
//# sourceMappingURL=index.d.ts.map
|