markform 0.1.27 → 0.1.29

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { A as MarkformSectionInputSchema, B as ProgressCountsSchema, R as PatchSchema, ht as StructureSummarySchema, z as PatchWarningSchema } from "./coreTypes-DIv9Aabl.mjs";
3
- import { $ as DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN, A as tryParseSentinelResponse, B as isTagNode, D as detectSyntaxStyle, F as getBooleanAttr, G as DEFAULT_MAX_PARALLEL_AGENTS, H as AGENT_ROLE, I as getNumberAttr, J as DEFAULT_MAX_STEPS_PER_TURN, K as DEFAULT_MAX_PATCHES_PER_TURN, L as getStringArrayAttr, M as extractFenceValue, N as extractOptionItems, O as preprocessCommentSyntax, P as extractTableContent, Pt as wrapApiError, Q as DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN, R as getStringAttr, S as computeStructureSummary, St as MarkformParseError, V as parseOptionText, W as DEFAULT_MAX_ISSUES_PER_TURN, Y as DEFAULT_MAX_TURNS, Z as DEFAULT_PRIORITY, _ as inspect, a as WEB_SEARCH_INSTRUCTIONS, c as filterIssuesByOrder, d as coerceInputContext, dt as transformHarnessConfigToTs, et as DEFAULT_ROLES, g as getFieldsForRoles, ht as getWebSearchConfig, i as SECTION_HEADERS, j as CHECKBOX_MARKERS, l as filterIssuesByScope, m as applyPatches, n as GENERAL_INSTRUCTIONS, o as getIssuesIntro, q as DEFAULT_MAX_RETRIES, r as ISSUES_HEADER, s as getPatchFormatHint, t as DEFAULT_SYSTEM_PROMPT, tt as DEFAULT_ROLE_INSTRUCTIONS, w as serializeForm, x as computeProgressSummary, yt as MarkformConfigError, z as getValidateAttr } from "./prompts-CwEV0X5z.mjs";
3
+ import { $ as DEFAULT_MAX_TURNS, A as extractTableHeaderLabels, B as getNumberAttr, Ct as MarkformConfigError, D as detectSyntaxStyle, Et as MarkformParseError, F as CHECKBOX_MARKERS, G as parseOptionText, H as getStringAttr, I as extractFenceValue, K as AGENT_ROLE, L as extractOptionItems, M as parseMarkdownTable, O as preprocessCommentSyntax, P as tryParseSentinelResponse, Q as DEFAULT_MAX_STEPS_PER_TURN, R as extractTableContent, Rt as wrapApiError, S as computeStructureSummary, U as getValidateAttr, V as getStringArrayAttr, W as isTagNode, X as DEFAULT_MAX_PARALLEL_AGENTS, Y as DEFAULT_MAX_ISSUES_PER_TURN, Z as DEFAULT_MAX_PATCHES_PER_TURN, _ as inspect, a as WEB_SEARCH_INSTRUCTIONS, at as DEFAULT_ROLE_INSTRUCTIONS, c as filterIssuesByOrder, d as coerceInputContext, g as getFieldsForRoles, ht as transformHarnessConfigToTs, i as SECTION_HEADERS, it as DEFAULT_ROLES, l as filterIssuesByScope, m as applyPatches, n as GENERAL_INSTRUCTIONS, nt as DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN, o as getIssuesIntro, r as ISSUES_HEADER, rt as DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN, s as getPatchFormatHint, t as DEFAULT_SYSTEM_PROMPT, tt as DEFAULT_PRIORITY, w as serializeForm, x as computeProgressSummary, yt as getWebSearchConfig, z as getBooleanAttr } from "./prompts-BR5xYbvY.mjs";
4
4
  import { z } from "zod";
5
5
  import Markdoc from "@markdoc/markdoc";
6
6
  import YAML from "yaml";
@@ -34,228 +34,6 @@ const FIELD_KINDS = [
34
34
  "table"
35
35
  ];
36
36
 
