happy-imou-cloud 1.1.6 → 2.0.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.
Files changed (36) hide show
  1. package/dist/{setupOfflineReconnection-B15b9tE7.mjs → BaseReasoningProcessor-BKLRCKTU.mjs} +133 -90
  2. package/dist/{setupOfflineReconnection-D2mAyajw.cjs → BaseReasoningProcessor-BRCQXCZY.cjs} +134 -90
  3. package/dist/{types-DY1-MAPO.mjs → api-BGXYX0yH.mjs} +397 -235
  4. package/dist/{types-DSQA_cBn.cjs → api-D7OK-mML.cjs} +419 -256
  5. package/dist/command-CnLtKtP-.mjs +51 -0
  6. package/dist/command-G85giEAF.cjs +54 -0
  7. package/dist/future-Dq4Ha1Dn.cjs +24 -0
  8. package/dist/future-xRdLl3vf.mjs +22 -0
  9. package/dist/{index-BJ0xEdNB.cjs → index-B_wlQBy2.cjs} +5518 -7115
  10. package/dist/{index-B3bkHdEU.mjs → index-C7Y0R-MI.mjs} +5471 -7080
  11. package/dist/index.cjs +19 -21
  12. package/dist/index.mjs +19 -21
  13. package/dist/lib.cjs +3 -2
  14. package/dist/lib.d.cts +49 -24
  15. package/dist/lib.d.mts +49 -24
  16. package/dist/lib.mjs +2 -1
  17. package/dist/{persistence-DS4-Wbnm.mjs → persistence-BA_unuca.mjs} +20 -6
  18. package/dist/{persistence-DW_z9Bsh.cjs → persistence-DHgf1CTG.cjs} +22 -8
  19. package/dist/registerKillSessionHandler-C2-yHm1V.mjs +428 -0
  20. package/dist/registerKillSessionHandler-CLREXN11.cjs +433 -0
  21. package/dist/runClaude-CwAitpX-.cjs +3274 -0
  22. package/dist/runClaude-uNC5Eym4.mjs +3271 -0
  23. package/dist/runCodex-B-05E-YZ.mjs +1846 -0
  24. package/dist/runCodex-Cm0VTqw_.cjs +1848 -0
  25. package/dist/{runGemini-81Ogay0E.cjs → runGemini-CLWjwDYS.cjs} +25 -1366
  26. package/dist/{runGemini-D1DZS8IL.mjs → runGemini-_biXvQAH.mjs} +12 -1353
  27. package/dist/types-CiliQpqS.mjs +52 -0
  28. package/dist/types-DVk3crez.cjs +54 -0
  29. package/package.json +13 -12
  30. package/scripts/devtools/README.md +9 -0
  31. package/scripts/devtools/generate-mock-credentials.ts +94 -0
  32. package/scripts/release-smoke.mjs +62 -0
  33. package/dist/config-C4c3eRAq.mjs +0 -173
  34. package/dist/config-DSI9r8Jl.cjs +0 -183
  35. package/dist/runCodex-BCgor8vK.cjs +0 -1143
  36. package/dist/runCodex-DHo2-Vmd.mjs +0 -1140
@@ -1,9 +1,99 @@
1
- import { l as logger, c as configuration, p as packageJson, s as startOfflineReconnection } from './types-DY1-MAPO.mjs';
2
- import { randomUUID } from 'node:crypto';
3
1
  import os from 'node:os';
4
2
  import { resolve } from 'node:path';
