@phuetz/code-buddy 2.1.0 → 2.2.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 (41) hide show
  1. package/README.fr.md +2 -2
  2. package/README.md +3 -2
  3. package/codebuddy-runtime.json +4 -4
  4. package/dist/agent/execution/agent-executor.js +16 -5
  5. package/dist/agent/execution/tool-selection-strategy.d.ts +7 -0
  6. package/dist/agent/execution/tool-selection-strategy.js +13 -0
  7. package/dist/codebuddy/fleet-tool-defs.d.ts +1 -0
  8. package/dist/codebuddy/fleet-tool-defs.js +31 -0
  9. package/dist/codebuddy/providers/provider-openai-compat.d.ts +7 -0
  10. package/dist/codebuddy/providers/provider-openai-compat.js +28 -0
  11. package/dist/commands/handlers/missing-handlers.js +8 -0
  12. package/dist/commands/mcp.d.ts +13 -0
  13. package/dist/commands/mcp.js +62 -21
  14. package/dist/config/model-tools.js +99 -0
  15. package/dist/doctor/integrations.d.ts +18 -0
  16. package/dist/doctor/integrations.js +14 -0
  17. package/dist/errors/crash-handler.js +2 -0
  18. package/dist/mcp/client.d.ts +11 -0
  19. package/dist/mcp/client.js +62 -3
  20. package/dist/mcp/mcp-oauth-constants.d.ts +8 -0
  21. package/dist/mcp/mcp-oauth-constants.js +9 -0
  22. package/dist/mcp/mcp-oauth-provider.d.ts +80 -0
  23. package/dist/mcp/mcp-oauth-provider.js +241 -0
  24. package/dist/mcp/mcp-oauth.d.ts +60 -1
  25. package/dist/mcp/mcp-oauth.js +241 -65
  26. package/dist/mcp/transports.d.ts +4 -0
  27. package/dist/mcp/transports.js +52 -3
  28. package/dist/services/prompt-builder.js +3 -1
  29. package/dist/services/runtime-settings-context.d.ts +8 -0
  30. package/dist/services/runtime-settings-context.js +11 -1
  31. package/dist/tools/metadata.js +9 -0
  32. package/dist/tools/peer-tool-invoke-tool.d.ts +61 -0
  33. package/dist/tools/peer-tool-invoke-tool.js +396 -0
  34. package/dist/tools/registry/fleet-tools.d.ts +12 -3
  35. package/dist/tools/registry/fleet-tools.js +116 -4
  36. package/dist/tools/registry/index.d.ts +1 -1
  37. package/dist/tools/registry/index.js +2 -2
  38. package/dist/utils/config-validation/schema.d.ts +2 -2
  39. package/dist/utils/graceful-shutdown.d.ts +8 -0
  40. package/dist/utils/graceful-shutdown.js +23 -7
  41. package/package.json +1 -1
@@ -12,6 +12,22 @@
12
12
  */
13
13
  import { logger, getLogger } from './logger.js';
14
14
  import { DisposableManager, registerDisposable } from './disposable.js';
15
+ import { EXIT_CODES } from './exit-codes.js';
16
+ /**
17
+ * Exit code after a shutdown signal. Only an explicit headless run (`-p`, loop,
18
+ * try: CODEBUDDY_HEADLESS=true) reports SIGINT as 130 (USER_CANCELLED), so a
19
+ * script can tell an interruption from success. Servers and daemons whose stdout
20
+ * is merely not a TTY (systemd) keep exit 0: a normal SIGTERM stop must not be
21
+ * reported as a failure and trigger Restart=on-failure.
22
+ */
23
+ export function signalExitCode(signal, env = process.env) {
24
+ if (env.CODEBUDDY_HEADLESS !== 'true')
25
+ return 0;
26
+ return signal === 'SIGINT' ? EXIT_CODES.USER_CANCELLED : 0;
27
+ }
28
+ function shutdownProgressStream() {
29
+ return process.stdout.isTTY ? process.stdout : process.stderr;
30
+ }
15
31
  const DEFAULT_OPTIONS = {
16
32
  timeoutMs: 30000, // 30 seconds max before force exit
17
33
  forceExitOnTimeout: true,
@@ -69,7 +85,7 @@ export class GracefulShutdownManager {
69
85
  // Show user-friendly message
70
86
  logger.info(`Received ${signal}. Shutting down gracefully...`);
71
87
  try {
72
- await this.shutdown({ exitCode: 0 });
88
+ await this.shutdown({ exitCode: signalExitCode(signal) });
73
89
  }
74
90
  catch (error) {
75
91
  logger.error('Error during shutdown', error instanceof Error ? error : new Error(String(error)));
@@ -232,7 +248,7 @@ export class GracefulShutdownManager {
232
248
  for (const handler of this.handlers) {
233
249
  try {
234
250
  if (showProgress) {
235
- process.stdout.write(` [shutdown] ${handler.name}...`);
251
+ shutdownProgressStream().write(` [shutdown] ${handler.name}...`);
236
252
  }
237
253
  logger.debug(`Running shutdown handler: ${handler.name}`);
238
254
  const result = handler.handler();
@@ -241,14 +257,14 @@ export class GracefulShutdownManager {
241
257
  }
242
258
  this.completedHandlers.add(handler.name);
243
259
  if (showProgress) {
244
- process.stdout.write(' done\n');
260
+ shutdownProgressStream().write(' done\n');
245
261
  }
246
262
  logger.debug(`Completed shutdown handler: ${handler.name}`);
247
263
  }
248
264
  catch (error) {
249
265
  this.completedHandlers.add(handler.name); // Mark as completed even on error
250
266
  if (showProgress) {
251
- process.stdout.write(' failed\n');
267
+ shutdownProgressStream().write(' failed\n');
252
268
  }
253
269
  logger.error(`Error in shutdown handler ${handler.name}:`, error instanceof Error ? error : new Error(String(error)));
254
270
  // Continue with other handlers even if one fails
@@ -257,18 +273,18 @@ export class GracefulShutdownManager {
257
273
  // Then, dispose all registered disposables
258
274
  try {
259
275
  if (showProgress) {
260
- process.stdout.write(' [shutdown] disposing resources...');
276
+ shutdownProgressStream().write(' [shutdown] disposing resources...');
261
277
  }
262
278
  logger.debug('Disposing all registered resources...');
263
279
  await DisposableManager.getInstance().disposeAll();
264
280
  if (showProgress) {
265
- process.stdout.write(' done\n');
281
+ shutdownProgressStream().write(' done\n');
266
282
  }
267
283
  logger.debug('All resources disposed');
268
284
  }
269
285
  catch (error) {
270
286
  if (showProgress) {
271
- process.stdout.write(' failed\n');
287
+ shutdownProgressStream().write(' failed\n');
272
288
  }
273
289
  logger.error('Error disposing resources:', error instanceof Error ? error : new Error(String(error)));
274
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phuetz/code-buddy",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "AI coding agent with terminal and HTTP interfaces, optional Cowork desktop integration, multi-provider routing, tools, fleet collaboration and inspectable memory. See release notes for supported integrations and limits.",
5
5
  "author": "Patrice Huetz <patrice.huetz@gmail.com>",
6
6
  "repository": {