@@ -13,9 +13,12 @@ import {
1313import { emitResult , emitBare } from "bailian-cli-runtime" ;
1414import {
1515 MEMORY_LIBRARY_FLAG ,
16+ MEMORY_RATE_LIMIT_NOTE ,
1617 MEMORY_WORKSPACE_NOTE ,
18+ MAX_CUSTOM_CONTENT_LENGTH ,
1719 PROJECT_ID_FLAG ,
1820 WORKSPACE_FLAG ,
21+ checkMemoryScopeLengths ,
1922 parseJsonArrayFlag ,
2023 parseJsonObjectFlag ,
2124 resolveWorkspaceId ,
@@ -71,10 +74,6 @@ type AddFlags = ParsedFlags<typeof ADD_FLAGS>;
7174
7275/** Max messages accepted per AddMemory call (a Q&A pair counts as 2). */
7376const MAX_MESSAGES = 50 ;
74- /** Max characters accepted for custom_content. */
75- const MAX_CONTENT_LENGTH = 512 ;
76- /** Max characters accepted for user_id. */
77- const MAX_USER_ID_LENGTH = 64 ;
7877
7978export default defineCommand ( {
8079 description : {
@@ -96,6 +95,7 @@ export default defineCommand({
9695 "The response lists the changed memory nodes; one call can add, update or delete several at once." ,
9796 "zh-CN" : "返回结果是变更的记忆片段列表;一次调用可能同时新增、更新或删除多条。" ,
9897 } ,
98+ MEMORY_RATE_LIMIT_NOTE ,
9999 ] ,
100100 exampleArgs : [
101101 {
@@ -118,10 +118,10 @@ export default defineCommand({
118118 ] ,
119119 validate : ( flags : AddFlags ) => {
120120 if ( ! flags . messages && ! flags . content ) return "Provide --messages or --content." ;
121- if ( flags . userId . length > MAX_USER_ID_LENGTH )
122- return `--user-id must be at most ${ MAX_USER_ID_LENGTH } characters.` ;
123- if ( flags . content && flags . content . length > MAX_CONTENT_LENGTH )
124- return `--content must be at most ${ MAX_CONTENT_LENGTH } characters.` ;
121+ const scopeError = checkMemoryScopeLengths ( flags ) ;
122+ if ( scopeError ) return scopeError ;
123+ if ( flags . content && flags . content . length > MAX_CUSTOM_CONTENT_LENGTH )
124+ return `--content must be at most ${ MAX_CUSTOM_CONTENT_LENGTH } characters.` ;
125125 return undefined ;
126126 } ,
127127 async run ( ctx ) {
0 commit comments