aws-runtime-bridge 1.9.172 → 1.9.175
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 +126 -0
- package/dist/adapter/AcodeSdkAdapter.d.ts +5 -1
- package/dist/adapter/AcodeSdkAdapter.js +3 -3
- package/dist/adapter/types.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/routes/bridge-temp-files.d.ts +1 -0
- package/dist/routes/bridge-temp-files.js +2 -0
- package/dist/routes/dashboard.js +35 -5
- package/dist/routes/file-browser.d.ts +4 -10
- package/dist/routes/file-browser.js +1 -1
- package/dist/routes/git.d.ts +42 -0
- package/dist/routes/git.js +34 -34
- package/dist/routes/sessions.js +1 -1
- package/dist/routes/tech-stack.d.ts +2 -0
- package/dist/routes/tech-stack.js +2 -0
- package/dist/routes/terminal.js +19 -19
- package/dist/services/agent-pty-manager.d.ts +2 -0
- package/dist/services/agent-pty-manager.js +5 -4
- package/dist/services/agent-startup-memory.js +4 -4
- package/dist/services/bridge-temp-files.d.ts +36 -0
- package/dist/services/bridge-temp-files.js +2 -0
- package/dist/services/fileSnapshotStore.d.ts +9 -0
- package/dist/services/fileSnapshotStore.js +1 -1
- package/dist/services/gitignore.d.ts +12 -0
- package/dist/services/gitignore.js +2 -0
- package/dist/services/log-retention.js +1 -1
- package/dist/services/open-doc-events.d.ts +21 -0
- package/dist/services/open-doc-events.js +2 -0
- package/dist/services/open-doc-registry.d.ts +24 -0
- package/dist/services/open-doc-registry.js +2 -0
- package/dist/services/request-invalid-dump.js +1 -1
- package/dist/services/runtime-resources-snapshot.js +2 -2
- package/dist/services/snapshot-retention.d.ts +7 -0
- package/dist/services/snapshot-retention.js +2 -0
- package/dist/services/tech-stack-scanner.d.ts +31 -0
- package/dist/services/tech-stack-scanner.js +2 -0
- package/dist/services/tunnel-client.d.ts +42 -0
- package/dist/services/tunnel-client.js +1 -1
- package/dist/services/workspaceTaskChangeWatcher.js +2 -2
- package/package/acode/dist/__tests__/summary-request-helper.d.ts +2 -0
- package/package/acode/dist/__tests__/summary-request-helper.js +2 -0
- package/package/acode/dist/cache-control.d.ts +26 -0
- package/package/acode/dist/cache-control.js +2 -0
- package/package/acode/dist/compaction.d.ts +35 -5
- package/package/acode/dist/compaction.js +19 -17
- package/package/acode/dist/microcompact.d.ts +57 -0
- package/package/acode/dist/microcompact.js +2 -0
- package/package/acode/dist/runtime.d.ts +4 -0
- package/package/acode/dist/runtime.js +40 -33
- package/package/acode/dist/token-estimator.d.ts +15 -0
- package/package/acode/dist/token-estimator.js +2 -0
- package/package/acode/dist/types.d.ts +13 -0
- package/package/aws-client-agent-mcp/dist/ability-market-tools.js +1 -1
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts +15 -2
- package/package/aws-client-agent-mcp/dist/agent-client.js +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +5 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.js +25 -23
- package/package/aws-client-agent-mcp/dist/mcp-tools.js +7 -7
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +21 -2
- package/package/aws-client-agent-mcp/dist/memory-store.js +27 -2
- package/package/aws-client-agent-mcp/dist/memory-tools.js +13 -9
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts +1 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.js +1 -1
- package/package/aws-client-agent-mcp/dist/types.d.ts +51 -0
- package/package.json +1 -1
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
export type MemoryType = '
|
|
1
|
+
export type MemoryType = 'instance_hotspot_memory' | 'instance_permanent_memory' | 'project_doc_memory' | 'session_context';
|
|
2
|
+
|
|
3
|
+
export declare const LEGACY_MEMORY_TYPE_ALIASES: Record<string, MemoryType>;
|
|
4
|
+
|
|
5
|
+
export declare const MEMORY_TYPE_GUIDE: string;
|
|
6
|
+
|
|
7
|
+
export declare function normalizeMemoryTypeName(input: unknown): MemoryType | null;
|
|
8
|
+
|
|
9
|
+
export declare function validateTypeConstraints(memoryType: MemoryType, input: {
|
|
10
|
+
title?: string;
|
|
11
|
+
content?: string;
|
|
12
|
+
bound_files?: string[];
|
|
13
|
+
}): void;
|
|
2
14
|
|
|
3
15
|
export declare function normalizeBoundFilePath(filePath: string): string;
|
|
4
16
|
export interface MemoryRecord {
|
|
@@ -156,7 +168,8 @@ export declare class MemoryStore implements MemoryStorePort {
|
|
|
156
168
|
constructor(storePath: string);
|
|
157
169
|
private nowIso;
|
|
158
170
|
private normalizeUri;
|
|
159
|
-
|
|
171
|
+
|
|
172
|
+
normalizeMemoryType(input: unknown, allowedTypes?: MemoryType[]): MemoryType;
|
|
160
173
|
private ensureTypeMatch;
|
|
161
174
|
|
|
162
175
|
private ensureStoreDir;
|
|
@@ -180,6 +193,12 @@ export declare class MemoryStore implements MemoryStorePort {
|
|
|
180
193
|
private static calcAgentMemoryExpiresAt;
|
|
181
194
|
|
|
182
195
|
static isExpirableType(memoryType: string | undefined): boolean;
|
|
196
|
+
|
|
197
|
+
validateTypeConstraints(memoryType: MemoryType, input: {
|
|
198
|
+
title?: string;
|
|
199
|
+
content?: string;
|
|
200
|
+
bound_files?: string[];
|
|
201
|
+
}): void;
|
|
183
202
|
createMemory(input: CreateMemoryInput): Promise<MemoryRecord>;
|
|
184
203
|
readMemory(input: ReadMemoryInput): Promise<MemoryRecord | null>;
|
|
185
204
|
updateMemory(input: UpdateMemoryInput): Promise<MemoryRecord>;
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
const E=["instance_memory","instance_long_memory","project_memory","session_context"],h=["instance_memory","instance_long_memory"],C=64,R=32,Y=128,$=64,P=1024;function L(y){const e=String(y||"").trim().replace(/\\/g,"/");if(!e)return e;const t=e.startsWith("@/")?e.substring(1):e;return t.startsWith("./")?t:`./${t.replace(/^\/+/,"")}`}class T extends Error{details;constructor(e,t){super(e),this.name="MemoryCapacityError",this.details=t}}const b=/^([a-zA-Z_][a-zA-Z0-9_]*):\/\/(.*)$/,g="local",S=50,x=10;function D(y){const e=(y||"").trim();return e?e.split("|").map(t=>t.trim()).filter(Boolean).map(t=>t.split(/\s+/).filter(Boolean)):[]}function O(y,e){return y.length===0?!1:y.some(t=>t.every(o=>e.includes(o)))}class p{storePath;domainJsonCache=new Map;constructor(e){this.storePath=e}nowIso(){return new Date().toISOString()}normalizeUri(e){const t=String(e||"").trim(),o=b.exec(t);if(!o)throw new Error(`Invalid memory uri: ${e}`);const r=o[1],n=o[2];if(!r||!n)throw new Error(`Invalid memory uri: ${e}`);const a=r.toLowerCase(),s=n.replace(/^\/+|\/+$/g,"");if(!s)throw new Error(`Invalid memory uri path: ${e}`);return{uri:`${a}://${s}`,domain:a,path:s}}normalizeMemoryType(e,t=E){const o=String(e||"").trim();if(!t.includes(o))throw new Error(`Invalid memory_type: ${e}`);return o}ensureTypeMatch(e,t){if(t&&e.memory_type!==t)throw new Error(`Memory type mismatch: expected ${t}, actual ${e.memory_type}`)}async ensureStoreDir(){const{mkdir:e}=await import("node:fs/promises");await e(this.storePath,{recursive:!0})}async loadMemoryFile(e){const{readFile:t}=await import("node:fs/promises");try{const o=await t(e,"utf-8"),r=JSON.parse(o),n=r.by_uri&&typeof r.by_uri=="object"?r.by_uri:{},a={};for(const[s,d]of Object.entries(n)){const i=this.normalizeMemoryType(d.memory_type||"project_memory"),l=this.normalizeUri(d.uri||s),m=d;let c=m.memory_status;c||(m.update_status==="updating"?c="updating":m.recall_status==="recalling"?c="recalling":c="normal");const u={...d};delete u.update_status,delete u.recall_status,a[l.uri]={...u,uri:l.uri,domain:l.domain,path:l.path,memory_type:i,memory_status:c}}return{by_uri:a}}catch{return{by_uri:{}}}}async loadData(){const{readdir:e}=await import("node:fs/promises"),t=await import("node:path");try{const o=await e(this.storePath,{withFileTypes:!0}),r={by_uri:{}};for(const n of o){if(!n.isFile()||!n.name.endsWith(".json"))continue;const a=await this.loadMemoryFile(t.join(this.storePath,n.name));Object.assign(r.by_uri,a.by_uri)}return r}catch{return{by_uri:{}}}}async writeJsonAtomically(e,t,o=JSON.stringify(t,null,2)){const{rename:r,rm:n,writeFile:a}=await import("node:fs/promises"),s=`${e}.${process.pid}.${Date.now()}.tmp`;try{await a(s,o,"utf-8"),await r(s,e)}catch(d){throw await n(s,{force:!0}),d}}async saveData(e){const{readFile:t,readdir:o,rm:r}=await import("node:fs/promises"),n=await import("node:path");await this.ensureStoreDir();const a=new Map;for(const i of Object.values(e.by_uri)){const l=a.get(i.domain)??{by_uri:{}};l.by_uri[i.uri]=i,a.set(i.domain,l)}for(const[i,l]of a.entries()){const m=n.join(this.storePath,`${i}.json`),c=JSON.stringify(l,null,2);if(this.domainJsonCache.get(m)===c)continue;let _;try{_=await t(m,"utf-8")}catch{_=void 0}if(_===c){this.domainJsonCache.set(m,c);continue}await this.writeJsonAtomically(m,l,c),this.domainJsonCache.set(m,c)}const s=new Set([...a.keys()].map(i=>`${i}.json`)),d=await o(this.storePath,{withFileTypes:!0});for(const i of d)if(i.isFile()&&i.name.endsWith(".json")&&!s.has(i.name)){const l=n.join(this.storePath,i.name);await r(l,{force:!0}),this.domainJsonCache.delete(l)}}createEmptyStats(){return{total:0,listable:{count:0,limit:64,hardLimit:128,exceeded:!1,hardExceeded:!1},by_type:{instance_memory:{count:0,limit:32,hardLimit:64,exceeded:!1,hardExceeded:!1,listable:!0,domainCount:0,by_domain:{}},instance_long_memory:{count:0,limit:32,hardLimit:64,exceeded:!1,hardExceeded:!1,listable:!0,domainCount:0,by_domain:{}},project_memory:{count:0,limit:null,hardLimit:null,exceeded:!1,hardExceeded:!1,listable:!1,domainCount:0,by_domain:{}},session_context:{count:0,limit:null,hardLimit:1024,exceeded:!1,hardExceeded:!1,listable:!1,domainCount:0,by_domain:{}}}}}calculateStats(e){const t=this.createEmptyStats();for(const o of Object.values(e.by_uri)){t.total+=1;const r=t.by_type[o.memory_type];r.count+=1;const n=d=>h.includes(d)?32:null,a=d=>h.includes(d)?64:d==="session_context"?1024:null,s=r.by_domain[o.domain]??{count:0,limit:n(o.memory_type),hardLimit:a(o.memory_type),exceeded:!1,hardExceeded:!1};s.count+=1,r.by_domain[o.domain]=s,h.includes(o.memory_type)&&(t.listable.count+=1)}t.listable.exceeded=t.listable.count>t.listable.limit,t.listable.hardExceeded=t.listable.count>=t.listable.hardLimit;for(const o of E){const r=t.by_type[o];r.domainCount=Object.keys(r.by_domain).length,r.limit!==null&&r.hardLimit!==null&&(r.exceeded=r.domainCount>r.limit,r.hardExceeded=r.domainCount>=r.hardLimit);for(const n of Object.values(r.by_domain))n.limit!==null&&n.hardLimit!==null&&(n.exceeded=n.count>n.limit,n.hardExceeded=n.count>=n.hardLimit)}return t}generateId(e){return`${e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${Date.now().toString(36)}`}ensureListableMemoryCapacity(e,t,o){if(!h.includes(t))return;const n=this.calculateStats(e).by_type[t],a=n.by_domain[o.domain];if(!a&&n.domainCount>=64)throw new T(`Cannot create ${t}: hard domain type limit 64 reached. Please delete an existing ${t} domain type before creating a new ${t}.`,{code:"MEMORY_TYPE_LIMIT_REACHED",memory_type:t,limit:64,current:n.domainCount,recommended_actions:[`list_memories({ memory_type: '${t}' })`,`delete_memory({ uri, memory_type: '${t}' })`]});if(a&&a.count>=64)throw new T(`Cannot create ${t}: hard memory limit 64 reached under domain ${o.domain}. Please delete or archive existing ${o.domain}://${t} memories before creating a new one.`,{code:"MEMORY_TYPE_LIMIT_REACHED",memory_type:t,domain:o.domain,limit:64,current:a.count,recommended_actions:[`list_memories({ memory_type: '${t}' })`,`delete_memory({ uri, memory_type: '${t}' })`]})}ensureSessionContextCapacity(e,t,o){if(t!=="session_context")return;const r=Object.values(e.by_uri).filter(n=>n.memory_type==="session_context"&&n.domain===o.domain).length;if(r>=1024)throw new T(`Cannot create session_context: hard limit 1024 reached under domain ${o.domain}. Please delete existing session_context memories before creating a new one.`,{code:"MEMORY_TYPE_LIMIT_REACHED",memory_type:t,domain:o.domain,limit:1024,current:r,recommended_actions:["list_memories({ memory_type: 'session_context' })","delete_memory({ uri, memory_type: 'session_context' })"]})}async getStats(){const e=await this.loadData();return this.calculateStats(e)}static calcAgentMemoryExpiresAt(){return new Date(Date.now()+432e5).toISOString()}static isExpirableType(e){return e==="instance_long_memory"||e==="instance_memory"}async createMemory(e){const t=this.normalizeMemoryType(e.memory_type),o=this.normalizeUri(e.uri),r=await this.loadData();if(r.by_uri[o.uri])throw new Error(`Memory already exists: ${o.uri}`);this.ensureListableMemoryCapacity(r,t,o),this.ensureSessionContextCapacity(r,t,o);const n=this.nowIso(),a={id:this.generateId(o.uri),uri:o.uri,domain:o.domain,path:o.path,title:e.title||void 0,content:String(e.content||""),memory_type:t,createdAt:n,updatedAt:n,version:1,keywords:e.keywords,bound_files:e.bound_files,file_md5_map:e.file_md5_map||void 0,updating_agent_id:void 0,last_check_time:e.last_check_time||void 0,expiresAt:e.expiresAt||(p.isExpirableType(t)?p.calcAgentMemoryExpiresAt():void 0),memory_status:"normal"};return r.by_uri[o.uri]=a,await this.saveData(r),a}async readMemory(e){const t=this.normalizeUri(e.uri),o=typeof e.memory_type=="string"?this.normalizeMemoryType(e.memory_type):void 0,n=(await this.loadData()).by_uri[t.uri]??null;return n?(this.ensureTypeMatch(n,o),n):null}async updateMemory(e){const t=this.normalizeUri(e.uri),o=typeof e.memory_type=="string"?this.normalizeMemoryType(e.memory_type):void 0,r=await this.loadData(),n=r.by_uri[t.uri];if(!n)throw new Error(`Memory not found: ${t.uri}`);this.ensureTypeMatch(n,o);let a=n.content;if(typeof e.old_string=="string"&&typeof e.new_string=="string"){const m=e.old_string;if(!m)throw new Error("old_string cannot be empty when replacing");const c=a.split(m).length-1;if(c===0)throw new Error("old_string not found in memory content");if(c>1)throw new Error("old_string appears multiple times; replace is ambiguous");a=a.replace(m,e.new_string)}typeof e.append=="string"&&e.append.length>0&&(a=`${a}${e.append}`);const s=a!==n.content||typeof e.title=="string"&&e.title!==n.title,d=this.nowIso();let i=n.expiresAt;if(p.isExpirableType(n.memory_type))if(n.memory_type==="instance_memory")i=new Date(Date.now()+24*60*60*1e3).toISOString();else{const m=n.expiresAt?new Date(n.expiresAt):null,c=n.updatedAt?new Date(n.updatedAt):null,u=m&&c&&!isNaN(c.getTime())?Math.max(12*60*60*1e3,m.getTime()-c.getTime()):12*60*60*1e3;i=new Date(Date.now()+u*2).toISOString()}e.expiresAt!==void 0&&(i=e.expiresAt);const l={...n,content:a,title:e.title!==void 0?e.title:n.title,updatedAt:d,version:n.version+1,keywords:e.keywords!==void 0?e.keywords:n.keywords,bound_files:e.bound_files!==void 0?e.bound_files:n.bound_files,file_md5_map:e.file_md5_map!==void 0?e.file_md5_map:e.bound_files!==void 0?void 0:n.file_md5_map,memory_status:e.memory_status!==void 0?e.memory_status:n.memory_status==="updating"?"normal":n.memory_status||"normal",updating_agent_id:e.memory_status!==void 0?e.updating_agent_id||void 0:n.memory_status==="updating"?void 0:n.updating_agent_id,last_check_time:e.last_check_time!==void 0?e.last_check_time:n.last_check_time,expiresAt:i};return r.by_uri[t.uri]=l,await this.saveData(r),l}async deleteMemory(e){const t=this.normalizeUri(e.uri),o=typeof e.memory_type=="string"?this.normalizeMemoryType(e.memory_type):void 0,r=await this.loadData(),n=r.by_uri[t.uri];return n?(this.ensureTypeMatch(n,o),delete r.by_uri[t.uri],await this.saveData(r),!0):!1}async listExpiredRecentlyMemories(){const e=await this.loadData(),t=new Date,o=[];for(const r of Object.values(e.by_uri))r.memory_type!=="instance_long_memory"&&r.memory_type!=="instance_memory"||r.expiresAt&&(new Date(r.expiresAt)>t||r.memory_status==="recalling"&&r.updating_agent_id!==g||o.push(r));return o.sort((r,n)=>r.expiresAt.localeCompare(n.expiresAt))}async searchMemory(e){const t=await this.loadData(),r=String(e.query||"").trim().toLowerCase(),n=e.memory_type?this.normalizeMemoryType(e.memory_type):void 0,a=typeof e.limit=="number"&&e.limit>0?e.limit:10,s=e.keywords?.map(c=>c.toLowerCase()),d=e.keyword_mode==="all"?"all":"any",i=D(r);if(i.length===0&&(!s||s.length===0))return{query:r,results:[]};const l=new Set,m=[];for(const c of Object.values(t.by_uri)){if(n&&c.memory_type!==n||l.has(c.id))continue;let u=0;if(s&&s.length>0&&c.keywords){const _=c.keywords.map(f=>f.toLowerCase());if(d==="all"){if(s.every(w=>_.includes(w)))u+=10*s.length;else if(i.length===0)continue}else for(const f of s)_.includes(f)&&(u+=10)}if(i.length>0){const _=`${c.uri}
|
|
1
|
+
const M=["instance_hotspot_memory","instance_permanent_memory","project_doc_memory","session_context"],w=["instance_hotspot_memory","instance_permanent_memory"],A={task_list:"instance_hotspot_memory",recently_memory:"instance_hotspot_memory",instance_memory:"instance_hotspot_memory",agent_memory:"instance_permanent_memory",instance_long_memory:"instance_permanent_memory",memory:"project_doc_memory",project_memory:"project_doc_memory"},p=["\u8BB0\u5FC6\u7C7B\u578B\u4E09\u9009\u4E00\uFF08\u6309\u300C\u8FD9\u6761\u5185\u5BB9\u672A\u6765\u88AB\u8C01\u8BFB\u5230\u3001\u4F55\u65F6\u8BFB\u5230\u300D\u9009\u62E9\uFF09\uFF1A","- instance_hotspot_memory \u5B9E\u4F8B\u70ED\u70B9\u8BB0\u5FC6\uFF1A\u4E0B\u6B21\u4F1A\u8BDD\u5F00\u573A\u5C31\u8981\u7528\u7684\u5DE5\u4F5C\u72B6\u6001\uFF08\u8FDB\u5EA6/\u5F85\u529E/\u4E34\u65F6\u7ED3\u8BBA\uFF09\u3002\u6761\u6570\u6709\u9650\u3001\u77ED TTL\uFF0C\u81EA\u52A8\u6CE8\u5165\u4E0B\u6B21\u4F1A\u8BDD\u8BB0\u5FC6\u5757\u3002\u7981\u6B62\u5B58\u957F\u671F\u7ECF\u9A8C\u4E0E\u9879\u76EE\u6587\u6863\u3002","- instance_permanent_memory \u5B9E\u4F8B\u6C38\u4E45\u8BB0\u5FC6\uFF1A\u672C\u5B9E\u4F8B\u5BF9\u73AF\u5883/\u5DE5\u5177/\u6D41\u7A0B\u7684\u957F\u671F\u7ECF\u9A8C\u7ED3\u8BBA\uFF08\u6559\u8BAD/\u7EA6\u5B9A/\u80FD\u529B\u8FB9\u754C\uFF09\u3002\u65E0\u8FC7\u671F\uFF0C\u9760 search_memory \u68C0\u7D22\u3002\u4E0D\u8981\u6C42\u7ED1\u5B9A\u6587\u4EF6\u3002","- project_doc_memory \u9879\u76EE\u6587\u6863\u8BB0\u5FC6\uFF1A\u5BF9\u9879\u76EE\u6587\u4EF6\u96C6\u7684\u5BA2\u89C2\u7B14\u8BB0\uFF08\u67B6\u6784/\u6A21\u5757\u804C\u8D23/\u63A5\u53E3\u7EA6\u5B9A/\u5751\u70B9\uFF09\u3002\u5E94\u5C3D\u91CF\u7528 bound_files \u5173\u8054\u6587\u4EF6\uFF0C\u6807\u9898\u5FC5\u586B\u3001\u5185\u5BB9\u9700\u542B markdown \u5C0F\u8282\uFF08## \uFF09\uFF0C\u89D2\u8272\u7EA7\u5171\u4EAB\u3001\u968F\u6587\u4EF6\u53D8\u66F4\u7EF4\u62A4\u3002","\u9009\u62E9\u89C4\u5219\uFF1A\u5185\u5BB9\u6307\u5411\u5177\u4F53\u9879\u76EE\u6587\u4EF6\u3001\u9700\u968F\u6587\u4EF6\u53D8\u66F4\u7EF4\u62A4 \u2192 project_doc_memory\uFF1B\u73AF\u5883/\u5DE5\u5177\u7ECF\u9A8C\u3001\u4E0D\u6307\u5411\u5177\u4F53\u6587\u4EF6 \u2192 instance_permanent_memory\uFF1B\u672C\u6B21\u4EFB\u52A1\u8FDB\u5EA6\u3001\u4E0B\u6B21\u4F1A\u8BDD\u63A5\u7740\u5E72 \u2192 instance_hotspot_memory\u3002"].join(`
|
|
2
|
+
`);function Y(_){const e=String(_||"").trim(),t=A[e]??e;return M.includes(t)?t:null}function j(_,e){const t=(e.bound_files||[]).filter(o=>String(o||"").trim()),r=String(e.title||"").trim(),n=String(e.content||"");if(_==="project_doc_memory"){if(!r)throw new Error(`project_doc_memory \u5FC5\u987B\u586B\u5199 title\uFF08\u226450 \u5B57\u7684\u89C4\u8303\u6807\u9898\uFF0C\u4FBF\u4E8E\u68C0\u7D22\u4E0E\u53D8\u66F4\u8FFD\u8E2A\uFF09\u3002
|
|
3
|
+
\u63A8\u8350\u683C\u5F0F\uFF1A\u300C<\u6A21\u5757/\u6587\u4EF6\u96C6> - <\u4E3B\u9898>\u300D\uFF0C\u4F8B\u5982\u300Csrc/api - \u63A5\u53E3\u5C42\u804C\u8D23\u4E0E\u7EA6\u5B9A\u300D\u3002
|
|
4
|
+
`+p);if(r.length>50)throw new Error(`project_doc_memory \u7684 title \u4E0D\u5F97\u8D85\u8FC7 50 \u5B57\uFF08\u5F53\u524D ${r.length} \u5B57\uFF09\u3002\u8BF7\u7CBE\u70BC\u4E3A\u300C<\u6A21\u5757/\u6587\u4EF6\u96C6> - <\u4E3B\u9898>\u300D\u5F62\u5F0F\u3002`);if(!/^##\s+\S/m.test(n))throw new Error(`project_doc_memory \u7684 content \u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A markdown \u5C0F\u8282\uFF08## \u6807\u9898\uFF09\uFF0C\u6309\u5BA2\u89C2\u7B14\u8BB0\u89C4\u8303\u7EC4\u7EC7\u3002
|
|
5
|
+
\u63A8\u8350\u6A21\u677F\uFF1A
|
|
6
|
+
## \u6982\u8FF0
|
|
7
|
+
<\u4E00\u53E5\u8BDD\u8BF4\u660E\u8FD9\u4EFD\u7B14\u8BB0\u8986\u76D6\u54EA\u4E9B\u6587\u4EF6>
|
|
8
|
+
## \u7ED3\u6784
|
|
9
|
+
<\u6A21\u5757/\u6587\u4EF6\u804C\u8D23\u3001\u4F9D\u8D56\u5173\u7CFB>
|
|
10
|
+
## \u5173\u952E\u7ED3\u8BBA
|
|
11
|
+
<\u63A5\u53E3\u7EA6\u5B9A\u3001\u8BBE\u8BA1\u51B3\u7B56>
|
|
12
|
+
## \u8E29\u5751
|
|
13
|
+
<\u5DF2\u77E5\u95EE\u9898\u4E0E\u89C4\u907F\u65B9\u5F0F>
|
|
14
|
+
`+p)}if(_==="instance_hotspot_memory"){if(!r)throw new Error(`instance_hotspot_memory \u5FC5\u987B\u586B\u5199 title\uFF08\u7B80\u77ED\u6807\u9898\uFF0C\u8BF4\u660E\u8FD9\u6761\u70ED\u70B9\u8BB0\u5FC6\u662F\u4EC0\u4E48\u5DE5\u4F5C\u72B6\u6001\uFF09\u3002
|
|
15
|
+
`+p);if(n.length>2e3)throw new Error(`instance_hotspot_memory \u7684 content \u4E0D\u5F97\u8D85\u8FC7 2000 \u5B57\uFF08\u5F53\u524D ${n.length} \u5B57\uFF09\u3002\u70ED\u70B9\u8BB0\u5FC6\u53EA\u5B58\u4E0B\u6B21\u4F1A\u8BDD\u5F00\u573A\u9700\u8981\u7684\u5DE5\u4F5C\u72B6\u6001\uFF1B\u957F\u671F\u7ECF\u9A8C\u8BF7\u6539\u7528 instance_permanent_memory\uFF0C\u9879\u76EE\u6587\u6863\u8BF7\u6539\u7528 project_doc_memory \u5E76\u62C6\u5206\u5230\u5BF9\u5E94\u6587\u4EF6\u7B14\u8BB0\u3002`)}if(_==="instance_permanent_memory"&&t.length>0)throw new Error(`instance_permanent_memory \u4E0D\u8981\u6C42\u4E5F\u4E0D\u5EFA\u8BAE\u7ED1\u5B9A\u6587\u4EF6\uFF1A\u7ED1\u5B9A\u6587\u4EF6\u7684\u5185\u5BB9\u5C5E\u4E8E\u9879\u76EE\u6587\u6863\uFF0C\u5E94\u6539\u7528 project_doc_memory\uFF08bound_files + \u89C4\u8303\u6807\u9898/\u5185\u5BB9\uFF09\u3002
|
|
16
|
+
\u82E5\u786E\u5B9E\u53EA\u662F\u73AF\u5883\u7ECF\u9A8C\u3001\u53EA\u662F\u987A\u5E26\u8BB0\u5F55\u4E86\u6587\u4EF6\u8DEF\u5F84\uFF0C\u8BF7\u53BB\u6389 bound_files \u518D\u4FDD\u5B58\u4E3A instance_permanent_memory\u3002
|
|
17
|
+
`+p)}const L=64,x=32,O=L*2,h=x*2,g=1024;function I(_){const e=String(_||"").trim().replace(/\\/g,"/");if(!e)return e;const t=e.startsWith("@/")?e.substring(1):e;return t.startsWith("./")?t:`./${t.replace(/^\/+/,"")}`}class S extends Error{details;constructor(e,t){super(e),this.name="MemoryCapacityError",this.details=t}}const v=/^([a-zA-Z_][a-zA-Z0-9_]*):\/\/(.*)$/,C="local",k=50,R=10;function P(_){const e=(_||"").trim();return e?e.split("|").map(t=>t.trim()).filter(Boolean).map(t=>t.split(/\s+/).filter(Boolean)):[]}function z(_,e){return _.length===0?!1:_.some(t=>t.every(r=>e.includes(r)))}class b{storePath;domainJsonCache=new Map;constructor(e){this.storePath=e}nowIso(){return new Date().toISOString()}normalizeUri(e){const t=String(e||"").trim(),r=v.exec(t);if(!r)throw new Error(`Invalid memory uri: ${e}`);const n=r[1],o=r[2];if(!n||!o)throw new Error(`Invalid memory uri: ${e}`);const i=n.toLowerCase(),s=o.replace(/^\/+|\/+$/g,"");if(!s)throw new Error(`Invalid memory uri path: ${e}`);return{uri:`${i}://${s}`,domain:i,path:s}}normalizeMemoryType(e,t=M){const r=String(e||"").trim(),n=A[r]??r;if(!t.includes(n))throw new Error(`Invalid memory_type: ${e}
|
|
18
|
+
${p}`+(A[r]?`
|
|
19
|
+
\u63D0\u793A\uFF1A\u65E7\u7C7B\u578B\u540D ${r} \u5DF2\u66F4\u540D\u4E3A ${n}\u3002`:""));return n}ensureTypeMatch(e,t){if(t&&e.memory_type!==t)throw new Error(`Memory type mismatch: expected ${t}, actual ${e.memory_type}`)}async ensureStoreDir(){const{mkdir:e}=await import("node:fs/promises");await e(this.storePath,{recursive:!0})}async loadMemoryFile(e){const{readFile:t}=await import("node:fs/promises");try{const r=await t(e,"utf-8"),n=JSON.parse(r),o=n.by_uri&&typeof n.by_uri=="object"?n.by_uri:{},i={};for(const[s,d]of Object.entries(o)){const a=this.normalizeMemoryType(d.memory_type||"project_doc_memory"),m=this.normalizeUri(d.uri||s),l=d;let c=l.memory_status;c||(l.update_status==="updating"?c="updating":l.recall_status==="recalling"?c="recalling":c="normal");const y={...d};delete y.update_status,delete y.recall_status,i[m.uri]={...y,uri:m.uri,domain:m.domain,path:m.path,memory_type:a,memory_status:c}}return{by_uri:i}}catch{return{by_uri:{}}}}async loadData(){const{readdir:e}=await import("node:fs/promises"),t=await import("node:path");try{const r=await e(this.storePath,{withFileTypes:!0}),n={by_uri:{}};for(const o of r){if(!o.isFile()||!o.name.endsWith(".json"))continue;const i=await this.loadMemoryFile(t.join(this.storePath,o.name));Object.assign(n.by_uri,i.by_uri)}return n}catch{return{by_uri:{}}}}async writeJsonAtomically(e,t,r=JSON.stringify(t,null,2)){const{rename:n,rm:o,writeFile:i}=await import("node:fs/promises"),s=`${e}.${process.pid}.${Date.now()}.tmp`;try{await i(s,r,"utf-8"),await n(s,e)}catch(d){throw await o(s,{force:!0}),d}}async saveData(e){const{readFile:t,readdir:r,rm:n}=await import("node:fs/promises"),o=await import("node:path");await this.ensureStoreDir();const i=new Map;for(const a of Object.values(e.by_uri)){const m=i.get(a.domain)??{by_uri:{}};m.by_uri[a.uri]=a,i.set(a.domain,m)}for(const[a,m]of i.entries()){const l=o.join(this.storePath,`${a}.json`),c=JSON.stringify(m,null,2);if(this.domainJsonCache.get(l)===c)continue;let u;try{u=await t(l,"utf-8")}catch{u=void 0}if(u===c){this.domainJsonCache.set(l,c);continue}await this.writeJsonAtomically(l,m,c),this.domainJsonCache.set(l,c)}const s=new Set([...i.keys()].map(a=>`${a}.json`)),d=await r(this.storePath,{withFileTypes:!0});for(const a of d)if(a.isFile()&&a.name.endsWith(".json")&&!s.has(a.name)){const m=o.join(this.storePath,a.name);await n(m,{force:!0}),this.domainJsonCache.delete(m)}}createEmptyStats(){return{total:0,listable:{count:0,limit:L,hardLimit:O,exceeded:!1,hardExceeded:!1},by_type:{instance_hotspot_memory:{count:0,limit:x,hardLimit:h,exceeded:!1,hardExceeded:!1,listable:!0,domainCount:0,by_domain:{}},instance_permanent_memory:{count:0,limit:x,hardLimit:h,exceeded:!1,hardExceeded:!1,listable:!0,domainCount:0,by_domain:{}},project_doc_memory:{count:0,limit:null,hardLimit:null,exceeded:!1,hardExceeded:!1,listable:!1,domainCount:0,by_domain:{}},session_context:{count:0,limit:null,hardLimit:g,exceeded:!1,hardExceeded:!1,listable:!1,domainCount:0,by_domain:{}}}}}calculateStats(e){const t=this.createEmptyStats();for(const r of Object.values(e.by_uri)){t.total+=1;const n=t.by_type[r.memory_type];n.count+=1;const o=d=>w.includes(d)?x:null,i=d=>w.includes(d)?h:d==="session_context"?g:null,s=n.by_domain[r.domain]??{count:0,limit:o(r.memory_type),hardLimit:i(r.memory_type),exceeded:!1,hardExceeded:!1};s.count+=1,n.by_domain[r.domain]=s,w.includes(r.memory_type)&&(t.listable.count+=1)}t.listable.exceeded=t.listable.count>t.listable.limit,t.listable.hardExceeded=t.listable.count>=t.listable.hardLimit;for(const r of M){const n=t.by_type[r];n.domainCount=Object.keys(n.by_domain).length,n.limit!==null&&n.hardLimit!==null&&(n.exceeded=n.domainCount>n.limit,n.hardExceeded=n.domainCount>=n.hardLimit);for(const o of Object.values(n.by_domain))o.limit!==null&&o.hardLimit!==null&&(o.exceeded=o.count>o.limit,o.hardExceeded=o.count>=o.hardLimit)}return t}generateId(e){return`${e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${Date.now().toString(36)}`}ensureListableMemoryCapacity(e,t,r){if(!w.includes(t))return;const o=this.calculateStats(e).by_type[t],i=o.by_domain[r.domain];if(!i&&o.domainCount>=h)throw new S(`Cannot create ${t}: hard domain type limit ${h} reached. Please delete an existing ${t} domain type before creating a new ${t}.`,{code:"MEMORY_TYPE_LIMIT_REACHED",memory_type:t,limit:h,current:o.domainCount,recommended_actions:[`list_memories({ memory_type: '${t}' })`,`delete_memory({ uri, memory_type: '${t}' })`]});if(i&&i.count>=h)throw new S(`Cannot create ${t}: hard memory limit ${h} reached under domain ${r.domain}. Please delete or archive existing ${r.domain}://${t} memories before creating a new one.`,{code:"MEMORY_TYPE_LIMIT_REACHED",memory_type:t,domain:r.domain,limit:h,current:i.count,recommended_actions:[`list_memories({ memory_type: '${t}' })`,`delete_memory({ uri, memory_type: '${t}' })`]})}ensureSessionContextCapacity(e,t,r){if(t!=="session_context")return;const n=Object.values(e.by_uri).filter(o=>o.memory_type==="session_context"&&o.domain===r.domain).length;if(n>=g)throw new S(`Cannot create session_context: hard limit ${g} reached under domain ${r.domain}. Please delete existing session_context memories before creating a new one.`,{code:"MEMORY_TYPE_LIMIT_REACHED",memory_type:t,domain:r.domain,limit:g,current:n,recommended_actions:["list_memories({ memory_type: 'session_context' })","delete_memory({ uri, memory_type: 'session_context' })"]})}async getStats(){const e=await this.loadData();return this.calculateStats(e)}static calcAgentMemoryExpiresAt(){return new Date(Date.now()+432e5).toISOString()}static isExpirableType(e){return e==="instance_hotspot_memory"}validateTypeConstraints(e,t){j(e,t)}async createMemory(e){const t=this.normalizeMemoryType(e.memory_type),r=this.normalizeUri(e.uri),n=await this.loadData();if(n.by_uri[r.uri])throw new Error(`Memory already exists: ${r.uri}`);this.validateTypeConstraints(t,e),this.ensureListableMemoryCapacity(n,t,r),this.ensureSessionContextCapacity(n,t,r);const o=this.nowIso(),i={id:this.generateId(r.uri),uri:r.uri,domain:r.domain,path:r.path,title:e.title||void 0,content:String(e.content||""),memory_type:t,createdAt:o,updatedAt:o,version:1,keywords:e.keywords,bound_files:e.bound_files,file_md5_map:e.file_md5_map||void 0,updating_agent_id:void 0,last_check_time:e.last_check_time||void 0,expiresAt:e.expiresAt||(b.isExpirableType(t)?b.calcAgentMemoryExpiresAt():void 0),memory_status:"normal"};return n.by_uri[r.uri]=i,await this.saveData(n),i}async readMemory(e){const t=this.normalizeUri(e.uri),r=typeof e.memory_type=="string"?this.normalizeMemoryType(e.memory_type):void 0,o=(await this.loadData()).by_uri[t.uri]??null;return o?(this.ensureTypeMatch(o,r),o):null}async updateMemory(e){const t=this.normalizeUri(e.uri),r=typeof e.memory_type=="string"?this.normalizeMemoryType(e.memory_type):void 0,n=await this.loadData(),o=n.by_uri[t.uri];if(!o)throw new Error(`Memory not found: ${t.uri}`);this.ensureTypeMatch(o,r);let i=o.content;if(typeof e.old_string=="string"&&typeof e.new_string=="string"){const l=e.old_string;if(!l)throw new Error("old_string cannot be empty when replacing");const c=i.split(l).length-1;if(c===0)throw new Error("old_string not found in memory content");if(c>1)throw new Error("old_string appears multiple times; replace is ambiguous");i=i.replace(l,e.new_string)}typeof e.append=="string"&&e.append.length>0&&(i=`${i}${e.append}`);const s=i!==o.content||typeof e.title=="string"&&e.title!==o.title,d=this.nowIso();if(Array.isArray(e.bound_files)){const l=(e.bound_files||[]).filter(c=>String(c||"").trim());if(o.memory_type==="instance_permanent_memory"&&l.length>0)throw new Error(`instance_permanent_memory \u4E0D\u8981\u6C42\u4E5F\u4E0D\u5EFA\u8BAE\u7ED1\u5B9A\u6587\u4EF6\uFF1A\u7ED1\u5B9A\u6587\u4EF6\u7684\u5185\u5BB9\u5C5E\u4E8E\u9879\u76EE\u6587\u6863\uFF0C\u5E94\u6539\u7528 project_doc_memory\u3002
|
|
20
|
+
`+p)}if(typeof e.title=="string"&&o.memory_type==="project_doc_memory"){const l=e.title.trim();if(!l)throw new Error("project_doc_memory \u7684 title \u4E0D\u80FD\u4E3A\u7A7A\u3002\u63A8\u8350\u683C\u5F0F\uFF1A\u300C<\u6A21\u5757/\u6587\u4EF6\u96C6> - <\u4E3B\u9898>\u300D\u3002");if(l.length>50)throw new Error(`project_doc_memory \u7684 title \u4E0D\u5F97\u8D85\u8FC7 50 \u5B57\uFF08\u5F53\u524D ${l.length} \u5B57\uFF09\u3002\u8BF7\u7CBE\u70BC\u4E3A\u300C<\u6A21\u5757/\u6587\u4EF6\u96C6> - <\u4E3B\u9898>\u300D\u5F62\u5F0F\u3002`)}if(s&&o.memory_type==="project_doc_memory"&&!/^##\s+\S/m.test(i))throw new Error(`project_doc_memory \u7684 content \u5FC5\u987B\u4FDD\u7559\u81F3\u5C11\u4E00\u4E2A markdown \u5C0F\u8282\uFF08## \u6807\u9898\uFF09\u3002
|
|
21
|
+
\u63A8\u8350\u6A21\u677F\uFF1A
|
|
22
|
+
## \u6982\u8FF0
|
|
23
|
+
## \u7ED3\u6784
|
|
24
|
+
## \u5173\u952E\u7ED3\u8BBA
|
|
25
|
+
## \u8E29\u5751
|
|
26
|
+
`);if(s&&o.memory_type==="instance_hotspot_memory"&&i.length>2e3)throw new Error(`instance_hotspot_memory \u7684 content \u4E0D\u5F97\u8D85\u8FC7 2000 \u5B57\uFF08\u5F53\u524D ${i.length} \u5B57\uFF09\u3002\u957F\u671F\u7ECF\u9A8C\u8BF7\u6539\u7528 instance_permanent_memory\uFF0C\u9879\u76EE\u6587\u6863\u8BF7\u6539\u7528 project_doc_memory\u3002`);let a=o.expiresAt;b.isExpirableType(o.memory_type)?a=new Date(Date.now()+24*60*60*1e3).toISOString():a=void 0,e.expiresAt!==void 0&&(a=e.expiresAt);const m={...o,content:i,title:e.title!==void 0?e.title:o.title,updatedAt:d,version:o.version+1,keywords:e.keywords!==void 0?e.keywords:o.keywords,bound_files:e.bound_files!==void 0?e.bound_files:o.bound_files,file_md5_map:e.file_md5_map!==void 0?e.file_md5_map:e.bound_files!==void 0?void 0:o.file_md5_map,memory_status:e.memory_status!==void 0?e.memory_status:o.memory_status==="updating"?"normal":o.memory_status||"normal",updating_agent_id:e.memory_status!==void 0?e.updating_agent_id||void 0:o.memory_status==="updating"?void 0:o.updating_agent_id,last_check_time:e.last_check_time!==void 0?e.last_check_time:o.last_check_time,expiresAt:a};return n.by_uri[t.uri]=m,await this.saveData(n),m}async deleteMemory(e){const t=this.normalizeUri(e.uri),r=typeof e.memory_type=="string"?this.normalizeMemoryType(e.memory_type):void 0,n=await this.loadData(),o=n.by_uri[t.uri];return o?(this.ensureTypeMatch(o,r),delete n.by_uri[t.uri],await this.saveData(n),!0):!1}async listExpiredRecentlyMemories(){const e=await this.loadData(),t=new Date,r=[];for(const n of Object.values(e.by_uri))n.memory_type==="instance_hotspot_memory"&&n.expiresAt&&(new Date(n.expiresAt)>t||n.memory_status==="recalling"&&n.updating_agent_id!==C||r.push(n));return r.sort((n,o)=>n.expiresAt.localeCompare(o.expiresAt))}async searchMemory(e){const t=await this.loadData(),n=String(e.query||"").trim().toLowerCase(),o=e.memory_type?this.normalizeMemoryType(e.memory_type):void 0,i=typeof e.limit=="number"&&e.limit>0?e.limit:10,s=e.keywords?.map(c=>c.toLowerCase()),d=e.keyword_mode==="all"?"all":"any",a=P(n);if(a.length===0&&(!s||s.length===0))return{query:n,results:[]};const m=new Set,l=[];for(const c of Object.values(t.by_uri)){if(o&&c.memory_type!==o||m.has(c.id))continue;let y=0;if(s&&s.length>0&&c.keywords){const u=c.keywords.map(f=>f.toLowerCase());if(d==="all"){if(s.every(E=>u.includes(E)))y+=10*s.length;else if(a.length===0)continue}else for(const f of s)u.includes(f)&&(y+=10)}if(a.length>0){const u=`${c.uri}
|
|
2
27
|
${c.title||""}
|
|
3
|
-
${c.content}`.toLowerCase();if(!
|
|
28
|
+
${c.content}`.toLowerCase();if(!z(a,u)&&y===0)continue;for(const f of a){const E=f.filter(T=>u.includes(T)).length;if(E>0){const T=c.uri.toLowerCase(),$=f.filter(D=>T.includes(D)).length;y+=E+$}}}y!==0&&(m.add(c.id),l.push({score:y,record:c}))}return l.sort((c,y)=>y.score!==c.score?y.score-c.score:y.record.updatedAt.localeCompare(c.record.updatedAt)),{query:n,results:l.slice(0,i).map(c=>c.record)}}async listByType(e){const t=e==="session_context"||e==="project_doc_memory"?M:w,r=this.normalizeMemoryType(e,t),n=await this.loadData(),o=new Set,i=[];for(const s of Object.values(n.by_uri))s.memory_type===r&&(o.has(s.id)||(o.add(s.id),i.push(s)));return i.sort((s,d)=>d.updatedAt.localeCompare(s.updatedAt)),i}async listByFile(e,t){const r=await this.loadData(),n=typeof t=="object"&&t!==null?t.memory_type:t,o=n?this.normalizeMemoryType(n):void 0,i=I(e),s=new Set,d=[];for(const a of Object.values(r.by_uri))o&&a.memory_type!==o||s.has(a.id)||a.bound_files&&a.bound_files.length>0&&a.bound_files.some(l=>I(l)===i)&&(s.add(a.id),d.push(a));return d.sort((a,m)=>m.updatedAt.localeCompare(a.updatedAt)),d}async markExpiredMemoriesRecalling(e){const t=await this.listExpiredRecentlyMemories();if(t.length===0)return{marked:0,uris:[]};const r=t.filter(a=>a.memory_status!=="recalling"),n=e?r.filter(a=>e.includes(a.uri)):r.slice(0,k);if(n.length===0){const a=t.filter(m=>m.memory_status==="recalling").map(m=>m.uri);return{marked:a.length,uris:a}}const o=await this.loadData(),i=this.nowIso(),s=new Date(Date.now()+R*60*1e3).toISOString(),d=[];for(const a of n){const m=o.by_uri[a.uri];m&&(m.memory_status="recalling",m.updating_agent_id=C,m.lease_expires_at=s,m.updatedAt=i,m.version=(m.version||1)+1,d.push(a.uri))}return d.length>0&&await this.saveData(o),{marked:d.length,uris:d}}async clearRecallingExpiredMemories(e){const t=await this.loadData(),r=new Date,n=[];for(const o of Object.values(t.by_uri))b.isExpirableType(o.memory_type)&&o.memory_status==="recalling"&&o.updating_agent_id===C&&o.expiresAt&&(new Date(o.expiresAt)>r||n.push(o.uri));if(e){const o=new Set(e),i=n.filter(s=>o.has(s));n.length=0,n.push(...i)}if(n.length===0)return{deleted:0,uris:[]};for(const o of n)delete t.by_uri[o];return await this.saveData(t),{deleted:n.length,uris:n}}async claimMemoryUpdate(e,t,r){throw new Error("claimMemoryUpdate not supported in local MemoryStore")}async renewMemoryLease(e){throw new Error("renewMemoryLease not supported in local MemoryStore")}async releaseMemoryClaim(e){throw new Error("releaseMemoryClaim not supported in local MemoryStore")}async releaseAllMemoryClaims(){throw new Error("releaseAllMemoryClaims not supported in local MemoryStore")}async getMyClaimedUris(){throw new Error("getMyClaimedUris not supported in local MemoryStore")}}export{A as LEGACY_MEMORY_TYPE_ALIASES,p as MEMORY_TYPE_GUIDE,S as MemoryCapacityError,b as MemoryStore,I as normalizeBoundFilePath,Y as normalizeMemoryTypeName,j as validateTypeConstraints};
|
|
4
29
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const r=`\u8BB0\u5FC6\u7C7B\u578B\u4E09\u9009\u4E00\uFF08\u6309\u300C\u8FD9\u6761\u5185\u5BB9\u672A\u6765\u88AB\u8C01\u8BFB\u5230\u3001\u4F55\u65F6\u8BFB\u5230\u300D\u9009\u62E9\uFF09\uFF1A
|
|
2
|
+
- instance_hotspot_memory \u5B9E\u4F8B\u70ED\u70B9\u8BB0\u5FC6\uFF1A\u4E0B\u6B21\u4F1A\u8BDD\u5F00\u573A\u5C31\u8981\u7528\u7684\u5DE5\u4F5C\u72B6\u6001\uFF08\u8FDB\u5EA6/\u5F85\u529E/\u4E34\u65F6\u7ED3\u8BBA\uFF09\u3002\u6761\u6570\u6709\u9650\u3001\u77ED TTL\uFF0C\u81EA\u52A8\u6CE8\u5165\u4E0B\u6B21\u4F1A\u8BDD\u8BB0\u5FC6\u5757\u3002\u7981\u6B62\u5B58\u957F\u671F\u7ECF\u9A8C\u4E0E\u9879\u76EE\u6587\u6863\u3002
|
|
3
|
+
- instance_permanent_memory \u5B9E\u4F8B\u6C38\u4E45\u8BB0\u5FC6\uFF1A\u672C\u5B9E\u4F8B\u5BF9\u73AF\u5883/\u5DE5\u5177/\u6D41\u7A0B\u7684\u957F\u671F\u7ECF\u9A8C\u7ED3\u8BBA\uFF08\u6559\u8BAD/\u7EA6\u5B9A/\u80FD\u529B\u8FB9\u754C\uFF09\u3002\u65E0\u8FC7\u671F\uFF0C\u9760 search_memory \u68C0\u7D22\u3002\u4E0D\u8981\u6C42\u7ED1\u5B9A\u6587\u4EF6\u3002
|
|
4
|
+
- project_doc_memory \u9879\u76EE\u6587\u6863\u8BB0\u5FC6\uFF1A\u5BF9\u9879\u76EE\u6587\u4EF6\u96C6\u7684\u5BA2\u89C2\u7B14\u8BB0\uFF08\u67B6\u6784/\u6A21\u5757\u804C\u8D23/\u63A5\u53E3\u7EA6\u5B9A/\u5751\u70B9\uFF09\u3002\u5E94\u5C3D\u91CF\u7528 bound_files \u5173\u8054\u6587\u4EF6\uFF0C\u6807\u9898\u5FC5\u586B\uFF08\u226450 \u5B57\uFF0C\u300C<\u6A21\u5757/\u6587\u4EF6\u96C6> - <\u4E3B\u9898>\u300D\uFF09\uFF0C\u5185\u5BB9\u9700\u542B markdown \u5C0F\u8282\uFF08## \uFF09\uFF0C\u89D2\u8272\u7EA7\u5171\u4EAB\u3001\u968F\u6587\u4EF6\u53D8\u66F4\u7EF4\u62A4\u3002
|
|
5
|
+
\u9009\u62E9\u89C4\u5219\uFF1A\u5185\u5BB9\u6307\u5411\u5177\u4F53\u9879\u76EE\u6587\u4EF6\u3001\u9700\u968F\u6587\u4EF6\u53D8\u66F4\u7EF4\u62A4 \u2192 project_doc_memory\uFF1B\u73AF\u5883/\u5DE5\u5177\u7ECF\u9A8C\u3001\u4E0D\u6307\u5411\u5177\u4F53\u6587\u4EF6 \u2192 instance_permanent_memory\uFF1B\u672C\u6B21\u4EFB\u52A1\u8FDB\u5EA6\u3001\u4E0B\u6B21\u4F1A\u8BDD\u63A5\u7740\u5E72 \u2192 instance_hotspot_memory\u3002
|
|
6
|
+
\u53CD\u4F8B\uFF1A\u628A\u300Cpptx \u5706\u89D2\u8981\u5199 round_rect\u300D\u5199\u8FDB hotspot \u662F\u9519\u7684\uFF08\u5B83\u662F\u6C38\u4E45\u7ECF\u9A8C\uFF09\uFF1B\u628A\u300C\u9879\u76EE API \u5728 src/api \u4E0B\u300D\u5199\u8FDB permanent \u662F\u9519\u7684\uFF08\u5B83\u662F\u9879\u76EE\u6587\u6863\uFF09\u3002`,e={type:"string",enum:["instance_hotspot_memory","instance_permanent_memory","project_doc_memory"],description:r},n={type:"string",enum:["instance_hotspot_memory","instance_permanent_memory","project_doc_memory","session_context"],description:"\u53EF\u76F4\u63A5\u5217\u51FA\u7684\u8BB0\u5FC6\u7C7B\u578B\u3002instance_permanent_memory \u4E3B\u8981\u7528 search_memory \u68C0\u7D22\uFF1Bproject_doc_memory \u4E0E session_context \u540C\u6837\u652F\u6301 list\u3002"},t={type:"string",description:"\u8BB0\u5FC6 URI\uFF0C\u683C\u5F0F\u4E3A domain://path\uFF0C\u4F8B\u5982 core://agent/profile \u6216 task://todo/current\u3002domain \u4F1A\u81EA\u52A8\u8F6C\u5C0F\u5199\u3002"},o={name:"create_memory",description:"\u5728\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u521B\u5EFA\u4E00\u6761\u672C\u5730\u8BB0\u5FC6\u3002\u4E09\u79CD\u7C7B\u578B\u5B9A\u4F4D\u4E0D\u540C\uFF0C\u5199\u9519\u7C7B\u578B\u4F1A\u88AB\u62D2\u7EDD\u5E76\u63D0\u793A\u6B63\u786E\u5F52\u5BBF\uFF1B\u540C\u4E00 uri \u5DF2\u5B58\u5728\u65F6\u4F1A\u5931\u8D25\uFF0C\u907F\u514D\u610F\u5916\u8986\u76D6\u3002",inputSchema:{type:"object",properties:{memory_type:{type:"string",enum:["instance_hotspot_memory","instance_permanent_memory","project_doc_memory"],description:r},uri:t,title:{type:"string",description:"\u8BB0\u5FC6\u6807\u9898\uFF0C\u7528\u4E8E\u5FEB\u901F\u8BC6\u522B\u8BB0\u5FC6\u5185\u5BB9\u3002project_doc_memory \u4E0E instance_hotspot_memory \u5FC5\u586B\uFF1Bproject_doc_memory \u6807\u9898\u987B \u226450 \u5B57\uFF0C\u63A8\u8350\u300C<\u6A21\u5757/\u6587\u4EF6\u96C6> - <\u4E3B\u9898>\u300D\u683C\u5F0F\u3002"},content:{type:"string",description:"\u8BB0\u5FC6\u5185\u5BB9\u3002project_doc_memory \u5FC5\u987B\u542B\u81F3\u5C11\u4E00\u4E2A markdown \u5C0F\u8282\uFF08## \u6807\u9898\uFF09\uFF0C\u6309\u300C\u6982\u8FF0/\u7ED3\u6784/\u5173\u952E\u7ED3\u8BBA/\u8E29\u5751\u300D\u7EC4\u7EC7\u5BA2\u89C2\u7B14\u8BB0\uFF1Binstance_hotspot_memory \u4E0D\u8D85\u8FC7 2000 \u5B57\u3002"},keywords:{type:"array",items:{type:"string"},description:'\u5173\u952E\u8BCD\u5217\u8868\uFF0C\u7528\u4E8E\u5FEB\u901F\u641C\u7D22\u548C\u5206\u7C7B\uFF0C\u4F8B\u5982 ["React", "\u524D\u7AEF", "\u6700\u4F73\u5B9E\u8DF5"]\u3002'},bound_files:{type:"array",items:{type:"string"},description:`\u7ED1\u5B9A\u7684\u6587\u4EF6\u8DEF\u5F84\u5217\u8868\uFF0C\u7528\u4E8E\u81EA\u52A8\u68C0\u6D4B\u6587\u4EF6\u53D8\u66F4\u5E76\u63D0\u9192\u66F4\u65B0\u8BB0\u5FC6\uFF0C\u4F8B\u5982 ["./path/to/file.md"]\u3002\uFF08/ \u524D\u7F00\u4F1A\u88AB\u89C6\u4E3A\u5DE5\u4F5C\u533A\u6839\u8DEF\u5F84\uFF0C\u7EDF\u4E00\u8F6C\u4E3A ./\uFF09
|
|
7
|
+
project_doc_memory \u5FC5\u586B\uFF08\u81F3\u5C11\u4E00\u4E2A\u6587\u4EF6\uFF09\uFF1Binstance_permanent_memory \u7981\u6B62\u7ED1\u5B9A\uFF08\u7ED1\u5B9A\u6587\u4EF6\u7684\u5185\u5BB9\u5C5E\u4E8E\u9879\u76EE\u6587\u6863\uFF0C\u8BF7\u6539\u7528 project_doc_memory\uFF09\u3002`}},required:["memory_type","uri","content"]}},i={name:"read_memory",description:"\u6309 uri \u8BFB\u53D6\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u7684\u4E00\u6761\u672C\u5730\u8BB0\u5FC6\u3002\u53EF\u4F20 memory_type \u505A\u7C7B\u578B\u6821\u9A8C\uFF0C\u907F\u514D\u8BFB\u9519\u5206\u7C7B\u3002",inputSchema:{type:"object",properties:{uri:t,memory_type:e},required:["uri"]}},m={name:"update_memory",description:"\u66F4\u65B0\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u7684\u4E00\u6761\u672C\u5730\u8BB0\u5FC6\u3002\u652F\u6301\u4E09\u79CD\u5199\u6CD5\uFF1A1) \u7CBE\u786E\u66FF\u6362\u65F6\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B old_string \u548C new_string\uFF1B2) \u8FFD\u52A0\u65F6\u53EA\u63D0\u4F9B append\uFF1B3) \u4EC5\u4F20 uri\uFF08\u4E0D\u63D0\u4F9B\u5185\u5BB9\u53C2\u6570\uFF09\u505A\u65E0\u5185\u5BB9\u66F4\u65B0\u2014\u2014\u6B64\u65F6\u5185\u5BB9\u4E0D\u53D8\uFF0C\u4F46\u4F1A\u5237\u65B0\u7ED1\u5B9A\u6587\u4EF6 MD5\u3001\u91CA\u653E updating \u72B6\u6001\u3001\u5E76\u5BF9 instance_hotspot_memory \u7EED\u671F\uFF08\u56FA\u5B9A 24h TTL\uFF09\u3002\u82E5\u8BB0\u5FC6\u4E0D\u5B58\u5728\u8BF7\u4F7F\u7528 create_memory\u3002",inputSchema:{type:"object",properties:{uri:t,memory_type:e,title:{type:"string",description:"\u66F4\u65B0\u6807\u9898\u3002\u4F20\u5165\u6B64\u5B57\u6BB5\u4F1A\u8986\u76D6\u73B0\u6709\u6807\u9898\u3002"},old_string:{type:"string",minLength:1,description:"\u8981\u88AB\u66FF\u6362\u7684\u65E7\u5185\u5BB9\u3002\u66FF\u6362\u65F6\u5FC5\u987B\u4E0E new_string \u540C\u65F6\u4F20\u5165\uFF1B\u8FFD\u52A0\u6216\u4EC5\u72B6\u6001\u66F4\u65B0\u65F6\u4E0D\u8981\u4F20\u6B64\u5B57\u6BB5\u3002"},new_string:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u5185\u5BB9\u3002\u66FF\u6362\u65F6\u5FC5\u987B\u4E0E old_string \u540C\u65F6\u4F20\u5165\uFF1B\u8FFD\u52A0\u6216\u4EC5\u72B6\u6001\u66F4\u65B0\u65F6\u4E0D\u8981\u4F20\u6B64\u5B57\u6BB5\u3002\u5141\u8BB8\u4E3A\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u5220\u9664\u65E7\u5185\u5BB9\u3002"},append:{type:"string",minLength:1,description:"\u8FFD\u52A0\u5230\u8BB0\u5FC6\u672B\u5C3E\u7684\u5185\u5BB9\u3002\u8FFD\u52A0\u65F6\u53EA\u4F20 append\uFF0C\u4E0D\u8981\u4F20 old_string/new_string\u3002"},keywords:{type:"array",items:{type:"string"},description:"\u66F4\u65B0\u5173\u952E\u8BCD\u5217\u8868\u3002"},bound_files:{type:"array",items:{type:"string"},description:"\u66F4\u65B0\u7ED1\u5B9A\u6587\u4EF6\u8DEF\u5F84\u5217\u8868\u3002\u66F4\u65B0\u540E\u4F1A\u91CD\u65B0\u8BA1\u7B97\u6587\u4EF6 MD5\u3002"}},required:["uri"]}},p={name:"delete_memory",description:`\u5220\u9664\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u7684\u672C\u5730\u8BB0\u5FC6\u3002\u652F\u6301\u4E24\u79CD\u8C03\u7528\u65B9\u5F0F\uFF08uri \u4E0E memories \u4E92\u65A5\uFF09\uFF1A
|
|
4
8
|
1) \u5355\u6761\uFF1A\u4F20 uri\uFF08+ \u53EF\u9009 memory_type \u505A\u7C7B\u578B\u6821\u9A8C\uFF09\uFF0C\u8FD4\u56DE { deleted: boolean }\u3002
|
|
5
9
|
2) \u6279\u91CF\uFF1A\u4F20 memories \u6570\u7EC4\uFF0C\u6BCF\u9879\u4E3A { uri, memory_type? }\uFF08\u5B57\u6BB5\u7ED3\u6784\u4E0E read_memory \u4E00\u81F4\uFF09\uFF0C\u8FD4\u56DE { deleted: number, not_found: string[], failed: Array<{uri, reason}> }\u3002
|
|
6
10
|
\u6279\u91CF\u6A21\u5F0F\u9010\u6761\u5220\u9664\uFF0C\u5355\u6761\u5931\u8D25\uFF08\u7C7B\u578B\u4E0D\u5339\u914D\u7B49\uFF09\u4E0D\u963B\u65AD\u5176\u4ED6\uFF1B\u6BCF\u6761\u53EF\u72EC\u7ACB\u6307\u5B9A memory_type\uFF0C\u7701\u7565\u65F6\u7531\u7CFB\u7EDF\u81EA\u52A8\u5224\u5B9A\u3002
|
|
7
|
-
\u9002\u7528\u573A\u666F\uFF1A\u8FC7\u671F\u56DE\u5FC6\u6D41\u7A0B\u4E2D recalling \u72B6\u6001\
|
|
11
|
+
\u9002\u7528\u573A\u666F\uFF1A\u8FC7\u671F\u56DE\u5FC6\u6D41\u7A0B\u4E2D\u6279\u91CF\u6E05\u7406 recalling \u72B6\u6001\u7684 instance_hotspot_memory\u3002`,inputSchema:{type:"object",properties:{uri:t,memory_type:e,memories:{type:"array",items:{type:"object",properties:{uri:t,memory_type:e},required:["uri"]},description:"\u6279\u91CF\u5220\u9664\u7684\u6761\u76EE\u5217\u8868\uFF0C\u6BCF\u9879\u4E3A { uri, memory_type? }\u3002\u4E0E uri \u4E92\u65A5\u3002memory_type \u53EF\u9009\uFF0C\u4E0D\u4F20\u65F6\u7531\u7CFB\u7EDF\u81EA\u52A8\u5224\u5B9A\u7C7B\u578B\u3002"}},anyOf:[{required:["uri"]},{required:["memories"]}]}},s={name:"search_memory",description:`\u6309\u5173\u952E\u5B57\u641C\u7D22\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u7684\u672C\u5730\u8BB0\u5FC6\u3002\u4F1A\u540C\u65F6\u5339\u914D uri\u3001title \u4E0E content\uFF0C\u4F18\u5148\u6309\u5173\u952E\u8BCD\u5339\u914D\uFF0C\u7136\u540E\u6309\u5185\u5BB9\u5339\u914D\u3002\u652F\u6301scope\u53C2\u6570\u641C\u7D22\u5B50Agent\uFF08\u5DE5\u4F5C\u533A\u8DEF\u5F84\u4E3A\u5F53\u524D\u8DEF\u5F84\u5B50\u76EE\u5F55\u7684Agent\uFF09\u7ED1\u5B9A\u4E86\u6587\u4EF6\u7684\u8BB0\u5FC6\u3002
|
|
8
12
|
|
|
9
13
|
\u3010\u641C\u7D22\u8BED\u6CD5\u3011
|
|
10
14
|
- OR \u641C\u7D22\uFF1A\u4F7F\u7528 | \u5206\u9694\u591A\u4E2A\u8BCD\uFF0C\u5339\u914D\u4EFB\u4E00\u5373\u8FD4\u56DE\u3002\u4F8B\u5982\u300C\u67B6\u6784|\u6280\u672F\u300D\u5339\u914D\u5305\u542B\u300C\u67B6\u6784\u300D\u6216\u300C\u6280\u672F\u300D\u7684\u8BB0\u5F55\u3002
|
|
@@ -18,15 +22,15 @@ const e={type:"string",enum:["instance_memory","instance_long_memory","project_m
|
|
|
18
22
|
|
|
19
23
|
\u3010\u641C\u7D22\u6548\u7387\u3011
|
|
20
24
|
- \u641C\u7D22\u7ED3\u679C\u4F7F\u7528 5 \u79D2\u5185\u5B58\u7F13\u5B58\uFF0C\u8FDE\u7EED\u641C\u7D22\u4E0D\u4F1A\u91CD\u590D\u8BFB\u76D8\u3002
|
|
21
|
-
- \u8BB0\u5FC6\u5199\u5165\u64CD\u4F5C\u4F1A\u81EA\u52A8\u6E05\u9664\u7F13\u5B58\uFF0C\u786E\u4FDD\u6570\u636E\u4E00\u81F4\u6027\u3002`,inputSchema:{type:"object",properties:{query:{type:"string",description:"\u641C\u7D22\u5173\u952E\u5B57\u3002\u652F\u6301 | OR \u5206\u9694\u7B26\u548C\u7A7A\u683C AND \u8BCD\u7EC4\u3002\u4F8B\u5982\u300C\u67B6\u6784|\u6280\u672F \u8BBE\u8BA1\u300D\u8868\u793A\u641C\u7D22\u5305\u542B\u300C\u67B6\u6784\u300D\u6216\u540C\u65F6\u5305\u542B\u300C\u6280\u672F+\u8BBE\u8BA1\u300D\u7684\u8BB0\u5F55\u3002"},limit:{type:"number",description:"\u6700\u591A\u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4 10\u3002"},memory_type:e,keywords:{type:"array",items:{type:"string"},description:"\u6309\u5173\u952E\u8BCD\u8FC7\u6EE4\u3002\u914D\u5408 keyword_mode \u63A7\u5236\u5339\u914D\u903B\u8F91\uFF08any=\u4EFB\u4E00\u5339\u914D\uFF0Call=\u5168\u90E8\u5339\u914D\uFF09\u3002\u5173\u952E\u8BCD\u5339\u914D\u4F18\u5148\u7EA7\u9AD8\u4E8E\u5185\u5BB9\u5339\u914D\u3002"},keyword_mode:{type:"string",enum:["any","all"],description:"\u5173\u952E\u8BCD\u8FC7\u6EE4\u6A21\u5F0F\uFF1Aany\uFF08\u9ED8\u8BA4\uFF0C\u4EFB\u4E00\u5173\u952E\u8BCD\u5339\u914D\u5373\u9009\u4E2D\uFF09\u3001all\uFF08\u6240\u6709\u5173\u952E\u8BCD\u90FD\u9700\u5339\u914D\uFF09\u3002"},scope:{type:"string",enum:["own","children","all"],description:"\u641C\u7D22\u8303\u56F4\uFF1Aown\uFF08\u9ED8\u8BA4\uFF0C\u4EC5\u641C\u7D22\u81EA\u5DF1\u7684\u8BB0\u5FC6\uFF09\u3001children\uFF08\u641C\u7D22\u5B50Agent\u7ED1\u5B9A\u4E86\u6587\u4EF6\u7684\u8BB0\u5FC6\uFF09\u3001all\uFF08\u5408\u5E76\u641C\u7D22\u81EA\u5DF1\u548C\u5B50Agent\u7684\u8BB0\u5FC6\uFF09\u3002"}},required:["query"]}},
|
|
22
|
-
\u8FC7\u671F\u6761\u4EF6\
|
|
25
|
+
- \u8BB0\u5FC6\u5199\u5165\u64CD\u4F5C\u4F1A\u81EA\u52A8\u6E05\u9664\u7F13\u5B58\uFF0C\u786E\u4FDD\u6570\u636E\u4E00\u81F4\u6027\u3002`,inputSchema:{type:"object",properties:{query:{type:"string",description:"\u641C\u7D22\u5173\u952E\u5B57\u3002\u652F\u6301 | OR \u5206\u9694\u7B26\u548C\u7A7A\u683C AND \u8BCD\u7EC4\u3002\u4F8B\u5982\u300C\u67B6\u6784|\u6280\u672F \u8BBE\u8BA1\u300D\u8868\u793A\u641C\u7D22\u5305\u542B\u300C\u67B6\u6784\u300D\u6216\u540C\u65F6\u5305\u542B\u300C\u6280\u672F+\u8BBE\u8BA1\u300D\u7684\u8BB0\u5F55\u3002"},limit:{type:"number",description:"\u6700\u591A\u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4 10\u3002"},memory_type:e,keywords:{type:"array",items:{type:"string"},description:"\u6309\u5173\u952E\u8BCD\u8FC7\u6EE4\u3002\u914D\u5408 keyword_mode \u63A7\u5236\u5339\u914D\u903B\u8F91\uFF08any=\u4EFB\u4E00\u5339\u914D\uFF0Call=\u5168\u90E8\u5339\u914D\uFF09\u3002\u5173\u952E\u8BCD\u5339\u914D\u4F18\u5148\u7EA7\u9AD8\u4E8E\u5185\u5BB9\u5339\u914D\u3002"},keyword_mode:{type:"string",enum:["any","all"],description:"\u5173\u952E\u8BCD\u8FC7\u6EE4\u6A21\u5F0F\uFF1Aany\uFF08\u9ED8\u8BA4\uFF0C\u4EFB\u4E00\u5173\u952E\u8BCD\u5339\u914D\u5373\u9009\u4E2D\uFF09\u3001all\uFF08\u6240\u6709\u5173\u952E\u8BCD\u90FD\u9700\u5339\u914D\uFF09\u3002"},scope:{type:"string",enum:["own","children","all"],description:"\u641C\u7D22\u8303\u56F4\uFF1Aown\uFF08\u9ED8\u8BA4\uFF0C\u4EC5\u641C\u7D22\u81EA\u5DF1\u7684\u8BB0\u5FC6\uFF09\u3001children\uFF08\u641C\u7D22\u5B50Agent\u7ED1\u5B9A\u4E86\u6587\u4EF6\u7684\u8BB0\u5FC6\uFF09\u3001all\uFF08\u5408\u5E76\u641C\u7D22\u81EA\u5DF1\u548C\u5B50Agent\u7684\u8BB0\u5FC6\uFF09\u3002"}},required:["query"]}},_={name:"list_memories",description:"\u6309\u7C7B\u578B\u5217\u51FA\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u7684\u70ED\u70B9/\u6C38\u4E45/\u9879\u76EE\u6587\u6863\u8BB0\u5FC6\uFF0C\u652F\u6301\u5206\u9875\u3002\u53EF\u5217\u7C7B\u578B\uFF1Ainstance_hotspot_memory\u3001instance_permanent_memory\u3001project_doc_memory\u3001session_context\u3002\u5206\u9875\u53C2\u6570\u5747\u4E3A\u53EF\u9009\uFF1Aoffset\uFF08\u504F\u79FB\u91CF\uFF0C\u4ECE 0 \u5F00\u59CB\uFF0C\u9ED8\u8BA4 0\uFF09\u3001limit\uFF08\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 30\uFF09\u3002\u8FD4\u56DE\u7ED3\u679C\u5305\u542B\u5206\u9875\u5143\u4FE1\u606F { memory_type, total, offset, limit, has_more, memories }\uFF0Chas_more \u4E3A true \u65F6\u53EF\u7528\u589E\u5927 offset \u7EE7\u7EED\u7FFB\u9875\u3002instance_permanent_memory \u4E3B\u8981\u7528 search_memory \u68C0\u7D22\uFF1Bproject_doc_memory \u540C\u6837\u652F\u6301 list\u3002",inputSchema:{type:"object",properties:{memory_type:n,offset:{type:"integer",minimum:0,description:"\u5206\u9875\u504F\u79FB\u91CF\uFF0C\u8DF3\u8FC7\u524D N \u6761\u8BB0\u5F55\uFF08\u4ECE 0 \u5F00\u59CB\uFF09\uFF0C\u9ED8\u8BA4 0\u3002"},limit:{type:"integer",minimum:1,description:"\u6BCF\u9875\u8FD4\u56DE\u7684\u6761\u6570\uFF0C\u9ED8\u8BA4 30\u3002"}},required:["memory_type"]}},c={name:"get_memory_stats",description:"\u83B7\u53D6\u5F53\u524D Agent \u5DE5\u4F5C\u533A\u672C\u5730\u8BB0\u5FC6\u7684\u5BB9\u91CF\u7EDF\u8BA1\u3002\u9ED8\u8BA4\u8FD4\u56DE\u5373\u65F6/\u957F\u671F/\u9879\u76EE\u603B\u6570\u3001\u5373\u65F6/\u957F\u671F\u4E0B\u7684 URI domain \u7C7B\u578B\u5360\u7528\u3001\u4EE5\u53CA\u6BCF\u4E2A domain \u4E0B memory \u6761\u6570\u5360\u7528\u3002",inputSchema:{type:"object",properties:{memory_type:{...e,description:"\u8BB0\u5FC6\u7C7B\u578B\uFF08\u53EF\u9009\uFF09\u3002\u4E0D\u4F20\u65F6\u8FD4\u56DE\u5373\u65F6/\u957F\u671F/\u9879\u76EE\u603B\u6570\u4E0E\u5404 domain \u5360\u7528\u7EDF\u8BA1\uFF1B\u4F20\u6307\u5B9A\u7C7B\u578B\u65F6\u53EA\u8FD4\u56DE\u8BE5\u7C7B\u578B\u7684\u5360\u7528\u8BE6\u60C5\u3002"}},required:[]}},y={name:"list_memories_by_file",description:"\u67E5\u8BE2\u7ED1\u5B9A\u4E86\u6307\u5B9A\u6587\u4EF6\u7684\u6240\u6709 Memory\u3002\u9ED8\u8BA4\u5408\u5E76\u641C\u7D22\u81EA\u8EAB\u3001\u540C\u5DE5\u4F5C\u8DEF\u5F84\u5176\u4ED6\u89D2\u8272\uFF08\u540Cbridge\u5B9E\u4F8B\uFF09\u4E0E\u5B50Agent\uFF08\u5DE5\u4F5C\u533A\u8DEF\u5F84\u4E3A\u5F53\u524D\u8DEF\u5F84\u5B50\u76EE\u5F55\u7684Agent\uFF09\u7ED1\u5B9A\u4E86\u6587\u4EF6\u7684\u8BB0\u5FC6\u3002\u5B50Agent\u7684\u8BB0\u5FC6\u4F1A\u505Apath_prefix\u81EA\u52A8\u5339\u914D\uFF0C\u65E0\u9700\u624B\u52A8\u8BA1\u7B97\u8DEF\u5F84\u3002\u540C\u5DE5\u4F5C\u8DEF\u5F84\u5176\u4ED6\u89D2\u8272\u7684\u5171\u4EAB\u8BB0\u5FC6\u4EC5\u9650\u7ED1\u5B9A\u6587\u4EF6\u7684 project_doc_memory\uFF0C\u5E26 readonly=true \u4E0E source_role_name \u6765\u6E90\u6807\u8BB0\uFF0C\u53EA\u8BFB\u4E0D\u53EF\u4FEE\u6539\u3002\u4F8B\u5982\u7236Agent\u641C\u7D22 ./a/b/c/src/a.txt\uFF0C\u5B50Agent(\u5DE5\u4F5C\u8DEF\u5F84./a/b/c)\u7ED1\u5B9A./src/a.txt\u7684\u8BB0\u5FC6\u4F1A\u88AB\u81EA\u52A8\u5339\u914D\u3002",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF0C\u4F8B\u5982 /path/to/file.md"},memory_type:e,scope:{type:"string",enum:["own","children","all"],description:"\u641C\u7D22\u8303\u56F4\uFF1Aown\uFF08\u4EC5\u641C\u7D22\u81EA\u5DF1\u7684\u8BB0\u5FC6\uFF09\u3001children\uFF08\u641C\u7D22\u5B50Agent\u7ED1\u5B9A\u4E86\u6587\u4EF6\u7684\u8BB0\u5FC6\uFF0C\u6309path_prefix\u81EA\u52A8\u5339\u914D\uFF09\u3001all\uFF08\u9ED8\u8BA4\uFF0C\u5408\u5E76\u641C\u7D22\u81EA\u5DF1\u3001\u540C\u5DE5\u4F5C\u8DEF\u5F84\u5176\u4ED6\u89D2\u8272\u7684\u53EA\u8BFB\u5171\u4EAB\u8BB0\u5FC6\uFF08\u4EC5 project_doc_memory\uFF09\u3001\u5B50Agent\u7684\u8BB0\u5FC6\uFF09\u3002"}},required:["file_path"]}},a={name:"abandon_memory_update",description:"\u653E\u5F03\u6307\u5B9A Memory \u7684\u66F4\u65B0\u4E2D\u72B6\u6001\u3002\u5F53\u7CFB\u7EDF\u68C0\u6D4B\u5230\u6587\u4EF6\u53D8\u66F4\u5E76\u81EA\u52A8\u6807\u8BB0\u4E3A\u66F4\u65B0\u4E2D\u540E\uFF0C\u5982\u679C Agent \u51B3\u5B9A\u6682\u4E0D\u66F4\u65B0\uFF0C\u53EF\u4EE5\u8C03\u7528\u6B64\u5DE5\u5177\u6E05\u9664\u66F4\u65B0\u6807\u8BB0\u3002\u6CE8\u610F\uFF1A\u82E5\u5F53\u524D\u5DF2\u7ED1\u5B9A\u7684\u6587\u4EF6\u4E2D\u5B58\u5728\u5DF2\u5220\u9664\u7684\u6587\u4EF6\uFF0C\u653E\u5F03\u66F4\u65B0\u5C06\u5931\u8D25\uFF0C\u9700\u5148\u901A\u8FC7 update_memory \u4FEE\u6B63 bound_files \u5217\u8868\uFF08\u79FB\u9664\u4E0D\u5B58\u5728\u7684\u6587\u4EF6\uFF09\u3002",inputSchema:{type:"object",properties:{uri:t,memory_type:e},required:["uri"]}},d={name:"memory_recurrence",description:`\u83B7\u53D6\u5DF2\u8FC7\u671F\u7684\u53EF\u8FC7\u671F\u8BB0\u5FC6\uFF08\u4EC5 instance_hotspot_memory \u5B9E\u4F8B\u70ED\u70B9\u8BB0\u5FC6\uFF1Binstance_permanent_memory / project_doc_memory \u65E0\u8FC7\u671F\uFF09\u3002
|
|
26
|
+
\u8FC7\u671F\u6761\u4EF6\uFF1Aexpires_at < NOW()\u3002\u521D\u59CB TTL 12h\uFF1Bupdate_memory \u7EED\u671F\u5237\u65B0\u4E3A\u56FA\u5B9A 24h\u3002
|
|
23
27
|
\u8C03\u7528\u540E\uFF0C\u7CFB\u7EDF\u4F1A\u539F\u5B50\u8BA4\u9886\u6700\u591A 50 \u6761\u5DF2\u8FC7\u671F\u8BB0\u5FC6\u4E3A[\u56DE\u5FC6\u4E2D](recalling)\u72B6\u6001\uFF08\u8BA4\u9886\u8005+\u8BA4\u9886\u79DF\u7EA6\uFF0C\u5E42\u7B49\u53EF\u91CD\u590D\u8C03\u7528\uFF09\u3002
|
|
24
28
|
\u5DF2\u7EED\u671F\u7684\u8BB0\u5FC6\uFF08expiresAt \u5728\u672A\u6765\uFF09\u4E0D\u4F1A\u518D\u6B21\u51FA\u73B0\uFF1B\u51B3\u5B9A\u4E0D\u4FDD\u7559\u7684\u8BB0\u5FC6\u4FDD\u6301[\u56DE\u5FC6\u4E2D]\u72B6\u6001\uFF0C
|
|
25
29
|
\u5728\u672C\u6279\u5BA1\u67E5\u5B8C\u6BD5\u540E\u901A\u8FC7 memory_recurrence_complete \u6E05\u7406\u5220\u9664\u3002
|
|
26
30
|
Agent \u5E94\u5BA1\u67E5\u8FD9\u4E9B\u8BB0\u5FC6\u5185\u5BB9\uFF0C\u51B3\u5B9A\u662F\uFF1A
|
|
27
31
|
1) \u901A\u8FC7 update_memory \u7EED\u671F\uFF08\u7EED\u671F\u540E\u4E0D\u518D\u88AB\u672C\u6D41\u7A0B\u56DE\u6536\uFF09
|
|
28
|
-
2) \u4E0D\u7EED\u671F\uFF0C\u672C\u6279\u5BA1\u67E5\u5B8C\u6BD5\u540E\u8C03\u7528 memory_recurrence_complete \u5220\u9664\u5B83\u4EEC`,inputSchema:{type:"object",properties:{limit:{type:"number",description:"\u6BCF\u6B21\u6279\u91CF\u5904\u7406\u7684\u8BB0\u5FC6\u6570\u91CF\uFF08\u6309\u8FC7\u671F\u65F6\u95F4\u6700\u65E9\u4F18\u5148\uFF0C\u9ED8\u8BA4 10\uFF09\u3002\u4F8B\u5982 totalExpired=40\u3001limit=10 \u65F6\u7B2C\u4E00\u6B21\u8FD4\u56DE 10 \u6761\uFF0Cremaining=30\u3002",default:10}},required:[]}},
|
|
29
|
-
\u5220\u9664\u672C\u4EBA\u8BA4\u9886\u7684[\u56DE\u5FC6\u4E2D](recalling)\u72B6\u6001\u5DF2\u8FC7\u671F\u53EF\u8FC7\u671F\u8BB0\u5FC6\
|
|
32
|
+
2) \u4E0D\u7EED\u671F\uFF0C\u672C\u6279\u5BA1\u67E5\u5B8C\u6BD5\u540E\u8C03\u7528 memory_recurrence_complete \u5220\u9664\u5B83\u4EEC`,inputSchema:{type:"object",properties:{limit:{type:"number",description:"\u6BCF\u6B21\u6279\u91CF\u5904\u7406\u7684\u8BB0\u5FC6\u6570\u91CF\uFF08\u6309\u8FC7\u671F\u65F6\u95F4\u6700\u65E9\u4F18\u5148\uFF0C\u9ED8\u8BA4 10\uFF09\u3002\u4F8B\u5982 totalExpired=40\u3001limit=10 \u65F6\u7B2C\u4E00\u6B21\u8FD4\u56DE 10 \u6761\uFF0Cremaining=30\u3002",default:10}},required:[]}},u={name:"memory_recurrence_complete",description:`\u5B8C\u6210\u5373\u5C06\u9057\u5FD8\u7684\u8BB0\u5FC6\u758F\u7406\u5DE5\u4F5C\u3002
|
|
33
|
+
\u5220\u9664\u672C\u4EBA\u8BA4\u9886\u7684[\u56DE\u5FC6\u4E2D](recalling)\u72B6\u6001\u5DF2\u8FC7\u671F\u53EF\u8FC7\u671F\u8BB0\u5FC6\uFF08instance_hotspot_memory\uFF09\u3002
|
|
30
34
|
\u63A8\u8350\u7528\u6CD5\uFF1A\u968F\u5BA1\u67E5\u5206\u6279\u6E05\u7406\uFF08\u6BCF\u6279\u4F20\u5165\u672C\u6279\u786E\u5B9A\u5220\u9664\u7684 URI\uFF09\uFF1B\u5168\u90E8\u6279\u6B21\u5904\u7406\u5B8C\u6BD5\u540E\u4E0D\u5E26\u53C2\u6570\u8C03\u7528\u4E00\u6B21\uFF0C\u6E05\u7406\u5269\u4F59\u5168\u90E8\u3002
|
|
31
|
-
\u8BE5\u5DE5\u5177\u4EC5\u5220\u9664\uFF0C\u4E0D\u505A\u5F52\u6863\uFF1B\u9700\u8981\u957F\u671F\u4FDD\u7559\u7684\u5185\u5BB9\u8BF7\u5148\u8C03\u7528 create_memory \u4FDD\u5B58\u540E\u518D\u5220\u9664\u65E7\u6761\u76EE\u3002`,inputSchema:{type:"object",properties:{uris:{type:"array",items:{type:"string"},description:"\u53EF\u9009\u3002\u672C\u6279\u786E\u5B9A\u5220\u9664\u7684 memory URI \u5217\u8868\uFF1B\u4E0D\u4F20\u65F6\u5220\u9664\u672C\u4EBA\u8BA4\u9886\u7684\u5168\u90E8[\u56DE\u5FC6\u4E2D]\u5DF2\u8FC7\u671F\u8BB0\u5FC6\u3002"}},required:[]}};export{
|
|
35
|
+
\u8BE5\u5DE5\u5177\u4EC5\u5220\u9664\uFF0C\u4E0D\u505A\u5F52\u6863\uFF1B\u9700\u8981\u957F\u671F\u4FDD\u7559\u7684\u5185\u5BB9\u8BF7\u5148\u8C03\u7528 create_memory \u4FDD\u5B58\u540E\u518D\u5220\u9664\u65E7\u6761\u76EE\u3002`,inputSchema:{type:"object",properties:{uris:{type:"array",items:{type:"string"},description:"\u53EF\u9009\u3002\u672C\u6279\u786E\u5B9A\u5220\u9664\u7684 memory URI \u5217\u8868\uFF1B\u4E0D\u4F20\u65F6\u5220\u9664\u672C\u4EBA\u8BA4\u9886\u7684\u5168\u90E8[\u56DE\u5FC6\u4E2D]\u5DF2\u8FC7\u671F\u8BB0\u5FC6\u3002"}},required:[]}};export{a as ABANDON_MEMORY_UPDATE_TOOL,o as CREATE_MEMORY_TOOL,p as DELETE_MEMORY_TOOL,c as GET_MEMORY_STATS_TOOL,y as LIST_MEMORIES_BY_FILE_TOOL,_ as LIST_MEMORIES_TOOL,u as MEMORY_RECURRENCE_COMPLETE_TOOL,d as MEMORY_RECURRENCE_TOOL,i as READ_MEMORY_TOOL,s as SEARCH_MEMORY_TOOL,m as UPDATE_MEMORY_TOOL};
|
|
32
36
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentClient } from "./agent-client.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type CreateMemoryInput, type DeleteMemoryInput, type ListByFileOptions, type MemoryRecord, type MemoryStats, type MemoryStorePort, type ReadMemoryInput, type SearchMemoryInput, type UpdateMemoryInput } from "./memory-store.js";
|
|
3
3
|
export declare class ServerMemoryStore implements MemoryStorePort {
|
|
4
4
|
private readonly agentClient;
|
|
5
5
|
constructor(agentClient: AgentClient);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class
|
|
1
|
+
import{normalizeMemoryTypeName as l,validateTypeConstraints as i}from"./memory-store.js";class u{agentClient;constructor(e){this.agentClient=e}ensureSuccess(e){if(e&&typeof e=="object"&&"error"in e){const t=e.error;throw new Error(typeof t=="string"?t:"Server memory operation failed")}return e}async getStats(){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("get_memory_stats",{}))}async createMemory(e){const t=l(e.memory_type);if(!t)throw new Error(`Invalid memory_type: ${String(e.memory_type)}`);return i(t,e),this.ensureSuccess(await this.agentClient.callAgentScopedTool("create_memory",{...e,memory_type:t}))}async readMemory(e){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("read_memory",e))}async updateMemory(e){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("update_memory",e))}async deleteMemory(e){return!!this.ensureSuccess(await this.agentClient.callAgentScopedTool("delete_memory",e)).deleted}async searchMemory(e){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("search_memory",e))}listByType(e){return this.listAllByType(e)}async listAllByType(e){const r=[];let s,a=0;for(;;){s=await this.agentClient.callAgentScopedTool("list_memories",{memory_type:e,offset:a,limit:1e3}),this.ensureSuccess(s);const n=Array.isArray(s)?s:s.memories??[];if(Array.isArray(s))return r.concat(n);if(n.length===0)break;r.push(...n);const o=s.total??1/0;if(!(s.has_more===!0)||r.length>=o)break;a=r.length}return r}async listExpiredRecentlyMemories(){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("list_expired_memories",{}))}async markExpiredMemoriesRecalling(e){const t={};return e&&e.length>0&&(t.uris=e),this.ensureSuccess(await this.agentClient.callAgentScopedTool("mark_expired_memories_recalling",t))}async clearRecallingExpiredMemories(e){const t={};return e&&e.length>0&&(t.uris=e),this.ensureSuccess(await this.agentClient.callAgentScopedTool("clear_recalling_expired_memories",t))}async claimMemoryUpdate(e,t,r){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("claim_memory_update",{uris:e,lease_minutes:t,...r?{memory_type:r}:{}}))}async renewMemoryLease(e){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("renew_memory_lease",{lease_minutes:e}))}async releaseMemoryClaim(e){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("release_memory_update",{uri:e}))}async releaseAllMemoryClaims(){return this.ensureSuccess(await this.agentClient.callAgentScopedTool("release_all_memory_updates",{}))}async getMyClaimedUris(){const e=await this.agentClient.callAgentScopedTool("get_my_claimed_memory_uris",{});return this.ensureSuccess(e),e.uris??[]}async listByFile(e,t){const r=typeof t=="object"&&t!==null?{memory_type:t.memory_type,scope:t.scope}:{memory_type:t},s=await this.agentClient.callAgentScopedTool("list_memories_by_file",{file_path:e,...r.memory_type?{memory_type:r.memory_type}:{},...r.scope?{scope:r.scope}:{}});return this.ensureSuccess(s),s.results??[]}}export{u as ServerMemoryStore};
|
|
2
2
|
|
|
@@ -280,6 +280,16 @@ export interface DirectMessage {
|
|
|
280
280
|
requireReply: boolean;
|
|
281
281
|
|
|
282
282
|
force?: boolean;
|
|
283
|
+
|
|
284
|
+
priority?: "normal" | "force" | "interrupt" | string;
|
|
285
|
+
|
|
286
|
+
forceIntent?: string;
|
|
287
|
+
|
|
288
|
+
forceRef?: Record<string, unknown>;
|
|
289
|
+
|
|
290
|
+
forceReason?: string;
|
|
291
|
+
|
|
292
|
+
forceDeliveryState?: "pending" | "queued" | "injected" | "consumed" | "timeout" | string;
|
|
283
293
|
prompt?: string;
|
|
284
294
|
|
|
285
295
|
replyTo?: ReplyToRef[];
|
|
@@ -364,6 +374,18 @@ export interface BrowserListenerEventsResponse {
|
|
|
364
374
|
agentId: string;
|
|
365
375
|
events: BrowserListenerEvent[];
|
|
366
376
|
}
|
|
377
|
+
|
|
378
|
+
export interface CurrentActionSnapshot {
|
|
379
|
+
ok: boolean;
|
|
380
|
+
|
|
381
|
+
found?: boolean;
|
|
382
|
+
|
|
383
|
+
hasActiveBlockingToolCall?: boolean;
|
|
384
|
+
runtimeStatus?: string;
|
|
385
|
+
runtimeActionType?: string;
|
|
386
|
+
runtimeActionLabel?: string;
|
|
387
|
+
runtimeActionDetail?: string;
|
|
388
|
+
}
|
|
367
389
|
export interface SendMessageResult {
|
|
368
390
|
msgId: string | number;
|
|
369
391
|
timestamp: string;
|
|
@@ -372,6 +394,23 @@ export interface SendDmResult {
|
|
|
372
394
|
msgId?: string;
|
|
373
395
|
timestamp?: string;
|
|
374
396
|
reply?: DirectMessage;
|
|
397
|
+
|
|
398
|
+
priority?: "normal" | "force" | "interrupt" | string;
|
|
399
|
+
|
|
400
|
+
deliveryState?: "pending" | "queued" | "injected" | "consumed" | "timeout" | string;
|
|
401
|
+
|
|
402
|
+
degraded?: boolean;
|
|
403
|
+
|
|
404
|
+
degradeReason?: string;
|
|
405
|
+
|
|
406
|
+
degradeHint?: string;
|
|
407
|
+
|
|
408
|
+
forceIgnored?: boolean;
|
|
409
|
+
warning?: string;
|
|
410
|
+
replyToCallIdIgnored?: string;
|
|
411
|
+
replyToCallId?: string;
|
|
412
|
+
autoCorrelated?: boolean;
|
|
413
|
+
success?: boolean;
|
|
375
414
|
}
|
|
376
415
|
export interface WebSocketMessage<T = unknown> {
|
|
377
416
|
type: "GROUP_MSG" | "DM_MSG" | "MEETING_MSG" | "ONLINE_CHANGE" | "DM_REPLY" | "HEARTBEAT" | "PROFILE_INFO" | "AGENT_CONFIG" | "AGENT_STATUS" | "MCP_NODE_LOG" | "MCP_NODE_LOG_BATCH" | "LOG_ACK" | "MESSAGE_ACK" | "TERMINAL_OUTPUT" | "TERMINAL_STATUS" | "GROUP_READ_RECEIPT" | "DM_READ_RECEIPT" | "AGENT_EVENTS_DELTA" | "SYSTEM_NOTIFY";
|
|
@@ -518,6 +557,18 @@ export interface SendPrivateArgs {
|
|
|
518
557
|
card?: Card;
|
|
519
558
|
|
|
520
559
|
replyTo?: ReplyToRef[];
|
|
560
|
+
|
|
561
|
+
priority?: "normal" | "force";
|
|
562
|
+
|
|
563
|
+
intent?: "stop" | "redirect" | "constraint";
|
|
564
|
+
|
|
565
|
+
ref?: {
|
|
566
|
+
taskInstanceId?: string;
|
|
567
|
+
nodeId?: string;
|
|
568
|
+
messageId?: string;
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
reason?: string;
|
|
521
572
|
}
|
|
522
573
|
|
|
523
574
|
export interface SendGroupArgs {
|