@sentry/junior 0.107.0 → 0.108.0
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/{agent-hooks-ICPIJAFY.js → agent-hooks-NU5HK3PS.js} +4 -4
- package/dist/api/conversations/list.d.ts +1 -0
- package/dist/api.js +11 -8
- package/dist/app.js +270 -48
- package/dist/chat/conversations/history.d.ts +16 -5
- package/dist/chat/conversations/message-projection.d.ts +3 -5
- package/dist/chat/resource-events/store.d.ts +6 -0
- package/dist/chat/runtime/slack-runtime.d.ts +3 -0
- package/dist/chat/task-execution/slack-work.d.ts +237 -10
- package/dist/chat/tool-support/turn-deadline-result.d.ts +3 -0
- package/dist/{chunk-YFQ7CQDE.js → chunk-3RGQLX2F.js} +10 -16
- package/dist/{chunk-CQ7KSO2B.js → chunk-A5CO2EHL.js} +6 -6
- package/dist/{chunk-AUUOHQAT.js → chunk-AHJR2IFF.js} +1 -1
- package/dist/{chunk-SPUAJVVH.js → chunk-B5I5LMSP.js} +1 -1
- package/dist/{chunk-B2Z2H66D.js → chunk-H3QYZL7K.js} +32 -2
- package/dist/{chunk-4YF7Z6IA.js → chunk-J3B3FPP2.js} +2 -2
- package/dist/{chunk-EDLNHZH3.js → chunk-KPMPQ6AA.js} +143 -98
- package/dist/{chunk-NVOTGWYX.js → chunk-TE4QHJH4.js} +25 -10
- package/dist/{chunk-YNP2ATQX.js → chunk-TWINAEZQ.js} +6 -5
- package/dist/{chunk-RMVOAJRL.js → chunk-UD6THJ2I.js} +2 -2
- package/dist/{chunk-IGHMVDWI.js → chunk-XKB7LGIW.js} +1 -1
- package/dist/cli/chat.js +11 -11
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-warmup.js +2 -2
- package/dist/cli/upgrade.js +6 -11
- package/dist/{db-DIGO4TGW.js → db-AMRBAT5D.js} +1 -1
- package/dist/{runner-ACR2HAIC.js → runner-TQH5GAJ4.js} +7 -7
- package/package.json +7 -7
|
@@ -43,6 +43,9 @@ export interface SlackTurnOptions extends ReplyHooks {
|
|
|
43
43
|
}
|
|
44
44
|
export interface SlackTurnRuntimeDependencies<TPreparedState> {
|
|
45
45
|
assistantUserName: string;
|
|
46
|
+
cancelEventSubscriptions: (input: {
|
|
47
|
+
conversationId: string;
|
|
48
|
+
}) => Promise<void>;
|
|
46
49
|
getChannelId: (thread: Thread, message: Message) => string | undefined;
|
|
47
50
|
getPreparedConversationContext: (preparedState: TPreparedState) => string | undefined;
|
|
48
51
|
getThreadId: (thread: Thread, message: Message) => string | undefined;
|
|
@@ -1,20 +1,247 @@
|
|
|
1
1
|
import type { SlackAdapter } from "@chat-adapter/slack";
|
|
2
|
-
import { Message, ThreadImpl, type
|
|
2
|
+
import { Message, ThreadImpl, type StateAdapter } from "chat";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import type { SlackTurnOptions } from "@/chat/runtime/slack-runtime";
|
|
4
5
|
import type { ConversationStore } from "@/chat/conversations/store";
|
|
5
6
|
import type { InboundMessage } from "@/chat/task-execution/store";
|
|
6
7
|
import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
|
|
7
8
|
import { type SlackInstallationContext } from "@/chat/slack/adapter-context";
|
|
8
9
|
import { type SlackActorProfile } from "@/chat/actor";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
declare const slackConversationRouteSchema: z.ZodEnum<{
|
|
11
|
+
mention: "mention";
|
|
12
|
+
subscribed: "subscribed";
|
|
13
|
+
}>;
|
|
14
|
+
export type SlackConversationRoute = z.output<typeof slackConversationRouteSchema>;
|
|
15
|
+
declare const slackConversationMessageMetadataSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
16
|
+
installation: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
enterpriseId: z.ZodOptional<z.ZodString>;
|
|
18
|
+
isEnterpriseInstall: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strict>>;
|
|
21
|
+
message: z.ZodObject<{
|
|
22
|
+
_type: z.ZodLiteral<"chat:Message">;
|
|
23
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
24
|
+
type: z.ZodEnum<{
|
|
25
|
+
image: "image";
|
|
26
|
+
file: "file";
|
|
27
|
+
audio: "audio";
|
|
28
|
+
video: "video";
|
|
29
|
+
}>;
|
|
30
|
+
url: z.ZodOptional<z.ZodString>;
|
|
31
|
+
name: z.ZodOptional<z.ZodString>;
|
|
32
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
33
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
fetchMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
author: z.ZodObject<{
|
|
39
|
+
userId: z.ZodString;
|
|
40
|
+
userName: z.ZodString;
|
|
41
|
+
fullName: z.ZodString;
|
|
42
|
+
isBot: z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"unknown">]>;
|
|
43
|
+
isMe: z.ZodBoolean;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
formatted: z.ZodCustom<import("chat").Root, import("chat").Root>;
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
isMention: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
49
|
+
url: z.ZodString;
|
|
50
|
+
title: z.ZodOptional<z.ZodString>;
|
|
51
|
+
description: z.ZodOptional<z.ZodString>;
|
|
52
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
53
|
+
siteName: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strict>>>;
|
|
55
|
+
metadata: z.ZodObject<{
|
|
56
|
+
dateSent: z.ZodISODateTime;
|
|
57
|
+
edited: z.ZodBoolean;
|
|
58
|
+
editedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
raw: z.ZodUnknown;
|
|
61
|
+
text: z.ZodString;
|
|
62
|
+
threadId: z.ZodString;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
platform: z.ZodLiteral<"slack">;
|
|
65
|
+
route: z.ZodEnum<{
|
|
66
|
+
mention: "mention";
|
|
67
|
+
subscribed: "subscribed";
|
|
68
|
+
}>;
|
|
69
|
+
thread: z.ZodObject<{
|
|
70
|
+
_type: z.ZodLiteral<"chat:Thread">;
|
|
71
|
+
adapterName: z.ZodLiteral<"slack">;
|
|
72
|
+
channelId: z.ZodString;
|
|
73
|
+
channelVisibility: z.ZodOptional<z.ZodEnum<{
|
|
74
|
+
private: "private";
|
|
75
|
+
unknown: "unknown";
|
|
76
|
+
external: "external";
|
|
77
|
+
workspace: "workspace";
|
|
78
|
+
}>>;
|
|
79
|
+
currentMessage: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
_type: z.ZodLiteral<"chat:Message">;
|
|
81
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
82
|
+
type: z.ZodEnum<{
|
|
83
|
+
image: "image";
|
|
84
|
+
file: "file";
|
|
85
|
+
audio: "audio";
|
|
86
|
+
video: "video";
|
|
87
|
+
}>;
|
|
88
|
+
url: z.ZodOptional<z.ZodString>;
|
|
89
|
+
name: z.ZodOptional<z.ZodString>;
|
|
90
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
91
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
fetchMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
95
|
+
}, z.core.$strict>>;
|
|
96
|
+
author: z.ZodObject<{
|
|
97
|
+
userId: z.ZodString;
|
|
98
|
+
userName: z.ZodString;
|
|
99
|
+
fullName: z.ZodString;
|
|
100
|
+
isBot: z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"unknown">]>;
|
|
101
|
+
isMe: z.ZodBoolean;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
formatted: z.ZodCustom<import("chat").Root, import("chat").Root>;
|
|
104
|
+
id: z.ZodString;
|
|
105
|
+
isMention: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
107
|
+
url: z.ZodString;
|
|
108
|
+
title: z.ZodOptional<z.ZodString>;
|
|
109
|
+
description: z.ZodOptional<z.ZodString>;
|
|
110
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
111
|
+
siteName: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strict>>>;
|
|
113
|
+
metadata: z.ZodObject<{
|
|
114
|
+
dateSent: z.ZodISODateTime;
|
|
115
|
+
edited: z.ZodBoolean;
|
|
116
|
+
editedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
117
|
+
}, z.core.$strict>;
|
|
118
|
+
raw: z.ZodUnknown;
|
|
119
|
+
text: z.ZodString;
|
|
120
|
+
threadId: z.ZodString;
|
|
121
|
+
}, z.core.$strict>>;
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
isDM: z.ZodBoolean;
|
|
124
|
+
}, z.core.$strict>;
|
|
125
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
126
|
+
installation: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
enterpriseId: z.ZodOptional<z.ZodString>;
|
|
128
|
+
isEnterpriseInstall: z.ZodOptional<z.ZodBoolean>;
|
|
129
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
message: z.ZodObject<{
|
|
132
|
+
_type: z.ZodLiteral<"chat:Message">;
|
|
133
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
134
|
+
type: z.ZodEnum<{
|
|
135
|
+
image: "image";
|
|
136
|
+
file: "file";
|
|
137
|
+
audio: "audio";
|
|
138
|
+
video: "video";
|
|
139
|
+
}>;
|
|
140
|
+
url: z.ZodOptional<z.ZodString>;
|
|
141
|
+
name: z.ZodOptional<z.ZodString>;
|
|
142
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
143
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
146
|
+
fetchMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
147
|
+
}, z.core.$strict>>;
|
|
148
|
+
author: z.ZodObject<{
|
|
149
|
+
userId: z.ZodString;
|
|
150
|
+
userName: z.ZodString;
|
|
151
|
+
fullName: z.ZodString;
|
|
152
|
+
isBot: z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"unknown">]>;
|
|
153
|
+
isMe: z.ZodBoolean;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
formatted: z.ZodCustom<import("chat").Root, import("chat").Root>;
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
isMention: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
159
|
+
url: z.ZodString;
|
|
160
|
+
title: z.ZodOptional<z.ZodString>;
|
|
161
|
+
description: z.ZodOptional<z.ZodString>;
|
|
162
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
163
|
+
siteName: z.ZodOptional<z.ZodString>;
|
|
164
|
+
}, z.core.$strict>>>;
|
|
165
|
+
metadata: z.ZodObject<{
|
|
166
|
+
dateSent: z.ZodISODateTime;
|
|
167
|
+
edited: z.ZodBoolean;
|
|
168
|
+
editedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
169
|
+
}, z.core.$strict>;
|
|
170
|
+
raw: z.ZodUnknown;
|
|
171
|
+
text: z.ZodString;
|
|
172
|
+
threadId: z.ZodString;
|
|
173
|
+
}, z.core.$strict>;
|
|
174
|
+
platform: z.ZodLiteral<"slack">;
|
|
175
|
+
route: z.ZodEnum<{
|
|
176
|
+
mention: "mention";
|
|
177
|
+
subscribed: "subscribed";
|
|
178
|
+
}>;
|
|
179
|
+
thread: z.ZodObject<{
|
|
180
|
+
_type: z.ZodLiteral<"chat:Thread">;
|
|
181
|
+
adapterName: z.ZodLiteral<"slack">;
|
|
182
|
+
channelId: z.ZodString;
|
|
183
|
+
channelVisibility: z.ZodOptional<z.ZodEnum<{
|
|
184
|
+
private: "private";
|
|
185
|
+
unknown: "unknown";
|
|
186
|
+
external: "external";
|
|
187
|
+
workspace: "workspace";
|
|
188
|
+
}>>;
|
|
189
|
+
currentMessage: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
_type: z.ZodLiteral<"chat:Message">;
|
|
191
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
192
|
+
type: z.ZodEnum<{
|
|
193
|
+
image: "image";
|
|
194
|
+
file: "file";
|
|
195
|
+
audio: "audio";
|
|
196
|
+
video: "video";
|
|
197
|
+
}>;
|
|
198
|
+
url: z.ZodOptional<z.ZodString>;
|
|
199
|
+
name: z.ZodOptional<z.ZodString>;
|
|
200
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
201
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
fetchMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
205
|
+
}, z.core.$strict>>;
|
|
206
|
+
author: z.ZodObject<{
|
|
207
|
+
userId: z.ZodString;
|
|
208
|
+
userName: z.ZodString;
|
|
209
|
+
fullName: z.ZodString;
|
|
210
|
+
isBot: z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"unknown">]>;
|
|
211
|
+
isMe: z.ZodBoolean;
|
|
212
|
+
}, z.core.$strict>;
|
|
213
|
+
formatted: z.ZodCustom<import("chat").Root, import("chat").Root>;
|
|
214
|
+
id: z.ZodString;
|
|
215
|
+
isMention: z.ZodOptional<z.ZodBoolean>;
|
|
216
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
217
|
+
url: z.ZodString;
|
|
218
|
+
title: z.ZodOptional<z.ZodString>;
|
|
219
|
+
description: z.ZodOptional<z.ZodString>;
|
|
220
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
221
|
+
siteName: z.ZodOptional<z.ZodString>;
|
|
222
|
+
}, z.core.$strict>>>;
|
|
223
|
+
metadata: z.ZodObject<{
|
|
224
|
+
dateSent: z.ZodISODateTime;
|
|
225
|
+
edited: z.ZodBoolean;
|
|
226
|
+
editedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
227
|
+
}, z.core.$strict>;
|
|
228
|
+
raw: z.ZodUnknown;
|
|
229
|
+
text: z.ZodString;
|
|
230
|
+
threadId: z.ZodString;
|
|
231
|
+
}, z.core.$strict>>;
|
|
232
|
+
id: z.ZodString;
|
|
233
|
+
isDM: z.ZodBoolean;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
kind: z.ZodLiteral<"resource_event">;
|
|
236
|
+
resourceEvent: z.ZodObject<{
|
|
237
|
+
eventKey: z.ZodString;
|
|
238
|
+
eventType: z.ZodString;
|
|
239
|
+
provider: z.ZodString;
|
|
240
|
+
resourceRef: z.ZodString;
|
|
241
|
+
subscriptionId: z.ZodString;
|
|
242
|
+
}, z.core.$strict>;
|
|
243
|
+
}, z.core.$strict>]>;
|
|
244
|
+
export type SlackConversationMessageMetadata = z.output<typeof slackConversationMessageMetadataSchema>;
|
|
18
245
|
type SlackInboxTurnOptions = SlackTurnOptions & {
|
|
19
246
|
ack: () => Promise<void>;
|
|
20
247
|
isFinalAttempt: boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AfterToolCallResult, AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
+
/** Mark an unknown tool outcome as caused by an internal execution-slice deadline. */
|
|
3
|
+
export declare function annotateTurnDeadlineToolResult(result: AgentToolResult<unknown>): AfterToolCallResult | undefined;
|
|
@@ -5,16 +5,16 @@ import {
|
|
|
5
5
|
getAgentTurnSessionRecord,
|
|
6
6
|
getAgentTurnSessionRecordForResume,
|
|
7
7
|
upsertAgentTurnSessionRecord
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-J3B3FPP2.js";
|
|
9
9
|
import {
|
|
10
10
|
addAgentTurnUsage
|
|
11
11
|
} from "./chunk-MU6HHZEN.js";
|
|
12
12
|
import {
|
|
13
13
|
getStateAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-H3QYZL7K.js";
|
|
15
15
|
import {
|
|
16
16
|
getConversationEventStore
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TE4QHJH4.js";
|
|
18
18
|
import {
|
|
19
19
|
sleep
|
|
20
20
|
} from "./chunk-4ZNGQH7C.js";
|
|
@@ -949,10 +949,7 @@ async function persistConversationMessageSummaries(args) {
|
|
|
949
949
|
const historyFromSeq = history.events.find(
|
|
950
950
|
(event) => event.data.type === "message" && liveMessageIds.has(event.data.messageId)
|
|
951
951
|
)?.seq;
|
|
952
|
-
const nextHistoryFromSeq = historyFromSeq ?? Math.max(
|
|
953
|
-
history.compaction?.data.type === "messages_summarized" ? history.compaction.data.historyFromSeq : 0,
|
|
954
|
-
(history.events.at(-1)?.seq ?? -1) + 1
|
|
955
|
-
);
|
|
952
|
+
const nextHistoryFromSeq = historyFromSeq ?? Math.max(history.historyFromSeq, (history.events.at(-1)?.seq ?? -1) + 1);
|
|
956
953
|
await eventStore.append(args.conversationId, [
|
|
957
954
|
{
|
|
958
955
|
data: {
|
|
@@ -983,9 +980,9 @@ function missingBaselineError(event) {
|
|
|
983
980
|
`Message event ${event.data.type} at seq ${event.seq} references ${event.data.messageId} before message`
|
|
984
981
|
);
|
|
985
982
|
}
|
|
986
|
-
function projectConversationMessages(
|
|
983
|
+
function projectConversationMessages(history) {
|
|
987
984
|
const byId = /* @__PURE__ */ new Map();
|
|
988
|
-
for (const event of events) {
|
|
985
|
+
for (const event of history.events) {
|
|
989
986
|
if (!isMessageEvent(event)) continue;
|
|
990
987
|
const data = event.data;
|
|
991
988
|
const current = byId.get(data.messageId);
|
|
@@ -1002,7 +999,7 @@ function projectConversationMessages(events, options = {}) {
|
|
|
1002
999
|
`Duplicate message event for ${data.messageId} at seq ${event.seq}`
|
|
1003
1000
|
);
|
|
1004
1001
|
if (data.type === "message_updated" && !current) {
|
|
1005
|
-
if (
|
|
1002
|
+
if (history.historyFromSeq > 0) continue;
|
|
1006
1003
|
throw missingBaselineError(event);
|
|
1007
1004
|
}
|
|
1008
1005
|
byId.set(data.messageId, {
|
|
@@ -1015,7 +1012,7 @@ function projectConversationMessages(events, options = {}) {
|
|
|
1015
1012
|
continue;
|
|
1016
1013
|
}
|
|
1017
1014
|
if (!current) {
|
|
1018
|
-
if (
|
|
1015
|
+
if (history.historyFromSeq > 0) continue;
|
|
1019
1016
|
throw missingBaselineError(event);
|
|
1020
1017
|
}
|
|
1021
1018
|
current.repliedAtMs ??= event.createdAtMs;
|
|
@@ -1063,10 +1060,7 @@ async function hydrateConversationMessages(args) {
|
|
|
1063
1060
|
args.conversationId
|
|
1064
1061
|
);
|
|
1065
1062
|
args.conversation.compactions = history.compaction ? projectConversationMessageSummaries([history.compaction]) : [];
|
|
1066
|
-
|
|
1067
|
-
args.conversation.messages = projectConversationMessages(history.events, {
|
|
1068
|
-
historyFromSeq
|
|
1069
|
-
});
|
|
1063
|
+
args.conversation.messages = projectConversationMessages(history);
|
|
1070
1064
|
updateConversationStats(args.conversation);
|
|
1071
1065
|
}
|
|
1072
1066
|
async function persistConversationMessages(args) {
|
|
@@ -1075,7 +1069,7 @@ async function persistConversationMessages(args) {
|
|
|
1075
1069
|
args.conversationId
|
|
1076
1070
|
);
|
|
1077
1071
|
const existingMessages = new Map(
|
|
1078
|
-
projectConversationMessages(history
|
|
1072
|
+
projectConversationMessages(history).map((message) => [
|
|
1079
1073
|
message.id,
|
|
1080
1074
|
message
|
|
1081
1075
|
])
|
|
@@ -12,26 +12,26 @@ import {
|
|
|
12
12
|
markTurnCompleted,
|
|
13
13
|
mergeArtifactsState,
|
|
14
14
|
updateConversationStats
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3RGQLX2F.js";
|
|
16
16
|
import {
|
|
17
17
|
coerceThreadConversationState,
|
|
18
18
|
getAgentTurnSessionRecord
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-J3B3FPP2.js";
|
|
20
20
|
import {
|
|
21
21
|
createPluginEmbedder,
|
|
22
22
|
createPluginModel,
|
|
23
23
|
getPlugins
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-UD6THJ2I.js";
|
|
25
25
|
import {
|
|
26
26
|
createPluginLogger,
|
|
27
27
|
createPluginState
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-AHJR2IFF.js";
|
|
29
29
|
import {
|
|
30
30
|
getStateAdapter
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-H3QYZL7K.js";
|
|
32
32
|
import {
|
|
33
33
|
getDb
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-TE4QHJH4.js";
|
|
35
35
|
import {
|
|
36
36
|
getPiMessageRole,
|
|
37
37
|
instructionTextForProjection,
|
|
@@ -16,6 +16,32 @@ async function acquireActiveLock(state, threadId) {
|
|
|
16
16
|
var ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
|
|
17
17
|
var stateAdapter;
|
|
18
18
|
var redisStateAdapter;
|
|
19
|
+
function createConnectingStateAdapter(base) {
|
|
20
|
+
const connected = async (operation) => {
|
|
21
|
+
await base.connect();
|
|
22
|
+
return await operation();
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
appendToList: (key, value, options) => connected(() => base.appendToList(key, value, options)),
|
|
26
|
+
connect: () => base.connect(),
|
|
27
|
+
disconnect: () => base.disconnect(),
|
|
28
|
+
subscribe: (threadId) => connected(() => base.subscribe(threadId)),
|
|
29
|
+
unsubscribe: (threadId) => connected(() => base.unsubscribe(threadId)),
|
|
30
|
+
isSubscribed: (threadId) => connected(() => base.isSubscribed(threadId)),
|
|
31
|
+
acquireLock: (threadId, ttlMs) => connected(() => base.acquireLock(threadId, ttlMs)),
|
|
32
|
+
releaseLock: (lock) => connected(() => base.releaseLock(lock)),
|
|
33
|
+
extendLock: (lock, ttlMs) => connected(() => base.extendLock(lock, ttlMs)),
|
|
34
|
+
forceReleaseLock: (threadId) => connected(() => base.forceReleaseLock(threadId)),
|
|
35
|
+
enqueue: (threadId, entry, maxSize) => connected(() => base.enqueue(threadId, entry, maxSize)),
|
|
36
|
+
dequeue: (threadId) => connected(() => base.dequeue(threadId)),
|
|
37
|
+
queueDepth: (threadId) => connected(() => base.queueDepth(threadId)),
|
|
38
|
+
get: (key) => connected(() => base.get(key)),
|
|
39
|
+
getList: (key) => connected(() => base.getList(key)),
|
|
40
|
+
set: (key, value, ttlMs) => connected(() => base.set(key, value, ttlMs)),
|
|
41
|
+
setIfNotExists: (key, value, ttlMs) => connected(() => base.setIfNotExists(key, value, ttlMs)),
|
|
42
|
+
delete: (key) => connected(() => base.delete(key))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
19
45
|
function createPrefixedStateAdapter(base, prefix) {
|
|
20
46
|
const prefixed = (value) => `${prefix}:${value}`;
|
|
21
47
|
const unprefixed = (value) => value.startsWith(`${prefix}:`) ? value.slice(prefix.length + 1) : value;
|
|
@@ -188,7 +214,9 @@ function createStateAdapter() {
|
|
|
188
214
|
if (config.state.adapter === "memory") {
|
|
189
215
|
redisStateAdapter = void 0;
|
|
190
216
|
return createQueuedStateAdapter(
|
|
191
|
-
|
|
217
|
+
createConnectingStateAdapter(
|
|
218
|
+
withOptionalPrefix(createMemoryState(), config.state.keyPrefix)
|
|
219
|
+
),
|
|
192
220
|
{ activeLockMaxAgeMs }
|
|
193
221
|
);
|
|
194
222
|
}
|
|
@@ -200,7 +228,9 @@ function createStateAdapter() {
|
|
|
200
228
|
});
|
|
201
229
|
redisStateAdapter = redisState;
|
|
202
230
|
return createQueuedStateAdapter(
|
|
203
|
-
|
|
231
|
+
createConnectingStateAdapter(
|
|
232
|
+
withOptionalPrefix(redisState, config.state.keyPrefix)
|
|
233
|
+
),
|
|
204
234
|
{ activeLockMaxAgeMs }
|
|
205
235
|
);
|
|
206
236
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-MU6HHZEN.js";
|
|
4
4
|
import {
|
|
5
5
|
getStateAdapter
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-H3QYZL7K.js";
|
|
7
7
|
import {
|
|
8
8
|
contextProvenance,
|
|
9
9
|
createSqlConversationEventStore,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
instructionProvenanceFor,
|
|
15
15
|
sanitizePostgresJson,
|
|
16
16
|
withConversationEventLock
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TE4QHJH4.js";
|
|
18
18
|
import {
|
|
19
19
|
retainRuntimeTurnContext,
|
|
20
20
|
stripRuntimeTurnContext
|