@resolveio/server-lib 22.3.193 → 22.3.194

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.193",
3
+ "version": "22.3.194",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -1631,6 +1631,12 @@ function buildSupportQaEvidence(input) {
1631
1631
  || autonomousDecision.customer_reply_policy
1632
1632
  || job.customerReplyPolicy
1633
1633
  || job.customer_reply_policy);
1634
+ var customerReplyReadiness = plainObject(autonomousDecision.customerReplyReadiness
1635
+ || autonomousDecision.customer_reply_readiness
1636
+ || customerReplyPolicy.readinessContract
1637
+ || customerReplyPolicy.readiness_contract
1638
+ || job.customerReplyReadiness
1639
+ || job.customer_reply_readiness);
1634
1640
  var humanReviewPacket = plainObject(autonomousDecision.humanReviewPacket
1635
1641
  || autonomousDecision.human_review_packet
1636
1642
  || customerReplyPolicy.humanReviewPacket
@@ -1651,6 +1657,9 @@ function buildSupportQaEvidence(input) {
1651
1657
  else if (Object.keys(humanReviewPacket).length) {
1652
1658
  evidence.customerReplyPolicy = { humanReviewPacket: humanReviewPacket };
1653
1659
  }
1660
+ if (Object.keys(customerReplyReadiness).length) {
1661
+ evidence.customerReplyReadiness = customerReplyReadiness;
1662
+ }
1654
1663
  if (Object.keys(preflightGate).length) {
1655
1664
  evidence.supportV5PreflightGate = preflightGate;
1656
1665
  applySupportPreflightGateToQaEvidence(evidence, preflightGate);
@@ -1874,6 +1883,47 @@ function supportCustomerReplyPolicyGate(policy, now) {
1874
1883
  }
1875
1884
  };
1876
1885
  }
1886
+ function supportCustomerReplyReadinessGate(contract, now) {
1887
+ if (!contract || !Object.keys(contract).length) {
1888
+ return undefined;
1889
+ }
1890
+ var validation = (0, support_runner_v5_1.validateResolveIOSupportCustomerReplyReadinessContract)(contract);
1891
+ var normalized = validation.normalized;
1892
+ var status = cleanText(normalized.status, 120);
1893
+ var gateStatus = normalized.canSendCustomerReply
1894
+ ? 'blocked'
1895
+ : validation.valid && (status === 'draft_ready' || status === 'clarification_required')
1896
+ ? 'warn'
1897
+ : 'blocked';
1898
+ return {
1899
+ key: 'support_customer_reply_readiness',
1900
+ label: 'Support customer reply readiness',
1901
+ status: gateStatus,
1902
+ reason: normalized.reason || validation.blockers.join('; ') || status || 'Support customer reply readiness recorded.',
1903
+ evidenceRefs: normalized.evidenceRefs,
1904
+ recordedAt: isoNow(now || normalized.createdAt),
1905
+ metadata: {
1906
+ contractId: normalized.contractId,
1907
+ status: status,
1908
+ policyAction: normalized.policyAction,
1909
+ reviewType: normalized.reviewType,
1910
+ primaryCommand: normalized.primaryCommand,
1911
+ canDraftCustomerReply: normalized.canDraftCustomerReply,
1912
+ canSendCustomerReply: normalized.canSendCustomerReply,
1913
+ requiresHumanApproval: normalized.requiresHumanApproval,
1914
+ proofBacked: normalized.proofBacked,
1915
+ businessProofReady: normalized.businessProofReady,
1916
+ releaseReady: normalized.releaseReady,
1917
+ diagnosisReady: normalized.diagnosisReady,
1918
+ issueClassProbePlanReady: normalized.issueClassProbePlanReady,
1919
+ clarificationRequired: normalized.clarificationRequired,
1920
+ blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(normalized.blockers), false), __read(validation.blockers), false))),
1921
+ requiredEvidence: normalized.requiredEvidence,
1922
+ nextCommands: normalized.nextCommands,
1923
+ forbiddenActions: normalized.forbiddenActions
1924
+ }
1925
+ };
1926
+ }
1877
1927
  function supportNextActionContractObject(ticket, job, evidence) {
1878
1928
  var ticketAutomation = plainObject(ticket.automation);
1879
1929
  var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
@@ -3121,7 +3171,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
3121
3171
  }
