@resolveio/server-lib 22.3.189 → 22.3.191

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.189",
3
+ "version": "22.3.191",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -1637,6 +1637,8 @@ function supportCustomerReplyPolicyGate(policy, now) {
1637
1637
  var canSend = policy.canSendCustomerReply === true || policy.can_send_customer_reply === true;
1638
1638
  var reviewPacket = plainObject(policy.humanReviewPacket || policy.human_review_packet);
1639
1639
  var draftBasis = plainObject(policy.draftBasis || policy.draft_basis);
1640
+ var clarificationValidation = (0, support_runner_v5_1.validateResolveIOSupportClarificationContract)(policy.clarificationContract || policy.clarification_contract || {});
1641
+ var clarificationContract = clarificationValidation.normalized;
1640
1642
  var reviewType = cleanText(reviewPacket.reviewType || reviewPacket.review_type, 160);
1641
1643
  var evidenceRefs = cleanStringList(reviewPacket.evidenceRefs || reviewPacket.evidence_refs, 40, 500);
1642
1644
  var blockers = cleanStringList(policy.blockers || reviewPacket.blockers, 20, 500);
@@ -1645,13 +1647,14 @@ function supportCustomerReplyPolicyGate(policy, now) {
1645
1647
  : action === 'draft_resolution_reply' && canDraft
1646
1648
  ? 'warn'
1647
1649
  : action === 'ask_clarification' && canDraft
1648
- ? 'warn'
1650
+ ? (clarificationValidation.valid ? 'warn' : 'blocked')
1649
1651
  : 'blocked';
1652
+ var mergedBlockers = Array.from(new Set(__spreadArray(__spreadArray([], __read(blockers), false), __read((action === 'ask_clarification' ? clarificationValidation.blockers : [])), false)));
1650
1653
  return {
1651
1654
  key: 'support_customer_reply_policy',
1652
1655
  label: 'Support customer reply policy',
1653
1656
  status: gateStatus,
1654
- reason: reason || action || 'Support customer reply policy recorded.',
1657
+ reason: reason || mergedBlockers.join('; ') || action || 'Support customer reply policy recorded.',
1655
1658
  evidenceRefs: evidenceRefs,
1656
1659
  recordedAt: isoNow(now || policy.recordedAt || policy.recorded_at || reviewPacket.createdAt || reviewPacket.created_at),
1657
1660
  metadata: {
@@ -1667,7 +1670,11 @@ function supportCustomerReplyPolicyGate(policy, now) {
1667
1670
  primaryAction: cleanText(reviewPacket.primaryAction || reviewPacket.primary_action, 160),
1668
1671
  requiresHumanApproval: reviewPacket.requiresHumanApproval !== false && reviewPacket.requires_human_approval !== false,
1669
1672
  questionPresent: !!cleanText(policy.clarificationQuestion || policy.clarification_question || reviewPacket.question, 1000),
1670
- blockers: blockers
1673
+ clarificationContractStatus: cleanText(clarificationContract.status, 120),
1674
+ clarificationMissingField: cleanText(clarificationContract.missingField, 120),
1675
+ clarificationOneQuestionOnly: clarificationContract.oneQuestionOnly === true,
1676
+ clarificationParksTicket: clarificationContract.parksTicketUntilCustomerReply === true,
1677
+ blockers: mergedBlockers
1671
1678
  }
1672
1679
  };
1673
1680
  }
@@ -2308,22 +2315,30 @@ function aicoderNextActionContractGate(contract, now) {
2308
2315
  var requiresHumanApproval = booleanFlag((_b = contract.requiresHumanApproval) !== null && _b !== void 0 ? _b : contract.requires_human_approval) === true;
2309
2316
  var canRunWithoutCodexMonitor = booleanFlag((_c = contract.canRunWithoutCodexMonitor) !== null && _c !== void 0 ? _c : contract.can_run_without_codex_monitor) === true;
2310
2317
  var codexFallbackRequired = booleanFlag((_d = contract.codexFallbackRequired) !== null && _d !== void 0 ? _d : contract.codex_fallback_required) === true;
2311
- var blockers = cleanStringList(contract.blockers, 40, 500);
2318
+ var sourceBlockers = cleanStringList(contract.blockers, 40, 500);
2312
2319
  var primaryCommand = cleanText(contract.primaryCommand || contract.primary_command, 200);
2313
- var gateStatus = canRunWithoutCodexMonitor
2314
- ? 'pass'
2315
- : requiresHumanApproval
2316
- ? 'blocked'
2317
- : codexFallbackRequired
2318
- ? 'warn'
2319
- : safeToAutoRun ? 'warn' : 'blocked';
2320
+ var liveHotfixBlockedUntilCommit = booleanFlag((_g = (_f = (_e = contract.liveHotfixBlockedUntilCommit) !== null && _e !== void 0 ? _e : contract.live_hotfix_blocked_until_commit) !== null && _f !== void 0 ? _f : plainObject(contract.decisionBasis || contract.decision_basis).liveHotfixBlockedUntilCommit) !== null && _g !== void 0 ? _g : plainObject(contract.decisionBasis || contract.decision_basis).live_hotfix_blocked_until_commit) === true;
2321
+ var safetyBlockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((safeToAutoRun ? [] : ['AICoder next action is not marked safe to auto-run.'])), false), __read((canRunWithoutCodexMonitor ? [] : ['AICoder next action requires Codex fallback/monitoring instead of manager-only execution.'])), false), __read((codexFallbackRequired ? [cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000) || 'AICoder next action contract requires Codex fallback.'] : [])), false), __read((requiresHumanApproval ? ['AICoder next action requires human approval.'] : [])), false), __read((liveHotfixBlockedUntilCommit ? ['Live AICoder hotfix is blocked until GitHub commit and push proof is recorded.'] : [])), false))).filter(Boolean).slice(0, 40);
2322
+ var contractBlockers = safetyBlockers.length
2323
+ ? Array.from(new Set(__spreadArray(__spreadArray([], __read(sourceBlockers), false), __read(safetyBlockers), false))).slice(0, 40)
2324
+ : [];
2325
+ var missingSafetyFlags = [
2326
+ contract.safeToAutoRun === undefined && contract.safe_to_auto_run === undefined ? 'safeToAutoRun' : '',
2327
+ contract.canRunWithoutCodexMonitor === undefined && contract.can_run_without_codex_monitor === undefined ? 'canRunWithoutCodexMonitor' : '',
2328
+ contract.codexFallbackRequired === undefined && contract.codex_fallback_required === undefined ? 'codexFallbackRequired' : ''
2329
+ ].filter(Boolean);
2330
+ var gateStatus = contractBlockers.length
2331
+ ? 'blocked'
2332
+ : missingSafetyFlags.length
2333
+ ? 'warn'
2334
+ : 'pass';
2320
2335
  return {
2321
2336
  key: 'aicoder_next_action_contract',
2322
2337
  label: 'AICoder next action contract',
2323
2338
  status: gateStatus,
2324
2339
  reason: gateStatus === 'pass'
2325
2340
  ? "AICoder can run ".concat(primaryCommand || 'the next action', " without a Codex monitor.")
2326
- : (blockers.join(' ') || cleanText(contract.codexFallbackReason || contract.codex_fallback_reason || contract.expectedStateTransition || contract.expected_state_transition, 1200) || 'AICoder next action is not safe to run unattended.'),
2341
+ : (contractBlockers.join(' ') || cleanText(contract.codexFallbackReason || contract.codex_fallback_reason || contract.expectedStateTransition || contract.expected_state_transition, 1200) || 'AICoder next action is not safe to run unattended.'),
2327
2342
  evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(contract.preconditions)), false), __read(asArray(contract.successEvidence || contract.success_evidence)), false), __read(asArray(contract.stopConditions || contract.stop_conditions)), false), 40, 500),
