@magnusekdahl/parallix 1.2.0 → 1.2.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.
- package/lib/agents/agents.js +737 -838
- package/lib/agents/agents.ts +930 -0
- package/lib/agents/claude-telemetry.js +149 -154
- package/lib/agents/claude-telemetry.ts +233 -0
- package/lib/agents/claude.js +121 -131
- package/lib/agents/claude.ts +156 -0
- package/lib/agents/codex-telemetry.js +176 -164
- package/lib/agents/codex-telemetry.ts +205 -0
- package/lib/agents/codex.js +168 -201
- package/lib/agents/codex.ts +236 -0
- package/lib/agents/limit-hit.js +216 -226
- package/lib/agents/limit-hit.ts +262 -0
- package/lib/agents/mistral-telemetry.js +7 -10
- package/lib/agents/mistral-telemetry.ts +44 -0
- package/lib/agents/mistral.js +40 -58
- package/lib/agents/mistral.ts +84 -0
- package/lib/agents/opencode-export.js +126 -127
- package/lib/agents/opencode-export.ts +160 -0
- package/lib/agents/opencode-telemetry.js +282 -261
- package/lib/agents/opencode-telemetry.ts +350 -0
- package/lib/agents/opencode.js +263 -305
- package/lib/agents/opencode.ts +370 -0
- package/lib/agents/stage-telemetry.js +23 -24
- package/lib/agents/stage-telemetry.ts +47 -0
- package/lib/commands/integrate.js +9 -3
- package/lib/core/fmt.js +140 -211
- package/lib/core/fmt.ts +189 -0
- package/lib/core/git.js +121 -102
- package/lib/core/git.ts +146 -0
- package/lib/core/gitignore.js +59 -106
- package/lib/core/gitignore.ts +103 -0
- package/lib/core/mission-utils.js +833 -875
- package/lib/core/mission-utils.ts +998 -0
- package/lib/core/persistent-data-migration.js +247 -205
- package/lib/core/persistent-data-migration.ts +255 -0
- package/lib/core/product-config.js +400 -476
- package/lib/core/product-config.ts +518 -0
- package/lib/core/runtime-matrix.js +41 -87
- package/lib/core/runtime-matrix.ts +84 -0
- package/lib/core/spawn-tee.js +152 -192
- package/lib/core/spawn-tee.ts +202 -0
- package/lib/core/state-map.js +92 -92
- package/lib/core/state-map.ts +115 -0
- package/lib/core/storage.js +101 -129
- package/lib/core/storage.ts +182 -0
- package/lib/core/verification.js +148 -138
- package/lib/core/verification.ts +200 -0
- package/package.json +4 -2
- package/prompts/draft.md +1 -0
- package/prompts/portfolio.md +1 -1
- package/px.js +0 -2
package/lib/agents/limit-hit.js
CHANGED
|
@@ -1,269 +1,259 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SIGINT_SHORT_BLOCK_MINUTES = exports.DEFAULT_FALLBACK_HOURS = exports.PATTERN_SETS = void 0;
|
|
4
|
+
exports.detectLimitHit = detectLimitHit;
|
|
5
|
+
exports.parseResetTime = parseResetTime;
|
|
6
|
+
exports.formatBlockUntil = formatBlockUntil;
|
|
7
|
+
exports.ceilToNextHour = ceilToNextHour;
|
|
8
|
+
exports.findLimitHitMatch = findLimitHitMatch;
|
|
9
|
+
exports.clipContext = clipContext;
|
|
10
|
+
exports.parseIsoOffset = parseIsoOffset;
|
|
11
|
+
exports.parseIso = parseIso;
|
|
12
|
+
exports.parseTwelveHour = parseTwelveHour;
|
|
13
|
+
exports.parseTwentyFourHour = parseTwentyFourHour;
|
|
14
|
+
exports.parseRelative = parseRelative;
|
|
15
|
+
exports.parseRetryAfter = parseRetryAfter;
|
|
16
|
+
exports.parseRetryAtDate = parseRetryAtDate;
|
|
17
|
+
exports.projectClockTime = projectClockTime;
|
|
18
|
+
exports.getPatternsForAgent = getPatternsForAgent;
|
|
3
19
|
const DEFAULT_FALLBACK_HOURS = 1;
|
|
20
|
+
exports.DEFAULT_FALLBACK_HOURS = DEFAULT_FALLBACK_HOURS;
|
|
4
21
|
const SIGINT_SHORT_BLOCK_MINUTES = 15;
|
|
5
|
-
|
|
22
|
+
exports.SIGINT_SHORT_BLOCK_MINUTES = SIGINT_SHORT_BLOCK_MINUTES;
|
|
6
23
|
const PATTERN_SETS = Object.freeze({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]
|
|
24
|
+
claude: [
|
|
25
|
+
/claude (?:ai )?usage limit reached/i,
|
|
26
|
+
/\b5-hour limit (?:reached|exceeded)\b/i,
|
|
27
|
+
/you(?:'|')?ve hit your limit(?:\b|$)/i,
|
|
28
|
+
/you(?:'|')?ve hit your (?:weekly|daily|monthly|usage) limit/i,
|
|
29
|
+
/(?:usage|rate)\s*limit (?:has been )?(?:reached|exceeded)/i,
|
|
30
|
+
/\b429\b[^\n]*?\b(?:rate|usage|quota)\b/i
|
|
31
|
+
],
|
|
32
|
+
codex: [
|
|
33
|
+
/you(?:'|’)?ve hit your (?:weekly|daily|monthly|usage) limit/i,
|
|
34
|
+
/\brate[_ ]?limit(?:_| )?(?:exceeded|reached)\b/i,
|
|
35
|
+
/\bweekly (?:codex )?usage limit\b/i,
|
|
36
|
+
/\b429\b[^\n]*?\b(?:rate|quota|usage)\b/i,
|
|
37
|
+
/resource_exhausted/i
|
|
38
|
+
],
|
|
39
|
+
custom: [
|
|
40
|
+
/\b(?:rate|usage|quota)\s*limit\s*(?:reached|exceeded)\b/i,
|
|
41
|
+
/\b429\b[^\n]*?\b(?:rate|quota|usage)\b/i,
|
|
42
|
+
/\b429\b/i,
|
|
43
|
+
/\binsufficient[_ ]quota\b/i
|
|
44
|
+
],
|
|
45
|
+
mistral: [
|
|
46
|
+
/\bmistral (?:ai )?usage limit reached/i,
|
|
47
|
+
/\bmistral (?:ai )?quota exceeded/i,
|
|
48
|
+
/\bmistral (?:ai )?rate limit(?: reached| exceeded)/i,
|
|
49
|
+
/you(?:'|')?ve hit your (?:mistral|vibe) (?:weekly|daily|monthly|usage) limit/i,
|
|
50
|
+
/\b429\b[^\n]*?\b(?:rate|quota|usage)\b/i,
|
|
51
|
+
/\bvibe\b[^\n]*?\b(?:quota exceeded|rate limit exceeded)\b/i,
|
|
52
|
+
/\bmistral\b[^\n]*?\b(?:quota exceeded|rate limit exceeded)\b/i,
|
|
53
|
+
/\bresource[_ ]has[_ ]been[_ ]exhausted\b/i,
|
|
54
|
+
/\bresource_exhausted\b/i
|
|
55
|
+
]
|
|
40
56
|
});
|
|
41
|
-
|
|
42
|
-
/** @param {string} agent */
|
|
57
|
+
exports.PATTERN_SETS = PATTERN_SETS;
|
|
43
58
|
function getPatternsForAgent(agent) {
|
|
44
|
-
|
|
59
|
+
return PATTERN_SETS[agent] || [];
|
|
45
60
|
}
|
|
46
|
-
|
|
47
|
-
/** @param {string} agent @param {string} text */
|
|
48
61
|
function findLimitHitMatch(agent, text) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
const patterns = getPatternsForAgent(agent);
|
|
63
|
+
for (const pattern of patterns) {
|
|
64
|
+
const match = pattern.exec(text);
|
|
65
|
+
if (match) {
|
|
66
|
+
return { pattern, index: match.index, length: match[0].length };
|
|
67
|
+
}
|
|
54
68
|
}
|
|
55
|
-
|
|
56
|
-
return null;
|
|
69
|
+
return null;
|
|
57
70
|
}
|
|
58
|
-
|
|
59
|
-
/** @param {string} text @param {number} index @param {number} length */
|
|
60
71
|
function clipContext(text, index, length) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
const before = Math.max(0, index - 200);
|
|
73
|
+
const after = Math.min(text.length, index + length + 200);
|
|
74
|
+
return text.slice(before, after);
|
|
64
75
|
}
|
|
65
|
-
|
|
66
76
|
const ISO_PATTERN = /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?(Z|[+-]\d{2}:?\d{2})?/;
|
|
67
77
|
const TWELVE_HOUR_PATTERN = /\b(\d{1,2})(?::(\d{2}))?\s*(am|pm|AM|PM)\b/;
|
|
68
78
|
const TWENTY_FOUR_HOUR_PATTERN = /\b([01]?\d|2[0-3]):([0-5]\d)\b/;
|
|
69
79
|
const RELATIVE_PATTERN = /\bin\s+(\d+)\s+(hour|hours|minute|minutes|second|seconds)\b/i;
|
|
70
80
|
const RETRY_AFTER_PATTERN = /retry[- ]?after[:\s]+(\d+)\s*(seconds?|s|minutes?|m)?/i;
|
|
71
81
|
const RETRY_AT_DATE_PATTERN = /(?:retry|reset|try again|reset(?:s)? at)[^\n]{0,40}?(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)/i;
|
|
72
|
-
|
|
73
|
-
/** @param {string | undefined} value */
|
|
74
82
|
function parseIsoOffset(value) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
if (!value) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (value === 'Z') {
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
const m = /([+-])(\d{2}):?(\d{2})/.exec(value);
|
|
90
|
+
if (!m) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const sign = m[1] === '-' ? -1 : 1;
|
|
94
|
+
return sign * (Number(m[2]) * 60 + Number(m[3]));
|
|
81
95
|
}
|
|
82
|
-
|
|
83
|
-
/** @param {string} text */
|
|
84
96
|
function parseIso(text) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
const m = ISO_PATTERN.exec(text);
|
|
98
|
+
if (!m) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const [, year, month, day, hour, minute, second, offset] = m;
|
|
102
|
+
const offsetMinutes = parseIsoOffset(offset);
|
|
103
|
+
if (offsetMinutes === null) {
|
|
104
|
+
return new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second || 0), 0);
|
|
105
|
+
}
|
|
106
|
+
const utcMs = Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second || 0), 0);
|
|
107
|
+
return new Date(utcMs - offsetMinutes * 60 * 1000);
|
|
94
108
|
}
|
|
95
|
-
|
|
96
|
-
/** @param {string} text @param {Date} now */
|
|
97
109
|
function parseTwelveHour(text, now) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
const m = TWELVE_HOUR_PATTERN.exec(text);
|
|
111
|
+
if (!m) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
let hour = Number(m[1]);
|
|
115
|
+
const minute = Number(m[2] || 0);
|
|
116
|
+
const meridiem = m[3].toLowerCase();
|
|
117
|
+
if (hour < 1 || hour > 12) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
if (meridiem === 'pm' && hour !== 12) {
|
|
121
|
+
hour += 12;
|
|
122
|
+
}
|
|
123
|
+
if (meridiem === 'am' && hour === 12) {
|
|
124
|
+
hour = 0;
|
|
125
|
+
}
|
|
126
|
+
return projectClockTime(now, hour, minute);
|
|
107
127
|
}
|
|
108
|
-
|
|
109
|
-
/** @param {string} text @param {Date} now */
|
|
110
128
|
function parseTwentyFourHour(text, now) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
const m = TWENTY_FOUR_HOUR_PATTERN.exec(text);
|
|
130
|
+
if (!m) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const hour = Number(m[1]);
|
|
134
|
+
const minute = Number(m[2]);
|
|
135
|
+
return projectClockTime(now, hour, minute);
|
|
116
136
|
}
|
|
117
|
-
|
|
118
|
-
/** @param {string} text @param {Date} now */
|
|
119
137
|
function parseRelative(text, now) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
const m = RELATIVE_PATTERN.exec(text);
|
|
139
|
+
if (!m) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const amount = Number(m[1]);
|
|
143
|
+
const unit = m[2].toLowerCase();
|
|
144
|
+
let ms;
|
|
145
|
+
if (unit.startsWith('hour')) {
|
|
146
|
+
ms = amount * 60 * 60 * 1000;
|
|
147
|
+
}
|
|
148
|
+
else if (unit.startsWith('minute')) {
|
|
149
|
+
ms = amount * 60 * 1000;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
ms = amount * 1000;
|
|
153
|
+
}
|
|
154
|
+
return new Date(now.getTime() + ms);
|
|
129
155
|
}
|
|
130
|
-
|
|
131
|
-
/** @param {string} text @param {Date} now */
|
|
132
156
|
function parseRetryAfter(text, now) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
157
|
+
const m = RETRY_AFTER_PATTERN.exec(text);
|
|
158
|
+
if (!m) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const amount = Number(m[1]);
|
|
162
|
+
const unit = (m[2] || 's').toLowerCase();
|
|
163
|
+
let ms;
|
|
164
|
+
if (unit.startsWith('m') && unit !== 's') {
|
|
165
|
+
ms = amount * 60 * 1000;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
ms = amount * 1000;
|
|
169
|
+
}
|
|
170
|
+
return new Date(now.getTime() + ms);
|
|
141
171
|
}
|
|
142
|
-
|
|
143
|
-
/** @param {string} text */
|
|
144
172
|
function parseRetryAtDate(text) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
173
|
+
const m = RETRY_AT_DATE_PATTERN.exec(text);
|
|
174
|
+
if (!m) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return parseIso(m[1]);
|
|
148
178
|
}
|
|
149
|
-
|
|
150
|
-
/** @param {Date} now @param {number} hour @param {number} minute */
|
|
151
179
|
function projectClockTime(now, hour, minute) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
180
|
+
const candidate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hour, minute, 0, 0);
|
|
181
|
+
if (candidate.getTime() <= now.getTime()) {
|
|
182
|
+
candidate.setDate(candidate.getDate() + 1);
|
|
183
|
+
}
|
|
184
|
+
return candidate;
|
|
157
185
|
}
|
|
158
|
-
|
|
159
|
-
/** @param {string} text @param {Date} [now] */
|
|
160
186
|
function parseResetTime(text, now = new Date()) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
187
|
+
if (!text) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
return (parseRetryAtDate(text) ||
|
|
191
|
+
parseIso(text) ||
|
|
192
|
+
parseTwelveHour(text, now) ||
|
|
193
|
+
parseTwentyFourHour(text, now) ||
|
|
194
|
+
parseRelative(text, now) ||
|
|
195
|
+
parseRetryAfter(text, now));
|
|
170
196
|
}
|
|
171
|
-
|
|
172
|
-
/** @param {Date} date */
|
|
173
197
|
function formatBlockUntil(date) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
198
|
+
const year = date.getFullYear();
|
|
199
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
200
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
201
|
+
const hour = String(date.getHours()).padStart(2, '0');
|
|
202
|
+
return `${year}-${month}-${day} ${hour}`;
|
|
179
203
|
}
|
|
180
|
-
|
|
181
|
-
/** @param {Date} date */
|
|
182
204
|
function ceilToNextHour(date) {
|
|
183
|
-
|
|
184
|
-
|
|
205
|
+
const ceil = new Date(date.getTime());
|
|
206
|
+
if (ceil.getMinutes() === 0 && ceil.getSeconds() === 0 && ceil.getMilliseconds() === 0) {
|
|
207
|
+
return ceil;
|
|
208
|
+
}
|
|
209
|
+
ceil.setMinutes(0, 0, 0);
|
|
210
|
+
ceil.setHours(ceil.getHours() + 1);
|
|
185
211
|
return ceil;
|
|
186
|
-
}
|
|
187
|
-
ceil.setMinutes(0, 0, 0);
|
|
188
|
-
ceil.setHours(ceil.getHours() + 1);
|
|
189
|
-
return ceil;
|
|
190
212
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
*/
|
|
195
|
-
function detectLimitHit({
|
|
196
|
-
agent,
|
|
197
|
-
stdout = '',
|
|
198
|
-
stderr = '',
|
|
199
|
-
status,
|
|
200
|
-
signal,
|
|
201
|
-
error,
|
|
202
|
-
now = new Date()
|
|
203
|
-
} = /** @type {{ agent: string, stdout?: string, stderr?: string, status?: number, signal?: string | null, error?: { code?: string } | null, now?: Date }} */({})) {
|
|
204
|
-
if (!agent) {return null;}
|
|
205
|
-
// Gate detection on a failed launcher invocation. A successful child (exit 0,
|
|
206
|
-
// no signal, no spawn error) means any limit-hit phrases in the transcript
|
|
207
|
-
// are quoted text — typically when the agent itself reviewed code, tests, or
|
|
208
|
-
// logs containing those strings. Treating that as a real limit hit would
|
|
209
|
-
// wrongly block a healthy agent in agents.local.json.
|
|
210
|
-
// `status === undefined` means the caller did not pass exit metadata; preserve
|
|
211
|
-
// the legacy behavior so callers that haven't been updated still get detection.
|
|
212
|
-
const launcherFailed =
|
|
213
|
-
error !== null && error !== undefined ||
|
|
214
|
-
signal !== null && signal !== undefined ||
|
|
215
|
-
(typeof status === 'number' && status !== 0) ||
|
|
216
|
-
typeof status === 'undefined';
|
|
217
|
-
if (!launcherFailed) {return null;}
|
|
218
|
-
|
|
219
|
-
const combined = `${stdout || ''}\n${stderr || ''}`;
|
|
220
|
-
const match = findLimitHitMatch(agent, combined);
|
|
221
|
-
|
|
222
|
-
let target;
|
|
223
|
-
let source;
|
|
224
|
-
|
|
225
|
-
if (match) {
|
|
226
|
-
const context = clipContext(combined, match.index, match.length);
|
|
227
|
-
const parsed = parseResetTime(context, now);
|
|
228
|
-
|
|
229
|
-
if (parsed && !Number.isNaN(parsed.getTime()) && parsed.getTime() > now.getTime()) {
|
|
230
|
-
target = parsed;
|
|
231
|
-
source = 'parsed';
|
|
232
|
-
} else {
|
|
233
|
-
target = new Date(now.getTime() + DEFAULT_FALLBACK_HOURS * 60 * 60 * 1000);
|
|
234
|
-
source = 'fallback';
|
|
213
|
+
function detectLimitHit({ agent, stdout = '', stderr = '', status, signal, error, now = new Date() } = {}) {
|
|
214
|
+
if (!agent) {
|
|
215
|
+
return null;
|
|
235
216
|
}
|
|
236
|
-
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
217
|
+
// Gate detection on a failed launcher invocation. A successful child (exit 0,
|
|
218
|
+
// no signal, no spawn error) means any limit-hit phrases in the transcript
|
|
219
|
+
// are quoted text — typically when the agent itself reviewed code, tests, or
|
|
220
|
+
// logs containing those strings. Treating that as a real limit hit would
|
|
221
|
+
// wrongly block a healthy agent in agents.local.json.
|
|
222
|
+
// `status === undefined` means the caller did not pass exit metadata; preserve
|
|
223
|
+
// the legacy behavior so callers that haven't been updated still get detection.
|
|
224
|
+
const launcherFailed = error !== null && error !== undefined ||
|
|
225
|
+
signal !== null && signal !== undefined ||
|
|
226
|
+
(typeof status === 'number' && status !== 0) ||
|
|
227
|
+
typeof status === 'undefined';
|
|
228
|
+
if (!launcherFailed) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
const combined = `${stdout || ''}\n${stderr || ''}`;
|
|
232
|
+
const match = findLimitHitMatch(agent, combined);
|
|
233
|
+
let target;
|
|
234
|
+
let source;
|
|
235
|
+
if (match) {
|
|
236
|
+
const context = clipContext(combined, match.index, match.length);
|
|
237
|
+
const parsed = parseResetTime(context, now);
|
|
238
|
+
if (parsed && !Number.isNaN(parsed.getTime()) && parsed.getTime() > now.getTime()) {
|
|
239
|
+
target = parsed;
|
|
240
|
+
source = 'parsed';
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
target = new Date(now.getTime() + DEFAULT_FALLBACK_HOURS * 60 * 60 * 1000);
|
|
244
|
+
source = 'fallback';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (signal !== null && signal !== undefined) {
|
|
248
|
+
// Agent was killed by a signal (e.g. SIGINT/Ctrl-C) but no limit-hit
|
|
249
|
+
// pattern matched. Apply a short-term block so the next invocation
|
|
250
|
+
// selects a different agent instead of re-picking the same one.
|
|
251
|
+
target = new Date(now.getTime() + SIGINT_SHORT_BLOCK_MINUTES * 60 * 1000);
|
|
252
|
+
source = 'sigint';
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
const ceiled = ceilToNextHour(target);
|
|
258
|
+
return { until: formatBlockUntil(ceiled), source };
|
|
248
259
|
}
|
|
249
|
-
|
|
250
|
-
module.exports = {
|
|
251
|
-
detectLimitHit,
|
|
252
|
-
parseResetTime,
|
|
253
|
-
formatBlockUntil,
|
|
254
|
-
ceilToNextHour,
|
|
255
|
-
findLimitHitMatch,
|
|
256
|
-
clipContext,
|
|
257
|
-
parseIsoOffset,
|
|
258
|
-
parseIso,
|
|
259
|
-
parseTwelveHour,
|
|
260
|
-
parseTwentyFourHour,
|
|
261
|
-
parseRelative,
|
|
262
|
-
parseRetryAfter,
|
|
263
|
-
parseRetryAtDate,
|
|
264
|
-
projectClockTime,
|
|
265
|
-
getPatternsForAgent,
|
|
266
|
-
PATTERN_SETS,
|
|
267
|
-
DEFAULT_FALLBACK_HOURS,
|
|
268
|
-
SIGINT_SHORT_BLOCK_MINUTES
|
|
269
|
-
};
|