@morlay/session-rdb 0.0.17 → 0.0.19
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/dist/artifact.d.mts +1 -1
- package/dist/artifact.mjs +1 -1
- package/dist/{import-DZIAjOUr.mjs → import-Bc2QQa5G.mjs} +14 -5
- package/dist/import.d.mts +3 -2
- package/dist/import.mjs +1 -1
- package/dist/{index-BEKoV1Uy.d.mts → index-CCcK9tia.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +93 -39
- package/dist/{magic-string.es-BWtG0AyA.mjs → magic-string.es-BgJoa-3K.mjs} +2 -2
- package/dist/{schema-Bo6Hy5gW.d.mts → schema-DPcuEh_a.d.mts} +36 -47
- package/dist/{sqlite-BIPdMNQb.mjs → sqlite-DYExtbLo.mjs} +27 -6
- package/dist/storage.d.mts +1 -1
- package/dist/storage.mjs +1 -1
- package/dist/testing.mjs +20 -20
- package/drizzle/postgres/20260910120001_v3_storage_tables/snapshot.json +25 -78
- package/drizzle/postgres/20260910130001_v3_session_title_backfill/snapshot.json +25 -78
- package/drizzle/sqlite/20260910120000_v3_storage_tables/snapshot.json +25 -78
- package/drizzle/sqlite/20260910130000_v3_session_title_backfill/snapshot.json +25 -78
- package/package.json +20 -19
- package/src/entities/v3/workspace-state.ts +1 -1
- package/src/import-storages.ts +8 -3
- package/src/import.ts +41 -4
- package/src/index.ts +10 -2
- package/src/postgres.ts +15 -9
- package/src/session-query.ts +27 -0
- package/src/storage-takeover/index.ts +8 -8
- package/src/storage-takeover/projection-cache.ts +50 -24
- package/src/storage-takeover/repository.ts +66 -20
- package/src/storage-takeover/storage-backend.ts +65 -21
- package/src/storage-takeover/types.ts +11 -3
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
"version": "7",
|
|
3
3
|
"dialect": "sqlite",
|
|
4
4
|
"id": "1d8acf30-2759-4afb-9aa6-81ee2b470237",
|
|
5
|
-
"prevIds": [
|
|
6
|
-
"73c73ac0-f96e-4579-8784-04343de1a0d7"
|
|
7
|
-
],
|
|
5
|
+
"prevIds": ["73c73ac0-f96e-4579-8784-04343de1a0d7"],
|
|
8
6
|
"ddl": [
|
|
9
7
|
{
|
|
10
8
|
"name": "t_events",
|
|
@@ -357,13 +355,9 @@
|
|
|
357
355
|
"table": "t_sessions"
|
|
358
356
|
},
|
|
359
357
|
{
|
|
360
|
-
"columns": [
|
|
361
|
-
"f_session_id"
|
|
362
|
-
],
|
|
358
|
+
"columns": ["f_session_id"],
|
|
363
359
|
"tableTo": "t_sessions",
|
|
364
|
-
"columnsTo": [
|
|
365
|
-
"f_session_id"
|
|
366
|
-
],
|
|
360
|
+
"columnsTo": ["f_session_id"],
|
|
367
361
|
"onUpdate": "NO ACTION",
|
|
368
362
|
"onDelete": "CASCADE",
|
|
369
363
|
"nameExplicit": false,
|
|
@@ -372,13 +366,9 @@
|
|
|
372
366
|
"table": "t_session_events"
|
|
373
367
|
},
|
|
374
368
|
{
|
|
375
|
-
"columns": [
|
|
376
|
-
"f_event_id"
|
|
377
|
-
],
|
|
369
|
+
"columns": ["f_event_id"],
|
|
378
370
|
"tableTo": "t_events",
|
|
379
|
-
"columnsTo": [
|
|
380
|
-
"f_event_id"
|
|
381
|
-
],
|
|
371
|
+
"columnsTo": ["f_event_id"],
|
|
382
372
|
"onUpdate": "NO ACTION",
|
|
383
373
|
"onDelete": "CASCADE",
|
|
384
374
|
"nameExplicit": false,
|
|
@@ -387,45 +377,35 @@
|
|
|
387
377
|
"table": "t_session_events"
|
|
388
378
|
},
|
|
389
379
|
{
|
|
390
|
-
"columns": [
|
|
391
|
-
"f_id"
|
|
392
|
-
],
|
|
380
|
+
"columns": ["f_id"],
|
|
393
381
|
"nameExplicit": false,
|
|
394
382
|
"name": "t_events_pk",
|
|
395
383
|
"table": "t_events",
|
|
396
384
|
"entityType": "pks"
|
|
397
385
|
},
|
|
398
386
|
{
|
|
399
|
-
"columns": [
|
|
400
|
-
"f_singleton"
|
|
401
|
-
],
|
|
387
|
+
"columns": ["f_singleton"],
|
|
402
388
|
"nameExplicit": false,
|
|
403
389
|
"name": "t_persistence_state_pk",
|
|
404
390
|
"table": "t_persistence_state",
|
|
405
391
|
"entityType": "pks"
|
|
406
392
|
},
|
|
407
393
|
{
|
|
408
|
-
"columns": [
|
|
409
|
-
"f_key"
|
|
410
|
-
],
|
|
394
|
+
"columns": ["f_key"],
|
|
411
395
|
"nameExplicit": false,
|
|
412
396
|
"name": "t_schema_meta_pk",
|
|
413
397
|
"table": "t_schema_meta",
|
|
414
398
|
"entityType": "pks"
|
|
415
399
|
},
|
|
416
400
|
{
|
|
417
|
-
"columns": [
|
|
418
|
-
"f_id"
|
|
419
|
-
],
|
|
401
|
+
"columns": ["f_id"],
|
|
420
402
|
"nameExplicit": false,
|
|
421
403
|
"name": "t_session_events_pk",
|
|
422
404
|
"table": "t_session_events",
|
|
423
405
|
"entityType": "pks"
|
|
424
406
|
},
|
|
425
407
|
{
|
|
426
|
-
"columns": [
|
|
427
|
-
"f_id"
|
|
428
|
-
],
|
|
408
|
+
"columns": ["f_id"],
|
|
429
409
|
"nameExplicit": false,
|
|
430
410
|
"name": "t_sessions_pk",
|
|
431
411
|
"table": "t_sessions",
|
|
@@ -502,28 +482,21 @@
|
|
|
502
482
|
"table": "t_session_events"
|
|
503
483
|
},
|
|
504
484
|
{
|
|
505
|
-
"columns": [
|
|
506
|
-
"f_session_id",
|
|
507
|
-
"f_sequence"
|
|
508
|
-
],
|
|
485
|
+
"columns": ["f_session_id", "f_sequence"],
|
|
509
486
|
"nameExplicit": true,
|
|
510
487
|
"name": "uq_session_events_session_sequence",
|
|
511
488
|
"entityType": "uniques",
|
|
512
489
|
"table": "t_session_events"
|
|
513
490
|
},
|
|
514
491
|
{
|
|
515
|
-
"columns": [
|
|
516
|
-
"f_event_id"
|
|
517
|
-
],
|
|
492
|
+
"columns": ["f_event_id"],
|
|
518
493
|
"nameExplicit": false,
|
|
519
494
|
"name": "t_events_f_event_id_unique",
|
|
520
495
|
"entityType": "uniques",
|
|
521
496
|
"table": "t_events"
|
|
522
497
|
},
|
|
523
498
|
{
|
|
524
|
-
"columns": [
|
|
525
|
-
"f_session_id"
|
|
526
|
-
],
|
|
499
|
+
"columns": ["f_session_id"],
|
|
527
500
|
"nameExplicit": false,
|
|
528
501
|
"name": "t_sessions_f_session_id_unique",
|
|
529
502
|
"entityType": "uniques",
|
|
@@ -816,74 +789,56 @@
|
|
|
816
789
|
"table": "t_workspace_sessions"
|
|
817
790
|
},
|
|
818
791
|
{
|
|
819
|
-
"columns": [
|
|
820
|
-
"f_id"
|
|
821
|
-
],
|
|
792
|
+
"columns": ["f_id"],
|
|
822
793
|
"nameExplicit": false,
|
|
823
794
|
"name": "t_session_projcache_row_pk",
|
|
824
795
|
"table": "t_session_projcache_row",
|
|
825
796
|
"entityType": "pks"
|
|
826
797
|
},
|
|
827
798
|
{
|
|
828
|
-
"columns": [
|
|
829
|
-
"f_name"
|
|
830
|
-
],
|
|
799
|
+
"columns": ["f_name"],
|
|
831
800
|
"nameExplicit": false,
|
|
832
801
|
"name": "t_storage_units_pk",
|
|
833
802
|
"table": "t_storage_units",
|
|
834
803
|
"entityType": "pks"
|
|
835
804
|
},
|
|
836
805
|
{
|
|
837
|
-
"columns": [
|
|
838
|
-
"f_singleton"
|
|
839
|
-
],
|
|
806
|
+
"columns": ["f_singleton"],
|
|
840
807
|
"nameExplicit": false,
|
|
841
808
|
"name": "t_workspace_state_pk",
|
|
842
809
|
"table": "t_workspace_state",
|
|
843
810
|
"entityType": "pks"
|
|
844
811
|
},
|
|
845
812
|
{
|
|
846
|
-
"columns": [
|
|
847
|
-
"f_id"
|
|
848
|
-
],
|
|
813
|
+
"columns": ["f_id"],
|
|
849
814
|
"nameExplicit": false,
|
|
850
815
|
"name": "t_workspaces_pk",
|
|
851
816
|
"table": "t_workspaces",
|
|
852
817
|
"entityType": "pks"
|
|
853
818
|
},
|
|
854
819
|
{
|
|
855
|
-
"columns": [
|
|
856
|
-
"f_id"
|
|
857
|
-
],
|
|
820
|
+
"columns": ["f_id"],
|
|
858
821
|
"nameExplicit": false,
|
|
859
822
|
"name": "t_workspace_sessions_pk",
|
|
860
823
|
"table": "t_workspace_sessions",
|
|
861
824
|
"entityType": "pks"
|
|
862
825
|
},
|
|
863
826
|
{
|
|
864
|
-
"columns": [
|
|
865
|
-
"f_session_id",
|
|
866
|
-
"f_key"
|
|
867
|
-
],
|
|
827
|
+
"columns": ["f_session_id", "f_key"],
|
|
868
828
|
"nameExplicit": true,
|
|
869
829
|
"name": "uq_session_projcache_row_session_key",
|
|
870
830
|
"entityType": "uniques",
|
|
871
831
|
"table": "t_session_projcache_row"
|
|
872
832
|
},
|
|
873
833
|
{
|
|
874
|
-
"columns": [
|
|
875
|
-
"f_workspace_id"
|
|
876
|
-
],
|
|
834
|
+
"columns": ["f_workspace_id"],
|
|
877
835
|
"nameExplicit": false,
|
|
878
836
|
"name": "t_workspaces_f_workspace_id_unique",
|
|
879
837
|
"entityType": "uniques",
|
|
880
838
|
"table": "t_workspaces"
|
|
881
839
|
},
|
|
882
840
|
{
|
|
883
|
-
"columns": [
|
|
884
|
-
"f_workspace_id",
|
|
885
|
-
"f_session_id"
|
|
886
|
-
],
|
|
841
|
+
"columns": ["f_workspace_id", "f_session_id"],
|
|
887
842
|
"nameExplicit": true,
|
|
888
843
|
"name": "uq_workspace_sessions_workspace_session",
|
|
889
844
|
"entityType": "uniques",
|
|
@@ -924,13 +879,9 @@
|
|
|
924
879
|
"table": "t_workspace_state"
|
|
925
880
|
},
|
|
926
881
|
{
|
|
927
|
-
"columns": [
|
|
928
|
-
"f_session_id"
|
|
929
|
-
],
|
|
882
|
+
"columns": ["f_session_id"],
|
|
930
883
|
"tableTo": "t_sessions",
|
|
931
|
-
"columnsTo": [
|
|
932
|
-
"f_session_id"
|
|
933
|
-
],
|
|
884
|
+
"columnsTo": ["f_session_id"],
|
|
934
885
|
"onUpdate": "NO ACTION",
|
|
935
886
|
"onDelete": "CASCADE",
|
|
936
887
|
"nameExplicit": false,
|
|
@@ -939,13 +890,9 @@
|
|
|
939
890
|
"table": "t_session_projcache_row"
|
|
940
891
|
},
|
|
941
892
|
{
|
|
942
|
-
"columns": [
|
|
943
|
-
"f_workspace_id"
|
|
944
|
-
],
|
|
893
|
+
"columns": ["f_workspace_id"],
|
|
945
894
|
"tableTo": "t_workspaces",
|
|
946
|
-
"columnsTo": [
|
|
947
|
-
"f_workspace_id"
|
|
948
|
-
],
|
|
895
|
+
"columnsTo": ["f_workspace_id"],
|
|
949
896
|
"onUpdate": "NO ACTION",
|
|
950
897
|
"onDelete": "CASCADE",
|
|
951
898
|
"nameExplicit": false,
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
"version": "7",
|
|
3
3
|
"dialect": "sqlite",
|
|
4
4
|
"id": "9f0f3ef7-6951-441e-ac74-b4eb613de8b4",
|
|
5
|
-
"prevIds": [
|
|
6
|
-
"1d8acf30-2759-4afb-9aa6-81ee2b470237"
|
|
7
|
-
],
|
|
5
|
+
"prevIds": ["1d8acf30-2759-4afb-9aa6-81ee2b470237"],
|
|
8
6
|
"ddl": [
|
|
9
7
|
{
|
|
10
8
|
"name": "t_events",
|
|
@@ -357,13 +355,9 @@
|
|
|
357
355
|
"table": "t_sessions"
|
|
358
356
|
},
|
|
359
357
|
{
|
|
360
|
-
"columns": [
|
|
361
|
-
"f_session_id"
|
|
362
|
-
],
|
|
358
|
+
"columns": ["f_session_id"],
|
|
363
359
|
"tableTo": "t_sessions",
|
|
364
|
-
"columnsTo": [
|
|
365
|
-
"f_session_id"
|
|
366
|
-
],
|
|
360
|
+
"columnsTo": ["f_session_id"],
|
|
367
361
|
"onUpdate": "NO ACTION",
|
|
368
362
|
"onDelete": "CASCADE",
|
|
369
363
|
"nameExplicit": false,
|
|
@@ -372,13 +366,9 @@
|
|
|
372
366
|
"table": "t_session_events"
|
|
373
367
|
},
|
|
374
368
|
{
|
|
375
|
-
"columns": [
|
|
376
|
-
"f_event_id"
|
|
377
|
-
],
|
|
369
|
+
"columns": ["f_event_id"],
|
|
378
370
|
"tableTo": "t_events",
|
|
379
|
-
"columnsTo": [
|
|
380
|
-
"f_event_id"
|
|
381
|
-
],
|
|
371
|
+
"columnsTo": ["f_event_id"],
|
|
382
372
|
"onUpdate": "NO ACTION",
|
|
383
373
|
"onDelete": "CASCADE",
|
|
384
374
|
"nameExplicit": false,
|
|
@@ -387,45 +377,35 @@
|
|
|
387
377
|
"table": "t_session_events"
|
|
388
378
|
},
|
|
389
379
|
{
|
|
390
|
-
"columns": [
|
|
391
|
-
"f_id"
|
|
392
|
-
],
|
|
380
|
+
"columns": ["f_id"],
|
|
393
381
|
"nameExplicit": false,
|
|
394
382
|
"name": "t_events_pk",
|
|
395
383
|
"table": "t_events",
|
|
396
384
|
"entityType": "pks"
|
|
397
385
|
},
|
|
398
386
|
{
|
|
399
|
-
"columns": [
|
|
400
|
-
"f_singleton"
|
|
401
|
-
],
|
|
387
|
+
"columns": ["f_singleton"],
|
|
402
388
|
"nameExplicit": false,
|
|
403
389
|
"name": "t_persistence_state_pk",
|
|
404
390
|
"table": "t_persistence_state",
|
|
405
391
|
"entityType": "pks"
|
|
406
392
|
},
|
|
407
393
|
{
|
|
408
|
-
"columns": [
|
|
409
|
-
"f_key"
|
|
410
|
-
],
|
|
394
|
+
"columns": ["f_key"],
|
|
411
395
|
"nameExplicit": false,
|
|
412
396
|
"name": "t_schema_meta_pk",
|
|
413
397
|
"table": "t_schema_meta",
|
|
414
398
|
"entityType": "pks"
|
|
415
399
|
},
|
|
416
400
|
{
|
|
417
|
-
"columns": [
|
|
418
|
-
"f_id"
|
|
419
|
-
],
|
|
401
|
+
"columns": ["f_id"],
|
|
420
402
|
"nameExplicit": false,
|
|
421
403
|
"name": "t_session_events_pk",
|
|
422
404
|
"table": "t_session_events",
|
|
423
405
|
"entityType": "pks"
|
|
424
406
|
},
|
|
425
407
|
{
|
|
426
|
-
"columns": [
|
|
427
|
-
"f_id"
|
|
428
|
-
],
|
|
408
|
+
"columns": ["f_id"],
|
|
429
409
|
"nameExplicit": false,
|
|
430
410
|
"name": "t_sessions_pk",
|
|
431
411
|
"table": "t_sessions",
|
|
@@ -502,28 +482,21 @@
|
|
|
502
482
|
"table": "t_session_events"
|
|
503
483
|
},
|
|
504
484
|
{
|
|
505
|
-
"columns": [
|
|
506
|
-
"f_session_id",
|
|
507
|
-
"f_sequence"
|
|
508
|
-
],
|
|
485
|
+
"columns": ["f_session_id", "f_sequence"],
|
|
509
486
|
"nameExplicit": true,
|
|
510
487
|
"name": "uq_session_events_session_sequence",
|
|
511
488
|
"entityType": "uniques",
|
|
512
489
|
"table": "t_session_events"
|
|
513
490
|
},
|
|
514
491
|
{
|
|
515
|
-
"columns": [
|
|
516
|
-
"f_event_id"
|
|
517
|
-
],
|
|
492
|
+
"columns": ["f_event_id"],
|
|
518
493
|
"nameExplicit": false,
|
|
519
494
|
"name": "t_events_f_event_id_unique",
|
|
520
495
|
"entityType": "uniques",
|
|
521
496
|
"table": "t_events"
|
|
522
497
|
},
|
|
523
498
|
{
|
|
524
|
-
"columns": [
|
|
525
|
-
"f_session_id"
|
|
526
|
-
],
|
|
499
|
+
"columns": ["f_session_id"],
|
|
527
500
|
"nameExplicit": false,
|
|
528
501
|
"name": "t_sessions_f_session_id_unique",
|
|
529
502
|
"entityType": "uniques",
|
|
@@ -816,74 +789,56 @@
|
|
|
816
789
|
"table": "t_workspace_sessions"
|
|
817
790
|
},
|
|
818
791
|
{
|
|
819
|
-
"columns": [
|
|
820
|
-
"f_id"
|
|
821
|
-
],
|
|
792
|
+
"columns": ["f_id"],
|
|
822
793
|
"nameExplicit": false,
|
|
823
794
|
"name": "t_session_projcache_row_pk",
|
|
824
795
|
"table": "t_session_projcache_row",
|
|
825
796
|
"entityType": "pks"
|
|
826
797
|
},
|
|
827
798
|
{
|
|
828
|
-
"columns": [
|
|
829
|
-
"f_name"
|
|
830
|
-
],
|
|
799
|
+
"columns": ["f_name"],
|
|
831
800
|
"nameExplicit": false,
|
|
832
801
|
"name": "t_storage_units_pk",
|
|
833
802
|
"table": "t_storage_units",
|
|
834
803
|
"entityType": "pks"
|
|
835
804
|
},
|
|
836
805
|
{
|
|
837
|
-
"columns": [
|
|
838
|
-
"f_singleton"
|
|
839
|
-
],
|
|
806
|
+
"columns": ["f_singleton"],
|
|
840
807
|
"nameExplicit": false,
|
|
841
808
|
"name": "t_workspace_state_pk",
|
|
842
809
|
"table": "t_workspace_state",
|
|
843
810
|
"entityType": "pks"
|
|
844
811
|
},
|
|
845
812
|
{
|
|
846
|
-
"columns": [
|
|
847
|
-
"f_id"
|
|
848
|
-
],
|
|
813
|
+
"columns": ["f_id"],
|
|
849
814
|
"nameExplicit": false,
|
|
850
815
|
"name": "t_workspaces_pk",
|
|
851
816
|
"table": "t_workspaces",
|
|
852
817
|
"entityType": "pks"
|
|
853
818
|
},
|
|
854
819
|
{
|
|
855
|
-
"columns": [
|
|
856
|
-
"f_id"
|
|
857
|
-
],
|
|
820
|
+
"columns": ["f_id"],
|
|
858
821
|
"nameExplicit": false,
|
|
859
822
|
"name": "t_workspace_sessions_pk",
|
|
860
823
|
"table": "t_workspace_sessions",
|
|
861
824
|
"entityType": "pks"
|
|
862
825
|
},
|
|
863
826
|
{
|
|
864
|
-
"columns": [
|
|
865
|
-
"f_session_id",
|
|
866
|
-
"f_key"
|
|
867
|
-
],
|
|
827
|
+
"columns": ["f_session_id", "f_key"],
|
|
868
828
|
"nameExplicit": true,
|
|
869
829
|
"name": "uq_session_projcache_row_session_key",
|
|
870
830
|
"entityType": "uniques",
|
|
871
831
|
"table": "t_session_projcache_row"
|
|
872
832
|
},
|
|
873
833
|
{
|
|
874
|
-
"columns": [
|
|
875
|
-
"f_workspace_id"
|
|
876
|
-
],
|
|
834
|
+
"columns": ["f_workspace_id"],
|
|
877
835
|
"nameExplicit": false,
|
|
878
836
|
"name": "t_workspaces_f_workspace_id_unique",
|
|
879
837
|
"entityType": "uniques",
|
|
880
838
|
"table": "t_workspaces"
|
|
881
839
|
},
|
|
882
840
|
{
|
|
883
|
-
"columns": [
|
|
884
|
-
"f_workspace_id",
|
|
885
|
-
"f_session_id"
|
|
886
|
-
],
|
|
841
|
+
"columns": ["f_workspace_id", "f_session_id"],
|
|
887
842
|
"nameExplicit": true,
|
|
888
843
|
"name": "uq_workspace_sessions_workspace_session",
|
|
889
844
|
"entityType": "uniques",
|
|
@@ -924,13 +879,9 @@
|
|
|
924
879
|
"table": "t_workspace_state"
|
|
925
880
|
},
|
|
926
881
|
{
|
|
927
|
-
"columns": [
|
|
928
|
-
"f_session_id"
|
|
929
|
-
],
|
|
882
|
+
"columns": ["f_session_id"],
|
|
930
883
|
"tableTo": "t_sessions",
|
|
931
|
-
"columnsTo": [
|
|
932
|
-
"f_session_id"
|
|
933
|
-
],
|
|
884
|
+
"columnsTo": ["f_session_id"],
|
|
934
885
|
"onUpdate": "NO ACTION",
|
|
935
886
|
"onDelete": "CASCADE",
|
|
936
887
|
"nameExplicit": false,
|
|
@@ -939,13 +890,9 @@
|
|
|
939
890
|
"table": "t_session_projcache_row"
|
|
940
891
|
},
|
|
941
892
|
{
|
|
942
|
-
"columns": [
|
|
943
|
-
"f_workspace_id"
|
|
944
|
-
],
|
|
893
|
+
"columns": ["f_workspace_id"],
|
|
945
894
|
"tableTo": "t_workspaces",
|
|
946
|
-
"columnsTo": [
|
|
947
|
-
"f_workspace_id"
|
|
948
|
-
],
|
|
895
|
+
"columnsTo": ["f_workspace_id"],
|
|
949
896
|
"onUpdate": "NO ACTION",
|
|
950
897
|
"onDelete": "CASCADE",
|
|
951
898
|
"nameExplicit": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morlay/session-rdb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "RDB durable session backend for DeepSeek Harness: implements both session-persistence and session-branch (rewind / retry / fork) providers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"branch",
|
|
@@ -35,33 +35,34 @@
|
|
|
35
35
|
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@morlay/session-branch": "^0.0.
|
|
38
|
+
"@morlay/session-branch": "^0.0.7",
|
|
39
39
|
"drizzle-orm": "^1.0.0-rc.5-ab785fc",
|
|
40
40
|
"fflate": "^0.8.2",
|
|
41
41
|
"pg": "^8.23.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.5-rc.
|
|
45
|
-
"@deepseek-ai/dsh-session-projection-cache": "^0.1.5-rc.
|
|
46
|
-
"@deepseek-ai/dsh-session-turn-outline": "^0.1.5-rc.
|
|
47
|
-
"@deepseek-ai/dsh-storage": "^0.1.5-rc.
|
|
48
|
-
"@deepseek-ai/dsh-storage-domain": "^0.1.5-rc.
|
|
49
|
-
"@deepseek-ai/dsh-token-meter": "^0.1.5-rc.
|
|
50
|
-
"@deepseek-ai/dsh-workspace": "^0.1.5-rc.
|
|
44
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.5-rc.2",
|
|
45
|
+
"@deepseek-ai/dsh-session-projection-cache": "^0.1.5-rc.2",
|
|
46
|
+
"@deepseek-ai/dsh-session-turn-outline": "^0.1.5-rc.2",
|
|
47
|
+
"@deepseek-ai/dsh-storage": "^0.1.5-rc.2",
|
|
48
|
+
"@deepseek-ai/dsh-storage-domain": "^0.1.5-rc.2",
|
|
49
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.5-rc.2",
|
|
50
|
+
"@deepseek-ai/dsh-workspace": "^0.1.5-rc.2",
|
|
51
51
|
"@types/pg": "^8.23.1",
|
|
52
52
|
"drizzle-kit": "1.0.0-rc.5-ab785fc"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
56
|
-
"@deepseek-ai/dsh-invariants": "^0.1.5-rc.
|
|
57
|
-
"@deepseek-ai/dsh-llm": "^0.1.5-rc.
|
|
58
|
-
"@deepseek-ai/dsh-scope": "^0.1.5-rc.
|
|
59
|
-
"@deepseek-ai/dsh-session": "^0.1.5-rc.
|
|
60
|
-
"@deepseek-ai/dsh-session-format": "^0.1.5-rc.
|
|
61
|
-
"@deepseek-ai/dsh-session-format-catalog": "^0.1.5-rc.
|
|
62
|
-
"@deepseek-ai/dsh-session-persistence": "^0.1.5-rc.
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-
|
|
56
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-scope": "^0.1.5-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-session": "^0.1.5-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-session-format": "^0.1.5-rc.2",
|
|
61
|
+
"@deepseek-ai/dsh-session-format-catalog": "^0.1.5-rc.2",
|
|
62
|
+
"@deepseek-ai/dsh-session-persistence": "^0.1.5-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-session-query": "^0.1.5-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-storage": "^0.1.5-rc.2",
|
|
65
66
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
66
67
|
},
|
|
67
68
|
"dsh": {
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"magic-string": "0.30.21",
|
|
82
83
|
"tinyrainbow": "3.1.1",
|
|
83
84
|
"vitest": "4.1.11",
|
|
84
|
-
"zod": "4.6.
|
|
85
|
+
"zod": "4.6.4"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"build": "pnpm exec tsdown",
|
|
@@ -4,7 +4,7 @@ import type { TableDef } from "../../adapters/types.ts";
|
|
|
4
4
|
* workspace 域 global 单例(上游 `workspaceDomainState`):`initialized` 是
|
|
5
5
|
* 引导标记,`pendingMutation` 拆成操作与目标两列(create / delete 的可恢复
|
|
6
6
|
* 两写标记)。显示顺序(`workspaceIds`)在 `t_workspaces.f_position`,
|
|
7
|
-
*
|
|
7
|
+
* 归档集由 `t_sessions.f_archived_at` 承载(归档不触碰归属槽位)。
|
|
8
8
|
*/
|
|
9
9
|
export const workspaceState: TableDef = {
|
|
10
10
|
name: "t_workspace_state",
|
package/src/import-storages.ts
CHANGED
|
@@ -42,9 +42,11 @@ export interface StoragesImportOptions {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const WORKSPACE_UNIT = "workspace";
|
|
45
|
-
|
|
45
|
+
/** 旧 workspace 文档可接受的域版本集(对齐上游 `workspaceDomainSpec`,见对齐测试)。 */
|
|
46
|
+
export const WORKSPACE_UNIT_VERSIONS: ReadonlySet<number> = new Set([2]);
|
|
46
47
|
const PROJCACHE_UNIT = "session_projcache";
|
|
47
|
-
|
|
48
|
+
/** 旧投影缓存文档可接受的域版本集(对齐上游 spec 的 version ∪ compatibleVersions)。 */
|
|
49
|
+
export const PROJCACHE_UNIT_VERSIONS: ReadonlySet<number> = new Set([7, 3, 4, 5, 6]);
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* Import the legacy storages documents into the rdb tables.
|
|
@@ -62,7 +64,10 @@ export async function importStorages(
|
|
|
62
64
|
const workspaceDocument = await readJson(join(storagesRoot, `${WORKSPACE_UNIT}.json`));
|
|
63
65
|
if (workspaceDocument !== undefined) {
|
|
64
66
|
const tables = unitTables(workspaceDocument, WORKSPACE_UNIT, WORKSPACE_UNIT_VERSIONS);
|
|
65
|
-
await repository.insertUnitVersion(
|
|
67
|
+
await repository.insertUnitVersion(
|
|
68
|
+
WORKSPACE_UNIT,
|
|
69
|
+
WORKSPACE_UNIT_VERSIONS.values().next().value as number,
|
|
70
|
+
);
|
|
66
71
|
for (const [id, record] of Object.entries(tables["workspaces"] ?? {})) {
|
|
67
72
|
await repository.putWorkspace(id, record as WorkspaceRecord);
|
|
68
73
|
result.workspaces += 1;
|
package/src/import.ts
CHANGED
|
@@ -2,12 +2,14 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import type { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
import { SESSION_FORMAT_VERSION, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
4
4
|
import type { Session, SessionEvent, SessionId, SessionHeader } from "@deepseek-ai/dsh-session";
|
|
5
|
+
import { parseSessionFormatLogFilename } from "@deepseek-ai/dsh-session-format";
|
|
5
6
|
import { sessionFormatCatalog } from "@deepseek-ai/dsh-session-format-catalog";
|
|
6
7
|
import type { SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
7
8
|
import { unzipSync } from "fflate";
|
|
8
9
|
import { replaceLiveSessionLog } from "./branch.ts";
|
|
9
10
|
import type { SessionPersistenceRdb } from "./index.ts";
|
|
10
11
|
|
|
12
|
+
/** 当前世代产物的文件名(读入侧接受任意 canonical 世代名,见 parseImportZip)。 */
|
|
11
13
|
export const SESSION_LOG_ARTIFACT_FILENAME = "session.jsonl";
|
|
12
14
|
|
|
13
15
|
export const SESSION_IMPORT_PATH = "/api/session.import";
|
|
@@ -107,11 +109,36 @@ export function parseImportZip(zip: Uint8Array): SessionStorageMetadata & {
|
|
|
107
109
|
} catch {
|
|
108
110
|
throw new Error("imported zip is not a valid ZIP archive");
|
|
109
111
|
}
|
|
110
|
-
|
|
112
|
+
// 上游导出按世代命名(`session.v3.jsonl`),早期 rdb 导出沿用 `session.jsonl`:
|
|
113
|
+
// 两者都接受,按 canonical 名字规则识别(临时/大写/压缩后缀名不视为产物)。
|
|
114
|
+
const artifact = Object.entries(entries).find(
|
|
115
|
+
([name]) => parseSessionFormatLogFilename(name) !== undefined,
|
|
116
|
+
);
|
|
111
117
|
if (artifact === undefined) {
|
|
112
|
-
throw new Error(
|
|
118
|
+
throw new Error(
|
|
119
|
+
`imported zip has no session log artifact (expected ${SESSION_LOG_ARTIFACT_FILENAME} ` +
|
|
120
|
+
"or a canonical session.vN.jsonl)",
|
|
121
|
+
);
|
|
113
122
|
}
|
|
114
|
-
return parseJsonlArtifact(new TextDecoder().decode(artifact));
|
|
123
|
+
return parseJsonlArtifact(new TextDecoder().decode(artifact[1]));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 上游 Agent 的取消面(duck-type):停止运行中的 loop。
|
|
127
|
+
interface ImportAgentLike {
|
|
128
|
+
cancel?(cause: { kind: "user" }, options?: { keepInbox?: boolean }): void;
|
|
129
|
+
whenIdle(): Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// persistImport 会先 rewind(-1) 截断 live 会话的内存 log,不能与 agent 写日志
|
|
133
|
+
// 并发;keepInbox 保留排队输入(截断后由 rewind 的 live 钩子 durable 取消)。
|
|
134
|
+
async function stopAgentLoop(ctx: Context, sessionId: SessionId): Promise<void> {
|
|
135
|
+
const agents = ctx.get("agents") as
|
|
136
|
+
| { get(id: SessionId): ImportAgentLike | undefined }
|
|
137
|
+
| undefined;
|
|
138
|
+
const agent = agents?.get(sessionId);
|
|
139
|
+
if (agent === undefined) return;
|
|
140
|
+
agent.cancel?.({ kind: "user" }, { keepInbox: true });
|
|
141
|
+
await agent.whenIdle();
|
|
115
142
|
}
|
|
116
143
|
|
|
117
144
|
export async function persistImport(
|
|
@@ -120,12 +147,15 @@ export async function persistImport(
|
|
|
120
147
|
imported: SessionStorageMetadata & { events: SessionEvent[] },
|
|
121
148
|
targetId?: SessionId,
|
|
122
149
|
sessions?: { get(id: SessionId): Session | undefined },
|
|
150
|
+
stopLoop?: (id: SessionId) => Promise<void>,
|
|
123
151
|
): Promise<SessionId> {
|
|
124
152
|
const id = targetId ?? (`session-${randomUUID()}` as SessionId);
|
|
125
153
|
if (targetId !== undefined) {
|
|
126
154
|
if (branch === undefined) {
|
|
127
155
|
throw new Error("sessionBranch service is unavailable");
|
|
128
156
|
}
|
|
157
|
+
// 覆盖语义先 rewind(-1) 截断:停止运行中的 loop(未注入端口时空操作)。
|
|
158
|
+
if (stopLoop !== undefined) await stopLoop(targetId);
|
|
129
159
|
await branch.rewind(targetId, -1);
|
|
130
160
|
// rewind 截断后追加导入事件(覆盖语义)。live 会话的 write handle 由
|
|
131
161
|
// live 路由持有——复用而非 open(open 会撞 SessionAlreadyOwnedError)。
|
|
@@ -252,7 +282,14 @@ export function registerSessionImport(ctx: Context, persistence: SessionPersiste
|
|
|
252
282
|
const sessions = webCtx.get("sessions") as
|
|
253
283
|
| { get(id: SessionId): Session | undefined }
|
|
254
284
|
| undefined;
|
|
255
|
-
const id = await persistImport(
|
|
285
|
+
const id = await persistImport(
|
|
286
|
+
persistence,
|
|
287
|
+
branch,
|
|
288
|
+
imported,
|
|
289
|
+
targetId,
|
|
290
|
+
sessions,
|
|
291
|
+
(sessionId) => stopAgentLoop(webCtx, sessionId),
|
|
292
|
+
);
|
|
256
293
|
res.writeHead(200, { "content-type": "application/json" });
|
|
257
294
|
res.end(JSON.stringify({ sessionId: id }));
|
|
258
295
|
} catch (error: unknown) {
|