orquesta-cli 0.2.117 → 0.2.119

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.
@@ -40,6 +40,7 @@ export declare class ConfigManager {
40
40
  enableTool(toolId: string): Promise<void>;
41
41
  disableTool(toolId: string): Promise<void>;
42
42
  hasOrquestaConnection(): boolean;
43
+ getReportingToken(): string | undefined;
43
44
  shouldAutoSync(): boolean;
44
45
  getOrquestaConfig(): OrquestaConfig | undefined;
45
46
  setOrquestaConfig(orquestaConfig: OrquestaConfig): Promise<void>;
@@ -262,6 +262,9 @@ export class ConfigManager {
262
262
  }
263
263
  return !!this.config.orquesta?.token;
264
264
  }
265
+ getReportingToken() {
266
+ return this.config?.orquesta?.token || process.env['ORQUESTA_TOKEN'] || undefined;
267
+ }
265
268
  shouldAutoSync() {
266
269
  if (!this.config?.orquesta) {
267
270
  return false;
@@ -208,18 +208,19 @@ export async function pushConfigsToOrquesta() {
208
208
  }
209
209
  export async function submitPromptToOrquesta(prompt) {
210
210
  const orquestaConfig = configManager.getOrquestaConfig();
211
- if (!orquestaConfig?.token) {
211
+ const reportingToken = configManager.getReportingToken();
212
+ if (!reportingToken) {
212
213
  return { success: false, error: 'Not connected to Orquesta' };
213
214
  }
214
215
  const cwd = prompt.context?.['cwd'] || process.cwd();
215
216
  const effectiveProjectId = readHookConfig(cwd)?.projectId ||
216
217
  process.env['ORQUESTA_PROJECT_ID'] ||
217
- orquestaConfig.projectId;
218
+ orquestaConfig?.projectId;
218
219
  try {
219
220
  const response = await fetch(`${ORQUESTA_API}/api/orquesta-cli/prompts`, {
220
221
  method: 'POST',
221
222
  headers: {
222
- Authorization: `Bearer ${orquestaConfig.token}`,
223
+ Authorization: `Bearer ${reportingToken}`,
223
224
  'Content-Type': 'application/json',
224
225
  },
225
226
  body: JSON.stringify({
@@ -254,15 +255,15 @@ export async function submitPromptToOrquesta(prompt) {
254
255
  }
255
256
  }
256
257
  export async function updatePromptStatus(promptId, update) {
257
- const orquestaConfig = configManager.getOrquestaConfig();
258
- if (!orquestaConfig?.token) {
258
+ const reportingToken = configManager.getReportingToken();
259
+ if (!reportingToken) {
259
260
  return { success: false, error: 'Not connected to Orquesta' };
260
261
  }
261
262
  try {
262
263
  const response = await fetch(`${ORQUESTA_API}/api/orquesta-cli/prompts`, {
263
264
  method: 'PATCH',
264
265
  headers: {
265
- Authorization: `Bearer ${orquestaConfig.token}`,
266
+ Authorization: `Bearer ${reportingToken}`,
266
267
  'Content-Type': 'application/json',
267
268
  },
268
269
  body: JSON.stringify({
@@ -287,15 +288,15 @@ export async function updatePromptStatus(promptId, update) {
287
288
  }
288
289
  }
289
290
  export async function streamPromptLogs(promptId, logs) {
290
- const orquestaConfig = configManager.getOrquestaConfig();
291
- if (!orquestaConfig?.token) {
291
+ const reportingToken = configManager.getReportingToken();
292
+ if (!reportingToken) {
292
293
  return { success: false, error: 'Not connected to Orquesta' };
293
294
  }
294
295
  try {
295
296
  const response = await fetch(`${ORQUESTA_API}/api/prompts/${promptId}/logs`, {
296
297
  method: 'POST',
297
298
  headers: {
298
- 'X-Agent-Token': orquestaConfig.token,
299
+ 'X-Agent-Token': reportingToken,
299
300
  'Content-Type': 'application/json',
300
301
  },
301
302
  body: JSON.stringify({ logs }),
@@ -11,7 +11,7 @@ export async function reportPromptStart(content, context) {
11
11
  if (process.env['ORQUESTA_PROMPT_ID']) {
12
12
  return null;
13
13
  }
14
- if (!configManager.hasOrquestaConnection()) {
14
+ if (!configManager.getReportingToken()) {
15
15
  return null;
16
16
  }
17
17
  try {
@@ -46,7 +46,7 @@ export async function reportPromptStart(content, context) {
46
46
  }
47
47
  }
48
48
  export async function reportPromptComplete(trackingId, result) {
49
- if (!trackingId || !configManager.hasOrquestaConnection()) {
49
+ if (!trackingId || !configManager.getReportingToken()) {
50
50
  return;
51
51
  }
52
52
  try {
@@ -69,7 +69,7 @@ export async function reportPromptComplete(trackingId, result) {
69
69
  }
70
70
  }
71
71
  export async function reportPromptCancelled(trackingId) {
72
- if (!trackingId || !configManager.hasOrquestaConnection()) {
72
+ if (!trackingId || !configManager.getReportingToken()) {
73
73
  return;
74
74
  }
75
75
  try {
@@ -112,7 +112,7 @@ function describeToolCall(toolName, args) {
112
112
  }
113
113
  export async function reportAssistantOutput(text) {
114
114
  const promptId = currentPromptId;
115
- if (!promptId || !text || !text.trim() || !configManager.hasOrquestaConnection()) {
115
+ if (!promptId || !text || !text.trim() || !configManager.getReportingToken()) {
116
116
  return;
117
117
  }
118
118
  try {
@@ -130,7 +130,7 @@ export async function reportAssistantOutput(text) {
130
130
  }
131
131
  export async function reportTodos(todos, label = 'Plan') {
132
132
  const promptId = currentPromptId;
133
- if (!promptId || !todos || todos.length === 0 || !configManager.hasOrquestaConnection()) {
133
+ if (!promptId || !todos || todos.length === 0 || !configManager.getReportingToken()) {
134
134
  return;
135
135
  }
136
136
  try {
@@ -150,7 +150,7 @@ export async function reportTodos(todos, label = 'Plan') {
150
150
  }
151
151
  export async function reportToolUse(toolName, args, result) {
152
152
  const promptId = currentPromptId;
153
- if (!promptId || !configManager.hasOrquestaConnection()) {
153
+ if (!promptId || !configManager.getReportingToken()) {
154
154
  return;
155
155
  }
156
156
  try {
@@ -4,7 +4,8 @@ import { logger } from '../../../utils/logger.js';
4
4
  import { isNativeWindows, findNativePowerShellPath, isDangerousPowerShellCommand, } from '../../../utils/platform-utils.js';
5
5
  import { filterSafeEnv } from '../../../utils/env-filter.js';
6
6
  import { configManager } from '../../../core/config/config-manager.js';
7
- async function executePowerShell(command, cwd, timeout = 30000, explicitEnv) {
7
+ const DEFAULT_POWERSHELL_TIMEOUT = 120000;
8
+ async function executePowerShell(command, cwd, timeout = DEFAULT_POWERSHELL_TIMEOUT, explicitEnv) {
8
9
  return new Promise((resolve, reject) => {
9
10
  const psPath = findNativePowerShellPath();
10
11
  const userSafeVars = configManager.getSafeEnvVars();
@@ -15,32 +16,55 @@ async function executePowerShell(command, cwd, timeout = 30000, explicitEnv) {
15
16
  let stdout = '';
16
17
  let stderr = '';
17
18
  let killed = false;
19
+ let settled = false;
20
+ const finish = (code) => {
21
+ if (settled)
22
+ return;
23
+ settled = true;
24
+ clearTimeout(timer);
25
+ clearTimeout(hardTimer);
26
+ resolve({
27
+ stdout: stdout.trim(),
28
+ stderr: stderr.trim(),
29
+ exitCode: code ?? (killed ? 124 : 0),
30
+ timedOut: killed,
31
+ });
32
+ };
18
33
  child.stdout?.on('data', (data) => {
19
34
  stdout += data.toString();
20
35
  });
21
36
  child.stderr?.on('data', (data) => {
22
37
  stderr += data.toString();
23
38
  });
24
- child.on('close', (code) => {
25
- if (!killed) {
26
- resolve({
27
- stdout: stdout.trim(),
28
- stderr: stderr.trim(),
29
- exitCode: code ?? 0,
30
- });
31
- }
32
- });
39
+ child.on('close', (code) => finish(code));
33
40
  child.on('error', (error) => {
41
+ if (settled)
42
+ return;
43
+ settled = true;
44
+ clearTimeout(timer);
45
+ clearTimeout(hardTimer);
34
46
  reject(error);
35
47
  });
36
48
  const timer = setTimeout(() => {
37
49
  killed = true;
38
- child.kill('SIGTERM');
39
- reject(new Error(`Command timed out after ${timeout}ms`));
50
+ try {
51
+ child.kill('SIGTERM');
52
+ }
53
+ catch { }
54
+ setTimeout(() => { try {
55
+ child.kill('SIGKILL');
56
+ }
57
+ catch { } }, 2000).unref?.();
40
58
  }, timeout);
41
- child.on('close', () => {
42
- clearTimeout(timer);
43
- });
59
+ const hardTimer = setTimeout(() => {
60
+ killed = true;
61
+ try {
62
+ child.kill('SIGKILL');
63
+ }
64
+ catch { }
65
+ finish(124);
66
+ }, timeout + 5000);
67
+ hardTimer.unref?.();
44
68
  });
45
69
  }
46
70
  const POWERSHELL_TOOL_DEFINITION = {
@@ -51,7 +75,7 @@ const POWERSHELL_TOOL_DEFINITION = {
51
75
 
52
76
  IMPORTANT:
53
77
  - Do NOT use for file reading/writing - use read_file, create_file, edit_file instead
54
- - Commands have a 30 second timeout by default
78
+ - Commands have a 120 second timeout by default
55
79
  - Dangerous commands (Remove-Item -Recurse -Force C:\\, Stop-Computer, etc.) are blocked
56
80
  - Output is truncated if too long
57
81
  - PowerShell 7 (pwsh) is used if available, otherwise PowerShell 5.1`,
@@ -78,7 +102,7 @@ Examples:
78
102
  },
79
103
  timeout: {
80
104
  type: 'number',
81
- description: 'Timeout in milliseconds (optional, default: 30000)',
105
+ description: 'Timeout in milliseconds (optional, default: 120000)',
82
106
  },
83
107
  env: {
84
108
  type: 'object',
@@ -98,7 +122,7 @@ export const powershellTool = {
98
122
  async execute(args) {
99
123
  const command = args['command'];
100
124
  const cwd = args['cwd'];
101
- const timeout = args['timeout'] || 30000;
125
+ const timeout = args['timeout'] || DEFAULT_POWERSHELL_TIMEOUT;
102
126
  const env = args['env'];
103
127
  logger.enter('powershellTool.execute', { command, cwd, timeout, envKeys: env ? Object.keys(env) : [] });
104
128
  if (!isNativeWindows()) {
@@ -149,6 +173,16 @@ export const powershellTool = {
149
173
  if (output.length > MAX_OUTPUT_LENGTH) {
150
174
  output = output.slice(0, MAX_OUTPUT_LENGTH) + '\n\n... [output truncated]';
151
175
  }
176
+ if (execResult.timedOut) {
177
+ const secs = Math.round(timeout / 1000);
178
+ const partial = output ? `\n\nPartial output before timeout:\n${output}` : '';
179
+ logger.exit('powershellTool.execute', { timedOut: true, outputLength: output.length });
180
+ return {
181
+ success: false,
182
+ error: `Command timed out after ${secs}s. For long-running commands, pass a larger \`timeout\` ` +
183
+ `(in ms) or run it in the background.${partial}`,
184
+ };
185
+ }
152
186
  if (execResult.exitCode !== 0) {
153
187
  output += `\n\n[Exit code: ${execResult.exitCode}]`;
154
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orquesta-cli",
3
- "version": "0.2.117",
3
+ "version": "0.2.119",
4
4
  "description": "Orquesta CLI - AI-powered coding assistant with team collaboration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",