forked from kenn-io/agentsview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
1194 lines (1141 loc) · 35 KB
/
Copy pathtypes.go
File metadata and controls
1194 lines (1141 loc) · 35 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
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package parser
import (
"encoding/json"
"strings"
"time"
)
// AgentType identifies the AI agent that produced a session.
type AgentType string
const (
AgentClaude AgentType = "claude"
AgentOpenClaude AgentType = "openclaude"
AgentCowork AgentType = "cowork"
AgentCodex AgentType = "codex"
AgentCopilot AgentType = "copilot"
AgentGemini AgentType = "gemini"
AgentMiMoCode AgentType = "mimocode"
AgentOpenCode AgentType = "opencode"
AgentKilo AgentType = "kilo"
AgentOpenHands AgentType = "openhands"
AgentCursor AgentType = "cursor"
AgentIflow AgentType = "iflow"
AgentAmp AgentType = "amp"
AgentZencoder AgentType = "zencoder"
AgentVSCodeCopilot AgentType = "vscode-copilot"
AgentWindsurf AgentType = "windsurf"
AgentVSCopilot AgentType = "visualstudio-copilot"
AgentPi AgentType = "pi"
AgentOMP AgentType = "omp"
AgentQwen AgentType = "qwen"
AgentCommandCode AgentType = "commandcode"
AgentDeepSeekTUI AgentType = "deepseek-tui"
AgentOpenClaw AgentType = "openclaw"
AgentQClaw AgentType = "qclaw"
AgentKimi AgentType = "kimi"
AgentClaudeAI AgentType = "claude-ai"
AgentChatGPT AgentType = "chatgpt"
AgentKiro AgentType = "kiro"
AgentKiroIDE AgentType = "kiro-ide"
AgentCortex AgentType = "cortex"
AgentHermes AgentType = "hermes"
AgentWorkBuddy AgentType = "workbuddy"
AgentForge AgentType = "forge"
AgentDevin AgentType = "devin"
AgentPiebald AgentType = "piebald"
AgentWarp AgentType = "warp"
AgentPositron AgentType = "positron"
AgentZCode AgentType = "zcode"
AgentAntigravity AgentType = "antigravity"
AgentAntigravityCLI AgentType = "antigravity-cli"
AgentVibe AgentType = "vibe"
AgentZed AgentType = "zed"
AgentQwenPaw AgentType = "qwenpaw"
AgentGptme AgentType = "gptme"
AgentQoder AgentType = "qoder"
AgentShelley AgentType = "shelley"
AgentAider AgentType = "aider"
AgentReasonix AgentType = "reasonix"
AgentIcodemate AgentType = "icodemate"
)
// AgentDef describes a supported coding agent's filesystem
// layout, configuration keys, and session ID conventions.
type AgentDef struct {
Type AgentType
DisplayName string // "Claude Code", "Codex", etc.
EnvVar string // env var for dir override
DefaultRootEnvVar string // env var that re-roots DefaultDirs before $HOME fallback
ConfigKey string // TOML key in config.toml ("" = none)
DefaultDirs []string // paths relative to $HOME
IDPrefix string // session ID prefix ("" for Claude)
WatchSubdirs []string // subdirs to watch (nil = watch root)
ShallowWatch bool // true = watch root only, rely on periodic sync for subdirs
FileBased bool // false for DB-backed agents
Usage UsageCapabilities
// WatchRootsFunc resolves the directories to watch for live
// updates under a configured root, for agents whose watch
// targets depend on the on-disk layout rather than a static
// WatchSubdirs list. When set, it takes precedence over
// WatchSubdirs. Nil for agents that use WatchSubdirs.
WatchRootsFunc func(string) []string
// ShallowWatchRootsFunc resolves directories to watch shallowly
// (root only) for a configured root, in addition to the agent's
// normal recursive watch. Used for sibling metadata files that
// live outside the session tree, such as Codex's
// session_index.jsonl. Nil for agents with no such files.
ShallowWatchRootsFunc func(string) []string
}
type UsageCapabilities struct {
NoPerMessageTokenData bool
AICreditsDenominated bool
}
// Registry lists all supported agents. Order is stable and
// used for iteration in config, sync, and watcher setup.
var Registry = []AgentDef{
{
Type: AgentClaude,
DisplayName: "Claude Code",
EnvVar: "CLAUDE_PROJECTS_DIR",
DefaultRootEnvVar: "CLAUDE_CONFIG_DIR",
ConfigKey: "claude_project_dirs",
DefaultDirs: []string{".claude/projects"},
IDPrefix: "",
FileBased: true,
},
{
Type: AgentOpenClaude,
DisplayName: "OpenClaude",
EnvVar: "OPENCLAUDE_PROJECTS_DIR",
DefaultRootEnvVar: "OPENCLAUDE_CONFIG_DIR",
ConfigKey: "openclaude_project_dirs",
DefaultDirs: []string{".openclaude/projects"},
IDPrefix: "openclaude:",
FileBased: true,
},
{
Type: AgentCowork,
DisplayName: "Claude Cowork",
EnvVar: "COWORK_DIR",
ConfigKey: "cowork_dirs",
DefaultDirs: coworkDefaultDirs(),
IDPrefix: "cowork:",
FileBased: true,
ShallowWatch: true,
},
{
Type: AgentCodex,
DisplayName: "Codex",
EnvVar: "CODEX_SESSIONS_DIR",
ConfigKey: "codex_sessions_dirs",
DefaultDirs: []string{
".codex/sessions",
".codex/archived_sessions",
},
IDPrefix: "codex:",
FileBased: true,
ShallowWatchRootsFunc: ResolveCodexShallowWatchRoots,
},
{
Type: AgentCopilot,
DisplayName: "Copilot",
EnvVar: "COPILOT_DIR",
ConfigKey: "copilot_dirs",
DefaultDirs: []string{".copilot"},
IDPrefix: "copilot:",
WatchSubdirs: []string{"session-state"},
FileBased: true,
Usage: UsageCapabilities{
NoPerMessageTokenData: true,
AICreditsDenominated: true,
},
},
{
Type: AgentGemini,
DisplayName: "Gemini",
EnvVar: "GEMINI_DIR",
ConfigKey: "gemini_dirs",
DefaultDirs: []string{".gemini"},
IDPrefix: "gemini:",
WatchSubdirs: []string{"tmp"},
FileBased: true,
},
{
Type: AgentMiMoCode,
DisplayName: "MiMoCode",
EnvVar: "MIMOCODE_DIR",
ConfigKey: "mimocode_dirs",
DefaultDirs: []string{".local/share/mimocode"},
IDPrefix: "mimocode:",
WatchSubdirs: []string{
"storage/session_diff",
"storage/message",
"storage/part",
},
FileBased: true,
WatchRootsFunc: ResolveMiMoCodeWatchRoots,
},
{
Type: AgentOpenCode,
DisplayName: "OpenCode",
EnvVar: "OPENCODE_DIR",
ConfigKey: "opencode_dirs",
DefaultDirs: []string{".local/share/opencode"},
IDPrefix: "opencode:",
WatchSubdirs: []string{
"storage/session",
"storage/message",
"storage/part",
},
FileBased: true,
WatchRootsFunc: ResolveOpenCodeWatchRoots,
},
{
Type: AgentKilo,
DisplayName: "Kilo",
EnvVar: "KILO_DIR",
ConfigKey: "kilo_dirs",
DefaultDirs: []string{".local/share/kilo"},
IDPrefix: "kilo:",
WatchSubdirs: []string{
"storage/session",
"storage/message",
"storage/part",
},
FileBased: true,
WatchRootsFunc: ResolveKiloWatchRoots,
},
{
Type: AgentOpenHands,
DisplayName: "OpenHands CLI",
EnvVar: "OPENHANDS_CONVERSATIONS_DIR",
ConfigKey: "openhands_dirs",
DefaultDirs: []string{".openhands/conversations"},
IDPrefix: "openhands:",
FileBased: true,
ShallowWatch: true,
},
{
Type: AgentCursor,
DisplayName: "Cursor",
EnvVar: "CURSOR_PROJECTS_DIR",
ConfigKey: "cursor_project_dirs",
DefaultDirs: []string{".cursor/projects"},
IDPrefix: "cursor:",
FileBased: true,
},
{
Type: AgentAmp,
DisplayName: "Amp",
EnvVar: "AMP_DIR",
ConfigKey: "amp_dirs",
DefaultDirs: []string{".local/share/amp/threads"},
IDPrefix: "amp:",
FileBased: true,
},
{
Type: AgentZencoder,
DisplayName: "Zencoder",
EnvVar: "ZENCODER_DIR",
ConfigKey: "zencoder_dirs",
DefaultDirs: []string{".zencoder/sessions"},
IDPrefix: "zencoder:",
FileBased: true,
},
{
Type: AgentIflow,
DisplayName: "iFlow",
EnvVar: "IFLOW_DIR",
ConfigKey: "iflow_dirs",
DefaultDirs: []string{".iflow/projects"},
IDPrefix: "iflow:",
FileBased: true,
},
{
Type: AgentVSCodeCopilot,
DisplayName: "VSCode Copilot",
EnvVar: "VSCODE_COPILOT_DIR",
ConfigKey: "vscode_copilot_dirs",
DefaultDirs: []string{
// Windows
"AppData/Roaming/Code/User",
"AppData/Roaming/Code - Insiders/User",
"AppData/Roaming/VSCodium/User",
// macOS
"Library/Application Support/Code/User",
"Library/Application Support/Code - Insiders/User",
"Library/Application Support/VSCodium/User",
// Linux
".config/Code/User",
".config/Code - Insiders/User",
".config/VSCodium/User",
},
IDPrefix: "vscode-copilot:",
WatchSubdirs: []string{
"workspaceStorage",
"globalStorage",
},
FileBased: true,
Usage: UsageCapabilities{
NoPerMessageTokenData: true,
AICreditsDenominated: true,
},
},
{
Type: AgentWindsurf,
DisplayName: "Windsurf",
EnvVar: "WINDSURF_DIR",
ConfigKey: "windsurf_dirs",
DefaultDirs: []string{
// Windows
"AppData/Roaming/Windsurf/User",
"AppData/Roaming/Windsurf - Next/User",
// macOS
"Library/Application Support/Windsurf/User",
"Library/Application Support/Windsurf - Next/User",
// Linux
".config/Windsurf/User",
".config/Windsurf - Next/User",
},
IDPrefix: "windsurf:",
WatchSubdirs: []string{
"workspaceStorage",
},
FileBased: true,
Usage: UsageCapabilities{
NoPerMessageTokenData: true,
AICreditsDenominated: true,
},
},
{
Type: AgentVSCopilot,
DisplayName: "Visual Studio Copilot",
EnvVar: "VISUALSTUDIO_COPILOT_DIR",
ConfigKey: "visualstudio_copilot_dirs",
DefaultDirs: []string{
// Windows
"AppData/Local/Temp/VSGitHubCopilotLogs/traces",
// macOS
"Library/Caches/VSGitHubCopilotLogs/traces",
// Linux
".cache/VSGitHubCopilotLogs/traces",
},
IDPrefix: "visualstudio-copilot:",
FileBased: true,
Usage: UsageCapabilities{
NoPerMessageTokenData: true,
AICreditsDenominated: true,
},
},
{
Type: AgentPi,
DisplayName: "Pi",
EnvVar: "PI_DIR",
ConfigKey: "pi_dirs",
DefaultDirs: []string{".pi/agent/sessions"},
IDPrefix: "pi:",
FileBased: true,
},
{
Type: AgentOMP,
DisplayName: "OhMyPi",
EnvVar: "OMP_DIR",
ConfigKey: "omp_dirs",
DefaultDirs: []string{".omp/agent/sessions"},
IDPrefix: "omp:",
FileBased: true,
},
{
Type: AgentQwen,
DisplayName: "Qwen Code",
EnvVar: "QWEN_PROJECTS_DIR",
ConfigKey: "qwen_project_dirs",
DefaultDirs: []string{".qwen/projects"},
IDPrefix: "qwen:",
// Sessions live under <projectsDir>/<encoded-project>/chats/<id>.jsonl,
// so the projects root must be watched recursively — pinning the
// watch to a "chats" subdir of the root catches no events.
FileBased: true,
},
{
Type: AgentCommandCode,
DisplayName: "Command Code",
EnvVar: "COMMANDCODE_PROJECTS_DIR",
ConfigKey: "commandcode_project_dirs",
DefaultDirs: []string{".commandcode/projects"},
IDPrefix: "commandcode:",
FileBased: true,
},
{
Type: AgentDeepSeekTUI,
DisplayName: "DeepSeek TUI",
EnvVar: "DEEPSEEK_TUI_SESSIONS_DIR",
ConfigKey: "deepseek_tui_sessions_dirs",
DefaultDirs: []string{
".codewhale/sessions",
".deepseek/sessions",
},
IDPrefix: "deepseek-tui:",
FileBased: true,
},
{
Type: AgentOpenClaw,
DisplayName: "OpenClaw",
EnvVar: "OPENCLAW_DIR",
ConfigKey: "openclaw_dirs",
DefaultDirs: []string{
".openclaw/agents",
".kimi_openclaw/agents",
},
IDPrefix: "openclaw:",
FileBased: true,
},
{
Type: AgentQClaw,
DisplayName: "QClaw",
EnvVar: "QCLAW_DIR",
ConfigKey: "qclaw_dirs",
DefaultDirs: []string{".qclaw/agents"},
IDPrefix: "qclaw:",
FileBased: true,
},
{
Type: AgentKimi,
DisplayName: "Kimi",
EnvVar: "KIMI_DIR",
ConfigKey: "kimi_dirs",
DefaultDirs: []string{
".kimi/sessions",
".kimi-code/sessions",
},
IDPrefix: "kimi:",
FileBased: true,
},
{
Type: AgentClaudeAI,
DisplayName: "Claude.ai",
IDPrefix: "claude-ai:",
FileBased: false,
},
{
Type: AgentChatGPT,
DisplayName: "ChatGPT",
IDPrefix: "chatgpt:",
FileBased: false,
},
{
Type: AgentKiro,
DisplayName: "Kiro",
EnvVar: "KIRO_SESSIONS_DIR",
ConfigKey: "kiro_dirs",
DefaultDirs: []string{
".kiro/sessions/cli",
".local/share/kiro-cli",
},
IDPrefix: "kiro:",
FileBased: true,
},
{
Type: AgentKiroIDE,
DisplayName: "Kiro IDE",
EnvVar: "KIRO_IDE_DIR",
ConfigKey: "kiro_ide_dirs",
DefaultDirs: kiroIDEDefaultDirs(),
IDPrefix: "kiro-ide:",
FileBased: true,
},
{
Type: AgentCortex,
DisplayName: "Cortex Code",
EnvVar: "CORTEX_DIR",
ConfigKey: "cortex_dirs",
DefaultDirs: []string{
".snowflake/cortex/conversations",
},
IDPrefix: "cortex:",
FileBased: true,
},
{
Type: AgentHermes,
DisplayName: "Hermes Agent",
EnvVar: "HERMES_SESSIONS_DIR",
ConfigKey: "hermes_sessions_dirs",
DefaultDirs: []string{".hermes/sessions"},
IDPrefix: "hermes:",
FileBased: true,
WatchRootsFunc: ResolveHermesWatchRoots,
ShallowWatchRootsFunc: ResolveHermesShallowWatchRoots,
},
{
Type: AgentWorkBuddy,
DisplayName: "WorkBuddy",
EnvVar: "WORKBUDDY_PROJECTS_DIR",
ConfigKey: "workbuddy_project_dirs",
DefaultDirs: []string{".workbuddy/projects"},
IDPrefix: "workbuddy:",
FileBased: true,
},
{
Type: AgentForge,
DisplayName: "Forge",
EnvVar: "FORGE_DIR",
ConfigKey: "forge_dirs",
DefaultDirs: []string{".forge"},
IDPrefix: "forge:",
FileBased: false,
},
{
Type: AgentDevin,
DisplayName: "Devin",
EnvVar: "DEVIN_DIR",
ConfigKey: "devin_dirs",
DefaultDirs: []string{
"Library/Application Support/devin",
".local/share/devin",
},
IDPrefix: "devin:",
FileBased: false,
},
{
Type: AgentPiebald,
DisplayName: "Piebald",
EnvVar: "PIEBALD_DIR",
ConfigKey: "piebald_dirs",
DefaultDirs: []string{
// Linux
".local/share/piebald",
// macOS
"Library/Application Support/piebald",
// Windows
"AppData/Roaming/piebald",
},
IDPrefix: "piebald:",
FileBased: false,
},
{
Type: AgentWarp,
DisplayName: "Warp",
EnvVar: "WARP_DIR",
ConfigKey: "warp_dirs",
DefaultDirs: warpDefaultDirs(),
IDPrefix: "warp:",
FileBased: false,
},
{
Type: AgentPositron,
DisplayName: "Positron Assistant",
EnvVar: "POSITRON_DIR",
ConfigKey: "positron_dirs",
DefaultDirs: []string{
"Library/Application Support/Positron/User",
},
IDPrefix: "positron:",
WatchSubdirs: []string{"workspaceStorage"},
FileBased: true,
},
{
Type: AgentZCode,
DisplayName: "ZCode",
EnvVar: "ZCODE_DIR",
ConfigKey: "zcode_dirs",
DefaultDirs: []string{
".zcode/cli/db",
".zcode/cli",
},
IDPrefix: "zcode:",
FileBased: false,
Usage: UsageCapabilities{
NoPerMessageTokenData: true,
},
},
{
Type: AgentZed,
DisplayName: "Zed",
EnvVar: "ZED_DIR",
ConfigKey: "zed_dirs",
DefaultDirs: zedDefaultDirs(),
IDPrefix: "zed:",
FileBased: true,
WatchSubdirs: []string{"threads"},
},
{
Type: AgentAntigravity,
DisplayName: "Antigravity",
EnvVar: "ANTIGRAVITY_DIR",
ConfigKey: "antigravity_dirs",
DefaultDirs: []string{".gemini/antigravity"},
IDPrefix: "antigravity:",
WatchSubdirs: []string{
"conversations",
"brain",
"annotations",
},
FileBased: true,
},
{
Type: AgentAntigravityCLI,
DisplayName: "Antigravity CLI",
EnvVar: "ANTIGRAVITY_CLI_DIR",
ConfigKey: "antigravity_cli_dirs",
DefaultDirs: []string{".gemini/antigravity-cli"},
IDPrefix: "antigravity-cli:",
WatchSubdirs: []string{
"conversations",
"implicit",
"brain",
},
FileBased: true,
},
{
Type: AgentQwenPaw,
DisplayName: "QwenPaw",
EnvVar: "QWENPAW_DIR",
ConfigKey: "qwenpaw_dirs",
DefaultDirs: []string{".copaw/workspaces"},
IDPrefix: "qwenpaw:",
FileBased: true,
},
{
Type: AgentGptme,
DisplayName: "gptme",
EnvVar: "GPTME_DIR",
ConfigKey: "gptme_dirs",
DefaultDirs: []string{".local/share/gptme/logs"},
IDPrefix: "gptme:",
FileBased: true,
},
{
Type: AgentQoder,
DisplayName: "Qoder",
EnvVar: "QODER_PROJECTS_DIR",
ConfigKey: "qoder_project_dirs",
DefaultDirs: []string{
".qoder/projects",
".qoderwork/projects",
},
IDPrefix: "qoder:",
FileBased: true,
},
{
// Shelley (exe.dev) stores all conversations in a single
// SQLite DB at ~/.config/shelley/shelley.db. Like Zed, each
// conversation is addressed by a virtual path (dbPath#id).
Type: AgentShelley,
DisplayName: "Shelley",
EnvVar: "SHELLEY_DIR",
ConfigKey: "shelley_dirs",
DefaultDirs: []string{".config/shelley"},
IDPrefix: "shelley:",
FileBased: true,
},
{
Type: AgentVibe,
DisplayName: "Mistral Vibe",
EnvVar: "VIBE_SESSIONS_DIR",
ConfigKey: "vibe_session_dirs",
DefaultDirs: []string{".vibe/logs/session"},
IDPrefix: "vibe:",
FileBased: true,
},
{
// Aider has no central session store. It writes one Markdown
// chat log per repo at <repo>/.aider.chat.history.md. There is
// no safe canonical root: an always-on $HOME walk is prone to
// macOS privacy prompts (Documents/Downloads/Music/Photos) during
// passive background refreshes, and to surprising work. Users must
// opt in by setting AIDER_DIR or the aider_dirs config key to a
// code root they want scanned. A configured broad root such as
// $HOME still gets the bounded, symlink-safe, depth-capped,
// time-budgeted walk with protected-folder pruning.
//
// ShallowWatch is true because users can still opt into broad
// roots; watch those roots shallowly and rely on the 15-minute
// periodic sync to pick up new repos' history files. Aider history
// is append-mostly, so this is an acceptable latency tradeoff.
Type: AgentAider,
DisplayName: "Aider",
EnvVar: "AIDER_DIR",
ConfigKey: "aider_dirs",
IDPrefix: "aider:",
FileBased: true,
ShallowWatch: true,
},
{
Type: AgentReasonix,
DisplayName: "Reasonix",
EnvVar: "REASONIX_DIR",
ConfigKey: "reasonix_dirs",
DefaultDirs: []string{".reasonix", "AppData/Roaming/reasonix"},
IDPrefix: "reasonix:",
WatchSubdirs: []string{"sessions", "archive", "projects"},
FileBased: true,
},
{
Type: AgentIcodemate,
DisplayName: "IcodeMate",
EnvVar: "ICODEMATE_DIR",
ConfigKey: "icodemate_dirs",
DefaultDirs: []string{".local/share/icodemate"},
IDPrefix: "icodemate:",
WatchSubdirs: []string{"storage/session_diff"},
FileBased: true,
WatchRootsFunc: ResolveIcodemateWatchRoots,
},
}
// NonFileBackedAgents returns agent types where FileBased is false.
func NonFileBackedAgents() []AgentType {
var agents []AgentType
for _, def := range Registry {
if !def.FileBased {
agents = append(agents, def.Type)
}
}
return agents
}
// AgentByType returns the AgentDef for the given type.
func AgentByType(t AgentType) (AgentDef, bool) {
for _, def := range Registry {
if def.Type == t {
return def, true
}
}
return AgentDef{}, false
}
// AgentNameLacksPerMessageTokenData reports whether the named agent
// records no per-message token data. Names match registry types
// exactly and unknown names fail closed; CSV filter parsing trims its
// parts before calling.
func AgentNameLacksPerMessageTokenData(agent string) bool {
def, ok := AgentByType(AgentType(agent))
return ok && def.Usage.NoPerMessageTokenData
}
// AgentNameUsesAICredits reports whether the named agent's cost is
// denominated in AI credits rather than USD.
func AgentNameUsesAICredits(agent string) bool {
def, ok := AgentByType(AgentType(agent))
return ok && def.Usage.AICreditsDenominated
}
// AgentFilterLacksPerMessageTokenData reports whether a (possibly
// comma-separated) agent filter selects only agents without
// per-message token data, with at least one entry.
func AgentFilterLacksPerMessageTokenData(agentFilter string) bool {
return agentFilterMatches(agentFilter, AgentNameLacksPerMessageTokenData)
}
func agentFilterMatches(agentFilter string, match func(string) bool) bool {
matched := false
for part := range strings.SplitSeq(agentFilter, ",") {
part = strings.TrimSpace(part)
if part == "" {
continue
}
if !match(part) {
return false
}
matched = true
}
return matched
}
// AgentIsCopilot reports whether t is one of the GitHub Copilot
// family agents. Copilot-specific user-facing wording keys on this
// identity; the usage capabilities above intentionally do not imply
// it, so a future agent can adopt NoPerMessageTokenData or
// AICreditsDenominated without inheriting Copilot messaging.
func AgentIsCopilot(t AgentType) bool {
switch t {
case AgentCopilot, AgentVSCodeCopilot, AgentVSCopilot:
return true
}
return false
}
// AgentNameIsCopilot reports whether the agent name identifies a
// Copilot-family agent. Names match exactly, like the capability
// helpers above.
func AgentNameIsCopilot(agent string) bool {
return AgentIsCopilot(AgentType(agent))
}
// AgentFilterIsCopilot reports whether a (possibly comma-separated)
// agent filter selects only Copilot-family agents, with at least one
// entry.
func AgentFilterIsCopilot(agentFilter string) bool {
return agentFilterMatches(agentFilter, AgentNameIsCopilot)
}
// StripHostPrefix splits a remote session ID into its host
// and raw ID parts. Remote IDs use the form "host~rawID"
// where the "~" separator avoids conflict with both agent
// prefixes (":") and URL path segments ("/"). For local
// session IDs (no "~" present), host is empty and rawID is
// the original ID.
func StripHostPrefix(id string) (host, rawID string) {
if before, after, ok := strings.Cut(id, "~"); ok {
return before, after
}
return "", id
}
// AgentByPrefix returns the AgentDef whose IDPrefix matches
// the session ID. For Claude (empty prefix), the match
// succeeds only when no other prefix matches and the ID
// does not contain a colon. Host prefixes ("host~...") are
// stripped before matching.
func AgentByPrefix(sessionID string) (AgentDef, bool) {
_, rawID := StripHostPrefix(sessionID)
for _, def := range Registry {
if def.IDPrefix != "" &&
strings.HasPrefix(rawID, def.IDPrefix) {
return def, true
}
}
// No prefixed agent matched. Fall back to Claude only
// if the raw ID has no colon (unprefixed).
if !strings.Contains(rawID, ":") {
if def, ok := AgentByType(AgentClaude); ok {
return def, true
}
}
return AgentDef{}, false
}
// RelationshipType describes how a session relates to its parent.
type RelationshipType string
const (
RelNone RelationshipType = ""
RelContinuation RelationshipType = "continuation"
RelSubagent RelationshipType = "subagent"
RelFork RelationshipType = "fork"
)
// RoleType identifies the role of a message sender.
type RoleType string
const (
RoleUser RoleType = "user"
RoleAssistant RoleType = "assistant"
// RoleSystem and RoleTool are emitted by several parsers (for
// system-injected notices and standalone tool-result records) and
// persist to the messages table, so they are part of the known
// role enum even though the user/assistant pair carries the common
// case.
RoleSystem RoleType = "system"
RoleTool RoleType = "tool"
)
// Transcript fidelity values for ParsedSession.TranscriptFidelity. Empty
// is treated as full (no degradation signalled).
const (
TranscriptFidelityFull = "full"
TranscriptFidelitySummary = "summary"
)
// FileInfo holds file system metadata for a session source file.
type FileInfo struct {
Path string
Size int64
Mtime int64
Inode int64
Device int64
Hash string
}
// ParsedSession holds session metadata extracted from a JSONL file.
type ParsedSession struct {
ID string
Project string
Machine string
Agent AgentType
ParentSessionID string
RelationshipType RelationshipType
Cwd string
GitBranch string
SourceSessionID string
SourceVersion string
// TranscriptFidelity classifies how complete a stored transcript is
// relative to the agent's full session data: "full" when the
// high-resolution source was used, "summary" for a degraded/fallback
// decode. Empty means full (parser did not classify). Currently set
// only by the Antigravity CLI parser.
TranscriptFidelity string
// GenMetadataWithoutUsage reports whether this Antigravity session's steps
// table carried gen_metadata rows but none decoded into a usage event --
// an early warning that a newer agy build changed the gen_metadata wire
// format the token-block heuristic depends on. Set by both Antigravity
// parsers; false for every other agent.
GenMetadataWithoutUsage bool
MalformedLines int
IsTruncated bool
FirstMessage string
SessionName string
StartedAt time.Time
EndedAt time.Time
MessageCount int
UserMessageCount int
File FileInfo
// TerminationStatus describes how the session appears to have
// ended. Empty string = unknown (parser did not classify, or
// agent format does not yet support classification).
TerminationStatus TerminationStatus
TotalOutputTokens int
PeakContextTokens int
HasTotalOutputTokens bool
HasPeakContextTokens bool
// UsageEvents carries parser-emitted aggregate usage rows for
// agents whose session-level accounting is computed inline
// (e.g. VSCode Copilot). The sync engine forwards these into
// the usage_events table for catalog-based cost pricing.
UsageEvents []ParsedUsageEvent
// aggregateTokenPresenceKnown marks session aggregate token
// coverage as parser-owned and authoritative.
aggregateTokenPresenceKnown bool
}
// ParsedToolCall holds a single tool invocation extracted from
// a message.
type ParsedToolCall struct {
ToolUseID string // tool_use block id from session data
ToolName string // raw name from session data
Category string // normalized: Read, Edit, Write, Bash, etc.
InputJSON string // raw JSON of the input object
FilePath string // resolved edit/write target path, when known natively
SkillName string // skill name when ToolName is "Skill"
SubagentSessionID string // linked subagent session file (e.g. "agent-{task_id}")
ResultEvents []ParsedToolResultEvent
}
// ParsedToolResult holds metadata about a tool result block in a
// user message (the response to a prior tool_use).
type ParsedToolResult struct {
ToolUseID string
ContentLength int
ContentRaw string // raw JSON of the content field; decode with DecodeContent
}
// ParsedToolResultEvent is a canonical chronological update attached
// to a tool call. Used for Codex subagent terminal status updates.
type ParsedToolResultEvent struct {
ToolUseID string
AgentID string
SubagentSessionID string
Source string
Status string
Content string
Timestamp time.Time
}
// ParsedMessage holds a single extracted message.
type ParsedMessage struct {
Ordinal int
Role RoleType
Content string
ThinkingText string // concatenated text of all thinking blocks; "" if none
Timestamp time.Time
HasThinking bool
HasToolUse bool
IsSystem bool
ContentLength int
ToolCalls []ParsedToolCall
ToolResults []ParsedToolResult
Model string
TokenUsage json.RawMessage
ContextTokens int
OutputTokens int
HasContextTokens bool
HasOutputTokens bool
// ClaudeMessageID and ClaudeRequestID hold the provider's
// per-response identifiers. Used for cross-file / cross-session
// deduplication when summing token usage, matching ccusage's
// `${messageId}:${requestId}` hash. Only populated by the
// Claude parser; empty for all other agents.
ClaudeMessageID string
ClaudeRequestID string
SourceType string
SourceSubtype string
SourceUUID string
SourceParentUUID string
IsSidechain bool
IsCompactBoundary bool
// StopReason is the reason the assistant stopped generating
// (Claude: "end_turn", "tool_use", "max_tokens", "stop_sequence";
// other agents may use their own vocabulary or leave it empty).
// Only populated for assistant messages where the parser sees
// the field. Empty when unknown.
StopReason string
// tokenPresenceKnown marks per-message token coverage as
// parser-owned and authoritative.
tokenPresenceKnown bool
}
// ParsedUsageEvent records session-level usage emitted by parsers
// when an agent exposes aggregate accounting instead of per-message
// token_usage rows.
type ParsedUsageEvent struct {
SessionID string
MessageOrdinal *int
Source string
Model string
InputTokens int