@orchagent/cli 0.3.74 → 0.3.76

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerCommands = registerCommands;
4
4
  const login_1 = require("./login");
5
+ const logout_1 = require("./logout");
5
6
  const call_1 = require("./call");
6
7
  const agents_1 = require("./agents");
7
8
  const init_1 = require("./init");
@@ -37,6 +38,7 @@ const logs_1 = require("./logs");
37
38
  const secrets_1 = require("./secrets");
38
39
  function registerCommands(program) {
39
40
  (0, login_1.registerLoginCommand)(program);
41
+ (0, logout_1.registerLogoutCommand)(program);
40
42
  (0, whoami_1.registerWhoamiCommand)(program);
41
43
  (0, init_1.registerInitCommand)(program);
42
44
  (0, publish_1.registerPublishCommand)(program);
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerLogoutCommand = registerLogoutCommand;
4
+ const config_1 = require("../lib/config");
5
+ const api_1 = require("../lib/api");
6
+ const analytics_1 = require("../lib/analytics");
7
+ function registerLogoutCommand(program) {
8
+ program
9
+ .command('logout')
10
+ .description('Log out of orchagent (revokes API key and clears local credentials)')
11
+ .action(async () => {
12
+ const config = await (0, config_1.loadConfig)();
13
+ // Check if already logged out
14
+ if (!config.api_key && !process.env.ORCHAGENT_API_KEY) {
15
+ process.stdout.write('Not logged in.\n');
16
+ return;
17
+ }
18
+ const resolved = await (0, config_1.getResolvedConfig)();
19
+ // Best-effort server-side key revocation (Vercel/Fly pattern)
20
+ if (resolved.apiKey) {
21
+ try {
22
+ await (0, api_1.safeFetch)(`${resolved.apiUrl}/auth/cli-logout`, {
23
+ method: 'POST',
24
+ headers: {
25
+ Authorization: `Bearer ${resolved.apiKey}`,
26
+ },
27
+ });
28
+ }
29
+ catch {
30
+ // Network errors, server down, etc. — proceed with local cleanup
31
+ }
32
+ }
33
+ // Clear auth fields but preserve user preferences
34
+ delete config.api_key;
35
+ delete config.default_org;
36
+ delete config.workspace;
37
+ await (0, config_1.saveConfig)(config);
38
+ await (0, analytics_1.track)('cli_logout', {});
39
+ process.stdout.write('Logged out.\n');
40
+ // Warn if env var is still set (GitHub CLI / Fly.io pattern)
41
+ if (process.env.ORCHAGENT_API_KEY) {
42
+ process.stderr.write('\nWarning: ORCHAGENT_API_KEY is set in your environment.\n' +
43
+ 'The env var will still authenticate requests. Unset it with:\n' +
44
+ ' unset ORCHAGENT_API_KEY\n');
45
+ }
46
+ });
47
+ }
@@ -310,7 +310,7 @@ async function downloadBundle(config, org, agent, version, agentId) {
310
310
  }
311
311
  async function unzipBundle(zipPath, destDir) {
312
312
  return new Promise((resolve, reject) => {
313
- const proc = (0, child_process_1.spawn)('unzip', ['-q', zipPath, '-d', destDir], {
313
+ const proc = (0, child_process_1.spawn)('unzip', ['-o', '-q', zipPath, '-d', destDir], {
314
314
  stdio: ['ignore', 'pipe', 'pipe'],
315
315
  });
316
316
  let stderr = '';
@@ -397,26 +397,12 @@ Examples:
397
397
  const filesWritten = [];
398
398
  const warnings = [];
399
399
  let bundleExtracted = false;
400
- // Write orchagent.json
401
- const manifest = buildManifest(data);
402
- await promises_1.default.writeFile(path_1.default.join(outputDir, 'orchagent.json'), JSON.stringify(manifest, null, 2) + '\n');
403
- filesWritten.push('orchagent.json');
404
- // Write prompt.md (for prompt-driven engines)
405
- if (data.prompt && (engine === 'direct_llm' || engine === 'managed_loop')) {
406
- await promises_1.default.writeFile(path_1.default.join(outputDir, 'prompt.md'), data.prompt);
407
- filesWritten.push('prompt.md');
408
- }
409
- // Write schema.json (if schemas exist)
410
- if (data.input_schema || data.output_schema) {
411
- const schema = {};
412
- if (data.input_schema)
413
- schema.input = data.input_schema;
414
- if (data.output_schema)
415
- schema.output = data.output_schema;
416
- await promises_1.default.writeFile(path_1.default.join(outputDir, 'schema.json'), JSON.stringify(schema, null, 2) + '\n');
417
- filesWritten.push('schema.json');
418
- }
419
- // Bundle download for code_runtime agents
400
+ // Extract bundle FIRST for code_runtime agents.
401
+ // Metadata files (orchagent.json, schema.json) are written AFTER so they
402
+ // always take precedence over anything the bundle may contain. This also
403
+ // avoids the interactive overwrite prompt that `unzip` issues when a file
404
+ // already exists on disk — in non-interactive shells the prompt causes EOF
405
+ // and exit-code 1.
420
406
  if (engine === 'code_runtime' && data.has_bundle) {
421
407
  write('Downloading code bundle...\n');
422
408
  const bundle = await downloadBundle(config, org, data.name, data.version, data.agentId);
@@ -441,6 +427,25 @@ Examples:
441
427
  else if (engine === 'code_runtime' && !data.has_bundle) {
442
428
  warnings.push('No downloadable bundle available for this version.');
443
429
  }
430
+ // Write orchagent.json (after bundle extraction so it always wins)
431
+ const manifest = buildManifest(data);
432
+ await promises_1.default.writeFile(path_1.default.join(outputDir, 'orchagent.json'), JSON.stringify(manifest, null, 2) + '\n');
433
+ filesWritten.push('orchagent.json');
434
+ // Write prompt.md (for prompt-driven engines)
435
+ if (data.prompt && (engine === 'direct_llm' || engine === 'managed_loop')) {
436
+ await promises_1.default.writeFile(path_1.default.join(outputDir, 'prompt.md'), data.prompt);
437
+ filesWritten.push('prompt.md');
438
+ }
439
+ // Write schema.json (if schemas exist)
440
+ if (data.input_schema || data.output_schema) {
441
+ const schema = {};
442
+ if (data.input_schema)
443
+ schema.input = data.input_schema;
444
+ if (data.output_schema)
445
+ schema.output = data.output_schema;
446
+ await promises_1.default.writeFile(path_1.default.join(outputDir, 'schema.json'), JSON.stringify(schema, null, 2) + '\n');
447
+ filesWritten.push('schema.json');
448
+ }
444
449
  // Track analytics
445
450
  await (0, analytics_1.track)('cli_pull', {
446
451
  org,
@@ -1002,7 +1002,7 @@ async function executeTool(agentData, args) {
1002
1002
  }
1003
1003
  async function unzipBundle(zipPath, destDir) {
1004
1004
  return new Promise((resolve, reject) => {
1005
- const proc = (0, child_process_1.spawn)('unzip', ['-q', zipPath, '-d', destDir], {
1005
+ const proc = (0, child_process_1.spawn)('unzip', ['-o', '-q', zipPath, '-d', destDir], {
1006
1006
  stdio: ['ignore', 'pipe', 'pipe'],
1007
1007
  });
1008
1008
  let stderr = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchagent/cli",
3
- "version": "0.3.74",
3
+ "version": "0.3.76",
4
4
  "description": "Command-line interface for orchagent — deploy and run AI agents for your team",
5
5
  "license": "MIT",
6
6
  "author": "orchagent <hello@orchagent.io>",