@refrainai/cli 0.4.1 → 0.4.2

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.
Files changed (83) hide show
  1. package/dist/{ai-model-FM6GWCID.js → ai-model-DP5PKGM6.js} +2 -2
  2. package/dist/{chunk-2BVDAJZT.js → chunk-65CTEK2K.js} +9 -6
  3. package/dist/chunk-65CTEK2K.js.map +1 -0
  4. package/dist/chunk-BGC75OVR.js +30 -0
  5. package/dist/chunk-BGC75OVR.js.map +1 -0
  6. package/dist/{chunk-H47NWH7N.js → chunk-CJM3IU5Q.js} +611 -73
  7. package/dist/chunk-CJM3IU5Q.js.map +1 -0
  8. package/dist/{chunk-CLYJHKPY.js → chunk-CMWLFQXD.js} +43 -42
  9. package/dist/chunk-CMWLFQXD.js.map +1 -0
  10. package/dist/{chunk-IGFCYKHC.js → chunk-CNJ5KCDN.js} +252 -295
  11. package/dist/chunk-CNJ5KCDN.js.map +1 -0
  12. package/dist/{chunk-DJVUITRB.js → chunk-ELQ23L4Z.js} +898 -1135
  13. package/dist/chunk-ELQ23L4Z.js.map +1 -0
  14. package/dist/chunk-EMAYENG4.js +1146 -0
  15. package/dist/chunk-EMAYENG4.js.map +1 -0
  16. package/dist/{chunk-7UCVPKD4.js → chunk-F7WTOQIQ.js} +12 -72
  17. package/dist/chunk-F7WTOQIQ.js.map +1 -0
  18. package/dist/{chunk-WEYR56ZN.js → chunk-HHRHHFSK.js} +4 -4
  19. package/dist/{chunk-UGPXCQY3.js → chunk-KFNW4XR2.js} +13 -4
  20. package/dist/chunk-KFNW4XR2.js.map +1 -0
  21. package/dist/{chunk-RT664YIO.js → chunk-LZDZGI4M.js} +3 -1
  22. package/dist/chunk-LZDZGI4M.js.map +1 -0
  23. package/dist/chunk-RBZK7T76.js +349 -0
  24. package/dist/chunk-RBZK7T76.js.map +1 -0
  25. package/dist/{chunk-HQDXLWAY.js → chunk-SDV3X5UN.js} +2 -2
  26. package/dist/{chunk-Z33FCOTZ.js → chunk-VVXNFUPL.js} +4 -2
  27. package/dist/chunk-VVXNFUPL.js.map +1 -0
  28. package/dist/chunk-XIVS7N3V.js +74 -0
  29. package/dist/chunk-XIVS7N3V.js.map +1 -0
  30. package/dist/chunk-YTVEYQGA.js +64 -0
  31. package/dist/chunk-YTVEYQGA.js.map +1 -0
  32. package/dist/{chunk-RYIJPYM3.js → chunk-YW46VP57.js} +25 -8
  33. package/dist/chunk-YW46VP57.js.map +1 -0
  34. package/dist/cli.js +5 -5
  35. package/dist/{compose-MTSIJY5D.js → compose-B2IAO7YW.js} +9 -7
  36. package/dist/{compose-MTSIJY5D.js.map → compose-B2IAO7YW.js.map} +1 -1
  37. package/dist/extraction-prompt-VDCKIFLB.js +17 -0
  38. package/dist/extraction-prompt-VDCKIFLB.js.map +1 -0
  39. package/dist/{fix-runbook-ZSBOTLC2.js → fix-runbook-JJN4HVIP.js} +12 -10
  40. package/dist/{fix-runbook-ZSBOTLC2.js.map → fix-runbook-JJN4HVIP.js.map} +1 -1
  41. package/dist/prompts-XMJXIITW.js +13 -0
  42. package/dist/runbook-builder-2ZLE2AEO.js +11 -0
  43. package/dist/{runbook-data-helpers-KRR2SH76.js → runbook-data-helpers-5UAO65TZ.js} +3 -3
  44. package/dist/{runbook-executor-K7T6RJWJ.js → runbook-executor-TVV5EG6Q.js} +41 -444
  45. package/dist/runbook-executor-TVV5EG6Q.js.map +1 -0
  46. package/dist/{runbook-generator-MPXJBQ5N.js → runbook-generator-4XKNV2B7.js} +61 -136
  47. package/dist/runbook-generator-4XKNV2B7.js.map +1 -0
  48. package/dist/{runbook-schema-3T6TP3JJ.js → runbook-schema-X7DW725O.js} +2 -2
  49. package/dist/runbook-store-S24PXIHD.js +11 -0
  50. package/dist/{schema-5G6UQSPT.js → schema-XFSD5EWN.js} +2 -2
  51. package/dist/{server-AG3LXQBI.js → server-5XARL5N7.js} +1176 -128
  52. package/dist/server-5XARL5N7.js.map +1 -0
  53. package/dist/{tenant-ai-config-QPFEJUVJ.js → tenant-ai-config-4NHKRW7O.js} +4 -4
  54. package/dist/tenant-ai-config-4NHKRW7O.js.map +1 -0
  55. package/dist/yaml-patcher-32QBPXT2.js +18 -0
  56. package/dist/yaml-patcher-32QBPXT2.js.map +1 -0
  57. package/package.json +3 -2
  58. package/dist/chunk-2BVDAJZT.js.map +0 -1
  59. package/dist/chunk-7UCVPKD4.js.map +0 -1
  60. package/dist/chunk-CLYJHKPY.js.map +0 -1
  61. package/dist/chunk-DJVUITRB.js.map +0 -1
  62. package/dist/chunk-H47NWH7N.js.map +0 -1
  63. package/dist/chunk-IGFCYKHC.js.map +0 -1
  64. package/dist/chunk-RT664YIO.js.map +0 -1
  65. package/dist/chunk-RYIJPYM3.js.map +0 -1
  66. package/dist/chunk-UGPXCQY3.js.map +0 -1
  67. package/dist/chunk-VPK2MQAZ.js +0 -589
  68. package/dist/chunk-VPK2MQAZ.js.map +0 -1
  69. package/dist/chunk-Z33FCOTZ.js.map +0 -1
  70. package/dist/runbook-executor-K7T6RJWJ.js.map +0 -1
  71. package/dist/runbook-generator-MPXJBQ5N.js.map +0 -1
  72. package/dist/runbook-store-G5GUOWRR.js +0 -11
  73. package/dist/server-AG3LXQBI.js.map +0 -1
  74. package/dist/yaml-patcher-VGUS2JGH.js +0 -15
  75. /package/dist/{ai-model-FM6GWCID.js.map → ai-model-DP5PKGM6.js.map} +0 -0
  76. /package/dist/{chunk-WEYR56ZN.js.map → chunk-HHRHHFSK.js.map} +0 -0
  77. /package/dist/{chunk-HQDXLWAY.js.map → chunk-SDV3X5UN.js.map} +0 -0
  78. /package/dist/{runbook-data-helpers-KRR2SH76.js.map → prompts-XMJXIITW.js.map} +0 -0
  79. /package/dist/{runbook-schema-3T6TP3JJ.js.map → runbook-builder-2ZLE2AEO.js.map} +0 -0
  80. /package/dist/{runbook-store-G5GUOWRR.js.map → runbook-data-helpers-5UAO65TZ.js.map} +0 -0
  81. /package/dist/{schema-5G6UQSPT.js.map → runbook-schema-X7DW725O.js.map} +0 -0
  82. /package/dist/{tenant-ai-config-QPFEJUVJ.js.map → runbook-store-S24PXIHD.js.map} +0 -0
  83. /package/dist/{yaml-patcher-VGUS2JGH.js.map → schema-XFSD5EWN.js.map} +0 -0
