happy-imou-cloud 2.0.21 → 2.0.23
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/{BaseReasoningProcessor-0nj-PMFc.cjs → BaseReasoningProcessor-BzbDRBqp.cjs} +3 -3
- package/dist/{BaseReasoningProcessor-DnVC7liC.mjs → BaseReasoningProcessor-DH3BCCTf.mjs} +3 -3
- package/dist/ProviderSelectionHandler-CbkbtIRC.mjs +673 -0
- package/dist/ProviderSelectionHandler-meVvz9NZ.cjs +680 -0
- package/dist/{api-MGlKcEf3.cjs → api-C4bF6GEA.cjs} +35 -3
- package/dist/{api-DJe9WP9M.mjs → api-DX7Vg4Hz.mjs} +35 -4
- package/dist/{command-DAlFmWmr.cjs → command-CF6Wi_v2.cjs} +3 -3
- package/dist/{command-CfyFnMv2.mjs → command-DicPZ-Up.mjs} +3 -3
- package/dist/{index-CgVjDJpt.cjs → index-BybqdOf2.cjs} +63 -15
- package/dist/{index-CHXCgpwi.mjs → index-CEJmASSW.mjs} +60 -12
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +108 -105
- package/dist/lib.d.mts +108 -105
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-DLFUNI9q.cjs → persistence-CdqBfAwo.cjs} +1 -1
- package/dist/{persistence-CkP90vEt.mjs → persistence-xypxp7ei.mjs} +1 -1
- package/dist/{registerKillSessionHandler-Cs_INk4A.cjs → registerKillSessionHandler-BK3fZIch.cjs} +14 -364
- package/dist/{registerKillSessionHandler-DsHTZDsU.mjs → registerKillSessionHandler-BNN-_qNu.mjs} +15 -362
- package/dist/{runClaude-DAQAEmHe.mjs → runClaude-B-ex_tr3.mjs} +8 -6
- package/dist/{runClaude-BGSgcyUp.cjs → runClaude-CT3jCZjH.cjs} +11 -9
- package/dist/{runCodex-B2UpSn82.mjs → runCodex-DhbvUtJC.mjs} +9 -7
- package/dist/{runCodex-earICaxw.cjs → runCodex-DodH9jhh.cjs} +12 -10
- package/dist/{runGemini-BBUmH1Qh.mjs → runGemini-BsFR5Pd3.mjs} +12 -74
- package/dist/{runGemini-D5RAIaR0.cjs → runGemini-CeHCZ1l4.cjs} +12 -74
- package/package.json +1 -1
- package/dist/ProviderSelectionHandler-Bafuy28L.cjs +0 -265
- package/dist/ProviderSelectionHandler-R-2r7ItM.mjs +0 -261
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { l as logger } from './api-DJe9WP9M.mjs';
|
|
2
|
-
import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-DsHTZDsU.mjs';
|
|
3
|
-
|
|
4
|
-
async function runModeLoop(opts) {
|
|
5
|
-
let currentMode = opts.startingMode;
|
|
6
|
-
if (opts.notifyInitialMode) {
|
|
7
|
-
await opts.onModeChange?.(currentMode);
|
|
8
|
-
}
|
|
9
|
-
while (true) {
|
|
10
|
-
opts.onIteration?.(currentMode);
|
|
11
|
-
const result = await opts.launchers[currentMode]();
|
|
12
|
-
if (result.type === "exit") {
|
|
13
|
-
return result.value;
|
|
14
|
-
}
|
|
15
|
-
currentMode = result.mode;
|
|
16
|
-
await opts.onModeChange?.(currentMode);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function createKeepAliveController(opts) {
|
|
21
|
-
let thinking = opts.initialThinking ?? false;
|
|
22
|
-
let mode = opts.initialMode;
|
|
23
|
-
let disposed = false;
|
|
24
|
-
const sync = () => {
|
|
25
|
-
if (disposed) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
opts.send(thinking, mode);
|
|
29
|
-
};
|
|
30
|
-
sync();
|
|
31
|
-
const intervalId = setInterval(sync, opts.intervalMs ?? 2e3);
|
|
32
|
-
return {
|
|
33
|
-
dispose: () => {
|
|
34
|
-
if (disposed) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
disposed = true;
|
|
38
|
-
clearInterval(intervalId);
|
|
39
|
-
},
|
|
40
|
-
getMode: () => mode,
|
|
41
|
-
getThinking: () => thinking,
|
|
42
|
-
setMode: (nextMode) => {
|
|
43
|
-
mode = nextMode;
|
|
44
|
-
sync();
|
|
45
|
-
},
|
|
46
|
-
setThinking: (nextThinking) => {
|
|
47
|
-
thinking = nextThinking;
|
|
48
|
-
sync();
|
|
49
|
-
},
|
|
50
|
-
sync
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class ProviderSelectionHandler {
|
|
55
|
-
pendingRequests = /* @__PURE__ */ new Map();
|
|
56
|
-
session;
|
|
57
|
-
providerLabel;
|
|
58
|
-
constructor(session, providerLabel) {
|
|
59
|
-
this.session = session;
|
|
60
|
-
this.providerLabel = providerLabel;
|
|
61
|
-
this.setupRpcHandler();
|
|
62
|
-
}
|
|
63
|
-
updateSession(newSession) {
|
|
64
|
-
this.session = newSession;
|
|
65
|
-
this.setupRpcHandler();
|
|
66
|
-
}
|
|
67
|
-
async requestSelection(request) {
|
|
68
|
-
return new Promise((resolve, reject) => {
|
|
69
|
-
const pending = {
|
|
70
|
-
resolve,
|
|
71
|
-
reject,
|
|
72
|
-
request
|
|
73
|
-
};
|
|
74
|
-
pending.timeoutHandle = setTimeout(() => {
|
|
75
|
-
this.handleSelectionTimeout(request.id, pending);
|
|
76
|
-
}, getPendingInteractionTimeoutMs());
|
|
77
|
-
this.pendingRequests.set(request.id, pending);
|
|
78
|
-
this.session.updateAgentState((currentState) => ({
|
|
79
|
-
...currentState,
|
|
80
|
-
requests: {
|
|
81
|
-
...currentState.requests,
|
|
82
|
-
[request.id]: {
|
|
83
|
-
tool: "AskUserQuestion",
|
|
84
|
-
arguments: {
|
|
85
|
-
requestKind: "selection",
|
|
86
|
-
questions: [
|
|
87
|
-
{
|
|
88
|
-
header: this.providerLabel,
|
|
89
|
-
question: request.message,
|
|
90
|
-
multiSelect: false,
|
|
91
|
-
options: request.options.map((option) => ({
|
|
92
|
-
label: option.label,
|
|
93
|
-
description: option.description || option.optionId,
|
|
94
|
-
optionId: option.optionId
|
|
95
|
-
}))
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
},
|
|
99
|
-
createdAt: Date.now(),
|
|
100
|
-
requestKind: "selection",
|
|
101
|
-
options: request.options,
|
|
102
|
-
defaultOptionId: request.defaultOptionId
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}));
|
|
106
|
-
logger.debug(`[${this.providerLabel}] Selection request sent (${request.id}) with ${request.options.length} options`);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
hasPendingRequests() {
|
|
110
|
-
return this.pendingRequests.size > 0;
|
|
111
|
-
}
|
|
112
|
-
supersedePendingRequests(reason = INTERACTION_SUPERSEDED_ERROR) {
|
|
113
|
-
const pendingSnapshot = Array.from(this.pendingRequests.entries());
|
|
114
|
-
if (pendingSnapshot.length === 0) {
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
117
|
-
this.pendingRequests.clear();
|
|
118
|
-
const completedAt = Date.now();
|
|
119
|
-
for (const [, pending] of pendingSnapshot) {
|
|
120
|
-
this.clearPendingRequestTimeout(pending);
|
|
121
|
-
pending.reject(new Error(reason));
|
|
122
|
-
}
|
|
123
|
-
this.session.updateAgentState((currentState) => {
|
|
124
|
-
const requests = { ...currentState.requests || {} };
|
|
125
|
-
const completedRequests = { ...currentState.completedRequests || {} };
|
|
126
|
-
for (const [id, request] of Object.entries(requests)) {
|
|
127
|
-
if (request.requestKind !== "selection") {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
completedRequests[id] = {
|
|
131
|
-
...request,
|
|
132
|
-
completedAt,
|
|
133
|
-
status: "canceled",
|
|
134
|
-
reason,
|
|
135
|
-
requestKind: "selection"
|
|
136
|
-
};
|
|
137
|
-
delete requests[id];
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
...currentState,
|
|
141
|
-
requests,
|
|
142
|
-
completedRequests
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
logger.debug(`[${this.providerLabel}] Superseded ${pendingSnapshot.length} pending selection request(s)`);
|
|
146
|
-
return pendingSnapshot.length;
|
|
147
|
-
}
|
|
148
|
-
reset(reason = "Session reset") {
|
|
149
|
-
const pendingSnapshot = Array.from(this.pendingRequests.entries());
|
|
150
|
-
this.pendingRequests.clear();
|
|
151
|
-
for (const [, pending] of pendingSnapshot) {
|
|
152
|
-
this.clearPendingRequestTimeout(pending);
|
|
153
|
-
pending.reject(new Error(reason));
|
|
154
|
-
}
|
|
155
|
-
this.session.updateAgentState((currentState) => {
|
|
156
|
-
const requests = { ...currentState.requests || {} };
|
|
157
|
-
const completedRequests = { ...currentState.completedRequests || {} };
|
|
158
|
-
for (const [id, request] of Object.entries(requests)) {
|
|
159
|
-
if (request.requestKind !== "selection") {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
completedRequests[id] = {
|
|
163
|
-
...request,
|
|
164
|
-
completedAt: Date.now(),
|
|
165
|
-
status: "canceled",
|
|
166
|
-
reason,
|
|
167
|
-
requestKind: "selection"
|
|
168
|
-
};
|
|
169
|
-
delete requests[id];
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
...currentState,
|
|
173
|
-
requests,
|
|
174
|
-
completedRequests
|
|
175
|
-
};
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
setupRpcHandler() {
|
|
179
|
-
this.session.rpcHandlerManager.registerHandler("selection", async (response) => {
|
|
180
|
-
const pending = this.pendingRequests.get(response.id);
|
|
181
|
-
if (!pending) {
|
|
182
|
-
logger.debug(`[${this.providerLabel}] Selection request not found or already resolved`);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
this.pendingRequests.delete(response.id);
|
|
186
|
-
this.clearPendingRequestTimeout(pending);
|
|
187
|
-
pending.resolve(response);
|
|
188
|
-
this.session.updateAgentState((currentState) => {
|
|
189
|
-
const request = currentState.requests?.[response.id];
|
|
190
|
-
if (!request) {
|
|
191
|
-
return currentState;
|
|
192
|
-
}
|
|
193
|
-
const { [response.id]: _, ...remainingRequests } = currentState.requests || {};
|
|
194
|
-
return {
|
|
195
|
-
...currentState,
|
|
196
|
-
requests: remainingRequests,
|
|
197
|
-
completedRequests: {
|
|
198
|
-
...currentState.completedRequests,
|
|
199
|
-
[response.id]: {
|
|
200
|
-
...request,
|
|
201
|
-
completedAt: Date.now(),
|
|
202
|
-
status: "approved",
|
|
203
|
-
requestKind: "selection",
|
|
204
|
-
selectedOptionId: response.optionId
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
clearPendingRequestTimeout(pending) {
|
|
212
|
-
if (pending?.timeoutHandle) {
|
|
213
|
-
clearTimeout(pending.timeoutHandle);
|
|
214
|
-
pending.timeoutHandle = void 0;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
handleSelectionTimeout(requestId, pending) {
|
|
218
|
-
const active = this.pendingRequests.get(requestId);
|
|
219
|
-
if (!active || active !== pending) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
this.pendingRequests.delete(requestId);
|
|
223
|
-
this.clearPendingRequestTimeout(active);
|
|
224
|
-
active.reject(new Error(INTERACTION_TIMED_OUT_ERROR));
|
|
225
|
-
this.session.updateAgentState((currentState) => {
|
|
226
|
-
const request = currentState.requests?.[requestId] || {
|
|
227
|
-
tool: "AskUserQuestion",
|
|
228
|
-
arguments: {
|
|
229
|
-
requestKind: "selection",
|
|
230
|
-
questions: []
|
|
231
|
-
},
|
|
232
|
-
createdAt: Date.now(),
|
|
233
|
-
requestKind: "selection",
|
|
234
|
-
options: active.request.options,
|
|
235
|
-
defaultOptionId: active.request.defaultOptionId
|
|
236
|
-
};
|
|
237
|
-
const { [requestId]: _, ...remainingRequests } = currentState.requests || {};
|
|
238
|
-
return {
|
|
239
|
-
...currentState,
|
|
240
|
-
requests: remainingRequests,
|
|
241
|
-
completedRequests: {
|
|
242
|
-
...currentState.completedRequests,
|
|
243
|
-
[requestId]: {
|
|
244
|
-
...request,
|
|
245
|
-
completedAt: Date.now(),
|
|
246
|
-
status: "canceled",
|
|
247
|
-
reason: INTERACTION_TIMED_OUT_ERROR,
|
|
248
|
-
requestKind: "selection"
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
});
|
|
253
|
-
this.session.sendSessionEvent({
|
|
254
|
-
type: "message",
|
|
255
|
-
message: "Pending interaction timed out waiting for a response. Send a new message to continue."
|
|
256
|
-
});
|
|
257
|
-
logger.debug(`[${this.providerLabel}] Selection request timed out (${requestId})`);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export { ProviderSelectionHandler as P, createKeepAliveController as c, runModeLoop as r };
|