@@ -60,11 +60,6 @@ const ROUTES = {
6060 columnVirtualSet : { method : "POST" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/datasets/${ encodePath ( argv [ "dataset-id" ] ) } /virtual-columns` } ,
6161 columnVirtualList : { method : "GET" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/datasets/${ encodePath ( argv [ "dataset-id" ] ) } /virtual-columns` } ,
6262 columnVirtualDelete : { method : "DELETE" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/datasets/${ encodePath ( argv [ "dataset-id" ] ) } /virtual-columns/${ encodePath ( argv [ "attr-id" ] ) } ` } ,
63- knowledgeEntryList : { method : "GET" , path : "/open/api/v1/analytics-agent/knowledge/entries" } ,
64- knowledgeEntryDetail : { method : "GET" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/knowledge/entries/${ encodePath ( argv [ "knowledge-id" ] ) } ` } ,
65- knowledgeEntryCreate : { method : "POST" , path : "/open/api/v1/analytics-agent/knowledge/entries" } ,
66- knowledgeEntryUpdate : { method : "PUT" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/knowledge/entries/${ encodePath ( argv [ "knowledge-id" ] ) } ` } ,
67- knowledgeEntryDelete : { method : "DELETE" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/knowledge/entries/${ encodePath ( argv [ "knowledge-id" ] ) } ` } ,
6863 knowledgeSpaceList : { method : "GET" , path : "/open/api/v1/analytics-agent/knowledge/spaces" } ,
6964 knowledgeSpaceCreate : { method : "POST" , path : "/open/api/v1/analytics-agent/knowledge/spaces" } ,
7065 knowledgeSpaceRename : { method : "PUT" , path : ( argv : Record < string , unknown > ) => `/open/api/v1/analytics-agent/knowledge/spaces/${ encodePath ( argv [ "space-id" ] ) } ` } ,
@@ -1199,33 +1194,6 @@ async function executeKnowledgeNodeDomainCommand(
11991194 }
12001195}
12011196
1202- function knowledgeEntryBody ( argv : Record < string , unknown > ) : Record < string , unknown > {
1203- const format = typeof argv . format === "string" ? argv . format : "json"
1204- return mergeBody ( { } , {
1205- aliases : stringArray ( argv . alias ) ,
1206- content : argv . content ,
1207- dictionary : parseOptionalJsonObject ( argv . dictionary as string | undefined , "--dictionary" ) ,
1208- type : argv . type ,
1209- domainIds : positiveIntegerArray ( argv [ "domain-id" ] , "--domain-id" , format ) ,
1210- } )
1211- }
1212-
1213- async function knowledgeCreateBody ( argv : Record < string , unknown > ) : Promise < Record < string , unknown > > {
1214- const format = typeof argv . format === "string" ? argv . format : "json"
1215- const content = typeof argv . content === "string"
1216- ? argv . content
1217- : typeof argv . file === "string"
1218- ? await Bun . file ( ( await collectKnowledgeLocalFile ( argv . file ) ) . absolutePath ) . text ( )
1219- : undefined
1220- return mergeBody ( { } , {
1221- aliases : stringArray ( argv . alias ) ,
1222- content,
1223- dictionary : parseOptionalJsonObject ( argv . dictionary as string | undefined , "--dictionary" ) ,
1224- type : argv . type ,
1225- domainIds : positiveIntegerArray ( argv [ "domain-id" ] , "--domain-id" , format ) ,
1226- } )
1227- }
1228-
12291197function normalizedRemotePath ( pathValue : string | undefined ) : string {
12301198 if ( ! pathValue ) return ""
12311199 const normalized = pathValue . replaceAll ( "\\" , "/" ) . split ( "/" ) . filter ( Boolean ) . join ( "/" )
@@ -2613,87 +2581,6 @@ export function registerAnalyticsAgentCommand(cli: Argv<GlobalArgs>): void {
26132581 } )
26142582 . command ( "knowledge" , "Manage Analytics Agent knowledge" , ( knowledge ) => {
26152583 knowledge
2616- . command (
2617- "list" ,
2618- "List structured knowledge entries" ,
2619- ( y ) =>
2620- y
2621- . option ( "keyword" , { type : "string" , describe : "Keyword for fuzzy search" } )
2622- . option ( "domain-id" , { type : "number" , describe : "Bound domain ID" } )
2623- . option ( "type" , { type : "string" , choices : [ "text" , "dictionary" ] , describe : "Knowledge type" } )
2624- . option ( "page-num" , { type : "number" , describe : "Page number" } )
2625- . option ( "page-size" , { type : "number" , describe : "Page size" } ) ,
2626- async ( argv ) => {
2627- await executeAnalyticsCommand ( "analytics-agent knowledge list" , argv as Record < string , unknown > , ROUTES . knowledgeEntryList , { } , {
2628- keyword : argv . keyword ,
2629- domainId : argv [ "domain-id" ] ,
2630- type : argv . type ,
2631- pageNum : argv [ "page-num" ] ,
2632- pageSize : argv [ "page-size" ] ,
2633- } )
2634- } ,
2635- )
2636- . command (
2637- "get <knowledge-id>" ,
2638- "Show structured knowledge detail" ,
2639- ( y ) => y . positional ( "knowledge-id" , { type : "number" , demandOption : true , describe : "Knowledge ID" } ) ,
2640- async ( argv ) => {
2641- await executeAnalyticsCommand ( "analytics-agent knowledge get" , argv as Record < string , unknown > , ROUTES . knowledgeEntryDetail , { } )
2642- } ,
2643- )
2644- . command (
2645- "create" ,
2646- "Create structured knowledge" ,
2647- ( y ) =>
2648- y
2649- . option ( "alias" , { type : "string" , array : true , describe : "Knowledge alias, can be repeated" } )
2650- . option ( "content" , { type : "string" , describe : "Text knowledge content" } )
2651- . option ( "file" , { type : "string" , describe : "Local file path to load as text knowledge content" } )
2652- . option ( "dictionary" , { type : "string" , describe : "Dictionary JSON object" } )
2653- . option ( "type" , { type : "string" , choices : [ "text" , "dictionary" ] , describe : "Knowledge type" } )
2654- . option ( "domain-id" , { type : "number" , array : true , describe : "Bound domain ID, can be repeated" } ) ,
2655- async ( argv ) => {
2656- const type = typeof argv . type === "string" ? argv . type : "text"
2657- if ( type === "dictionary" && ! argv . dictionary ) {
2658- handledError ( "USAGE_ERROR" , "dictionary knowledge requires --dictionary" , { format : typeof argv . format === "string" ? argv . format : "json" } )
2659- }
2660- if ( type !== "dictionary" && ! argv . content && ! argv . file && ! argv . dictionary ) {
2661- handledError ( "USAGE_ERROR" , "text knowledge requires --content or --file" , { format : typeof argv . format === "string" ? argv . format : "json" } )
2662- }
2663- let body : Record < string , unknown >
2664- try {
2665- body = await knowledgeCreateBody ( argv as Record < string , unknown > )
2666- } catch ( err ) {
2667- handledError ( "ANALYTICS_AGENT_ERROR" , err instanceof Error ? err . message : String ( err ) , {
2668- format : typeof argv . format === "string" ? argv . format : "json" ,
2669- } )
2670- }
2671- await executeAnalyticsCommand ( "analytics-agent knowledge create" , argv as Record < string , unknown > , ROUTES . knowledgeEntryCreate , body )
2672- } ,
2673- )
2674- . command (
2675- "update <knowledge-id>" ,
2676- "Update structured knowledge" ,
2677- ( y ) =>
2678- y
2679- . positional ( "knowledge-id" , { type : "number" , demandOption : true , describe : "Knowledge ID" } )
2680- . option ( "alias" , { type : "string" , array : true , describe : "Knowledge alias, can be repeated" } )
2681- . option ( "content" , { type : "string" , describe : "Text knowledge content" } )
2682- . option ( "dictionary" , { type : "string" , describe : "Dictionary JSON object" } )
2683- . option ( "type" , { type : "string" , choices : [ "text" , "dictionary" ] , describe : "Knowledge type" } )
2684- . option ( "domain-id" , { type : "number" , array : true , describe : "Bound domain ID, can be repeated" } ) ,
2685- async ( argv ) => {
2686- await executeAnalyticsCommand ( "analytics-agent knowledge update" , argv as Record < string , unknown > , ROUTES . knowledgeEntryUpdate , knowledgeEntryBody ( argv as Record < string , unknown > ) )
2687- } ,
2688- )
2689- . command (
2690- "delete <knowledge-id>" ,
2691- "Delete structured knowledge" ,
2692- ( y ) => y . positional ( "knowledge-id" , { type : "number" , demandOption : true , describe : "Knowledge ID" } ) ,
2693- async ( argv ) => {
2694- await executeAnalyticsCommand ( "analytics-agent knowledge delete" , argv as Record < string , unknown > , ROUTES . knowledgeEntryDelete , { } )
2695- } ,
2696- )
26972584 . command (
26982585 "space" ,
26992586 "Manage knowledge spaces" ,
0 commit comments