pi-advisor-flow 0.15.2-dev.1 → 0.15.2-dev.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.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,10 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
11
11
  - Bundled the `pi-advisor-flow` Pi skill and added the `advisor_config` tool so agents can inspect and update settings after confirmation.
12
12
  - Localized the human-facing interface via the optional `@juicesharp/rpiv-i18n` peer dependency: settings, dialogs, submenus, notifications, and transcript renderers resolve through `t()` with complete `de` and `fr` locale files; every other locale falls back to English. Model-facing strings (tool descriptions, prompts, tool-result envelopes) intentionally remain English. A key-consistency test guards locale drift and an integration test verifies live locale switching.
13
13
 
14
+ ### Fixed
15
+
16
+ - Prevented catastrophic backtracking in quoted credential redaction, fail closed on ambiguous assignments and private-key blocks, and omit oversized redaction inputs rather than scanning or truncating them.
17
+
14
18
  ## 0.15.1 - 2026-11-14
15
19
 
16
20
  ### Fixed
package/README.md CHANGED
@@ -172,7 +172,7 @@ Contributing or improving a locale: mirror the exact keys from [`locales/en.json
172
172
 
173
173
  ## Privacy
174
174
 
175
- Advisor requests can include user messages, tool calls, tool results, targeted questions, trusted project and global `AGENTS.md` rules, and repository information. `advisorAgentsMdContext` is on by default and can be disabled in `/advisor-settings`; rules are sent as origin-labelled, capped, redacted, untrusted review guidance only. Untrusted projects withhold both rule files and tell the Advisor that rules were withheld. Repository context is configurable from no access through changed-file summaries to a capped patch; when it is disabled, the Advisor is told so rather than shown an apparently clean tree. Images from disclosed conversation and full-policy tool results can be sent as pixels only to image-capable Advisor models; Scout sees markers, not pixels. Exact tracked and untracked image files can be attached using `includeTrackedFiles` and `includeUntracked` under their existing separate global consent rules. Images are limited to four and 8 MiB total, with a 4 MiB per-image cap; unsupported, missing, or oversized images are reported as withheld, not reviewed. Explicit tracked and untracked file contents require separate global opt-ins and are sent as untrusted data. Secret redaction is off by default; when enabled, credential-shaped values in targeted questions are redacted before the provider request. Tools without an explicit policy use full context. Settings are global, so a project cannot silently change them.
175
+ Advisor requests can include user messages, tool calls, tool results, targeted questions, trusted project and global `AGENTS.md` rules, and repository information. `advisorAgentsMdContext` is on by default and can be disabled in `/advisor-settings`; rules are sent as origin-labelled, capped, redacted, untrusted review guidance only. Untrusted projects withhold both rule files and tell the Advisor that rules were withheld. Repository context is configurable from no access through changed-file summaries to a capped patch; when it is disabled, the Advisor is told so rather than shown an apparently clean tree. Images from disclosed conversation and full-policy tool results can be sent as pixels only to image-capable Advisor models; Scout sees markers, not pixels. Exact tracked and untracked image files can be attached using `includeTrackedFiles` and `includeUntracked` under their existing separate global consent rules. Images are limited to four and 8 MiB total, with a 4 MiB per-image cap; unsupported, missing, or oversized images are reported as withheld, not reviewed. Explicit tracked and untracked file contents require separate global opt-ins and are sent as untrusted data. Secret redaction is off by default; when enabled, credential-shaped values in targeted questions are redacted before the provider request. Individual text inputs over 65,536 UTF-16 code units are omitted rather than scanned or truncated, and ambiguous secret blocks can cause additional text to be omitted. Tools without an explicit policy use full context. Settings are global, so a project cannot silently change them.
176
176
 
177
177
  When Scout is enabled, the Executor model provider also receives bounded Advisor-eligible conversation history. Pi's `buildContextEntries()` projection is used when available. OMP-compatible session managers without that API are supported through the active branch, with the latest reset boundary and compaction's retained range applied before history or images are disclosed; cleared and compacted-out entries are not forwarded. Read [Privacy and data handling](https://github.com/philipbrembeck/pi-advisor/blob/main/docs/privacy.md) before using pi-advisor with sensitive work.
178
178
 
package/dist/index.js CHANGED
@@ -1776,29 +1776,62 @@ import net from "node:net";
1776
1776
 
1777
1777
  // src/redaction.ts
1778
1778
  var REDACTION_MARKER = "[REDACTED SECRET]";
1779
- var PEM_BEGIN_PATTERN = /-----BEGIN(?: [A-Z0-9]+)? PRIVATE KEY-----/giu;
1780
- var PEM_END_PATTERN = /-----END(?: [A-Z0-9]+)? PRIVATE KEY-----/iu;
1779
+ var MAX_REDACTION_CHARS = 65536;
1780
+ var OVERSIZED_MARKER = "[Redaction omitted: input exceeds 65536 characters]";
1781
+ var PEM_MARKER_PATTERN = /-----(?<action>BEGIN|END)(?: (?<type>[A-Z0-9]+))? PRIVATE KEY-----/giu;
1781
1782
  var CREDENTIAL_NAME = String.raw`(?:api[_-]?key|token|secret|password|passwd)`;
1782
- var SECRET_ASSIGNMENT_PATTERN = new RegExp(String.raw`(?:(?:"(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}"|'(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}')|(?:\b|_)${CREDENTIAL_NAME})[ \t]*[:=][ \t]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|"(?:\\.|[^"\r\n])*(?=\r?\n|$)|'(?:\\.|[^'\r\n])*(?=\r?\n|$)|[^\s"'&,;)}\]]+)`, "giu");
1783
+ var ASSIGNMENT_START = String.raw`(?:(?:"(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}"|'(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}')|(?:\b|_)${CREDENTIAL_NAME})[ \t]*[:=][ \t]*`;
1784
+ var SECRET_ASSIGNMENT_PATTERN = new RegExp(String.raw`${ASSIGNMENT_START}(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|"(?:\\[^\r\n]|[^"\\\r\n]|\\(?=\r?\n|\r|$))*(?=\r?\n|\r|$)|'(?:\\[^\r\n]|[^'\\\r\n]|\\(?=\r?\n|\r|$))*(?=\r?\n|\r|$)|[^\s"'&,;)}\]]+)`, "giu");
1785
+ var ASSIGNMENT_START_PATTERN = new RegExp(ASSIGNMENT_START, "giu");
1786
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/giu;
1783
1787
  var SECRET_PATTERNS = [
1784
- /-----BEGIN(?: [A-Z0-9]+)? PRIVATE KEY-----[\s\S]*?-----END(?: [A-Z0-9]+)? PRIVATE KEY-----/giu,
1785
- /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/giu,
1786
- SECRET_ASSIGNMENT_PATTERN,
1787
- /(?<scheme>[a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu,
1788
+ /(?<scheme>(?<![a-z0-9+.-])[a-z0-9+.-]+:\/\/)[^\s/@:]+:[^\s/@]+@/giu,
1788
1789
  /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/gu,
1789
1790
  /\b(?:aws_secret_access_key|aws_session_token)\s*[:=]\s*[^\s"'&,;)}\]]+/giu
1790
1791
  ];
1791
- var redactUnterminatedPem = (value) => {
1792
- const begins = [...value.matchAll(PEM_BEGIN_PATTERN)];
1793
- const lastBegin = begins.at(-1);
1794
- if (lastBegin?.index === undefined) {
1795
- return value;
1792
+ var redactPem = (value) => {
1793
+ const parts = [];
1794
+ const stack = [];
1795
+ let copied = 0;
1796
+ for (const match of value.matchAll(PEM_MARKER_PATTERN)) {
1797
+ const type = (match.groups?.type ?? "").toUpperCase();
1798
+ if (match.groups?.action.toUpperCase() === "BEGIN") {
1799
+ if (stack.length === 0) {
1800
+ parts.push(value.slice(copied, match.index));
1801
+ }
1802
+ stack.push(type);
1803
+ } else if (stack.length > 0) {
1804
+ if (stack.pop() !== type) {
1805
+ return `${parts.join("")}${REDACTION_MARKER}`;
1806
+ }
1807
+ if (stack.length === 0) {
1808
+ parts.push(REDACTION_MARKER);
1809
+ copied = match.index + match[0].length;
1810
+ }
1811
+ }
1796
1812
  }
1797
- const hasEnd = PEM_END_PATTERN.test(value.slice(lastBegin.index + lastBegin[0].length));
1798
- return hasEnd ? value : `${value.slice(0, lastBegin.index)}${REDACTION_MARKER}`;
1813
+ return stack.length > 0 ? `${parts.join("")}${REDACTION_MARKER}` : `${parts.join("")}${value.slice(copied)}`;
1814
+ };
1815
+ var redactAssignments = (value) => {
1816
+ const parts = [];
1817
+ let copied = 0;
1818
+ for (const match of value.matchAll(SECRET_ASSIGNMENT_PATTERN)) {
1819
+ parts.push(value.slice(copied, match.index), REDACTION_MARKER);
1820
+ const starts = match[0].matchAll(ASSIGNMENT_START_PATTERN);
1821
+ starts.next();
1822
+ if (!starts.next().done) {
1823
+ return parts.join("");
1824
+ }
1825
+ copied = match.index + match[0].length;
1826
+ }
1827
+ return `${parts.join("")}${value.slice(copied)}`;
1799
1828
  };
1800
1829
  var redactSecrets = (value) => {
1801
- let redacted = redactUnterminatedPem(value);
1830
+ if (value.length > MAX_REDACTION_CHARS) {
1831
+ return OVERSIZED_MARKER;
1832
+ }
1833
+ let redacted = redactPem(value).replaceAll(BEARER_PATTERN, REDACTION_MARKER);
1834
+ redacted = redactAssignments(redacted);
1802
1835
  for (const pattern of SECRET_PATTERNS) {
1803
1836
  redacted = redacted.replace(pattern, (_match, scheme) => isString(scheme) ? `${scheme}${REDACTION_MARKER}@` : REDACTION_MARKER);
1804
1837
  }
package/docs/privacy.md CHANGED
@@ -30,7 +30,7 @@ The `advisor_config` tool reads recognized effective settings and persisted glob
30
30
 
31
31
  ## Secret redaction and tool policies
32
32
 
33
- - `advisorRedactSecrets` defaults to `false`. When enabled, pi-advisor locally redacts common credential patterns before including context or targeted questions in an Advisor request. The raw targeted question remains available to local UI displays but is not sent to the provider.
33
+ - `advisorRedactSecrets` defaults to `false`. When enabled, pi-advisor locally redacts common credential patterns before including context or targeted questions in an Advisor request. Individual text inputs over 65,536 UTF-16 code units are omitted entirely before scanning; ambiguous credential or private-key blocks may also cause surrounding text to be omitted. The raw targeted question remains available to local UI displays but is not sent to the provider.
34
34
  - `advisorToolPolicies` matches an **exact tool name**. Each tool may use `full`, `summary`, or `exclude`:
35
35
  - `full` includes call arguments and capped result output.
36
36
  - `summary` omits call arguments and result output but includes result status and size metadata.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-advisor-flow",
3
- "version": "0.15.2-dev.1",
3
+ "version": "0.15.2-dev.2",
4
4
  "description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
5
5
  "keywords": [
6
6
  "advisor",
package/src/redaction.ts CHANGED
@@ -1,44 +1,89 @@
1
1
  import { capUtf8Bytes, isString } from "./content-utils.ts";
2
2
 
3
3
  const REDACTION_MARKER = "[REDACTED SECRET]";
4
- const PEM_BEGIN_PATTERN = /-----BEGIN(?: [A-Z0-9]+)? PRIVATE KEY-----/giu;
5
- const PEM_END_PATTERN = /-----END(?: [A-Z0-9]+)? PRIVATE KEY-----/iu;
4
+ const MAX_REDACTION_CHARS = 65_536;
5
+ const OVERSIZED_MARKER = "[Redaction omitted: input exceeds 65536 characters]";
6
+
7
+ const PEM_MARKER_PATTERN =
8
+ /-----(?<action>BEGIN|END)(?: (?<type>[A-Z0-9]+))? PRIVATE KEY-----/giu;
9
+
6
10
  const CREDENTIAL_NAME = String.raw`(?:api[_-]?key|token|secret|password|passwd)`;
11
+ const ASSIGNMENT_START = String.raw`(?:(?:"(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}"|'(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}')|(?:\b|_)${CREDENTIAL_NAME})[ \t]*[:=][ \t]*`;
7
12
 
8
13
  const SECRET_ASSIGNMENT_PATTERN = new RegExp(
9
- String.raw`(?:(?:"(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}"|'(?:[a-z0-9]+[_-])*?${CREDENTIAL_NAME}')|(?:\b|_)${CREDENTIAL_NAME})[ \t]*[:=][ \t]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|"(?:\\.|[^"\r\n])*(?=\r?\n|$)|'(?:\\.|[^'\r\n])*(?=\r?\n|$)|[^\s"'&,;)}\]]+)`,
14
+ String.raw`${ASSIGNMENT_START}(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|"(?:\\[^\r\n]|[^"\\\r\n]|\\(?=\r?\n|\r|$))*(?=\r?\n|\r|$)|'(?:\\[^\r\n]|[^'\\\r\n]|\\(?=\r?\n|\r|$))*(?=\r?\n|\r|$)|[^\s"'&,;)}\]]+)`,
10
15
  "giu"
11
16
  );
12
17
 
18
+ const ASSIGNMENT_START_PATTERN = new RegExp(ASSIGNMENT_START, "giu");
19
+
20
+ const BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/giu;
21
+
13
22
  const SECRET_PATTERNS = [
14
- /-----BEGIN(?: [A-Z0-9]+)? PRIVATE KEY-----[\s\S]*?-----END(?: [A-Z0-9]+)? PRIVATE KEY-----/giu,
15
- /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/giu,
16
- SECRET_ASSIGNMENT_PATTERN,
17
- /(?<scheme>[a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu,
23
+ /(?<scheme>(?<![a-z0-9+.-])[a-z0-9+.-]+:\/\/)[^\s/@:]+:[^\s/@]+@/giu,
18
24
  /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/gu,
19
25
  /\b(?:aws_secret_access_key|aws_session_token)\s*[:=]\s*[^\s"'&,;)}\]]+/giu,
20
26
  ] as const;
21
27
 
22
- const redactUnterminatedPem = (value: string): string => {
23
- const begins = [...value.matchAll(PEM_BEGIN_PATTERN)];
24
- const lastBegin = begins.at(-1);
28
+ const redactPem = (value: string): string => {
29
+ const parts: string[] = [];
30
+ const stack: string[] = [];
31
+ let copied = 0;
25
32
 
26
- if (lastBegin?.index === undefined) {
27
- return value;
33
+ for (const match of value.matchAll(PEM_MARKER_PATTERN)) {
34
+ const type = (match.groups?.type ?? "").toUpperCase();
35
+
36
+ if (match.groups?.action.toUpperCase() === "BEGIN") {
37
+ if (stack.length === 0) {
38
+ parts.push(value.slice(copied, match.index));
39
+ }
40
+
41
+ stack.push(type);
42
+ } else if (stack.length > 0) {
43
+ if (stack.pop() !== type) {
44
+ return `${parts.join("")}${REDACTION_MARKER}`;
45
+ }
46
+
47
+ if (stack.length === 0) {
48
+ parts.push(REDACTION_MARKER);
49
+ copied = match.index + match[0].length;
50
+ }
51
+ }
28
52
  }
29
53
 
30
- const hasEnd = PEM_END_PATTERN.test(
31
- value.slice(lastBegin.index + lastBegin[0].length)
32
- );
54
+ return stack.length > 0
55
+ ? `${parts.join("")}${REDACTION_MARKER}`
56
+ : `${parts.join("")}${value.slice(copied)}`;
57
+ };
58
+
59
+ const redactAssignments = (value: string): string => {
60
+ const parts: string[] = [];
61
+ let copied = 0;
62
+
63
+ for (const match of value.matchAll(SECRET_ASSIGNMENT_PATTERN)) {
64
+ parts.push(value.slice(copied, match.index), REDACTION_MARKER);
65
+
66
+ const starts = match[0].matchAll(ASSIGNMENT_START_PATTERN);
67
+ starts.next();
68
+
69
+ if (!starts.next().done) {
70
+ return parts.join("");
71
+ }
33
72
 
34
- return hasEnd
35
- ? value
36
- : `${value.slice(0, lastBegin.index)}${REDACTION_MARKER}`;
73
+ copied = match.index + match[0].length;
74
+ }
75
+
76
+ return `${parts.join("")}${value.slice(copied)}`;
37
77
  };
38
78
 
39
79
  /** Redacts common credential forms locally; it is not a data-classification system. */
40
80
  export const redactSecrets = (value: string): string => {
41
- let redacted = redactUnterminatedPem(value);
81
+ if (value.length > MAX_REDACTION_CHARS) {
82
+ return OVERSIZED_MARKER;
83
+ }
84
+
85
+ let redacted = redactPem(value).replaceAll(BEARER_PATTERN, REDACTION_MARKER);
86
+ redacted = redactAssignments(redacted);
42
87
 
43
88
  for (const pattern of SECRET_PATTERNS) {
44
89
  redacted = redacted.replace(pattern, (_match, scheme) =>