5
- import { p as projectPath } from './index-B3bkHdEU.mjs';
3
+ import { c as configuration, p as packageJson, s as startOfflineReconnection, l as logger } from './api-BGXYX0yH.mjs';
4
+ import { p as projectPath } from './index-C7Y0R-MI.mjs';
5
+ import { randomUUID } from 'node:crypto';
6
+
7
+ function createSessionMetadata(opts) {
8
+ const state = {
9
+ controlledByUser: false
10
+ };
11
+ const metadata = {
12
+ path: process.cwd(),
13
+ host: os.hostname(),
14
+ version: packageJson.version,
15
+ os: os.platform(),
16
+ machineId: opts.machineId,
17
+ homeDir: os.homedir(),
18
+ happyHomeDir: configuration.happyCloudHomeDir,
19
+ happyLibDir: projectPath(),
20
+ happyToolsDir: resolve(projectPath(), "tools", "unpacked"),
21
+ startedFromDaemon: opts.startedBy === "daemon",
22
+ hostPid: process.pid,
23
+ startedBy: opts.startedBy || "terminal",
24
+ lifecycleState: "running",
25
+ lifecycleStateSince: Date.now(),
26
+ flavor: opts.flavor
27
+ };
28
+ return { state, metadata };
29
+ }
30
+
31
+ function createOfflineSessionStub(sessionTag) {
32
+ return {
33
+ sessionId: `offline-${sessionTag}`,
34
+ sendCodexMessage: () => {
35
+ },
36
+ sendAgentMessage: () => {
37
+ },
38
+ sendClaudeSessionMessage: () => {
39
+ },
40
+ keepAlive: () => {
41
+ },
42
+ sendSessionEvent: () => {
43
+ },
44
+ sendSessionDeath: () => {
45
+ },
46
+ updateLifecycleState: () => {
47
+ },
48
+ requestControlTransfer: async () => {
49
+ },
50
+ flush: async () => {
51
+ },
52
+ close: async () => {
53
+ },
54
+ updateMetadata: () => {
55
+ },
56
+ updateAgentState: () => {
57
+ },
58
+ getMetadataSnapshot: () => null,
59
+ getAgentStateSnapshot: () => null,
60
+ waitForMetadataUpdate: async () => null,
61
+ onUserMessage: () => {
62
+ },
63
+ rpcHandlerManager: {
64
+ registerHandler: () => {
65
+ }
66
+ }
67
+ };
68
+ }
69
+
70
+ function setupOfflineReconnection(opts) {
71
+ const { api, sessionTag, metadata, state, response, onSessionSwap } = opts;
72
+ let session;
73
+ let reconnectionHandle = null;
74
+ if (!response) {
75
+ session = createOfflineSessionStub(sessionTag);
76
+ reconnectionHandle = startOfflineReconnection({
77
+ serverUrl: configuration.serverUrl,
78
+ onReconnected: async () => {
79
+ const resp = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
80
+ if (!resp) throw new Error("Server unavailable");
81
+ const realSession = api.sessionSyncClient(resp);
82
+ onSessionSwap(realSession);
83
+ return realSession;
84
+ },
85
+ onNotify: (msg) => {
86
+ console.log(msg);
87
+ }
88
+ });
89
+ return { session, reconnectionHandle, isOffline: true };
90
+ } else {
91
+ session = api.sessionSyncClient(response);
92
+ return { session, reconnectionHandle: null, isOffline: false };
93
+ }
94
+ }
6
95
 
96
+ const INTERACTION_SUPERSEDED_ERROR = "Interaction superseded by new user message";
7
97
  class BasePermissionHandler {
8
98
  pendingRequests = /* @__PURE__ */ new Map();
9
99
  session;
@@ -75,6 +165,45 @@ class BasePermissionHandler {
75
165
  }
76
166
  }));
77
167
  }