37
- //#endregion
38
- //#region src/engine/table/parseTable.ts
39
- /** Sentinel pattern: %SKIP% or %SKIP:reason% or %SKIP(reason)% */
40
- const SKIP_PATTERN = /^%SKIP(?:[:(](.*))?[)]?%$/i;
41
- /** Sentinel pattern: %ABORT% or %ABORT:reason% or %ABORT(reason)% */
42
- const ABORT_PATTERN = /^%ABORT(?:[:(](.*))?[)]?%$/i;
43
- /** Markdown link pattern: [text](url) */
44
- const MARKDOWN_LINK_PATTERN = /^\[([^\]]*)\]\(([^)]+)\)$/;
45
- /**
46
- * Extract URL from markdown link format if present.
47
- * Returns the URL part from [text](url) format, or the original value if not a markdown link.
48
- */
49
- function extractUrlFromMarkdownLink(value) {
50
- const match = MARKDOWN_LINK_PATTERN.exec(value);
51
- if (match) return match[2];
52
- return value;
53
- }
54
- /**
55
- * Detect if a cell value is a sentinel.
56
- */
57
- function parseSentinel(value) {
58
- const trimmed = value.trim();
59
- const skipMatch = SKIP_PATTERN.exec(trimmed);
60
- if (skipMatch) return {
61
- type: "skip",
62
- reason: skipMatch[1]
63
- };
64
- const abortMatch = ABORT_PATTERN.exec(trimmed);
65
- if (abortMatch) return {
66
- type: "abort",
67
- reason: abortMatch[1]
68
- };
69
- return null;
70
- }
71
- /**
72
- * Parse a cell value according to its column type.
73
- * Returns a CellResponse with appropriate state.
74
- */
75
- function parseCellValue(rawValue, columnType) {
76
- const trimmed = rawValue.trim();
77
- if (!trimmed) return { state: "skipped" };
78
- const sentinel = parseSentinel(trimmed);
79
- if (sentinel) return {
80
- state: sentinel.type === "skip" ? "skipped" : "aborted",
81
- reason: sentinel.reason
82
- };
83
- const unescaped = trimmed.replace(/\\[|]/g, "|").replace(/<br\s*\/?>/gi, "\n");
84
- switch (columnType) {
85
- case "string": return {
86
- state: "answered",
87
- value: unescaped
88
- };
89
- case "number": {
90
- const num = parseFloat(trimmed);
91
- if (isNaN(num)) return {
92
- state: "answered",
93
- value: trimmed
94
- };
95
- return {
96
- state: "answered",
97
- value: num
98
- };
99
- }
100
- case "url": return {
101
- state: "answered",
102
- value: extractUrlFromMarkdownLink(trimmed)
103
- };
104
- case "date": return {
105
- state: "answered",
106
- value: trimmed
107
- };
108
- case "year": {
109
- const year = parseInt(trimmed, 10);
110
- if (isNaN(year) || !Number.isInteger(year)) return {
111
- state: "answered",
112
- value: trimmed
113
- };
114
- return {
115
- state: "answered",
116
- value: year
117
- };
118
- }
119
- }
120
- }
121
- /**
122
- * Parse a table row into cell values.
123
- * Handles leading/trailing pipes and cell trimming.
124
- */
125
- function parseTableRow(line) {
126
- let trimmed = line.trim();
127
- if (trimmed.startsWith("|")) trimmed = trimmed.slice(1);
128
- if (trimmed.endsWith("|")) trimmed = trimmed.slice(0, -1);
129
- return trimmed.split("|").map((cell) => cell.trim());
130
- }
131
- /**
132
- * Extract header labels from table content.
133
- * Returns array of header labels from the first row, or empty array if no valid header.
134
- */
135
- function extractTableHeaderLabels(content) {
136
- if (!content || content.trim() === "") return [];
137
- const lines = content.trim().split("\n").filter((line) => line.trim());
138
- if (lines.length === 0) return [];
139
- return parseTableRow(lines[0]);
140
- }
141
- /**
142
- * Check if a line is a valid table separator row.
143
- * Each cell should contain only dashes and optional colons for alignment.
144
- */
145
- function isValidSeparator(line, expectedCols) {
146
- const cells = parseTableRow(line);
147
- if (cells.length !== expectedCols) return false;
148
- const separatorPattern = /^:?-+:?$/;
149
- return cells.every((cell) => separatorPattern.test(cell.trim()));
150
- }
151
- /**
152
- * Parse a markdown table with column schema for type coercion.
153
- *
154
- * @param content - The markdown table content
155
- * @param columns - Column definitions from the table field schema
156
- * @param dataStartLine - Optional line index where data rows start (skips header validation)
157
- * @returns Parsed table value with typed cells
158
- */
159
- function parseMarkdownTable(content, columns, dataStartLine) {
160
- const lines = content.trim().split("\n").filter((line) => line.trim());
161
- if (lines.length === 0) return {
162
- ok: true,
163
- value: {
164
- kind: "table",
165
- rows: []
166
- }
167
- };
168
- if (lines.length < 2) return {
169
- ok: false,
170
- error: "Table must have at least a header and separator row"
171
- };
172
- const headerLine = lines[0];
173
- const headers = parseTableRow(headerLine);
174
- const separatorLine = lines[1];
175
- if (!isValidSeparator(separatorLine, headers.length)) return {
176
- ok: false,
177
- error: "Invalid table separator row"
178
- };
179
- if (dataStartLine !== void 0) {
180
- const rows = [];
181
- for (let i = dataStartLine; i < lines.length; i++) {
182
- const rawCells = parseTableRow(lines[i]);
183
- const row = {};
184
- for (let j = 0; j < columns.length; j++) {
185
- const column = columns[j];
186
- const rawValue = rawCells[j] ?? "";
187
- row[column.id] = parseCellValue(rawValue, column.type);
188
- }
189
- rows.push(row);
190
- }
191
- return {
192
- ok: true,
193
- value: {
194
- kind: "table",
195
- rows
196
- }
197
- };
198
- }
199
- const columnIdToIndex = /* @__PURE__ */ new Map();
200
- for (let i = 0; i < headers.length; i++) {
201
- const header = headers[i];
202
- const column = columns.find((c) => c.id === header || c.label === header);
203
- if (column) columnIdToIndex.set(column.id, i);
204
- }
205
- const rows = [];
206
- for (let i = 2; i < lines.length; i++) {
207
- const rawCells = parseTableRow(lines[i]);
208
- const row = {};
209
- for (const column of columns) {
210
- const cellIndex = columnIdToIndex.get(column.id);
211
- const rawValue = cellIndex !== void 0 ? rawCells[cellIndex] ?? "" : "";
212
- row[column.id] = parseCellValue(rawValue, column.type);
213
- }
214
- rows.push(row);
215
- }
216
- return {
217
- ok: true,
218
- value: {
219
- kind: "table",
220
- rows
221
- }
222
- };
223
- }
224
- /**
225
- * Parse just the raw table structure without schema.
226
- * Useful for validation and error reporting.
227
- */
228
- function parseRawTable(content) {
229
- const lines = content.trim().split("\n").filter((line) => line.trim());
230
- if (lines.length === 0) return {
231
- ok: true,
232
- headers: [],
233
- rows: []
234
- };
235
- if (lines.length < 2) return {
236
- ok: false,
237
- error: "Table must have at least a header and separator row"
238
- };
239
- const headers = parseTableRow(lines[0]);
240
- const separatorLine = lines[1];
241
- if (!isValidSeparator(separatorLine, headers.length)) return {
242
- ok: false,
243
- error: "Invalid table separator row"
244
- };
245
- const rows = [];
246
- for (let i = 2; i < lines.length; i++) {
247
- const row = parseTableRow(lines[i]);
248
- while (row.length < headers.length) row.push("");
249
- if (row.length > headers.length) row.length = headers.length;
250
- rows.push(row);
251
- }
252
- return {
253
- ok: true,
254
- headers,
255
- rows
256
- };
257
- }
258
-
259
37
  //#endregion
