@the-open-engine/zeroshot 6.6.0 → 6.7.1

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 (68) hide show
  1. package/bin/zeroshot-cluster-worker.js +16 -0
  2. package/cli/commands/providers.js +4 -1
  3. package/cli/index.js +153 -24
  4. package/docs/openengine-cluster-protocol/v1/legacy-worker.md +117 -0
  5. package/lib/agent-cli-provider/adapters/claude.d.ts.map +1 -1
  6. package/lib/agent-cli-provider/adapters/claude.js +23 -10
  7. package/lib/agent-cli-provider/adapters/claude.js.map +1 -1
  8. package/lib/agent-cli-provider/adapters/codex.d.ts.map +1 -1
  9. package/lib/agent-cli-provider/adapters/codex.js +4 -0
  10. package/lib/agent-cli-provider/adapters/codex.js.map +1 -1
  11. package/lib/agent-cli-provider/adapters/common.d.ts.map +1 -1
  12. package/lib/agent-cli-provider/adapters/common.js +2 -1
  13. package/lib/agent-cli-provider/adapters/common.js.map +1 -1
  14. package/lib/agent-cli-provider/contract-options.d.ts.map +1 -1
  15. package/lib/agent-cli-provider/contract-options.js +2 -1
  16. package/lib/agent-cli-provider/contract-options.js.map +1 -1
  17. package/lib/agent-cli-provider/index.d.ts +1 -1
  18. package/lib/agent-cli-provider/index.d.ts.map +1 -1
  19. package/lib/agent-cli-provider/index.js.map +1 -1
  20. package/lib/agent-cli-provider/provider-registry.d.ts +1 -1
  21. package/lib/agent-cli-provider/provider-registry.js +1 -1
  22. package/lib/agent-cli-provider/provider-registry.js.map +1 -1
  23. package/lib/agent-cli-provider/single-agent-runtime.js +6 -2
  24. package/lib/agent-cli-provider/single-agent-runtime.js.map +1 -1
  25. package/lib/agent-cli-provider/types.d.ts +3 -1
  26. package/lib/agent-cli-provider/types.d.ts.map +1 -1
  27. package/lib/agent-cli-provider/types.js.map +1 -1
  28. package/lib/cluster-worker/contracts.js +194 -0
  29. package/lib/cluster-worker/engine-adapter.js +300 -0
  30. package/lib/cluster-worker/executable.js +229 -0
  31. package/lib/cluster-worker/index.d.ts +227 -0
  32. package/lib/cluster-worker/index.js +294 -0
  33. package/lib/cluster-worker/object-utils.js +17 -0
  34. package/lib/cluster-worker/process-stdio.js +37 -0
  35. package/lib/cluster-worker/profiles.js +81 -0
  36. package/lib/cluster-worker/runtime-engine.js +50 -0
  37. package/lib/cluster-worker/runtime-support.js +298 -0
  38. package/lib/cluster-worker/state-machine.js +147 -0
  39. package/lib/cluster-worker/terminal-normalizer.js +95 -0
  40. package/lib/cluster-worker/worker-internals.js +20 -0
  41. package/lib/detached-startup.js +127 -11
  42. package/lib/process-liveness.js +26 -0
  43. package/lib/settings.js +1 -0
  44. package/lib/start-cluster.js +93 -18
  45. package/package.json +8 -2
  46. package/protocol/openengine-cluster/v1/worker.schema.json +1174 -0
  47. package/scripts/assert-release-published.js +65 -11
  48. package/scripts/run-lint-staged-no-stash.js +68 -0
  49. package/src/agent/agent-lifecycle.js +368 -91
  50. package/src/agent/agent-task-executor.js +384 -101
  51. package/src/agent-cli-provider/adapters/claude.ts +29 -11
  52. package/src/agent-cli-provider/adapters/codex.ts +4 -0
  53. package/src/agent-cli-provider/adapters/common.ts +2 -1
  54. package/src/agent-cli-provider/contract-options.ts +2 -1
  55. package/src/agent-cli-provider/index.ts +1 -0
  56. package/src/agent-cli-provider/provider-registry.ts +1 -1
  57. package/src/agent-cli-provider/single-agent-runtime.ts +8 -2
  58. package/src/agent-cli-provider/types.ts +3 -1
  59. package/src/agent-wrapper.js +9 -2
  60. package/src/config-validator.js +10 -11
  61. package/src/orchestrator.js +482 -67
  62. package/task-lib/attachable-watcher.js +10 -1
  63. package/task-lib/commands/kill.js +34 -9
  64. package/task-lib/commands/status.js +13 -3
  65. package/task-lib/process-termination.js +202 -0
  66. package/task-lib/runner.js +8 -20
  67. package/task-lib/store.js +28 -6
  68. package/task-lib/watcher.js +14 -2
