art-framework 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +290 -54
- package/dist/index.d.ts +290 -54
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1013,41 +1013,88 @@ interface ConversationMessage {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
/**
|
|
1015
1015
|
* Represents the type of an observation record, capturing significant events during agent execution.
|
|
1016
|
+
* Observations are the primary mechanism for the agent to report its internal state and actions to the outside world (UI, logs, etc.).
|
|
1016
1017
|
*
|
|
1017
1018
|
* @enum {string}
|
|
1018
1019
|
*/
|
|
1019
1020
|
declare enum ObservationType {
|
|
1020
|
-
/**
|
|
1021
|
+
/**
|
|
1022
|
+
* The user's inferred intent.
|
|
1023
|
+
* Generated during the planning phase to signal understanding of the user's goal.
|
|
1024
|
+
*/
|
|
1021
1025
|
INTENT = "INTENT",
|
|
1022
|
-
/**
|
|
1026
|
+
/**
|
|
1027
|
+
* The generated concise thread title.
|
|
1028
|
+
* Usually generated once at the start of a new conversation.
|
|
1029
|
+
*/
|
|
1023
1030
|
TITLE = "TITLE",
|
|
1024
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* The agent's step-by-step plan to address the intent.
|
|
1033
|
+
* Contains the initial or updated TodoList.
|
|
1034
|
+
*/
|
|
1025
1035
|
PLAN = "PLAN",
|
|
1026
|
-
/**
|
|
1036
|
+
/**
|
|
1037
|
+
* The agent's internal monologue or reasoning process.
|
|
1038
|
+
* Often captures the 'thinking' blocks from reasoning models.
|
|
1039
|
+
*/
|
|
1027
1040
|
THOUGHTS = "THOUGHTS",
|
|
1028
|
-
/**
|
|
1041
|
+
/**
|
|
1042
|
+
* Records the LLM's decision to call one or more tools (part of the plan).
|
|
1043
|
+
* Contains the tool name and arguments.
|
|
1044
|
+
*/
|
|
1029
1045
|
TOOL_CALL = "TOOL_CALL",
|
|
1030
|
-
/**
|
|
1046
|
+
/**
|
|
1047
|
+
* Records the actual execution attempt and result of a specific tool call.
|
|
1048
|
+
* Contains the result payload or error message.
|
|
1049
|
+
*/
|
|
1031
1050
|
TOOL_EXECUTION = "TOOL_EXECUTION",
|
|
1032
|
-
/**
|
|
1051
|
+
/**
|
|
1052
|
+
* Records events specifically related to the synthesis phase (e.g., the LLM call).
|
|
1053
|
+
*/
|
|
1033
1054
|
SYNTHESIS = "SYNTHESIS",
|
|
1034
|
-
/**
|
|
1055
|
+
/**
|
|
1056
|
+
* Records an error encountered during any phase of execution.
|
|
1057
|
+
* Contains error details and stack traces.
|
|
1058
|
+
*/
|
|
1035
1059
|
ERROR = "ERROR",
|
|
1036
|
-
/**
|
|
1060
|
+
/**
|
|
1061
|
+
* Records the final AI response message generated by the agent.
|
|
1062
|
+
* This signals the completion of a turn.
|
|
1063
|
+
*/
|
|
1037
1064
|
FINAL_RESPONSE = "FINAL_RESPONSE",
|
|
1038
|
-
/**
|
|
1065
|
+
/**
|
|
1066
|
+
* Records changes made to the agent's persistent state.
|
|
1067
|
+
* Useful for debugging state transitions.
|
|
1068
|
+
*/
|
|
1039
1069
|
STATE_UPDATE = "STATE_UPDATE",
|
|
1040
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* Records updates to the plan structure (intent, title, or list changes).
|
|
1072
|
+
* Triggered when the agent refines its plan during execution.
|
|
1073
|
+
*/
|
|
1041
1074
|
PLAN_UPDATE = "PLAN_UPDATE",
|
|
1042
|
-
/**
|
|
1075
|
+
/**
|
|
1076
|
+
* Records status changes of a specific todo item (e.g., PENDING -> IN_PROGRESS -> COMPLETED).
|
|
1077
|
+
*/
|
|
1043
1078
|
ITEM_STATUS_CHANGE = "ITEM_STATUS_CHANGE",
|
|
1044
|
-
/**
|
|
1079
|
+
/**
|
|
1080
|
+
* Logged by Agent Core when LLM stream consumption begins.
|
|
1081
|
+
* Signals the UI to prepare for incoming tokens.
|
|
1082
|
+
*/
|
|
1045
1083
|
LLM_STREAM_START = "LLM_STREAM_START",
|
|
1046
|
-
/**
|
|
1084
|
+
/**
|
|
1085
|
+
* Logged by Agent Core upon receiving a METADATA stream event.
|
|
1086
|
+
* Content contains LLMMetadata (token counts, latency).
|
|
1087
|
+
*/
|
|
1047
1088
|
LLM_STREAM_METADATA = "LLM_STREAM_METADATA",
|
|
1048
|
-
/**
|
|
1089
|
+
/**
|
|
1090
|
+
* Logged by Agent Core upon receiving an END stream event.
|
|
1091
|
+
* Signals the end of a streaming response.
|
|
1092
|
+
*/
|
|
1049
1093
|
LLM_STREAM_END = "LLM_STREAM_END",
|
|
1050
|
-
/**
|
|
1094
|
+
/**
|
|
1095
|
+
* Logged by Agent Core upon receiving an ERROR stream event.
|
|
1096
|
+
* Content contains the Error object or message.
|
|
1097
|
+
*/
|
|
1051
1098
|
LLM_STREAM_ERROR = "LLM_STREAM_ERROR"
|
|
1052
1099
|
}
|
|
1053
1100
|
/**
|
|
@@ -1074,6 +1121,7 @@ declare enum ModelCapability {
|
|
|
1074
1121
|
}
|
|
1075
1122
|
/**
|
|
1076
1123
|
* Represents a recorded event during the agent's execution.
|
|
1124
|
+
* Observations provide a granular log of the agent's internal state, decisions, and interactions.
|
|
1077
1125
|
*
|
|
1078
1126
|
* @interface Observation
|
|
1079
1127
|
*/
|
|
@@ -1193,7 +1241,7 @@ interface StreamEvent {
|
|
|
1193
1241
|
*/
|
|
1194
1242
|
traceId: string;
|
|
1195
1243
|
/**
|
|
1196
|
-
* Optional identifier linking the event to a specific UI
|
|
1244
|
+
* Optional identifier linking the event to a specific UI session/window.
|
|
1197
1245
|
* @property {string} [sessionId]
|
|
1198
1246
|
*/
|
|
1199
1247
|
sessionId?: string;
|
|
@@ -1466,27 +1514,32 @@ interface ParsedToolCall {
|
|
|
1466
1514
|
}
|
|
1467
1515
|
/**
|
|
1468
1516
|
* Configuration specific to a conversation thread.
|
|
1517
|
+
* Controls behavior, tools, and provider settings for a particular interaction context.
|
|
1469
1518
|
*
|
|
1470
1519
|
* @interface ThreadConfig
|
|
1471
1520
|
*/
|
|
1472
1521
|
interface ThreadConfig {
|
|
1473
1522
|
/**
|
|
1474
1523
|
* Default provider configuration for this thread.
|
|
1524
|
+
* Determines which LLM and model will be used for reasoning.
|
|
1475
1525
|
* @property {RuntimeProviderConfig} providerConfig
|
|
1476
1526
|
*/
|
|
1477
1527
|
providerConfig: RuntimeProviderConfig;
|
|
1478
1528
|
/**
|
|
1479
1529
|
* An array of tool names (matching `ToolSchema.name`) that are permitted for use within this thread.
|
|
1530
|
+
* Allows for scoping capabilities per conversation.
|
|
1480
1531
|
* @property {string[]} enabledTools
|
|
1481
1532
|
*/
|
|
1482
1533
|
enabledTools: string[];
|
|
1483
1534
|
/**
|
|
1484
1535
|
* The maximum number of past messages (`ConversationMessage` objects) to retrieve for context.
|
|
1536
|
+
* Helps manage context window limits.
|
|
1485
1537
|
* @property {number} historyLimit
|
|
1486
1538
|
*/
|
|
1487
1539
|
historyLimit: number;
|
|
1488
1540
|
/**
|
|
1489
1541
|
* Optional system prompt override to be used for this thread, overriding instance or agent defaults.
|
|
1542
|
+
* Allows for thread-specific role instructions.
|
|
1490
1543
|
* @property {string | SystemPromptOverride} [systemPrompt]
|
|
1491
1544
|
*/
|
|
1492
1545
|
systemPrompt?: string | SystemPromptOverride;
|
|
@@ -1499,13 +1552,15 @@ interface ThreadConfig {
|
|
|
1499
1552
|
}
|
|
1500
1553
|
/**
|
|
1501
1554
|
* Represents non-configuration state associated with an agent or thread.
|
|
1502
|
-
*
|
|
1555
|
+
* This is the persistent memory of the agent, used to store planning progress,
|
|
1556
|
+
* variables, and other dynamic data across execution cycles.
|
|
1503
1557
|
*
|
|
1504
1558
|
* @interface AgentState
|
|
1505
1559
|
*/
|
|
1506
1560
|
interface AgentState {
|
|
1507
1561
|
/**
|
|
1508
|
-
* The primary data payload of the agent's state.
|
|
1562
|
+
* The primary data payload of the agent's state.
|
|
1563
|
+
* Structure is application-defined but typically includes the current plan, todo list, etc.
|
|
1509
1564
|
* @property {any} data
|
|
1510
1565
|
*/
|
|
1511
1566
|
data: any;
|
|
@@ -1521,7 +1576,8 @@ interface AgentState {
|
|
|
1521
1576
|
[key: string]: any;
|
|
1522
1577
|
}
|
|
1523
1578
|
/**
|
|
1524
|
-
* Encapsulates the
|
|
1579
|
+
* Encapsulates the complete context for a specific thread, combining configuration and state.
|
|
1580
|
+
* This object represents the full snapshot of a thread's environment.
|
|
1525
1581
|
*
|
|
1526
1582
|
* @interface ThreadContext
|
|
1527
1583
|
*/
|
|
@@ -1538,7 +1594,7 @@ interface ThreadContext {
|
|
|
1538
1594
|
state: AgentState | null;
|
|
1539
1595
|
}
|
|
1540
1596
|
/**
|
|
1541
|
-
* Properties required to initiate an agent processing cycle.
|
|
1597
|
+
* Properties required to initiate an agent processing cycle via `agent.process()`.
|
|
1542
1598
|
*
|
|
1543
1599
|
* @interface AgentProps
|
|
1544
1600
|
*/
|
|
@@ -1554,7 +1610,7 @@ interface AgentProps {
|
|
|
1554
1610
|
*/
|
|
1555
1611
|
threadId: string;
|
|
1556
1612
|
/**
|
|
1557
|
-
* An optional identifier for the specific UI session, useful for targeting UI updates.
|
|
1613
|
+
* An optional identifier for the specific UI session, useful for targeting UI updates via sockets.
|
|
1558
1614
|
* @property {string} [sessionId]
|
|
1559
1615
|
*/
|
|
1560
1616
|
sessionId?: string;
|
|
@@ -1575,7 +1631,7 @@ interface AgentProps {
|
|
|
1575
1631
|
options?: AgentOptions;
|
|
1576
1632
|
}
|
|
1577
1633
|
/**
|
|
1578
|
-
* Options to override agent behavior at runtime.
|
|
1634
|
+
* Options to override agent behavior at runtime during a `process` call.
|
|
1579
1635
|
*
|
|
1580
1636
|
* @interface AgentOptions
|
|
1581
1637
|
*/
|
|
@@ -2683,24 +2739,46 @@ declare class A2ATaskSocket extends TypedSocket<A2ATaskEvent, A2ATaskFilter> {
|
|
|
2683
2739
|
}
|
|
2684
2740
|
|
|
2685
2741
|
/**
|
|
2686
|
-
* A specialized TypedSocket for handling Observation data.
|
|
2687
|
-
*
|
|
2688
|
-
*
|
|
2742
|
+
* A specialized `TypedSocket` designed for handling `Observation` data streams.
|
|
2743
|
+
*
|
|
2744
|
+
* @remarks
|
|
2745
|
+
* This socket acts as the bridge between the agent's internal `ObservationManager` and the external UI or monitoring systems.
|
|
2746
|
+
* It extends the generic `TypedSocket` to provide:
|
|
2747
|
+
* 1. **Type-Safe Notification**: Specifically handles `Observation` objects.
|
|
2748
|
+
* 2. **Specialized Filtering**: Allows subscribers to filter events by `ObservationType` (e.g., only subscribe to 'TOOL_EXECUTION' or 'THOUGHTS').
|
|
2749
|
+
* 3. **Historical Access**: Provides a `getHistory` method that leverages the `IObservationRepository` to fetch past observations, enabling UIs to populate initial state.
|
|
2750
|
+
*
|
|
2751
|
+
* This class is a key component of the `UISystem`.
|
|
2689
2752
|
*/
|
|
2690
2753
|
declare class ObservationSocket extends TypedSocket<Observation, ObservationType | ObservationType[]> {
|
|
2691
2754
|
private observationRepository?;
|
|
2755
|
+
/**
|
|
2756
|
+
* Creates an instance of ObservationSocket.
|
|
2757
|
+
* @param observationRepository - Optional repository for fetching observation history. If not provided, `getHistory` will return empty arrays.
|
|
2758
|
+
*/
|
|
2692
2759
|
constructor(observationRepository?: IObservationRepository);
|
|
2693
2760
|
/**
|
|
2694
|
-
* Notifies subscribers about a new observation.
|
|
2695
|
-
*
|
|
2761
|
+
* Notifies all eligible subscribers about a new observation.
|
|
2762
|
+
*
|
|
2763
|
+
* @remarks
|
|
2764
|
+
* This method is called by the `ObservationManager` whenever a new observation is recorded.
|
|
2765
|
+
* It iterates through all active subscriptions and invokes their callbacks if:
|
|
2766
|
+
* 1. The subscriber's `targetThreadId` (if any) matches the observation's `threadId`.
|
|
2767
|
+
* 2. The subscriber's `filter` (if any) matches the observation's `type`.
|
|
2768
|
+
*
|
|
2769
|
+
* @param observation - The new `Observation` object to broadcast.
|
|
2696
2770
|
*/
|
|
2697
2771
|
notifyObservation(observation: Observation): void;
|
|
2698
2772
|
/**
|
|
2699
|
-
* Retrieves historical observations
|
|
2700
|
-
*
|
|
2701
|
-
* @
|
|
2702
|
-
*
|
|
2703
|
-
*
|
|
2773
|
+
* Retrieves historical observations from the underlying repository.
|
|
2774
|
+
*
|
|
2775
|
+
* @remarks
|
|
2776
|
+
* This is typically used by UIs when they first connect to a thread to backfill the event log.
|
|
2777
|
+
* It translates the socket's filter criteria into an `ObservationFilter` compatible with the repository.
|
|
2778
|
+
*
|
|
2779
|
+
* @param filter - Optional `ObservationType` or array of types to filter the history by.
|
|
2780
|
+
* @param options - Required object containing `threadId` and optional `limit`.
|
|
2781
|
+
* @returns A promise resolving to an array of `Observation` objects matching the criteria.
|
|
2704
2782
|
*/
|
|
2705
2783
|
getHistory(filter?: ObservationType | ObservationType[], options?: {
|
|
2706
2784
|
threadId?: string;
|
|
@@ -3817,21 +3895,162 @@ declare class PESAgent implements IAgentCore {
|
|
|
3817
3895
|
private readonly deps;
|
|
3818
3896
|
private readonly persona;
|
|
3819
3897
|
constructor(dependencies: PESAgentDependencies);
|
|
3898
|
+
/**
|
|
3899
|
+
* Processes a user query through the PES (Plan-Execute-Synthesize) reasoning loop.
|
|
3900
|
+
* This is the main entry point for the agent's execution logic.
|
|
3901
|
+
*
|
|
3902
|
+
* The process involves:
|
|
3903
|
+
* 1. **Configuration**: Loading thread context, resolving system prompts, and determining the active persona.
|
|
3904
|
+
* 2. **Context Gathering**: Retrieving conversation history and available tools.
|
|
3905
|
+
* 3. **Planning**: Generating a new plan (Todo List) or refining an existing one based on the new query.
|
|
3906
|
+
* 4. **Execution**: Iterating through the Todo List, executing tasks, calling tools, and managing dependencies.
|
|
3907
|
+
* 5. **Synthesis**: Aggregating results to generate a final, coherent response for the user.
|
|
3908
|
+
* 6. **Finalization**: Saving the response and updating the conversation history.
|
|
3909
|
+
*
|
|
3910
|
+
* @param props - The input properties for the agent execution, including the user query, thread ID, and optional configuration overrides.
|
|
3911
|
+
* @returns A promise that resolves with the final agent response and detailed execution metadata.
|
|
3912
|
+
*/
|
|
3820
3913
|
process(props: AgentProps): Promise<AgentFinalResponse>;
|
|
3914
|
+
/**
|
|
3915
|
+
* Persists the current agent state to the StateManager.
|
|
3916
|
+
* @param threadId - The unique identifier of the thread.
|
|
3917
|
+
* @param pesState - The current state of the PES agent.
|
|
3918
|
+
*/
|
|
3821
3919
|
private _saveState;
|
|
3920
|
+
/**
|
|
3921
|
+
* Records observations related to the planning phase.
|
|
3922
|
+
* Emits events for INTENT, TITLE (if new), and PLAN.
|
|
3923
|
+
* @param threadId - The thread ID.
|
|
3924
|
+
* @param traceId - The trace ID for correlation.
|
|
3925
|
+
* @param planningOutput - The structured output from the planning LLM.
|
|
3926
|
+
* @param rawText - The raw text output from the LLM (for debugging/audit).
|
|
3927
|
+
*/
|
|
3822
3928
|
private _recordPlanObservations;
|
|
3929
|
+
/**
|
|
3930
|
+
* Executes the initial planning phase using the LLM.
|
|
3931
|
+
* Generates the initial Todo List based on the user's query and available tools.
|
|
3932
|
+
* @param props - Agent execution properties.
|
|
3933
|
+
* @param systemPrompt - The resolved system prompt for planning.
|
|
3934
|
+
* @param formattedHistory - The conversation history formatted for the LLM.
|
|
3935
|
+
* @param availableTools - List of tools available for the plan.
|
|
3936
|
+
* @param runtimeProviderConfig - Configuration for the LLM provider.
|
|
3937
|
+
* @param traceId - Trace ID for logging and observations.
|
|
3938
|
+
* @returns The structured planning output and metadata.
|
|
3939
|
+
*/
|
|
3823
3940
|
private _performPlanning;
|
|
3941
|
+
/**
|
|
3942
|
+
* Refines an existing plan based on new user input (follow-up).
|
|
3943
|
+
* Updates the Todo List to accommodate the new request while preserving context.
|
|
3944
|
+
* @param props - Agent execution properties.
|
|
3945
|
+
* @param systemPrompt - The resolved system prompt.
|
|
3946
|
+
* @param formattedHistory - Conversation history.
|
|
3947
|
+
* @param currentState - The current agent state (including the existing plan).
|
|
3948
|
+
* @param availableTools - Available tools.
|
|
3949
|
+
* @param runtimeProviderConfig - LLM provider config.
|
|
3950
|
+
* @param traceId - Trace ID.
|
|
3951
|
+
* @returns The updated planning output.
|
|
3952
|
+
*/
|
|
3824
3953
|
private _performPlanRefinement;
|
|
3954
|
+
/**
|
|
3955
|
+
* Common internal method to call the LLM for planning or refinement.
|
|
3956
|
+
* Handles streaming, observation recording, and output parsing.
|
|
3957
|
+
* @param prompt - The constructed prompt.
|
|
3958
|
+
* @param props - Agent properties.
|
|
3959
|
+
* @param runtimeProviderConfig - Provider config.
|
|
3960
|
+
* @param traceId - Trace ID.
|
|
3961
|
+
* @returns Parsed output and metadata.
|
|
3962
|
+
*/
|
|
3825
3963
|
private _callPlanningLLM;
|
|
3964
|
+
/**
|
|
3965
|
+
* Orchestrates the execution of the Todo List.
|
|
3966
|
+
* Loops through pending items, checks dependencies, and executes them.
|
|
3967
|
+
* @param props - Agent properties.
|
|
3968
|
+
* @param pesState - The current state containing the Todo List.
|
|
3969
|
+
* @param availableTools - Tools available for execution.
|
|
3970
|
+
* @param runtimeProviderConfig - Provider config.
|
|
3971
|
+
* @param traceId - Trace ID.
|
|
3972
|
+
* @returns Execution statistics (LLM calls, tool calls) and metadata.
|
|
3973
|
+
*/
|
|
3826
3974
|
private _executeTodoList;
|
|
3975
|
+
/**
|
|
3976
|
+
* Processes a single Todo Item.
|
|
3977
|
+
* This involves calling the LLM to execute the step, potentially using tools, and updating the plan if necessary.
|
|
3978
|
+
* @param props - Agent properties.
|
|
3979
|
+
* @param item - The Todo Item to execute.
|
|
3980
|
+
* @param state - Current agent state.
|
|
3981
|
+
* @param availableTools - Available tools.
|
|
3982
|
+
* @param runtimeProviderConfig - Provider config.
|
|
3983
|
+
* @param traceId - Trace ID.
|
|
3984
|
+
* @returns Result of the item execution (status, output, usage metrics).
|
|
3985
|
+
*/
|
|
3827
3986
|
private _processTodoItem;
|
|
3987
|
+
/**
|
|
3988
|
+
* Synthesizes the final response based on the completed tasks and the user's original query.
|
|
3989
|
+
* @param props - Agent properties.
|
|
3990
|
+
* @param systemPrompt - Synthesis system prompt.
|
|
3991
|
+
* @param formattedHistory - Conversation history.
|
|
3992
|
+
* @param state - Final agent state.
|
|
3993
|
+
* @param runtimeProviderConfig - Provider config.
|
|
3994
|
+
* @param traceId - Trace ID.
|
|
3995
|
+
* @param finalPersona - The persona to use for synthesis.
|
|
3996
|
+
* @returns The final response content and metadata.
|
|
3997
|
+
*/
|
|
3828
3998
|
private _performSynthesis;
|
|
3999
|
+
/**
|
|
4000
|
+
* Loads the initial configuration, thread context, and resolves prompts.
|
|
4001
|
+
* @param props - Agent properties.
|
|
4002
|
+
* @param traceId - Trace ID.
|
|
4003
|
+
* @returns Loaded configuration and context.
|
|
4004
|
+
* @throws {ARTError} If context or config is missing.
|
|
4005
|
+
*/
|
|
3829
4006
|
private _loadConfiguration;
|
|
4007
|
+
/**
|
|
4008
|
+
* Retrieves the conversation history for the thread.
|
|
4009
|
+
* @param threadId - The thread ID.
|
|
4010
|
+
* @param threadContext - The loaded thread context.
|
|
4011
|
+
* @returns Formatted conversation history.
|
|
4012
|
+
*/
|
|
3830
4013
|
private _gatherHistory;
|
|
4014
|
+
/**
|
|
4015
|
+
* Retrieves available tools for the thread.
|
|
4016
|
+
* @param threadId - The thread ID.
|
|
4017
|
+
* @returns Array of available tool schemas.
|
|
4018
|
+
*/
|
|
3831
4019
|
private _gatherTools;
|
|
4020
|
+
/**
|
|
4021
|
+
* Delegates tasks to other agents (Agent-to-Agent).
|
|
4022
|
+
* Discovers agents and sends task requests.
|
|
4023
|
+
* @param planningOutput - Output from the planning phase containing potential delegation calls.
|
|
4024
|
+
* @param threadId - Current thread ID.
|
|
4025
|
+
* @param traceId - Trace ID.
|
|
4026
|
+
* @returns Array of created A2A tasks.
|
|
4027
|
+
*/
|
|
3832
4028
|
private _delegateA2ATasks;
|
|
4029
|
+
/**
|
|
4030
|
+
* Waits for delegated A2A tasks to complete.
|
|
4031
|
+
* Polls the repository until all tasks are in a terminal state or timeout is reached.
|
|
4032
|
+
* @param a2aTasks - The tasks to wait for.
|
|
4033
|
+
* @param threadId - Thread ID.
|
|
4034
|
+
* @param traceId - Trace ID.
|
|
4035
|
+
* @param maxWaitTimeMs - Maximum time to wait in milliseconds.
|
|
4036
|
+
* @param pollIntervalMs - Polling interval.
|
|
4037
|
+
* @returns The updated list of tasks.
|
|
4038
|
+
*/
|
|
3833
4039
|
private _waitForA2ACompletion;
|
|
4040
|
+
/**
|
|
4041
|
+
* Finalizes the agent execution by saving the AI response and recording the final observation.
|
|
4042
|
+
* @param props - Agent properties.
|
|
4043
|
+
* @param finalResponseContent - The content of the final AI message.
|
|
4044
|
+
* @param traceId - Trace ID.
|
|
4045
|
+
* @param uiMetadata - Optional UI metadata extracted from the response.
|
|
4046
|
+
* @returns The created ConversationMessage object.
|
|
4047
|
+
*/
|
|
3834
4048
|
private _finalize;
|
|
4049
|
+
/**
|
|
4050
|
+
* Helper to format internal conversation messages into the standard prompt format required by the LLM.
|
|
4051
|
+
* @param history - Array of ConversationMessages.
|
|
4052
|
+
* @returns Array of formatted prompt messages.
|
|
4053
|
+
*/
|
|
3835
4054
|
private formatHistoryForPrompt;
|
|
3836
4055
|
}
|
|
3837
4056
|
|
|
@@ -4144,7 +4363,7 @@ declare class SupabaseStorageAdapter implements StorageAdapter {
|
|
|
4144
4363
|
interface GeminiAdapterOptions {
|
|
4145
4364
|
/** Your Google AI API key (e.g., from Google AI Studio). Handle securely. */
|
|
4146
4365
|
apiKey: string;
|
|
4147
|
-
/** The default Gemini model ID to use (e.g., 'gemini-
|
|
4366
|
+
/** The default Gemini model ID to use (e.g., 'gemini-3-flash', 'gemini-pro'). Defaults to 'gemini-3-flash' if not provided. */
|
|
4148
4367
|
model?: string;
|
|
4149
4368
|
/** Optional: Override the base URL for the Google Generative AI API. */
|
|
4150
4369
|
apiBaseUrl?: string;
|
|
@@ -4172,10 +4391,11 @@ declare class GeminiAdapter implements ProviderAdapter {
|
|
|
4172
4391
|
* Handles both streaming and non-streaming requests based on `options.stream`.
|
|
4173
4392
|
*
|
|
4174
4393
|
* Thinking tokens (Gemini):
|
|
4175
|
-
* - On supported Gemini models (e.g., `gemini-
|
|
4394
|
+
* - On supported Gemini models (e.g., `gemini-3-*`), you can enable thought output via `config.thinkingConfig`.
|
|
4176
4395
|
* - This adapter reads provider-specific flags from the call options:
|
|
4177
4396
|
* - `options.gemini.thinking.includeThoughts: boolean` — when `true`, requests thought (reasoning) output.
|
|
4178
4397
|
* - `options.gemini.thinking.thinkingBudget?: number` — optional token budget for thinking.
|
|
4398
|
+
* - `options.gemini.thinking.thinkingLevel?: 'low' | 'minimal' | 'medium' | 'high'` — optional thinking level (Gemini 3+).
|
|
4179
4399
|
* - When enabled and supported, the adapter will attempt to differentiate thought vs response parts and set
|
|
4180
4400
|
* `StreamEvent.tokenType` accordingly:
|
|
4181
4401
|
* - For planning calls (`callContext === 'AGENT_THOUGHT'`): `AGENT_THOUGHT_LLM_THINKING` or `AGENT_THOUGHT_LLM_RESPONSE`.
|
|
@@ -4217,22 +4437,20 @@ declare class GeminiAdapter implements ProviderAdapter {
|
|
|
4217
4437
|
*/
|
|
4218
4438
|
call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
|
|
4219
4439
|
/**
|
|
4220
|
-
* Translates the provider-agnostic `ArtStandardPrompt` into the Gemini API's `Content[]` format
|
|
4440
|
+
* Translates the provider-agnostic `ArtStandardPrompt` into the Gemini API's `Content[]` format
|
|
4441
|
+
* and extracts any system instructions.
|
|
4221
4442
|
*
|
|
4222
4443
|
* Key translations:
|
|
4223
|
-
* - `system` role:
|
|
4444
|
+
* - `system` role: Extracted to `systemInstruction`.
|
|
4224
4445
|
* - `user` role: Maps to Gemini's `user` role.
|
|
4225
4446
|
* - `assistant` role: Maps to Gemini's `model` role. Handles text content and `tool_calls` (mapped to `functionCall`).
|
|
4226
4447
|
* - `tool_result` role: Maps to Gemini's `user` role with a `functionResponse` part.
|
|
4227
4448
|
* - `tool_request` role: Skipped (implicitly handled by `assistant`'s `tool_calls`).
|
|
4228
4449
|
*
|
|
4229
|
-
* Adds validation to ensure the conversation doesn't start with a 'model' role.
|
|
4230
|
-
*
|
|
4231
4450
|
* @private
|
|
4232
4451
|
* @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
|
|
4233
|
-
* @returns {
|
|
4234
|
-
* @throws {ARTError} If translation encounters an issue
|
|
4235
|
-
* @see https://ai.google.dev/api/rest/v1beta/Content
|
|
4452
|
+
* @returns {{ contents: Content[], systemInstruction?: string }} The Gemini formatted payload.
|
|
4453
|
+
* @throws {ARTError} If translation encounters an issue.
|
|
4236
4454
|
*/
|
|
4237
4455
|
private translateToGemini;
|
|
4238
4456
|
}
|
|
@@ -4243,7 +4461,7 @@ declare class GeminiAdapter implements ProviderAdapter {
|
|
|
4243
4461
|
interface OpenAIAdapterOptions {
|
|
4244
4462
|
/** Your OpenAI API key. Handle securely. */
|
|
4245
4463
|
apiKey: string;
|
|
4246
|
-
/** The default OpenAI model ID to use (e.g., 'gpt-
|
|
4464
|
+
/** The default OpenAI model ID to use (e.g., 'gpt-5.2-instant', 'gpt-5.2-thinking', 'gpt-5.2-pro'). */
|
|
4247
4465
|
model?: string;
|
|
4248
4466
|
/** Optional: Override the base URL for the OpenAI API (e.g., for Azure OpenAI or custom proxies). */
|
|
4249
4467
|
apiBaseUrl?: string;
|
|
@@ -4322,7 +4540,7 @@ declare class OpenAIAdapter implements ProviderAdapter {
|
|
|
4322
4540
|
interface AnthropicAdapterOptions {
|
|
4323
4541
|
/** Your Anthropic API key. Handle securely. */
|
|
4324
4542
|
apiKey: string;
|
|
4325
|
-
/** The default Anthropic model ID to use (e.g., '
|
|
4543
|
+
/** The default Anthropic model ID to use (e.g., 'claude_4.5_sonnet', 'claude_4.5_opus'). */
|
|
4326
4544
|
model?: string;
|
|
4327
4545
|
/** Optional: Override the base URL for the Anthropic API. */
|
|
4328
4546
|
apiBaseUrl?: string;
|
|
@@ -5011,7 +5229,17 @@ declare class McpProxyTool implements IToolExecutor {
|
|
|
5011
5229
|
|
|
5012
5230
|
/**
|
|
5013
5231
|
* Manages thread-specific configuration (ThreadConfig) and state (AgentState)
|
|
5014
|
-
* using an underlying StateRepository.
|
|
5232
|
+
* using an underlying StateRepository.
|
|
5233
|
+
*
|
|
5234
|
+
* This class serves as the central point for accessing and modifying the persistent context
|
|
5235
|
+
* of a conversation thread. It supports two state saving strategies:
|
|
5236
|
+
*
|
|
5237
|
+
* 1. **Explicit**: The agent is responsible for calling `setAgentState()` whenever it wants to persist changes.
|
|
5238
|
+
* `saveStateIfModified()` is a no-op. This gives fine-grained control but requires discipline.
|
|
5239
|
+
*
|
|
5240
|
+
* 2. **Implicit**: State is loaded via `loadThreadContext()` and cached. The agent modifies the state object in-memory.
|
|
5241
|
+
* Calls to `saveStateIfModified()` (typically at the end of an execution cycle) compare the current state
|
|
5242
|
+
* against the initial snapshot and persist only if changes are detected. This simplifies agent logic.
|
|
5015
5243
|
*/
|
|
5016
5244
|
declare class StateManager implements StateManager$1 {
|
|
5017
5245
|
private repository;
|
|
@@ -5025,8 +5253,12 @@ declare class StateManager implements StateManager$1 {
|
|
|
5025
5253
|
constructor(stateRepository: IStateRepository, strategy?: StateSavingStrategy);
|
|
5026
5254
|
/**
|
|
5027
5255
|
* Loads the complete context (`ThreadConfig` and `AgentState`) for a specific thread.
|
|
5028
|
-
*
|
|
5029
|
-
*
|
|
5256
|
+
*
|
|
5257
|
+
* - In **Implicit** mode: Caches the loaded context and creates a snapshot of the `AgentState`.
|
|
5258
|
+
* This snapshot is used later by `saveStateIfModified` to detect changes. Subsequent loads
|
|
5259
|
+
* within the same lifecycle might return the cached object to maintain reference consistency.
|
|
5260
|
+
* - In **Explicit** mode: Simply fetches data from the repository.
|
|
5261
|
+
*
|
|
5030
5262
|
* @param {string} threadId - The unique identifier for the thread.
|
|
5031
5263
|
* @param {string} [_userId] - Optional user identifier (currently unused).
|
|
5032
5264
|
* @returns {Promise<ThreadContext>} A promise resolving to the `ThreadContext` object.
|
|
@@ -5052,11 +5284,13 @@ declare class StateManager implements StateManager$1 {
|
|
|
5052
5284
|
getThreadConfigValue<T>(threadId: string, key: string): Promise<T | undefined>;
|
|
5053
5285
|
/**
|
|
5054
5286
|
* Persists the thread's `AgentState` if it has been modified.
|
|
5287
|
+
*
|
|
5055
5288
|
* Behavior depends on the `stateSavingStrategy`:
|
|
5056
|
-
* - 'explicit'
|
|
5057
|
-
* - 'implicit'
|
|
5058
|
-
*
|
|
5059
|
-
*
|
|
5289
|
+
* - **'explicit'**: This method is a no-op for `AgentState` persistence and logs a warning. State must be saved manually via `setAgentState`.
|
|
5290
|
+
* - **'implicit'**: Compares the current `AgentState` (from the cached `ThreadContext` modified by the agent)
|
|
5291
|
+
* with the snapshot taken during `loadThreadContext`. If different, saves the state
|
|
5292
|
+
* to the repository and updates the snapshot.
|
|
5293
|
+
*
|
|
5060
5294
|
* @param {string} threadId - The ID of the thread whose state might need saving.
|
|
5061
5295
|
* @returns {Promise<void>} A promise that resolves when the state is saved or the operation is skipped.
|
|
5062
5296
|
*/
|
|
@@ -5071,8 +5305,10 @@ declare class StateManager implements StateManager$1 {
|
|
|
5071
5305
|
setThreadConfig(threadId: string, config: ThreadConfig): Promise<void>;
|
|
5072
5306
|
/**
|
|
5073
5307
|
* Explicitly sets or updates the AgentState for a specific thread by calling the underlying state repository.
|
|
5074
|
-
*
|
|
5075
|
-
*
|
|
5308
|
+
*
|
|
5309
|
+
* - If in **Implicit** mode: This also updates the cached snapshot to prevent `saveStateIfModified`
|
|
5310
|
+
* from re-saving the same state immediately (optimizing writes).
|
|
5311
|
+
*
|
|
5076
5312
|
* @param {string} threadId - The unique identifier of the thread.
|
|
5077
5313
|
* @param {AgentState} state - The AgentState object to save. Must not be undefined or null.
|
|
5078
5314
|
* @returns {Promise<void>} A promise that resolves when the state is saved.
|
|
@@ -5265,6 +5501,6 @@ declare const generateUUID: () => string;
|
|
|
5265
5501
|
/**
|
|
5266
5502
|
* The current version of the ART Framework package.
|
|
5267
5503
|
*/
|
|
5268
|
-
declare const VERSION = "0.
|
|
5504
|
+
declare const VERSION = "0.4.1";
|
|
5269
5505
|
|
|
5270
5506
|
export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, AgentFactory, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type ExecutionOutput, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PESAgentStateData, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, type TodoItem, TodoItemStatus, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };
|