260
38
  //#region src/engine/parseFields.ts
261
39
  /**
@@ -8482,7 +8260,7 @@ var LiveAgent = class {
8482
8260
  this.additionalTools = config.additionalTools ?? {};
8483
8261
  this.callbacks = config.callbacks;
8484
8262
  this.executionId = config.executionId ?? "0-serial";
8485
- this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
8263
+ this.maxRetries = config.maxRetries;
8486
8264
  this.signal = config.signal;
8487
8265
  this.toolChoice = config.toolChoice ?? "required";
8488
8266
  if (this.enableWebSearch) {
@@ -9760,7 +9538,8 @@ async function fillForm(options) {
9760
9538
  callbacks: mergedCallbacks,
9761
9539
  maxStepsPerTurn: options.maxStepsPerTurn,
9762
9540
  toolChoice: options.toolChoice,
9763
- signal: options.signal
9541
+ signal: options.signal,
9542
+ maxRetries: options.maxRetries
9764
9543
  });
9765
9544
  let turnCount = startingTurnNumber;
9766
9545
  let turnsThisCall = 0;
@@ -9952,7 +9731,8 @@ async function fillFormParallel(form, model, provider, providerTools, options, i
9952
9731
  maxStepsPerTurn: options.maxStepsPerTurn,
9953
9732
  executionId,
9954
9733
  toolChoice: options.toolChoice,
9955
- signal: options.signal
9734
+ signal: options.signal,
9735
+ maxRetries: options.maxRetries
9956
9736
  });
9957
9737
  };
9958
9738
  for (const order of plan.orderLevels) {
@@ -10148,6 +9928,15 @@ async function runMultiTurnForItems(form, agent, items, targetRoles, maxPatchesP
10148
9928
  }
10149
9929
  };
10150
9930
  }
9931
+ if (mergedCallbacks?.onPatchesGenerated) try {
9932
+ mergedCallbacks.onPatchesGenerated({
9933
+ turnNumber: startTurn + turnsUsed + 1,
9934
+ patches: response.patches,
9935
+ stats: response.stats
9936
+ });
9937
+ } catch (cbError) {
9938
+ warnCallbackError("onPatchesGenerated", cbError);
9939
+ }
10151
9940
  let lastCoercionWarnings;
10152
9941
  if (response.patches.length > 0) {
10153
9942
  const applyResult = applyPatches(form, response.patches);
@@ -10640,7 +10429,8 @@ async function runResearch(form, options) {
10640
10429
  provider,
10641
10430
  targetRole: config.targetRoles?.[0] ?? AGENT_ROLE,
10642
10431
  enableWebSearch: options.enableWebSearch,
10643
- additionalTools: options.additionalTools
10432
+ additionalTools: options.additionalTools,
10433
+ maxRetries: options.maxRetries
10644
10434
  });
10645
10435
  const availableTools = agent.getAvailableToolNames();
10646
10436
  let totalInputTokens = 0;
@@ -10727,8 +10517,8 @@ function validateResearchForm(form) {
10727
10517
  //#endregion
10728
10518
  //#region src/index.ts
10729
10519
  /** Markform version (injected at build time). */
