@covibes/zeroshot 5.4.0 → 5.4.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 (136) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -465
  3. package/cli/index.js +101 -5231
  4. package/package.json +16 -130
  5. package/CHANGELOG.md +0 -537
  6. package/cli/commands/providers.js +0 -149
  7. package/cli/lib/first-run.js +0 -211
  8. package/cli/lib/update-checker.js +0 -281
  9. package/cli/message-formatter-utils.js +0 -75
  10. package/cli/message-formatters-normal.js +0 -275
  11. package/cli/message-formatters-watch.js +0 -181
  12. package/cluster-templates/base-templates/debug-workflow.json +0 -375
  13. package/cluster-templates/base-templates/full-workflow.json +0 -581
  14. package/cluster-templates/base-templates/single-worker.json +0 -63
  15. package/cluster-templates/base-templates/worker-validator.json +0 -208
  16. package/cluster-templates/conductor-bootstrap.json +0 -124
  17. package/docker/zeroshot-cluster/Dockerfile +0 -152
  18. package/docker/zeroshot-cluster/pre-baked-deps.json +0 -28
  19. package/lib/completion.js +0 -174
  20. package/lib/docker-config.js +0 -220
  21. package/lib/git-remote-utils.js +0 -165
  22. package/lib/id-detector.js +0 -56
  23. package/lib/provider-defaults.js +0 -62
  24. package/lib/provider-detection.js +0 -59
  25. package/lib/provider-names.js +0 -57
  26. package/lib/settings/claude-auth.js +0 -78
  27. package/lib/settings.js +0 -503
  28. package/lib/stream-json-parser.js +0 -10
  29. package/scripts/fix-node-pty-permissions.js +0 -75
  30. package/scripts/record-demo.sh +0 -279
  31. package/scripts/setup-merge-queue.sh +0 -170
  32. package/scripts/test-install.sh +0 -40
  33. package/scripts/validate-templates.js +0 -100
  34. package/src/agent/agent-config.js +0 -246
  35. package/src/agent/agent-context-builder.js +0 -444
  36. package/src/agent/agent-hook-executor.js +0 -599
  37. package/src/agent/agent-lifecycle.js +0 -743
  38. package/src/agent/agent-stuck-detector.js +0 -256
  39. package/src/agent/agent-task-executor.js +0 -1690
  40. package/src/agent/agent-trigger-evaluator.js +0 -67
  41. package/src/agent/output-extraction.js +0 -217
  42. package/src/agent/output-reformatter.js +0 -175
  43. package/src/agent/schema-utils.js +0 -146
  44. package/src/agent-wrapper.js +0 -579
  45. package/src/agents/git-pusher-template.js +0 -285
  46. package/src/attach/attach-client.js +0 -438
  47. package/src/attach/attach-server.js +0 -543
  48. package/src/attach/index.js +0 -35
  49. package/src/attach/protocol.js +0 -220
  50. package/src/attach/ring-buffer.js +0 -121
  51. package/src/attach/socket-discovery.js +0 -267
  52. package/src/claude-task-runner.js +0 -574
  53. package/src/config-router.js +0 -80
  54. package/src/config-validator.js +0 -1925
  55. package/src/copy-worker.js +0 -43
  56. package/src/input-helpers.js +0 -65
  57. package/src/isolation-manager.js +0 -1471
  58. package/src/issue-providers/README.md +0 -305
  59. package/src/issue-providers/azure-devops-provider.js +0 -273
  60. package/src/issue-providers/base-provider.js +0 -232
  61. package/src/issue-providers/github-provider.js +0 -179
  62. package/src/issue-providers/gitlab-provider.js +0 -241
  63. package/src/issue-providers/index.js +0 -196
  64. package/src/issue-providers/jira-provider.js +0 -239
  65. package/src/ledger.js +0 -631
  66. package/src/lib/safe-exec.js +0 -88
  67. package/src/logic-engine.js +0 -223
  68. package/src/message-bus-bridge.js +0 -139
  69. package/src/message-bus.js +0 -249
  70. package/src/name-generator.js +0 -232
  71. package/src/orchestrator.js +0 -2815
  72. package/src/preflight.js +0 -639
  73. package/src/process-metrics.js +0 -608
  74. package/src/providers/anthropic/cli-builder.js +0 -73
  75. package/src/providers/anthropic/index.js +0 -204
  76. package/src/providers/anthropic/models.js +0 -23
  77. package/src/providers/anthropic/output-parser.js +0 -177
  78. package/src/providers/base-provider.js +0 -251
  79. package/src/providers/capabilities.js +0 -60
  80. package/src/providers/google/cli-builder.js +0 -55
  81. package/src/providers/google/index.js +0 -116
  82. package/src/providers/google/models.js +0 -24
  83. package/src/providers/google/output-parser.js +0 -101
  84. package/src/providers/index.js +0 -91
  85. package/src/providers/openai/cli-builder.js +0 -133
  86. package/src/providers/openai/index.js +0 -136
  87. package/src/providers/openai/models.js +0 -21
  88. package/src/providers/openai/output-parser.js +0 -143
  89. package/src/providers/opencode/cli-builder.js +0 -42
  90. package/src/providers/opencode/index.js +0 -103
  91. package/src/providers/opencode/models.js +0 -55
  92. package/src/providers/opencode/output-parser.js +0 -122
  93. package/src/schemas/sub-cluster.js +0 -185
  94. package/src/status-footer.js +0 -1026
  95. package/src/sub-cluster-wrapper.js +0 -601
  96. package/src/task-runner.js +0 -30
  97. package/src/template-resolver.js +0 -372
  98. package/src/tui/CHANGES.txt +0 -133
  99. package/src/tui/LAYOUT.md +0 -261
  100. package/src/tui/README.txt +0 -192
  101. package/src/tui/TWO-LEVEL-NAVIGATION.md +0 -186
  102. package/src/tui/data-poller.js +0 -349
  103. package/src/tui/demo.js +0 -208
  104. package/src/tui/formatters.js +0 -129
  105. package/src/tui/index.js +0 -193
  106. package/src/tui/keybindings.js +0 -324
  107. package/src/tui/layout.js +0 -334
  108. package/src/tui/renderer.js +0 -184
  109. package/task-lib/attachable-watcher.js +0 -309
  110. package/task-lib/claude-recovery.js +0 -156
  111. package/task-lib/commands/clean.js +0 -50
  112. package/task-lib/commands/episodes.js +0 -105
  113. package/task-lib/commands/get-log-path.js +0 -23
  114. package/task-lib/commands/kill.js +0 -32
  115. package/task-lib/commands/list.js +0 -105
  116. package/task-lib/commands/logs.js +0 -453
  117. package/task-lib/commands/resume.js +0 -42
  118. package/task-lib/commands/run.js +0 -57
  119. package/task-lib/commands/schedule.js +0 -105
  120. package/task-lib/commands/scheduler-cmd.js +0 -96
  121. package/task-lib/commands/schedules.js +0 -148
  122. package/task-lib/commands/status.js +0 -44
  123. package/task-lib/commands/unschedule.js +0 -16
  124. package/task-lib/completion.js +0 -9
  125. package/task-lib/config.js +0 -8
  126. package/task-lib/name-generator.js +0 -230
  127. package/task-lib/package.json +0 -3
  128. package/task-lib/runner.js +0 -201
  129. package/task-lib/scheduler.js +0 -252
  130. package/task-lib/store.js +0 -529
  131. package/task-lib/tui/formatters.js +0 -215
  132. package/task-lib/tui/index.js +0 -197
  133. package/task-lib/tui/layout.js +0 -111
  134. package/task-lib/tui/renderer.js +0 -129
  135. package/task-lib/tui.js +0 -425
  136. package/task-lib/watcher.js +0 -226