@@ -2,6 +2,9 @@
2
2
 
3
3
  const { execFileSync } = require('child_process');
4
4
 
5
+ const DEFAULT_ATTEMPTS = 24;
6
+ const DEFAULT_DELAY_MS = 5000;
7
+
5
8
  function run(command, args) {
6
9
  return execFileSync(command, args, { encoding: 'utf8' }).trim();
7
10
  }
@@ -22,32 +25,83 @@ function tagsPointingAtHead() {
22
25
  .filter(Boolean);
23
26
  }
24
27
 
25
- function main() {
28
+ function releaseTagParts(tag) {
29
+ const match = tag.match(/^v(\d+)\.(\d+)\.(\d+)$/);
30
+ if (!match) return null;
31
+ return match.slice(1).map((part) => Number(part));
32
+ }
33
+
34
+ function compareReleaseTags(left, right) {
35
+ const leftParts = releaseTagParts(left);
36
+ const rightParts = releaseTagParts(right);
37
+ for (let index = 0; index < leftParts.length; index += 1) {
38
+ if (leftParts[index] !== rightParts[index]) return leftParts[index] - rightParts[index];
39
+ }
40
+ return 0;
41
+ }
42
+
43
+ function latestReleaseTag(tags) {
44
+ const releaseTags = tags.filter((tag) => releaseTagParts(tag));
45
+ releaseTags.sort(compareReleaseTags);
46
+ return releaseTags.at(-1) || null;
47
+ }
48
+
49
+ function sleep(ms) {
50
+ return new Promise((resolve) => {
51
+ setTimeout(resolve, ms);
52
+ });
53
+ }
54
+
55
+ async function waitForNpmLatest(name, expectedVersion, options = {}) {
56
+ const attempts =
57
+ options.attempts || Number(process.env.RELEASE_ASSERT_ATTEMPTS || DEFAULT_ATTEMPTS);
58
+ const delayMs =
59
+ options.delayMs || Number(process.env.RELEASE_ASSERT_DELAY_MS || DEFAULT_DELAY_MS);
60
+
61
+ let latest = null;
62
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
63
+ latest = npmLatest(name);
64
+ if (latest === expectedVersion) return latest;
65
+
66
+ if (attempt < attempts) {
67
+ console.log(
68
+ `npm latest for ${name} is ${latest}; waiting for ${expectedVersion} (${attempt}/${attempts})`
69
+ );
70
+ await sleep(delayMs);
71
+ }
72
+ }
73
+
74
+ throw new Error(`expected npm latest for ${name} to be ${expectedVersion}, got ${latest}`);
75
+ }
76
+
77
+ async function main() {
26
78
  const name = packageName();
27
- const latest = npmLatest(name);
28
- const expectedTag = `v${latest}`;
29
79
  const headTags = tagsPointingAtHead();
80
+ const expectedTag = latestReleaseTag(headTags);
81
+
82
+ if (!expectedTag) {
83
+ throw new Error('expected a vX.Y.Z release tag to point at HEAD after release');
84
+ }
30
85
 
31
- console.log(`npm latest for ${name}: ${latest}`);
32
86
  console.log(`tags on HEAD: ${headTags.join(', ') || '(none)'}`);
87
+ const expectedVersion = expectedTag.slice(1);
88
+ const latest = await waitForNpmLatest(name, expectedVersion);
33
89
 
34
- if (!headTags.includes(expectedTag)) {
35
- throw new Error(`expected ${expectedTag} to point at HEAD after release`);
36
- }
90
+ console.log(`npm latest for ${name}: ${latest}`);
37
91
 
38
92
  console.log(`Release publication verified: ${name}@${latest}`);
39
93
  }
