happy-imou-cloud 2.1.49 → 2.1.51

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 (55) hide show
  1. package/dist/AcpBackend-CqO3D07V.mjs +2619 -0
  2. package/dist/AcpBackend-XPiTd6ph.cjs +2621 -0
  3. package/dist/{BaseReasoningProcessor-Dn9NcoHz.cjs → BaseReasoningProcessor-BD9tiwep.cjs} +1 -144
  4. package/dist/{BaseReasoningProcessor-CAVeOdyo.mjs → BaseReasoningProcessor-CjlayL2f.mjs} +2 -144
  5. package/dist/ConversationHistory-Bl2doTA-.cjs +780 -0
  6. package/dist/ConversationHistory-CI5bBfuA.mjs +771 -0
  7. package/dist/{ProviderSelectionHandler-BJJc7qOR.cjs → ProviderSelectionHandler-C7GE5QjX.cjs} +6 -6
  8. package/dist/{ProviderSelectionHandler-DIYidT13.mjs → ProviderSelectionHandler-uQ8jzdzr.mjs} +2 -2
  9. package/dist/RuntimeShell-BDt42io_.mjs +252 -0
  10. package/dist/RuntimeShell-D_Te12wq.cjs +258 -0
  11. package/dist/bootstrapManagedProviderSession-Bln-TwyB.cjs +147 -0
  12. package/dist/bootstrapManagedProviderSession-D2Z6YU3n.mjs +145 -0
  13. package/dist/claude-BKNT-2fG.cjs +1080 -0
  14. package/dist/claude-CnN5WCWj.mjs +1073 -0
  15. package/dist/codex-DLGP8WF6.mjs +577 -0
  16. package/dist/codex-Fv2eali8.cjs +582 -0
  17. package/dist/{command-VcH4hbhi.cjs → command-BWPlJyCN.cjs} +16 -8
  18. package/dist/{command-CzfRRhVe.mjs → command-CELwsYoG.mjs} +15 -7
  19. package/dist/config-CFL0Gkqt.cjs +184 -0
  20. package/dist/config-ChSPe7p9.mjs +174 -0
  21. package/dist/createDefaultRuntimeShell-BXu3vCvT.cjs +33 -0
  22. package/dist/createDefaultRuntimeShell-DOg6g3-G.mjs +31 -0
  23. package/dist/cursor-Blq1cHdr.cjs +91 -0
  24. package/dist/cursor-CwPNSy_A.mjs +88 -0
  25. package/dist/future-Dq4Ha1Dn.cjs +24 -0
  26. package/dist/future-xRdLl3vf.mjs +22 -0
  27. package/dist/{index-xa1kwZoj.cjs → index-B_JYgMUS.cjs} +189 -5352
  28. package/dist/{index-7Z93BoVn.mjs → index-CX-F_fuk.mjs} +177 -5331
  29. package/dist/index.cjs +2 -2
  30. package/dist/index.mjs +2 -2
  31. package/dist/installFatalProcessHandlers-0vaw9MAz.mjs +55 -0
  32. package/dist/installFatalProcessHandlers-CyURn5Bp.cjs +57 -0
  33. package/dist/launch-BoCCEd5p.mjs +63 -0
  34. package/dist/launch-wZA5BcvS.cjs +66 -0
  35. package/dist/lib.cjs +2 -3
  36. package/dist/lib.d.cts +20 -17
  37. package/dist/lib.d.mts +20 -17
  38. package/dist/lib.mjs +1 -2
  39. package/dist/resolveCommand-B3BGyBE2.mjs +189 -0
  40. package/dist/resolveCommand-DYMd9PNC.cjs +193 -0
  41. package/dist/{runClaude-zCwRhpOw.mjs → runClaude-Be0myF9k.mjs} +8 -5
  42. package/dist/{runClaude-BBGNmGj6.cjs → runClaude-DZJt5er7.cjs} +46 -43
  43. package/dist/{runCodex-BbgLVjb9.mjs → runCodex-BSnyN4m7.mjs} +226 -117
  44. package/dist/{runCodex-jUU6U2tZ.cjs → runCodex-DTCcGRue.cjs} +269 -160
  45. package/dist/runCursor-Bn1PuwJy.cjs +506 -0
  46. package/dist/runCursor-M6dQ6bGF.mjs +504 -0
  47. package/dist/{runGemini-DcwNsudA.mjs → runGemini-BNm4vYKA.mjs} +279 -5
  48. package/dist/{runGemini-C0NT8MHK.cjs → runGemini-Bn3lFhz6.cjs} +309 -35
  49. package/dist/{registerKillSessionHandler-DLDg2EES.mjs → sessionControl-1bT_7OI6.mjs} +1643 -2405
  50. package/dist/{registerKillSessionHandler-CfCya6si.cjs → sessionControl-flKnQrx0.cjs} +1647 -2417
  51. package/dist/{api-DnqaNvyV.mjs → types-B5vtxa38.mjs} +55 -5
  52. package/dist/{api-D7nAeZi7.cjs → types-CttABk32.cjs} +55 -4
  53. package/package.json +2 -2
  54. package/dist/types-CiliQpqS.mjs +0 -52
  55. package/dist/types-DVk3crez.cjs +0 -54