@@ -17,6 +17,7 @@ import {
17
17
  enforceFeatureGates,
18
18
  execute,
19
19
  formatPlanLabel,
20
+ generateExecutionReportFile,
20
21
  getApiKey,
21
22
  loadCache,
22
23
  loadChatConfig,
@@ -25,28 +26,7 @@ import {
25
26
  saveCache,
26
27
  validateBatchLimit,
27
28
  validateStepLimit
28
- } from "./chunk-H47NWH7N.js";
29
- import {
30
- formatAiMetricsSection,
31
- formatAiSelectorQualityIssues,
32
- formatDebugLogSections,
33
- formatFailureCategoryDistribution,
34
- formatPerformanceBottlenecks,
35
- formatRecoveryEffectiveness,
36
- formatRetryDistribution,
37
- formatRuntimeEnvironment,
38
- formatSelectorResolutionStats,
39
- readDebugLog,
40
- renderOptionsMarkdown,
41
- serializeExecutorOptions
42
- } from "./chunk-VPK2MQAZ.js";
43
- import {
44
- checkHelpFlag,
45
- getRawArgs,
46
- parseModelConfig,
47
- readContextFile,
48
- validateNotifyMode
49
- } from "./chunk-2BVDAJZT.js";
29
+ } from "./chunk-CJM3IU5Q.js";
50
30
  import {
51
31
  AgentBrowser,
52
32
  DownloadManager,
@@ -55,33 +35,45 @@ import {
55
35
  NoopSpinner,
56
36
  formatDuration,
57
37
  getRecoveryHint,
58
- loadSecrets
59
- } from "./chunk-DJVUITRB.js";
60
- import "./chunk-XMFCXPYU.js";
38
+ loadSecrets,
39
+ serializeExecutorOptions
40
+ } from "./chunk-ELQ23L4Z.js";
61
41
  import {
62
- createSkills,
63
- initBuiltinSkills
64
- } from "./chunk-AG3CFMYU.js";
42
+ checkHelpFlag,
43
+ getRawArgs,
44
+ parseModelConfig,
45
+ readContextFile,
46
+ validateNotifyMode
47
+ } from "./chunk-65CTEK2K.js";
65
48
  import "./chunk-D5SI2PHK.js";
