@covibes/zeroshot 5.3.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 (119) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -385
  3. package/cli/index.js +108 -4615
  4. package/package.json +16 -125
  5. package/CHANGELOG.md +0 -537
  6. package/cli/commands/providers.js +0 -150
  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 -253
  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 -697
  14. package/cluster-templates/base-templates/single-worker.json +0 -63
  15. package/cluster-templates/base-templates/worker-validator.json +0 -152
  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 -212
  21. package/lib/id-detector.js +0 -53
  22. package/lib/provider-detection.js +0 -59
  23. package/lib/provider-names.js +0 -56
  24. package/lib/settings.js +0 -405
  25. package/lib/stream-json-parser.js +0 -10
  26. package/scripts/fix-node-pty-permissions.js +0 -75
  27. package/scripts/record-demo.sh +0 -279
  28. package/scripts/test-install.sh +0 -40
  29. package/scripts/validate-templates.js +0 -100
  30. package/src/agent/agent-config.js +0 -193
  31. package/src/agent/agent-context-builder.js +0 -335
  32. package/src/agent/agent-hook-executor.js +0 -402
  33. package/src/agent/agent-lifecycle.js +0 -683
  34. package/src/agent/agent-stuck-detector.js +0 -256
  35. package/src/agent/agent-task-executor.js +0 -1431
  36. package/src/agent/agent-trigger-evaluator.js +0 -67
  37. package/src/agent/output-extraction.js +0 -200
  38. package/src/agent/output-reformatter.js +0 -175
  39. package/src/agent/schema-utils.js +0 -111
  40. package/src/agent-wrapper.js +0 -570
  41. package/src/agents/git-pusher-agent.json +0 -20
  42. package/src/attach/attach-client.js +0 -438
  43. package/src/attach/attach-server.js +0 -543
  44. package/src/attach/index.js +0 -35
  45. package/src/attach/protocol.js +0 -220
  46. package/src/attach/ring-buffer.js +0 -121
  47. package/src/attach/socket-discovery.js +0 -267
  48. package/src/claude-task-runner.js +0 -523
  49. package/src/config-router.js +0 -80
  50. package/src/config-validator.js +0 -1660
  51. package/src/copy-worker.js +0 -43
  52. package/src/github.js +0 -139
  53. package/src/isolation-manager.js +0 -1381
  54. package/src/ledger.js +0 -614
  55. package/src/logic-engine.js +0 -223
  56. package/src/message-bus-bridge.js +0 -139
  57. package/src/message-bus.js +0 -249
  58. package/src/name-generator.js +0 -232
  59. package/src/orchestrator.js +0 -2519
  60. package/src/preflight.js +0 -485
  61. package/src/process-metrics.js +0 -566
  62. package/src/providers/anthropic/cli-builder.js +0 -45
  63. package/src/providers/anthropic/index.js +0 -134
  64. package/src/providers/anthropic/models.js +0 -23
  65. package/src/providers/anthropic/output-parser.js +0 -159
  66. package/src/providers/base-provider.js +0 -181
  67. package/src/providers/capabilities.js +0 -51
  68. package/src/providers/google/cli-builder.js +0 -55
  69. package/src/providers/google/index.js +0 -116
  70. package/src/providers/google/models.js +0 -24
  71. package/src/providers/google/output-parser.js +0 -92
  72. package/src/providers/index.js +0 -75
  73. package/src/providers/openai/cli-builder.js +0 -122
  74. package/src/providers/openai/index.js +0 -135
  75. package/src/providers/openai/models.js +0 -21
  76. package/src/providers/openai/output-parser.js +0 -129
  77. package/src/schemas/sub-cluster.js +0 -156
  78. package/src/status-footer.js +0 -980
  79. package/src/sub-cluster-wrapper.js +0 -560
  80. package/src/task-runner.js +0 -30
  81. package/src/template-resolver.js +0 -369
  82. package/src/tui/CHANGES.txt +0 -133
  83. package/src/tui/LAYOUT.md +0 -261
  84. package/src/tui/README.txt +0 -192
  85. package/src/tui/TWO-LEVEL-NAVIGATION.md +0 -186
  86. package/src/tui/data-poller.js +0 -325
  87. package/src/tui/demo.js +0 -208
  88. package/src/tui/formatters.js +0 -128
  89. package/src/tui/index.js +0 -193
  90. package/src/tui/keybindings.js +0 -383
  91. package/src/tui/layout.js +0 -334
  92. package/src/tui/renderer.js +0 -194
  93. package/task-lib/attachable-watcher.js +0 -272
  94. package/task-lib/claude-recovery.js +0 -119
  95. package/task-lib/commands/clean.js +0 -50
  96. package/task-lib/commands/get-log-path.js +0 -23
  97. package/task-lib/commands/kill.js +0 -32
  98. package/task-lib/commands/list.js +0 -105
  99. package/task-lib/commands/logs.js +0 -411
  100. package/task-lib/commands/resume.js +0 -42
  101. package/task-lib/commands/run.js +0 -57
  102. package/task-lib/commands/schedule.js +0 -105
  103. package/task-lib/commands/scheduler-cmd.js +0 -96
  104. package/task-lib/commands/schedules.js +0 -98
  105. package/task-lib/commands/status.js +0 -44
  106. package/task-lib/commands/unschedule.js +0 -16
  107. package/task-lib/completion.js +0 -9
  108. package/task-lib/config.js +0 -10
  109. package/task-lib/name-generator.js +0 -230
  110. package/task-lib/package.json +0 -3
  111. package/task-lib/runner.js +0 -144
  112. package/task-lib/scheduler.js +0 -252
  113. package/task-lib/store.js +0 -230
  114. package/task-lib/tui/formatters.js +0 -166
  115. package/task-lib/tui/index.js +0 -197
  116. package/task-lib/tui/layout.js +0 -111
  117. package/task-lib/tui/renderer.js +0 -119
  118. package/task-lib/tui.js +0 -384
  119. package/task-lib/watcher.js +0 -188
@@ -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('child_process');
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
- const confidence =
209
- stuckScore >= HIGH_CONFIDENCE_THRESHOLD
210
- ? 'high'
211
- : stuckScore >= STUCK_THRESHOLD
212
- ? 'medium'
213
- : 'low';
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
- };