site-operator 0.2.7 → 0.2.9
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/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,22 @@ export declare type Action = NavigationAction | {
|
|
|
34
34
|
targetId: string;
|
|
35
35
|
/** Optional reason for the click */
|
|
36
36
|
reason?: string;
|
|
37
|
+
} | {
|
|
38
|
+
/** Sets a value to an input element (e.g., text, number) */
|
|
39
|
+
type: "setValue";
|
|
40
|
+
/** Identifier for the target input element */
|
|
41
|
+
targetId: string;
|
|
42
|
+
/** The value to set (string or number) */
|
|
43
|
+
value: string | number;
|
|
44
|
+
/** Optional reason for setting the value */
|
|
45
|
+
reason?: string;
|
|
46
|
+
} | {
|
|
47
|
+
/** Sequence of actions to be performed in order */
|
|
48
|
+
type: "plan";
|
|
49
|
+
/** Ordered list of actions to execute */
|
|
50
|
+
steps: Action[];
|
|
51
|
+
/** Description of the plan's overall goal */
|
|
52
|
+
goal?: string;
|
|
37
53
|
} | {
|
|
38
54
|
/** Generic action type for extension */
|
|
39
55
|
type: string;
|
|
@@ -341,6 +357,10 @@ export declare class ChatController implements ReactiveController {
|
|
|
341
357
|
* Refresca el listado de conversaciones desde el servidor.
|
|
342
358
|
*/
|
|
343
359
|
refreshConversations(): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* Obtiene el listado de conversaciones desde el servidor.
|
|
362
|
+
*/
|
|
363
|
+
getConversations(): Promise<ConversationSummary[]>;
|
|
344
364
|
/**
|
|
345
365
|
* Manejador interno para cambios de estado.
|
|
346
366
|
* Llama a requestUpdate() en el host para forzar el renderizado.
|
|
@@ -498,11 +518,17 @@ declare class ChatService extends EventTarget {
|
|
|
498
518
|
sendMessage(content: string, role?: "developer" | "user" | "assistant" | "system" | "tool" | "activity"): Promise<void>;
|
|
499
519
|
_ensureConversation(): Promise<void>;
|
|
500
520
|
addPlaceholderMessage(): void;
|
|
521
|
+
cleanupThinkingPlaceholder(): void;
|
|
501
522
|
prepareMessageForStreaming(newId: string): void;
|
|
502
523
|
appendMessageContent(id: string, content: string): void;
|
|
503
524
|
setMessages(messages: Message[]): void;
|
|
504
525
|
addA2UIMessage(event: ActivitySnapshotEvent): void;
|
|
505
526
|
startNewThread(): Promise<void>;
|
|
527
|
+
/**
|
|
528
|
+
* Obtiene el listado de conversaciones desde el servidor.
|
|
529
|
+
* @returns Promesa con el listado de conversaciones.
|
|
530
|
+
*/
|
|
531
|
+
getConversations(): Promise<ConversationSummary[]>;
|
|
506
532
|
/**
|
|
507
533
|
* Refresca la lista de conversaciones desde el servicio de conversaciones.
|
|
508
534
|
*/
|
package/dist/site-operator.es.js
CHANGED
|
@@ -1144,6 +1144,15 @@ const styles$4 = i$1`
|
|
|
1144
1144
|
O.push(this.normalizeServerMessage(M));
|
|
1145
1145
|
continue;
|
|
1146
1146
|
}
|
|
1147
|
+
let o = M;
|
|
1148
|
+
if (o.role === "activity" && o.activityType === "a2ui" && o.content) {
|
|
1149
|
+
if (this.isServerToClientMessage(o.content)) O.push(this.normalizeServerMessage(o.content));
|
|
1150
|
+
else {
|
|
1151
|
+
let M = o.content, F = Array.isArray(M) ? M : [M];
|
|
1152
|
+
for (let o of F) this.isServerToClientMessage(o) && O.push(this.normalizeServerMessage(o));
|
|
1153
|
+
}
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1147
1156
|
M.role === "assistant" && M.toolCalls && O.push(...this.mapMessage(M));
|
|
1148
1157
|
}
|
|
1149
1158
|
if (O.length !== 0) return this.processor.processMessages(O);
|
|
@@ -1208,8 +1217,8 @@ var ChatMessage = class extends i {
|
|
|
1208
1217
|
}));
|
|
1209
1218
|
}
|
|
1210
1219
|
render() {
|
|
1211
|
-
let o = this.message.role === "user";
|
|
1212
|
-
if (this.message.role === "assistant" && Array.isArray(this.message.toolCalls) && this.message.toolCalls.length > 0) {
|
|
1220
|
+
let o = this.message.role === "user", O = this.message.role === "activity";
|
|
1221
|
+
if (this.message.role === "assistant" && Array.isArray(this.message.toolCalls) && this.message.toolCalls.length > 0 || O && this.message.activityType === "a2ui") {
|
|
1213
1222
|
a2uiService.processMessages([this.message]);
|
|
1214
1223
|
let o = Array.from(a2uiService.processor.getSurfaces().entries()), O = a2uiService.processor;
|
|
1215
1224
|
if (o.length > 0) return b`
|
|
@@ -1280,7 +1289,7 @@ var ChatThread = class extends i {
|
|
|
1280
1289
|
</div>
|
|
1281
1290
|
` : b`
|
|
1282
1291
|
<div class="messages-list">
|
|
1283
|
-
${this.messages.filter((o) => o.role === "assistant" || o.role === "user" || o.role === "activity").map((o, O, M) => b`
|
|
1292
|
+
${this.messages.filter((o) => o.role === "assistant" || o.role === "user" || o.role === "activity" && o.activityType === "a2ui").map((o, O, M) => b`
|
|
1284
1293
|
<agent-chat-message
|
|
1285
1294
|
.message=${o}
|
|
1286
1295
|
.isLast=${O === M.length - 1}
|
|
@@ -3055,9 +3064,18 @@ var ChatPortalService = class o extends EventTarget {
|
|
|
3055
3064
|
this._visibleTargetIds = new Set(o), this.dispatchEvent(new CustomEvent("targets-updated", { detail: o }));
|
|
3056
3065
|
}
|
|
3057
3066
|
async executePlan(o) {
|
|
3058
|
-
if (o.type === "
|
|
3067
|
+
if (o.type === "plan") {
|
|
3068
|
+
let O = o.steps;
|
|
3069
|
+
console.log(`ChatPortalService: Executing multi-step plan with ${O.length} steps.`);
|
|
3070
|
+
for (let o of O) {
|
|
3071
|
+
let O = await this.executePlan(o);
|
|
3072
|
+
if (O.status === "error") return O;
|
|
3073
|
+
}
|
|
3074
|
+
return { status: "ok" };
|
|
3075
|
+
}
|
|
3076
|
+
if (o.type === "click" || o.type === "setValue") {
|
|
3059
3077
|
let O = o.targetId;
|
|
3060
|
-
if (console.log(`ChatPortalService: Waiting for
|
|
3078
|
+
if (console.log(`ChatPortalService: Waiting for target "${O}" for action "${o.type}"...`), !await this._waitForTarget(O)) return {
|
|
3061
3079
|
status: "error",
|
|
3062
3080
|
details: `Target "${O}" not found or not visible after timeout.`
|
|
3063
3081
|
};
|
|
@@ -3090,13 +3108,13 @@ var ChatSubscriber = class {
|
|
|
3090
3108
|
this.service = o;
|
|
3091
3109
|
}
|
|
3092
3110
|
onRunFinishedEvent(o) {
|
|
3093
|
-
inspectorService.addEvent("onRunFinishedEvent", o.event);
|
|
3111
|
+
inspectorService.addEvent("onRunFinishedEvent", o.event), this.service.cleanupThinkingPlaceholder();
|
|
3094
3112
|
}
|
|
3095
3113
|
onRunStartedEvent(o) {
|
|
3096
3114
|
inspectorService.addEvent("onRunStartedEvent", o.event), this.service.addPlaceholderMessage();
|
|
3097
3115
|
}
|
|
3098
3116
|
onRunErrorEvent(o) {
|
|
3099
|
-
inspectorService.addEvent("onRunErrorEvent", o.event), console.error("ChatSubscriber: Run Error", o.event);
|
|
3117
|
+
inspectorService.addEvent("onRunErrorEvent", o.event), console.error("ChatSubscriber: Run Error", o.event), this.service.cleanupThinkingPlaceholder();
|
|
3100
3118
|
}
|
|
3101
3119
|
onStepStartedEvent(o) {
|
|
3102
3120
|
inspectorService.addEvent("onStepStartedEvent", o.event);
|
|
@@ -3153,6 +3171,21 @@ var ChatSubscriber = class {
|
|
|
3153
3171
|
});
|
|
3154
3172
|
console.log("ChatSubscriber: click_element result", O);
|
|
3155
3173
|
}
|
|
3174
|
+
if (o.toolCallName === "set_value") {
|
|
3175
|
+
console.log("ChatSubscriber: Received set_value tool call", o.toolCallArgs);
|
|
3176
|
+
let O = await chatPortalService.executePlan({
|
|
3177
|
+
type: "setValue",
|
|
3178
|
+
targetId: o.toolCallArgs.target_id,
|
|
3179
|
+
value: o.toolCallArgs.value,
|
|
3180
|
+
reason: o.toolCallArgs.reason
|
|
3181
|
+
});
|
|
3182
|
+
console.log("ChatSubscriber: set_value result", O);
|
|
3183
|
+
}
|
|
3184
|
+
if (o.toolCallName === "execute_ui_plan" || o.toolCallName === "executePlan") {
|
|
3185
|
+
console.log("ChatSubscriber: Received UI plan tool call", o.toolCallArgs);
|
|
3186
|
+
let O = await chatPortalService.executePlan(o.toolCallArgs);
|
|
3187
|
+
console.log("ChatSubscriber: UI plan result", O);
|
|
3188
|
+
}
|
|
3156
3189
|
}
|
|
3157
3190
|
onToolCallResultEvent(o) {
|
|
3158
3191
|
inspectorService.addEvent("onToolCallResultEvent", o.event);
|
|
@@ -3164,7 +3197,12 @@ var ChatSubscriber = class {
|
|
|
3164
3197
|
inspectorService.addEvent("onStateDeltaEvent", o.event);
|
|
3165
3198
|
}
|
|
3166
3199
|
onActivitySnapshotEvent(o) {
|
|
3167
|
-
inspectorService.addEvent("onActivitySnapshotEvent", o.event), o.event.activityType == "a2ui" && o.event.content.surfaceUpdate ? this.service.addA2UIMessage(o.event) : o.event.activityType == "a2ui" && o.event.content.beginRendering ? a2uiService.processMessages([o.event.content]) :
|
|
3200
|
+
inspectorService.addEvent("onActivitySnapshotEvent", o.event), o.event.activityType == "a2ui" && o.event.content.surfaceUpdate ? this.service.addA2UIMessage(o.event) : o.event.activityType == "a2ui" && o.event.content.beginRendering ? a2uiService.processMessages([o.event.content]) : [
|
|
3201
|
+
"navigation",
|
|
3202
|
+
"click",
|
|
3203
|
+
"setValue",
|
|
3204
|
+
"plan"
|
|
3205
|
+
].includes(o.event.activityType) && chatPortalService.executePlan(o.event.content);
|
|
3168
3206
|
}
|
|
3169
3207
|
onActivityDeltaEvent(o) {
|
|
3170
3208
|
inspectorService.addEvent("onActivityDeltaEvent", o.event);
|
|
@@ -3363,10 +3401,7 @@ const chatService = new class extends EventTarget {
|
|
|
3363
3401
|
}
|
|
3364
3402
|
this.notify();
|
|
3365
3403
|
try {
|
|
3366
|
-
this.agent?.threadId == threadIdPlaceHolder && await this._ensureConversation(), this.agent.addMessage(U), this.agent.state = {
|
|
3367
|
-
appContext: this._appContext,
|
|
3368
|
-
appState: this._appState
|
|
3369
|
-
}, await this.agent.runAgent({ tools: [] }, this.subscriber);
|
|
3404
|
+
this.agent?.threadId == threadIdPlaceHolder && await this._ensureConversation(), this.agent.addMessage(U), this.agent.state = { appState: this._appState }, await this.agent.runAgent({ tools: [] }, this.subscriber);
|
|
3370
3405
|
} catch (o) {
|
|
3371
3406
|
console.error("Failed to send message", o);
|
|
3372
3407
|
} finally {
|
|
@@ -3389,7 +3424,12 @@ const chatService = new class extends EventTarget {
|
|
|
3389
3424
|
createdAt: Date.now(),
|
|
3390
3425
|
isThinking: !0
|
|
3391
3426
|
};
|
|
3392
|
-
this.agent.messages = [...this.agent.messages, o], this.notify();
|
|
3427
|
+
this.agent.messages = [...this.agent.messages || [], o], this.notify();
|
|
3428
|
+
}
|
|
3429
|
+
cleanupThinkingPlaceholder() {
|
|
3430
|
+
if (!this.agent) return;
|
|
3431
|
+
let o = this.agent.messages.filter((o) => o.id !== "thinking-placeholder");
|
|
3432
|
+
o.length !== this.agent.messages.length && (this.agent.messages = o, this.notify());
|
|
3393
3433
|
}
|
|
3394
3434
|
prepareMessageForStreaming(o) {
|
|
3395
3435
|
if (!this.agent) throw Error("Agent not initialized");
|
|
@@ -3431,6 +3471,9 @@ const chatService = new class extends EventTarget {
|
|
|
3431
3471
|
async startNewThread() {
|
|
3432
3472
|
localStorage.removeItem(STORAGE_THREAD_ID_KEY), this.agent && (this.agent.threadId = threadIdPlaceHolder, this.agent.messages = [], this.agent.isRunning = !1), this._suggestedPrompts.length > 0 && (this._showPrompts = !0), this.notify();
|
|
3433
3473
|
}
|
|
3474
|
+
async getConversations() {
|
|
3475
|
+
return await this.refreshConversations(), this._conversations;
|
|
3476
|
+
}
|
|
3434
3477
|
async refreshConversations() {
|
|
3435
3478
|
try {
|
|
3436
3479
|
this._conversations = (await conversationService.getConversations()).map((o) => ({
|
|
@@ -3508,6 +3551,9 @@ var ChatController = class {
|
|
|
3508
3551
|
refreshConversations() {
|
|
3509
3552
|
return chatService.refreshConversations();
|
|
3510
3553
|
}
|
|
3554
|
+
getConversations() {
|
|
3555
|
+
return chatService.getConversations();
|
|
3556
|
+
}
|
|
3511
3557
|
}, FetchInterceptorService = class {
|
|
3512
3558
|
constructor() {
|
|
3513
3559
|
this.originalFetch = window.fetch.bind(window), this._isEnabled = !1;
|