@burmese/agent-events 3.1.0
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 +21 -0
- package/dist/check-agent-events.d.ts +2 -0
- package/dist/check-agent-events.d.ts.map +1 -0
- package/dist/check-agent-events.js +15 -0
- package/dist/check-agent-events.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenPets
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-agent-events.d.ts","sourceRoot":"","sources":["../src/check-agent-events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { hookSpeechPools, pickHookSpeech, validateHookSpeech } from "./index.js";
|
|
3
|
+
assert.equal(pickHookSpeech("thinking", () => 0), "Thinking it through");
|
|
4
|
+
assert.equal(pickHookSpeech("success", () => 0.99), "Nice, finished");
|
|
5
|
+
for (const [category, messages] of Object.entries(hookSpeechPools)) {
|
|
6
|
+
for (const message of messages) {
|
|
7
|
+
assert.match(message, /^[A-Z]/, `${category} hook speech must start with uppercase: ${message}`);
|
|
8
|
+
assert.equal(validateHookSpeech(message), message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
for (const unsafe of ["", "a".repeat(141), "line\nbreak", "const x = 1", "https://example.com", "/Users/alvin/project", "api_key=secret"]) {
|
|
12
|
+
assert.throws(() => validateHookSpeech(unsafe));
|
|
13
|
+
}
|
|
14
|
+
console.error("Agent event speech validation passed.");
|
|
15
|
+
//# sourceMappingURL=check-agent-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-agent-events.js","sourceRoot":"","sources":["../src/check-agent-events.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEjF,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;AACzE,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAEtE,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;IACnE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,QAAQ,2CAA2C,OAAO,EAAE,CAAC,CAAC;QACjG,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,EAAE,CAAC;IAC1I,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type HookSpeechCategory = "thinking" | "success" | "error" | "permission";
|
|
2
|
+
export declare const hookSpeechPools: Record<HookSpeechCategory, readonly string[]>;
|
|
3
|
+
export declare function pickHookSpeech(category: HookSpeechCategory, random?: () => number): string;
|
|
4
|
+
export declare function validateHookSpeech(message: string): string;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,CAAC;AAEjF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAKzE,CAAC;AAEF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,kBAAkB,EAAE,MAAM,GAAE,MAAM,MAAoB,GAAG,MAAM,CAGvG;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ1D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const hookSpeechPools = {
|
|
2
|
+
thinking: ["Thinking it through", "Let me check", "On it", "Working it out"],
|
|
3
|
+
success: ["Done", "That worked", "All set", "Nice, finished"],
|
|
4
|
+
error: ["Something failed", "Needs another look", "Hit a snag", "Not quite there"],
|
|
5
|
+
permission: ["Approval needed"],
|
|
6
|
+
};
|
|
7
|
+
export function pickHookSpeech(category, random = Math.random) {
|
|
8
|
+
const pool = hookSpeechPools[category];
|
|
9
|
+
return pool[Math.max(0, Math.min(pool.length - 1, Math.floor(random() * pool.length)))] ?? pool[0] ?? "Working";
|
|
10
|
+
}
|
|
11
|
+
export function validateHookSpeech(message) {
|
|
12
|
+
if (message.length < 1 || message.length > 140)
|
|
13
|
+
throw new Error("Hook speech length is invalid.");
|
|
14
|
+
if (/\r|\n/.test(message))
|
|
15
|
+
throw new Error("Hook speech must be single line.");
|
|
16
|
+
if (/```|\b(function|const|let|var|class|import|export)\b|[{};]/.test(message))
|
|
17
|
+
throw new Error("Hook speech looks code-like.");
|
|
18
|
+
if (/https?:\/\/|www\./i.test(message))
|
|
19
|
+
throw new Error("Hook speech must not contain URLs.");
|
|
20
|
+
if (/(^|\s)(?:~|\.{1,2}|[A-Za-z]:)?[\\/][^\s]+/.test(message))
|
|
21
|
+
throw new Error("Hook speech must not contain paths.");
|
|
22
|
+
if (/\b(api[_-]?key|secret|password|token)\s*[:=]/i.test(message))
|
|
23
|
+
throw new Error("Hook speech must not contain secrets.");
|
|
24
|
+
return message;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAA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AC,qCAAqC,CAAC,CAAC;IACtH,IAAI,+CAA+C,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5H,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@burmese/agent-events",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/wannabeepolymath/pet-assistant.git",
|
|
8
|
+
"directory": "packages/agent-events"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^25.6.2",
|
|
27
|
+
"typescript": "^6.0.3"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "node dist/check-agent-events.js",
|
|
31
|
+
"check": "pnpm typecheck && pnpm build && pnpm test",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"build": "tsc"
|
|
34
|
+
}
|
|
35
|
+
}
|