168
+ hasPendingRequests() {
169
+ return this.pendingRequests.size > 0;
170
+ }
171
+ supersedePendingRequests(reason = INTERACTION_SUPERSEDED_ERROR) {
172
+ const pendingSnapshot = Array.from(this.pendingRequests.entries());
173
+ if (pendingSnapshot.length === 0) {
174
+ return 0;
175
+ }
176
+ this.pendingRequests.clear();
177
+ const completedAt = Date.now();
178
+ for (const [, pending] of pendingSnapshot) {
179
+ pending.resolve({ decision: "abort" });
180
+ }
181
+ this.session.updateAgentState((currentState) => {
182
+ const requests = { ...currentState.requests || {} };
183
+ const completedRequests = { ...currentState.completedRequests || {} };
184
+ for (const [id, request] of Object.entries(requests)) {
185
+ if (request.requestKind === "selection") {
186
+ continue;
187
+ }
188
+ completedRequests[id] = {
189
+ ...request,
190
+ completedAt,
191
+ status: "denied",
192
+ reason,
193
+ decision: "abort",
194
+ requestKind: request.requestKind || "permission"
195
+ };
196
+ delete requests[id];
197
+ }
198
+ return {
199
+ ...currentState,
200
+ requests,
201
+ completedRequests
202
+ };
203
+ });
204
+ logger.debug(`${this.getLogPrefix()} Superseded ${pendingSnapshot.length} pending permission request(s)`);
205
+ return pendingSnapshot.length;
206
+ }
78
207
  /**
79
208
  * Reset state for new sessions.
80
209
  * This method is idempotent - safe to call multiple times.
@@ -313,90 +442,4 @@ class BaseReasoningProcessor {
313
442
  }
314
443
  }
315
444
 
316
- function createSessionMetadata(opts) {
317
- const state = {
318
- controlledByUser: false
319
- };
320
- const metadata = {
321
- path: process.cwd(),
322
- host: os.hostname(),
323
- version: packageJson.version,
324
- os: os.platform(),
325
- machineId: opts.machineId,
326
- homeDir: os.homedir(),
327
- happyHomeDir: configuration.happyCloudHomeDir,
328
- happyLibDir: projectPath(),
329
- happyToolsDir: resolve(projectPath(), "tools", "unpacked"),
330
- startedFromDaemon: opts.startedBy === "daemon",
331
- hostPid: process.pid,
332
- startedBy: opts.startedBy || "terminal",
333
- lifecycleState: "running",
334
- lifecycleStateSince: Date.now(),
335
- flavor: opts.flavor
336
- };
337
- return { state, metadata };
338
- }
339
-
340
- function createOfflineSessionStub(sessionTag) {
341
- return {
342
- sessionId: `offline-${sessionTag}`,
343
- sendCodexMessage: () => {
344
- },
345
- sendAgentMessage: () => {
346
- },
347
- sendClaudeSessionMessage: () => {
348
- },
349
- keepAlive: () => {
350
- },
351
- sendSessionEvent: () => {
352
- },
353
- sendSessionDeath: () => {
354
- },
355
- updateLifecycleState: () => {
356
- },
357
- requestControlTransfer: async () => {
358
- },
359
- flush: async () => {
360
- },
361
- close: async () => {
362
- },
363
- updateMetadata: () => {
364
- },
365
- updateAgentState: () => {
366
- },
367
- onUserMessage: () => {
368
- },
369
- rpcHandlerManager: {
370
- registerHandler: () => {
371
- }
372
- }
373
- };
374
- }
375
-
376
- function setupOfflineReconnection(opts) {
377
- const { api, sessionTag, metadata, state, response, onSessionSwap } = opts;
378
- let session;
379
- let reconnectionHandle = null;
380
- if (!response) {
381
- session = createOfflineSessionStub(sessionTag);
382
- reconnectionHandle = startOfflineReconnection({
383
- serverUrl: configuration.serverUrl,
384
- onReconnected: async () => {
385
- const resp = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
386
- if (!resp) throw new Error("Server unavailable");
387
- const realSession = api.sessionSyncClient(resp);
388
- onSessionSwap(realSession);
389
- return realSession;
390
- },
391
- onNotify: (msg) => {
392
- console.log(msg);
393
- }
394
- });
395
- return { session, reconnectionHandle, isOffline: true };
396
- } else {
397
- session = api.sessionSyncClient(response);
398
- return { session, reconnectionHandle: null, isOffline: false };
399
- }
400
- }
401
-
402
- export { BasePermissionHandler as B, BaseReasoningProcessor as a, createSessionMetadata as c, setupOfflineReconnection as s };
445
+ export { BasePermissionHandler as B, INTERACTION_SUPERSEDED_ERROR as I, BaseReasoningProcessor as a, createSessionMetadata as c, setupOfflineReconnection as s };
@@ -1,11 +1,101 @@
1
1
  'use strict';
2
2
 
3
- var api = require('./types-DSQA_cBn.cjs');
4
- var node_crypto = require('node:crypto');
5
3
  var os = require('node:os');
6
- var node_path = require('node:path');
7
- var index = require('./index-BJ0xEdNB.cjs');
4
+ var path = require('node:path');
5
+ var api = require('./api-D7OK-mML.cjs');
6
+ var index = require('./index-B_wlQBy2.cjs');
7
+ var node_crypto = require('node:crypto');
8
+
9
+ function createSessionMetadata(opts) {
10
+ const state = {
11
+ controlledByUser: false
12
+ };
13
+ const metadata = {
14
+ path: process.cwd(),
15
+ host: os.hostname(),
16
+ version: api.packageJson.version,
17
+ os: os.platform(),
18
+ machineId: opts.machineId,
19
+ homeDir: os.homedir(),
20
+ happyHomeDir: api.configuration.happyCloudHomeDir,
21
+ happyLibDir: index.projectPath(),
22
+ happyToolsDir: path.resolve(index.projectPath(), "tools", "unpacked"),
23
+ startedFromDaemon: opts.startedBy === "daemon",
24
+ hostPid: process.pid,
25
+ startedBy: opts.startedBy || "terminal",
26
+ lifecycleState: "running",
27
+ lifecycleStateSince: Date.now(),
28
+ flavor: opts.flavor
29
+ };
30
+ return { state, metadata };
31
+ }
8
32
 
33
+ function createOfflineSessionStub(sessionTag) {
34
+ return {
35
+ sessionId: `offline-${sessionTag}`,
36
+ sendCodexMessage: () => {
37
+ },
38
+ sendAgentMessage: () => {
39
+ },
40
+ sendClaudeSessionMessage: () => {
41
+ },
42
+ keepAlive: () => {
43
+ },
44
+ sendSessionEvent: () => {
45
+ },
46
+ sendSessionDeath: () => {
47
+ },
48
+ updateLifecycleState: () => {
49
+ },
50
+ requestControlTransfer: async () => {
51
+ },
52
+ flush: async () => {
53
+ },
54
+ close: async () => {
55
+ },
56
+ updateMetadata: () => {
57
+ },
58
+ updateAgentState: () => {
59
+ },
60
+ getMetadataSnapshot: () => null,
61
+ getAgentStateSnapshot: () => null,
62
+ waitForMetadataUpdate: async () => null,
63
+ onUserMessage: () => {
64
+ },
65
+ rpcHandlerManager: {
66
+ registerHandler: () => {
67
+ }
68
+ }
69
+ };
70
+ }
71
+
72
+ function setupOfflineReconnection(opts) {
73
+ const { api: api$1, sessionTag, metadata, state, response, onSessionSwap } = opts;
74
+ let session;
75
+ let reconnectionHandle = null;
76
+ if (!response) {
77
+ session = createOfflineSessionStub(sessionTag);
78
+ reconnectionHandle = api.startOfflineReconnection({
79
+ serverUrl: api.configuration.serverUrl,
80
+ onReconnected: async () => {
81
+ const resp = await api$1.getOrCreateSession({ tag: sessionTag, metadata, state });
82
+ if (!resp) throw new Error("Server unavailable");
83
+ const realSession = api$1.sessionSyncClient(resp);
84
+ onSessionSwap(realSession);
85
+ return realSession;
86
+ },
87
+ onNotify: (msg) => {
88
+ console.log(msg);
89
+ }
90
+ });
91
+ return { session, reconnectionHandle, isOffline: true };
92
+ } else {
93
+ session = api$1.sessionSyncClient(response);
94
+ return { session, reconnectionHandle: null, isOffline: false };
95
+ }
96
+ }
97
+
98
+ const INTERACTION_SUPERSEDED_ERROR = "Interaction superseded by new user message";
9
99
  class BasePermissionHandler {
10
100
  pendingRequests = /* @__PURE__ */ new Map();
