happy-imou-cloud 2.1.1 → 2.1.2
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/bin/happy-cloud.mjs +21 -21
- package/compat/acp-sdk-schema/index.js +27 -27
- package/compat/acp-sdk-schema/types.gen.js +2 -2
- package/compat/acp-sdk-schema/zod.gen.js +1553 -1553
- package/compat/ink-build/components/Cursor.d.ts +83 -83
- package/compat/ink-build/components/Cursor.js +52 -52
- package/compat/ink-build/components/CursorContext.d.ts +11 -11
- package/compat/ink-build/components/CursorContext.js +7 -7
- package/compat/ink-build/components/ErrorBoundary.d.ts +18 -18
- package/compat/ink-build/components/ErrorBoundary.js +22 -22
- package/compat/ink-build/hooks/use-cursor.d.ts +12 -12
- package/compat/ink-build/hooks/use-cursor.js +28 -28
- package/dist/{BaseReasoningProcessor-Dn9FxfxU.mjs → BaseReasoningProcessor-BaOWkVcu.mjs} +3 -3
- package/dist/{BaseReasoningProcessor-CBMK-8Gi.cjs → BaseReasoningProcessor-CzvqwxuY.cjs} +3 -3
- package/dist/ProviderSelectionHandler-Q8pl7e-d.mjs +261 -0
- package/dist/ProviderSelectionHandler-wwbfeK_s.cjs +265 -0
- package/dist/{api-DBy5lPZw.mjs → api-Cxifhw5r.mjs} +3 -3
- package/dist/{api-DId_j3C2.cjs → api-DZimmN4C.cjs} +2 -2
- package/dist/{command-CeaBwYCW.mjs → command-B6LM3Nml.mjs} +3 -3
- package/dist/{command-DwfUpmId.cjs → command-RcCJI1jl.cjs} +3 -3
- package/dist/{index-CuuYSKiv.cjs → index-Cuvs0lFS.cjs} +168 -75
- package/dist/{index-66vjECEd.mjs → index-Des7I5WX.mjs} +165 -72
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +36 -36
- package/dist/lib.d.mts +36 -36
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-BOWh1NER.mjs → persistence-6d4U4Sh8.mjs} +1 -1
- package/dist/{persistence-Dzr6sFwD.cjs → persistence-C8-MtdQK.cjs} +1 -1
- package/dist/{registerKillSessionHandler-D4_wpN18.mjs → registerKillSessionHandler-BFBkz_XT.mjs} +417 -5
- package/dist/{registerKillSessionHandler-Dg_iRBPm.cjs → registerKillSessionHandler-BapPCRmp.cjs} +419 -4
- package/dist/{runClaude-B74dHAnQ.mjs → runClaude-CPV5Uap2.mjs} +34 -5
- package/dist/{runClaude-oIFzkfuU.cjs → runClaude-DVnqKa1q.cjs} +37 -8
- package/dist/{runCodex-D_9CuL6M.cjs → runCodex-Bzsp8gFO.cjs} +29 -21
- package/dist/{runCodex-mLHjsgVj.mjs → runCodex-CwtLSTMJ.mjs} +26 -18
- package/dist/{runGemini-CcWGezMt.cjs → runGemini-6Dwyk_Km.cjs} +267 -82
- package/dist/{runGemini-BMiho2ab.mjs → runGemini-Bmoxehlh.mjs} +267 -82
- package/package.json +9 -9
- package/scripts/build.mjs +68 -68
- package/scripts/ensureAcpSdkCompat.mjs +170 -172
- package/scripts/release-smoke.mjs +38 -35
- package/dist/ProviderSelectionHandler-BuXk-8ji.cjs +0 -680
- package/dist/ProviderSelectionHandler-CMaQThYO.mjs +0 -673
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { l as logger } from './api-Cxifhw5r.mjs';
|
|
2
|
+
import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-BFBkz_XT.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 };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var api = require('./api-DZimmN4C.cjs');
|
|
4
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-BapPCRmp.cjs');
|
|
5
|
+
|
|
6
|
+
async function runModeLoop(opts) {
|
|
7
|
+
let currentMode = opts.startingMode;
|
|
8
|
+
if (opts.notifyInitialMode) {
|
|
9
|
+
await opts.onModeChange?.(currentMode);
|
|
10
|
+
}
|
|
11
|
+
while (true) {
|
|
12
|
+
opts.onIteration?.(currentMode);
|
|
13
|
+
const result = await opts.launchers[currentMode]();
|
|
14
|
+
if (result.type === "exit") {
|
|
15
|
+
return result.value;
|
|
16
|
+
}
|
|
17
|
+
currentMode = result.mode;
|
|
18
|
+
await opts.onModeChange?.(currentMode);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createKeepAliveController(opts) {
|
|
23
|
+
let thinking = opts.initialThinking ?? false;
|
|
24
|
+
let mode = opts.initialMode;
|
|
25
|
+
let disposed = false;
|
|
26
|
+
const sync = () => {
|
|
27
|
+
if (disposed) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
opts.send(thinking, mode);
|
|
31
|
+
};
|
|
32
|
+
sync();
|
|
33
|
+
const intervalId = setInterval(sync, opts.intervalMs ?? 2e3);
|
|
34
|
+
return {
|
|
35
|
+
dispose: () => {
|
|
36
|
+
if (disposed) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
disposed = true;
|
|
40
|
+
clearInterval(intervalId);
|
|
41
|
+
},
|
|
42
|
+
getMode: () => mode,
|
|
43
|
+
getThinking: () => thinking,
|
|
44
|
+
setMode: (nextMode) => {
|
|
45
|
+
mode = nextMode;
|
|
46
|
+
sync();
|
|
47
|
+
},
|
|
48
|
+
setThinking: (nextThinking) => {
|
|
49
|
+
thinking = nextThinking;
|
|
50
|
+
sync();
|
|
51
|
+
},
|
|
52
|
+
sync
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class ProviderSelectionHandler {
|
|
57
|
+
pendingRequests = /* @__PURE__ */ new Map();
|
|
58
|
+
session;
|
|
59
|
+
providerLabel;
|
|
60
|
+
constructor(session, providerLabel) {
|
|
61
|
+
this.session = session;
|
|
62
|
+
this.providerLabel = providerLabel;
|
|
63
|
+
this.setupRpcHandler();
|
|
64
|
+
}
|
|
65
|
+
updateSession(newSession) {
|
|
66
|
+
this.session = newSession;
|
|
67
|
+
this.setupRpcHandler();
|
|
68
|
+
}
|
|
69
|
+
async requestSelection(request) {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const pending = {
|
|
72
|
+
resolve,
|
|
73
|
+
reject,
|
|
74
|
+
request
|
|
75
|
+
};
|
|
76
|
+
pending.timeoutHandle = setTimeout(() => {
|
|
77
|
+
this.handleSelectionTimeout(request.id, pending);
|
|
78
|
+
}, registerKillSessionHandler.getPendingInteractionTimeoutMs());
|
|
79
|
+
this.pendingRequests.set(request.id, pending);
|
|
80
|
+
this.session.updateAgentState((currentState) => ({
|
|
81
|
+
...currentState,
|
|
82
|
+
requests: {
|
|
83
|
+
...currentState.requests,
|
|
84
|
+
[request.id]: {
|
|
85
|
+
tool: "AskUserQuestion",
|
|
86
|
+
arguments: {
|
|
87
|
+
requestKind: "selection",
|
|
88
|
+
questions: [
|
|
89
|
+
{
|
|
90
|
+
header: this.providerLabel,
|
|
91
|
+
question: request.message,
|
|
92
|
+
multiSelect: false,
|
|
93
|
+
options: request.options.map((option) => ({
|
|
94
|
+
label: option.label,
|
|
95
|
+
description: option.description || option.optionId,
|
|
96
|
+
optionId: option.optionId
|
|
97
|
+
}))
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
createdAt: Date.now(),
|
|
102
|
+
requestKind: "selection",
|
|
103
|
+
options: request.options,
|
|
104
|
+
defaultOptionId: request.defaultOptionId
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
api.logger.debug(`[${this.providerLabel}] Selection request sent (${request.id}) with ${request.options.length} options`);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
hasPendingRequests() {
|
|
112
|
+
return this.pendingRequests.size > 0;
|
|
113
|
+
}
|
|
114
|
+
supersedePendingRequests(reason = registerKillSessionHandler.INTERACTION_SUPERSEDED_ERROR) {
|
|
115
|
+
const pendingSnapshot = Array.from(this.pendingRequests.entries());
|
|
116
|
+
if (pendingSnapshot.length === 0) {
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
this.pendingRequests.clear();
|
|
120
|
+
const completedAt = Date.now();
|
|
121
|
+
for (const [, pending] of pendingSnapshot) {
|
|
122
|
+
this.clearPendingRequestTimeout(pending);
|
|
123
|
+
pending.reject(new Error(reason));
|
|
124
|
+
}
|
|
125
|
+
this.session.updateAgentState((currentState) => {
|
|
126
|
+
const requests = { ...currentState.requests || {} };
|
|
127
|
+
const completedRequests = { ...currentState.completedRequests || {} };
|
|
128
|
+
for (const [id, request] of Object.entries(requests)) {
|
|
129
|
+
if (request.requestKind !== "selection") {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
completedRequests[id] = {
|
|
133
|
+
...request,
|
|
134
|
+
completedAt,
|
|
135
|
+
status: "canceled",
|
|
136
|
+
reason,
|
|
137
|
+
requestKind: "selection"
|
|
138
|
+
};
|
|
139
|
+
delete requests[id];
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...currentState,
|
|
143
|
+
requests,
|
|
144
|
+
completedRequests
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
api.logger.debug(`[${this.providerLabel}] Superseded ${pendingSnapshot.length} pending selection request(s)`);
|
|
148
|
+
return pendingSnapshot.length;
|
|
149
|
+
}
|
|
150
|
+
reset(reason = "Session reset") {
|
|
151
|
+
const pendingSnapshot = Array.from(this.pendingRequests.entries());
|
|
152
|
+
this.pendingRequests.clear();
|
|
153
|
+
for (const [, pending] of pendingSnapshot) {
|
|
154
|
+
this.clearPendingRequestTimeout(pending);
|
|
155
|
+
pending.reject(new Error(reason));
|
|
156
|
+
}
|
|
157
|
+
this.session.updateAgentState((currentState) => {
|
|
158
|
+
const requests = { ...currentState.requests || {} };
|
|
159
|
+
const completedRequests = { ...currentState.completedRequests || {} };
|
|
160
|
+
for (const [id, request] of Object.entries(requests)) {
|
|
161
|
+
if (request.requestKind !== "selection") {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
completedRequests[id] = {
|
|
165
|
+
...request,
|
|
166
|
+
completedAt: Date.now(),
|
|
167
|
+
status: "canceled",
|
|
168
|
+
reason,
|
|
169
|
+
requestKind: "selection"
|
|
170
|
+
};
|
|
171
|
+
delete requests[id];
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
...currentState,
|
|
175
|
+
requests,
|
|
176
|
+
completedRequests
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
setupRpcHandler() {
|
|
181
|
+
this.session.rpcHandlerManager.registerHandler("selection", async (response) => {
|
|
182
|
+
const pending = this.pendingRequests.get(response.id);
|
|
183
|
+
if (!pending) {
|
|
184
|
+
api.logger.debug(`[${this.providerLabel}] Selection request not found or already resolved`);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.pendingRequests.delete(response.id);
|
|
188
|
+
this.clearPendingRequestTimeout(pending);
|
|
189
|
+
pending.resolve(response);
|
|
190
|
+
this.session.updateAgentState((currentState) => {
|
|
191
|
+
const request = currentState.requests?.[response.id];
|
|
192
|
+
if (!request) {
|
|
193
|
+
return currentState;
|
|
194
|
+
}
|
|
195
|
+
const { [response.id]: _, ...remainingRequests } = currentState.requests || {};
|
|
196
|
+
return {
|
|
197
|
+
...currentState,
|
|
198
|
+
requests: remainingRequests,
|
|
199
|
+
completedRequests: {
|
|
200
|
+
...currentState.completedRequests,
|
|
201
|
+
[response.id]: {
|
|
202
|
+
...request,
|
|
203
|
+
completedAt: Date.now(),
|
|
204
|
+
status: "approved",
|
|
205
|
+
requestKind: "selection",
|
|
206
|
+
selectedOptionId: response.optionId
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
clearPendingRequestTimeout(pending) {
|
|
214
|
+
if (pending?.timeoutHandle) {
|
|
215
|
+
clearTimeout(pending.timeoutHandle);
|
|
216
|
+
pending.timeoutHandle = void 0;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
handleSelectionTimeout(requestId, pending) {
|
|
220
|
+
const active = this.pendingRequests.get(requestId);
|
|
221
|
+
if (!active || active !== pending) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this.pendingRequests.delete(requestId);
|
|
225
|
+
this.clearPendingRequestTimeout(active);
|
|
226
|
+
active.reject(new Error(registerKillSessionHandler.INTERACTION_TIMED_OUT_ERROR));
|
|
227
|
+
this.session.updateAgentState((currentState) => {
|
|
228
|
+
const request = currentState.requests?.[requestId] || {
|
|
229
|
+
tool: "AskUserQuestion",
|
|
230
|
+
arguments: {
|
|
231
|
+
requestKind: "selection",
|
|
232
|
+
questions: []
|
|
233
|
+
},
|
|
234
|
+
createdAt: Date.now(),
|
|
235
|
+
requestKind: "selection",
|
|
236
|
+
options: active.request.options,
|
|
237
|
+
defaultOptionId: active.request.defaultOptionId
|
|
238
|
+
};
|
|
239
|
+
const { [requestId]: _, ...remainingRequests } = currentState.requests || {};
|
|
240
|
+
return {
|
|
241
|
+
...currentState,
|
|
242
|
+
requests: remainingRequests,
|
|
243
|
+
completedRequests: {
|
|
244
|
+
...currentState.completedRequests,
|
|
245
|
+
[requestId]: {
|
|
246
|
+
...request,
|
|
247
|
+
completedAt: Date.now(),
|
|
248
|
+
status: "canceled",
|
|
249
|
+
reason: registerKillSessionHandler.INTERACTION_TIMED_OUT_ERROR,
|
|
250
|
+
requestKind: "selection"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
this.session.sendSessionEvent({
|
|
256
|
+
type: "message",
|
|
257
|
+
message: "Pending interaction timed out waiting for a response. Send a new message to continue."
|
|
258
|
+
});
|
|
259
|
+
api.logger.debug(`[${this.providerLabel}] Selection request timed out (${requestId})`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
exports.ProviderSelectionHandler = ProviderSelectionHandler;
|
|
264
|
+
exports.createKeepAliveController = createKeepAliveController;
|
|
265
|
+
exports.runModeLoop = runModeLoop;
|
|
@@ -16,7 +16,7 @@ import { spawn } from 'node:child_process';
|
|
|
16
16
|
import { Expo } from 'expo-server-sdk';
|
|
17
17
|
|
|
18
18
|
var name = "happy-imou-cloud";
|
|
19
|
-
var version = "2.1.
|
|
19
|
+
var version = "2.1.2";
|
|
20
20
|
var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
|
|
21
21
|
var author = "long.zhu";
|
|
22
22
|
var license = "MIT";
|
|
@@ -431,7 +431,7 @@ async function listDaemonLogFiles(limit = 50) {
|
|
|
431
431
|
return { file, path: fullPath, modified: stats.mtime };
|
|
432
432
|
}).sort((a, b) => b.modified.getTime() - a.modified.getTime());
|
|
433
433
|
try {
|
|
434
|
-
const { readDaemonState } = await import('./persistence-
|
|
434
|
+
const { readDaemonState } = await import('./persistence-6d4U4Sh8.mjs');
|
|
435
435
|
const state = await readDaemonState();
|
|
436
436
|
if (!state) {
|
|
437
437
|
return logs;
|
|
@@ -3645,4 +3645,4 @@ var api = /*#__PURE__*/Object.freeze({
|
|
|
3645
3645
|
ApiClient: ApiClient
|
|
3646
3646
|
});
|
|
3647
3647
|
|
|
3648
|
-
export { ApiClient as A,
|
|
3648
|
+
export { ApiClient as A, HAPPY_ORG_TURN_REPORT_TAG as H, SigningBootstrapRequiredError as S, ApiSessionClient as a, connectionState as b, configuration as c, HAPPY_ORG_SUMMARY_MAX_LENGTH as d, encodeBase64 as e, HAPPY_ORG_REPEAT_THRESHOLD as f, backoff as g, delay as h, isAuthenticationRequiredError as i, AsyncLock as j, buildAuthenticatedHeaders as k, logger as l, SIGNING_BOOTSTRAP_REQUIRED_MESSAGE as m, encodeBase64Url as n, buildClientHeaders as o, packageJson as p, decodeBase64 as q, HAPPY_CLOUD_DAEMON_PORT as r, startOfflineReconnection as s, HeadTailPreviewBuffer as t, getLatestDaemonLog as u, api as v };
|
|
@@ -18,7 +18,7 @@ var node_child_process = require('node:child_process');
|
|
|
18
18
|
var expoServerSdk = require('expo-server-sdk');
|
|
19
19
|
|
|
20
20
|
var name = "happy-imou-cloud";
|
|
21
|
-
var version = "2.1.
|
|
21
|
+
var version = "2.1.2";
|
|
22
22
|
var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
|
|
23
23
|
var author = "long.zhu";
|
|
24
24
|
var license = "MIT";
|
|
@@ -433,7 +433,7 @@ async function listDaemonLogFiles(limit = 50) {
|
|
|
433
433
|
return { file, path: fullPath, modified: stats.mtime };
|
|
434
434
|
}).sort((a, b) => b.modified.getTime() - a.modified.getTime());
|
|
435
435
|
try {
|
|
436
|
-
const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-
|
|
436
|
+
const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-C8-MtdQK.cjs'); });
|
|
437
437
|
const state = await readDaemonState();
|
|
438
438
|
if (!state) {
|
|
439
439
|
return logs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as createDefaultRuntimeShell } from './index-
|
|
1
|
+
import { c as createDefaultRuntimeShell } from './index-Des7I5WX.mjs';
|
|
2
2
|
import 'chalk';
|
|
3
|
-
import './api-
|
|
3
|
+
import './api-Cxifhw5r.mjs';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'node:fs';
|
|
@@ -16,7 +16,7 @@ import 'crypto';
|
|
|
16
16
|
import 'path';
|
|
17
17
|
import 'node:child_process';
|
|
18
18
|
import 'expo-server-sdk';
|
|
19
|
-
import './persistence-
|
|
19
|
+
import './persistence-6d4U4Sh8.mjs';
|
|
20
20
|
import 'node:fs/promises';
|
|
21
21
|
import 'os';
|
|
22
22
|
import 'tmp';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cuvs0lFS.cjs');
|
|
4
4
|
require('chalk');
|
|
5
|
-
require('./api-
|
|
5
|
+
require('./api-DZimmN4C.cjs');
|
|
6
6
|
require('axios');
|
|
7
7
|
require('fs');
|
|
8
8
|
require('node:fs');
|
|
@@ -18,7 +18,7 @@ require('crypto');
|
|
|
18
18
|
require('path');
|
|
19
19
|
require('node:child_process');
|
|
20
20
|
require('expo-server-sdk');
|
|
21
|
-
require('./persistence-
|
|
21
|
+
require('./persistence-C8-MtdQK.cjs');
|
|
22
22
|
require('node:fs/promises');
|
|
23
23
|
require('os');
|
|
24
24
|
require('tmp');
|