3122
3172
  function buildSupportAIRunFromEvidence(input) {
3123
3173
  var e_32, _a, e_33, _b;
3124
- 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, _45, _46, _47, _48, _49, _50, _51;
3174
+ 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, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61;
3125
3175
  var ticket = input.ticket || {};
3126
3176
  var job = input.job || {};
3127
3177
  var evidence = buildSupportQaEvidence(input);
@@ -3133,8 +3183,8 @@ function buildSupportAIRunFromEvidence(input) {
3133
3183
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
3134
3184
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
3135
3185
  try {
3136
- for (var _52 = __values(asArray(input.taskEvents)), _53 = _52.next(); !_53.done; _53 = _52.next()) {
3137
- var event_1 = _53.value;
3186
+ for (var _62 = __values(asArray(input.taskEvents)), _63 = _62.next(); !_63.done; _63 = _62.next()) {
3187
+ var event_1 = _63.value;
3138
3188
  pushEvent(events, {
3139
3189
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
3140
3190
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -3151,13 +3201,13 @@ function buildSupportAIRunFromEvidence(input) {
3151
3201
  catch (e_32_1) { e_32 = { error: e_32_1 }; }
3152
3202
  finally {
3153
3203
  try {
3154
- if (_53 && !_53.done && (_a = _52.return)) _a.call(_52);
3204
+ if (_63 && !_63.done && (_a = _62.return)) _a.call(_62);
3155
3205
  }
3156
3206
  finally { if (e_32) throw e_32.error; }
3157
3207
  }
3158
3208
  try {
3159
- for (var _54 = __values(asArray(input.aiJobs)), _55 = _54.next(); !_55.done; _55 = _54.next()) {
3160
- var aiJob = _55.value;
3209
+ for (var _64 = __values(asArray(input.aiJobs)), _65 = _64.next(); !_65.done; _65 = _64.next()) {
3210
+ var aiJob = _65.value;
3161
3211
  pushEvent(events, {
3162
3212
  type: aiJob.model ? 'model_call' : 'log',
3163
3213
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -3175,7 +3225,7 @@ function buildSupportAIRunFromEvidence(input) {
3175
3225
  catch (e_33_1) { e_33 = { error: e_33_1 }; }
3176
3226
  finally {
3177
3227
  try {
3178
- if (_55 && !_55.done && (_b = _54.return)) _b.call(_54);
3228
+ if (_65 && !_65.done && (_b = _64.return)) _b.call(_64);
3179
3229
  }
3180
3230
  finally { if (e_33) throw e_33.error; }
3181
3231
  }
@@ -3219,6 +3269,22 @@ function buildSupportAIRunFromEvidence(input) {
3219
3269
  metadata: customerReplyPolicyGate.metadata
3220
3270
  });
3221
3271
  }
3272
+ var customerReplyReadiness = plainObject(evidence.customerReplyReadiness
3273
+ || evidence.customer_reply_readiness
3274
+ || customerReplyPolicy.readinessContract
3275
+ || customerReplyPolicy.readiness_contract);
3276
+ var customerReplyReadinessGate = supportCustomerReplyReadinessGate(customerReplyReadiness, input.now);
3277
+ if (customerReplyReadinessGate) {
3278
+ gates.push(customerReplyReadinessGate);
3279
+ pushEvent(events, {
3280
+ type: 'human_intervention',
3281
+ category: 'support_customer_reply_readiness',
3282
+ message: customerReplyReadinessGate.reason,
3283
+ artifactPaths: customerReplyReadinessGate.evidenceRefs,
3284
+ recordedAt: customerReplyReadinessGate.recordedAt,
3285
+ metadata: customerReplyReadinessGate.metadata
3286
+ });
3287
+ }
3222
3288
  var nextActionContract = supportNextActionContractObject(ticket, job, evidence);
3223
3289
  var nextActionContractRequired = supportNextActionContractRequired(ticket, job, evidence);
3224
3290
  var nextActionContractGate = supportNextActionContractGate(nextActionContract, input.now, nextActionContractRequired);
@@ -3487,6 +3553,19 @@ function buildSupportAIRunFromEvidence(input) {
3487
3553
  oneQuestionOnly: ((_48 = customerReplyPolicy.clarificationContract) === null || _48 === void 0 ? void 0 : _48.oneQuestionOnly) === true || ((_49 = customerReplyPolicy.clarification_contract) === null || _49 === void 0 ? void 0 : _49.one_question_only) === true,
3488
3554
  parksTicketUntilCustomerReply: ((_50 = customerReplyPolicy.clarificationContract) === null || _50 === void 0 ? void 0 : _50.parksTicketUntilCustomerReply) === true || ((_51 = customerReplyPolicy.clarification_contract) === null || _51 === void 0 ? void 0 : _51.parks_ticket_until_customer_reply) === true
3489
3555
  } : undefined
3556
+ } : undefined,
3557
+ customerReplyReadiness: customerReplyReadinessGate ? {
3558
+ status: cleanText((_52 = customerReplyReadinessGate.metadata) === null || _52 === void 0 ? void 0 : _52.status, 120),
3559
+ gateStatus: customerReplyReadinessGate.status,
3560
+ primaryCommand: cleanText((_53 = customerReplyReadinessGate.metadata) === null || _53 === void 0 ? void 0 : _53.primaryCommand, 180),
3561
+ policyAction: cleanText((_54 = customerReplyReadinessGate.metadata) === null || _54 === void 0 ? void 0 : _54.policyAction, 120),
3562
+ canDraftCustomerReply: ((_55 = customerReplyReadinessGate.metadata) === null || _55 === void 0 ? void 0 : _55.canDraftCustomerReply) === true,
3563
+ canSendCustomerReply: ((_56 = customerReplyReadinessGate.metadata) === null || _56 === void 0 ? void 0 : _56.canSendCustomerReply) === true,
3564
+ requiresHumanApproval: ((_57 = customerReplyReadinessGate.metadata) === null || _57 === void 0 ? void 0 : _57.requiresHumanApproval) === true,
3565
+ proofBacked: ((_58 = customerReplyReadinessGate.metadata) === null || _58 === void 0 ? void 0 : _58.proofBacked) === true,
3566
+ businessProofReady: ((_59 = customerReplyReadinessGate.metadata) === null || _59 === void 0 ? void 0 : _59.businessProofReady) === true,
3567
+ releaseReady: ((_60 = customerReplyReadinessGate.metadata) === null || _60 === void 0 ? void 0 : _60.releaseReady) === true,
3568
+ blockers: cleanStringList((_61 = customerReplyReadinessGate.metadata) === null || _61 === void 0 ? void 0 : _61.blockers, 20, 500)
3490
3569
  } : undefined
3491
3570
  }
3492
3571
  });