| ... | ... | @@ -733,6 +733,9 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 733 | 733 | const projectionPipeline = yield* OrchestrationProjectionPipeline; |
| 734 | 734 | const eventStore = yield* OrchestrationEventStore; |
| 735 | 735 | const now = new Date().toISOString(); |
| 736 | const threadId = ThreadId.makeUnsafe("thread revert.files"); |
| 737 | const keepAttachmentId = "thread-revert-files-keep"; |
| 738 | const removeAttachmentId = "thread-revert-files-remove"; |
| 736 | 739 | |
| 737 | 740 | const appendAndProject = (event: Parameters<typeof eventStore.append>[0]) => |
| 738 | 741 | eventStore |
| ... | ... | @@ -764,14 +767,14 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 764 | 767 | type: "thread.created", |
| 765 | 768 | eventId: EventId.makeUnsafe("evt-revert-files-2"), |
| 766 | 769 | aggregateKind: "thread", |
| 767 | | aggregateId: ThreadId.makeUnsafe("thread-revert-files"), |
| 770 | aggregateId: threadId, |
| 768 | 771 | occurredAt: now, |
| 769 | 772 | commandId: CommandId.makeUnsafe("cmd-revert-files-2"), |
| 770 | 773 | causationEventId: null, |
| 771 | 774 | correlationId: CorrelationId.makeUnsafe("cmd-revert-files-2"), |
| 772 | 775 | metadata: {}, |
| 773 | 776 | payload: { |
| 774 | | threadId: ThreadId.makeUnsafe("thread-revert-files"), |
| 777 | threadId, |
| 775 | 778 | projectId: ProjectId.makeUnsafe("project-revert-files"), |
| 776 | 779 | title: "Thread Revert Files", |
| 777 | 780 | model: "gpt-5-codex", |
| ... | ... | @@ -786,14 +789,14 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 786 | 789 | type: "thread.turn-diff-completed", |
| 787 | 790 | eventId: EventId.makeUnsafe("evt-revert-files-3"), |
| 788 | 791 | aggregateKind: "thread", |
| 789 | | aggregateId: ThreadId.makeUnsafe("thread-revert-files"), |
| 792 | aggregateId: threadId, |
| 790 | 793 | occurredAt: now, |
| 791 | 794 | commandId: CommandId.makeUnsafe("cmd-revert-files-3"), |
| 792 | 795 | causationEventId: null, |
| 793 | 796 | correlationId: CorrelationId.makeUnsafe("cmd-revert-files-3"), |
| 794 | 797 | metadata: {}, |
| 795 | 798 | payload: { |
| 796 | | threadId: ThreadId.makeUnsafe("thread-revert-files"), |
| 799 | threadId, |
| 797 | 800 | turnId: TurnId.makeUnsafe("turn-keep"), |
| 798 | 801 | checkpointTurnCount: 1, |
| 799 | 802 | checkpointRef: CheckpointRef.makeUnsafe("refs/t3/checkpoints/thread-revert-files/turn/1"), |
| ... | ... | @@ -808,21 +811,21 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 808 | 811 | type: "thread.message-sent", |
| 809 | 812 | eventId: EventId.makeUnsafe("evt-revert-files-4"), |
| 810 | 813 | aggregateKind: "thread", |
| 811 | | aggregateId: ThreadId.makeUnsafe("thread-revert-files"), |
| 814 | aggregateId: threadId, |
| 812 | 815 | occurredAt: now, |
| 813 | 816 | commandId: CommandId.makeUnsafe("cmd-revert-files-4"), |
| 814 | 817 | causationEventId: null, |
| 815 | 818 | correlationId: CorrelationId.makeUnsafe("cmd-revert-files-4"), |
| 816 | 819 | metadata: {}, |
| 817 | 820 | payload: { |
| 818 | | threadId: ThreadId.makeUnsafe("thread-revert-files"), |
| 821 | threadId, |
| 819 | 822 | messageId: MessageId.makeUnsafe("message-keep"), |
| 820 | 823 | role: "assistant", |
| 821 | 824 | text: "Keep", |
| 822 | 825 | attachments: [ |
| 823 | 826 | { |
| 824 | 827 | type: "image", |
| 825 | | id: "thread-revert-files-keep", |
| 828 | id: keepAttachmentId, |
| 826 | 829 | name: "keep.png", |
| 827 | 830 | mimeType: "image/png", |
| 828 | 831 | sizeBytes: 5, |
| ... | ... | @@ -839,14 +842,14 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 839 | 842 | type: "thread.turn-diff-completed", |
| 840 | 843 | eventId: EventId.makeUnsafe("evt-revert-files-5"), |
| 841 | 844 | aggregateKind: "thread", |
| 842 | | aggregateId: ThreadId.makeUnsafe("thread-revert-files"), |
| 845 | aggregateId: threadId, |
| 843 | 846 | occurredAt: now, |
| 844 | 847 | commandId: CommandId.makeUnsafe("cmd-revert-files-5"), |
| 845 | 848 | causationEventId: null, |
| 846 | 849 | correlationId: CorrelationId.makeUnsafe("cmd-revert-files-5"), |
| 847 | 850 | metadata: {}, |
| 848 | 851 | payload: { |
| 849 | | threadId: ThreadId.makeUnsafe("thread-revert-files"), |
| 852 | threadId, |
| 850 | 853 | turnId: TurnId.makeUnsafe("turn-remove"), |
| 851 | 854 | checkpointTurnCount: 2, |
| 852 | 855 | checkpointRef: CheckpointRef.makeUnsafe("refs/t3/checkpoints/thread-revert-files/turn/2"), |
| ... | ... | @@ -861,21 +864,21 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 861 | 864 | type: "thread.message-sent", |
| 862 | 865 | eventId: EventId.makeUnsafe("evt-revert-files-6"), |
| 863 | 866 | aggregateKind: "thread", |
| 864 | | aggregateId: ThreadId.makeUnsafe("thread-revert-files"), |
| 867 | aggregateId: threadId, |
| 865 | 868 | occurredAt: now, |
| 866 | 869 | commandId: CommandId.makeUnsafe("cmd-revert-files-6"), |
| 867 | 870 | causationEventId: null, |
| 868 | 871 | correlationId: CorrelationId.makeUnsafe("cmd-revert-files-6"), |
| 869 | 872 | metadata: {}, |
| 870 | 873 | payload: { |
| 871 | | threadId: ThreadId.makeUnsafe("thread-revert-files"), |
| 874 | threadId, |
| 872 | 875 | messageId: MessageId.makeUnsafe("message-remove"), |
| 873 | 876 | role: "assistant", |
| 874 | 877 | text: "Remove", |
| 875 | 878 | attachments: [ |
| 876 | 879 | { |
| 877 | 880 | type: "image", |
| 878 | | id: "thread-revert-files-remove", |
| 881 | id: removeAttachmentId, |
| 879 | 882 | name: "remove.png", |
| 880 | 883 | mimeType: "image/png", |
| 881 | 884 | sizeBytes: 5, |
| ... | ... | @@ -891,12 +894,12 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 891 | 894 | const keepPath = path.join( |
| 892 | 895 | stateDir, |
| 893 | 896 | "attachments", |
| 894 | | "thread-revert-files-keep.png", |
| 897 | `${keepAttachmentId}.png`, |
| 895 | 898 | ); |
| 896 | 899 | const removePath = path.join( |
| 897 | 900 | stateDir, |
| 898 | 901 | "attachments", |
| 899 | | "thread-revert-files-remove.png", |
| 902 | `${removeAttachmentId}.png`, |
| 900 | 903 | ); |
| 901 | 904 | fs.mkdirSync(path.join(stateDir, "attachments"), { recursive: true }); |
| 902 | 905 | fs.writeFileSync(keepPath, Buffer.from("keep")); |
| ... | ... | @@ -908,14 +911,14 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 908 | 911 | type: "thread.reverted", |
| 909 | 912 | eventId: EventId.makeUnsafe("evt-revert-files-7"), |
| 910 | 913 | aggregateKind: "thread", |
| 911 | | aggregateId: ThreadId.makeUnsafe("thread-revert-files"), |
| 914 | aggregateId: threadId, |
| 912 | 915 | occurredAt: now, |
| 913 | 916 | commandId: CommandId.makeUnsafe("cmd-revert-files-7"), |
| 914 | 917 | causationEventId: null, |
| 915 | 918 | correlationId: CorrelationId.makeUnsafe("cmd-revert-files-7"), |
| 916 | 919 | metadata: {}, |
| 917 | 920 | payload: { |
| 918 | | threadId: ThreadId.makeUnsafe("thread-revert-files"), |
| 921 | threadId, |
| 919 | 922 | turnCount: 1, |
| 920 | 923 | }, |
| 921 | 924 | }); |
| ... | ... | @@ -939,6 +942,8 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 939 | 942 | const projectionPipeline = yield* OrchestrationProjectionPipeline; |
| 940 | 943 | const eventStore = yield* OrchestrationEventStore; |
| 941 | 944 | const now = new Date().toISOString(); |
| 945 | const threadId = ThreadId.makeUnsafe("thread delete.files"); |
| 946 | const attachmentId = "thread-delete-files-att-1"; |
| 942 | 947 | |
| 943 | 948 | const appendAndProject = (event: Parameters<typeof eventStore.append>[0]) => |
| 944 | 949 | eventStore |
| ... | ... | @@ -970,14 +975,14 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 970 | 975 | type: "thread.created", |
| 971 | 976 | eventId: EventId.makeUnsafe("evt-delete-files-2"), |
| 972 | 977 | aggregateKind: "thread", |
| 973 | | aggregateId: ThreadId.makeUnsafe("thread-delete-files"), |
| 978 | aggregateId: threadId, |
| 974 | 979 | occurredAt: now, |
| 975 | 980 | commandId: CommandId.makeUnsafe("cmd-delete-files-2"), |
| 976 | 981 | causationEventId: null, |
| 977 | 982 | correlationId: CorrelationId.makeUnsafe("cmd-delete-files-2"), |
| 978 | 983 | metadata: {}, |
| 979 | 984 | payload: { |
| 980 | | threadId: ThreadId.makeUnsafe("thread-delete-files"), |
| 985 | threadId, |
| 981 | 986 | projectId: ProjectId.makeUnsafe("project-delete-files"), |
| 982 | 987 | title: "Thread Delete Files", |
| 983 | 988 | model: "gpt-5-codex", |
| ... | ... | @@ -992,21 +997,21 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 992 | 997 | type: "thread.message-sent", |
| 993 | 998 | eventId: EventId.makeUnsafe("evt-delete-files-3"), |
| 994 | 999 | aggregateKind: "thread", |
| 995 | | aggregateId: ThreadId.makeUnsafe("thread-delete-files"), |
| 1000 | aggregateId: threadId, |
| 996 | 1001 | occurredAt: now, |
| 997 | 1002 | commandId: CommandId.makeUnsafe("cmd-delete-files-3"), |
| 998 | 1003 | causationEventId: null, |
| 999 | 1004 | correlationId: CorrelationId.makeUnsafe("cmd-delete-files-3"), |
| 1000 | 1005 | metadata: {}, |
| 1001 | 1006 | payload: { |
| 1002 | | threadId: ThreadId.makeUnsafe("thread-delete-files"), |
| 1007 | threadId, |
| 1003 | 1008 | messageId: MessageId.makeUnsafe("message-delete-files"), |
| 1004 | 1009 | role: "user", |
| 1005 | 1010 | text: "Delete", |
| 1006 | 1011 | attachments: [ |
| 1007 | 1012 | { |
| 1008 | 1013 | type: "image", |
| 1009 | | id: "thread-delete-files-att-1", |
| 1014 | id: attachmentId, |
| 1010 | 1015 | name: "delete.png", |
| 1011 | 1016 | mimeType: "image/png", |
| 1012 | 1017 | sizeBytes: 5, |
| ... | ... | @@ -1019,7 +1024,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 1019 | 1024 | }, |
| 1020 | 1025 | }); |
| 1021 | 1026 | |
| 1022 | | const threadAttachmentPath = path.join(stateDir, "attachments", "thread-delete-files-att-1.png"); |
| 1027 | const threadAttachmentPath = path.join(stateDir, "attachments", `${attachmentId}.png`); |
| 1023 | 1028 | fs.mkdirSync(path.join(stateDir, "attachments"), { recursive: true }); |
| 1024 | 1029 | fs.writeFileSync(threadAttachmentPath, Buffer.from("delete")); |
| 1025 | 1030 | assert.equal(fs.existsSync(threadAttachmentPath), true); |
| ... | ... | @@ -1028,14 +1033,14 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => { |
| 1028 | 1033 | type: "thread.deleted", |
| 1029 | 1034 | eventId: EventId.makeUnsafe("evt-delete-files-4"), |
| 1030 | 1035 | aggregateKind: "thread", |
| 1031 | | aggregateId: ThreadId.makeUnsafe("thread-delete-files"), |
| 1036 | aggregateId: threadId, |
| 1032 | 1037 | occurredAt: now, |
| 1033 | 1038 | commandId: CommandId.makeUnsafe("cmd-delete-files-4"), |
| 1034 | 1039 | causationEventId: null, |
| 1035 | 1040 | correlationId: CorrelationId.makeUnsafe("cmd-delete-files-4"), |
| 1036 | 1041 | metadata: {}, |
| 1037 | 1042 | payload: { |
| 1038 | | threadId: ThreadId.makeUnsafe("thread-delete-files"), |
| 1043 | threadId, |
| 1039 | 1044 | deletedAt: now, |
| 1040 | 1045 | }, |
| 1041 | 1046 | }); |