@the-open-engine/zeroshot 6.11.0 → 6.12.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 (76) hide show
  1. package/cli/commands/providers.js +13 -13
  2. package/cli/index.js +77 -35
  3. package/cli/lib/first-run.js +12 -11
  4. package/cli/lib/update-checker.js +517 -132
  5. package/lib/agent-cli-provider/adapters/opencode.d.ts.map +1 -1
  6. package/lib/agent-cli-provider/adapters/opencode.js +3 -0
  7. package/lib/agent-cli-provider/adapters/opencode.js.map +1 -1
  8. package/lib/agent-cli-provider/types.d.ts +1 -0
  9. package/lib/agent-cli-provider/types.d.ts.map +1 -1
  10. package/lib/agent-cli-provider/types.js.map +1 -1
  11. package/lib/cluster/client.cjs +146 -0
  12. package/lib/cluster/client.d.ts +44 -0
  13. package/lib/cluster/client.mjs +141 -0
  14. package/lib/cluster/connection.cjs +382 -0
  15. package/lib/cluster/connection.d.ts +41 -0
  16. package/lib/cluster/connection.mjs +378 -0
  17. package/lib/cluster/errors.cjs +44 -0
  18. package/lib/cluster/errors.d.ts +23 -0
  19. package/lib/cluster/errors.mjs +32 -0
  20. package/lib/cluster/frames.cjs +49 -0
  21. package/lib/cluster/frames.d.ts +12 -0
  22. package/lib/cluster/frames.mjs +45 -0
  23. package/lib/cluster/generated/protocol-schema.cjs +5 -0
  24. package/lib/cluster/generated/protocol-schema.d.ts +1 -0
  25. package/lib/cluster/generated/protocol-schema.mjs +2 -0
  26. package/lib/cluster/generated/protocol.cjs +22 -0
  27. package/lib/cluster/generated/protocol.d.ts +781 -0
  28. package/lib/cluster/generated/protocol.mjs +19 -0
  29. package/lib/cluster/index.cjs +40 -0
  30. package/lib/cluster/index.d.ts +10 -0
  31. package/lib/cluster/index.mjs +6 -0
  32. package/lib/cluster/queue.cjs +71 -0
  33. package/lib/cluster/queue.d.ts +15 -0
  34. package/lib/cluster/queue.mjs +67 -0
  35. package/lib/cluster/socket.cjs +15 -0
  36. package/lib/cluster/socket.d.ts +11 -0
  37. package/lib/cluster/socket.mjs +12 -0
  38. package/lib/cluster/subscriptions.cjs +270 -0
  39. package/lib/cluster/subscriptions.d.ts +69 -0
  40. package/lib/cluster/subscriptions.mjs +264 -0
  41. package/lib/cluster/validators.cjs +46 -0
  42. package/lib/cluster/validators.d.ts +3 -0
  43. package/lib/cluster/validators.mjs +42 -0
  44. package/lib/settings.js +195 -23
  45. package/lib/setup-apply.js +45 -32
  46. package/lib/setup-undo.js +25 -16
  47. package/package.json +25 -3
  48. package/scripts/build-cluster.js +43 -0
  49. package/scripts/generate-cluster-types.js +203 -0
  50. package/scripts/release-dry-run.js +6 -6
  51. package/scripts/rust-distribution.js +933 -0
  52. package/src/agent/agent-hook-executor.js +14 -6
  53. package/src/agent/agent-lifecycle.js +25 -8
  54. package/src/agent/agent-task-executor.js +711 -139
  55. package/src/agent/output-reformatter.js +54 -41
  56. package/src/agent/pr-verification.js +11 -3
  57. package/src/agent/task-execution-handle.js +373 -0
  58. package/src/agent-cli-provider/adapters/opencode.ts +3 -0
  59. package/src/agent-cli-provider/types.ts +1 -0
  60. package/src/agent-wrapper.js +5 -2
  61. package/src/cluster/client.ts +199 -0
  62. package/src/cluster/connection.ts +300 -0
  63. package/src/cluster/errors.ts +32 -0
  64. package/src/cluster/frames.ts +44 -0
  65. package/src/cluster/generated/protocol-schema.ts +2 -0
  66. package/src/cluster/generated/protocol.ts +183 -0
  67. package/src/cluster/index.ts +38 -0
  68. package/src/cluster/queue.ts +84 -0
  69. package/src/cluster/socket.ts +31 -0
  70. package/src/cluster/subscriptions.ts +256 -0
  71. package/src/cluster/validators.ts +56 -0
  72. package/src/cluster/ws.d.ts +7 -0
  73. package/src/isolation-manager.js +16 -0
  74. package/src/issue-providers/jira-provider.js +1 -1
  75. package/src/issue-providers/linear-provider.js +4 -4
  76. package/task-lib/runner.js +3 -0