40
94
 
41
95
  if (require.main === module) {
42
- try {
43
- main();
44
- } catch (error) {
96
+ main().catch((error) => {
45
97
  console.error(`Release publication check failed: ${error.message}`);
46
98
  process.exit(1);
47
- }
99
+ });
48
100
  }
49
101
 
50
102
  module.exports = {
103
+ latestReleaseTag,
51
104
  npmLatest,
52
105
  tagsPointingAtHead,
106
+ waitForNpmLatest,
53
107
  };
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const PATCH_NAME = 'lint-staged_unstaged.patch';
8
+ const GIT_APPLY_ARGS = ['apply', '-v', '--whitespace=nowarn', '--recount', '--unidiff-zero'];
9
+
10
+ function run(command, args, options = {}) {
11
+ return spawnSync(command, args, {
12
+ cwd: process.cwd(),
13
+ env: process.env,
14
+ stdio: options.stdio || 'inherit',
15
+ encoding: options.encoding,
16
+ });
17
+ }
18
+
19
+ function resolveUnstagedPatchPath() {
20
+ const result = run('git', ['rev-parse', '--git-path', PATCH_NAME], {
21
+ stdio: 'pipe',
22
+ encoding: 'utf8',
23
+ });
24
+ if (result.status !== 0) return null;
25
+ const gitPath = result.stdout.trim();
26
+ return path.isAbsolute(gitPath) ? gitPath : path.resolve(process.cwd(), gitPath);
27
+ }
28
+
29
+ function restoreUnstagedPatch(patchPath) {
30
+ const direct = run('git', [...GIT_APPLY_ARGS, patchPath]);
31
+ if (direct.status === 0) return true;
32
+
33
+ const threeWay = run('git', [...GIT_APPLY_ARGS, '--3way', patchPath]);
34
+ return threeWay.status === 0;
35
+ }
36
+
37
+ function main() {
38
+ const patchPath = resolveUnstagedPatchPath();
39
+ if (patchPath && fs.existsSync(patchPath)) {
40
+ console.error(
41
+ `ERROR: Refusing to overwrite unresolved unstaged changes at ${patchPath}.\n` +
42
+ `Restore them with 'git apply "${patchPath}"', then remove the patch before committing.`
43
+ );
44
+ return 1;
45
+ }
46
+
47
+ const lintStagedBin = require.resolve('lint-staged/bin');
48
+ const lintStaged = run(process.execPath, [lintStagedBin, '--no-stash', ...process.argv.slice(2)]);
49
+ const lintStatus = lintStaged.status ?? 1;
50
+
51
+ if (!patchPath || !fs.existsSync(patchPath)) {
52
+ return lintStatus;
53
+ }
54
+
55
+ if (lintStatus === 0 || restoreUnstagedPatch(patchPath)) {
56
+ fs.rmSync(patchPath, { force: true });
57
+ return lintStatus;
58
+ }
59
+
60
+ console.error(
61
+ `ERROR: lint-staged failed and unstaged changes conflicted with task edits.\n` +
62
+ `The commit remains blocked. Your unstaged changes are preserved at ${patchPath}.\n` +
63
+ `Resolve them with 'git apply --3way "${patchPath}"'; do not delete the patch first.`
64
+ );
65
+ return lintStatus;
66
+ }
67
+
68
+ process.exitCode = main();