2328
2343
  recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
2329
2344
  metadata: {
@@ -2339,9 +2354,9 @@ function aicoderNextActionContractGate(contract, now) {
2339
2354
  codexFallbackRequired: codexFallbackRequired,
2340
2355
  codexFallbackReason: cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000),
2341
2356
  costRisk: cleanText(contract.costRisk || contract.cost_risk, 120),
2342
- workflowFirstSatisfied: booleanFlag((_e = contract.workflowFirstSatisfied) !== null && _e !== void 0 ? _e : contract.workflow_first_satisfied) === true,
2343
- hotfixCommitRequired: booleanFlag((_h = (_g = (_f = contract.hotfixCommitRequired) !== null && _f !== void 0 ? _f : contract.hotfix_commit_required) !== null && _g !== void 0 ? _g : plainObject(contract.decisionBasis || contract.decision_basis).hotfixCommitRequired) !== null && _h !== void 0 ? _h : plainObject(contract.decisionBasis || contract.decision_basis).hotfix_commit_required) === true,
2344
- liveHotfixBlockedUntilCommit: booleanFlag((_l = (_k = (_j = contract.liveHotfixBlockedUntilCommit) !== null && _j !== void 0 ? _j : contract.live_hotfix_blocked_until_commit) !== null && _k !== void 0 ? _k : plainObject(contract.decisionBasis || contract.decision_basis).liveHotfixBlockedUntilCommit) !== null && _l !== void 0 ? _l : plainObject(contract.decisionBasis || contract.decision_basis).live_hotfix_blocked_until_commit) === true,
2357
+ workflowFirstSatisfied: booleanFlag((_h = contract.workflowFirstSatisfied) !== null && _h !== void 0 ? _h : contract.workflow_first_satisfied) === true,
2358
+ hotfixCommitRequired: booleanFlag((_l = (_k = (_j = contract.hotfixCommitRequired) !== null && _j !== void 0 ? _j : contract.hotfix_commit_required) !== null && _k !== void 0 ? _k : plainObject(contract.decisionBasis || contract.decision_basis).hotfixCommitRequired) !== null && _l !== void 0 ? _l : plainObject(contract.decisionBasis || contract.decision_basis).hotfix_commit_required) === true,
2359
+ liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit,
2345
2360
  decisionBasis: plainObject(contract.decisionBasis || contract.decision_basis),
2346
2361
  preconditions: cleanStringList(contract.preconditions, 40, 500),
2347
2362
  expectedStateTransition: cleanText(contract.expectedStateTransition || contract.expected_state_transition, 1000),
@@ -2350,7 +2365,10 @@ function aicoderNextActionContractGate(contract, now) {
2350
2365
  stopConditions: cleanStringList(contract.stopConditions || contract.stop_conditions, 40, 500),
2351
2366
  forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 40, 500),
2352
2367
  nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 40, 240),
