@caupulican/pi-adaptative 0.80.61 → 0.80.62

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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * EffectivenessTracker — the closed adaptive loop (adaptive-agent design R4, leapfrog #9).
3
+ *
4
+ * Recall (R3) injects a `<memory_context>` page; this tracks whether the agent actually USED it, so the
5
+ * recall gate can adapt — recall more when it's paying off, back off when it isn't. "Used" = the
6
+ * fraction of the recall page's DISTINCTIVE tokens (those not already in the user's query) that reappear
7
+ * in the assistant's response. We isolate distinctive tokens so we measure recall's own contribution,
8
+ * not the baseline overlap every response shares with the query.
9
+ *
10
+ * The score is an exponential moving average ("useful lately") in [0,1], starting at a neutral prior so
11
+ * recall is given a fair chance before the loop adapts.
12
+ */
13
+ export declare class EffectivenessTracker {
14
+ private ema;
15
+ private samples;
16
+ /**
17
+ * Record the outcome of a turn that received a recall page: how much of the recall's distinctive
18
+ * content the assistant's response actually drew on.
19
+ */
20
+ recordRecallOutcome(recallText: string, queryText: string, responseText: string): void;
21
+ /** Rolling "useful lately" score in [0,1]. Neutral until enough samples accumulate. */
22
+ usefulLately(): number;
23
+ /** Number of recorded recall outcomes. */
24
+ get sampleCount(): number;
25
+ }
26
+ /**
27
+ * Fraction of the recall page's distinctive tokens (present in recall but NOT in the query) that appear
28
+ * in the response. 0 when recall added nothing the query didn't already carry.
29
+ */
30
+ export declare function distinctiveRecallUsage(recallText: string, queryText: string, responseText: string): number;
31
+ //# sourceMappingURL=effectiveness-tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectiveness-tracker.d.ts","sourceRoot":"","sources":["../../../src/core/memory/effectiveness-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,OAAO,CAAK;IAEpB;;;OAGG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAIrF;IAED,uFAAuF;IACvF,YAAY,IAAI,MAAM,CAErB;IAED,0CAA0C;IAC1C,IAAI,WAAW,IAAI,MAAM,CAExB;CACD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAU1G","sourcesContent":["/**\n * EffectivenessTracker — the closed adaptive loop (adaptive-agent design R4, leapfrog #9).\n *\n * Recall (R3) injects a `<memory_context>` page; this tracks whether the agent actually USED it, so the\n * recall gate can adapt — recall more when it's paying off, back off when it isn't. \"Used\" = the\n * fraction of the recall page's DISTINCTIVE tokens (those not already in the user's query) that reappear\n * in the assistant's response. We isolate distinctive tokens so we measure recall's own contribution,\n * not the baseline overlap every response shares with the query.\n *\n * The score is an exponential moving average (\"useful lately\") in [0,1], starting at a neutral prior so\n * recall is given a fair chance before the loop adapts.\n */\n\nimport { tokenize } from \"../tools/skill-audit.ts\";\n\nconst NEUTRAL_PRIOR = 0.5;\nconst ALPHA = 0.3; // EMA weight on the newest outcome\n\nexport class EffectivenessTracker {\n\tprivate ema = NEUTRAL_PRIOR;\n\tprivate samples = 0;\n\n\t/**\n\t * Record the outcome of a turn that received a recall page: how much of the recall's distinctive\n\t * content the assistant's response actually drew on.\n\t */\n\trecordRecallOutcome(recallText: string, queryText: string, responseText: string): void {\n\t\tconst used = distinctiveRecallUsage(recallText, queryText, responseText);\n\t\tthis.ema = ALPHA * used + (1 - ALPHA) * this.ema;\n\t\tthis.samples += 1;\n\t}\n\n\t/** Rolling \"useful lately\" score in [0,1]. Neutral until enough samples accumulate. */\n\tusefulLately(): number {\n\t\treturn this.ema;\n\t}\n\n\t/** Number of recorded recall outcomes. */\n\tget sampleCount(): number {\n\t\treturn this.samples;\n\t}\n}\n\n/**\n * Fraction of the recall page's distinctive tokens (present in recall but NOT in the query) that appear\n * in the response. 0 when recall added nothing the query didn't already carry.\n */\nexport function distinctiveRecallUsage(recallText: string, queryText: string, responseText: string): number {\n\tconst queryTokens = new Set(tokenize(queryText));\n\tconst distinctive = tokenize(recallText).filter((t) => !queryTokens.has(t));\n\tif (distinctive.length === 0) return 0;\n\tconst responseTokens = new Set(tokenize(responseText));\n\tlet hits = 0;\n\tfor (const token of distinctive) {\n\t\tif (responseTokens.has(token)) hits++;\n\t}\n\treturn hits / distinctive.length;\n}\n"]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * EffectivenessTracker — the closed adaptive loop (adaptive-agent design R4, leapfrog #9).
3
+ *
4
+ * Recall (R3) injects a `<memory_context>` page; this tracks whether the agent actually USED it, so the
5
+ * recall gate can adapt — recall more when it's paying off, back off when it isn't. "Used" = the
6
+ * fraction of the recall page's DISTINCTIVE tokens (those not already in the user's query) that reappear
7
+ * in the assistant's response. We isolate distinctive tokens so we measure recall's own contribution,
8
+ * not the baseline overlap every response shares with the query.
9
+ *
10
+ * The score is an exponential moving average ("useful lately") in [0,1], starting at a neutral prior so
11
+ * recall is given a fair chance before the loop adapts.
12
+ */
13
+ import { tokenize } from "../tools/skill-audit.js";
14
+ const NEUTRAL_PRIOR = 0.5;
15
+ const ALPHA = 0.3; // EMA weight on the newest outcome
16
+ export class EffectivenessTracker {
17
+ ema = NEUTRAL_PRIOR;
18
+ samples = 0;
19
+ /**
20
+ * Record the outcome of a turn that received a recall page: how much of the recall's distinctive
21
+ * content the assistant's response actually drew on.
22
+ */
23
+ recordRecallOutcome(recallText, queryText, responseText) {
24
+ const used = distinctiveRecallUsage(recallText, queryText, responseText);
25
+ this.ema = ALPHA * used + (1 - ALPHA) * this.ema;
26
+ this.samples += 1;
27
+ }
28
+ /** Rolling "useful lately" score in [0,1]. Neutral until enough samples accumulate. */
29
+ usefulLately() {
30
+ return this.ema;
31
+ }
32
+ /** Number of recorded recall outcomes. */
33
+ get sampleCount() {
34
+ return this.samples;
35
+ }
36
+ }
37
+ /**
38
+ * Fraction of the recall page's distinctive tokens (present in recall but NOT in the query) that appear
39
+ * in the response. 0 when recall added nothing the query didn't already carry.
40
+ */
41
+ export function distinctiveRecallUsage(recallText, queryText, responseText) {
42
+ const queryTokens = new Set(tokenize(queryText));
43
+ const distinctive = tokenize(recallText).filter((t) => !queryTokens.has(t));
44
+ if (distinctive.length === 0)
45
+ return 0;
46
+ const responseTokens = new Set(tokenize(responseText));
47
+ let hits = 0;
48
+ for (const token of distinctive) {
49
+ if (responseTokens.has(token))
50
+ hits++;
51
+ }
52
+ return hits / distinctive.length;
53
+ }
54
+ //# sourceMappingURL=effectiveness-tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectiveness-tracker.js","sourceRoot":"","sources":["../../../src/core/memory/effectiveness-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,mCAAmC;AAEtD,MAAM,OAAO,oBAAoB;IACxB,GAAG,GAAG,aAAa,CAAC;IACpB,OAAO,GAAG,CAAC,CAAC;IAEpB;;;OAGG;IACH,mBAAmB,CAAC,UAAkB,EAAE,SAAiB,EAAE,YAAoB,EAAQ;QACtF,MAAM,IAAI,GAAG,sBAAsB,CAAC,UAAU,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACzE,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;QACjD,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;IAAA,CAClB;IAED,uFAAuF;IACvF,YAAY,GAAW;QACtB,OAAO,IAAI,CAAC,GAAG,CAAC;IAAA,CAChB;IAED,0CAA0C;IAC1C,IAAI,WAAW,GAAW;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC;IAAA,CACpB;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB,EAAE,SAAiB,EAAE,YAAoB,EAAU;IAC3G,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACvC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QACjC,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,IAAI,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC;AAAA,CACjC","sourcesContent":["/**\n * EffectivenessTracker — the closed adaptive loop (adaptive-agent design R4, leapfrog #9).\n *\n * Recall (R3) injects a `<memory_context>` page; this tracks whether the agent actually USED it, so the\n * recall gate can adapt — recall more when it's paying off, back off when it isn't. \"Used\" = the\n * fraction of the recall page's DISTINCTIVE tokens (those not already in the user's query) that reappear\n * in the assistant's response. We isolate distinctive tokens so we measure recall's own contribution,\n * not the baseline overlap every response shares with the query.\n *\n * The score is an exponential moving average (\"useful lately\") in [0,1], starting at a neutral prior so\n * recall is given a fair chance before the loop adapts.\n */\n\nimport { tokenize } from \"../tools/skill-audit.ts\";\n\nconst NEUTRAL_PRIOR = 0.5;\nconst ALPHA = 0.3; // EMA weight on the newest outcome\n\nexport class EffectivenessTracker {\n\tprivate ema = NEUTRAL_PRIOR;\n\tprivate samples = 0;\n\n\t/**\n\t * Record the outcome of a turn that received a recall page: how much of the recall's distinctive\n\t * content the assistant's response actually drew on.\n\t */\n\trecordRecallOutcome(recallText: string, queryText: string, responseText: string): void {\n\t\tconst used = distinctiveRecallUsage(recallText, queryText, responseText);\n\t\tthis.ema = ALPHA * used + (1 - ALPHA) * this.ema;\n\t\tthis.samples += 1;\n\t}\n\n\t/** Rolling \"useful lately\" score in [0,1]. Neutral until enough samples accumulate. */\n\tusefulLately(): number {\n\t\treturn this.ema;\n\t}\n\n\t/** Number of recorded recall outcomes. */\n\tget sampleCount(): number {\n\t\treturn this.samples;\n\t}\n}\n\n/**\n * Fraction of the recall page's distinctive tokens (present in recall but NOT in the query) that appear\n * in the response. 0 when recall added nothing the query didn't already carry.\n */\nexport function distinctiveRecallUsage(recallText: string, queryText: string, responseText: string): number {\n\tconst queryTokens = new Set(tokenize(queryText));\n\tconst distinctive = tokenize(recallText).filter((t) => !queryTokens.has(t));\n\tif (distinctive.length === 0) return 0;\n\tconst responseTokens = new Set(tokenize(responseText));\n\tlet hits = 0;\n\tfor (const token of distinctive) {\n\t\tif (responseTokens.has(token)) hits++;\n\t}\n\treturn hits / distinctive.length;\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.80.58",
3
+ "version": "0.80.59",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.80.58",
9
+ "version": "0.80.59",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.80.58",
4
+ "version": "0.80.59",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.80.58",
4
+ "version": "0.80.59",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "0.80.58",
3
+ "version": "0.80.59",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "0.80.58",
9
+ "version": "0.80.59",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.80.58",
4
+ "version": "0.80.59",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.80.58",
3
+ "version": "0.80.59",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.80.58",
9
+ "version": "0.80.59",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.80.58",
4
+ "version": "0.80.59",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.80.61",
3
+ "version": "0.80.62",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@caupulican/pi-adaptative",
9
- "version": "0.80.61",
9
+ "version": "0.80.62",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@caupulican/pi-agent-core": "^0.80.61",
13
- "@caupulican/pi-ai": "^0.80.61",
14
- "@caupulican/pi-tui": "^0.80.61",
12
+ "@caupulican/pi-agent-core": "^0.80.62",
13
+ "@caupulican/pi-ai": "^0.80.62",
14
+ "@caupulican/pi-tui": "^0.80.62",
15
15
  "@silvia-odwyer/photon-node": "0.3.4",