66
49
  import {
67
50
  cancel,
68
- initLocale,
69
51
  intro,
70
52
  log,
71
53
  note,
72
- outro,
73
- t,
74
- tf
75
- } from "./chunk-7UCVPKD4.js";
54
+ outro
55
+ } from "./chunk-XIVS7N3V.js";
76
56
  import {
77
57
  computeCacheRate,
78
58
  computeTotalRealInput,
79
59
  globalMetrics,
80
60
  initModel
81
- } from "./chunk-UGPXCQY3.js";
61
+ } from "./chunk-KFNW4XR2.js";
62
+ import "./chunk-XMFCXPYU.js";
63
+ import {
64
+ createSkills,
65
+ initBuiltinSkills
66
+ } from "./chunk-AG3CFMYU.js";
67
+ import "./chunk-YTVEYQGA.js";
82
68
  import {
83
69
  ParsedRunbookSchema
84
- } from "./chunk-RT664YIO.js";
70
+ } from "./chunk-LZDZGI4M.js";
71
+ import "./chunk-EMAYENG4.js";
72
+ import {
73
+ initLocale,
74
+ t,
75
+ tf
76
+ } from "./chunk-F7WTOQIQ.js";
85
77
  import "./chunk-2H7UOFLK.js";
86
78
 
87
79
  // src/runbook-executor/config.ts