10730
- const VERSION = "0.1.27";
10520
+ const VERSION = "0.1.29";
10731
10521
 
10732
10522
  //#endregion
10733
- export { MockAgent as A, fieldToJsonSchema as B, getProviderInfo as C, createLiveAgent as D, buildMockWireFormat as E, isCellRef as F, injectHeaderIds as G, parseForm as H, isFieldRef as I, parseCellValue as J, findAllHeadings as K, isQualifiedRef as L, FormHarness as M, createHarness as N, FillRecordCollector as O, getFieldId as P, parseScopeRef as R, BUILT_IN_PROVIDERS as S, resolveModel as T, findAllCheckboxes as U, formToJsonSchema as V, injectCheckboxIds as W, parseRawTable as X, parseMarkdownTable as Y, resolveHarnessConfig as _, ExecutionMetadataSchema as a, createParallelHarness as b, TimelineEntrySchema as c, ToolCallRecordSchema as d, ToolStatsSchema as f, formatFillRecordSummary as g, stripUnstableFillRecordFields as h, runResearch as i, createMockAgent as j, computeExecutionPlan as k, TimingBreakdownItemSchema as l, isEmptyFillRecord as m, isResearchForm as n, FillRecordSchema as o, ToolSummarySchema as p, findEnclosingHeadings as q, validateResearchForm as r, FillRecordStatusSchema as s, VERSION as t, TimingBreakdownSchema as u, fillForm as v, getProviderNames as w, scopeIssuesForItem as x, ParallelHarness as y, serializeScopeRef as z };
10734
- //# sourceMappingURL=src-DMIq0BFC.mjs.map
10523
+ export { MockAgent as A, fieldToJsonSchema as B, getProviderInfo as C, createLiveAgent as D, buildMockWireFormat as E, isCellRef as F, injectHeaderIds as G, parseForm as H, isFieldRef as I, findAllHeadings as K, isQualifiedRef as L, FormHarness as M, createHarness as N, FillRecordCollector as O, getFieldId as P, parseScopeRef as R, BUILT_IN_PROVIDERS as S, resolveModel as T, findAllCheckboxes as U, formToJsonSchema as V, injectCheckboxIds as W, resolveHarnessConfig as _, ExecutionMetadataSchema as a, createParallelHarness as b, TimelineEntrySchema as c, ToolCallRecordSchema as d, ToolStatsSchema as f, formatFillRecordSummary as g, stripUnstableFillRecordFields as h, runResearch as i, createMockAgent as j, computeExecutionPlan as k, TimingBreakdownItemSchema as l, isEmptyFillRecord as m, isResearchForm as n, FillRecordSchema as o, ToolSummarySchema as p, findEnclosingHeadings as q, validateResearchForm as r, FillRecordStatusSchema as s, VERSION as t, TimingBreakdownSchema as u, fillForm as v, getProviderNames as w, scopeIssuesForItem as x, ParallelHarness as y, serializeScopeRef as z };
10524
+ //# sourceMappingURL=src-eBNM0w2R.mjs.map