@resolveio/server-lib 22.3.158 → 22.3.160
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/methods/ai-terminal.d.ts +1 -0
- package/methods/ai-terminal.js +133 -3
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
- package/util/ai-run-evidence-adapters.d.ts +37 -0
- package/util/ai-run-evidence-adapters.js +988 -79
- package/util/ai-run-evidence-adapters.js.map +1 -1
- package/util/ai-run-evidence.d.ts +1 -1
- package/util/ai-run-evidence.js.map +1 -1
- package/util/ai-runner-manager-autopilot.d.ts +99 -1
- package/util/ai-runner-manager-autopilot.js +370 -41
- package/util/ai-runner-manager-autopilot.js.map +1 -1
- package/util/ai-runner-manager-policy.d.ts +159 -0
- package/util/ai-runner-manager-policy.js +782 -30
- package/util/ai-runner-manager-policy.js.map +1 -1
- package/util/aicoder-runner-v6.d.ts +93 -3
- package/util/aicoder-runner-v6.js +699 -27
- package/util/aicoder-runner-v6.js.map +1 -1
- package/util/support-runner-v5.d.ts +192 -2
- package/util/support-runner-v5.js +1140 -74
- package/util/support-runner-v5.js.map +1 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __values = (this && this.__values) || function(o) {
|
|
3
14
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
15
|
if (m) return m.call(o);
|
|
@@ -55,6 +66,16 @@ function isoNow(value) {
|
|
|
55
66
|
var parsed = value ? new Date(value) : new Date();
|
|
56
67
|
return Number.isFinite(parsed.getTime()) ? parsed.toISOString() : new Date().toISOString();
|
|
57
68
|
}
|
|
69
|
+
function stableHash(prefix, value) {
|
|
70
|
+
var normalized = typeof value === 'string'
|
|
71
|
+
? cleanText(value, 12000)
|
|
72
|
+
: JSON.stringify(value || {});
|
|
73
|
+
var hash = 0;
|
|
74
|
+
for (var index = 0; index < normalized.length; index += 1) {
|
|
75
|
+
hash = ((hash << 5) - hash + normalized.charCodeAt(index)) | 0;
|
|
76
|
+
}
|
|
77
|
+
return "".concat(prefix, "-").concat(Math.abs(hash).toString(36) || '0');
|
|
78
|
+
}
|
|
58
79
|
function defaultLabelForAction(action) {
|
|
59
80
|
switch (action) {
|
|
60
81
|
case 'run_evidence_probe':
|
|
@@ -98,6 +119,45 @@ function expectedResultForAction(action, evidenceOnly) {
|
|
|
98
119
|
}
|
|
99
120
|
return 'Runner advances only after the current gate has proof.';
|
|
100
121
|
}
|
|
122
|
+
function autonomyModeLabel(mode) {
|
|
123
|
+
switch (mode) {
|
|
124
|
+
case 'monitor_only':
|
|
125
|
+
return 'Monitor Only';
|
|
126
|
+
case 'auto_retry_within_budget':
|
|
127
|
+
return 'Auto Retry Within Budget';
|
|
128
|
+
case 'manual_only':
|
|
129
|
+
default:
|
|
130
|
+
return 'Manual Only';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function autonomyModeDescription(mode) {
|
|
134
|
+
switch (mode) {
|
|
135
|
+
case 'monitor_only':
|
|
136
|
+
return 'Watch the runner and record evidence, but do not dispatch recovery, repair, QA, release, or customer actions.';
|
|
137
|
+
case 'auto_retry_within_budget':
|
|
138
|
+
return 'Auto-dispatch only evidence-backed actions with positive expected value inside the configured budget.';
|
|
139
|
+
case 'manual_only':
|
|
140
|
+
default:
|
|
141
|
+
return 'Show the safest next action, but require an operator to dispatch it.';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function controlAction(input) {
|
|
145
|
+
var action = cleanText(input.action, 120) || 'review';
|
|
146
|
+
return {
|
|
147
|
+
action: action,
|
|
148
|
+
label: cleanText(input.label, 160) || defaultLabelForAction(action),
|
|
149
|
+
group: input.group,
|
|
150
|
+
enabled: input.enabled !== false,
|
|
151
|
+
autoRunnable: input.autoRunnable === true,
|
|
152
|
+
requiresConfirmation: input.requiresConfirmation === true,
|
|
153
|
+
confirmationReason: cleanText(input.confirmationReason, 500),
|
|
154
|
+
safety: input.safety || 'medium',
|
|
155
|
+
reason: cleanText(input.reason, 1000),
|
|
156
|
+
nextCommand: cleanText(input.nextCommand || action, 160),
|
|
157
|
+
expectedResult: cleanText(input.expectedResult || expectedResultForAction(action, false), 500),
|
|
158
|
+
costCeilingUsd: cleanNumber(input.costCeilingUsd)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
101
161
|
function safetyFor(input) {
|
|
102
162
|
if (!input.enabled || input.action === 'park_manual') {
|
|
103
163
|
return 'blocked';
|
|
@@ -113,6 +173,112 @@ function safetyFor(input) {
|
|
|
113
173
|
}
|
|
114
174
|
return 'medium';
|
|
115
175
|
}
|
|
176
|
+
function buildControlPolicy(input) {
|
|
177
|
+
var recommended = input.recommendedAction;
|
|
178
|
+
var autonomy = input.autonomyPolicy;
|
|
179
|
+
var blocked = recommended.enabled === false || autonomy.blocked === true || recommended.action === 'park_manual';
|
|
180
|
+
var primaryAction = controlAction({
|
|
181
|
+
action: recommended.action,
|
|
182
|
+
label: recommended.label,
|
|
183
|
+
group: 'primary',
|
|
184
|
+
enabled: recommended.enabled,
|
|
185
|
+
autoRunnable: recommended.autoRunnable,
|
|
186
|
+
requiresConfirmation: recommended.safety === 'high'
|
|
187
|
+
|| recommended.canRunExpensiveModel
|
|
188
|
+
|| recommended.action === 'run_targeted_product_repair'
|
|
189
|
+
|| recommended.action === 'run_release_repair',
|
|
190
|
+
confirmationReason: recommended.safety === 'high'
|
|
191
|
+
? 'This can spend model tokens or modify product code; confirm the diagnosis/proof gate is current.'
|
|
192
|
+
: recommended.action === 'run_release_repair'
|
|
193
|
+
? 'This can affect release state; confirm hotfix/release evidence first.'
|
|
194
|
+
: '',
|
|
195
|
+
safety: recommended.safety,
|
|
196
|
+
reason: recommended.reason,
|
|
197
|
+
nextCommand: recommended.allowedDispatchAction || recommended.dispatchAction || recommended.action,
|
|
198
|
+
expectedResult: recommended.expectedResult,
|
|
199
|
+
costCeilingUsd: recommended.costCeilingUsd
|
|
200
|
+
});
|
|
201
|
+
var policyActions = ['manual_only', 'monitor_only', 'auto_retry_within_budget'].map(function (mode) { return controlAction({
|
|
202
|
+
action: "set_mode:".concat(mode),
|
|
203
|
+
label: autonomyModeLabel(mode),
|
|
204
|
+
group: 'policy',
|
|
205
|
+
enabled: autonomy.mode !== mode,
|
|
206
|
+
autoRunnable: false,
|
|
207
|
+
requiresConfirmation: mode === 'auto_retry_within_budget',
|
|
208
|
+
confirmationReason: mode === 'auto_retry_within_budget'
|
|
209
|
+
? 'Auto retry will dispatch only evidence-backed actions inside budget, but can still spend runner tokens.'
|
|
210
|
+
: '',
|
|
211
|
+
safety: mode === 'auto_retry_within_budget' ? 'medium' : 'low',
|
|
212
|
+
reason: mode === autonomy.mode ? 'Current manager mode.' : autonomyModeDescription(mode),
|
|
213
|
+
nextCommand: "set_manager_mode_".concat(mode),
|
|
214
|
+
expectedResult: mode === autonomy.mode ? 'Mode is unchanged.' : "Manager switches to ".concat(autonomyModeLabel(mode), "."),
|
|
215
|
+
costCeilingUsd: 0
|
|
216
|
+
}); });
|
|
217
|
+
var choiceActions = (input.humanDecision.choices || [])
|
|
218
|
+
.filter(function (choice) { return choice.action !== recommended.action; })
|
|
219
|
+
.map(function (choice) { return controlAction({
|
|
220
|
+
action: choice.action,
|
|
221
|
+
label: choice.label,
|
|
222
|
+
group: choice.action === 'record_hotfix_evidence' ? 'release' : (choice.action === 'park_manual' ? 'danger' : 'evidence'),
|
|
223
|
+
enabled: true,
|
|
224
|
+
autoRunnable: false,
|
|
225
|
+
requiresConfirmation: choice.requiresConfirmation || choice.action === 'park_manual',
|
|
226
|
+
confirmationReason: choice.requiresConfirmation
|
|
227
|
+
? choice.description
|
|
228
|
+
: choice.action === 'park_manual'
|
|
229
|
+
? 'Parking stops automated progress until new evidence or operator policy changes.'
|
|
230
|
+
: '',
|
|
231
|
+
safety: choice.safety,
|
|
232
|
+
reason: choice.description,
|
|
233
|
+
nextCommand: choice.nextCommand,
|
|
234
|
+
expectedResult: choice.expectedResult,
|
|
235
|
+
costCeilingUsd: 0
|
|
236
|
+
}); });
|
|
237
|
+
if (recommended.requiresNewEvidence && !choiceActions.some(function (action) { return action.action === 'run_evidence_probe'; })) {
|
|
238
|
+
choiceActions.unshift(controlAction({
|
|
239
|
+
action: 'run_evidence_probe',
|
|
240
|
+
label: 'Collect New Evidence',
|
|
241
|
+
group: 'evidence',
|
|
242
|
+
enabled: true,
|
|
243
|
+
autoRunnable: false,
|
|
244
|
+
requiresConfirmation: false,
|
|
245
|
+
safety: 'low',
|
|
246
|
+
reason: 'Collect deterministic evidence before another repair loop.',
|
|
247
|
+
nextCommand: 'run_evidence_probe',
|
|
248
|
+
expectedResult: 'A new artifact path or changed evidence hash is recorded.',
|
|
249
|
+
costCeilingUsd: 0.25
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
var grouped = [
|
|
253
|
+
{ groupId: 'policy', label: 'Mode', actions: policyActions },
|
|
254
|
+
{ groupId: 'evidence', label: 'Evidence', actions: choiceActions.filter(function (action) { return action.group === 'evidence'; }) },
|
|
255
|
+
{ groupId: 'release', label: 'Release', actions: choiceActions.filter(function (action) { return action.group === 'release'; }) },
|
|
256
|
+
{ groupId: 'danger', label: 'Danger Zone', actions: choiceActions.filter(function (action) { return action.group === 'danger'; }) }
|
|
257
|
+
].filter(function (group) { return group.actions.length > 0; });
|
|
258
|
+
return {
|
|
259
|
+
mode: autonomy.mode,
|
|
260
|
+
modeLabel: autonomyModeLabel(autonomy.mode),
|
|
261
|
+
modeDescription: autonomyModeDescription(autonomy.mode),
|
|
262
|
+
onePrimaryActionOnly: true,
|
|
263
|
+
blocked: blocked,
|
|
264
|
+
blockedReason: blocked ? cleanText(autonomy.reason || recommended.reason, 1000) : '',
|
|
265
|
+
canAutoDispatch: recommended.autoRunnable === true && autonomy.canAutoDispatch === true,
|
|
266
|
+
requiresHumanDecision: input.humanDecision.required === true || recommended.autoRunnable !== true,
|
|
267
|
+
primaryAction: primaryAction,
|
|
268
|
+
secondaryActionGroups: grouped,
|
|
269
|
+
budget: {
|
|
270
|
+
currentRunUsd: input.currentRunUsd,
|
|
271
|
+
totalUsd: input.totalUsd,
|
|
272
|
+
projectedActionCostUsd: autonomy.projectedActionCostUsd,
|
|
273
|
+
projectedSpendUsd: autonomy.projectedSpendUsd,
|
|
274
|
+
budgetSoftUsd: autonomy.budgetSoftUsd,
|
|
275
|
+
budgetHardUsd: autonomy.budgetHardUsd,
|
|
276
|
+
softBudgetExceeded: autonomy.softBudgetExceeded,
|
|
277
|
+
hardBudgetExceeded: autonomy.hardBudgetExceeded,
|
|
278
|
+
untrackedWarning: input.untrackedWarning
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
116
282
|
function resolveDispatchAction(input) {
|
|
117
283
|
var _a, _b, _c;
|
|
118
284
|
var directiveAction = cleanText((_a = input.recoveryDirective) === null || _a === void 0 ? void 0 : _a.dispatchAction, 120);
|
|
@@ -185,8 +351,112 @@ function normalizeRecentDispatches(history) {
|
|
|
185
351
|
createdAt: cleanText(entry === null || entry === void 0 ? void 0 : entry.createdAt, 80)
|
|
186
352
|
}); });
|
|
187
353
|
}
|
|
354
|
+
function humanDecisionChoice(choiceId, label, action, description, safety, nextCommand, expectedResult, requiresConfirmation) {
|
|
355
|
+
if (requiresConfirmation === void 0) { requiresConfirmation = false; }
|
|
356
|
+
return {
|
|
357
|
+
choiceId: choiceId,
|
|
358
|
+
label: label,
|
|
359
|
+
action: action,
|
|
360
|
+
description: cleanText(description, 500),
|
|
361
|
+
safety: safety,
|
|
362
|
+
requiresConfirmation: requiresConfirmation,
|
|
363
|
+
nextCommand: nextCommand,
|
|
364
|
+
expectedResult: cleanText(expectedResult, 500)
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function buildHumanDecisionRequest(input) {
|
|
368
|
+
var _a, _b, _c, _d, _e;
|
|
369
|
+
var checkpoint = input.snapshot.recoveryCheckpoint;
|
|
370
|
+
var current = input.snapshot.current || {};
|
|
371
|
+
var recoveryClass = cleanText((checkpoint === null || checkpoint === void 0 ? void 0 : checkpoint.recoveryClass) || ((_a = input.snapshot.recoveryAction) === null || _a === void 0 ? void 0 : _a.recoveryClass) || ((_b = input.snapshot.recoveryPlan) === null || _b === void 0 ? void 0 : _b.recoveryClass), 120);
|
|
372
|
+
var failureClass = cleanText(current.failureClass, 120);
|
|
373
|
+
var blocker = cleanText(current.blocker || current.summary || input.reason, 1000);
|
|
374
|
+
var evidenceHash = cleanText(current.evidenceHash || (checkpoint === null || checkpoint === void 0 ? void 0 : checkpoint.evidenceHash), 160);
|
|
375
|
+
var blockerFingerprint = cleanText(current.blockerFingerprint || (checkpoint === null || checkpoint === void 0 ? void 0 : checkpoint.blockerFingerprint), 160);
|
|
376
|
+
var checkpointId = cleanText((checkpoint === null || checkpoint === void 0 ? void 0 : checkpoint.checkpointId) || ((_c = input.snapshot.recoveryAction) === null || _c === void 0 ? void 0 : _c.checkpointId), 160);
|
|
377
|
+
var recentArtifactPaths = cleanList(((_d = current.artifactPaths) === null || _d === void 0 ? void 0 : _d.length)
|
|
378
|
+
? current.artifactPaths
|
|
379
|
+
: input.recentDispatches.flatMap(function (entry) { return entry.artifactPaths || []; }), 12, 500);
|
|
380
|
+
var required = input.sameEvidenceAlreadyAttempted
|
|
381
|
+
|| input.loopState === 'parked'
|
|
382
|
+
|| input.loopState === 'manual_handoff'
|
|
383
|
+
|| input.recommendedAction.enabled === false
|
|
384
|
+
|| input.recommendedAction.action === 'park_manual';
|
|
385
|
+
var baseEvidence = {
|
|
386
|
+
failureClass: failureClass,
|
|
387
|
+
blocker: blocker,
|
|
388
|
+
blockerFingerprint: blockerFingerprint,
|
|
389
|
+
evidenceHash: evidenceHash,
|
|
390
|
+
checkpointId: checkpointId,
|
|
391
|
+
recoveryClass: recoveryClass,
|
|
392
|
+
dispatchAction: input.dispatchAction,
|
|
393
|
+
requiredArtifacts: input.requiredArtifacts,
|
|
394
|
+
forbiddenActions: input.forbiddenActions,
|
|
395
|
+
recentArtifactPaths: recentArtifactPaths
|
|
396
|
+
};
|
|
397
|
+
var blockedUntil = input.requiresNewEvidence
|
|
398
|
+
? Array.from(new Set([
|
|
399
|
+
'new material evidence changes the evidenceHash or blockerFingerprint',
|
|
400
|
+
'new artifact path is recorded from the failed deterministic gate',
|
|
401
|
+
'operator updates scope, diagnosis, budget, or retry policy'
|
|
402
|
+
]))
|
|
403
|
+
: [];
|
|
404
|
+
if (!required) {
|
|
405
|
+
return {
|
|
406
|
+
requestId: stableHash('mgr-human', {
|
|
407
|
+
checkpointId: checkpointId,
|
|
408
|
+
evidenceHash: evidenceHash,
|
|
409
|
+
blockerFingerprint: blockerFingerprint,
|
|
410
|
+
required: false
|
|
411
|
+
}),
|
|
412
|
+
required: false,
|
|
413
|
+
status: 'not_required',
|
|
414
|
+
reason: 'No human decision is required for the current bounded next action.',
|
|
415
|
+
question: '',
|
|
416
|
+
preferredChoiceId: '',
|
|
417
|
+
evidence: baseEvidence,
|
|
418
|
+
choices: [],
|
|
419
|
+
blockedUntil: [],
|
|
420
|
+
createdAt: isoNow(input.updatedAt)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
var choices = [];
|
|
424
|
+
if (input.requiresNewEvidence || input.sameEvidenceAlreadyAttempted || input.loopState === 'parked') {
|
|
425
|
+
choices.push(humanDecisionChoice('attach_new_evidence', 'Attach New Evidence', 'run_evidence_probe', 'Collect a new deterministic artifact before allowing another model/code loop.', 'low', 'run_evidence_probe', 'The runner records a new artifact path or changed evidence hash, then re-evaluates the same gate.'));
|
|
426
|
+
}
|
|
427
|
+
if (/diagnosis|owner|scope|product_code|business|unknown/i.test("".concat(recoveryClass, " ").concat(failureClass))) {
|
|
428
|
+
choices.push(humanDecisionChoice('revise_diagnosis', 'Revise Diagnosis', 'run_read_only_diagnosis', 'Run a read-only diagnosis revision to change owner files or proof plan with evidence.', 'low', 'run_read_only_diagnosis', 'The diagnosis gate is updated before any product-code repair is allowed.'));
|
|
429
|
+
}
|
|
430
|
+
if (/infra|compile/i.test("".concat(recoveryClass, " ").concat(failureClass))) {
|
|
431
|
+
choices.push(humanDecisionChoice('repair_named_gate', /compile/i.test("".concat(recoveryClass, " ").concat(failureClass)) ? 'Repair Compile Gate' : 'Repair Infra Gate', /compile/i.test("".concat(recoveryClass, " ").concat(failureClass)) ? 'run_compile_repair' : 'run_infra_repair', 'Repair only the deterministic gate that failed; do not count this as product-code failure.', 'medium', /compile/i.test("".concat(recoveryClass, " ").concat(failureClass)) ? 'run_compile_repair' : 'run_infra_repair', 'The named infra/compile gate passes or returns a new blocker hash.', true));
|
|
432
|
+
}
|
|
433
|
+
if (/release/i.test("".concat(recoveryClass, " ").concat(failureClass))) {
|
|
434
|
+
choices.push(humanDecisionChoice('record_hotfix_evidence', 'Record Hotfix Evidence', 'record_hotfix_evidence', 'Record commit, checksum, restart, health, and self-test proof before continuing release repair.', 'low', 'record_hotfix_evidence', 'Hotfix evidence validates and the runner reruns the smallest release gate.'));
|
|
435
|
+
}
|
|
436
|
+
choices.push(humanDecisionChoice('keep_parked', 'Keep Parked', 'park_manual', 'Leave the run parked until a human changes the evidence, scope, budget, or retry policy.', 'blocked', 'park_manual', 'No additional model, QA, repair, publish, or deploy work is queued.'));
|
|
437
|
+
var dedupedChoices = choices.filter(function (choice, index, source) {
|
|
438
|
+
return source.findIndex(function (candidate) { return candidate.choiceId === choice.choiceId; }) === index;
|
|
439
|
+
}).slice(0, 4);
|
|
440
|
+
return {
|
|
441
|
+
requestId: stableHash('mgr-human', {
|
|
442
|
+
checkpointId: checkpointId,
|
|
443
|
+
evidenceHash: evidenceHash,
|
|
444
|
+
blockerFingerprint: blockerFingerprint,
|
|
445
|
+
choices: dedupedChoices.map(function (choice) { return choice.choiceId; })
|
|
446
|
+
}),
|
|
447
|
+
required: true,
|
|
448
|
+
status: 'waiting_for_operator',
|
|
449
|
+
reason: cleanText(input.reason || input.recommendedAction.reason, 1000),
|
|
450
|
+
question: 'Choose the one evidence-backed action that should unblock this runner.',
|
|
451
|
+
preferredChoiceId: ((_e = dedupedChoices[0]) === null || _e === void 0 ? void 0 : _e.choiceId) || 'keep_parked',
|
|
452
|
+
evidence: baseEvidence,
|
|
453
|
+
choices: dedupedChoices,
|
|
454
|
+
blockedUntil: blockedUntil,
|
|
455
|
+
createdAt: isoNow(input.updatedAt)
|
|
456
|
+
};
|
|
457
|
+
}
|
|
188
458
|
function buildResolveIOAIManagerAutopilotSnapshot(input) {
|
|
189
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _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, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51;
|
|
459
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _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, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78;
|
|
190
460
|
var dispatchAction = resolveDispatchAction(input);
|
|
191
461
|
var directiveAllowed = input.recoveryDirective
|
|
192
462
|
? input.recoveryDirective.allowed === true
|
|
@@ -236,43 +506,94 @@ function buildResolveIOAIManagerAutopilotSnapshot(input) {
|
|
|
236
506
|
var resetRequires = cleanList(((_14 = (_13 = (_12 = input.recoveryAction) === null || _12 === void 0 ? void 0 : _12.retryPolicy) === null || _13 === void 0 ? void 0 : _13.resetLoopWhen) === null || _14 === void 0 ? void 0 : _14.length)
|
|
237
507
|
? input.recoveryAction.retryPolicy.resetLoopWhen
|
|
238
508
|
: (_15 = input.recoveryCheckpoint) === null || _15 === void 0 ? void 0 : _15.loopResetEvidence, 20, 500);
|
|
509
|
+
var recoveryRequiredArtifacts = cleanList(((_17 = (_16 = input.recoveryDirective) === null || _16 === void 0 ? void 0 : _16.requiredArtifacts) === null || _17 === void 0 ? void 0 : _17.length) ? input.recoveryDirective.requiredArtifacts : (_18 = input.recoveryAction) === null || _18 === void 0 ? void 0 : _18.requiredArtifacts, 20, 500);
|
|
510
|
+
var recoveryForbiddenActions = cleanList(((_20 = (_19 = input.recoveryDirective) === null || _19 === void 0 ? void 0 : _19.forbiddenActions) === null || _20 === void 0 ? void 0 : _20.length) ? input.recoveryDirective.forbiddenActions : (_22 = (_21 = input.recoveryAction) === null || _21 === void 0 ? void 0 : _21.retryPolicy) === null || _22 === void 0 ? void 0 : _22.stopWhen, 20, 500);
|
|
511
|
+
var singleActionOnly = ((_23 = input.recoveryDirective) === null || _23 === void 0 ? void 0 : _23.singleActionOnly) !== false && ((_24 = input.recoveryAction) === null || _24 === void 0 ? void 0 : _24.singleActionOnly) !== false;
|
|
512
|
+
var allowedDispatchAction = cleanText(((_25 = input.recoveryDirective) === null || _25 === void 0 ? void 0 : _25.allowedDispatchAction) || ((_26 = input.recoveryAction) === null || _26 === void 0 ? void 0 : _26.allowedDispatchAction) || dispatchAction, 120);
|
|
513
|
+
var costCeilingUsd = cleanNumber(((_27 = input.recoveryDirective) === null || _27 === void 0 ? void 0 : _27.costCeilingUsd) || ((_28 = input.recoveryAction) === null || _28 === void 0 ? void 0 : _28.costCeilingUsd));
|
|
514
|
+
var requiredStateTransition = cleanText(((_29 = input.recoveryDirective) === null || _29 === void 0 ? void 0 : _29.requiredStateTransition) || ((_30 = input.recoveryAction) === null || _30 === void 0 ? void 0 : _30.requiredStateTransition), 500);
|
|
515
|
+
var proofRequiredBeforeContinuation = ((_31 = input.recoveryDirective) === null || _31 === void 0 ? void 0 : _31.proofRequiredBeforeContinuation) === true || ((_32 = input.recoveryAction) === null || _32 === void 0 ? void 0 : _32.proofRequiredBeforeContinuation) === true;
|
|
516
|
+
var exitCriteria = cleanList(((_34 = (_33 = input.recoveryDirective) === null || _33 === void 0 ? void 0 : _33.exitCriteria) === null || _34 === void 0 ? void 0 : _34.length) ? input.recoveryDirective.exitCriteria : (_35 = input.recoveryAction) === null || _35 === void 0 ? void 0 : _35.exitCriteria, 30, 500);
|
|
517
|
+
var currentRunUsd = cleanNumber(input.currentRunUsd);
|
|
518
|
+
var totalUsd = cleanNumber(input.totalUsd);
|
|
519
|
+
var autonomyPolicy = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerAutonomyPolicy)(__assign(__assign({}, (input.autonomyPolicy || {})), { currentSpendUsd: (_37 = (_36 = input.autonomyPolicy) === null || _36 === void 0 ? void 0 : _36.currentSpendUsd) !== null && _37 !== void 0 ? _37 : totalUsd, projectedActionCostUsd: (_39 = (_38 = input.autonomyPolicy) === null || _38 === void 0 ? void 0 : _38.projectedActionCostUsd) !== null && _39 !== void 0 ? _39 : costCeilingUsd, dispatchAction: dispatchAction, newEvidence: (_41 = (_40 = input.autonomyPolicy) === null || _40 === void 0 ? void 0 : _40.newEvidence) !== null && _41 !== void 0 ? _41 : evidenceAssessment.changed, materialEvidence: (_43 = (_42 = input.autonomyPolicy) === null || _42 === void 0 ? void 0 : _42.materialEvidence) !== null && _43 !== void 0 ? _43 : evidenceAssessment.material, evidenceStrength: (_45 = (_44 = input.autonomyPolicy) === null || _44 === void 0 ? void 0 : _44.evidenceStrength) !== null && _45 !== void 0 ? _45 : evidenceAssessment.strength, evidenceSignals: (_47 = (_46 = input.autonomyPolicy) === null || _46 === void 0 ? void 0 : _46.evidenceSignals) !== null && _47 !== void 0 ? _47 : evidenceAssessment.signals, sameEvidenceAlreadyAttempted: (_49 = (_48 = input.autonomyPolicy) === null || _48 === void 0 ? void 0 : _48.sameEvidenceAlreadyAttempted) !== null && _49 !== void 0 ? _49 : sameEvidenceAlreadyAttempted }));
|
|
520
|
+
var recentDispatches = normalizeRecentDispatches(input.recoveryDispatchHistory);
|
|
521
|
+
var recommendedActionPacket = {
|
|
522
|
+
action: recommendedAction,
|
|
523
|
+
label: label,
|
|
524
|
+
reason: reason,
|
|
525
|
+
safety: safetyFor({
|
|
526
|
+
action: recommendedAction,
|
|
527
|
+
enabled: enabled,
|
|
528
|
+
evidenceOnly: evidenceOnly,
|
|
529
|
+
productRepairAllowed: productRepairAllowed,
|
|
530
|
+
expensiveModelAllowed: expensiveModelAllowed
|
|
531
|
+
}),
|
|
532
|
+
enabled: enabled,
|
|
533
|
+
autoRunnable: enabled && ((_50 = input.recoveryAction) === null || _50 === void 0 ? void 0 : _50.autoRunnable) !== false && autonomyPolicy.canAutoDispatch === true,
|
|
534
|
+
expectedResult: expectedResultForAction(recommendedAction, evidenceOnly),
|
|
535
|
+
requiresNewEvidence: requiresNewEvidence,
|
|
536
|
+
canRunProductRepair: enabled && productRepairAllowed,
|
|
537
|
+
canRunExpensiveModel: enabled && expensiveModelAllowed,
|
|
538
|
+
canResetLoopAfterEvidence: canResetLoopAfterEvidence,
|
|
539
|
+
singleActionOnly: singleActionOnly,
|
|
540
|
+
allowedDispatchAction: allowedDispatchAction,
|
|
541
|
+
costCeilingUsd: costCeilingUsd,
|
|
542
|
+
requiredStateTransition: requiredStateTransition,
|
|
543
|
+
proofRequiredBeforeContinuation: proofRequiredBeforeContinuation,
|
|
544
|
+
autonomyMode: autonomyPolicy.mode,
|
|
545
|
+
autonomyCanAutoDispatch: autonomyPolicy.canAutoDispatch,
|
|
546
|
+
autonomyBlocked: autonomyPolicy.blocked,
|
|
547
|
+
expectedValueScore: autonomyPolicy.expectedValueScore,
|
|
548
|
+
expectedValueSource: autonomyPolicy.expectedValueSource,
|
|
549
|
+
expectedValuePositive: autonomyPolicy.expectedValuePositive,
|
|
550
|
+
evidenceBacked: autonomyPolicy.evidenceBacked,
|
|
551
|
+
evidenceStrength: autonomyPolicy.evidenceStrength,
|
|
552
|
+
dispatchAction: dispatchAction
|
|
553
|
+
};
|
|
554
|
+
var humanDecision = buildHumanDecisionRequest({
|
|
555
|
+
snapshot: input,
|
|
556
|
+
recommendedAction: recommendedActionPacket,
|
|
557
|
+
loopState: loopState,
|
|
558
|
+
reason: reason,
|
|
559
|
+
dispatchAction: dispatchAction,
|
|
560
|
+
sameEvidenceAlreadyAttempted: sameEvidenceAlreadyAttempted,
|
|
561
|
+
requiresNewEvidence: requiresNewEvidence,
|
|
562
|
+
requiredArtifacts: recoveryRequiredArtifacts,
|
|
563
|
+
forbiddenActions: recoveryForbiddenActions,
|
|
564
|
+
recentDispatches: recentDispatches,
|
|
565
|
+
updatedAt: input.updatedAt
|
|
566
|
+
});
|
|
567
|
+
var untrackedWarning = cleanText(input.untrackedCostWarning || 'Manual Codex sessions outside this runner are not included unless recorded in the usage ledger.', 500);
|
|
568
|
+
var controlPolicy = buildControlPolicy({
|
|
569
|
+
recommendedAction: recommendedActionPacket,
|
|
570
|
+
autonomyPolicy: autonomyPolicy,
|
|
571
|
+
humanDecision: humanDecision,
|
|
572
|
+
recoveryRequiredArtifacts: recoveryRequiredArtifacts,
|
|
573
|
+
recoveryForbiddenActions: recoveryForbiddenActions,
|
|
574
|
+
currentRunUsd: currentRunUsd,
|
|
575
|
+
totalUsd: totalUsd,
|
|
576
|
+
untrackedWarning: untrackedWarning
|
|
577
|
+
});
|
|
239
578
|
return {
|
|
240
579
|
surface: cleanText(input.surface || 'unknown', 120),
|
|
241
580
|
runId: cleanText(input.runId, 160),
|
|
242
581
|
title: cleanText(input.title, 240),
|
|
243
|
-
status: cleanText(input.status || ((
|
|
244
|
-
phase: cleanText(input.phase || ((
|
|
245
|
-
lane: cleanText(input.lane || ((
|
|
246
|
-
stepType: cleanText(input.stepType || ((
|
|
582
|
+
status: cleanText(input.status || ((_51 = input.recoveryCheckpoint) === null || _51 === void 0 ? void 0 : _51.status), 80),
|
|
583
|
+
phase: cleanText(input.phase || ((_52 = input.recoveryDirective) === null || _52 === void 0 ? void 0 : _52.phase), 80),
|
|
584
|
+
lane: cleanText(input.lane || ((_53 = input.recoveryDirective) === null || _53 === void 0 ? void 0 : _53.lane) || ((_54 = input.recoveryCheckpoint) === null || _54 === void 0 ? void 0 : _54.lane) || ((_55 = input.current) === null || _55 === void 0 ? void 0 : _55.lane), 120),
|
|
585
|
+
stepType: cleanText(input.stepType || ((_56 = input.recoveryDirective) === null || _56 === void 0 ? void 0 : _56.stepType) || ((_57 = input.recoveryCheckpoint) === null || _57 === void 0 ? void 0 : _57.stepType) || ((_58 = input.current) === null || _58 === void 0 ? void 0 : _58.stepType), 120),
|
|
247
586
|
runKind: cleanText(input.runKind, 120),
|
|
248
|
-
recommendedAction:
|
|
249
|
-
|
|
250
|
-
label: label,
|
|
251
|
-
reason: reason,
|
|
252
|
-
safety: safetyFor({
|
|
253
|
-
action: recommendedAction,
|
|
254
|
-
enabled: enabled,
|
|
255
|
-
evidenceOnly: evidenceOnly,
|
|
256
|
-
productRepairAllowed: productRepairAllowed,
|
|
257
|
-
expensiveModelAllowed: expensiveModelAllowed
|
|
258
|
-
}),
|
|
259
|
-
enabled: enabled,
|
|
260
|
-
autoRunnable: enabled && ((_24 = input.recoveryAction) === null || _24 === void 0 ? void 0 : _24.autoRunnable) !== false,
|
|
261
|
-
expectedResult: expectedResultForAction(recommendedAction, evidenceOnly),
|
|
262
|
-
requiresNewEvidence: requiresNewEvidence,
|
|
263
|
-
canRunProductRepair: enabled && productRepairAllowed,
|
|
264
|
-
canRunExpensiveModel: enabled && expensiveModelAllowed,
|
|
265
|
-
canResetLoopAfterEvidence: canResetLoopAfterEvidence,
|
|
266
|
-
dispatchAction: dispatchAction
|
|
267
|
-
},
|
|
587
|
+
recommendedAction: recommendedActionPacket,
|
|
588
|
+
controlPolicy: controlPolicy,
|
|
268
589
|
loopGuard: {
|
|
269
590
|
state: loopState,
|
|
270
591
|
blocked: loopState === 'parked' || loopState === 'manual_handoff',
|
|
271
592
|
reason: reason,
|
|
272
|
-
failureClass: cleanText((
|
|
273
|
-
blocker: cleanText(((
|
|
274
|
-
blockerFingerprint: cleanText(((
|
|
275
|
-
evidenceHash: cleanText(((
|
|
593
|
+
failureClass: cleanText((_59 = input.current) === null || _59 === void 0 ? void 0 : _59.failureClass, 120),
|
|
594
|
+
blocker: cleanText(((_60 = input.current) === null || _60 === void 0 ? void 0 : _60.blocker) || ((_61 = input.current) === null || _61 === void 0 ? void 0 : _61.summary), 1000),
|
|
595
|
+
blockerFingerprint: cleanText(((_62 = input.current) === null || _62 === void 0 ? void 0 : _62.blockerFingerprint) || ((_63 = input.recoveryCheckpoint) === null || _63 === void 0 ? void 0 : _63.blockerFingerprint), 160),
|
|
596
|
+
evidenceHash: cleanText(((_64 = input.current) === null || _64 === void 0 ? void 0 : _64.evidenceHash) || ((_65 = input.recoveryCheckpoint) === null || _65 === void 0 ? void 0 : _65.evidenceHash), 160),
|
|
276
597
|
materialEvidence: evidenceAssessment.material === true,
|
|
277
598
|
evidenceStrength: cleanText(evidenceAssessment.strength, 40),
|
|
278
599
|
evidenceSignals: cleanList(evidenceAssessment.signals, 12, 120),
|
|
@@ -280,31 +601,39 @@ function buildResolveIOAIManagerAutopilotSnapshot(input) {
|
|
|
280
601
|
sameEvidenceAlreadyAttempted: sameEvidenceAlreadyAttempted,
|
|
281
602
|
loopCount: cleanNumber(input.loopCount),
|
|
282
603
|
maxLoopCount: cleanNumber(input.maxLoopCount),
|
|
283
|
-
attempts: cleanNumber((
|
|
284
|
-
maxAttemptsBeforePark: cleanNumber((
|
|
604
|
+
attempts: cleanNumber((_66 = input.recoveryCheckpoint) === null || _66 === void 0 ? void 0 : _66.attempts),
|
|
605
|
+
maxAttemptsBeforePark: cleanNumber((_67 = input.recoveryCheckpoint) === null || _67 === void 0 ? void 0 : _67.maxAttemptsBeforePark),
|
|
285
606
|
canResetLoopAfterEvidence: canResetLoopAfterEvidence,
|
|
286
607
|
resetRequires: resetRequires
|
|
287
608
|
},
|
|
288
609
|
recovery: {
|
|
289
|
-
checkpointId: cleanText(((
|
|
290
|
-
recoveryClass: cleanText(((
|
|
610
|
+
checkpointId: cleanText(((_68 = input.recoveryCheckpoint) === null || _68 === void 0 ? void 0 : _68.checkpointId) || ((_69 = input.recoveryAction) === null || _69 === void 0 ? void 0 : _69.checkpointId), 160),
|
|
611
|
+
recoveryClass: cleanText(((_70 = input.recoveryCheckpoint) === null || _70 === void 0 ? void 0 : _70.recoveryClass) || ((_71 = input.recoveryAction) === null || _71 === void 0 ? void 0 : _71.recoveryClass) || ((_72 = input.recoveryPlan) === null || _72 === void 0 ? void 0 : _72.recoveryClass), 120),
|
|
291
612
|
dispatchAction: dispatchAction,
|
|
613
|
+
singleActionOnly: singleActionOnly,
|
|
614
|
+
allowedDispatchAction: allowedDispatchAction,
|
|
292
615
|
directiveAllowed: directiveAllowed,
|
|
293
616
|
evidenceOnly: evidenceOnly,
|
|
294
617
|
productRepairAllowed: productRepairAllowed,
|
|
295
618
|
expensiveModelAllowed: expensiveModelAllowed,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
619
|
+
costCeilingUsd: costCeilingUsd,
|
|
620
|
+
requiredStateTransition: requiredStateTransition,
|
|
621
|
+
proofRequiredBeforeContinuation: proofRequiredBeforeContinuation,
|
|
622
|
+
requiredArtifacts: recoveryRequiredArtifacts,
|
|
623
|
+
nextCommands: cleanList(((_74 = (_73 = input.recoveryDirective) === null || _73 === void 0 ? void 0 : _73.nextCommands) === null || _74 === void 0 ? void 0 : _74.length) ? input.recoveryDirective.nextCommands : (_75 = input.recoveryAction) === null || _75 === void 0 ? void 0 : _75.nextCommands, 20, 500),
|
|
624
|
+
successCriteria: cleanList(((_77 = (_76 = input.recoveryDirective) === null || _76 === void 0 ? void 0 : _76.successCriteria) === null || _77 === void 0 ? void 0 : _77.length) ? input.recoveryDirective.successCriteria : (_78 = input.recoveryAction) === null || _78 === void 0 ? void 0 : _78.successCriteria, 20, 500),
|
|
625
|
+
exitCriteria: exitCriteria,
|
|
626
|
+
forbiddenActions: recoveryForbiddenActions
|
|
300
627
|
},
|
|
301
|
-
|
|
628
|
+
autonomyPolicy: autonomyPolicy,
|
|
629
|
+
recentDispatches: recentDispatches,
|
|
630
|
+
humanDecision: humanDecision,
|
|
302
631
|
cost: {
|
|
303
|
-
currentRunUsd:
|
|
304
|
-
totalUsd:
|
|
632
|
+
currentRunUsd: currentRunUsd,
|
|
633
|
+
totalUsd: totalUsd,
|
|
305
634
|
currentRunTokens: cleanNumber(input.currentRunTokens),
|
|
306
635
|
totalTokens: cleanNumber(input.totalTokens),
|
|
307
|
-
untrackedWarning:
|
|
636
|
+
untrackedWarning: untrackedWarning
|
|
308
637
|
},
|
|
309
638
|
updatedAt: isoNow(input.updatedAt)
|
|
310
639
|
};
|