16
16
  "chalk": "5.6.2",
17
17
  "cross-spawn": "7.0.6",
@@ -474,11 +474,11 @@
474
474
  }
475
475
  },
476
476
  "node_modules/@caupulican/pi-agent-core": {
477
- "version": "0.80.61",
478
- "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.80.61.tgz",
477
+ "version": "0.80.62",
478
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.80.62.tgz",
479
479
  "license": "MIT",
480
480
  "dependencies": {
481
- "@caupulican/pi-ai": "^0.80.61",
481
+ "@caupulican/pi-ai": "^0.80.62",
482
482
  "ignore": "7.0.5",
483
483
  "typebox": "1.1.38",
484
484
  "yaml": "2.9.0"
@@ -488,8 +488,8 @@
488
488
  }
489
489
  },
490
490
  "node_modules/@caupulican/pi-ai": {
491
- "version": "0.80.61",
492
- "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.80.61.tgz",
491
+ "version": "0.80.62",
492
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.80.62.tgz",
493
493
  "license": "MIT",
494
494
  "dependencies": {
495
495
  "@anthropic-ai/sdk": "0.91.1",
@@ -511,8 +511,8 @@
511
511
  }
512
512
  },
513
513
  "node_modules/@caupulican/pi-tui": {
514
- "version": "0.80.61",
515
- "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.80.61.tgz",
514
+ "version": "0.80.62",
515
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.80.62.tgz",
516
516
  "license": "MIT",
517
517
  "dependencies": {
518
518
  "get-east-asian-width": "1.6.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.80.61",
3
+ "version": "0.80.62",
4
4
  "description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -41,9 +41,9 @@
41
41
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
42
42
  },
43
43
  "dependencies": {
44
- "@caupulican/pi-agent-core": "^0.80.61",
45
- "@caupulican/pi-ai": "^0.80.61",
46
- "@caupulican/pi-tui": "^0.80.61",
44
+ "@caupulican/pi-agent-core": "^0.80.62",
45
+ "@caupulican/pi-ai": "^0.80.62",
46
+ "@caupulican/pi-tui": "^0.80.62",
47
47
  "@silvia-odwyer/photon-node": "0.3.4",
48
48
  "chalk": "5.6.2",
49
49
  "cross-spawn": "7.0.6",