site-operator 0.1.13 → 0.2.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 +8 -1
- package/dist/index.d.ts +150 -12
- package/dist/site-operator.es.js +9330 -761
- package/dist/site-operator.es.js.map +1 -1
- package/dist/site-operator.umd.js +1401 -52
- package/dist/site-operator.umd.js.map +1 -1
- package/package.json +19 -7
package/README.md
CHANGED
|
@@ -10,6 +10,14 @@ This package is framework-agnostic and built with Lit.
|
|
|
10
10
|
npm install site-operator
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run dev
|
|
17
|
+
npm run build
|
|
18
|
+
npm run preview
|
|
19
|
+
```
|
|
20
|
+
|
|
13
21
|
## Chat Portal API
|
|
14
22
|
|
|
15
23
|
The Chat Portal API is the bridge that allows the AI Agent to understand and interact with your application. It consists of two main parts:
|
|
@@ -112,4 +120,3 @@ chatService.setAppState(currentState);
|
|
|
112
120
|
</script>
|
|
113
121
|
```
|
|
114
122
|
|
|
115
|
-
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,15 @@ import { CSSResult } from 'lit';
|
|
|
2
2
|
import { LitElement } from 'lit';
|
|
3
3
|
import { Message } from '@ag-ui/client';
|
|
4
4
|
import { Message as Message_2 } from '@ag-ui/core';
|
|
5
|
+
import { ReactiveController } from 'lit';
|
|
6
|
+
import { ReactiveControllerHost } from 'lit';
|
|
5
7
|
import { TemplateResult } from 'lit-html';
|
|
6
8
|
|
|
7
9
|
export declare class AgentChat extends LitElement {
|
|
8
10
|
static styles: CSSResult;
|
|
9
11
|
private _chatController;
|
|
12
|
+
get controller(): ChatController;
|
|
13
|
+
protected firstUpdated(): void;
|
|
10
14
|
backendUrl: string;
|
|
11
15
|
appName: string;
|
|
12
16
|
conversationUrl: string;
|
|
@@ -45,6 +49,8 @@ export declare class AgentChat extends LitElement {
|
|
|
45
49
|
private _handleSelectThread;
|
|
46
50
|
private _toggleInspector;
|
|
47
51
|
render(): TemplateResult<1>;
|
|
52
|
+
private _handleContextUpdate;
|
|
53
|
+
private _handleStateUpdate;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
/**
|
|
@@ -145,6 +151,133 @@ export declare interface AppState {
|
|
|
145
151
|
};
|
|
146
152
|
}
|
|
147
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Controlador reactivo para gestionar la conexión con el ChatService.
|
|
156
|
+
* Se encarga de suscribirse a los cambios de estado y limpiar los recursos
|
|
157
|
+
* cuando el componente host se desconecta.
|
|
158
|
+
*/
|
|
159
|
+
export declare class ChatController implements ReactiveController {
|
|
160
|
+
private _host;
|
|
161
|
+
constructor(host: ReactiveControllerHost);
|
|
162
|
+
/**
|
|
163
|
+
* Inicializa el servicio de chat con las URLs necesarias y el nombre de la aplicación.
|
|
164
|
+
* @param config Configuración de inicialización.
|
|
165
|
+
*/
|
|
166
|
+
initialize(config: {
|
|
167
|
+
backendUrl: string;
|
|
168
|
+
appName: string;
|
|
169
|
+
conversationUrl: string;
|
|
170
|
+
inspector?: boolean;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Se ejecuta cuando el componente se conecta al DOM.
|
|
174
|
+
* Registra el listener para actualizaciones de estado.
|
|
175
|
+
*/
|
|
176
|
+
hostConnected(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Se ejecuta cuando el componente se desconecta del DOM.
|
|
179
|
+
* Elimina el listener para evitar fugas de memoria.
|
|
180
|
+
*/
|
|
181
|
+
hostDisconnected(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Retorna el estado actual del hilo de chat.
|
|
184
|
+
*/
|
|
185
|
+
get isRunning(): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Retorna el listado de mensajes.
|
|
188
|
+
*/
|
|
189
|
+
get messages(): ({
|
|
190
|
+
id: string;
|
|
191
|
+
role: "developer";
|
|
192
|
+
content: string;
|
|
193
|
+
name?: string | undefined;
|
|
194
|
+
} | {
|
|
195
|
+
id: string;
|
|
196
|
+
role: "system";
|
|
197
|
+
content: string;
|
|
198
|
+
name?: string | undefined;
|
|
199
|
+
} | {
|
|
200
|
+
id: string;
|
|
201
|
+
role: "assistant";
|
|
202
|
+
name?: string | undefined;
|
|
203
|
+
content?: string | undefined;
|
|
204
|
+
toolCalls?: {
|
|
205
|
+
function: {
|
|
206
|
+
name: string;
|
|
207
|
+
arguments: string;
|
|
208
|
+
};
|
|
209
|
+
type: "function";
|
|
210
|
+
id: string;
|
|
211
|
+
}[] | undefined;
|
|
212
|
+
} | {
|
|
213
|
+
id: string;
|
|
214
|
+
role: "user";
|
|
215
|
+
content: string | ({
|
|
216
|
+
type: "text";
|
|
217
|
+
text: string;
|
|
218
|
+
} | {
|
|
219
|
+
type: "binary";
|
|
220
|
+
mimeType: string;
|
|
221
|
+
id?: string | undefined;
|
|
222
|
+
url?: string | undefined;
|
|
223
|
+
data?: string | undefined;
|
|
224
|
+
filename?: string | undefined;
|
|
225
|
+
})[];
|
|
226
|
+
name?: string | undefined;
|
|
227
|
+
} | {
|
|
228
|
+
id: string;
|
|
229
|
+
role: "tool";
|
|
230
|
+
content: string;
|
|
231
|
+
toolCallId: string;
|
|
232
|
+
error?: string | undefined;
|
|
233
|
+
} | {
|
|
234
|
+
id: string;
|
|
235
|
+
role: "activity";
|
|
236
|
+
content: Record<string, any>;
|
|
237
|
+
activityType: string;
|
|
238
|
+
})[];
|
|
239
|
+
/**
|
|
240
|
+
* Retorna el listado de conversaciones recientes.
|
|
241
|
+
*/
|
|
242
|
+
get conversations(): ConversationSummary[];
|
|
243
|
+
/**
|
|
244
|
+
* Envía un mensaje a través del servicio.
|
|
245
|
+
* @param content Contenido del mensaje.
|
|
246
|
+
*/
|
|
247
|
+
sendMessage(content: string): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* Inicia un nuevo hilo de charla.
|
|
250
|
+
*/
|
|
251
|
+
startNewThread(): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Carga una conversación existente por su ID.
|
|
254
|
+
* @param id ID de la conversación a cargar.
|
|
255
|
+
*/
|
|
256
|
+
loadConversation(id: string): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Establece el contexto de la aplicación.
|
|
259
|
+
* @param context Objeto AgentState o AppContext con el contexto.
|
|
260
|
+
*/
|
|
261
|
+
setAppContext(context: AppContext): void;
|
|
262
|
+
/**
|
|
263
|
+
* Establece el estado dinámico de la aplicación.
|
|
264
|
+
* @param state Objeto AppState.
|
|
265
|
+
*/
|
|
266
|
+
setAppState(state: AppState): void;
|
|
267
|
+
setAppLocation(location: AppState["location"]): void;
|
|
268
|
+
setAppUI(ui: AppState["ui"]): void;
|
|
269
|
+
setAppFocus(focus: AppState["focus"]): void;
|
|
270
|
+
/**
|
|
271
|
+
* Refresca el listado de conversaciones desde el servidor.
|
|
272
|
+
*/
|
|
273
|
+
refreshConversations(): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Manejador interno para cambios de estado.
|
|
276
|
+
* Llama a requestUpdate() en el host para forzar el renderizado.
|
|
277
|
+
*/
|
|
278
|
+
private _onStateChange;
|
|
279
|
+
}
|
|
280
|
+
|
|
148
281
|
/**
|
|
149
282
|
* Core interface for the Chat Portal API.
|
|
150
283
|
*/
|
|
@@ -161,21 +294,18 @@ export declare interface ChatPortalAPI {
|
|
|
161
294
|
executePlan(plan: unknown): Promise<ExecutePlanResult>;
|
|
162
295
|
}
|
|
163
296
|
|
|
164
|
-
export declare class ChatPortalService implements ChatPortalAPI {
|
|
297
|
+
export declare class ChatPortalService extends EventTarget implements ChatPortalAPI {
|
|
165
298
|
private _context;
|
|
166
299
|
private static _instance;
|
|
167
300
|
private constructor();
|
|
168
301
|
static getInstance(): ChatPortalService;
|
|
169
302
|
registerPortal(context: AppContext): void;
|
|
170
|
-
executePlan(plan:
|
|
171
|
-
status: "ok" | "error";
|
|
172
|
-
details?: any;
|
|
173
|
-
}>;
|
|
303
|
+
executePlan(plan: unknown): Promise<ExecutePlanResult>;
|
|
174
304
|
get context(): AppContext | null;
|
|
175
305
|
/**
|
|
176
306
|
* @deprecated Use context instead
|
|
177
307
|
*/
|
|
178
|
-
get specs():
|
|
308
|
+
get specs(): AppContext | null;
|
|
179
309
|
}
|
|
180
310
|
|
|
181
311
|
export declare const chatPortalService: ChatPortalService;
|
|
@@ -210,7 +340,7 @@ export declare type ClickAction = {
|
|
|
210
340
|
} | {
|
|
211
341
|
/** Generic action type for extension */
|
|
212
342
|
type: string;
|
|
213
|
-
[k: string]:
|
|
343
|
+
[k: string]: unknown;
|
|
214
344
|
};
|
|
215
345
|
|
|
216
346
|
/**
|
|
@@ -270,7 +400,7 @@ export declare class ConversationService {
|
|
|
270
400
|
constructor();
|
|
271
401
|
/**
|
|
272
402
|
* Inicializa la URL base del servicio.
|
|
273
|
-
* @param apiUrl URL base del API de conversaciones
|
|
403
|
+
* @param apiUrl URL base del API de conversaciones
|
|
274
404
|
*/
|
|
275
405
|
initialize(apiUrl: string): void;
|
|
276
406
|
/**
|
|
@@ -278,12 +408,20 @@ export declare class ConversationService {
|
|
|
278
408
|
* @returns Promesa con el listado de conversaciones
|
|
279
409
|
*/
|
|
280
410
|
getConversations(): Promise<Conversation[]>;
|
|
411
|
+
/**
|
|
412
|
+
* Obtiene una conversación por su ID.
|
|
413
|
+
* @param id ID de la conversación
|
|
414
|
+
* @returns Promesa con la conversación
|
|
415
|
+
*/
|
|
416
|
+
getConversation(id: string): Promise<Conversation>;
|
|
281
417
|
/**
|
|
282
418
|
* Crea una nueva conversación.
|
|
283
|
-
* @param
|
|
419
|
+
* @param data Datos de la conversación a crear (incluyendo opcionalmente el appContext).
|
|
284
420
|
* @returns Promesa con la conversación creada
|
|
285
421
|
*/
|
|
286
|
-
createConversation(
|
|
422
|
+
createConversation(data: Partial<Conversation> & {
|
|
423
|
+
appContext?: AppContext;
|
|
424
|
+
}): Promise<Conversation>;
|
|
287
425
|
/**
|
|
288
426
|
* Actualiza una conversación existente.
|
|
289
427
|
* @param id ID de la conversación
|
|
@@ -312,7 +450,7 @@ export declare interface ExecutePlanResult {
|
|
|
312
450
|
/** Status of the execution */
|
|
313
451
|
status: "ok" | "error";
|
|
314
452
|
/** Optional details about the execution or error message */
|
|
315
|
-
details?:
|
|
453
|
+
details?: unknown;
|
|
316
454
|
}
|
|
317
455
|
|
|
318
456
|
/**
|
|
@@ -346,7 +484,7 @@ export declare const fetchInterceptorService: FetchInterceptorService;
|
|
|
346
484
|
|
|
347
485
|
export declare interface InspectorEvent {
|
|
348
486
|
event: string;
|
|
349
|
-
content:
|
|
487
|
+
content: unknown;
|
|
350
488
|
time: string;
|
|
351
489
|
}
|
|
352
490
|
|