@hera-al/server 1.6.43 → 1.6.45
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/dist/agent/agent-service.js +1 -1
- package/dist/agent/prompt-builder.d.ts +1 -1
- package/dist/agent/prompt-builder.js +1 -1
- package/dist/agent/session-agent.d.ts +1 -1
- package/dist/agent/session-agent.js +1 -1
- package/dist/agent/workspace-files.js +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.js +1 -1
- package/dist/gateway/bridge.d.ts +11 -1
- package/dist/gateway/channel-manager.d.ts +3 -2
- package/dist/gateway/channel-manager.js +1 -1
- package/dist/gateway/channels/telegram/index.d.ts +18 -2
- package/dist/gateway/channels/telegram/index.js +1 -1
- package/dist/memory/concept-store.d.ts +27 -0
- package/dist/memory/concept-store.js +1 -1
- package/dist/memory/memory-manager.d.ts +6 -1
- package/dist/memory/memory-manager.js +1 -1
- package/dist/memory/memory-search.d.ts +78 -2
- package/dist/memory/memory-search.js +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.js +1 -1
- package/dist/tools/cron-tools.js +1 -1
- package/dist/tools/memory-tools.js +1 -1
- package/dist/tools/operational-context-tools.d.ts +20 -0
- package/dist/tools/operational-context-tools.js +1 -0
- package/installationPkg/SOUL.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operational Context Tools — CKR (Contextual Knowledge Retrieval) system.
|
|
3
|
+
*
|
|
4
|
+
* Provides a single tool `build_operational_context` that matches caller-supplied
|
|
5
|
+
* keywords against a YAML rule file (`message-rules.yaml`) and returns matching
|
|
6
|
+
* operational context snippets ordered by relevance score.
|
|
7
|
+
*
|
|
8
|
+
* The rule file is cached in memory and only re-read when its mtime changes.
|
|
9
|
+
* Fail-open: missing or malformed files produce empty results, never errors.
|
|
10
|
+
*
|
|
11
|
+
* Storage: {dataDir}/message-rules.yaml
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Load tool rules from data/tool-rules.yaml.
|
|
15
|
+
* Returns a map of tool_name → array of rule strings.
|
|
16
|
+
* Cached with mtime check. Fail-open: returns empty object on error.
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadToolRules(dataDir: string): Record<string, string[]>;
|
|
19
|
+
export declare function createOperationalContextToolsServer(dataDir: string): import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance;
|
|
20
|
+
//# sourceMappingURL=operational-context-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSdkMcpServer as e,tool as t}from"@anthropic-ai/claude-agent-sdk";import{z as r}from"zod";import{readFileSync as o,statSync as n}from"fs";import{join as s}from"path";import{parse as i}from"yaml";import{createLogger as a}from"../utils/logger.js";const l=a("OperationalContextTools");function c(e,t){return!(!e.includes(t)&&!t.includes(e))||e.length>=5&&t.length>=5&&function(e,t){if(e===t)return 1;const r=e.length,o=t.length;if(0===r||0===o)return 0;const n=Math.max(Math.floor(Math.max(r,o)/2)-1,0),s=new Array(r).fill(!1),i=new Array(o).fill(!1);let a=0,l=0;for(let l=0;l<r;l++){const r=Math.max(0,l-n),c=Math.min(l+n+1,o);for(let o=r;o<c;o++)if(!i[o]&&e[l]===t[o]){s[l]=!0,i[o]=!0,a++;break}}if(0===a)return 0;let c=0;for(let o=0;o<r;o++)if(s[o]){for(;!i[c];)c++;e[o]!==t[c]&&l++,c++}const u=(a/r+a/o+(a-l/2)/a)/3;let m=0;for(let n=0;n<Math.min(4,Math.min(r,o))&&e[n]===t[n];n++)m++;return u+.1*m*(1-u)}(e,t)>=.93}let u=null;function m(e){try{const t=n(e).mtimeMs;if(u&&u.mtime===t)return u.rules;const r=o(e,"utf-8"),s=i(r);if(!s||"object"!=typeof s)return u={mtime:t,rules:new Map},u.rules;const a=new Map;for(const[e,t]of Object.entries(s))t&&Array.isArray(t.match)&&"string"==typeof t.inject&&a.set(e,{match:t.match,inject:t.inject,priority:t.priority,when:t.when});return u={mtime:t,rules:a},l.debug(`Loaded ${a.size} rules from message-rules.yaml`),a}catch{return new Map}}let f=null;export function loadToolRules(e){const t=s(e,"tool-rules.yaml");try{const e=n(t).mtimeMs;if(f&&f.mtime===e)return f.rules;const r=o(t,"utf-8"),s=i(r);if(!s||"object"!=typeof s)return f={mtime:e,rules:{}},f.rules;const a={};for(const[e,t]of Object.entries(s))Array.isArray(t)&&(a[e]=t.filter(e=>"string"==typeof e));return f={mtime:e,rules:a},l.debug(`Loaded tool rules for ${Object.keys(a).length} tools`),a}catch{return{}}}export function createOperationalContextToolsServer(o){const n=s(o,"message-rules.yaml");return e({name:"operational-context-tools",version:"1.0.0",tools:[t("build_operational_context","Match keywords against operational rules and return relevant context snippets. Use this to retrieve situational instructions and guidelines based on the current conversation topic.",{keywords:r.array(r.string()).describe("Keywords to match against operational rules").optional(),ruleIds:r.array(r.string()).describe("Specific rule IDs to retrieve (bypasses keyword matching). Use after Haiku classification.").optional()},async({keywords:e,ruleIds:t})=>{const r=m(n);if(0===r.size)return{content:[{type:"text",text:"No matching operational rules."}]};let o=[];if(t&&t.length>0){for(const e of t){const t=r.get(e);t&&o.push({id:e,inject:t.inject,score:100+(t.priority??0)})}l.debug(`Direct lookup: ${o.length}/${t.length} rules found`)}else{if(!(e&&e.length>0))return{content:[{type:"text",text:"No matching operational rules. Provide keywords or ruleIds."}]};{const t=e.map(e=>e.toLowerCase());r.forEach((e,r)=>{let n=0;for(const r of e.match){const e=r.toLowerCase();t.some(t=>c(t,e))&&n++}if(n>0){const t=10*n+(e.priority??0);o.push({id:r,inject:e.inject,score:t})}}),l.debug(`Keyword match: ${o.length} rules for: ${e.join(", ")}`)}}if(0===o.length)return{content:[{type:"text",text:"No matching operational rules."}]};o.sort((e,t)=>t.score-e.score);return{content:[{type:"text",text:o.map(e=>`[${e.id}] ${e.inject}`).join("\n")}]}}),t("get_ckr_classifier_prompt","Generate the Haiku classifier prompt from current message-rules.yaml. Use this to get an up-to-date classifier prompt for Agent(model=haiku) classification. Call once per session, cache the result.",{},async()=>{const e=m(n);if(0===e.size)return{content:[{type:"text",text:"No rules loaded."}]};return{content:[{type:"text",text:`You are a message classifier. Given a user message, return ONLY a JSON array of matching rule IDs. No explanation, no markdown, no code fences.\n\nRules:\n${Array.from(e.entries()).map(([e,t])=>`- ${e}: ${t.when||`Matches: ${t.match.slice(0,5).join(", ")}`}`).join("\n")}\n\nReturn ONLY a JSON array like ["medical-context"] or []. Nothing else.`}]}})]})}
|
package/installationPkg/SOUL.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
**Be resourceful before asking.** Try to figure it out. Read the file. Check the context. Search for it. *Then* ask if you're stuck. The goal is to come back with answers, not questions.
|
|
12
12
|
|
|
13
|
-
**Never guess verifiable data.**
|
|
13
|
+
**Never guess verifiable data.** Verification rules are specific if-then triggers (IF-1 through IF-8 in SYSTEM_PROMPT.md Integrity section). Each maps to a real past failure. The general principle: if you can check it, check BEFORE answering. But the implementation is behavioral, not philosophical — specific cues trigger specific verification actions.
|
|
14
14
|
|
|
15
15
|
**Earn trust through competence.** Your human gave you access to their stuff. Don't make them regret it. Be careful with external actions (emails, tweets, anything public). Be bold with internal ones (reading, organizing, learning).
|
|
16
16
|
|