-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli_defs.rs
More file actions
842 lines (750 loc) · 25.3 KB
/
Copy pathcli_defs.rs
File metadata and controls
842 lines (750 loc) · 25.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
use std::path::PathBuf;
use clap::{ArgGroup, Args, Parser, Subcommand, ValueEnum};
pub fn parse_identity_arg(value: &str) -> Result<String, String> {
if value.trim().is_empty() {
return Err("identity must not be empty or whitespace-only".to_string());
}
Ok(value.to_string())
}
#[derive(Parser, Debug)]
#[command(
name = "kinic-cli",
version,
about = "Kinic developer CLI for memory operations and agent-friendly local preferences",
after_help = "Auth modes:\n Network commands require --identity <NAME> or --ii unless noted otherwise.\n The TUI requires --identity <NAME> and does not support --ii.\n\nAgent entrypoints:\n kinic-cli capabilities\n kinic-cli prefs show\n kinic-cli prefs set-default-memory --memory-id MEMORY_ID\n\nReturns:\n capabilities and prefs commands return JSON.\n Existing network commands keep their current text output."
)]
pub struct Cli {
#[command(flatten)]
pub global: GlobalOpts,
#[command(subcommand)]
pub command: Command,
}
#[derive(Args, Debug)]
pub struct GlobalOpts {
#[arg(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(
long,
help = "Use the Internet Computer mainnet instead of local replica"
)]
pub ic: bool,
#[arg(
long,
conflicts_with = "ii",
value_name = "NAME",
value_parser = parse_identity_arg,
help = "Dfx identity name used to load credentials from the system keyring"
)]
pub identity: Option<String>,
#[arg(
long,
help = "Use Internet Identity login (delegation saved to identity.json)"
)]
pub ii: bool,
#[arg(
long,
value_name = "PATH",
help = "Path to identity.json (default: ~/.config/kinic/identity.json)"
)]
pub identity_path: Option<PathBuf>,
}
#[derive(Subcommand, Debug)]
pub enum Command {
#[command(
about = "Deploy a new memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
Create(CreateArgs),
#[command(
about = "List deployed memories. Requires --identity <NAME> or --ii. Returns text output."
)]
List(ListArgs),
#[command(
about = "Show details for a memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
Show(ShowArgs),
#[command(
about = "Insert text into an existing memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
Insert(InsertArgs),
#[command(
about = "Insert a precomputed embedding into a memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
InsertRaw(InsertRawArgs),
#[command(
about = "Insert a PDF converted to markdown into a memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
InsertPdf(InsertPdfArgs),
#[command(
about = "Convert a PDF to markdown and print it. No identity required. Returns text output."
)]
ConvertPdf(ConvertPdfArgs),
#[command(
about = "Generate one embedding with the configured backend. No identity required. Returns JSON.",
after_help = "Returns:\n {\"backend_id\": string, \"dimension\": integer, \"embedding\": number[]}\n\nExample:\n kinic-cli embed --text \"hello\""
)]
Embed(EmbedArgs),
#[command(
about = "Search within a memory canister using embeddings. Requires --identity <NAME> or --ii. Returns text output."
)]
Search(SearchArgs),
#[command(
about = "Search within a memory canister using a precomputed embedding. Requires --identity <NAME> or --ii. Returns text output."
)]
SearchRaw(SearchRawArgs),
#[command(
about = "Fetch embeddings for a tag from a memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
TaggedEmbeddings(TaggedEmbeddingsArgs),
#[command(
about = "Manage memory access control. Requires --identity <NAME> or --ii. Returns text output."
)]
Config(ConfigArgs),
#[command(
about = "Rename a memory canister. Requires --identity <NAME> or --ii. Returns text output."
)]
Rename(RenameArgs),
#[command(
about = "Describe CLI capabilities for agents. Returns JSON.",
after_help = "Returns:\n JSON with top-level commands, auth requirements, output modes, and major arguments.\n\nExample:\n kinic-cli capabilities"
)]
Capabilities(CapabilitiesArgs),
#[command(
about = "Manage local Kinic preferences shared with the TUI. All prefs commands return JSON.",
after_help = "Examples:\n kinic-cli prefs show\n kinic-cli prefs set-default-memory --memory-id MEMORY_CANISTER_ID\n kinic-cli prefs set-embedding-backend --model-id BAAI/bge-m3\n kinic-cli prefs set-chat-overall-top-k --value 10\n\nReturns:\n show -> {\"default_memory_id\": string|null, \"saved_tags\": string[], \"manual_memory_ids\": string[], \"chat_overall_top_k\": integer, \"chat_per_memory_cap\": integer, \"chat_mmr_lambda\": integer, \"embedding_model_id\": string}\n mutations -> {\"resource\": string, \"action\": string, \"status\": \"updated\"|\"unchanged\", \"value\": string|integer|null}"
)]
Prefs(PrefsArgs),
#[command(
about = "Update a memory canister instance. Requires --identity <NAME> or --ii. Returns text output."
)]
Update(UpdateArgs),
#[command(
about = "Reset a memory canister and set embedding dimension. Requires --identity <NAME> or --ii. Returns text output."
)]
Reset(ResetArgs),
#[command(
about = "Check KINIC token balance. Requires --identity <NAME> or --ii. Returns text output."
)]
Balance(BalanceArgs),
#[command(
about = "Transfer KINIC tokens. Requires --identity <NAME> or --ii. Returns text output."
)]
Transfer(TransferArgs),
#[command(
about = "Ask Kinic AI using memory search results. Requires --identity <NAME> or --ii. Returns text output."
)]
AskAi(AskAiArgs),
#[command(
about = "Login via Internet Identity and store a delegation. No identity required. Returns text output."
)]
Login(LoginArgs),
#[command(
about = "Expose Kinic memories as MCP tools. Env-only: uses KINIC_TOOL_IDENTITY/KINIC_TOOL_NETWORK.",
after_help = "Configuration:\n Set KINIC_TOOL_IDENTITY=<IDENTITY>\n Set KINIC_TOOL_NETWORK=local|mainnet\n\nNotes:\n tools serve does not accept global --identity, --ii, --ic, or --identity-path."
)]
Tools(ToolsArgs),
#[command(
about = "Operate the configured Wiki canister. Requires --identity <NAME> or --ii. Returns text output by default."
)]
Wiki(WikiArgs),
#[command(
about = "Launch the Kinic terminal UI. Requires global --identity <NAME>. --ii is not supported. Returns an interactive TUI, not JSON.",
after_help = "Requires:\n kinic-cli --identity <NAME> tui\n\nReturns:\n Interactive terminal UI.\n\nExample:\n kinic-cli --identity alice tui"
)]
Tui(TuiArgs),
}
#[derive(Args, Debug, Default)]
pub struct CapabilitiesArgs {}
#[derive(Args, Debug)]
pub struct CreateArgs {
#[arg(long, required = true, help = "Name for the new memory")]
pub name: String,
#[arg(long, required = true, help = "Short description for the new memory")]
pub description: String,
}
#[derive(Args, Debug, Default)]
pub struct TuiArgs {}
#[derive(Args, Debug)]
pub struct WikiArgs {
#[command(subcommand)]
pub command: WikiCommand,
}
#[derive(Subcommand, Debug)]
pub enum WikiCommand {
#[command(about = "Manage Wiki databases")]
Database(WikiDatabaseArgs),
#[command(about = "Read a Wiki node")]
Read(WikiReadArgs),
#[command(about = "List Wiki children under a path")]
Children(WikiChildrenArgs),
#[command(about = "Search Wiki nodes")]
Search(WikiSearchArgs),
#[command(about = "Write a Wiki node from a file")]
Write(WikiWriteArgs),
#[command(about = "Append file contents to a Wiki node")]
Append(WikiAppendArgs),
#[command(about = "Replace text in a Wiki node")]
Edit(WikiEditArgs),
#[command(about = "Delete a Wiki node. Requires --yes.")]
Delete(WikiDeleteArgs),
}
#[derive(Args, Debug)]
pub struct WikiDatabaseArgs {
#[command(subcommand)]
pub command: WikiDatabaseCommand,
}
#[derive(Subcommand, Debug)]
pub enum WikiDatabaseCommand {
#[command(about = "List databases visible to the caller")]
List(WikiJsonArgs),
#[command(about = "Create a new database")]
Create(WikiJsonArgs),
#[command(about = "Grant database access to a principal")]
Grant(WikiDatabaseGrantArgs),
}
#[derive(Args, Debug, Default)]
pub struct WikiJsonArgs {
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiDatabaseGrantArgs {
pub database_id: String,
pub principal: String,
#[arg(value_enum)]
pub role: WikiDatabaseRoleArg,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
pub enum WikiDatabaseRoleArg {
Owner,
Writer,
Reader,
}
#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
pub enum WikiNodeKindArg {
File,
Source,
}
#[derive(Args, Debug)]
pub struct WikiReadArgs {
#[arg(long, required = true)]
pub database_id: String,
#[arg(long, required = true)]
pub path: String,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiChildrenArgs {
#[arg(long, required = true)]
pub database_id: String,
#[arg(long, default_value = "/Wiki")]
pub path: String,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiSearchArgs {
#[arg(long, required = true)]
pub database_id: String,
pub query: String,
#[arg(long, default_value = "/Wiki")]
pub prefix: String,
#[arg(long, default_value_t = 10)]
pub top_k: u32,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiWriteArgs {
#[arg(long, required = true)]
pub database_id: String,
#[arg(long, required = true)]
pub path: String,
#[arg(long, value_name = "PATH", required = true)]
pub input: PathBuf,
#[arg(long, value_enum, default_value_t = WikiNodeKindArg::File)]
pub kind: WikiNodeKindArg,
#[arg(long, default_value = "{}")]
pub metadata_json: String,
#[arg(long)]
pub expected_etag: Option<String>,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiAppendArgs {
#[arg(long, required = true)]
pub database_id: String,
#[arg(long, required = true)]
pub path: String,
#[arg(long, value_name = "PATH", required = true)]
pub input: PathBuf,
#[arg(long)]
pub expected_etag: Option<String>,
#[arg(long)]
pub separator: Option<String>,
#[arg(long, value_enum)]
pub kind: Option<WikiNodeKindArg>,
#[arg(long)]
pub metadata_json: Option<String>,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiEditArgs {
#[arg(long, required = true)]
pub database_id: String,
#[arg(long, required = true)]
pub path: String,
#[arg(long, required = true)]
pub old_text: String,
#[arg(long, required = true)]
pub new_text: String,
#[arg(long)]
pub replace_all: bool,
#[arg(long)]
pub expected_etag: Option<String>,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WikiDeleteArgs {
#[arg(long, required = true)]
pub database_id: String,
#[arg(long, required = true)]
pub path: String,
#[arg(long)]
pub expected_etag: Option<String>,
#[arg(long, help = "Confirm deletion")]
pub yes: bool,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct ToolsArgs {
#[command(subcommand)]
pub command: ToolsCommand,
}
#[derive(Subcommand, Debug)]
pub enum ToolsCommand {
#[command(about = "Run the Kinic MCP tool server over stdio. Env-only.")]
Serve(ToolsServeArgs),
}
#[derive(Args, Debug, Clone, Default)]
pub struct ToolsServeArgs {}
#[derive(Args, Debug, Default)]
pub struct ListArgs {
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct ShowArgs {
#[arg(
long,
required = true,
help = "Principal of the memory canister to show"
)]
pub memory_id: String,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
#[command(group(
ArgGroup::new("insert_input")
.required(true)
.multiple(false)
.args(["text", "file_path"])
))]
pub struct InsertArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister"
)]
pub memory_id: String,
#[arg(long, help = "Markdown text to embed and insert")]
pub text: Option<String>,
#[arg(
long,
value_name = "PATH",
help = "Read markdown content from a file (conflicts with --text)"
)]
pub file_path: Option<PathBuf>,
#[arg(
long,
help = "Tag metadata stored alongside the text (required with --text; auto-derived from --file-path when omitted)"
)]
pub tag: Option<String>,
}
#[derive(Args, Debug)]
pub struct InsertRawArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister"
)]
pub memory_id: String,
#[arg(
long,
required = true,
help = "Embedding as a JSON array of floats, e.g. [0.1, 0.2]"
)]
pub embedding: String,
#[arg(
long,
required = true,
help = "Text payload to store with the embedding"
)]
pub text: String,
#[arg(long, required = true, help = "Tag metadata stored alongside the text")]
pub tag: String,
}
#[derive(Args, Debug)]
pub struct InsertPdfArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister"
)]
pub memory_id: String,
#[arg(
long,
value_name = "PATH",
required = true,
help = "PDF file to convert to markdown and insert"
)]
pub file_path: PathBuf,
#[arg(
long,
help = "Tag metadata stored alongside the text (auto-derived from --file-path when omitted)"
)]
pub tag: Option<String>,
}
#[derive(Args, Debug)]
pub struct ConvertPdfArgs {
#[arg(
long,
value_name = "PATH",
required = true,
help = "PDF file to convert to markdown"
)]
pub file_path: PathBuf,
}
#[derive(Args, Debug)]
pub struct EmbedArgs {
#[arg(
long,
required = true,
help = "Text to embed with the configured backend"
)]
pub text: String,
}
#[derive(Args, Debug)]
#[command(group(
ArgGroup::new("search_target")
.required(true)
.multiple(false)
.args(["memory_id", "all"])
))]
pub struct SearchArgs {
#[arg(long, help = "Principal of the memory canister to search")]
pub memory_id: Option<String>,
#[arg(long, help = "Search across every searchable memory canister")]
pub all: bool,
#[arg(long, required = true, help = "Query text to embed and search")]
pub query: String,
#[arg(long, help = "Return machine-readable JSON output")]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct SearchRawArgs {
#[arg(
long,
required = true,
help = "Principal of the memory canister to search"
)]
pub memory_id: String,
#[arg(
long,
required = true,
help = "Embedding as a JSON array of floats, e.g. [0.1, 0.2]"
)]
pub embedding: String,
}
#[derive(Args, Debug)]
pub struct TaggedEmbeddingsArgs {
#[arg(
long,
required = true,
help = "Principal of the memory canister to query"
)]
pub memory_id: String,
#[arg(long, required = true, help = "Tag to fetch embeddings for")]
pub tag: String,
}
#[derive(Args, Debug)]
pub struct ConfigArgs {
#[command(subcommand)]
pub command: ConfigCommand,
}
#[derive(Subcommand, Debug)]
pub enum ConfigCommand {
#[command(about = "Manage users for a memory canister")]
Users(ConfigUsersArgs),
}
#[derive(Args, Debug)]
pub struct ConfigUsersArgs {
#[command(subcommand)]
pub command: ConfigUsersCommand,
}
#[derive(Subcommand, Debug)]
pub enum ConfigUsersCommand {
#[command(about = "List users for a memory canister")]
List(MemoryIdArgs),
#[command(about = "Add a user to a memory canister")]
Add(ConfigUserWriteArgs),
#[command(about = "Change a user's role on a memory canister")]
Change(ConfigUserWriteArgs),
#[command(about = "Remove a user from a memory canister")]
Remove(ConfigUserRemoveArgs),
}
#[derive(Args, Debug)]
pub struct ConfigUserWriteArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister"
)]
pub memory_id: String,
#[arg(
long,
required = true,
help = "Principal to add or update, or anonymous"
)]
pub principal: String,
#[arg(long, required = true, help = "Role: admin, writer, or reader")]
pub role: String,
}
#[derive(Args, Debug)]
pub struct ConfigUserRemoveArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister"
)]
pub memory_id: String,
#[arg(long, required = true, help = "Principal to remove, or anonymous")]
pub principal: String,
}
#[derive(Args, Debug)]
pub struct PrefsArgs {
#[command(subcommand)]
pub command: PrefsCommand,
}
#[derive(Subcommand, Debug)]
pub enum PrefsCommand {
#[command(
about = "Show local preferences shared with the TUI. Returns JSON.",
after_help = "Returns:\n {\"default_memory_id\": string|null, \"saved_tags\": string[], \"manual_memory_ids\": string[], \"chat_overall_top_k\": integer, \"chat_per_memory_cap\": integer, \"chat_mmr_lambda\": integer, \"embedding_model_id\": string}\n\nExample:\n kinic-cli prefs show"
)]
Show,
#[command(
about = "Set the default memory id. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"default_memory_id\", \"action\": \"set\", \"status\": \"updated\"|\"unchanged\", \"value\": string}\n\nExample:\n kinic-cli prefs set-default-memory --memory-id MEMORY_CANISTER_ID"
)]
SetDefaultMemory(SetDefaultMemoryArgs),
#[command(
about = "Clear the default memory id. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"default_memory_id\", \"action\": \"clear\", \"status\": \"updated\"|\"unchanged\", \"value\": null}\n\nExample:\n kinic-cli prefs clear-default-memory"
)]
ClearDefaultMemory,
#[command(
about = "Add a saved tag. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"saved_tags\", \"action\": \"add\", \"status\": \"updated\"|\"unchanged\", \"value\": string}\n\nExample:\n kinic-cli prefs add-tag --tag quarterly_report"
)]
AddTag(TagArgs),
#[command(
about = "Remove a saved tag. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"saved_tags\", \"action\": \"remove\", \"status\": \"updated\"|\"unchanged\", \"value\": string}\n\nExample:\n kinic-cli prefs remove-tag --tag quarterly_report"
)]
RemoveTag(TagArgs),
#[command(
about = "Add a manually tracked memory id. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"manual_memory_ids\", \"action\": \"add\", \"status\": \"updated\"|\"unchanged\", \"value\": string}\n\nExamples:\n kinic-cli prefs add-memory --memory-id MEMORY_CANISTER_ID\n kinic-cli --identity alice prefs add-memory --memory-id MEMORY_CANISTER_ID --validate"
)]
AddMemory(AddMemoryArgs),
#[command(
about = "Remove a manually tracked memory id. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"manual_memory_ids\", \"action\": \"remove\", \"status\": \"updated\"|\"unchanged\", \"value\": string}\n\nExample:\n kinic-cli prefs remove-memory --memory-id MEMORY_CANISTER_ID"
)]
RemoveMemory(MemoryIdArgs),
#[command(
about = "Set the all-memories chat retrieval result limit. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"chat_overall_top_k\", \"action\": \"set\", \"status\": \"updated\"|\"unchanged\", \"value\": integer}\n\nExample:\n kinic-cli prefs set-chat-overall-top-k --value 10"
)]
SetChatOverallTopK(ChatOverallTopKArgs),
#[command(
about = "Set the per-memory chat retrieval cap. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"chat_per_memory_cap\", \"action\": \"set\", \"status\": \"updated\"|\"unchanged\", \"value\": integer}\n\nExample:\n kinic-cli prefs set-chat-per-memory-cap --value 4"
)]
SetChatPerMemoryCap(ChatPerMemoryCapArgs),
#[command(
about = "Set the chat retrieval MMR lambda percentage. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"chat_mmr_lambda\", \"action\": \"set\", \"status\": \"updated\"|\"unchanged\", \"value\": integer}\n\nExample:\n kinic-cli prefs set-chat-mmr-lambda --value 80"
)]
SetChatMmrLambda(ChatMmrLambdaArgs),
#[command(
about = "Set the embedding backend shared with the TUI. Returns JSON.",
after_help = "Returns:\n {\"resource\": \"embedding_model_id\", \"action\": \"set\", \"status\": \"updated\"|\"unchanged\", \"value\": string}\n\nExample:\n kinic-cli prefs set-embedding-backend --model-id BAAI/bge-m3"
)]
SetEmbeddingBackend(EmbeddingBackendArgs),
}
#[derive(Args, Debug)]
pub struct SetDefaultMemoryArgs {
#[arg(
long,
required = true,
help = "Principal of the default memory canister"
)]
pub memory_id: String,
}
#[derive(Args, Debug)]
pub struct TagArgs {
#[arg(long, required = true, help = "Tag value to add or remove")]
pub tag: String,
}
#[derive(Args, Debug)]
pub struct MemoryIdArgs {
#[arg(
long,
required = true,
help = "Principal of the memory canister to add or remove"
)]
pub memory_id: String,
}
#[derive(Args, Debug)]
pub struct AddMemoryArgs {
#[arg(
long,
required = true,
help = "Principal of the memory canister to add"
)]
pub memory_id: String,
#[arg(
long,
help = "Check memory reachability and visible metadata through get_name() using --identity or --ii before saving"
)]
pub validate: bool,
}
#[derive(Args, Debug)]
pub struct ChatOverallTopKArgs {
#[arg(
long,
required = true,
help = "Number of documents to keep after global reranking"
)]
pub value: usize,
}
#[derive(Args, Debug)]
pub struct ChatPerMemoryCapArgs {
#[arg(
long,
required = true,
help = "Maximum documents to keep from each memory"
)]
pub value: usize,
}
#[derive(Args, Debug)]
pub struct ChatMmrLambdaArgs {
#[arg(
long,
required = true,
help = "MMR lambda percentage, one of 60, 70, 80, 90"
)]
pub value: u8,
}
#[derive(Args, Debug)]
pub struct EmbeddingBackendArgs {
#[arg(
long,
required = true,
help = "Embedding backend id shared with the TUI, e.g. api or BAAI/bge-m3"
)]
pub model_id: String,
}
#[derive(Args, Debug)]
pub struct UpdateArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister to update"
)]
pub memory_id: String,
}
#[derive(Args, Debug)]
pub struct RenameArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister"
)]
pub memory_id: String,
#[arg(long, required = true, help = "New memory name")]
pub name: String,
#[arg(
long,
conflicts_with = "clear_description",
help = "New memory description. Omit to preserve the current description"
)]
pub description: Option<String>,
#[arg(
long,
conflicts_with = "description",
help = "Clear the current memory description"
)]
pub clear_description: bool,
}
#[derive(Args, Debug)]
pub struct ResetArgs {
#[arg(
long,
required = true,
help = "Principal of the target memory canister to reset"
)]
pub memory_id: String,
#[arg(long, required = true, help = "Embedding dimension to set after reset")]
pub dim: usize,
}
#[derive(Args, Debug)]
pub struct BalanceArgs {}
#[derive(Args, Debug)]
pub struct TransferArgs {
#[arg(long, required = true, help = "Recipient principal")]
pub to: String,
#[arg(long, required = true, help = "Amount in KINIC, e.g. 1 or 0.25")]
pub amount: String,
#[arg(long, help = "Confirm that the transfer should be executed")]
pub yes: bool,
}
#[derive(Args, Debug)]
pub struct AskAiArgs {
#[arg(
long,
required = true,
help = "Principal of the memory canister to search"
)]
pub memory_id: String,
#[arg(long, required = true, help = "Query text to embed and search")]
pub query: String,
#[arg(
long,
default_value_t = 5,
value_name = "N",
help = "Number of top search results to include in the LLM prompt"
)]
pub top_k: usize,
}
#[derive(Args, Debug)]
pub struct LoginArgs {}