art-framework 0.4.2 → 0.4.4
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 +4 -3
- package/dist/index.cjs +43 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -290
- package/dist/index.d.ts +54 -290
- package/dist/index.js +43 -26
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1013,88 +1013,41 @@ 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.).
|
|
1017
1016
|
*
|
|
1018
1017
|
* @enum {string}
|
|
1019
1018
|
*/
|
|
1020
1019
|
declare enum ObservationType {
|
|
1021
|
-
/**
|
|
1022
|
-
* The user's inferred intent.
|
|
1023
|
-
* Generated during the planning phase to signal understanding of the user's goal.
|
|
1024
|
-
*/
|
|
1020
|
+
/** The user's inferred intent. */
|
|
1025
1021
|
INTENT = "INTENT",
|
|
1026
|
-
/**
|
|
1027
|
-
* The generated concise thread title.
|
|
1028
|
-
* Usually generated once at the start of a new conversation.
|
|
1029
|
-
*/
|
|
1022
|
+
/** The generated concise thread title. */
|
|
1030
1023
|
TITLE = "TITLE",
|
|
1031
|
-
/**
|
|
1032
|
-
* The agent's step-by-step plan to address the intent.
|
|
1033
|
-
* Contains the initial or updated TodoList.
|
|
1034
|
-
*/
|
|
1024
|
+
/** The agent's step-by-step plan to address the intent. */
|
|
1035
1025
|
PLAN = "PLAN",
|
|
1036
|
-
/**
|
|
1037
|
-
* The agent's internal monologue or reasoning process.
|
|
1038
|
-
* Often captures the 'thinking' blocks from reasoning models.
|
|
1039
|
-
*/
|
|
1026
|
+
/** The agent's internal monologue or reasoning process. */
|
|
1040
1027
|
THOUGHTS = "THOUGHTS",
|
|
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
|
-
*/
|
|
1028
|
+
/** Records the LLM's decision to call one or more tools (part of the plan). */
|
|
1045
1029
|
TOOL_CALL = "TOOL_CALL",
|
|
1046
|
-
/**
|
|
1047
|
-
* Records the actual execution attempt and result of a specific tool call.
|
|
1048
|
-
* Contains the result payload or error message.
|
|
1049
|
-
*/
|
|
1030
|
+
/** Records the actual execution attempt and result of a specific tool call. */
|
|
1050
1031
|
TOOL_EXECUTION = "TOOL_EXECUTION",
|
|
1051
|
-
/**
|
|
1052
|
-
* Records events specifically related to the synthesis phase (e.g., the LLM call).
|
|
1053
|
-
*/
|
|
1032
|
+
/** Records events specifically related to the synthesis phase (e.g., the LLM call). */
|
|
1054
1033
|
SYNTHESIS = "SYNTHESIS",
|
|
1055
|
-
/**
|
|
1056
|
-
* Records an error encountered during any phase of execution.
|
|
1057
|
-
* Contains error details and stack traces.
|
|
1058
|
-
*/
|
|
1034
|
+
/** Records an error encountered during any phase of execution. */
|
|
1059
1035
|
ERROR = "ERROR",
|
|
1060
|
-
/**
|
|
1061
|
-
* Records the final AI response message generated by the agent.
|
|
1062
|
-
* This signals the completion of a turn.
|
|
1063
|
-
*/
|
|
1036
|
+
/** Records the final AI response message generated by the agent. */
|
|
1064
1037
|
FINAL_RESPONSE = "FINAL_RESPONSE",
|
|
1065
|
-
/**
|
|
1066
|
-
* Records changes made to the agent's persistent state.
|
|
1067
|
-
* Useful for debugging state transitions.
|
|
1068
|
-
*/
|
|
1038
|
+
/** Records changes made to the agent's persistent state. */
|
|
1069
1039
|
STATE_UPDATE = "STATE_UPDATE",
|
|
1070
|
-
/**
|
|
1071
|
-
* Records updates to the plan structure (intent, title, or list changes).
|
|
1072
|
-
* Triggered when the agent refines its plan during execution.
|
|
1073
|
-
*/
|
|
1040
|
+
/** Records updates to the plan structure (intent, title, or list changes). */
|
|
1074
1041
|
PLAN_UPDATE = "PLAN_UPDATE",
|
|
1075
|
-
/**
|
|
1076
|
-
* Records status changes of a specific todo item (e.g., PENDING -> IN_PROGRESS -> COMPLETED).
|
|
1077
|
-
*/
|
|
1042
|
+
/** Records status changes of a specific todo item. */
|
|
1078
1043
|
ITEM_STATUS_CHANGE = "ITEM_STATUS_CHANGE",
|
|
1079
|
-
/**
|
|
1080
|
-
* Logged by Agent Core when LLM stream consumption begins.
|
|
1081
|
-
* Signals the UI to prepare for incoming tokens.
|
|
1082
|
-
*/
|
|
1044
|
+
/** Logged by Agent Core when LLM stream consumption begins. */
|
|
1083
1045
|
LLM_STREAM_START = "LLM_STREAM_START",
|
|
1084
|
-
/**
|
|
1085
|
-
* Logged by Agent Core upon receiving a METADATA stream event.
|
|
1086
|
-
* Content contains LLMMetadata (token counts, latency).
|
|
1087
|
-
*/
|
|
1046
|
+
/** Logged by Agent Core upon receiving a METADATA stream event. Content should be LLMMetadata. */
|
|
1088
1047
|
LLM_STREAM_METADATA = "LLM_STREAM_METADATA",
|
|
1089
|
-
/**
|
|
1090
|
-
* Logged by Agent Core upon receiving an END stream event.
|
|
1091
|
-
* Signals the end of a streaming response.
|
|
1092
|
-
*/
|
|
1048
|
+
/** Logged by Agent Core upon receiving an END stream event. */
|
|
1093
1049
|
LLM_STREAM_END = "LLM_STREAM_END",
|
|
1094
|
-
/**
|
|
1095
|
-
* Logged by Agent Core upon receiving an ERROR stream event.
|
|
1096
|
-
* Content contains the Error object or message.
|
|
1097
|
-
*/
|
|
1050
|
+
/** Logged by Agent Core upon receiving an ERROR stream event. Content should be Error object or message. */
|
|
1098
1051
|
LLM_STREAM_ERROR = "LLM_STREAM_ERROR"
|
|
1099
1052
|
}
|
|
1100
1053
|
/**
|
|
@@ -1121,7 +1074,6 @@ declare enum ModelCapability {
|
|
|
1121
1074
|
}
|
|
1122
1075
|
/**
|
|
1123
1076
|
* Represents a recorded event during the agent's execution.
|
|
1124
|
-
* Observations provide a granular log of the agent's internal state, decisions, and interactions.
|
|
1125
1077
|
*
|
|
1126
1078
|
* @interface Observation
|
|
1127
1079
|
*/
|
|
@@ -1241,7 +1193,7 @@ interface StreamEvent {
|
|
|
1241
1193
|
*/
|
|
1242
1194
|
traceId: string;
|
|
1243
1195
|
/**
|
|
1244
|
-
* Optional identifier linking the event to a specific UI
|
|
1196
|
+
* Optional identifier linking the event to a specific UI tab/window.
|
|
1245
1197
|
* @property {string} [sessionId]
|
|
1246
1198
|
*/
|
|
1247
1199
|
sessionId?: string;
|
|
@@ -1514,32 +1466,27 @@ interface ParsedToolCall {
|
|
|
1514
1466
|
}
|
|
1515
1467
|
/**
|
|
1516
1468
|
* Configuration specific to a conversation thread.
|
|
1517
|
-
* Controls behavior, tools, and provider settings for a particular interaction context.
|
|
1518
1469
|
*
|
|
1519
1470
|
* @interface ThreadConfig
|
|
1520
1471
|
*/
|
|
1521
1472
|
interface ThreadConfig {
|
|
1522
1473
|
/**
|
|
1523
1474
|
* Default provider configuration for this thread.
|
|
1524
|
-
* Determines which LLM and model will be used for reasoning.
|
|
1525
1475
|
* @property {RuntimeProviderConfig} providerConfig
|
|
1526
1476
|
*/
|
|
1527
1477
|
providerConfig: RuntimeProviderConfig;
|
|
1528
1478
|
/**
|
|
1529
1479
|
* An array of tool names (matching `ToolSchema.name`) that are permitted for use within this thread.
|
|
1530
|
-
* Allows for scoping capabilities per conversation.
|
|
1531
1480
|
* @property {string[]} enabledTools
|
|
1532
1481
|
*/
|
|
1533
1482
|
enabledTools: string[];
|
|
1534
1483
|
/**
|
|
1535
1484
|
* The maximum number of past messages (`ConversationMessage` objects) to retrieve for context.
|
|
1536
|
-
* Helps manage context window limits.
|
|
1537
1485
|
* @property {number} historyLimit
|
|
1538
1486
|
*/
|
|
1539
1487
|
historyLimit: number;
|
|
1540
1488
|
/**
|
|
1541
1489
|
* Optional system prompt override to be used for this thread, overriding instance or agent defaults.
|
|
1542
|
-
* Allows for thread-specific role instructions.
|
|
1543
1490
|
* @property {string | SystemPromptOverride} [systemPrompt]
|
|
1544
1491
|
*/
|
|
1545
1492
|
systemPrompt?: string | SystemPromptOverride;
|
|
@@ -1552,15 +1499,13 @@ interface ThreadConfig {
|
|
|
1552
1499
|
}
|
|
1553
1500
|
/**
|
|
1554
1501
|
* Represents non-configuration state associated with an agent or thread.
|
|
1555
|
-
*
|
|
1556
|
-
* variables, and other dynamic data across execution cycles.
|
|
1502
|
+
* Could include user preferences, accumulated knowledge, etc. (Less defined for v1.0)
|
|
1557
1503
|
*
|
|
1558
1504
|
* @interface AgentState
|
|
1559
1505
|
*/
|
|
1560
1506
|
interface AgentState {
|
|
1561
1507
|
/**
|
|
1562
|
-
* The primary data payload of the agent's state.
|
|
1563
|
-
* Structure is application-defined but typically includes the current plan, todo list, etc.
|
|
1508
|
+
* The primary data payload of the agent's state. Structure is application-defined.
|
|
1564
1509
|
* @property {any} data
|
|
1565
1510
|
*/
|
|
1566
1511
|
data: any;
|
|
@@ -1576,8 +1521,7 @@ interface AgentState {
|
|
|
1576
1521
|
[key: string]: any;
|
|
1577
1522
|
}
|
|
1578
1523
|
/**
|
|
1579
|
-
* Encapsulates the
|
|
1580
|
-
* This object represents the full snapshot of a thread's environment.
|
|
1524
|
+
* Encapsulates the configuration and state for a specific thread.
|
|
1581
1525
|
*
|
|
1582
1526
|
* @interface ThreadContext
|
|
1583
1527
|
*/
|
|
@@ -1594,7 +1538,7 @@ interface ThreadContext {
|
|
|
1594
1538
|
state: AgentState | null;
|
|
1595
1539
|
}
|
|
1596
1540
|
/**
|
|
1597
|
-
* Properties required to initiate an agent processing cycle
|
|
1541
|
+
* Properties required to initiate an agent processing cycle.
|
|
1598
1542
|
*
|
|
1599
1543
|
* @interface AgentProps
|
|
1600
1544
|
*/
|
|
@@ -1610,7 +1554,7 @@ interface AgentProps {
|
|
|
1610
1554
|
*/
|
|
1611
1555
|
threadId: string;
|
|
1612
1556
|
/**
|
|
1613
|
-
* An optional identifier for the specific UI session, useful for targeting UI updates
|
|
1557
|
+
* An optional identifier for the specific UI session, useful for targeting UI updates.
|
|
1614
1558
|
* @property {string} [sessionId]
|
|
1615
1559
|
*/
|
|
1616
1560
|
sessionId?: string;
|
|
@@ -1631,7 +1575,7 @@ interface AgentProps {
|
|
|
1631
1575
|
options?: AgentOptions;
|
|
1632
1576
|
}
|
|
1633
1577
|
/**
|
|
1634
|
-
* Options to override agent behavior at runtime
|
|
1578
|
+
* Options to override agent behavior at runtime.
|
|
1635
1579
|
*
|
|
1636
1580
|
* @interface AgentOptions
|
|
1637
1581
|
*/
|
|
@@ -2739,46 +2683,24 @@ declare class A2ATaskSocket extends TypedSocket<A2ATaskEvent, A2ATaskFilter> {
|
|
|
2739
2683
|
}
|
|
2740
2684
|
|
|
2741
2685
|
/**
|
|
2742
|
-
* A specialized
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
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`.
|
|
2686
|
+
* A specialized TypedSocket for handling Observation data.
|
|
2687
|
+
* Allows filtering by ObservationType.
|
|
2688
|
+
* Can optionally fetch historical observations from a repository.
|
|
2752
2689
|
*/
|
|
2753
2690
|
declare class ObservationSocket extends TypedSocket<Observation, ObservationType | ObservationType[]> {
|
|
2754
2691
|
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
|
-
*/
|
|
2759
2692
|
constructor(observationRepository?: IObservationRepository);
|
|
2760
2693
|
/**
|
|
2761
|
-
* Notifies
|
|
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.
|
|
2694
|
+
* Notifies subscribers about a new observation.
|
|
2695
|
+
* @param observation - The observation data.
|
|
2770
2696
|
*/
|
|
2771
2697
|
notifyObservation(observation: Observation): void;
|
|
2772
2698
|
/**
|
|
2773
|
-
* Retrieves historical observations
|
|
2774
|
-
*
|
|
2775
|
-
* @
|
|
2776
|
-
*
|
|
2777
|
-
*
|
|
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.
|
|
2699
|
+
* Retrieves historical observations, optionally filtered by type and thread.
|
|
2700
|
+
* Requires an ObservationRepository to be configured.
|
|
2701
|
+
* @param filter - Optional ObservationType or array of types to filter by.
|
|
2702
|
+
* @param options - Optional threadId and limit.
|
|
2703
|
+
* @returns A promise resolving to an array of observations.
|
|
2782
2704
|
*/
|
|
2783
2705
|
getHistory(filter?: ObservationType | ObservationType[], options?: {
|
|
2784
2706
|
threadId?: string;
|
|
@@ -3895,162 +3817,21 @@ declare class PESAgent implements IAgentCore {
|
|
|
3895
3817
|
private readonly deps;
|
|
3896
3818
|
private readonly persona;
|
|
3897
3819
|
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
|
-
*/
|
|
3913
3820
|
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
|
-
*/
|
|
3919
3821
|
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
|
-
*/
|
|
3928
3822
|
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
|
-
*/
|
|
3940
3823
|
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
|
-
*/
|
|
3953
3824
|
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
|
-
*/
|
|
3963
3825
|
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
|
-
*/
|
|
3974
3826
|
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
|
-
*/
|
|
3986
3827
|
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
|
-
*/
|
|
3998
3828
|
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
|
-
*/
|
|
4006
3829
|
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
|
-
*/
|
|
4013
3830
|
private _gatherHistory;
|
|
4014
|
-
/**
|
|
4015
|
-
* Retrieves available tools for the thread.
|
|
4016
|
-
* @param threadId - The thread ID.
|
|
4017
|
-
* @returns Array of available tool schemas.
|
|
4018
|
-
*/
|
|
4019
3831
|
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
|
-
*/
|
|
4028
3832
|
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
|
-
*/
|
|
4039
3833
|
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
|
-
*/
|
|
4048
3834
|
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
|
-
*/
|
|
4054
3835
|
private formatHistoryForPrompt;
|
|
4055
3836
|
}
|
|
4056
3837
|
|
|
@@ -4363,7 +4144,7 @@ declare class SupabaseStorageAdapter implements StorageAdapter {
|
|
|
4363
4144
|
interface GeminiAdapterOptions {
|
|
4364
4145
|
/** Your Google AI API key (e.g., from Google AI Studio). Handle securely. */
|
|
4365
4146
|
apiKey: string;
|
|
4366
|
-
/** The default Gemini model ID to use (e.g., 'gemini-
|
|
4147
|
+
/** The default Gemini model ID to use (e.g., 'gemini-2.5-flash', 'gemini-pro'). Defaults to 'gemini-2.5-flash' if not provided. */
|
|
4367
4148
|
model?: string;
|
|
4368
4149
|
/** Optional: Override the base URL for the Google Generative AI API. */
|
|
4369
4150
|
apiBaseUrl?: string;
|
|
@@ -4391,11 +4172,10 @@ declare class GeminiAdapter implements ProviderAdapter {
|
|
|
4391
4172
|
* Handles both streaming and non-streaming requests based on `options.stream`.
|
|
4392
4173
|
*
|
|
4393
4174
|
* Thinking tokens (Gemini):
|
|
4394
|
-
* - On supported Gemini models (e.g., `gemini-
|
|
4175
|
+
* - On supported Gemini models (e.g., `gemini-2.5-*`), you can enable thought output via `config.thinkingConfig`.
|
|
4395
4176
|
* - This adapter reads provider-specific flags from the call options:
|
|
4396
4177
|
* - `options.gemini.thinking.includeThoughts: boolean` — when `true`, requests thought (reasoning) output.
|
|
4397
4178
|
* - `options.gemini.thinking.thinkingBudget?: number` — optional token budget for thinking.
|
|
4398
|
-
* - `options.gemini.thinking.thinkingLevel?: 'low' | 'minimal' | 'medium' | 'high'` — optional thinking level (Gemini 3+).
|
|
4399
4179
|
* - When enabled and supported, the adapter will attempt to differentiate thought vs response parts and set
|
|
4400
4180
|
* `StreamEvent.tokenType` accordingly:
|
|
4401
4181
|
* - For planning calls (`callContext === 'AGENT_THOUGHT'`): `AGENT_THOUGHT_LLM_THINKING` or `AGENT_THOUGHT_LLM_RESPONSE`.
|
|
@@ -4437,20 +4217,22 @@ declare class GeminiAdapter implements ProviderAdapter {
|
|
|
4437
4217
|
*/
|
|
4438
4218
|
call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
|
|
4439
4219
|
/**
|
|
4440
|
-
* Translates the provider-agnostic `ArtStandardPrompt` into the Gemini API's `Content[]` format
|
|
4441
|
-
* and extracts any system instructions.
|
|
4220
|
+
* Translates the provider-agnostic `ArtStandardPrompt` into the Gemini API's `Content[]` format.
|
|
4442
4221
|
*
|
|
4443
4222
|
* Key translations:
|
|
4444
|
-
* - `system` role:
|
|
4223
|
+
* - `system` role: Merged into the first `user` message.
|
|
4445
4224
|
* - `user` role: Maps to Gemini's `user` role.
|
|
4446
4225
|
* - `assistant` role: Maps to Gemini's `model` role. Handles text content and `tool_calls` (mapped to `functionCall`).
|
|
4447
4226
|
* - `tool_result` role: Maps to Gemini's `user` role with a `functionResponse` part.
|
|
4448
4227
|
* - `tool_request` role: Skipped (implicitly handled by `assistant`'s `tool_calls`).
|
|
4449
4228
|
*
|
|
4229
|
+
* Adds validation to ensure the conversation doesn't start with a 'model' role.
|
|
4230
|
+
*
|
|
4450
4231
|
* @private
|
|
4451
4232
|
* @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
|
|
4452
|
-
* @returns {
|
|
4453
|
-
* @throws {ARTError} If translation encounters an issue.
|
|
4233
|
+
* @returns {Content[]} The `Content[]` array formatted for the Gemini API.
|
|
4234
|
+
* @throws {ARTError} If translation encounters an issue, such as a `tool_result` missing required fields (ErrorCode.PROMPT_TRANSLATION_FAILED).
|
|
4235
|
+
* @see https://ai.google.dev/api/rest/v1beta/Content
|
|
4454
4236
|
*/
|
|
4455
4237
|
private translateToGemini;
|
|
4456
4238
|
}
|
|
@@ -4461,7 +4243,7 @@ declare class GeminiAdapter implements ProviderAdapter {
|
|
|
4461
4243
|
interface OpenAIAdapterOptions {
|
|
4462
4244
|
/** Your OpenAI API key. Handle securely. */
|
|
4463
4245
|
apiKey: string;
|
|
4464
|
-
/** The default OpenAI model ID to use (e.g., 'gpt-
|
|
4246
|
+
/** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-5', 'gpt-5-mini'). */
|
|
4465
4247
|
model?: string;
|
|
4466
4248
|
/** Optional: Override the base URL for the OpenAI API (e.g., for Azure OpenAI or custom proxies). */
|
|
4467
4249
|
apiBaseUrl?: string;
|
|
@@ -4540,7 +4322,7 @@ declare class OpenAIAdapter implements ProviderAdapter {
|
|
|
4540
4322
|
interface AnthropicAdapterOptions {
|
|
4541
4323
|
/** Your Anthropic API key. Handle securely. */
|
|
4542
4324
|
apiKey: string;
|
|
4543
|
-
/** The default Anthropic model ID to use (e.g., '
|
|
4325
|
+
/** The default Anthropic model ID to use (e.g., 'claude-3-opus-20240229', 'claude-3-5-sonnet-20240620'). */
|
|
4544
4326
|
model?: string;
|
|
4545
4327
|
/** Optional: Override the base URL for the Anthropic API. */
|
|
4546
4328
|
apiBaseUrl?: string;
|
|
@@ -5229,17 +5011,7 @@ declare class McpProxyTool implements IToolExecutor {
|
|
|
5229
5011
|
|
|
5230
5012
|
/**
|
|
5231
5013
|
* Manages thread-specific configuration (ThreadConfig) and state (AgentState)
|
|
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.
|
|
5014
|
+
* using an underlying StateRepository. Supports explicit and implicit state saving strategies.
|
|
5243
5015
|
*/
|
|
5244
5016
|
declare class StateManager implements StateManager$1 {
|
|
5245
5017
|
private repository;
|
|
@@ -5253,12 +5025,8 @@ declare class StateManager implements StateManager$1 {
|
|
|
5253
5025
|
constructor(stateRepository: IStateRepository, strategy?: StateSavingStrategy);
|
|
5254
5026
|
/**
|
|
5255
5027
|
* Loads the complete context (`ThreadConfig` and `AgentState`) for a specific thread.
|
|
5256
|
-
*
|
|
5257
|
-
*
|
|
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
|
-
*
|
|
5028
|
+
* If in 'implicit' state saving strategy, it caches the loaded context and a snapshot
|
|
5029
|
+
* of its AgentState for later comparison in `saveStateIfModified`.
|
|
5262
5030
|
* @param {string} threadId - The unique identifier for the thread.
|
|
5263
5031
|
* @param {string} [_userId] - Optional user identifier (currently unused).
|
|
5264
5032
|
* @returns {Promise<ThreadContext>} A promise resolving to the `ThreadContext` object.
|
|
@@ -5284,13 +5052,11 @@ declare class StateManager implements StateManager$1 {
|
|
|
5284
5052
|
getThreadConfigValue<T>(threadId: string, key: string): Promise<T | undefined>;
|
|
5285
5053
|
/**
|
|
5286
5054
|
* Persists the thread's `AgentState` if it has been modified.
|
|
5287
|
-
*
|
|
5288
5055
|
* Behavior depends on the `stateSavingStrategy`:
|
|
5289
|
-
* -
|
|
5290
|
-
* -
|
|
5291
|
-
*
|
|
5292
|
-
*
|
|
5293
|
-
*
|
|
5056
|
+
* - 'explicit': This method is a no-op for `AgentState` persistence and logs a warning.
|
|
5057
|
+
* - 'implicit': Compares the current `AgentState` (from the cached `ThreadContext` modified by the agent)
|
|
5058
|
+
* with the snapshot taken during `loadThreadContext`. If different, saves the state
|
|
5059
|
+
* to the repository and updates the snapshot.
|
|
5294
5060
|
* @param {string} threadId - The ID of the thread whose state might need saving.
|
|
5295
5061
|
* @returns {Promise<void>} A promise that resolves when the state is saved or the operation is skipped.
|
|
5296
5062
|
*/
|
|
@@ -5305,10 +5071,8 @@ declare class StateManager implements StateManager$1 {
|
|
|
5305
5071
|
setThreadConfig(threadId: string, config: ThreadConfig): Promise<void>;
|
|
5306
5072
|
/**
|
|
5307
5073
|
* Explicitly sets or updates the AgentState for a specific thread by calling the underlying state repository.
|
|
5308
|
-
*
|
|
5309
|
-
* -
|
|
5310
|
-
* from re-saving the same state immediately (optimizing writes).
|
|
5311
|
-
*
|
|
5074
|
+
* If in 'implicit' mode, this also updates the cached snapshot to prevent `saveStateIfModified`
|
|
5075
|
+
* from re-saving the same state immediately.
|
|
5312
5076
|
* @param {string} threadId - The unique identifier of the thread.
|
|
5313
5077
|
* @param {AgentState} state - The AgentState object to save. Must not be undefined or null.
|
|
5314
5078
|
* @returns {Promise<void>} A promise that resolves when the state is saved.
|
|
@@ -5501,6 +5265,6 @@ declare const generateUUID: () => string;
|
|
|
5501
5265
|
/**
|
|
5502
5266
|
* The current version of the ART Framework package.
|
|
5503
5267
|
*/
|
|
5504
|
-
declare const VERSION = "0.4.
|
|
5268
|
+
declare const VERSION = "0.4.4";
|
|
5505
5269
|
|
|
5506
5270
|
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 };
|