11
101
  session;
@@ -77,6 +167,45 @@ class BasePermissionHandler {
77
167
  }
78
168
  }));
79
169
  }
170
+ hasPendingRequests() {
171
+ return this.pendingRequests.size > 0;
172
+ }
173
+ supersedePendingRequests(reason = INTERACTION_SUPERSEDED_ERROR) {
174
+ const pendingSnapshot = Array.from(this.pendingRequests.entries());
175
+ if (pendingSnapshot.length === 0) {
176
+ return 0;
177
+ }
178
+ this.pendingRequests.clear();
179
+ const completedAt = Date.now();
180
+ for (const [, pending] of pendingSnapshot) {
181
+ pending.resolve({ decision: "abort" });
182
+ }
183
+ this.session.updateAgentState((currentState) => {
184
+ const requests = { ...currentState.requests || {} };
185
+ const completedRequests = { ...currentState.completedRequests || {} };
186
+ for (const [id, request] of Object.entries(requests)) {
187
+ if (request.requestKind === "selection") {
188
+ continue;
189
+ }
190
+ completedRequests[id] = {
191
+ ...request,
192
+ completedAt,
193
+ status: "denied",
194
+ reason,
195
+ decision: "abort",
196
+ requestKind: request.requestKind || "permission"
197
+ };
198
+ delete requests[id];
199
+ }
200
+ return {
201
+ ...currentState,
202
+ requests,
203
+ completedRequests
204
+ };
205
+ });
206
+ api.logger.debug(`${this.getLogPrefix()} Superseded ${pendingSnapshot.length} pending permission request(s)`);
207
+ return pendingSnapshot.length;
208
+ }
80
209
  /**
81
210
  * Reset state for new sessions.
82
211
  * This method is idempotent - safe to call multiple times.
@@ -315,93 +444,8 @@ class BaseReasoningProcessor {
315
444
  }
316
445
  }
317
446
 
318
- function createSessionMetadata(opts) {
319
- const state = {
320
- controlledByUser: false
321
- };
322
- const metadata = {
323
- path: process.cwd(),
324
- host: os.hostname(),
325
- version: api.packageJson.version,
326
- os: os.platform(),
327
- machineId: opts.machineId,
328
- homeDir: os.homedir(),
329
- happyHomeDir: api.configuration.happyCloudHomeDir,
330
- happyLibDir: index.projectPath(),
331
- happyToolsDir: node_path.resolve(index.projectPath(), "tools", "unpacked"),
332
- startedFromDaemon: opts.startedBy === "daemon",
333
- hostPid: process.pid,
334
- startedBy: opts.startedBy || "terminal",
335
- lifecycleState: "running",
336
- lifecycleStateSince: Date.now(),
337
- flavor: opts.flavor
338
- };
339
- return { state, metadata };
340
- }
341
-
342
- function createOfflineSessionStub(sessionTag) {
343
- return {
344
- sessionId: `offline-${sessionTag}`,
345
- sendCodexMessage: () => {
346
- },
347
- sendAgentMessage: () => {
348
- },
349
- sendClaudeSessionMessage: () => {
350
- },
351
- keepAlive: () => {
352
- },
353
- sendSessionEvent: () => {
354
- },
355
- sendSessionDeath: () => {
356
- },
357
- updateLifecycleState: () => {
358
- },
359
- requestControlTransfer: async () => {
360
- },
361
- flush: async () => {
362
- },
363
- close: async () => {
364
- },
365
- updateMetadata: () => {
366
- },
367
- updateAgentState: () => {
368
- },
369
- onUserMessage: () => {
370
- },
371
- rpcHandlerManager: {
372
- registerHandler: () => {
373
- }
374
- }
375
- };
376
- }
377
-
378
- function setupOfflineReconnection(opts) {
379
- const { api: api$1, sessionTag, metadata, state, response, onSessionSwap } = opts;
380
- let session;
381
- let reconnectionHandle = null;
382
- if (!response) {
383
- session = createOfflineSessionStub(sessionTag);
384
- reconnectionHandle = api.startOfflineReconnection({
385
- serverUrl: api.configuration.serverUrl,
386
- onReconnected: async () => {
387
- const resp = await api$1.getOrCreateSession({ tag: sessionTag, metadata, state });
388
- if (!resp) throw new Error("Server unavailable");
389
- const realSession = api$1.sessionSyncClient(resp);
390
- onSessionSwap(realSession);
391
- return realSession;
392
- },
393
- onNotify: (msg) => {
394
- console.log(msg);
395
- }
396
- });
397
- return { session, reconnectionHandle, isOffline: true };
398
- } else {
399
- session = api$1.sessionSyncClient(response);
400
- return { session, reconnectionHandle: null, isOffline: false };
401
- }
402
- }
403
-
404
447
  exports.BasePermissionHandler = BasePermissionHandler;
405
448
  exports.BaseReasoningProcessor = BaseReasoningProcessor;
449
+ exports.INTERACTION_SUPERSEDED_ERROR = INTERACTION_SUPERSEDED_ERROR;
406
450
  exports.createSessionMetadata = createSessionMetadata;
407
451
  exports.setupOfflineReconnection = setupOfflineReconnection;