@bytesbrains/pi-tool-awareness-gate 1.0.3 → 1.0.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BytesBrains Pte Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -5,14 +5,14 @@
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- pi install npm:pi-tool-awareness-gate
8
+ pi install npm:@bytesbrains/pi-tool-awareness-gate
9
9
  ```
10
10
 
11
11
  Or add to `.pi/settings.json`:
12
12
 
13
13
  ```json
14
14
  {
15
- "packages": ["npm:pi-tool-awareness-gate"]
15
+ "packages": ["npm:@bytesbrains/pi-tool-awareness-gate"]
16
16
  }
17
17
  ```
18
18
 
@@ -146,7 +146,7 @@ tool-awareness-gate/
146
146
  When a gate wants to provide domain-specific quality signals (richer than what inference can detect), it imports the envelope types:
147
147
 
148
148
  ```typescript
149
- import type { ToolResultEnvelope } from "pi-tool-awareness-gate/src/types";
149
+ import type { ToolResultEnvelope } from "@bytesbrains/pi-tool-awareness-gate/src/types";
150
150
 
151
151
  // Gate enriches its own result with domain-specific quality signals
152
152
  return {
@@ -174,3 +174,8 @@ The awareness gate will **merge** gate-provided signals with its own inference,
174
174
  ## License
175
175
 
176
176
  MIT © [nandal](https://github.com/nandal)
177
+
178
+ ---
179
+
180
+ Built and maintained by [BytesBrains](https://bytesbrains.com) — AI automation & agents, engineered to production standards.
181
+ *The model proposes, code guarantees.*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytesbrains/pi-tool-awareness-gate",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Tool limitation awareness layer for AI agents — intercepts tool results, infers quality signals, injects limitation reminders, and logs structured envelopes for evaluation.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -11,15 +11,14 @@
11
11
  "agent-protocol",
12
12
  "observability"
13
13
  ],
14
- "author": "nandal <nandal@users.noreply.github.com>",
14
+ "author": "BytesBrains Pte Ltd (https://bytesbrains.com)",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://github.com/nandal/pi-ext",
18
- "directory": "tool-awareness-gate"
17
+ "url": "git+https://github.com/bytesbrains/pi-tool-awareness-gate.git"
19
18
  },
20
- "homepage": "https://github.com/nandal/pi-ext/tree/main/tool-awareness-gate",
19
+ "homepage": "https://github.com/bytesbrains/pi-tool-awareness-gate#readme",
21
20
  "bugs": {
22
- "url": "https://github.com/nandal/pi-ext/issues"
21
+ "url": "https://github.com/bytesbrains/pi-tool-awareness-gate/issues"
23
22
  },
24
23
  "license": "MIT",
25
24
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -75,6 +75,12 @@ export default function (pi: ExtensionAPI) {
75
75
  const latencyMs = startTime ? Date.now() - startTime : 0;
76
76
  invocationStarts.delete(event.toolCallId);
77
77
 
78
+ // Prune stale entries (>5 min old) to prevent memory leak from orphaned starts
79
+ const now = Date.now();
80
+ for (const [key, ts] of invocationStarts) {
81
+ if (now - ts > 300000) invocationStarts.delete(key);
82
+ }
83
+
78
84
  // Build raw input for inference
79
85
  const raw: RawToolResult = {
80
86
  toolName: event.toolName,
@@ -155,6 +161,7 @@ export default function (pi: ExtensionAPI) {
155
161
 
156
162
  const startTime = invocationStarts.get(event.toolCallId);
157
163
  const latencyMs = startTime ? Date.now() - startTime : 0;
164
+ invocationStarts.delete(event.toolCallId);
158
165
 
159
166
  const envelope: ToolResultEnvelope = {
160
167
  status: "failure",