@probelabs/probe 0.6.0-rc128 → 0.6.0-rc129

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.
@@ -54632,7 +54632,7 @@ var init_semantics = __esm({
54632
54632
  return;
54633
54633
  for (const cn of contentNodes) {
54634
54634
  const ch = cn.children || {};
54635
- const inspectTok = (tk) => {
54635
+ const inspectTok = (tk, inQuoted = false) => {
54636
54636
  if (!tk)
54637
54637
  return false;
54638
54638
  const img = String(tk.image || "");
@@ -54642,7 +54642,7 @@ var init_semantics = __esm({
54642
54642
  this.ctx.errors.push({
54643
54643
  line: tk.startLine ?? 1,
54644
54644
  column: col,
54645
- severity: "warning",
54645
+ severity: inQuoted ? "error" : "warning",
54646
54646
  code: "FL-LABEL-BACKTICK",
54647
54647
  message: "Backticks (`\u2026`) inside node labels are not supported by Mermaid.",
54648
54648
  hint: 'Remove the backticks or use quotes instead, e.g., "GITHUB_ACTIONS" and "--cli".',
@@ -54654,12 +54654,12 @@ var init_semantics = __esm({
54654
54654
  };
54655
54655
  const texts = ch.Text || [];
54656
54656
  for (const tk of texts) {
54657
- if (inspectTok(tk))
54657
+ if (inspectTok(tk, false))
54658
54658
  return;
54659
54659
  }
54660
54660
  const qs = ch.QuotedString || [];
54661
54661
  for (const tk of qs) {
54662
- if (inspectTok(tk))
54662
+ if (inspectTok(tk, true))
54663
54663
  return;
54664
54664
  }
54665
54665
  }
@@ -55060,6 +55060,36 @@ function mapFlowchartParserError(err, text) {
55060
55060
  length: len
55061
55061
  };
55062
55062
  }
55063
+ {
55064
+ const caret0 = Math.max(0, column - 1);
55065
+ const openIdx = lineStr.lastIndexOf("[", caret0);
55066
+ if (openIdx !== -1) {
55067
+ const closeIdx = lineStr.indexOf("]", openIdx + 1);
55068
+ const seg = closeIdx !== -1 ? lineStr.slice(openIdx + 1, closeIdx) : lineStr.slice(openIdx + 1);
55069
+ if (seg.includes('"')) {
55070
+ return {
55071
+ line,
55072
+ column,
55073
+ severity: "error",
55074
+ code: "FL-LABEL-QUOTE-IN-UNQUOTED",
55075
+ message: "Quotes are not allowed inside unquoted node labels. Use " for quotes or wrap the entire label in quotes.",
55076
+ hint: 'Example: I[Log "processing N items"] or I["Log \\"processing N items\\""]',
55077
+ length: len
55078
+ };
55079
+ }
55080
+ if (seg.includes("(") || seg.includes(")")) {
55081
+ return {
55082
+ line,
55083
+ column,
55084
+ severity: "error",
55085
+ code: "FL-LABEL-PARENS-UNQUOTED",
55086
+ message: "Parentheses inside an unquoted label are not supported by Mermaid.",
55087
+ hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).',
55088
+ length: len
55089
+ };
55090
+ }
55091
+ }
55092
+ }
55063
55093
  if (tokType === "QuotedString") {
55064
55094
  return {
55065
55095
  line,
@@ -55092,6 +55122,24 @@ function mapFlowchartParserError(err, text) {
55092
55122
  length: len
55093
55123
  };
55094
55124
  }
55125
+ {
55126
+ const caret0 = Math.max(0, column - 1);
55127
+ const openIdx = lineStr.lastIndexOf("(", caret0);
55128
+ if (openIdx !== -1) {
55129
+ const seg = lineStr.slice(openIdx + 1);
55130
+ if (seg.includes("(") || seg.includes(")")) {
55131
+ return {
55132
+ line,
55133
+ column,
55134
+ severity: "error",
55135
+ code: "FL-LABEL-PARENS-UNQUOTED",
55136
+ message: "Parentheses inside an unquoted label are not supported by Mermaid.",
55137
+ hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).',
55138
+ length: len
55139
+ };
55140
+ }
55141
+ }
55142
+ }
55095
55143
  const q3 = findInnerQuoteIssue("(");
55096
55144
  if (q3?.kind === "escaped") {
55097
55145
  return { line, column: q3.column, severity: "error", code: "FL-LABEL-ESCAPED-QUOTE", message: 'Escaped quotes (\\") in node labels are not supported by Mermaid. Use " instead.', hint: 'Prefer "He said "Hi"".', length: 2 };
@@ -55113,6 +55161,25 @@ function mapFlowchartParserError(err, text) {
55113
55161
  length: len
55114
55162
  };
55115
55163
  }
55164
+ {
55165
+ const caret0 = Math.max(0, column - 1);
55166
+ const openIdx = lineStr.lastIndexOf("{", caret0);
55167
+ if (openIdx !== -1) {
55168
+ const closeIdx = lineStr.indexOf("}", openIdx + 1);
55169
+ const seg = closeIdx !== -1 ? lineStr.slice(openIdx + 1, closeIdx) : lineStr.slice(openIdx + 1);
55170
+ if (seg.includes("(") || seg.includes(")")) {
55171
+ return {
55172
+ line,
55173
+ column,
55174
+ severity: "error",
55175
+ code: "FL-LABEL-PARENS-UNQUOTED",
55176
+ message: "Parentheses inside an unquoted label are not supported by Mermaid.",
55177
+ hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).',
55178
+ length: len
55179
+ };
55180
+ }
55181
+ }
55182
+ }
55116
55183
  const q3 = findInnerQuoteIssue("{");
55117
55184
  if (q3?.kind === "escaped") {
55118
55185
  return {
@@ -55451,6 +55518,17 @@ ${br.example}`,
55451
55518
  if (inRule("arrow") && err.name === "NoViableAltException") {
55452
55519
  return { line, column, severity: "error", code: "SE-ARROW-INVALID", message: `Invalid sequence arrow near '${found}'.`, hint: "Use ->, -->, ->>, -->>, -x, --x, -), --), <<->>, or <<-->>", length: len };
55453
55520
  }
55521
+ if ((err.name === "NoViableAltException" || err.name === "MismatchedTokenException") && tokType === "Minus") {
55522
+ return {
55523
+ line,
55524
+ column,
55525
+ severity: "error",
55526
+ code: "SE-BULLET-LINE-UNSUPPORTED",
55527
+ message: "Bullet list lines starting with '-' are not supported in sequence diagrams.",
55528
+ hint: "Wrap free\u2011form text in a note block instead, for example:\nNote over A : Item 1\nNote over A\n - Item 1\n - Item 2\nend note",
55529
+ length: len
55530
+ };
55531
+ }
55454
55532
  if (inRule("noteStmt")) {
55455
55533
  if (err.name === "MismatchedTokenException" && exp("Colon")) {
55456
55534
  return { line, column, severity: "error", code: "SE-NOTE-MALFORMED", message: "Malformed note: missing colon before the note text.", hint: "Example: Note right of Alice: Hello", length: len };
@@ -55608,6 +55686,17 @@ ${br.example}`,
55608
55686
  };
55609
55687
  }
55610
55688
  }
55689
+ if ((err.name === "NotAllInputParsedException" || err.name === "NoViableAltException") && found === "-") {
55690
+ return {
55691
+ line,
55692
+ column,
55693
+ severity: "error",
55694
+ code: "SE-BULLET-LINE-UNSUPPORTED",
55695
+ message: "Bullet list lines starting with '-' are not supported in sequence diagrams.",
55696
+ hint: "Wrap free\u2011form text in a note block, for example:\nNote over A : Item 1\nNote over A\n - Item 1\n - Item 2\nend note",
55697
+ length: len
55698
+ };
55699
+ }
55611
55700
  if ((err.name === "NoViableAltException" || err.name === "NotAllInputParsedException") && tokType === "ElseKeyword") {
55612
55701
  return { line, column, severity: "error", code: "SE-ELSE-OUTSIDE-ALT", message: "'else' is only allowed inside 'alt' blocks.", hint: "Use: alt Condition \u2026 else \u2026 end", length: len };
55613
55702
  }
@@ -55809,6 +55898,30 @@ function validateFlowchart(text, options = {}) {
55809
55898
  return errs;
55810
55899
  },
55811
55900
  postParse: (text2, tokens, _cst, prevErrors) => {
55901
+ {
55902
+ const tks = tokens;
55903
+ const firstByLine = /* @__PURE__ */ new Map();
55904
+ for (const tk of tks) {
55905
+ const ln = tk.startLine ?? 1;
55906
+ const col = tk.startColumn ?? 1;
55907
+ const prev = firstByLine.get(ln);
55908
+ if (!prev || (prev.startColumn ?? Infinity) > col)
55909
+ firstByLine.set(ln, tk);
55910
+ }
55911
+ for (const tk of tks) {
55912
+ if (tk.image === "title" && firstByLine.get(tk.startLine ?? 1) === tk) {
55913
+ prevErrors.push({
55914
+ line: tk.startLine ?? 1,
55915
+ column: tk.startColumn ?? 1,
55916
+ severity: "error",
55917
+ code: "FL-META-UNSUPPORTED",
55918
+ message: "'title' is not supported in flowcharts by the current Mermaid CLI.",
55919
+ hint: 'Use a Markdown heading above the code block, or draw a labeled node at the top (e.g., T["Dependency Relationship"]).',
55920
+ length: tk.image?.length ?? 5
55921
+ });
55922
+ }
55923
+ }
55924
+ }
55812
55925
  const escWarn = detectEscapedQuotes(tokens, {
55813
55926
  code: "FL-LABEL-ESCAPED-QUOTE",
55814
55927
  message: 'Escaped quotes (\\") in node labels are accepted by Mermaid, but using &quot; is preferred for portability.',
@@ -58227,6 +58340,13 @@ function computeFixes(text, errors, level = "safe") {
58227
58340
  const replaced = inner.split('\\"').join("&quot;");
58228
58341
  edits.push({ start: { line: e3.line, column: q1 + 2 }, end: { line: e3.line, column: q22 + 1 }, newText: replaced });
58229
58342
  continue;
58343
+ if (is("FL-META-UNSUPPORTED", e3)) {
58344
+ if (level === "all") {
58345
+ const lineText2 = lineTextAt(text, e3.line);
58346
+ edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line + 1, column: 1 }, newText: "" });
58347
+ }
58348
+ continue;
58349
+ }
58230
58350
  }
58231
58351
  }
58232
58352
  }
@@ -58234,6 +58354,12 @@ function computeFixes(text, errors, level = "safe") {
58234
58354
  edits.push(replaceRange(text, at(e3), e3.length ?? 2, "&quot;"));
58235
58355
  continue;
58236
58356
  }
58357
+ if (is("FL-META-UNSUPPORTED", e3)) {
58358
+ if (level === "all") {
58359
+ edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line + 1, column: 1 }, newText: "" });
58360
+ }
58361
+ continue;
58362
+ }
58237
58363
  if (is("FL-LABEL-BACKTICK", e3)) {
58238
58364
  edits.push(replaceRange(text, at(e3), e3.length ?? 1, ""));
58239
58365
  continue;
@@ -58283,6 +58409,12 @@ function computeFixes(text, errors, level = "safe") {
58283
58409
  edits.push(replaceRange(text, at(e3), e3.length ?? 1, rep));
58284
58410
  continue;
58285
58411
  }
58412
+ if (is("FL-END-WITHOUT-SUBGRAPH", e3)) {
58413
+ if (level === "all") {
58414
+ edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line + 1, column: 1 }, newText: "" });
58415
+ }
58416
+ continue;
58417
+ }
58286
58418
  if (is("FL-LABEL-DOUBLE-IN-DOUBLE", e3)) {
58287
58419
  const lineText = lineTextAt(text, e3.line);
58288
58420
  const caret0 = Math.max(0, e3.column - 1);
@@ -58619,6 +58751,9 @@ function computeFixes(text, errors, level = "safe") {
58619
58751
  continue;
58620
58752
  }
58621
58753
  if (is("FL-QUOTE-UNCLOSED", e3)) {
58754
+ if (patchedLines.has(e3.line)) {
58755
+ continue;
58756
+ }
58622
58757
  if (level === "all") {
58623
58758
  const lineText = lineTextAt(text, e3.line);
58624
58759
  const caret0 = Math.max(0, e3.column - 1);
@@ -58693,7 +58828,7 @@ function computeFixes(text, errors, level = "safe") {
58693
58828
  newInner = ltrim + left + replacedMid + right + rtrim;
58694
58829
  } else {
58695
58830
  const replaced = inner.split("&quot;").join("\0").split('"').join("&quot;").split("\0").join("&quot;");
58696
- newInner = '"' + replaced + '"';
58831
+ newInner = replaced;
58697
58832
  }
58698
58833
  edits.push({ start: { line: e3.line, column: contentStart + 1 }, end: { line: e3.line, column: closeIdx + 1 }, newText: newInner });
58699
58834
  patchedLines.add(e3.line);
@@ -73242,7 +73377,7 @@ var init_ProbeAgent = __esm({
73242
73377
  MAX_HISTORY_MESSAGES = 100;
73243
73378
  SUPPORTED_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "gif", "bmp", "svg"];
73244
73379
  MAX_IMAGE_FILE_SIZE = 20 * 1024 * 1024;
73245
- ProbeAgent = class {
73380
+ ProbeAgent = class _ProbeAgent {
73246
73381
  /**
73247
73382
  * Create a new ProbeAgent instance
73248
73383
  * @param {Object} options - Configuration options
@@ -74124,12 +74259,24 @@ You are working with a repository located at: ${searchDirectory}
74124
74259
  }))
74125
74260
  ];
74126
74261
  }
74127
- let currentMessages = [
74128
- { role: "system", content: systemMessage },
74129
- ...this.history,
74130
- // Include previous conversation history
74131
- userMessage
74132
- ];
74262
+ const hasSystemMessage = this.history.length > 0 && this.history[0].role === "system";
74263
+ let currentMessages;
74264
+ if (hasSystemMessage) {
74265
+ currentMessages = [
74266
+ ...this.history,
74267
+ userMessage
74268
+ ];
74269
+ if (this.debug) {
74270
+ console.log("[DEBUG] Reusing existing system message from history for cache efficiency");
74271
+ }
74272
+ } else {
74273
+ currentMessages = [
74274
+ { role: "system", content: systemMessage },
74275
+ ...this.history,
74276
+ // Include previous conversation history
74277
+ userMessage
74278
+ ];
74279
+ }
74133
74280
  let currentIteration = 0;
74134
74281
  let completionAttempted = false;
74135
74282
  let finalResult = "I was unable to complete your request due to reaching the maximum number of tool iterations.";
@@ -74924,6 +75071,116 @@ Convert your previous response content into actual JSON data that follows this s
74924
75071
  console.log(`[DEBUG] Cleared conversation history and reset counters for session ${this.sessionId}`);
74925
75072
  }
74926
75073
  }
75074
+ /**
75075
+ * Clone this agent's session to create a new agent with shared conversation history
75076
+ * @param {Object} options - Clone options
75077
+ * @param {string} [options.sessionId] - Session ID for the cloned agent (defaults to new UUID)
75078
+ * @param {boolean} [options.stripInternalMessages=true] - Remove internal messages (schema reminders, mermaid fixes, etc.)
75079
+ * @param {boolean} [options.keepSystemMessage=true] - Keep the system message in cloned history
75080
+ * @param {boolean} [options.deepCopy=true] - Deep copy messages to prevent mutations
75081
+ * @param {Object} [options.overrides] - Override any ProbeAgent constructor options
75082
+ * @returns {ProbeAgent} New agent instance with cloned history
75083
+ */
75084
+ clone(options = {}) {
75085
+ const {
75086
+ sessionId = (0, import_crypto5.randomUUID)(),
75087
+ stripInternalMessages = true,
75088
+ keepSystemMessage = true,
75089
+ deepCopy = true,
75090
+ overrides = {}
75091
+ } = options;
75092
+ let clonedHistory = deepCopy ? JSON.parse(JSON.stringify(this.history)) : [...this.history];
75093
+ if (stripInternalMessages) {
75094
+ clonedHistory = this._stripInternalMessages(clonedHistory, keepSystemMessage);
75095
+ }
75096
+ const clonedAgent = new _ProbeAgent({
75097
+ // Copy current agent's config
75098
+ customPrompt: this.customPrompt,
75099
+ promptType: this.promptType,
75100
+ allowEdit: this.allowEdit,
75101
+ path: this.allowedFolders[0],
75102
+ // Use first allowed folder as primary path
75103
+ allowedFolders: [...this.allowedFolders],
75104
+ provider: this.clientApiProvider,
75105
+ model: this.modelName,
75106
+ debug: this.debug,
75107
+ outline: this.outline,
75108
+ maxResponseTokens: this.maxResponseTokens,
75109
+ maxIterations: this.maxIterations,
75110
+ disableMermaidValidation: this.disableMermaidValidation,
75111
+ enableMcp: !!this.mcpBridge,
75112
+ mcpConfig: this.mcpConfig,
75113
+ enableBash: this.enableBash,
75114
+ bashConfig: this.bashConfig,
75115
+ storageAdapter: this.storageAdapter,
75116
+ // Override with any provided options
75117
+ sessionId,
75118
+ ...overrides
75119
+ });
75120
+ clonedAgent.history = clonedHistory;
75121
+ if (this.debug) {
75122
+ console.log(`[DEBUG] Cloned session ${this.sessionId} -> ${sessionId}`);
75123
+ console.log(`[DEBUG] Cloned ${clonedHistory.length} messages (stripInternal: ${stripInternalMessages})`);
75124
+ }
75125
+ return clonedAgent;
75126
+ }
75127
+ /**
75128
+ * Internal method to strip internal/temporary messages from history
75129
+ * Removes: schema reminders, mermaid fix prompts, tool use reminders, etc.
75130
+ * Keeps: system message, user messages, assistant responses, tool results
75131
+ * @private
75132
+ */
75133
+ _stripInternalMessages(history, keepSystemMessage = true) {
75134
+ const filtered = [];
75135
+ for (let i3 = 0; i3 < history.length; i3++) {
75136
+ const message = history[i3];
75137
+ if (message.role === "system") {
75138
+ if (keepSystemMessage) {
75139
+ filtered.push(message);
75140
+ } else if (this.debug) {
75141
+ console.log(`[DEBUG] Removing system message at index ${i3}`);
75142
+ }
75143
+ continue;
75144
+ }
75145
+ if (this._isInternalMessage(message, i3, history)) {
75146
+ if (this.debug) {
75147
+ console.log(`[DEBUG] Stripping internal message at index ${i3}: ${message.role}`);
75148
+ }
75149
+ continue;
75150
+ }
75151
+ filtered.push(message);
75152
+ }
75153
+ return filtered;
75154
+ }
75155
+ /**
75156
+ * Determine if a message is an internal/temporary message
75157
+ * @private
75158
+ */
75159
+ _isInternalMessage(message, index, history) {
75160
+ if (message.role !== "user") {
75161
+ return false;
75162
+ }
75163
+ if (!message.content) {
75164
+ return false;
75165
+ }
75166
+ const content = typeof message.content === "string" ? message.content : JSON.stringify(message.content);
75167
+ if (content.includes("IMPORTANT: A schema was provided") || content.includes("You MUST respond with data that matches this schema") || content.includes("Your response must conform to this schema:")) {
75168
+ return true;
75169
+ }
75170
+ if (content.includes("Please use one of the available tools") && content.includes("or use attempt_completion") && content.includes("Remember: Use proper XML format")) {
75171
+ return true;
75172
+ }
75173
+ if (content.includes("The mermaid diagram in your response has syntax errors") || content.includes("Please fix the mermaid syntax errors") || content.includes("Here is the corrected version:")) {
75174
+ return true;
75175
+ }
75176
+ if (content.includes("Your response does not match the expected JSON schema") || content.includes("Please provide a valid JSON response") || content.includes("Schema validation error:")) {
75177
+ return true;
75178
+ }
75179
+ if (content.includes("When using <attempt_complete>") && content.includes("this must be the ONLY content in your response")) {
75180
+ return true;
75181
+ }
75182
+ return false;
75183
+ }
74927
75184
  /**
74928
75185
  * Clean up resources (including MCP connections)
74929
75186
  */