@applica-software-guru/persona-chat-sdk 0.1.113 → 0.1.115
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/.eslintrc.cjs +7 -0
- package/dist/bundle.cjs.js +14 -14
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +2867 -2633
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +17 -17
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +14 -14
- package/dist/bundle.umd.js.map +1 -1
- package/dist/protocol/rest.d.ts +1 -0
- package/dist/protocol/rest.d.ts.map +1 -1
- package/dist/runtime/context.d.ts +11 -1
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/handlers.d.ts +7 -6
- package/dist/runtime/handlers.d.ts.map +1 -1
- package/dist/runtime/listeners.d.ts +6 -3
- package/dist/runtime/listeners.d.ts.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/types.d.ts +68 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/playground/src/hooks/theme.ts +0 -1
- package/playground/src/tools.ts +4 -3
- package/src/protocol/rest.ts +134 -21
- package/src/runtime/context.ts +25 -1
- package/src/runtime/handlers.ts +70 -32
- package/src/runtime/listeners.ts +190 -18
- package/src/runtime.tsx +56 -26
- package/src/types.ts +88 -3
package/dist/protocol/rest.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare class PersonaRESTProtocol extends PersonaProtocolBase {
|
|
|
18
18
|
connect(session: Session): Promise<Session>;
|
|
19
19
|
disconnect(): Promise<void>;
|
|
20
20
|
syncSession(session: Session): Promise<void>;
|
|
21
|
+
private buildHeaders;
|
|
21
22
|
sendPacket(packet: PersonaPacket): Promise<void>;
|
|
22
23
|
}
|
|
23
24
|
export { PersonaRESTProtocol };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../src/protocol/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAEL,OAAO,EACP,cAAc,EACd,yBAAyB,EAEzB,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,KAAK,yBAAyB,GAAG,yBAAyB,GAAG;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,cAAM,mBAAoB,SAAQ,mBAAmB;IACnD,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,yBAAyB,CAAC;IAClC,MAAM,EAAE,OAAO,CAAQ;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACtC,KAAK,EAAE,YAAY,EAAE,CAAM;gBAEf,MAAM,EAAE,yBAAyB;IAOtC,OAAO,IAAI,MAAM;IAIjB,WAAW,IAAI,MAAM;IAIf,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../src/protocol/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAEL,OAAO,EACP,cAAc,EACd,yBAAyB,EAEzB,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,KAAK,yBAAyB,GAAG,yBAAyB,GAAG;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,cAAM,mBAAoB,SAAQ,mBAAmB;IACnD,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,yBAAyB,CAAC;IAClC,MAAM,EAAE,OAAO,CAAQ;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACtC,KAAK,EAAE,YAAY,EAAE,CAAM;gBAEf,MAAM,EAAE,yBAAyB;IAOtC,OAAO,IAAI,MAAM;IAIjB,WAAW,IAAI,MAAM;IAIf,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,OAAO,CAAC,YAAY;IAOP,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CA2J9D;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { PersonaProtocol, ProtocolStatus } from '../types';
|
|
1
|
+
import { PersonaProtocol, ProtocolStatus, AgentState } from '../types';
|
|
2
2
|
import { PersonaMessage } from '../types';
|
|
3
3
|
import { PersonaWebRTCProtocol } from '../protocol';
|
|
4
4
|
export type PersonaRuntimeContextType = {
|
|
5
5
|
protocols: PersonaProtocol[];
|
|
6
6
|
protocolsStatus: Map<string, ProtocolStatus>;
|
|
7
|
+
agentState: AgentState;
|
|
7
8
|
getMessages: () => PersonaMessage[];
|
|
8
9
|
renameThread: (threadId: string, name: string) => void;
|
|
10
|
+
steerAgent: (text: string) => Promise<void>;
|
|
9
11
|
};
|
|
10
12
|
export declare const PersonaRuntimeContext: import("react").Context<PersonaRuntimeContextType | undefined>;
|
|
11
13
|
/**
|
|
@@ -36,4 +38,12 @@ export declare function usePersonaRenameThread(): (threadId: string, name: strin
|
|
|
36
38
|
* Gets all messages from the current conversation
|
|
37
39
|
*/
|
|
38
40
|
export declare function usePersonaRuntimeMessages(): PersonaMessage[];
|
|
41
|
+
/**
|
|
42
|
+
* Gets the current agent execution state
|
|
43
|
+
*/
|
|
44
|
+
export declare function useAgentState(): AgentState;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a function to steer the currently running agent
|
|
47
|
+
*/
|
|
48
|
+
export declare function useSteerAgent(): (text: string) => Promise<void>;
|
|
39
49
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/runtime/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/runtime/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,MAAM,cAAc,EAAE,CAAC;IACpC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,yBAAyB,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAyBlF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,IAAI,CAOzD;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,qBAAqB,GAAG,IAAI,CAE9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAMjF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,cAAc,EAAE,CAM5D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAM1C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAM/D"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { AppendMessage } from '@assistant-ui/react';
|
|
2
2
|
import { StartRunConfig } from '@assistant-ui/react/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore';
|
|
3
|
-
import { PersonaProtocol, PersonaMessage, TransformMessages } from '../types';
|
|
3
|
+
import { PersonaProtocol, PersonaMessage, TransformMessages, AgentState } from '../types';
|
|
4
4
|
import type { PersonaLogger } from '../logging';
|
|
5
5
|
/**
|
|
6
6
|
* Creates the onNew handler for new messages
|
|
7
7
|
*/
|
|
8
|
-
export declare function createOnNewHandler(protocols: PersonaProtocol[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>,
|
|
8
|
+
export declare function createOnNewHandler(protocols: PersonaProtocol[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setAgentState: React.Dispatch<React.SetStateAction<AgentState>>, transformMessages?: TransformMessages, logger?: PersonaLogger): (message: AppendMessage) => Promise<void>;
|
|
9
9
|
/**
|
|
10
10
|
* Creates the onEdit handler for editing messages
|
|
11
11
|
*/
|
|
12
|
-
export declare function createOnEditHandler(protocols: PersonaProtocol[], messages: PersonaMessage[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>,
|
|
12
|
+
export declare function createOnEditHandler(protocols: PersonaProtocol[], messages: PersonaMessage[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setAgentState: React.Dispatch<React.SetStateAction<AgentState>>, transformMessages?: TransformMessages, logger?: PersonaLogger): (message: AppendMessage) => Promise<void>;
|
|
13
13
|
/**
|
|
14
14
|
* Creates the onReload handler for regenerating messages
|
|
15
15
|
*/
|
|
16
|
-
export declare function createOnReloadHandler(protocols: PersonaProtocol[], messages: PersonaMessage[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>,
|
|
16
|
+
export declare function createOnReloadHandler(protocols: PersonaProtocol[], messages: PersonaMessage[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setAgentState: React.Dispatch<React.SetStateAction<AgentState>>, transformMessages?: TransformMessages, logger?: PersonaLogger): (parentId: string | null, config: StartRunConfig) => Promise<void>;
|
|
17
17
|
/**
|
|
18
|
-
* Creates the onCancel handler for cancelling
|
|
18
|
+
* Creates the onCancel handler for cancelling agent execution.
|
|
19
|
+
* Sends the dedicated 'cancel' command to all connected protocols.
|
|
19
20
|
*/
|
|
20
|
-
export declare function createOnCancelHandler(protocols: PersonaProtocol[],
|
|
21
|
+
export declare function createOnCancelHandler(protocols: PersonaProtocol[], setAgentState: React.Dispatch<React.SetStateAction<AgentState>>, logger?: PersonaLogger): () => Promise<void>;
|
|
21
22
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/runtime/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,8EAA8E,CAAC;AAC9G,OAAO,E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K,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,EACnE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAC/D,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,MAAM,CAAC,EAAE,aAAa,cAEE,MAAM,GAAG,IAAI,UAAU,cAAc,mBA0E9D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,eAAe,EAAE,EAC5B,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAC/D,MAAM,CAAC,EAAE,aAAa,uBAuBvB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { PersonaPacket, PersonaMessage, PersonaProtocol, TransformMessages } from '../types';
|
|
1
|
+
import { PersonaPacket, PersonaMessage, PersonaProtocol, TransformMessages, AgentState, SteerAcceptedPayload, SteerProcessedPayload } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Creates packet listener for a protocol
|
|
3
|
+
* Creates packet listener for a protocol.
|
|
4
|
+
*
|
|
5
|
+
* Uses setAgentState instead of setIsRunning for proper lifecycle management.
|
|
6
|
+
* The send button is only re-enabled after agent_end.
|
|
4
7
|
*/
|
|
5
|
-
export declare function createPacketListener(protocol: PersonaProtocol, setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>,
|
|
8
|
+
export declare function createPacketListener(protocol: PersonaProtocol, setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setAgentState: React.Dispatch<React.SetStateAction<AgentState>>, protocols: PersonaProtocol[], transformMessages?: TransformMessages, onSteerAccepted?: (payload: SteerAcceptedPayload) => void, onSteerProcessed?: (payload: SteerProcessedPayload) => void): (packet: PersonaPacket) => void;
|
|
6
9
|
//# sourceMappingURL=listeners.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/runtime/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/runtime/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EAGd,eAAe,EACf,iBAAiB,EACjB,UAAU,EAKV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAGlB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,EACnE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAC/D,SAAS,EAAE,eAAe,EAAE,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,EACzD,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,YAE3C,aAAa,UAkH9B"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { PersonaConfig, PersonaMessage, PersonaResponse, ThreadData } from './types';
|
|
3
|
-
export { usePersonaRuntime, usePersonaRuntimeProtocol, usePersonaRuntimeEndpoint, usePersonaRuntimeWebRTCProtocol, usePersonaRuntimeMessages, usePersonaRenameThread, } from './runtime/context';
|
|
3
|
+
export { usePersonaRuntime, usePersonaRuntimeProtocol, usePersonaRuntimeEndpoint, usePersonaRuntimeWebRTCProtocol, usePersonaRuntimeMessages, usePersonaRenameThread, useAgentState, useSteerAgent, } from './runtime/context';
|
|
4
4
|
export type { PersonaMessage, PersonaResponse, ThreadData };
|
|
5
5
|
export declare function PersonaRuntimeProvider({ children, ...config }: PropsWithChildren<PersonaConfig>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,iBAAiB,EAAmB,MAAM,OAAO,CAAC;AAS7F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAA2B,UAAU,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,iBAAiB,EAAmB,MAAM,OAAO,CAAC;AAS7F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAA2B,UAAU,EAAc,MAAM,SAAS,CAAC;AAS1H,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,+BAA+B,EAC/B,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AAwV5D,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EAAE,iBAAiB,CAAC,aAAa,CAAC,2CAE/F"}
|
package/dist/types.d.ts
CHANGED
|
@@ -88,13 +88,13 @@ export type PersonaSource = {
|
|
|
88
88
|
mostRelevant?: boolean;
|
|
89
89
|
};
|
|
90
90
|
export type PersonaCommand = {
|
|
91
|
-
command: 'get_mcp_assets' | 'set_initial_context' | 'set_local_tools';
|
|
91
|
+
command: 'get_mcp_assets' | 'set_initial_context' | 'set_local_tools' | 'cancel' | 'steer' | 'get_agent_state';
|
|
92
92
|
arguments: Record<string, unknown>;
|
|
93
93
|
};
|
|
94
94
|
export type PersonaRequest = PersonaMessage | Array<PersonaMessage> | string;
|
|
95
|
-
export type PersonaPacketPayload = PersonaRequest | PersonaCommand | PersonaReasoning | PersonaTransaction
|
|
95
|
+
export type PersonaPacketPayload = PersonaRequest | PersonaCommand | PersonaReasoning | PersonaTransaction | AgentStartPayload | AgentEndPayload | TurnStartPayload | TurnEndPayload | ToolExecutionStartPayload | ToolExecutionUpdatePayload | ToolExecutionEndPayload | SteerAcceptedPayload | SteerProcessedPayload | Record<string, unknown>;
|
|
96
96
|
export type PersonaPacket = {
|
|
97
|
-
type: 'request' | 'message' | 'command' | 'reasoning' | 'mcp_assets' | 'transaction';
|
|
97
|
+
type: 'request' | 'message' | 'command' | 'reasoning' | 'mcp_assets' | 'transaction' | 'agent_start' | 'agent_end' | 'turn_start' | 'turn_end' | 'tool_execution_start' | 'tool_execution_update' | 'tool_execution_end' | 'steer_accepted' | 'steer_processed';
|
|
98
98
|
payload?: PersonaPacketPayload;
|
|
99
99
|
};
|
|
100
100
|
export type PersonaMessage = {
|
|
@@ -120,6 +120,58 @@ export type PersonaMessage = {
|
|
|
120
120
|
[key: string]: unknown;
|
|
121
121
|
};
|
|
122
122
|
};
|
|
123
|
+
export type AgentState = 'idle' | 'running' | 'cancelling';
|
|
124
|
+
export type AgentStartPayload = {
|
|
125
|
+
sessionId: string;
|
|
126
|
+
agentId: string;
|
|
127
|
+
timestamp: string;
|
|
128
|
+
};
|
|
129
|
+
export type AgentEndPayload = {
|
|
130
|
+
sessionId: string;
|
|
131
|
+
stopReason: 'completed' | 'cancelled' | 'error' | 'max_turns' | 'steered_completion';
|
|
132
|
+
totalTurns: number;
|
|
133
|
+
totalCredits?: number;
|
|
134
|
+
errorMessage?: string;
|
|
135
|
+
};
|
|
136
|
+
export type TurnStartPayload = {
|
|
137
|
+
turnNumber: number;
|
|
138
|
+
timestamp: string;
|
|
139
|
+
};
|
|
140
|
+
export type TurnEndPayload = {
|
|
141
|
+
turnNumber: number;
|
|
142
|
+
messageCount: number;
|
|
143
|
+
toolResults: Array<{
|
|
144
|
+
toolCallId: string;
|
|
145
|
+
toolName: string;
|
|
146
|
+
result: string;
|
|
147
|
+
}>;
|
|
148
|
+
};
|
|
149
|
+
export type ToolExecutionStartPayload = {
|
|
150
|
+
toolCallId: string;
|
|
151
|
+
toolName: string;
|
|
152
|
+
args: Record<string, unknown>;
|
|
153
|
+
timestamp: string;
|
|
154
|
+
};
|
|
155
|
+
export type ToolExecutionUpdatePayload = {
|
|
156
|
+
toolCallId: string;
|
|
157
|
+
partialResult: unknown;
|
|
158
|
+
};
|
|
159
|
+
export type ToolExecutionEndPayload = {
|
|
160
|
+
toolCallId: string;
|
|
161
|
+
result: unknown;
|
|
162
|
+
durationMs?: number;
|
|
163
|
+
error?: string;
|
|
164
|
+
};
|
|
165
|
+
export type SteerAcceptedPayload = {
|
|
166
|
+
steerId: string;
|
|
167
|
+
text: string;
|
|
168
|
+
acceptedAt: string;
|
|
169
|
+
willProcessAfterTurn: number | null;
|
|
170
|
+
};
|
|
171
|
+
export type SteerProcessedPayload = {
|
|
172
|
+
steerId: string;
|
|
173
|
+
processedAtTurn: number;
|
|
174
|
+
};
|
|
123
175
|
export type ModelResponse = {
|
|
124
176
|
messages: PersonaMessage[];
|
|
125
177
|
};
|
|
@@ -234,5 +286,18 @@ export type PersonaConfig = PersonaBaseConfig & PersonaProtocolBaseConfig & {
|
|
|
234
286
|
* Enable file attachments (images, PDFs, text files) in the composer
|
|
235
287
|
*/
|
|
236
288
|
enableAttachments?: boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Enable steer commands during agent execution.
|
|
291
|
+
* When true, the user can send steer instructions while the agent is running.
|
|
292
|
+
*/
|
|
293
|
+
enableSteer?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Callback when a steer command is accepted by the server.
|
|
296
|
+
*/
|
|
297
|
+
onSteerAccepted?: (payload: SteerAcceptedPayload) => void;
|
|
298
|
+
/**
|
|
299
|
+
* Callback when a steer command is processed (injected into the agent context).
|
|
300
|
+
*/
|
|
301
|
+
onSteerProcessed?: (payload: SteerProcessedPayload) => void;
|
|
237
302
|
};
|
|
238
303
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACnH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,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E,oBAAoB,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@applica-software-guru/persona-chat-sdk",
|
|
3
3
|
"description": "Official Chat SDK for the Persona API — React runtime provider with REST, WebSocket and WebRTC protocols via assistant-ui.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.115",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
package/playground/src/tools.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* showcase or test tool integration.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { createTool, PersonaTools } from '@applica-software-guru/persona-chat-sdk';
|
|
10
|
+
import { createTool, PersonaConsoleLogger, PersonaTools } from '@applica-software-guru/persona-chat-sdk';
|
|
11
|
+
|
|
12
|
+
const logger = new PersonaConsoleLogger();
|
|
11
13
|
|
|
12
14
|
const toolLibrary = [
|
|
13
15
|
createTool({
|
|
@@ -22,13 +24,12 @@ const toolLibrary = [
|
|
|
22
24
|
success: { type: 'boolean', description: 'Indicates if the field value was set successfully' },
|
|
23
25
|
},
|
|
24
26
|
implementation: async (name: string, value: string) => {
|
|
25
|
-
console.log({ name, value });
|
|
26
27
|
const field = document.querySelector(`[name="${name}"]`);
|
|
27
28
|
if (field) {
|
|
28
29
|
(field as HTMLInputElement).value = value;
|
|
29
30
|
return { success: true };
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
logger.error(`Field with name "${name}" not found.`);
|
|
32
33
|
return { success: false };
|
|
33
34
|
},
|
|
34
35
|
}),
|
package/src/protocol/rest.ts
CHANGED
|
@@ -52,43 +52,147 @@ class PersonaRESTProtocol extends PersonaProtocolBase {
|
|
|
52
52
|
this.session = session;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
private buildHeaders(): Record<string, string> {
|
|
56
|
+
return {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
'x-persona-apikey': this.config.apiKey,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
public async sendPacket(packet: PersonaPacket): Promise<void> {
|
|
56
|
-
const { apiUrl,
|
|
63
|
+
const { apiUrl, agentId } = this.config;
|
|
57
64
|
const sessionId = this.session ?? 'new';
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
payload: {
|
|
67
|
-
type: 'text',
|
|
68
|
-
role: 'assistant',
|
|
69
|
-
text: 'Local tools with rest protocol are not supported.',
|
|
70
|
-
},
|
|
71
|
-
});
|
|
65
|
+
|
|
66
|
+
// ─── Comandi ──────────────────────────────────────────────────
|
|
67
|
+
if (packet.type === 'command') {
|
|
68
|
+
const cmd = packet.payload as PersonaCommand;
|
|
69
|
+
|
|
70
|
+
if (cmd.command === 'set_initial_context') {
|
|
71
|
+
this.context = cmd.arguments as Record<string, unknown>;
|
|
72
|
+
return;
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
if (cmd.command === 'set_local_tools') {
|
|
76
|
+
const tools = cmd.arguments?.tools as ToolInstance[] | undefined;
|
|
77
|
+
if (tools?.length) {
|
|
78
|
+
this.notifyPacket({
|
|
79
|
+
type: 'message',
|
|
80
|
+
payload: {
|
|
81
|
+
type: 'text',
|
|
82
|
+
role: 'assistant',
|
|
83
|
+
text: 'Local tools with rest protocol are not supported.',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (cmd.command === 'cancel') {
|
|
91
|
+
try {
|
|
92
|
+
await fetch(`${apiUrl}/sessions/${encodeURIComponent(String(sessionId))}/cancel`, {
|
|
93
|
+
method: 'POST',
|
|
94
|
+
headers: this.buildHeaders(),
|
|
95
|
+
});
|
|
96
|
+
this.notifyPacket({
|
|
97
|
+
type: 'agent_end',
|
|
98
|
+
payload: {
|
|
99
|
+
sessionId: String(sessionId),
|
|
100
|
+
stopReason: 'cancelled',
|
|
101
|
+
totalTurns: 0,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
this.config.logger?.error('Error cancelling via REST:', error);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (cmd.command === 'steer') {
|
|
111
|
+
const text = (cmd.arguments?.text as string) || '';
|
|
112
|
+
if (!text) return;
|
|
113
|
+
try {
|
|
114
|
+
const res = await fetch(`${apiUrl}/sessions/${encodeURIComponent(String(sessionId))}/steer`, {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
headers: this.buildHeaders(),
|
|
117
|
+
body: JSON.stringify({ text }),
|
|
118
|
+
});
|
|
119
|
+
const result = await res.json();
|
|
120
|
+
this.notifyPacket({ type: 'steer_accepted', payload: result });
|
|
121
|
+
} catch (error) {
|
|
122
|
+
this.config.logger?.error('Error steering via REST:', error);
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (cmd.command === 'get_agent_state') {
|
|
128
|
+
try {
|
|
129
|
+
const res = await fetch(`${apiUrl}/sessions/${encodeURIComponent(String(sessionId))}/agent-state`, {
|
|
130
|
+
method: 'GET',
|
|
131
|
+
headers: this.buildHeaders(),
|
|
132
|
+
});
|
|
133
|
+
const state = await res.json();
|
|
134
|
+
this.notifyPacket({ type: 'command', payload: { command: 'get_agent_state', arguments: state } });
|
|
135
|
+
} catch (error) {
|
|
136
|
+
this.config.logger?.error('Error getting agent state via REST:', error);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
73
141
|
return;
|
|
74
142
|
}
|
|
143
|
+
|
|
144
|
+
// ─── Request (messaggio utente) ───────────────────────────────
|
|
145
|
+
if (packet.type !== 'request') return;
|
|
146
|
+
|
|
75
147
|
const input = packet.payload as PersonaMessage;
|
|
148
|
+
|
|
149
|
+
// Emetti agent_start sintetico (REST è sincrono, quindi emettiamo subito)
|
|
150
|
+
this.notifyPacket({
|
|
151
|
+
type: 'agent_start',
|
|
152
|
+
payload: {
|
|
153
|
+
sessionId: String(sessionId),
|
|
154
|
+
agentId,
|
|
155
|
+
timestamp: new Date().toISOString(),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
76
159
|
try {
|
|
77
|
-
const response = await fetch(`${apiUrl}/sessions/${sessionId}/messages`, {
|
|
160
|
+
const response = await fetch(`${apiUrl}/sessions/${encodeURIComponent(String(sessionId))}/messages`, {
|
|
78
161
|
body: JSON.stringify({ agentId, userMessage: input, initialContext: this.context, tools: this.tools }),
|
|
79
162
|
method: 'POST',
|
|
80
|
-
headers:
|
|
81
|
-
'Content-Type': 'application/json',
|
|
82
|
-
'x-persona-apikey': apiKey,
|
|
83
|
-
},
|
|
163
|
+
headers: this.buildHeaders(),
|
|
84
164
|
});
|
|
85
165
|
const personaResponse = (await response.json()) as PersonaResponse;
|
|
166
|
+
|
|
167
|
+
// Forward messages
|
|
86
168
|
this.notifyPackets(
|
|
87
169
|
personaResponse.response.messages.map((payload) => ({
|
|
88
170
|
type: 'message',
|
|
89
171
|
payload,
|
|
90
172
|
})),
|
|
91
173
|
);
|
|
174
|
+
|
|
175
|
+
// Emetti agent_end sintetico
|
|
176
|
+
this.notifyPacket({
|
|
177
|
+
type: 'agent_end',
|
|
178
|
+
payload: {
|
|
179
|
+
sessionId: String(sessionId),
|
|
180
|
+
stopReason: 'completed',
|
|
181
|
+
totalTurns: 1,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Update session from response
|
|
186
|
+
if (personaResponse.sessionId && personaResponse.sessionId !== sessionId) {
|
|
187
|
+
this.session = personaResponse.sessionId;
|
|
188
|
+
this.notifyPacket({
|
|
189
|
+
type: 'command',
|
|
190
|
+
payload: {
|
|
191
|
+
command: 'set_initial_context',
|
|
192
|
+
arguments: { sessionId: personaResponse.sessionId },
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
92
196
|
} catch (error) {
|
|
93
197
|
this.notifyPacket({
|
|
94
198
|
type: 'message',
|
|
@@ -98,7 +202,16 @@ class PersonaRESTProtocol extends PersonaProtocolBase {
|
|
|
98
202
|
text: 'An error occurred while processing your request. Please try again later.',
|
|
99
203
|
},
|
|
100
204
|
});
|
|
101
|
-
this.
|
|
205
|
+
this.notifyPacket({
|
|
206
|
+
type: 'agent_end',
|
|
207
|
+
payload: {
|
|
208
|
+
sessionId: String(sessionId),
|
|
209
|
+
stopReason: 'error',
|
|
210
|
+
totalTurns: 0,
|
|
211
|
+
errorMessage: String(error),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
this.config.logger?.error('Error sending REST packet:', error);
|
|
102
215
|
}
|
|
103
216
|
}
|
|
104
217
|
}
|
package/src/runtime/context.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
-
import { PersonaProtocol, ProtocolStatus } from '../types';
|
|
2
|
+
import { PersonaProtocol, ProtocolStatus, AgentState } from '../types';
|
|
3
3
|
import { PersonaMessage } from '../types';
|
|
4
4
|
import { PersonaWebRTCProtocol } from '../protocol';
|
|
5
5
|
import { getFirstAvailableProtocolEndpoint } from './utils';
|
|
@@ -7,8 +7,10 @@ import { getFirstAvailableProtocolEndpoint } from './utils';
|
|
|
7
7
|
export type PersonaRuntimeContextType = {
|
|
8
8
|
protocols: PersonaProtocol[];
|
|
9
9
|
protocolsStatus: Map<string, ProtocolStatus>;
|
|
10
|
+
agentState: AgentState;
|
|
10
11
|
getMessages: () => PersonaMessage[];
|
|
11
12
|
renameThread: (threadId: string, name: string) => void;
|
|
13
|
+
steerAgent: (text: string) => Promise<void>;
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
export const PersonaRuntimeContext = createContext<PersonaRuntimeContextType | undefined>(undefined);
|
|
@@ -98,3 +100,25 @@ export function usePersonaRuntimeMessages(): PersonaMessage[] {
|
|
|
98
100
|
}
|
|
99
101
|
return context.getMessages();
|
|
100
102
|
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Gets the current agent execution state
|
|
106
|
+
*/
|
|
107
|
+
export function useAgentState(): AgentState {
|
|
108
|
+
const context = useContext(PersonaRuntimeContext);
|
|
109
|
+
if (!context) {
|
|
110
|
+
throw new Error('useAgentState must be used within a PersonaRuntimeProvider');
|
|
111
|
+
}
|
|
112
|
+
return context.agentState;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Returns a function to steer the currently running agent
|
|
117
|
+
*/
|
|
118
|
+
export function useSteerAgent(): (text: string) => Promise<void> {
|
|
119
|
+
const context = useContext(PersonaRuntimeContext);
|
|
120
|
+
if (!context) {
|
|
121
|
+
throw new Error('useSteerAgent must be used within a PersonaRuntimeProvider');
|
|
122
|
+
}
|
|
123
|
+
return context.steerAgent;
|
|
124
|
+
}
|