@@ -97,7 +89,7 @@ async function parseArgs() {
97
89
  headless: { type: "string" },
98
90
  "step-delay": { type: "string" },
99
91
  screenshots: { type: "string" },
100
- "skip-confirmation": { type: "boolean" },
92
+ yes: { type: "boolean", short: "y" },
101
93
  data: { type: "string" },
102
94
  secrets: { type: "string" },
103
95
  "reuse-session": { type: "boolean" },
@@ -171,7 +163,7 @@ async function parseArgs() {
171
163
  stepDelay: values["step-delay"] ? Number.parseInt(values["step-delay"], 10) : void 0,
172
164
  screenshotDir: values.screenshots,
173
165
  contextMarkdown,
174
- skipConfirmation: values["skip-confirmation"] ?? selfHeal,
166
+ skipConfirmation: values.yes ?? selfHeal,
175
167
  dataFilePath: values.data,
176
168
  secrets,
177
169
  reuseSession,
@@ -506,9 +498,13 @@ async function executeBatch(config, runbook, baseStore, dataRows, reuseSession,
506
498
  await new Promise((r) => setTimeout(r, 500));
507
499
  }
508
500
  const rowConfig = config;
501
+ const rowDataStore = new InMemoryDataStore();
502
+ const rowDownloadManager = config.outputDir ? new DownloadManager(config.outputDir) : void 0;
509
503
  const report = await execute(rowConfig, runbook, {
510
504
  store: rowStore,
511
505
  browser: sharedBrowser,
506
+ dataStore: rowDataStore,
507
+ downloadManager: rowDownloadManager,
512
508
  confirmationProvider: batchOpts.confirmationProvider,
513
509
  selectorCache: batchOpts.selectorCache,
514
510
  logger,
@@ -815,407 +811,6 @@ var cliLoggerFactory = {
815
811
  createSpinner: () => new CliSpinner()
816
812
  };
817
813
 
818
- // src/runbook-executor/report-generator.ts
819
- function formatStepResult(step, indent) {
820
- const lines = [];
821
- const duration = `${step.durationMs}ms`;
822
- if (step.conditionSkipped) {
823
- lines.push(`${indent}${step.ordinal}. [SKIPPED] ${step.description} (condition skipped)`);
824
- return lines;
825
- }
826
- if (step.branchMatch !== void 0) {
827
- const tag2 = step.status === "success" ? "DONE" : step.status === "skipped" ? "SKIPPED" : "FAILED";
828
- lines.push(`${indent}${step.ordinal}. [${tag2}] ${step.description} (branch: ${step.branchMatch || "no match"}, ${duration})`);
829
- if (step.subStepResults) {
830
- for (const subResults of step.subStepResults) {
831
- for (const sub of subResults) {
832
- lines.push(...formatStepResult(sub, `${indent} `));
833
- }
834
- }
835
- }
836
- return lines;
837
- }
838
- if (step.loopIterations !== void 0) {
839
- const tag2 = step.status === "success" ? "DONE" : "FAILED";
840
- const iterLabel = step.forEachItemCount !== void 0 ? `forEach: ${step.forEachItemCount} items` : `${step.loopIterations} iterations`;
841
- lines.push(`${indent}${step.ordinal}. [${tag2}] ${step.description} (${iterLabel}, ${duration})`);
842
- if (step.subStepResults) {
843
- for (let i = 0; i < step.subStepResults.length; i++) {
844
- lines.push(`${indent} iteration ${i}:`);
845
- for (const sub of step.subStepResults[i]) {
846
- lines.push(...formatStepResult(sub, `${indent} `));
847
- }
848
- }
849
- }
850
- return lines;
851
- }
852
- const tag = step.status === "success" ? "DONE" : step.status === "failed" ? "FAILED" : "SKIPPED";
853
- const errorInfo = step.status === "failed" && step.error ? ` \u2014 Error: ${step.error}` : "";
854
- const category = step.failureCategory ? ` [${step.failureCategory}]` : "";
855
- const retry = step.retryCount ? ` (retries: ${step.retryCount})` : "";
856
- lines.push(`${indent}${step.ordinal}. [${tag}] ${step.description} (${duration})${errorInfo}${category}${retry}`);
857
- return lines;
858
- }
859
- function formatDiagnostics(diag, stepOrdinal) {
860
- const lines = [];
861
- lines.push(`### Step #${stepOrdinal} \u2014 Diagnostics`);
862
- lines.push("");
863
- if (diag.stepAction) {
864
- lines.push(`**Step Action**: type=${diag.stepAction.type}`);
865
- if (diag.stepAction.value) lines.push(`- value: ${diag.stepAction.value}`);
866
- if (diag.stepAction.url) lines.push(`- url: ${diag.stepAction.url}`);
867
- if (diag.stepAction.selector) {
868
- lines.push("- selector:");
869
- lines.push("```json");
870
- lines.push(JSON.stringify(diag.stepAction.selector, null, 2));
871
- lines.push("```");
872
- }
873
- lines.push("");
874
- }
875
- if (diag.stepUrl) {
876
- lines.push(`**Step URL**: ${diag.stepUrl}`);
877
- lines.push("");
878
- }
879
- if (diag.recoveryHint) {
880
- lines.push(`**Recovery Hint**: ${diag.recoveryHint}`);
881
- lines.push("");
882
- }
883
- if (diag.executionStrategy) {
884
- const s = diag.executionStrategy;
885
- lines.push(`**Execution Strategy**: maxRetries=${s.maxRetries}, changeTimeouts=[${s.changeTimeouts.join(",")}]ms, finalRetryStabilize=${s.finalRetryStabilizeMs}ms, domStability=${s.domStabilityMs}ms`);
886
- lines.push("");
887
- }
888
- if (diag.deterministicResolveResult) {
889
- lines.push(`**Deterministic Resolve**: ${diag.deterministicResolveResult}`);
890
- lines.push("");
891
- }
892
- if (diag.failureHistory && diag.failureHistory.length > 0) {
893
- lines.push("**Failure History**:");
894
- for (const f of diag.failureHistory) {
895
- lines.push(`- ${f}`);
896
- }
897
- lines.push("");
898
- }
899
- if (diag.validationWarnings && diag.validationWarnings.length > 0) {
900
- lines.push("**Validation Warnings**:");
901
- for (const w of diag.validationWarnings) {
902
- lines.push(`- ${w}`);
903
- }
904
- lines.push("");
905
- }
906
- if (diag.validationErrors && diag.validationErrors.length > 0) {
907
- lines.push("**Validation Errors**:");
908
- for (const e of diag.validationErrors) {
909
- lines.push(`- ${e}`);
910
- }
911
- lines.push("");
912
- }
913
- if (diag.visionFallbackResult) {
914
- const vf = diag.visionFallbackResult;
915
- lines.push(`**Vision Fallback**: annotations=${vf.annotationCount}, success=${vf.success}`);
916
- lines.push(`- Reasoning: ${vf.reasoning}`);
917
- lines.push("");
918
- }
919
- if (diag.agentFallbackResult) {
920
- const fb = diag.agentFallbackResult;
921
- lines.push(`**Agent Fallback**: strategy=${fb.strategy}, success=${fb.success}`);
922
- lines.push(`- Analysis: ${fb.analysis}`);
923
- lines.push(`- Reasoning: ${fb.reasoning}`);
924
- lines.push("");
925
- }
926
- if (diag.lastAiResponseText) {
927
- lines.push("**Last AI Response**:");
928
- lines.push("```json");
929
- lines.push(diag.lastAiResponseText);
930
- lines.push("```");
931
- lines.push("");
932
- }
933
- if (diag.lastSnapshotPreview) {
934
- lines.push("**Last Snapshot Preview** (truncated):");
935
- lines.push("```");
936
- lines.push(diag.lastSnapshotPreview);
937
- lines.push("```");
938
- lines.push("");
939
- }
940
- return lines;
941
- }
942
- function formatRetryDetails(retryDetails, stepOrdinal) {
943
- if (!retryDetails || retryDetails.length === 0) return [];
944
- const lines = [];
945
- lines.push(`### Step #${stepOrdinal} \u2014 Retry Details`);
946
- lines.push("");
947
- for (const detail of retryDetails) {
948
- lines.push(`#### Attempt ${detail.attempt}`);
949
- lines.push(`- Snapshot changed: ${detail.snapshotChanged}`);
950
- lines.push(`- Element count: ${detail.snapshotElementCount}`);
951
- lines.push(`- Failure reason: ${detail.failureReason}`);
952
- if (detail.aiReasoning) {
953
- lines.push(`- AI reasoning: ${detail.aiReasoning}`);
954
- }
955
- if (detail.aiResponse) {
956
- lines.push("- AI response:");
957
- lines.push("```json");
958
- lines.push(detail.aiResponse);
959
- lines.push("```");
960
- }
961
- if (detail.aiPrompt) {
962
- lines.push("");
963
- lines.push("<details>");
964
- lines.push(`<summary>AI Prompt (attempt ${detail.attempt})</summary>`);
965
- lines.push("");
966
- lines.push("```");
967
- lines.push(detail.aiPrompt);
968
- lines.push("```");
969
- lines.push("</details>");
970
- }
971
- if (detail.snapshotPreview) {
972
- lines.push("");
973
- lines.push("<details>");
974
- lines.push(`<summary>Snapshot Preview (attempt ${detail.attempt}, truncated)</summary>`);
975
- lines.push("");
976
- lines.push("```");
977
- lines.push(detail.snapshotPreview);
978
- lines.push("```");
979
- lines.push("</details>");
980
- }
981
- lines.push("");
982
- }
983
- return lines;
984
- }
985
- function formatAiAgentSummary(failedSteps, input) {
986
- const lines = [];
987
- lines.push("## AI Agent Summary");
988
- lines.push("");
989
- lines.push("\u4EE5\u4E0B\u306F AI \u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u304C\u5373\u5EA7\u306B\u4FEE\u6B63\u30A2\u30AF\u30B7\u30E7\u30F3\u3092\u53D6\u308B\u305F\u3081\u306E\u69CB\u9020\u5316\u60C5\u5831\u3067\u3059\u3002");
990
- lines.push("");
991
- lines.push("### \u5931\u6557\u30B9\u30C6\u30C3\u30D7\u3068\u4FEE\u6B63\u6307\u793A");
992
- lines.push("");
993
- for (const step of failedSteps) {
994
- lines.push(`#### Step #${step.ordinal}: ${step.description}`);
995
- lines.push("");
996
- lines.push(`- **\u30A8\u30E9\u30FC**: ${step.error ?? "Unknown"}`);
997
- if (step.failureCategory) {
998
- lines.push(`- **\u5206\u985E**: \`${step.failureCategory}\``);
999
- lines.push(`- **\u63A8\u5968\u5BFE\u5FDC**: ${getRecoveryHint(step.failureCategory)}`);
1000
- }
1001
- if (step.retryCount !== void 0 && step.retryCount > 0) {
1002
- lines.push(`- **\u30EA\u30C8\u30E9\u30A4\u56DE\u6570**: ${step.retryCount}`);
1003
- }
1004
- if (step.diagnostics) {
1005
- const diag = step.diagnostics;
1006
- if (diag.stepAction?.selector) {
1007
- lines.push(`- **\u73FE\u5728\u306E\u30BB\u30EC\u30AF\u30BF**:`);
1008
- lines.push(" ```json");
1009
- lines.push(` ${JSON.stringify(diag.stepAction.selector)}`);
1010
- lines.push(" ```");
1011
- }
1012
- if (diag.lastSnapshotPreview) {
1013
- lines.push(`- **\u6700\u7D42\u30B9\u30CA\u30C3\u30D7\u30B7\u30E7\u30C3\u30C8**:`);
1014
- lines.push(" <details>");
1015
- lines.push(" <summary>\u30B9\u30CA\u30C3\u30D7\u30B7\u30E7\u30C3\u30C8\u5168\u6587\u3092\u8868\u793A</summary>");
1016
- lines.push("");
1017
- lines.push(" ```");
1018
- lines.push(` ${diag.lastSnapshotPreview}`);
1019
- lines.push(" ```");
1020
- lines.push(" </details>");
1021
- }
1022
- if (diag.visionFallbackResult) {
1023
- lines.push(`- **Vision Fallback \u7D50\u679C**: annotations=${diag.visionFallbackResult.annotationCount}, success=${diag.visionFallbackResult.success}`);
1024
- lines.push(` - \u7406\u7531: ${diag.visionFallbackResult.reasoning}`);
1025
- }
1026
- if (diag.agentFallbackResult) {
1027
- lines.push(`- **Agent Fallback \u7D50\u679C**: strategy=${diag.agentFallbackResult.strategy}, success=${diag.agentFallbackResult.success}`);
1028
- lines.push(` - \u5206\u6790: ${diag.agentFallbackResult.analysis}`);
1029
- }
1030
- }
1031
- if (input.selfHealSuggestions) {
1032
- const suggestion = input.selfHealSuggestions.find(
1033
- (s) => s.stepOrdinal === step.ordinal
1034
- );
1035
- if (suggestion) {
1036
- if (suggestion.runbookFix) {
1037
- lines.push(`- **YAML \u4FEE\u6B63\u63D0\u6848**: ${suggestion.runbookFix}`);
1038
- }
1039
- if (suggestion.contextFix) {
1040
- lines.push(`- **Context \u4FEE\u6B63\u63D0\u6848**: ${suggestion.contextFix}`);
1041
- }
1042
- if (suggestion.suggestedStrategy) {
1043
- lines.push(`- **\u63A8\u5968\u6226\u7565**: ${suggestion.suggestedStrategy}`);
1044
- }
1045
- }
1046
- }
1047
- lines.push("");
1048
- }
1049
- lines.push("### \u4FEE\u6B63\u5BFE\u8C61\u30D5\u30A1\u30A4\u30EB");
1050
- lines.push("");
1051
- lines.push(`- \`${input.runbookPath}\` (Steps: ${failedSteps.map((s) => `#${s.ordinal}`).join(", ")})`);
1052
- lines.push("");
1053
- lines.push("### \u4FEE\u6B63\u5F8C\u306E\u691C\u8A3C\u30B3\u30DE\u30F3\u30C9");
1054
- lines.push("");
1055
- lines.push("```bash");
1056
- lines.push(`pnpm execute -- --runbook ${input.runbookPath} --self-heal`);
1057
- lines.push("```");
1058
- lines.push("");
1059
- return lines;
1060
- }
1061
- function formatSystemInsights(report, debugEntries) {
1062
- const lines = [];
1063
- lines.push("## System Insights");
1064
- lines.push("");
1065
- lines.push("> refrain \u306E\u6A5F\u80FD\u6539\u5584\u30FB\u30D0\u30B0\u4FEE\u6B63\u306E\u305F\u3081\u306E\u5206\u6790\u60C5\u5831");
1066
- lines.push("");
1067
- const allSteps = flattenSteps2(report.steps);
1068
- lines.push(...formatRuntimeEnvironment());
1069
- if (report.aiMetrics && report.aiMetrics.totalCalls > 0) {
1070
- lines.push(...formatAiMetricsSection(report.aiMetrics));
1071
- }
1072
- lines.push(...formatSelectorResolutionStats(debugEntries, allSteps));
1073
- lines.push(...formatRetryDistribution(allSteps));
1074
- const failedSteps = allSteps.filter((s) => s.status === "failed");
1075
- lines.push(...formatFailureCategoryDistribution(failedSteps));
1076
- lines.push(...formatRecoveryEffectiveness(debugEntries, allSteps));
1077
- lines.push(...formatPerformanceBottlenecks(allSteps));
1078
- lines.push(...formatAiSelectorQualityIssues(debugEntries));
1079
- return lines;
1080
- }
1081
- function flattenSteps2(steps) {
1082
- const result = [];
1083
- for (const step of steps) {
1084
- result.push(step);
1085
- if (step.subStepResults) {
1086
- for (const iteration of step.subStepResults) {
1087
- result.push(...flattenSteps2(iteration));
1088
- }
1089
- }
1090
- }
1091
- return result;
1092
- }
1093
- async function generateExecutionReportFile(input) {
1094
- const { report } = input;
1095
- const lines = [];
1096
- lines.push("# Execution Report");
1097
- lines.push("");
1098
- lines.push("## Session Info");
1099
- lines.push(`- **Date**: ${(/* @__PURE__ */ new Date()).toISOString()}`);
1100
- lines.push(`- **Runbook**: ${report.runbookTitle}`);
1101
- lines.push(`- **Runbook Path**: ${input.runbookPath}`);
1102
- lines.push(`- **Start URL**: ${report.startUrl}`);
1103
- const outcome = report.aborted ? "Aborted" : report.failed > 0 ? "Failed" : input.errorMessage ? "Error" : "Success";
1104
- lines.push(`- **Outcome**: ${outcome}`);
1105
- lines.push("");
1106
- if (input.cliOptions && input.cliOptions.length > 0) {
1107
- lines.push("## Executor CLI Options");
1108
- lines.push(...renderOptionsMarkdown(input.cliOptions));
1109
- lines.push("");
1110
- }
1111
- if (input.generationContext) {
1112
- const gc = input.generationContext;
1113
- lines.push("## Generation Context");
1114
- lines.push(`- **Goal**: ${gc.goal}`);
1115
- lines.push(`- **Start URL**: ${gc.startUrl}`);
1116
- lines.push(`- **Goal Achieved (at generation)**: ${gc.goalAchieved}`);
1117
- lines.push(`- **Generated At**: ${gc.generatedAt}`);
1118
- lines.push(`- **Total Steps (generated)**: ${gc.totalSteps}`);
1119
- if (gc.notes) {
1120
- lines.push("- **Notes**:");
1121
- for (const line of gc.notes.split("\n")) {
1122
- lines.push(` > ${line}`);
1123
- }
1124
- }
1125
- lines.push("");
1126
- }
1127
- if (input.errorMessage) {
1128
- lines.push("## Error Details");
1129
- lines.push("```");
1130
- lines.push(input.errorMessage);
1131
- lines.push("```");
1132
- lines.push("");
1133
- }
1134
- lines.push("## Execution Summary");
1135
- lines.push(`- **Total Steps**: ${report.totalSteps}`);
1136
- lines.push(`- **Executed**: ${report.executed}`);
1137
- lines.push(`- **Succeeded**: ${report.succeeded}`);
1138
- lines.push(`- **Failed**: ${report.failed}`);
1139
- lines.push(`- **Skipped**: ${report.skipped}`);
1140
- lines.push(`- **Aborted**: ${report.aborted}`);
1141
- lines.push(`- **Duration**: ${report.totalDurationMs}ms`);
1142
- lines.push("");
1143
- const allFlatSteps = flattenSteps2(report.steps);
1144
- const extractSteps = allFlatSteps.filter((s) => s.actionType === "extract");
1145
- if (extractSteps.length > 0) {
1146
- const extractFailures = extractSteps.filter((s) => s.status === "failed");
1147
- const extractEmpty = extractSteps.filter(
1148
- (s) => s.status === "success" && (!s.extractedData || s.extractedData === "")
1149
- );
1150
- const extractSuccess = extractSteps.filter(
1151
- (s) => s.status === "success" && s.extractedData && s.extractedData !== ""
1152
- );
1153
- lines.push("## Extract Summary");
1154
- lines.push("");
1155
- lines.push(`- **Total extract steps**: ${extractSteps.length}`);
1156
- lines.push(`- **Succeeded (with data)**: ${extractSuccess.length}`);
1157
- lines.push(`- **Succeeded (empty result)**: ${extractEmpty.length}`);
1158
- lines.push(`- **Failed**: ${extractFailures.length}`);
1159
- lines.push("");
1160
- if (extractFailures.length > 0) {
1161
- lines.push("### Extract Failures");
1162
- lines.push("");
1163
- for (const step of extractFailures) {
1164
- lines.push(`- **Step #${step.ordinal}** (${step.description}): ${step.error ?? "Unknown"}`);
1165
- }
1166
- lines.push("");
1167
- }
1168
- if (extractEmpty.length > 0) {
1169
- lines.push("### Extract Empty Results (Warning)");
1170
- lines.push("");
1171
- for (const step of extractEmpty) {
1172
- lines.push(`- **Step #${step.ordinal}** (${step.description}): Script executed but returned empty`);
1173
- }
1174
- lines.push("");
1175
- }
1176
- }
1177
- if (report.steps.length > 0) {
1178
- lines.push("## Step Results");
1179
- for (const step of report.steps) {
1180
- lines.push(...formatStepResult(step, ""));
1181
- }
1182
- lines.push("");
1183
- }
1184
- const failedSteps = report.steps.filter((s) => s.status === "failed");
1185
- if (failedSteps.length > 0) {
1186
- lines.push("## Failed Step Diagnostics");
1187
- lines.push("");
1188
- for (const step of failedSteps) {
1189
- if (step.retryDetails && step.retryDetails.length > 0) {
1190
- lines.push(...formatRetryDetails(step.retryDetails, step.ordinal));
1191
- }
1192
- if (step.diagnostics) {
1193
- lines.push(...formatDiagnostics(step.diagnostics, step.ordinal));
1194
- }
1195
- if (!step.diagnostics && (!step.retryDetails || step.retryDetails.length === 0)) {
1196
- lines.push(`### Step #${step.ordinal} \u2014 Error Info`);
1197
- lines.push("");
1198
- lines.push(`**Error**: ${step.error ?? "Unknown"}`);
1199
- if (step.failureCategory) {
1200
- lines.push(`**Category**: ${step.failureCategory}`);
1201
- }
1202
- lines.push("");
1203
- }
1204
- }
1205
- }
1206
- if (failedSteps.length > 0) {
1207
- lines.push(...formatAiAgentSummary(failedSteps, input));
1208
- }
1209
- const debugEntries = input.debugLogPath ? await readDebugLog(input.debugLogPath) : [];
1210
- lines.push(...formatSystemInsights(report, debugEntries));
1211
- const failedOrdinals = new Set(failedSteps.map((s) => s.ordinal));
1212
- lines.push(...formatDebugLogSections(debugEntries, {
1213
- showFailedStepEvents: true,
1214
- failedOrdinals
1215
- }));
1216
- return lines.join("\n");
1217
- }
1218
-
1219
814
  // src/runbook-executor/index.ts
1220
815
  import { writeFile, mkdir } from "fs/promises";
1221
816
  import { dirname } from "path";
@@ -1290,7 +885,7 @@ async function main() {
1290
885
  log.info(`Secrets: ${Object.keys(config.secrets.values).length} keys loaded`);
1291
886
  }
1292
887
  if (config.skipConfirmation) {
1293
- log.info(`Skip confirmation: true`);
888
+ log.info("Yes mode: true");
1294
889
  }
1295
890
  if (approvalMode !== "web") {
1296
891
  log.info(`Approval mode: ${approvalMode}`);
@@ -1336,10 +931,12 @@ async function main() {
1336
931
  log.info(`Data file: ${dataRows.length} rows`);
1337
932
  }
1338
933
  displayPlan(plan, runbook, dataRows?.length);
1339
- const confirmed = await confirmPlan();
1340
- if (!confirmed) {
1341
- cancel(t("cli.executionCancelled"));
1342
- process.exit(0);
934
+ if (!config.skipConfirmation) {
935
+ const confirmed = await confirmPlan();
936
+ if (!confirmed) {
937
+ cancel(t("cli.executionCancelled"));
938
+ process.exit(0);
939
+ }
1343
940
  }
1344
941
  const store = new RuntimeStore();
1345
942
  store.seed(plan.resolvedVariables.values, plan.resolvedVariables.sensitiveKeys);
@@ -1477,4 +1074,4 @@ main().catch((error) => {
1477
1074
  }
1478
1075
  process.exit(1);
1479
1076
  });
1480
- //# sourceMappingURL=runbook-executor-K7T6RJWJ.js.map
1077
+ //# sourceMappingURL=runbook-executor-TVV5EG6Q.js.map