@resolveio/server-lib 22.3.186 → 22.3.188

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.186",
3
+ "version": "22.3.188",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -2285,6 +2285,75 @@ function aicoderWorkflowProofCheckpointGate(checkpoint, now) {
2285
2285
  }
2286
2286
  };
2287
2287
  }
2288
+ function aicoderNextActionContractObject(app, job, evidence) {
2289
+ var continuationDecision = plainObject(job.aicoderV6ContinuationDecision
2290
+ || job.aiCoderV6ContinuationDecision
2291
+ || job.aicoder_v6_continuation_decision
2292
+ || job.ai_coder_v6_continuation_decision
2293
+ || app.aicoderV6ContinuationDecision
2294
+ || app.aiCoderV6ContinuationDecision
2295
+ || app.aicoder_v6_continuation_decision
2296
+ || evidence.aicoderV6ContinuationDecision
2297
+ || evidence.aiCoderV6ContinuationDecision
2298
+ || evidence.aicoder_v6_continuation_decision);
2299
+ return evidenceObject(continuationDecision.nextActionContract, continuationDecision.next_action_contract, job.nextActionContract, job.next_action_contract, job.aicoderNextActionContract, job.aicoder_next_action_contract, job.aiCoderNextActionContract, job.ai_coder_next_action_contract, app.nextActionContract, app.next_action_contract, evidence.nextActionContract, evidence.next_action_contract, evidence.aicoderNextActionContract, evidence.aicoder_next_action_contract);
2300
+ }
2301
+ function aicoderNextActionContractGate(contract, now) {
2302
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2303
+ if (!contract || !Object.keys(contract).length) {
2304
+ return undefined;
2305
+ }
2306
+ var safeToAutoRun = booleanFlag((_a = contract.safeToAutoRun) !== null && _a !== void 0 ? _a : contract.safe_to_auto_run) === true;
2307
+ var requiresHumanApproval = booleanFlag((_b = contract.requiresHumanApproval) !== null && _b !== void 0 ? _b : contract.requires_human_approval) === true;
2308
+ var canRunWithoutCodexMonitor = booleanFlag((_c = contract.canRunWithoutCodexMonitor) !== null && _c !== void 0 ? _c : contract.can_run_without_codex_monitor) === true;
2309
+ var codexFallbackRequired = booleanFlag((_d = contract.codexFallbackRequired) !== null && _d !== void 0 ? _d : contract.codex_fallback_required) === true;
2310
+ var blockers = cleanStringList(contract.blockers, 40, 500);
2311
+ var primaryCommand = cleanText(contract.primaryCommand || contract.primary_command, 200);
2312
+ var gateStatus = canRunWithoutCodexMonitor
2313
+ ? 'pass'
2314
+ : requiresHumanApproval
2315
+ ? 'blocked'
2316
+ : codexFallbackRequired
2317
+ ? 'warn'
2318
+ : safeToAutoRun ? 'warn' : 'blocked';
2319
+ return {
2320
+ key: 'aicoder_next_action_contract',
2321
+ label: 'AICoder next action contract',
2322
+ status: gateStatus,
2323
+ reason: gateStatus === 'pass'
2324
+ ? "AICoder can run ".concat(primaryCommand || 'the next action', " without a Codex monitor.")
2325
+ : (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.'),
2326
+ 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),
2327
+ recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
2328
+ metadata: {
2329
+ contractId: cleanText(contract.contractId || contract.contract_id, 200),
2330
+ action: cleanText(contract.action, 120),
2331
+ label: cleanText(contract.label, 200),
2332
+ primaryCommand: primaryCommand,
2333
+ lane: cleanText(contract.lane, 120),
2334
+ stepType: cleanText(contract.stepType || contract.step_type, 120),
2335
+ safeToAutoRun: safeToAutoRun,
2336
+ requiresHumanApproval: requiresHumanApproval,
2337
+ canRunWithoutCodexMonitor: canRunWithoutCodexMonitor,
2338
+ codexFallbackRequired: codexFallbackRequired,
2339
+ codexFallbackReason: cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000),
2340
+ costRisk: cleanText(contract.costRisk || contract.cost_risk, 120),
2341
+ workflowFirstSatisfied: booleanFlag((_e = contract.workflowFirstSatisfied) !== null && _e !== void 0 ? _e : contract.workflow_first_satisfied) === true,
2342
+ 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,
2343
+ 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,
2344
+ decisionBasis: plainObject(contract.decisionBasis || contract.decision_basis),
2345
+ preconditions: cleanStringList(contract.preconditions, 40, 500),
2346
+ expectedStateTransition: cleanText(contract.expectedStateTransition || contract.expected_state_transition, 1000),
2347
+ successEvidence: cleanStringList(contract.successEvidence || contract.success_evidence, 40, 500),
2348
+ requiredHotfixCommitProof: cleanStringList(contract.requiredHotfixCommitProof || contract.required_hotfix_commit_proof, 20, 240),
2349
+ stopConditions: cleanStringList(contract.stopConditions || contract.stop_conditions, 40, 500),
2350
+ forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 40, 500),
2351
+ nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 40, 240),
2352
+ blockers: blockers,
2353
+ ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files, 40, 500)
2354
+ }
2355
+ };
2356
+ }
2288
2357
  function adapterStatusPassed(value) {
2289
2358
  var normalized = cleanText(value, 120).toLowerCase();
2290
2359
  return !!normalized && /(pass|passed|success|succeeded|ok|done|complete|completed|ready|saved|published|deployed)/i.test(normalized);
@@ -3002,7 +3071,7 @@ function buildSupportAIRunFromEvidence(input) {
3002
3071
  }
3003
3072
  function buildAICoderAIRunFromEvidence(input) {
3004
3073
  var e_30, _a;
3005
- var _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;
3074
+ var _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;
3006
3075
  var app = input.app || {};
3007
3076
  var job = input.job || {};
3008
3077
  var evidence = buildAICoderQaEvidence(input);
@@ -3013,8 +3082,8 @@ function buildAICoderAIRunFromEvidence(input) {
3013
3082
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
3014
3083
  addSourceId(sourceIds, 'domain', app.domain || app.customDomain || job.domain);
3015
3084
  try {
3016
- for (var _7 = __values(asArray(input.logs)), _8 = _7.next(); !_8.done; _8 = _7.next()) {
3017
- var log = _8.value;
3085
+ for (var _29 = __values(asArray(input.logs)), _30 = _29.next(); !_30.done; _30 = _29.next()) {
3086
+ var log = _30.value;
3018
3087
  pushEvent(events, {
3019
3088
  type: log.type === 'scorecard' ? 'scorecard' : 'log',
3020
3089
  category: cleanText(log.category || log.phase || log.level, 160),
@@ -3032,7 +3101,7 @@ function buildAICoderAIRunFromEvidence(input) {
3032
3101
  catch (e_30_1) { e_30 = { error: e_30_1 }; }
3033
3102
  finally {
3034
3103
  try {
3035
- if (_8 && !_8.done && (_a = _7.return)) _a.call(_7);
3104
+ if (_30 && !_30.done && (_a = _29.return)) _a.call(_29);
3036
3105
  }
3037
3106
  finally { if (e_30) throw e_30.error; }
3038
3107
  }
@@ -3127,6 +3196,19 @@ function buildAICoderAIRunFromEvidence(input) {
3127
3196
  metadata: workflowProofCheckpointGate.metadata
3128
3197
  });
3129
3198
  }
3199
+ var nextActionContract = aicoderNextActionContractObject(app, job, evidence);
3200
+ var nextActionContractGate = aicoderNextActionContractGate(nextActionContract, input.now);
3201
+ if (nextActionContractGate) {
3202
+ gates.push(nextActionContractGate);
3203
+ pushEvent(events, {
3204
+ type: 'log',
3205
+ category: 'aicoder_next_action_contract',
3206
+ message: nextActionContractGate.reason,
3207
+ artifactPaths: nextActionContractGate.evidenceRefs,
3208
+ recordedAt: nextActionContractGate.recordedAt,
3209
+ metadata: nextActionContractGate.metadata
3210
+ });
3211
+ }
3130
3212
  var qa = applyAICoderWorkflowProofGate(buildQaFromEvidence(evidence, input.now), workflowReadiness, input.now);
3131
3213
  return (0, ai_run_evidence_1.buildAIRun)({
3132
3214
  source: 'aicoder_app',
@@ -3199,6 +3281,31 @@ function buildAICoderAIRunFromEvidence(input) {
3199
3281
  workflowProofFingerprint: cleanText((_4 = workflowProofCheckpointGate.metadata) === null || _4 === void 0 ? void 0 : _4.workflowProofFingerprint, 200),
3200
3282
  artifactFingerprint: cleanText((_5 = workflowProofCheckpointGate.metadata) === null || _5 === void 0 ? void 0 : _5.artifactFingerprint, 200),
3201
3283
  blockers: cleanStringList((_6 = workflowProofCheckpointGate.metadata) === null || _6 === void 0 ? void 0 : _6.blockers, 20, 500)
3284
+ } : undefined,
3285
+ nextActionContract: nextActionContractGate ? {
3286
+ gateStatus: nextActionContractGate.status,
3287
+ contractId: cleanText((_7 = nextActionContractGate.metadata) === null || _7 === void 0 ? void 0 : _7.contractId, 200),
3288
+ action: cleanText((_8 = nextActionContractGate.metadata) === null || _8 === void 0 ? void 0 : _8.action, 120),
3289
+ label: cleanText((_9 = nextActionContractGate.metadata) === null || _9 === void 0 ? void 0 : _9.label, 200),
3290
+ primaryCommand: cleanText((_10 = nextActionContractGate.metadata) === null || _10 === void 0 ? void 0 : _10.primaryCommand, 200),
3291
+ lane: cleanText((_11 = nextActionContractGate.metadata) === null || _11 === void 0 ? void 0 : _11.lane, 120),
3292
+ stepType: cleanText((_12 = nextActionContractGate.metadata) === null || _12 === void 0 ? void 0 : _12.stepType, 120),
3293
+ safeToAutoRun: ((_13 = nextActionContractGate.metadata) === null || _13 === void 0 ? void 0 : _13.safeToAutoRun) === true,
3294
+ requiresHumanApproval: ((_14 = nextActionContractGate.metadata) === null || _14 === void 0 ? void 0 : _14.requiresHumanApproval) === true,
3295
+ canRunWithoutCodexMonitor: ((_15 = nextActionContractGate.metadata) === null || _15 === void 0 ? void 0 : _15.canRunWithoutCodexMonitor) === true,
3296
+ codexFallbackRequired: ((_16 = nextActionContractGate.metadata) === null || _16 === void 0 ? void 0 : _16.codexFallbackRequired) === true,
3297
+ costRisk: cleanText((_17 = nextActionContractGate.metadata) === null || _17 === void 0 ? void 0 : _17.costRisk, 120),
3298
+ workflowFirstSatisfied: ((_18 = nextActionContractGate.metadata) === null || _18 === void 0 ? void 0 : _18.workflowFirstSatisfied) === true,
3299
+ hotfixCommitRequired: ((_19 = nextActionContractGate.metadata) === null || _19 === void 0 ? void 0 : _19.hotfixCommitRequired) === true,
3300
+ liveHotfixBlockedUntilCommit: ((_20 = nextActionContractGate.metadata) === null || _20 === void 0 ? void 0 : _20.liveHotfixBlockedUntilCommit) === true,
3301
+ decisionBasis: plainObject((_21 = nextActionContractGate.metadata) === null || _21 === void 0 ? void 0 : _21.decisionBasis),
3302
+ preconditions: cleanStringList((_22 = nextActionContractGate.metadata) === null || _22 === void 0 ? void 0 : _22.preconditions, 20, 500),
3303
+ successEvidence: cleanStringList((_23 = nextActionContractGate.metadata) === null || _23 === void 0 ? void 0 : _23.successEvidence, 20, 500),
3304
+ requiredHotfixCommitProof: cleanStringList((_24 = nextActionContractGate.metadata) === null || _24 === void 0 ? void 0 : _24.requiredHotfixCommitProof, 20, 240),
3305
+ stopConditions: cleanStringList((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.stopConditions, 20, 500),
3306
+ forbiddenActions: cleanStringList((_26 = nextActionContractGate.metadata) === null || _26 === void 0 ? void 0 : _26.forbiddenActions, 20, 500),
3307
+ nextCommands: cleanStringList((_27 = nextActionContractGate.metadata) === null || _27 === void 0 ? void 0 : _27.nextCommands, 20, 240),
3308
+ blockers: cleanStringList((_28 = nextActionContractGate.metadata) === null || _28 === void 0 ? void 0 : _28.blockers, 20, 500)
3202
3309
  } : undefined
3203
3310
  }
3204
3311
  });