2353
- blockers: blockers,
2368
+ blockers: contractBlockers,
2369
+ contextBlockers: sourceBlockers,
2370
+ safetyBlockers: safetyBlockers,
2371
+ missingSafetyFlags: missingSafetyFlags,
2354
2372
  ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files, 40, 500)
2355
2373
  }
2356
2374
  };
@@ -2907,7 +2925,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
2907
2925
  }
2908
2926
  function buildSupportAIRunFromEvidence(input) {
2909
2927
  var e_28, _a, e_29, _b;
2910
- var _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;
2928
+ var _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;
2911
2929
  var ticket = input.ticket || {};
2912
2930
  var job = input.job || {};
2913
2931
  var evidence = buildSupportQaEvidence(input);
@@ -2919,8 +2937,8 @@ function buildSupportAIRunFromEvidence(input) {
2919
2937
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
2920
2938
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
2921
2939
  try {
2922
- for (var _37 = __values(asArray(input.taskEvents)), _38 = _37.next(); !_38.done; _38 = _37.next()) {
2923
- var event_1 = _38.value;
2940
+ for (var _45 = __values(asArray(input.taskEvents)), _46 = _45.next(); !_46.done; _46 = _45.next()) {
2941
+ var event_1 = _46.value;
2924
2942
  pushEvent(events, {
2925
2943
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
2926
2944
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -2937,13 +2955,13 @@ function buildSupportAIRunFromEvidence(input) {
2937
2955
  catch (e_28_1) { e_28 = { error: e_28_1 }; }
2938
2956
  finally {
2939
2957
  try {
2940
- if (_38 && !_38.done && (_a = _37.return)) _a.call(_37);
2958
+ if (_46 && !_46.done && (_a = _45.return)) _a.call(_45);
2941
2959
  }
2942
2960
  finally { if (e_28) throw e_28.error; }
2943
2961
  }
2944
2962
  try {
2945
- for (var _39 = __values(asArray(input.aiJobs)), _40 = _39.next(); !_40.done; _40 = _39.next()) {
2946
- var aiJob = _40.value;
2963
+ for (var _47 = __values(asArray(input.aiJobs)), _48 = _47.next(); !_48.done; _48 = _47.next()) {
2964
+ var aiJob = _48.value;
2947
2965
  pushEvent(events, {
2948
2966
  type: aiJob.model ? 'model_call' : 'log',
2949
2967
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -2961,7 +2979,7 @@ function buildSupportAIRunFromEvidence(input) {
2961
2979
  catch (e_29_1) { e_29 = { error: e_29_1 }; }
2962
2980
  finally {
2963
2981
  try {
2964
- if (_40 && !_40.done && (_b = _39.return)) _b.call(_39);
2982
+ if (_48 && !_48.done && (_b = _47.return)) _b.call(_47);
2965
2983
  }
2966
2984
  finally { if (e_29) throw e_29.error; }
2967
2985
  }
@@ -3244,7 +3262,13 @@ function buildSupportAIRunFromEvidence(input) {
3244
3262
  || ((_33 = customerReplyPolicy.human_review_packet) === null || _33 === void 0 ? void 0 : _33.reviewType), 160),
3245
3263
  primaryAction: cleanText(((_34 = customerReplyPolicy.humanReviewPacket) === null || _34 === void 0 ? void 0 : _34.primaryAction)
3246
3264
  || ((_35 = customerReplyPolicy.human_review_packet) === null || _35 === void 0 ? void 0 : _35.primary_action)
3247
- || ((_36 = customerReplyPolicy.human_review_packet) === null || _36 === void 0 ? void 0 : _36.primaryAction), 160)
3265
+ || ((_36 = customerReplyPolicy.human_review_packet) === null || _36 === void 0 ? void 0 : _36.primaryAction), 160),
3266
+ clarificationContract: customerReplyPolicy.clarificationContract || customerReplyPolicy.clarification_contract ? {
3267
+ status: cleanText(((_37 = customerReplyPolicy.clarificationContract) === null || _37 === void 0 ? void 0 : _37.status) || ((_38 = customerReplyPolicy.clarification_contract) === null || _38 === void 0 ? void 0 : _38.status), 120),
3268
+ missingField: cleanText(((_39 = customerReplyPolicy.clarificationContract) === null || _39 === void 0 ? void 0 : _39.missingField) || ((_40 = customerReplyPolicy.clarification_contract) === null || _40 === void 0 ? void 0 : _40.missing_field), 120),
3269
+ oneQuestionOnly: ((_41 = customerReplyPolicy.clarificationContract) === null || _41 === void 0 ? void 0 : _41.oneQuestionOnly) === true || ((_42 = customerReplyPolicy.clarification_contract) === null || _42 === void 0 ? void 0 : _42.one_question_only) === true,
3270
+ parksTicketUntilCustomerReply: ((_43 = customerReplyPolicy.clarificationContract) === null || _43 === void 0 ? void 0 : _43.parksTicketUntilCustomerReply) === true || ((_44 = customerReplyPolicy.clarification_contract) === null || _44 === void 0 ? void 0 : _44.parks_ticket_until_customer_reply) === true
3271
+ } : undefined
3248
3272
  } : undefined
3249
3273
  }
3250
3274
  });