@resolveio/server-lib 22.3.138 → 22.3.139

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "22.3.138",
3
+ "version": "22.3.139",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -153,6 +153,43 @@ export interface ResolveIOAIManagerRecoveryActionDispatchDecision {
153
153
  newEvidence: boolean;
154
154
  dispatchRecord?: ResolveIOAIManagerRecoveryActionDispatchRecord;
155
155
  }
156
+ export type ResolveIOAIManagerRecoveryExecutionPhase = 'evidence' | 'diagnosis' | 'infra' | 'compile' | 'journey' | 'business_proof' | 'release' | 'product_repair' | 'advance' | 'manual';
157
+ export interface ResolveIOAIManagerRecoveryExecutionDirectiveInput {
158
+ action?: ResolveIOAIManagerRecoveryActionPacket;
159
+ dispatchDecision?: ResolveIOAIManagerRecoveryActionDispatchDecision;
160
+ current?: ResolveIOAIManagerFailureRecord;
161
+ surface?: string;
162
+ now?: Date | string;
163
+ }
164
+ export interface ResolveIOAIManagerRecoveryExecutionDirective {
165
+ directiveId: string;
166
+ surface: string;
167
+ dispatchAction: ResolveIOAIManagerRecoveryActionDispatchAction;
168
+ phase: ResolveIOAIManagerRecoveryExecutionPhase;
169
+ allowed: boolean;
170
+ status: ResolveIOAIManagerRecoveryActionDispatchStatus;
171
+ reason: string;
172
+ lane: string;
173
+ stepType: string;
174
+ nextActionLabel: string;
175
+ rerunReason: string;
176
+ evidenceOnly: boolean;
177
+ autoRunnable: boolean;
178
+ productRepairAllowed: boolean;
179
+ expensiveModelAllowed: boolean;
180
+ canRunProductRepair: boolean;
181
+ canRunExpensiveModel: boolean;
182
+ canResetLoopAfterEvidence: boolean;
183
+ requiresNewEvidence: boolean;
184
+ newEvidence: boolean;
185
+ maxAttemptsBeforePark: number;
186
+ requiredArtifacts: string[];
187
+ nextCommands: string[];
188
+ successCriteria: string[];
189
+ forbiddenActions: string[];
190
+ dispatchRecord?: ResolveIOAIManagerRecoveryActionDispatchRecord;
191
+ createdAt: string;
192
+ }
156
193
  export interface ResolveIOAIManagerRecoveryCheckpointInput {
157
194
  plan: ResolveIOAIManagerRecoveryPlan;
158
195
  current?: ResolveIOAIManagerFailureRecord;
@@ -239,6 +276,7 @@ export declare function buildResolveIOAIManagerRecoveryEvidenceProbe(input: Reso
239
276
  export declare function buildResolveIOAIManagerRecoveryActionPacket(input: ResolveIOAIManagerRecoveryActionPacketInput): ResolveIOAIManagerRecoveryActionPacket;
240
277
  export declare function decideResolveIOAIManagerRecoveryActionDispatch(input: ResolveIOAIManagerRecoveryActionDispatchInput): ResolveIOAIManagerRecoveryActionDispatchDecision;
241
278
  export declare function appendResolveIOAIManagerRecoveryActionDispatch(history: ResolveIOAIManagerRecoveryActionDispatchRecord[] | undefined, record: ResolveIOAIManagerRecoveryActionDispatchRecord | undefined, limit?: number): ResolveIOAIManagerRecoveryActionDispatchRecord[];
279
+ export declare function buildResolveIOAIManagerRecoveryExecutionDirective(input: ResolveIOAIManagerRecoveryExecutionDirectiveInput): ResolveIOAIManagerRecoveryExecutionDirective;
242
280
  export declare function decideResolveIOAIManagerRecoveryGate(input: ResolveIOAIManagerRecoveryGateInput): ResolveIOAIManagerRecoveryGateDecision;
243
281
  export declare function buildResolveIOAIManagerRecoveryPlan(input?: ResolveIOAIManagerRecoveryPlanInput): ResolveIOAIManagerRecoveryPlan;
244
282
  export declare function decideResolveIOAIManagerPolicy(input: ResolveIOAIManagerPolicyInput): ResolveIOAIManagerPolicyDecision;
@@ -55,6 +55,7 @@ exports.buildResolveIOAIManagerRecoveryEvidenceProbe = buildResolveIOAIManagerRe
55
55
  exports.buildResolveIOAIManagerRecoveryActionPacket = buildResolveIOAIManagerRecoveryActionPacket;
56
56
  exports.decideResolveIOAIManagerRecoveryActionDispatch = decideResolveIOAIManagerRecoveryActionDispatch;
57
57
  exports.appendResolveIOAIManagerRecoveryActionDispatch = appendResolveIOAIManagerRecoveryActionDispatch;
58
+ exports.buildResolveIOAIManagerRecoveryExecutionDirective = buildResolveIOAIManagerRecoveryExecutionDirective;
58
59
  exports.decideResolveIOAIManagerRecoveryGate = decideResolveIOAIManagerRecoveryGate;
59
60
  exports.buildResolveIOAIManagerRecoveryPlan = buildResolveIOAIManagerRecoveryPlan;
60
61
  exports.decideResolveIOAIManagerPolicy = decideResolveIOAIManagerPolicy;
@@ -562,6 +563,59 @@ function appendResolveIOAIManagerRecoveryActionDispatch(history, record, limit)
562
563
  var deduped = existing.filter(function (entry) { return entry.dispatchId !== record.dispatchId; });
563
564
  return __spreadArray(__spreadArray([], __read(deduped), false), [record], false).slice(-limit);
564
565
  }
566
+ function recoveryExecutionPhaseForDispatch(dispatchAction) {
567
+ var map = {
568
+ run_evidence_probe: 'evidence',
569
+ run_read_only_diagnosis: 'diagnosis',
570
+ run_infra_repair: 'infra',
571
+ run_compile_repair: 'compile',
572
+ run_journey_contract_repair: 'journey',
573
+ run_business_assertion_repair: 'business_proof',
574
+ run_release_repair: 'release',
575
+ run_targeted_product_repair: 'product_repair',
576
+ advance: 'advance',
577
+ continue_gate: 'advance',
578
+ park_manual: 'manual'
579
+ };
580
+ return map[dispatchAction] || 'manual';
581
+ }
582
+ function recoveryDirectiveReason(action, decision, current) {
583
+ var blocker = cleanText((current === null || current === void 0 ? void 0 : current.blocker) || (current === null || current === void 0 ? void 0 : current.summary) || '', 260);
584
+ var label = cleanText(action === null || action === void 0 ? void 0 : action.label, 120) || decision.dispatchAction;
585
+ var objective = cleanText(action === null || action === void 0 ? void 0 : action.objective, 260);
586
+ return [
587
+ "MANAGER_RECOVERY:".concat(decision.dispatchAction),
588
+ "label=".concat(label),
589
+ decision.reason ? "reason=".concat(decision.reason) : '',
590
+ blocker ? "blocker=".concat(blocker) : '',
591
+ objective ? "objective=".concat(objective) : ''
592
+ ].filter(Boolean).join(' | ');
593
+ }
594
+ function buildResolveIOAIManagerRecoveryExecutionDirective(input) {
595
+ var _a, _b, _c, _d;
596
+ var action = input.action;
597
+ var dispatchDecision = input.dispatchDecision || decideResolveIOAIManagerRecoveryActionDispatch({
598
+ action: action,
599
+ current: input.current,
600
+ now: input.now
601
+ });
602
+ var dispatchAction = dispatchDecision.dispatchAction;
603
+ var now = isoNow(input.now);
604
+ var phase = recoveryExecutionPhaseForDispatch(dispatchAction);
605
+ var lane = cleanText((action === null || action === void 0 ? void 0 : action.lane) || ((_a = input.current) === null || _a === void 0 ? void 0 : _a.lane) || '', 120);
606
+ var stepType = cleanText((action === null || action === void 0 ? void 0 : action.stepType) || ((_b = input.current) === null || _b === void 0 ? void 0 : _b.stepType) || '', 120);
607
+ var rerunReason = recoveryDirectiveReason(action, dispatchDecision, input.current);
608
+ var surface = cleanText(input.surface || 'runner', 120);
609
+ return __assign(__assign({ directiveId: stableHash('mgr-directive', {
610
+ surface: surface,
611
+ actionId: (action === null || action === void 0 ? void 0 : action.actionId) || '',
612
+ dispatchAction: dispatchAction,
613
+ reason: dispatchDecision.reason,
614
+ evidenceHash: ((_c = dispatchDecision.dispatchRecord) === null || _c === void 0 ? void 0 : _c.evidenceHash) || ((_d = input.current) === null || _d === void 0 ? void 0 : _d.evidenceHash) || ''
615
+ }), surface: surface, dispatchAction: dispatchAction, phase: phase, allowed: dispatchDecision.allowed, status: dispatchDecision.status, reason: dispatchDecision.reason, lane: lane, stepType: stepType, nextActionLabel: cleanText(action === null || action === void 0 ? void 0 : action.label, 160) || dispatchAction, rerunReason: rerunReason, evidenceOnly: (action === null || action === void 0 ? void 0 : action.evidenceOnly) !== false || dispatchAction === 'run_evidence_probe', autoRunnable: (action === null || action === void 0 ? void 0 : action.autoRunnable) === true, productRepairAllowed: (action === null || action === void 0 ? void 0 : action.productRepairAllowed) === true, expensiveModelAllowed: (action === null || action === void 0 ? void 0 : action.expensiveModelAllowed) === true, canRunProductRepair: dispatchDecision.canRunProductRepair, canRunExpensiveModel: dispatchDecision.canRunExpensiveModel, canResetLoopAfterEvidence: (action === null || action === void 0 ? void 0 : action.canResetLoopAfterEvidence) === true, requiresNewEvidence: dispatchDecision.requiresNewEvidence, newEvidence: dispatchDecision.newEvidence, maxAttemptsBeforePark: Math.max(1, Number((action === null || action === void 0 ? void 0 : action.maxAttemptsBeforePark) || 1) || 1), requiredArtifacts: cleanList(action === null || action === void 0 ? void 0 : action.requiredArtifacts, 20, 500), nextCommands: cleanList(action === null || action === void 0 ? void 0 : action.nextCommands, 20, 500), successCriteria: cleanList(action === null || action === void 0 ? void 0 : action.successCriteria, 20, 500), forbiddenActions: (action === null || action === void 0 ? void 0 : action.productRepairAllowed) === true
616
+ ? []
617
+ : ['Do not run product-code repair from this directive unless canRunProductRepair is true.'] }, (dispatchDecision.dispatchRecord ? { dispatchRecord: dispatchDecision.dispatchRecord } : {})), { createdAt: now });
618
+ }
565
619
  function listHasNewEntry(current, previous) {
566
620
  var existing = new Set(previous.map(function (entry) { return cleanText(entry, 500); }).filter(Boolean));
567
621
  return current.some(function (entry) {