site-operator 0.1.0
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 +43 -0
- package/dist/index.d.ts +140 -0
- package/dist/site-operator.es.js +10025 -0
- package/dist/site-operator.umd.js +724 -0
- package/dist/vite.svg +1 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Site Operator (Core)
|
|
2
|
+
|
|
3
|
+
The core Web Component library for Site Operator. It provides the `<agent-chat>` custom element and the `chatPortalService`.
|
|
4
|
+
|
|
5
|
+
This package is framework-agnostic.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install site-operator
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Vanilla JS
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import { mount } from 'site-operator';
|
|
19
|
+
|
|
20
|
+
// Mount the chat widget
|
|
21
|
+
mount(document.body, {
|
|
22
|
+
backendUrl: 'http://localhost:8001/ag_ui',
|
|
23
|
+
appName: 'My App'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Register portal actions (Copilot)
|
|
27
|
+
import { chatPortalService } from 'site-operator';
|
|
28
|
+
|
|
29
|
+
chatPortalService.registerPortal({
|
|
30
|
+
actions: {
|
|
31
|
+
navigate: (args) => console.log('Navigating to', args.url)
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### HTML
|
|
37
|
+
|
|
38
|
+
You can also use it directly if loaded via script tag (assuming UMD build):
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script src="path/to/site-operator.umd.js"></script>
|
|
42
|
+
<agent-chat backend-url="..." app-name="..."></agent-chat>
|
|
43
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { TemplateResult } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
export declare class AgentChat extends LitElement {
|
|
6
|
+
static styles: CSSResult;
|
|
7
|
+
private _chatController;
|
|
8
|
+
backendUrl: string;
|
|
9
|
+
appName: string;
|
|
10
|
+
agentAvatar: string;
|
|
11
|
+
private _historyOpen;
|
|
12
|
+
private _inspectorOpen;
|
|
13
|
+
private _inspectorEnabled;
|
|
14
|
+
willUpdate(changedProperties: Map<string, any>): void;
|
|
15
|
+
private _handleSend;
|
|
16
|
+
private _handleNewThread;
|
|
17
|
+
/**
|
|
18
|
+
* API Pública para establecer el contexto de la aplicación.
|
|
19
|
+
* @param appContext Contexto de la aplicación (AgentState)
|
|
20
|
+
*/
|
|
21
|
+
setAppContext(appContext: AgentState): void;
|
|
22
|
+
private _toggleHistory;
|
|
23
|
+
private _handleSelectThread;
|
|
24
|
+
private _toggleInspector;
|
|
25
|
+
render(): TemplateResult<1>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Representa el estado del agente y el contexto de la aplicación
|
|
30
|
+
* donde se encuentra embebido el chat.
|
|
31
|
+
*/
|
|
32
|
+
export declare interface AgentState {
|
|
33
|
+
/** Nombre del portal donde se ejecuta el chat */
|
|
34
|
+
appName: string;
|
|
35
|
+
/** Nombre de la página donde se está ejecutando */
|
|
36
|
+
currentPage: string;
|
|
37
|
+
/** Habilita la ventana de inspección */
|
|
38
|
+
inspector?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare interface ChatPortalAPI {
|
|
42
|
+
registerPortal(spec: PortalSpec): void;
|
|
43
|
+
executePlan(plan: NavPlan): Promise<{
|
|
44
|
+
status: "ok" | "error";
|
|
45
|
+
details?: any;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare class ChatPortalService implements ChatPortalAPI {
|
|
50
|
+
private _spec;
|
|
51
|
+
private static _instance;
|
|
52
|
+
private constructor();
|
|
53
|
+
static getInstance(): ChatPortalService;
|
|
54
|
+
registerPortal(spec: PortalSpec): void;
|
|
55
|
+
executePlan(plan: NavPlan): Promise<{
|
|
56
|
+
status: "ok" | "error";
|
|
57
|
+
details?: any;
|
|
58
|
+
}>;
|
|
59
|
+
get specs(): PortalSpec | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare const chatPortalService: ChatPortalService;
|
|
63
|
+
|
|
64
|
+
export declare interface ChatThread {
|
|
65
|
+
id: string;
|
|
66
|
+
messages: Message[];
|
|
67
|
+
isRunning: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare interface ConversationSummary {
|
|
71
|
+
id: string;
|
|
72
|
+
title: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export declare interface InspectorEvent {
|
|
76
|
+
event: string;
|
|
77
|
+
content: any;
|
|
78
|
+
time: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export declare interface Message {
|
|
82
|
+
id: string;
|
|
83
|
+
role: Role;
|
|
84
|
+
content: string;
|
|
85
|
+
createdAt: number;
|
|
86
|
+
isThinking?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Mounts the Agent Chat component to a target element.
|
|
91
|
+
* @param element The DOM element to mount the chat into.
|
|
92
|
+
* @param options Configuration options for the chat.
|
|
93
|
+
*/
|
|
94
|
+
export declare function mount(element: HTMLElement, options?: any): AgentChat;
|
|
95
|
+
|
|
96
|
+
export declare interface NavAction {
|
|
97
|
+
action: string;
|
|
98
|
+
args?: any;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export declare interface NavGraph {
|
|
102
|
+
nodes: NavNode[];
|
|
103
|
+
edges: {
|
|
104
|
+
from: string;
|
|
105
|
+
to: string;
|
|
106
|
+
label?: string;
|
|
107
|
+
}[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare interface NavNode {
|
|
111
|
+
id: string;
|
|
112
|
+
description: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export declare interface NavPlan {
|
|
116
|
+
steps: NavAction[];
|
|
117
|
+
rationale?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export declare interface PortalSpec {
|
|
121
|
+
graph: NavGraph;
|
|
122
|
+
actions: Record<string, (args: any) => Promise<any>>;
|
|
123
|
+
state?: {
|
|
124
|
+
get: () => Promise<{
|
|
125
|
+
route: string;
|
|
126
|
+
pageId?: string;
|
|
127
|
+
selection?: any;
|
|
128
|
+
}>;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Registers the web component.
|
|
134
|
+
* (It's already registered by import, but this can be a safe-guard re-export or initialization function)
|
|
135
|
+
*/
|
|
136
|
+
export declare function register(): void;
|
|
137
|
+
|
|
138
|
+
export declare type Role = "user" | "assistant";
|
|
139
|
+
|
|
140
|
+
export { }
|