@@ -1,256 +0,0 @@
1
- /**
2
- * AgentStuckDetector - Multi-indicator process health analysis
3
- *
4
- * Detects stuck Claude processes using multiple indicators:
5
- * - Process state (S=sleeping vs R=running)
6
- * - Wait channel (ep_poll = blocked on epoll_wait)
7
- * - CPU usage over sample period
8
- * - Context switches (activity indicator)
9
- * - Network socket state (data in flight)
10
- *
11
- * CRITICAL: Single-indicator detection (just output freshness) has HIGH false positive risk.
12
- * Multi-indicator approach ONLY flags processes that fail ALL indicators.
13
- *
14
- * Scoring system:
15
- * - isSleeping: +1
16
- * - isBlockedOnPoll: +1
17
- * - lowCpuUsage: +1
18
- * - lowCtxSwitches: +1
19
- * - noDataInFlight: +0.5 (secondary signal)
20
- * - hasSynSent: +1 (stuck trying to connect)
21
- * - hasDataInFlight: -2 (active I/O = working)
22
- *
23
- * Threshold: stuckScore >= 3.5 = likely stuck
24
- */
25
-
26
- const { execSync } = require('../lib/safe-exec'); // Enforces timeouts
27
- const fs = require('fs');
28
-
29
- // Stuck detection thresholds
30
- const STUCK_THRESHOLD = 3.5; // Score at which we consider process stuck
31
- const HIGH_CONFIDENCE_THRESHOLD = 4.5;
32
- const CPU_LOW_THRESHOLD = 1; // Percent - below this is considered "low"
33
- const CTX_SWITCHES_LOW_THRESHOLD = 10; // Below this is considered "inactive"
34
-
35
- /**
36
- * Get process state from /proc filesystem
37
- * @param {number} pid - Process ID
38
- * @returns {object} Process state info
39
- */
40
- function getProcessState(pid) {
41
- try {
42
- const statPath = `/proc/${pid}/stat`;
43
- if (!fs.existsSync(statPath)) {
44
- return { exists: false };
45
- }
46
-
47
- const stat = fs.readFileSync(statPath, 'utf8');
48
- const parts = stat.split(' ');
49
-
50
- // stat fields: pid, comm, state, ppid, pgrp, ...
51
- // State is the 3rd field (index 2): R=running, S=sleeping, D=disk sleep, Z=zombie
52
- const state = parts[2];
53
-
54
- // Get wchan (what the process is waiting on)
55
- let wchan = '';
56
- try {
57
- wchan = fs.readFileSync(`/proc/${pid}/wchan`, 'utf8').trim();
58
- } catch {
59
- // wchan may not be readable
60
- }
61
-
62
- // Get CPU usage from stat
63
- // utime (field 14) + stime (field 15) = total CPU ticks
64
- const utime = parseInt(parts[13], 10);
65
- const stime = parseInt(parts[14], 10);
66
-
67
- // Get status for more info
68
- const status = fs.readFileSync(`/proc/${pid}/status`, 'utf8');
69
- const threads = status.match(/Threads:\s+(\d+)/)?.[1] || '1';
70
- const volCtxSwitches = status.match(/voluntary_ctxt_switches:\s+(\d+)/)?.[1] || '0';
71
-
72
- return {
73
- exists: true,
74
- state,
75
- wchan,
76
- cpuTicks: utime + stime,
77
- threads: parseInt(threads, 10),
78
- volCtxSwitches: parseInt(volCtxSwitches, 10),
79
- };
80
- } catch (err) {
81
- return { exists: false, error: err.message };
82
- }
83
- }
84
-
85
- /**
86
- * Get network socket activity for a process
87
- * @param {number} pid - Process ID
88
- * @returns {object} Network state info
89
- */
90
- function getNetworkState(pid) {
91
- try {
92
- const fdPath = `/proc/${pid}/fd`;
93
- if (!fs.existsSync(fdPath)) {
94
- return { hasNetwork: false };
95
- }
96
-
97
- // Use ss to get socket states for this process
98
- let ssOutput = '';
99
- try {
100
- ssOutput = execSync(`ss -tunp 2>/dev/null | grep ",pid=${pid}," || true`, {
101
- encoding: 'utf8',
102
- timeout: 5000,
103
- });
104
- } catch {
105
- return { hasNetwork: false };
106
- }
107
-
108
- if (!ssOutput.trim()) {
109
- return { hasNetwork: false, connections: [] };
110
- }
111
-
112
- const connections = [];
113
- const lines = ssOutput.trim().split('\n');
114
-
115
- for (const line of lines) {
116
- // Parse ss output: State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
117
- const match = line.match(/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\S+)/);
118
- if (match) {
119
- connections.push({
120
- state: match[1],
121
- recvQ: parseInt(match[2], 10),
122
- sendQ: parseInt(match[3], 10),
123
- local: match[4],
124
- peer: match[5],
125
- });
126
- }
127
- }
128
-
129
- // Analyze connection health
130
- const establishedCount = connections.filter((c) => c.state === 'ESTAB').length;
131
- const hasDataInFlight = connections.some((c) => c.recvQ > 0 || c.sendQ > 0);
132
- const hasSynSent = connections.some((c) => c.state === 'SYN-SENT');
133
-
134
- return {
135
- hasNetwork: connections.length > 0,
136
- connections,
137
- establishedCount,
138
- hasDataInFlight,
139
- hasSynSent,
140
- };
141
- } catch (err) {
142
- return { hasNetwork: false, error: err.message };
143
- }
144
- }
145
-
146
- /**
147
- * Analyze process health using multi-indicator approach
148
- *
149
- * @param {number} pid - Process ID
150
- * @param {number} samplePeriodMs - How long to sample (default 5000ms)
151
- * @returns {Promise<object>} Analysis result with isLikelyStuck, stuckScore, indicators
152
- */
153
- async function analyzeProcessHealth(pid, samplePeriodMs = 5000) {
154
- const t0 = getProcessState(pid);
155
- if (!t0.exists) {
156
- return { isLikelyStuck: null, reason: 'Process does not exist', pid };
157
- }
158
-
159
- // Wait and sample again
160
- await new Promise((r) => setTimeout(r, samplePeriodMs));
161
-
162
- const t1 = getProcessState(pid);
163
- if (!t1.exists) {
164
- return { isLikelyStuck: null, reason: 'Process died during analysis', pid };
165
- }
166
-
167
- // Calculate CPU usage during sample period
168
- const cpuTicksDelta = t1.cpuTicks - t0.cpuTicks;
169
- const ctxSwitchesDelta = t1.volCtxSwitches - t0.volCtxSwitches;
170
-
171
- // Get clock ticks per second (typically 100 on Linux)
172
- const clockTicks = 100;
173
-
174
- // CPU seconds used during sample
175
- const cpuSeconds = cpuTicksDelta / clockTicks;
176
- const sampleSeconds = samplePeriodMs / 1000;
177
- const cpuPercent = (cpuSeconds / sampleSeconds) * 100;
178
-
179
- // Get network state
180
- const network = getNetworkState(pid);
181
-
182
- // Analyze stuck indicators
183
- const indicators = {
184
- isSleeping: t1.state === 'S',
185
- isBlockedOnPoll: t1.wchan.includes('poll') || t1.wchan.includes('wait'),
186
- lowCpuUsage: cpuPercent < CPU_LOW_THRESHOLD,
187
- lowCtxSwitches: ctxSwitchesDelta < CTX_SWITCHES_LOW_THRESHOLD,
188
- // Network indicators (only apply if process has network connections)
189
- noDataInFlight: network.hasNetwork && !network.hasDataInFlight,
190
- hasSynSent: network.hasSynSent, // Stuck trying to connect
191
- };
192
-
193
- // Calculate stuck score using weighted indicators
194
- let stuckScore = 0;
195
- if (indicators.isSleeping) stuckScore += 1;
196
- if (indicators.isBlockedOnPoll) stuckScore += 1;
197
- if (indicators.lowCpuUsage) stuckScore += 1;
198
- if (indicators.lowCtxSwitches) stuckScore += 1;
199
- if (indicators.noDataInFlight) stuckScore += 0.5; // Secondary signal
200
- if (indicators.hasSynSent) stuckScore += 1; // Strong signal - stuck connecting
201
-
202
- // CRITICAL: If data IS flowing, REDUCE stuck score (legitimate work)
203
- if (network.hasDataInFlight) {
204
- stuckScore = Math.max(0, stuckScore - 2); // Active I/O = likely working
205
- }
206
-
207
- const isLikelyStuck = stuckScore >= STUCK_THRESHOLD;
208
- let confidence = 'low';
209
- if (stuckScore >= HIGH_CONFIDENCE_THRESHOLD) {
210
- confidence = 'high';
211
- } else if (stuckScore >= STUCK_THRESHOLD) {
212
- confidence = 'medium';
213
- }
214
-
215
- return {
216
- pid,
217
- state: t1.state,
218
- wchan: t1.wchan,
219
- cpuPercent: parseFloat(cpuPercent.toFixed(2)),
220
- ctxSwitchesDelta,
221
- threads: t1.threads,
222
- network: {
223
- hasConnections: network.hasNetwork,
224
- establishedCount: network.establishedCount || 0,
225
- hasDataInFlight: network.hasDataInFlight || false,
226
- hasSynSent: network.hasSynSent || false,
227
- },
228
- indicators,
229
- stuckScore: parseFloat(stuckScore.toFixed(1)),
230
- isLikelyStuck,
231
- confidence,
232
- analysis: isLikelyStuck
233
- ? `Process appears STUCK: sleeping on ${t1.wchan}, ${cpuPercent.toFixed(1)}% CPU, ${ctxSwitchesDelta} ctx switches`
234
- : `Process appears WORKING: ${cpuPercent.toFixed(1)}% CPU, ${ctxSwitchesDelta} ctx switches, state=${t1.state}`,
235
- };
236
- }
237
-
238
- /**
239
- * Check if we're on a platform that supports /proc filesystem
240
- * @returns {boolean}
241
- */
242
- function isPlatformSupported() {
243
- return process.platform === 'linux' && fs.existsSync('/proc');
244
- }
245
-
246
- module.exports = {
247
- analyzeProcessHealth,
248
- getProcessState,
249
- getNetworkState,
250
- isPlatformSupported,
251
- // Export thresholds for testing
252
- STUCK_THRESHOLD,
253
- HIGH_CONFIDENCE_THRESHOLD,
254
- CPU_LOW_THRESHOLD,
255
- CTX_SWITCHES_LOW_THRESHOLD,
256
- };