@@ -1,5 +1,5 @@
1
1
  const readline = require('readline');
2
- const { loadSettings, saveSettings } = require('../../lib/settings');
2
+ const { loadSettings, mutateSettings } = require('../../lib/settings');
3
3
  const {
4
4
  VALID_PROVIDERS,
5
5
  normalizeProviderName,
@@ -55,9 +55,9 @@ function setDefaultCommand(args) {
55
55
  process.exit(1);
56
56
  }
57
57
 
58
- const settings = loadSettings();
59
- settings.defaultProvider = provider;
60
- saveSettings(settings);
58
+ mutateSettings((settings) => {
59
+ settings.defaultProvider = provider;
60
+ });
61
61
 
62
62
  console.log(`Default provider set to: ${provider}`);
63
63
  }
@@ -135,15 +135,15 @@ async function setupCommand(args) {
135
135
  }
136
136
  }
137
137
 
138
- const settings = loadSettings();
139
- settings.providerSettings = settings.providerSettings || {};
140
- settings.providerSettings[provider] = {
141
- maxLevel: levelKeys[maxIdx - 1],
142
- minLevel: levelKeys[minIdx - 1],
143
- defaultLevel: levelKeys[defaultIdxNum - 1],
144
- levelOverrides,
145
- };
146
- saveSettings(settings);
138
+ mutateSettings((settings) => {
139
+ settings.providerSettings = settings.providerSettings || {};
140
+ settings.providerSettings[provider] = {
141
+ maxLevel: levelKeys[maxIdx - 1],
142
+ minLevel: levelKeys[minIdx - 1],
143
+ defaultLevel: levelKeys[defaultIdxNum - 1],
144
+ levelOverrides,
145
+ };
146
+ });
147
147
 
148
148
  console.log(`\n✓ ${providerModule.displayName} configured successfully`);