@@ -0,0 +1,184 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var os = require('os');
6
+ var child_process = require('child_process');
7
+ var persistence = require('./types-CttABk32.cjs');
8
+
9
+ const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
10
+ const GOOGLE_API_KEY_ENV = "GOOGLE_API_KEY";
11
+ const GEMINI_MODEL_ENV = "GEMINI_MODEL";
12
+ const DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
13
+
14
+ function readGeminiLocalConfig() {
15
+ let token = null;
16
+ let model = null;
17
+ let googleCloudProject = null;
18
+ let googleCloudProjectEmail = null;
19
+ const possiblePaths = [
20
+ path.join(os.homedir(), ".gemini", "oauth_creds.json"),
21
+ // Main OAuth credentials file
22
+ path.join(os.homedir(), ".gemini", "config.json"),
23
+ path.join(os.homedir(), ".config", "gemini", "config.json"),
24
+ path.join(os.homedir(), ".gemini", "auth.json"),
25
+ path.join(os.homedir(), ".config", "gemini", "auth.json")
26
+ ];
27
+ for (const configPath of possiblePaths) {
28
+ if (fs.existsSync(configPath)) {
29
+ try {
30
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
31
+ if (!token) {
32
+ const foundToken = config.access_token || config.token || config.apiKey || config.GEMINI_API_KEY;
33
+ if (foundToken && typeof foundToken === "string") {
34
+ token = foundToken;
35
+ persistence.logger.debug(`[Gemini] Found token in ${configPath}`);
36
+ }
37
+ }
38
+ if (!model) {
39
+ const foundModel = config.model || config.GEMINI_MODEL;
40
+ if (foundModel && typeof foundModel === "string") {
41
+ model = foundModel;
42
+ persistence.logger.debug(`[Gemini] Found model in ${configPath}: ${model}`);
43
+ }
44
+ }
45
+ if (!googleCloudProject) {
46
+ const foundProject = config.googleCloudProject || config.google_cloud_project || config.projectId;
47
+ if (foundProject && typeof foundProject === "string") {
48
+ googleCloudProject = foundProject;
49
+ if (config.googleCloudProjectEmail && typeof config.googleCloudProjectEmail === "string") {
50
+ googleCloudProjectEmail = config.googleCloudProjectEmail;
51
+ }
52
+ persistence.logger.debug(`[Gemini] Found Google Cloud Project in ${configPath}: ${googleCloudProject}${googleCloudProjectEmail ? ` (for ${googleCloudProjectEmail})` : ""}`);
53
+ }
54
+ }
55
+ } catch (error) {
56
+ persistence.logger.debug(`[Gemini] Failed to read config from ${configPath}:`, error);
57
+ }
58
+ }
59
+ }
60
+ if (!token) {
61
+ try {
62
+ const gcloudToken = child_process.execSync("gcloud auth application-default print-access-token", {
63
+ encoding: "utf8",
64
+ stdio: ["ignore", "pipe", "ignore"],
65
+ timeout: 5e3,
66
+ windowsHide: true
67
+ }).trim();
68
+ if (gcloudToken && gcloudToken.length > 0) {
69
+ token = gcloudToken;
70
+ persistence.logger.debug("[Gemini] Found token via gcloud Application Default Credentials");
71
+ }
72
+ } catch (error) {
73
+ persistence.logger.debug("[Gemini] gcloud Application Default Credentials not available");
74
+ }
75
+ }
76
+ if (!googleCloudProject) {
77
+ const envProject = process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT_ID;
78
+ if (envProject) {
79
+ googleCloudProject = envProject;
80
+ googleCloudProjectEmail = null;
81
+ persistence.logger.debug(`[Gemini] Found Google Cloud Project from env: ${googleCloudProject}`);
82
+ }
83
+ }
84
+ return { token, model, googleCloudProject, googleCloudProjectEmail };
85
+ }
86
+ function determineGeminiModel(explicitModel, localConfig) {
87
+ if (explicitModel !== void 0) {
88
+ if (explicitModel === null) {
89
+ return process.env[GEMINI_MODEL_ENV] || DEFAULT_GEMINI_MODEL;
90
+ } else {
91
+ return explicitModel;
92
+ }
93
+ } else {
94
+ const envModel = process.env[GEMINI_MODEL_ENV];
95
+ persistence.logger.debug(`[Gemini] Model selection: env[GEMINI_MODEL_ENV]=${envModel}, localConfig.model=${localConfig.model}, DEFAULT=${DEFAULT_GEMINI_MODEL}`);
96
+ const model = envModel || localConfig.model || DEFAULT_GEMINI_MODEL;
97
+ persistence.logger.debug(`[Gemini] Selected model: ${model}`);
98
+ return model;
99
+ }
100
+ }
101
+ function saveGeminiModelToConfig(model) {
102
+ try {
103
+ const configDir = path.join(os.homedir(), ".gemini");
104
+ const configPath = path.join(configDir, "config.json");
105
+ if (!fs.existsSync(configDir)) {
106
+ fs.mkdirSync(configDir, { recursive: true });
107
+ }
108
+ let config = {};
109
+ if (fs.existsSync(configPath)) {
110
+ try {
111
+ config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
112
+ } catch (error) {
113
+ persistence.logger.debug(`[Gemini] Failed to read existing config, creating new one`);
114
+ config = {};
115
+ }
116
+ }
117
+ config.model = model;
118
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
119
+ persistence.logger.debug(`[Gemini] Saved model "${model}" to ${configPath}`);
120
+ } catch (error) {
121
+ persistence.logger.debug(`[Gemini] Failed to save model to config:`, error);
122
+ }
123
+ }
124
+ function saveGoogleCloudProjectToConfig(projectId, email) {
125
+ try {
126
+ const configDir = path.join(os.homedir(), ".gemini");
127
+ const configPath = path.join(configDir, "config.json");
128
+ if (!fs.existsSync(configDir)) {
129
+ fs.mkdirSync(configDir, { recursive: true });
130
+ }
131
+ let config = {};
132
+ if (fs.existsSync(configPath)) {
133
+ try {
134
+ config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
135
+ } catch {
136
+ config = {};
137
+ }
138
+ }
139
+ config.googleCloudProject = projectId;
140
+ if (email) {
141
+ config.googleCloudProjectEmail = email;
142
+ }
143
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
144
+ persistence.logger.debug(`[Gemini] Saved Google Cloud Project "${projectId}"${email ? ` for ${email}` : ""} to ${configPath}`);
145
+ } catch (error) {
146
+ persistence.logger.debug(`[Gemini] Failed to save Google Cloud Project to config:`, error);
147
+ throw error;
148
+ }
149
+ }
150
+ function getInitialGeminiModel() {
151
+ const localConfig = readGeminiLocalConfig();
152
+ return process.env[GEMINI_MODEL_ENV] || localConfig.model || DEFAULT_GEMINI_MODEL;
153
+ }
154
+ function getGeminiModelSource(explicitModel, localConfig) {
155
+ if (explicitModel !== void 0 && explicitModel !== null) {
156
+ return "explicit";
157
+ } else if (process.env[GEMINI_MODEL_ENV]) {
158
+ return "env-var";
159
+ } else if (localConfig.model) {
160
+ return "local-config";
161
+ } else {
162
+ return "default";
163
+ }
164
+ }
165
+
166
+ var config = /*#__PURE__*/Object.freeze({
167
+ __proto__: null,
168
+ determineGeminiModel: determineGeminiModel,
169
+ getGeminiModelSource: getGeminiModelSource,
170
+ getInitialGeminiModel: getInitialGeminiModel,
171
+ readGeminiLocalConfig: readGeminiLocalConfig,
172
+ saveGeminiModelToConfig: saveGeminiModelToConfig,
173
+ saveGoogleCloudProjectToConfig: saveGoogleCloudProjectToConfig
174
+ });
175
+
176
+ exports.GEMINI_API_KEY_ENV = GEMINI_API_KEY_ENV;
177
+ exports.GEMINI_MODEL_ENV = GEMINI_MODEL_ENV;
178
+ exports.GOOGLE_API_KEY_ENV = GOOGLE_API_KEY_ENV;
179
+ exports.config = config;
180
+ exports.determineGeminiModel = determineGeminiModel;
181
+ exports.getGeminiModelSource = getGeminiModelSource;
182
+ exports.getInitialGeminiModel = getInitialGeminiModel;
183
+ exports.readGeminiLocalConfig = readGeminiLocalConfig;
184
+ exports.saveGeminiModelToConfig = saveGeminiModelToConfig;
@@ -0,0 +1,174 @@
1
+ import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { homedir } from 'os';
4
+ import { execSync } from 'child_process';
5
+ import { l as logger } from './types-B5vtxa38.mjs';
6
+
7
+ const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
8
+ const GOOGLE_API_KEY_ENV = "GOOGLE_API_KEY";
9
+ const GEMINI_MODEL_ENV = "GEMINI_MODEL";
10
+ const DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
11
+
12
+ function readGeminiLocalConfig() {
13
+ let token = null;
14
+ let model = null;
15
+ let googleCloudProject = null;
16
+ let googleCloudProjectEmail = null;
17
+ const possiblePaths = [
18
+ join(homedir(), ".gemini", "oauth_creds.json"),
19
+ // Main OAuth credentials file
20
+ join(homedir(), ".gemini", "config.json"),
21
+ join(homedir(), ".config", "gemini", "config.json"),
22
+ join(homedir(), ".gemini", "auth.json"),
23
+ join(homedir(), ".config", "gemini", "auth.json")
24
+ ];
25
+ for (const configPath of possiblePaths) {
26
+ if (existsSync(configPath)) {
27
+ try {
28
+ const config = JSON.parse(readFileSync(configPath, "utf-8"));
29
+ if (!token) {
30
+ const foundToken = config.access_token || config.token || config.apiKey || config.GEMINI_API_KEY;
31
+ if (foundToken && typeof foundToken === "string") {
32
+ token = foundToken;
33
+ logger.debug(`[Gemini] Found token in ${configPath}`);
34
+ }
35
+ }
36
+ if (!model) {
37
+ const foundModel = config.model || config.GEMINI_MODEL;
38
+ if (foundModel && typeof foundModel === "string") {
39
+ model = foundModel;
40
+ logger.debug(`[Gemini] Found model in ${configPath}: ${model}`);
41
+ }
42
+ }
43
+ if (!googleCloudProject) {
44
+ const foundProject = config.googleCloudProject || config.google_cloud_project || config.projectId;
45
+ if (foundProject && typeof foundProject === "string") {
46
+ googleCloudProject = foundProject;
47
+ if (config.googleCloudProjectEmail && typeof config.googleCloudProjectEmail === "string") {
48
+ googleCloudProjectEmail = config.googleCloudProjectEmail;
49
+ }
50
+ logger.debug(`[Gemini] Found Google Cloud Project in ${configPath}: ${googleCloudProject}${googleCloudProjectEmail ? ` (for ${googleCloudProjectEmail})` : ""}`);
51
+ }
52
+ }
53
+ } catch (error) {
54
+ logger.debug(`[Gemini] Failed to read config from ${configPath}:`, error);
55
+ }
56
+ }
57
+ }
58
+ if (!token) {
59
+ try {
60
+ const gcloudToken = execSync("gcloud auth application-default print-access-token", {
61
+ encoding: "utf8",
62
+ stdio: ["ignore", "pipe", "ignore"],
63
+ timeout: 5e3,
64
+ windowsHide: true
65
+ }).trim();
66
+ if (gcloudToken && gcloudToken.length > 0) {
67
+ token = gcloudToken;
68
+ logger.debug("[Gemini] Found token via gcloud Application Default Credentials");
69
+ }
70
+ } catch (error) {
71
+ logger.debug("[Gemini] gcloud Application Default Credentials not available");
72
+ }
73
+ }
74
+ if (!googleCloudProject) {
75
+ const envProject = process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT_ID;
76
+ if (envProject) {
77
+ googleCloudProject = envProject;
78
+ googleCloudProjectEmail = null;
79
+ logger.debug(`[Gemini] Found Google Cloud Project from env: ${googleCloudProject}`);
80
+ }
81
+ }
82
+ return { token, model, googleCloudProject, googleCloudProjectEmail };
83
+ }
84
+ function determineGeminiModel(explicitModel, localConfig) {
85
+ if (explicitModel !== void 0) {
86
+ if (explicitModel === null) {
87
+ return process.env[GEMINI_MODEL_ENV] || DEFAULT_GEMINI_MODEL;
88
+ } else {
89
+ return explicitModel;
90
+ }
91
+ } else {
92
+ const envModel = process.env[GEMINI_MODEL_ENV];
93
+ logger.debug(`[Gemini] Model selection: env[GEMINI_MODEL_ENV]=${envModel}, localConfig.model=${localConfig.model}, DEFAULT=${DEFAULT_GEMINI_MODEL}`);
94
+ const model = envModel || localConfig.model || DEFAULT_GEMINI_MODEL;
95
+ logger.debug(`[Gemini] Selected model: ${model}`);
96
+ return model;
97
+ }
98
+ }
99
+ function saveGeminiModelToConfig(model) {
100
+ try {
101
+ const configDir = join(homedir(), ".gemini");
102
+ const configPath = join(configDir, "config.json");
103
+ if (!existsSync(configDir)) {
104
+ mkdirSync(configDir, { recursive: true });
105
+ }
106
+ let config = {};
107
+ if (existsSync(configPath)) {
108
+ try {
109
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
110
+ } catch (error) {
111
+ logger.debug(`[Gemini] Failed to read existing config, creating new one`);
112
+ config = {};
113
+ }
114
+ }
115
+ config.model = model;
116
+ writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
117
+ logger.debug(`[Gemini] Saved model "${model}" to ${configPath}`);
118
+ } catch (error) {
119
+ logger.debug(`[Gemini] Failed to save model to config:`, error);
120
+ }
121
+ }
122
+ function saveGoogleCloudProjectToConfig(projectId, email) {
123
+ try {
124
+ const configDir = join(homedir(), ".gemini");
125
+ const configPath = join(configDir, "config.json");
126
+ if (!existsSync(configDir)) {
127
+ mkdirSync(configDir, { recursive: true });
128
+ }
129
+ let config = {};
130
+ if (existsSync(configPath)) {
131
+ try {
132
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
133
+ } catch {
134
+ config = {};
135
+ }
136
+ }
137
+ config.googleCloudProject = projectId;
138
+ if (email) {
139
+ config.googleCloudProjectEmail = email;
140
+ }
141
+ writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
142
+ logger.debug(`[Gemini] Saved Google Cloud Project "${projectId}"${email ? ` for ${email}` : ""} to ${configPath}`);
143
+ } catch (error) {
144
+ logger.debug(`[Gemini] Failed to save Google Cloud Project to config:`, error);
145
+ throw error;
146
+ }
147
+ }
148
+ function getInitialGeminiModel() {
149
+ const localConfig = readGeminiLocalConfig();
150
+ return process.env[GEMINI_MODEL_ENV] || localConfig.model || DEFAULT_GEMINI_MODEL;
151
+ }
152
+ function getGeminiModelSource(explicitModel, localConfig) {
153
+ if (explicitModel !== void 0 && explicitModel !== null) {
154
+ return "explicit";
155
+ } else if (process.env[GEMINI_MODEL_ENV]) {
156
+ return "env-var";
157
+ } else if (localConfig.model) {
158
+ return "local-config";
159
+ } else {
160
+ return "default";
161
+ }
162
+ }
163
+
164
+ var config = /*#__PURE__*/Object.freeze({
165
+ __proto__: null,
166
+ determineGeminiModel: determineGeminiModel,
167
+ getGeminiModelSource: getGeminiModelSource,
168
+ getInitialGeminiModel: getInitialGeminiModel,
169
+ readGeminiLocalConfig: readGeminiLocalConfig,
170
+ saveGeminiModelToConfig: saveGeminiModelToConfig,
171
+ saveGoogleCloudProjectToConfig: saveGoogleCloudProjectToConfig
172
+ });
173
+
174
+ export { GEMINI_API_KEY_ENV as G, GOOGLE_API_KEY_ENV as a, GEMINI_MODEL_ENV as b, getInitialGeminiModel as c, determineGeminiModel as d, config as e, getGeminiModelSource as g, readGeminiLocalConfig as r, saveGeminiModelToConfig as s };
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ require('cross-spawn');
4
+ require('@agentclientprotocol/sdk');
5
+ require('node:crypto');
6
+ require('./types-CttABk32.cjs');
7
+ require('./index-B_JYgMUS.cjs');
8
+ require('ps-list');
9
+ require('fs');
10
+ require('path');
11
+ require('os');
12
+ require('child_process');
13
+ var codex = require('./codex-Fv2eali8.cjs');
14
+ var claude = require('./claude-BKNT-2fG.cjs');
15
+ var cursor = require('./cursor-Blq1cHdr.cjs');
16
+ var RuntimeShell = require('./RuntimeShell-D_Te12wq.cjs');
17
+
18
+ function initializeAgents() {
19
+ claude.registerClaudeAgent();
20
+ codex.registerCodexAgent();
21
+ cursor.registerCursorAgent();
22
+ }
23
+
24
+ let initialized = false;
25
+ function createDefaultRuntimeShell() {
26
+ if (!initialized) {
27
+ initializeAgents();
28
+ initialized = true;
29
+ }
30
+ return new RuntimeShell.RuntimeShell();
31
+ }
32
+
33
+ exports.createDefaultRuntimeShell = createDefaultRuntimeShell;
@@ -0,0 +1,31 @@
1
+ import 'cross-spawn';
2
+ import '@agentclientprotocol/sdk';
3
+ import 'node:crypto';
4
+ import './types-B5vtxa38.mjs';
5
+ import './index-CX-F_fuk.mjs';
6
+ import 'ps-list';
7
+ import 'fs';
8
+ import 'path';
9
+ import 'os';
10
+ import 'child_process';
11
+ import { r as registerCodexAgent } from './codex-DLGP8WF6.mjs';
12
+ import { r as registerClaudeAgent } from './claude-CnN5WCWj.mjs';
13
+ import { r as registerCursorAgent } from './cursor-CwPNSy_A.mjs';
14
+ import { R as RuntimeShell } from './RuntimeShell-BDt42io_.mjs';
15
+
16
+ function initializeAgents() {
17
+ registerClaudeAgent();
18
+ registerCodexAgent();
19
+ registerCursorAgent();
20
+ }
21
+
22
+ let initialized = false;
23
+ function createDefaultRuntimeShell() {
24
+ if (!initialized) {
25
+ initializeAgents();
26
+ initialized = true;
27
+ }
28
+ return new RuntimeShell();
29
+ }
30
+
31
+ export { createDefaultRuntimeShell as c };
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ var AcpBackend = require('./AcpBackend-XPiTd6ph.cjs');
4
+ var RuntimeShell = require('./RuntimeShell-D_Te12wq.cjs');
5
+ require('./types-CttABk32.cjs');
6
+ var index = require('./index-B_JYgMUS.cjs');
7
+ var resolveCommand = require('./resolveCommand-DYMd9PNC.cjs');
8
+
9
+ const DEFAULT_CURSOR_ACP_ARGS = ["acp"];
10
+ function readFirstEnv(...names) {
11
+ for (const name of names) {
12
+ const raw = process.env[name];
13
+ if (typeof raw === "string" && raw.trim()) {
14
+ return raw.trim();
15
+ }
16
+ }
17
+ return "";
18
+ }
19
+ function splitCursorAcpArgs(raw) {
20
+ return raw.split(/\s+/).map((arg) => arg.trim()).filter(Boolean);
21
+ }
22
+ function defaultCursorArgs() {
23
+ const envArgs = readFirstEnv("HAPPY_CURSOR_ACP_ARGS", "HAPPIER_CURSOR_ACP_ARGS");
24
+ return envArgs ? splitCursorAcpArgs(envArgs) : [...DEFAULT_CURSOR_ACP_ARGS];
25
+ }
26
+ function resolveCursorCommand() {
27
+ const configured = readFirstEnv(
28
+ "HAPPY_CURSOR_ACP_COMMAND",
29
+ "HAPPY_CURSOR_ACP_BIN",
30
+ "HAPPIER_CURSOR_ACP_COMMAND",
31
+ "HAPPIER_CURSOR_ACP_BIN"
32
+ );
33
+ if (configured) {
34
+ return configured;
35
+ }
36
+ const cursorAgentCommand = process.platform === "win32" ? "cursor-agent.cmd" : "cursor-agent";
37
+ const agentCommand = process.platform === "win32" ? "agent.cmd" : "agent";
38
+ return resolveCommand.resolveCommandOnPath(cursorAgentCommand) ?? resolveCommand.resolveCommandOnPath("cursor-agent") ?? resolveCommand.resolveCommandOnPath(agentCommand) ?? resolveCommand.resolveCommandOnPath("agent") ?? cursorAgentCommand;
39
+ }
40
+ function enrichCursorStartupError(error, command, args) {
41
+ const original = error instanceof Error ? error : new Error(String(error));
42
+ const commandLine = [command, ...args].join(" ");
43
+ const hint = `Cursor ACP startup failed for "${commandLine}". Cursor ACP requires a recent Cursor CLI and the official ACP entrypoint "cursor-agent acp" or "agent acp". Upgrade Cursor CLI, add it to PATH, or set HAPPY_CURSOR_ACP_COMMAND and HAPPY_CURSOR_ACP_ARGS.`;
44
+ const next = new Error(`${original.message}
45
+ ${hint}`);
46
+ next.name = original.name || "CursorAcpStartupError";
47
+ next.stack = original.stack;
48
+ return next;
49
+ }
50
+ class CursorAcpBackend extends AcpBackend.AcpBackend {
51
+ constructor(options, command, args) {
52
+ super(options);
53
+ this.command = command;
54
+ this.args = args;
55
+ }
56
+ async startSession(initialPrompt) {
57
+ try {
58
+ return await super.startSession(initialPrompt);
59
+ } catch (error) {
60
+ throw enrichCursorStartupError(error, this.command, this.args);
61
+ }
62
+ }
63
+ }
64
+ function createCursorBackend(options) {
65
+ const command = options.command ?? resolveCursorCommand();
66
+ const args = options.args ?? defaultCursorArgs();
67
+ const backendOptions = {
68
+ agentName: "cursor",
69
+ cwd: options.cwd,
70
+ command,
71
+ args,
72
+ env: {
73
+ ...options.env,
74
+ NODE_ENV: "production"
75
+ },
76
+ mcpServers: options.mcpServers,
77
+ permissionHandler: options.permissionHandler,
78
+ transportHandler: index.cursorTransport
79
+ };
80
+ return {
81
+ backend: new CursorAcpBackend(backendOptions, command, args),
82
+ command,
83
+ args
84
+ };
85
+ }
86
+ function registerCursorAgent() {
87
+ RuntimeShell.agentRegistry.register("cursor", (opts) => createCursorBackend(opts).backend);
88
+ }
89
+
90
+ exports.createCursorBackend = createCursorBackend;
91
+ exports.registerCursorAgent = registerCursorAgent;
@@ -0,0 +1,88 @@
1
+ import { A as AcpBackend } from './AcpBackend-CqO3D07V.mjs';
2
+ import { a as agentRegistry } from './RuntimeShell-BDt42io_.mjs';
3
+ import './types-B5vtxa38.mjs';
4
+ import { c as cursorTransport } from './index-CX-F_fuk.mjs';
5
+ import { r as resolveCommandOnPath } from './resolveCommand-B3BGyBE2.mjs';
6
+
7
+ const DEFAULT_CURSOR_ACP_ARGS = ["acp"];
8
+ function readFirstEnv(...names) {
9
+ for (const name of names) {
10
+ const raw = process.env[name];
11
+ if (typeof raw === "string" && raw.trim()) {
12
+ return raw.trim();
13
+ }
14
+ }
15
+ return "";
16
+ }
17
+ function splitCursorAcpArgs(raw) {
18
+ return raw.split(/\s+/).map((arg) => arg.trim()).filter(Boolean);
19
+ }
20
+ function defaultCursorArgs() {
21
+ const envArgs = readFirstEnv("HAPPY_CURSOR_ACP_ARGS", "HAPPIER_CURSOR_ACP_ARGS");
22
+ return envArgs ? splitCursorAcpArgs(envArgs) : [...DEFAULT_CURSOR_ACP_ARGS];
23
+ }
24
+ function resolveCursorCommand() {
25
+ const configured = readFirstEnv(
26
+ "HAPPY_CURSOR_ACP_COMMAND",
27
+ "HAPPY_CURSOR_ACP_BIN",
28
+ "HAPPIER_CURSOR_ACP_COMMAND",
29
+ "HAPPIER_CURSOR_ACP_BIN"
30
+ );
31
+ if (configured) {
32
+ return configured;
33
+ }
34
+ const cursorAgentCommand = process.platform === "win32" ? "cursor-agent.cmd" : "cursor-agent";
35
+ const agentCommand = process.platform === "win32" ? "agent.cmd" : "agent";
36
+ return resolveCommandOnPath(cursorAgentCommand) ?? resolveCommandOnPath("cursor-agent") ?? resolveCommandOnPath(agentCommand) ?? resolveCommandOnPath("agent") ?? cursorAgentCommand;
37
+ }
38
+ function enrichCursorStartupError(error, command, args) {
39
+ const original = error instanceof Error ? error : new Error(String(error));
40
+ const commandLine = [command, ...args].join(" ");
41
+ const hint = `Cursor ACP startup failed for "${commandLine}". Cursor ACP requires a recent Cursor CLI and the official ACP entrypoint "cursor-agent acp" or "agent acp". Upgrade Cursor CLI, add it to PATH, or set HAPPY_CURSOR_ACP_COMMAND and HAPPY_CURSOR_ACP_ARGS.`;
42
+ const next = new Error(`${original.message}
43
+ ${hint}`);
44
+ next.name = original.name || "CursorAcpStartupError";
45
+ next.stack = original.stack;
46
+ return next;
47
+ }
48
+ class CursorAcpBackend extends AcpBackend {
49
+ constructor(options, command, args) {
50
+ super(options);
51
+ this.command = command;
52
+ this.args = args;
53
+ }
54
+ async startSession(initialPrompt) {
55
+ try {
56
+ return await super.startSession(initialPrompt);
57
+ } catch (error) {
58
+ throw enrichCursorStartupError(error, this.command, this.args);
59
+ }
60
+ }
61
+ }
62
+ function createCursorBackend(options) {
63
+ const command = options.command ?? resolveCursorCommand();
64
+ const args = options.args ?? defaultCursorArgs();
65
+ const backendOptions = {
66
+ agentName: "cursor",
67
+ cwd: options.cwd,
68
+ command,
69
+ args,
70
+ env: {
71
+ ...options.env,
72
+ NODE_ENV: "production"
73
+ },
74
+ mcpServers: options.mcpServers,
75
+ permissionHandler: options.permissionHandler,
76
+ transportHandler: cursorTransport
77
+ };
78
+ return {
79
+ backend: new CursorAcpBackend(backendOptions, command, args),
80
+ command,
81
+ args
82
+ };
83
+ }
84
+ function registerCursorAgent() {
85
+ agentRegistry.register("cursor", (opts) => createCursorBackend(opts).backend);
86
+ }
87
+
88
+ export { createCursorBackend as c, registerCursorAgent as r };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ class Future {
4
+ _resolve;
5
+ _reject;
6
+ _promise;
7
+ constructor() {
8
+ this._promise = new Promise((resolve, reject) => {
9
+ this._resolve = resolve;
10
+ this._reject = reject;
11
+ });
12
+ }
13
+ resolve(value) {
14
+ this._resolve(value);
15
+ }
16
+ reject(reason) {
17
+ this._reject(reason);
18
+ }
19
+ get promise() {
20
+ return this._promise;
21
+ }
22
+ }
23
+
24
+ exports.Future = Future;
@@ -0,0 +1,22 @@
1
+ class Future {
2
+ _resolve;
3
+ _reject;
4
+ _promise;
5
+ constructor() {
6
+ this._promise = new Promise((resolve, reject) => {
7
+ this._resolve = resolve;
8
+ this._reject = reject;
9
+ });
10
+ }
11
+ resolve(value) {
12
+ this._resolve(value);
13
+ }
14
+ reject(reason) {
15
+ this._reject(reason);
16
+ }
17
+ get promise() {
18
+ return this._promise;
19
+ }
20
+ }
21
+
22
+ export { Future as F };