149
149
  } finally {
package/cli/index.js CHANGED
@@ -42,9 +42,10 @@ const {
42
42
  } = require('./message-formatter-utils');
43
43
  const {
44
44
  loadSettings,
45
- saveSettings,
45
+ mutateSettings,
46
46
  validateSetting,
47
47
  coerceValue,
48
+ SettingsValidationError,
48
49
  DEFAULT_SETTINGS,
49
50
  settingsFileExists,
50
51
  } = require('../lib/settings');
@@ -81,7 +82,12 @@ const {
81
82
  } = require('../lib/detached-startup');
82
83
  const { isProcessRunning: isClusterProcessAlive } = require('../lib/process-liveness');
83
84
  // Setup wizard removed - use: zeroshot settings set <key> <value>
84
- const { checkForUpdates, printLegacyDistroNotice } = require('./lib/update-checker');
85
+ const {
86
+ checkForUpdates,
87
+ isAutomaticUpdateEligible,
88
+ printLegacyDistroNotice,
89
+ runLegacyUpdateIfRequested,
90
+ } = require('./lib/update-checker');
85
91
  const { checkBinDirOnPath, printPathWarning } = require('../lib/path-check');
86
92
  const { StatusFooter, AGENT_STATE, ACTIVE_STATES } = require('../src/status-footer');
87
93
  const { EVENT_COPY, formatMergeStatus } = require('./event-copy');
@@ -3853,6 +3859,11 @@ for (const providerName of VALID_PROVIDERS) {
3853
3859
 
3854
3860
  // Settings management
3855
3861
  const settingsCmd = program.command('settings').description('Manage zeroshot settings');
3862
+ const INTERNAL_SETTINGS_KEYS = new Set(['lastUpdateCheckClaim']);
3863
+
3864
+ function visibleSettingKeys() {
3865
+ return Object.keys(DEFAULT_SETTINGS).filter((key) => !INTERNAL_SETTINGS_KEYS.has(key));
3866
+ }
3856
3867
 
3857
3868
  function printSettingsUsage() {
3858
3869
  const mountPresetList = Object.keys(MOUNT_PRESETS).join(', ');
@@ -3873,7 +3884,7 @@ function printSettingsUsage() {
3873
3884
  function printNonDockerSettings(settings) {
3874
3885
  const dockerKeys = new Set(['dockerMounts', 'dockerEnvPassthrough', 'dockerContainerHome']);
3875
3886
  for (const [key, value] of Object.entries(settings)) {
3876
- if (dockerKeys.has(key)) {
3887
+ if (dockerKeys.has(key) || INTERNAL_SETTINGS_KEYS.has(key)) {
3877
3888
  continue;
3878
3889
  }
3879
3890
  const displayValue =
@@ -4227,6 +4238,13 @@ function parseSettingValue(value) {
4227
4238
  }
4228
4239
  }
4229
4240
 
4241
+ function resetGlobalSettings() {
4242
+ mutateSettings((settings) => {
4243
+ for (const key of Object.keys(settings)) delete settings[key];
4244
+ Object.assign(settings, JSON.parse(JSON.stringify({ ...DEFAULT_SETTINGS })));
4245
+ });
4246
+ }
4247
+
4230
4248
  settingsCmd
4231
4249
  .command('get <key>')
4232
4250
  .description(
@@ -4235,7 +4253,10 @@ settingsCmd
4235
4253
  .action((key) => {
4236
4254
  const settings = loadSettings();
4237
4255
 
4238
- // Support dot-notation for nested values
4256
+ if (INTERNAL_SETTINGS_KEYS.has(key.split('.')[0])) {
4257
+ console.error(chalk.red(`Setting not found: ${key}`));
4258
+ process.exit(1);
4259
+ }
4239
4260
  if (key.includes('.')) {
4240
4261
  const { value, found } = getNestedValue(settings, key);
4241
4262
  if (!found) {
@@ -4249,7 +4270,7 @@ settingsCmd
4249
4270
  if (!(key in settings)) {
4250
4271
  console.error(chalk.red(`Unknown setting: ${key}`));
4251
4272
  console.log(chalk.dim('\nAvailable settings:'));
4252
- Object.keys(DEFAULT_SETTINGS).forEach((k) => console.log(chalk.dim(` - ${k}`)));
4273
+ visibleSettingKeys().forEach((k) => console.log(chalk.dim(` - ${k}`)));
4253
4274
  process.exit(1);
4254
4275
  }
4255
4276
  console.log(
@@ -4263,34 +4284,35 @@ settingsCmd
4263
4284
  'Set a setting value (supports dot-notation: providerSettings.claude.anthropicApiKey)'
4264
4285
  )
4265
4286
  .action((key, value) => {
4266
- const settings = loadSettings();
4267
-
4287
+ if (INTERNAL_SETTINGS_KEYS.has(key.split('.')[0])) {
4288
+ console.error(chalk.red(`Unknown setting: ${key}`));
4289
+ process.exit(1);
4290
+ }
4268
4291
  // Support dot-notation for nested values
4269
4292
  if (key.includes('.')) {
4270
- const parts = key.split('.');
4271
- const rootKey = parts[0];
4293
+ const rootKey = key.split('.')[0];
4272
4294
 
4273
- // Validate root key exists in defaults
4274
4295
  if (!(rootKey in DEFAULT_SETTINGS)) {
4275
4296
  console.error(chalk.red(`Unknown setting: ${rootKey}`));
4276
4297
  console.log(chalk.dim('\nAvailable settings:'));
4277
- Object.keys(DEFAULT_SETTINGS).forEach((k) => console.log(chalk.dim(` - ${k}`)));
4298
+ visibleSettingKeys().forEach((k) => console.log(chalk.dim(` - ${k}`)));
4278
4299
  process.exit(1);
4279
4300
  }
4280
4301
 
4281
4302
  const parsedValue = parseSettingValue(value);
4282
-
4283
- // Set nested value
4284
- setNestedValue(settings, key, parsedValue);
4285
-
4286
- // Validate the root key after modification
4287
- const validationError = validateSetting(rootKey, settings[rootKey]);
4288
- if (validationError) {
4289
- console.error(chalk.red(validationError));
4290
- process.exit(1);
4303
+ try {
4304
+ mutateSettings((settings) => {
4305
+ setNestedValue(settings, key, parsedValue);
4306
+ const validationError = validateSetting(rootKey, settings[rootKey]);
4307
+ if (validationError) throw new SettingsValidationError(validationError);
4308
+ });
4309
+ } catch (error) {
4310
+ if (!(error instanceof SettingsValidationError)) throw error;
4311
+ console.error(chalk.red(error.message));
4312
+ process.exitCode = 1;
4313
+ return;
4291
4314
  }
4292
4315
 
4293
- saveSettings(settings);
4294
4316
  const displayValue =
4295
4317
  typeof parsedValue === 'string' ? parsedValue : JSON.stringify(parsedValue);
4296
4318
  console.log(chalk.green(`✓ Set ${key} = ${displayValue}`));
@@ -4301,7 +4323,7 @@ settingsCmd
4301
4323
  if (!(key in DEFAULT_SETTINGS)) {
4302
4324
  console.error(chalk.red(`Unknown setting: ${key}`));
4303
4325
  console.log(chalk.dim('\nAvailable settings:'));
4304
- Object.keys(DEFAULT_SETTINGS).forEach((k) => console.log(chalk.dim(` - ${k}`)));
4326
+ visibleSettingKeys().forEach((k) => console.log(chalk.dim(` - ${k}`)));
4305
4327
  process.exit(1);
4306
4328
  }
4307
4329
 
@@ -4321,8 +4343,9 @@ settingsCmd
4321
4343
  process.exit(1);
4322
4344
  }
4323
4345
 
4324
- settings[key] = parsedValue;
4325
- saveSettings(settings);
4346
+ mutateSettings((settings) => {
4347
+ settings[key] = parsedValue;
4348
+ });
4326
4349
  console.log(chalk.green(`✓ Set ${key} = ${JSON.stringify(parsedValue)}`));
4327
4350
  });
4328
4351
 
@@ -4344,11 +4367,16 @@ settingsCmd
4344
4367
  console.log('Aborted.');
4345
4368
  return;
4346
4369
  }
4347
- saveSettings(DEFAULT_SETTINGS);
4348
- console.log(chalk.green('✓ Settings reset to defaults'));
4370
+ try {
4371
+ resetGlobalSettings();
4372
+ console.log(chalk.green('✓ Settings reset to defaults'));
4373
+ } catch (error) {
4374
+ console.error(chalk.red(error.message));
4375
+ process.exitCode = 1;
4376
+ }
4349
4377
  });
4350
4378
  } else {
4351
- saveSettings(DEFAULT_SETTINGS);
4379
+ resetGlobalSettings();
4352
4380
  console.log(chalk.green('✓ Settings reset to defaults'));
4353
4381
  }
4354
4382
  });
@@ -5910,11 +5938,17 @@ function printMessage(msg, showClusterId = false, watchMode = false, isActive =
5910
5938
  formatGenericMessage(msg, prefix, timestamp, safePrint);
5911
5939
  }
5912
5940
 
5913
- // Main async entry point
5914
- async function main() {
5915
- const isTest = process.env.NODE_ENV === 'test';
5916
- const isQuiet = process.argv.includes('-q') || process.argv.includes('--quiet') || isTest;
5941
+ function isStartupUpdateEligible(argv, options = {}) {
5942
+ return isAutomaticUpdateEligible({
5943
+ ...options,
5944
+ argv,
5945
+ commanderProgram: program,
5946
+ defaultCommandName: 'run',
5947
+ });
5948
+ }
5917
5949
 
5950
+ // Main entry point
5951
+ async function main() {
5918
5952
  printLegacyDistroNotice();
5919
5953
 
5920
5954
  try {
@@ -5926,12 +5960,19 @@ async function main() {
5926
5960
  // Never block CLI startup on a PATH check failure
5927
5961
  }
5928
5962
 
5929
- // Check for updates (non-blocking if offline)
5930
- if (!isTest) {
5931
- await checkForUpdates({ quiet: isQuiet });
5963
+ const startupArgs = process.argv.slice(2);
5964
+ const legacyUpdate = runLegacyUpdateIfRequested(startupArgs);
5965
+ if (legacyUpdate !== null) {
5966
+ const success = await legacyUpdate;
5967
+ process.exitCode = success ? 0 : 1;
5968
+ return;
5969
+ }
5970
+
5971
+ if (isStartupUpdateEligible(startupArgs)) {
5972
+ checkForUpdates({ argv: startupArgs, eligibilityChecked: true });
5932
5973
  }
5933
5974
 
5934
- let args = process.argv.slice(2);
5975
+ let args = startupArgs;
5935
5976
 
5936
5977
  if (args.length === 0) {
5937
5978
  program.outputHelp();
@@ -5973,5 +6014,6 @@ module.exports = {
5973
6014
  inspectAgentAttachment,
5974
6015
  printAttachableAgentList,
5975
6016
  renderRecentMessagesToTerminal,
6017
+ isStartupUpdateEligible,
5976
6018
  resolveRunMode,
5977
6019
  };
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  const readline = require('readline');
12
- const { loadSettings, saveSettings } = require('../../lib/settings');
12
+ const { loadSettings, mutateSettings } = require('../../lib/settings');
13
13
  const { listProviderMetadata } = require('../../lib/provider-names');
14
14
  const { detectProviders } = require('../../src/providers');
15
15
 
@@ -175,8 +175,9 @@ async function checkFirstRun(options = {}) {
175
175
 
176
176
  // Quiet mode - use defaults, mark complete
177
177
  if (options.quiet) {
178
- settings.firstRunComplete = true;
179
- saveSettings(settings);
178
+ mutateSettings((current) => {
179
+ current.firstRunComplete = true;
180
+ });
180
181
  return true;
181
182
  }
182
183
 
@@ -188,22 +189,22 @@ async function checkFirstRun(options = {}) {
188
189
  try {
189
190
  const detected = await detectProviders();
190
191
  const provider = await promptProvider(rl, detected);
191
- settings.defaultProvider = provider;
192
-
193
192
  // Model ceiling selection
194
193
  const model = await promptModel(rl);
195
- settings.maxModel = model;
196
194
 
197
195
  // Auto-update preference
198
196
  const autoUpdate = await promptAutoUpdate(rl);
199
- settings.autoCheckUpdates = autoUpdate;
200
197
 
201
- // Mark complete
202
- settings.firstRunComplete = true;
203
- saveSettings(settings);
198
+ const savedSettings = mutateSettings((current) => {
199
+ current.defaultProvider = provider;
200
+ current.maxModel = model;
201
+ current.autoCheckUpdates = autoUpdate;
202
+ current.firstRunComplete = true;
203
+ return current;
204
+ });
204
205
 
205
206
  // Print completion
206
- printComplete(settings);
207
+ printComplete(savedSettings);
207
208
 
208
209
  return true;
209
210
  } finally {