@sentry/junior 0.143.0 → 0.145.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-2EP3QS47.js → agent-hooks-L7D2BDVV.js} +10 -10
- package/dist/api/conversations/detail.d.ts +9 -0
- package/dist/api/schema/conversation.d.ts +20 -0
- package/dist/api/schema/task.d.ts +40 -1
- package/dist/api/schema.d.ts +3 -3
- package/dist/api/schema.js +5 -1
- package/dist/api.js +2250 -2172
- package/dist/app.js +335 -409
- package/dist/{catalog-runtime-IAVW4W3B.js → catalog-runtime-QLAC4Q3W.js} +5 -5
- package/dist/chat/agent/request.d.ts +1 -1
- package/dist/chat/agent/resume.d.ts +6 -15
- package/dist/chat/agent/tools.d.ts +1 -1
- package/dist/chat/agent-dispatch/types.d.ts +1 -1
- package/dist/chat/app/conversation-work.d.ts +24 -0
- package/dist/chat/conversations/projection.d.ts +11 -3
- package/dist/chat/conversations/store.d.ts +1 -1
- package/dist/chat/runtime/agent-run-outcome.d.ts +1 -1
- package/dist/chat/runtime/reply-executor.d.ts +5 -5
- package/dist/chat/runtime/slack-resume.d.ts +12 -4
- package/dist/chat/scheduled-tasks/store.d.ts +1 -0
- package/dist/chat/scheduled-tasks/tool-support.d.ts +26 -1
- package/dist/chat/scheduled-tasks/tools/create.d.ts +10 -0
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +10 -0
- package/dist/chat/scheduled-tasks/tools/list.d.ts +15 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +10 -0
- package/dist/chat/scheduled-tasks/tools/update.d.ts +12 -1
- package/dist/chat/services/guardian-action-policy.d.ts +1 -1
- package/dist/chat/state/locks.d.ts +28 -0
- package/dist/chat/task-execution/checkpoint.d.ts +86 -0
- package/dist/chat/task-execution/paused-turn.d.ts +29 -0
- package/dist/chat/task-execution/queue-signing.d.ts +1 -0
- package/dist/chat/task-execution/queue.d.ts +7 -1
- package/dist/chat/task-execution/slack-work.d.ts +1 -1
- package/dist/chat/task-execution/state.d.ts +4 -4
- package/dist/chat/task-execution/store.d.ts +2 -2
- package/dist/chat/task-execution/turn-cursor-keys.d.ts +6 -0
- package/dist/chat/{state/turn-session.d.ts → task-execution/turn-cursor.d.ts} +52 -42
- package/dist/chat/task-execution/turn-wake.d.ts +29 -0
- package/dist/chat/tasks/execution-stats.d.ts +21 -0
- package/dist/chat/tasks/read.d.ts +9 -1
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/{chunk-2KLMGRRQ.js → chunk-27TEJTZO.js} +1 -1
- package/dist/{chunk-GZRWULXF.js → chunk-2LWPFSB4.js} +1 -1
- package/dist/{chunk-NAINBOZQ.js → chunk-2UH3JI64.js} +10 -9
- package/dist/{chunk-QFWXGUAH.js → chunk-2XET6PKP.js} +93 -89
- package/dist/{chunk-U5ATCOHE.js → chunk-5PNPQYTO.js} +2 -2
- package/dist/{chunk-XYJNNZYR.js → chunk-64SBYW2O.js} +397 -288
- package/dist/{chunk-F6RWNJBK.js → chunk-B46ZMVOV.js} +5 -5
- package/dist/{chunk-BJ6ISBOA.js → chunk-CD2XFGYQ.js} +1 -1
- package/dist/{chunk-WSWVWP2V.js → chunk-DS3J6WGY.js} +1 -1
- package/dist/{chunk-OG5JQHKR.js → chunk-DXEQAIUV.js} +1 -1
- package/dist/{chunk-A3XPSABC.js → chunk-EIX2LQ6L.js} +82 -4
- package/dist/{chunk-ANG7IWAI.js → chunk-FUBRJA5F.js} +6 -6
- package/dist/{chunk-OB7ZJK7Y.js → chunk-GDV5LXRA.js} +1 -1
- package/dist/{chunk-AEFJN7OK.js → chunk-GUWLDMGF.js} +4 -4
- package/dist/{chunk-I4NQNZVW.js → chunk-HISR3DTV.js} +33 -61
- package/dist/{chunk-WM4PRM7W.js → chunk-HLOUZC5C.js} +32 -34
- package/dist/{chunk-RABHACKG.js → chunk-I47UGQPJ.js} +7 -7
- package/dist/{chunk-IUFM5JWV.js → chunk-JAL3CH4G.js} +3 -0
- package/dist/{chunk-OGQGJAD7.js → chunk-JLMVCNXL.js} +26 -1
- package/dist/{chunk-5YJBS4I5.js → chunk-JTGS3ZZE.js} +1 -1
- package/dist/{chunk-LSBQHDI2.js → chunk-LVVSIMBB.js} +1 -1
- package/dist/{chunk-2T5CHXRZ.js → chunk-PJ4NMVQB.js} +2 -2
- package/dist/{chunk-I5PIM72M.js → chunk-QJBDABQA.js} +14 -17
- package/dist/{chunk-M2T7MHQJ.js → chunk-QUG4JSZK.js} +43 -1
- package/dist/{chunk-X5SC2UGE.js → chunk-RUSS62EN.js} +14 -14
- package/dist/{chunk-NVFVM67W.js → chunk-SIN3MXH6.js} +1 -1
- package/dist/{chunk-I25V3XRN.js → chunk-TZRXYWRE.js} +2 -2
- package/dist/{chunk-WJHWOAVZ.js → chunk-VTDMB7XX.js} +1 -1
- package/dist/{chunk-TPJK6AVJ.js → chunk-WF5HVH3M.js} +1 -1
- package/dist/{chunk-KCBZSJRU.js → chunk-WR76IVA5.js} +5 -2
- package/dist/{chunk-7GVX5SOG.js → chunk-XFKIRN3Q.js} +29 -29
- package/dist/{chunk-UFCA4EZB.js → chunk-YD54Q45G.js} +4 -4
- package/dist/{chunk-PBV7VXUA.js → chunk-ZIAMN2UW.js} +407 -523
- package/dist/{chunk-SNBTWIQO.js → chunk-ZIMRGFYL.js} +6 -6
- package/dist/{chunk-STX5WIH6.js → chunk-ZYAJMESY.js} +2 -2
- package/dist/cli/chat.js +32 -32
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +7 -7
- package/dist/{db-RBXBVEVO.js → db-62PW6LM3.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +4 -4
- package/dist/{oauth-callback-server-LRB6BX6C.js → oauth-callback-server-6NZNHJAM.js} +25 -25
- package/dist/{runner-WK5VUOW6.js → runner-GCRPG3GQ.js} +19 -18
- package/dist/{skills-MJWRME3A.js → skills-2S3MDFIQ.js} +6 -6
- package/dist/spawn-7WK37BTD.js +39 -0
- package/dist/{validation-556WSWVU.js → validation-HAOLCJ5A.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-W6IXSPY3.js → work-R4XYKMUW.js} +17 -16
- package/dist/worker-U2UCVR7M.js +24 -0
- package/package.json +5 -5
- package/dist/chat/agent/session.d.ts +0 -19
- package/dist/chat/runtime/agent-continue-runner.d.ts +0 -37
- package/dist/chat/services/agent-continue.d.ts +0 -29
- package/dist/chat/services/turn-session-record.d.ts +0 -164
- package/dist/chat/state/turn-session-keys.d.ts +0 -6
- package/dist/spawn-ZCW6UOAA.js +0 -38
- package/dist/worker-5KM346HH.js +0 -24
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// src/chat/task-execution/queue.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
var CONVERSATION_QUEUE_SCHEMA_VERSION = 2;
|
|
3
4
|
var conversationQueueMessageSchema = z.object({
|
|
5
|
+
schemaVersion: z.literal(CONVERSATION_QUEUE_SCHEMA_VERSION),
|
|
4
6
|
conversationId: z.string().trim().min(1)
|
|
5
7
|
}).strict();
|
|
6
8
|
var ConversationQueueMessageRejectedError = class extends Error {
|
|
@@ -18,6 +20,7 @@ function isConversationQueueMessageRejectedError(error) {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export {
|
|
23
|
+
CONVERSATION_QUEUE_SCHEMA_VERSION,
|
|
21
24
|
conversationQueueMessageSchema,
|
|
22
25
|
ConversationQueueMessageRejectedError,
|
|
23
26
|
isConversationQueueMessageRejectedError
|
|
@@ -85,6 +85,19 @@ var conversationAuxiliaryCostsSchema = z2.object({
|
|
|
85
85
|
}).strict()
|
|
86
86
|
).min(1)
|
|
87
87
|
}).strict();
|
|
88
|
+
var conversationSourceTaskSchema = z2.object({
|
|
89
|
+
id: z2.string().min(1).optional(),
|
|
90
|
+
kind: z2.enum(["scheduled", "event"]),
|
|
91
|
+
label: z2.string().min(1).optional(),
|
|
92
|
+
title: z2.string().min(1).optional()
|
|
93
|
+
}).strict().superRefine((value, context) => {
|
|
94
|
+
if (Boolean(value.id) !== Boolean(value.label)) {
|
|
95
|
+
context.addIssue({
|
|
96
|
+
code: "custom",
|
|
97
|
+
message: "sourceTask id and label must both be set or both omitted"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
88
101
|
var conversationSummaryReportSchema = z2.object({
|
|
89
102
|
displayTitle: z2.string(),
|
|
90
103
|
cumulativeDurationMs: z2.number(),
|
|
@@ -410,7 +423,8 @@ var conversationDetailReportSchema = conversationSummaryReportSchema.extend({
|
|
|
410
423
|
eventHistory: conversationEventHistorySchema,
|
|
411
424
|
previousCursor: z2.string().min(1).optional(),
|
|
412
425
|
generatedAt: z2.string(),
|
|
413
|
-
sentryConversationUrl: z2.string().optional()
|
|
426
|
+
sentryConversationUrl: z2.string().optional(),
|
|
427
|
+
sourceTask: conversationSourceTaskSchema.optional()
|
|
414
428
|
}).strict().superRefine(validateConversationEvents);
|
|
415
429
|
var conversationEventPageSchema = z2.object({
|
|
416
430
|
events: z2.array(conversationReportEventSchema),
|
|
@@ -668,6 +682,15 @@ var taskExecutionListSchema = z7.object({
|
|
|
668
682
|
task: taskSummarySchema,
|
|
669
683
|
truncated: z7.boolean()
|
|
670
684
|
}).strict();
|
|
685
|
+
var taskRunSchema = taskExecutionSchema.extend({
|
|
686
|
+
kind: z7.enum(["scheduled", "event"]),
|
|
687
|
+
taskId: z7.string().min(1),
|
|
688
|
+
taskTitle: z7.string().min(1)
|
|
689
|
+
}).strict();
|
|
690
|
+
var taskRunListSchema = z7.object({
|
|
691
|
+
runs: z7.array(taskRunSchema),
|
|
692
|
+
truncated: z7.boolean()
|
|
693
|
+
}).strict();
|
|
671
694
|
|
|
672
695
|
// src/api/schema/stats.ts
|
|
673
696
|
import { z as z8 } from "zod";
|
|
@@ -727,6 +750,8 @@ export {
|
|
|
727
750
|
taskExecutionSchema,
|
|
728
751
|
taskExecutionStatusDaySchema,
|
|
729
752
|
taskExecutionListSchema,
|
|
753
|
+
taskRunSchema,
|
|
754
|
+
taskRunListSchema,
|
|
730
755
|
statSchema,
|
|
731
756
|
statsReportSchema
|
|
732
757
|
};
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-UTL3MHPC.js";
|
|
4
4
|
import {
|
|
5
5
|
parseSlackThreadId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DXEQAIUV.js";
|
|
7
7
|
import {
|
|
8
8
|
normalizeSlackConversationId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TZRXYWRE.js";
|
|
10
10
|
|
|
11
11
|
// src/handlers/health.ts
|
|
12
12
|
function readHealthReport() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
recordTaskExecution
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EIX2LQ6L.js";
|
|
4
4
|
import {
|
|
5
5
|
pluginTaskId,
|
|
6
6
|
pluginTaskParamsSchema,
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
calculateContextCompactionTargetTokens,
|
|
11
11
|
estimateTextTokens,
|
|
12
12
|
getConversationContextCompactionTriggerTokens
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VTDMB7XX.js";
|
|
14
14
|
import {
|
|
15
15
|
buildDeterministicTurnId,
|
|
16
16
|
clearPendingAuth,
|
|
17
17
|
coerceThreadConversationState,
|
|
18
|
-
getAgentTurnSessionRecord,
|
|
19
18
|
getPersistedThreadState,
|
|
20
19
|
getPiMessageRole,
|
|
20
|
+
getTurnRecord,
|
|
21
21
|
hydrateConversationMessages,
|
|
22
22
|
instructionTextForProjection,
|
|
23
23
|
isToolResultError,
|
|
@@ -28,14 +28,14 @@ import {
|
|
|
28
28
|
normalizeToolNameFromResult,
|
|
29
29
|
persistThreadStateById,
|
|
30
30
|
stripRuntimeTurnContext
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ZIAMN2UW.js";
|
|
32
32
|
import {
|
|
33
33
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
34
34
|
} from "./chunk-3Y47VMHV.js";
|
|
35
35
|
import {
|
|
36
36
|
fallbackShortTitle,
|
|
37
37
|
generateShortTitle
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-ZYAJMESY.js";
|
|
39
39
|
import {
|
|
40
40
|
createPluginConversationEvents,
|
|
41
41
|
createPluginEmbedder,
|
|
@@ -43,15 +43,15 @@ import {
|
|
|
43
43
|
createPluginModel,
|
|
44
44
|
createPluginState,
|
|
45
45
|
getPlugins
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-ZIMRGFYL.js";
|
|
47
47
|
import {
|
|
48
48
|
getConversationStore,
|
|
49
49
|
getDb,
|
|
50
50
|
sameActorIdentity
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-2UH3JI64.js";
|
|
52
52
|
import {
|
|
53
53
|
getStateAdapter
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-QUG4JSZK.js";
|
|
55
55
|
import {
|
|
56
56
|
ProviderError,
|
|
57
57
|
botConfig,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
findProviderError,
|
|
60
60
|
getProviderErrorAttributes,
|
|
61
61
|
getProviderErrorUserMessage
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-XFKIRN3Q.js";
|
|
63
63
|
import {
|
|
64
64
|
credentialSubjectSchema
|
|
65
65
|
} from "./chunk-RUIXF3YQ.js";
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
buildTurnFailureResponse,
|
|
71
71
|
logWarn,
|
|
72
72
|
setSpanAttributes
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-2LWPFSB4.js";
|
|
74
74
|
|
|
75
75
|
// src/chat/services/conversation-memory.ts
|
|
76
76
|
var CONTEXT_MIN_LIVE_MESSAGES = 12;
|
|
@@ -410,7 +410,7 @@ import {
|
|
|
410
410
|
|
|
411
411
|
// src/chat/services/turn-session-routing.ts
|
|
412
412
|
async function resolveTurnSessionRouting(args) {
|
|
413
|
-
const conversationStore = args.conversationStore ?? (await import("./db-
|
|
413
|
+
const conversationStore = args.conversationStore ?? (await import("./db-62PW6LM3.js")).getConversationStore();
|
|
414
414
|
const conversation = await conversationStore.get({
|
|
415
415
|
conversationId: args.conversationId
|
|
416
416
|
});
|
|
@@ -998,10 +998,7 @@ async function withPluginTaskLock(taskId, callback) {
|
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
async function loadPluginRun(params) {
|
|
1001
|
-
const record = await
|
|
1002
|
-
params.conversationId,
|
|
1003
|
-
params.sessionId
|
|
1004
|
-
);
|
|
1001
|
+
const record = await getTurnRecord(params.conversationId, params.sessionId);
|
|
1005
1002
|
if (!record) {
|
|
1006
1003
|
throw new Error("Completed plugin task session record is unavailable");
|
|
1007
1004
|
}
|
|
@@ -1033,7 +1030,7 @@ async function loadPluginRun(params) {
|
|
|
1033
1030
|
// stripped transcript, so it reflects every committed instruction actor.
|
|
1034
1031
|
actors: record.actors,
|
|
1035
1032
|
...runActor ? { actor: runActor } : {},
|
|
1036
|
-
runId: record.
|
|
1033
|
+
runId: record.turnId,
|
|
1037
1034
|
source: routing.source,
|
|
1038
1035
|
transcript: [...contextEntries, ...runEntries]
|
|
1039
1036
|
});
|
|
@@ -1085,7 +1082,7 @@ async function scheduleSessionCompletedPluginTasks(params, options = {}) {
|
|
|
1085
1082
|
if (taskRegistrations.length === 0) {
|
|
1086
1083
|
return;
|
|
1087
1084
|
}
|
|
1088
|
-
const record = await
|
|
1085
|
+
const record = await getTurnRecord(
|
|
1089
1086
|
coreParams.conversationId,
|
|
1090
1087
|
coreParams.sessionId
|
|
1091
1088
|
);
|
|
@@ -1,16 +1,54 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getChatConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XFKIRN3Q.js";
|
|
4
4
|
|
|
5
5
|
// src/chat/state/adapter.ts
|
|
6
6
|
import { createMemoryState } from "@chat-adapter/state-memory";
|
|
7
7
|
import { createRedisState } from "@chat-adapter/state-redis";
|
|
8
8
|
|
|
9
9
|
// src/chat/state/locks.ts
|
|
10
|
+
import { setTimeout as sleep } from "timers/promises";
|
|
10
11
|
var ACTIVE_LOCK_TTL_MS = 9e4;
|
|
12
|
+
var MUTATION_LOCK_TTL_MS = 1e4;
|
|
11
13
|
async function acquireActiveLock(state, threadId) {
|
|
12
14
|
return await state.acquireLock(threadId, ACTIVE_LOCK_TTL_MS);
|
|
13
15
|
}
|
|
16
|
+
async function withLock(state, key, run, options = {}) {
|
|
17
|
+
const startedAtMs = Date.now();
|
|
18
|
+
let lock;
|
|
19
|
+
while (true) {
|
|
20
|
+
lock = await state.acquireLock(key, options.ttlMs ?? ACTIVE_LOCK_TTL_MS);
|
|
21
|
+
if (lock) break;
|
|
22
|
+
if (Date.now() - startedAtMs >= (options.waitMs ?? 0)) {
|
|
23
|
+
return { acquired: false };
|
|
24
|
+
}
|
|
25
|
+
await sleep(options.retryMs ?? 25, void 0, { ref: false });
|
|
26
|
+
}
|
|
27
|
+
const ttlMs = options.ttlMs ?? ACTIVE_LOCK_TTL_MS;
|
|
28
|
+
const heartbeat = options.keepAlive ? setInterval(
|
|
29
|
+
() => {
|
|
30
|
+
void state.extendLock(lock, ttlMs);
|
|
31
|
+
},
|
|
32
|
+
Math.max(1, Math.floor(ttlMs / 3))
|
|
33
|
+
) : void 0;
|
|
34
|
+
heartbeat?.unref();
|
|
35
|
+
try {
|
|
36
|
+
return { acquired: true, value: await run(lock) };
|
|
37
|
+
} finally {
|
|
38
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
39
|
+
await state.releaseLock(lock);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function fenceLock(state, lock, ttlMs = MUTATION_LOCK_TTL_MS) {
|
|
43
|
+
if (!await state.extendLock(lock, ttlMs)) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Lock ownership was lost before write for ${lock.threadId}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function withActiveLock(state, key, run) {
|
|
50
|
+
return await withLock(state, key, run);
|
|
51
|
+
}
|
|
14
52
|
|
|
15
53
|
// src/chat/state/adapter.ts
|
|
16
54
|
var ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
|
|
@@ -272,7 +310,11 @@ async function disconnectStateAdapter() {
|
|
|
272
310
|
}
|
|
273
311
|
|
|
274
312
|
export {
|
|
313
|
+
MUTATION_LOCK_TTL_MS,
|
|
275
314
|
acquireActiveLock,
|
|
315
|
+
withLock,
|
|
316
|
+
fenceLock,
|
|
317
|
+
withActiveLock,
|
|
276
318
|
getDefaultRedisStateAdapterFor,
|
|
277
319
|
getStateAdapter,
|
|
278
320
|
disconnectStateAdapter
|
|
@@ -16,22 +16,22 @@ import {
|
|
|
16
16
|
recordAttemptFailure,
|
|
17
17
|
recordConversationRetry,
|
|
18
18
|
releaseConversationWork,
|
|
19
|
-
|
|
19
|
+
requestAnotherSlice,
|
|
20
20
|
startConversationWork
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-HLOUZC5C.js";
|
|
22
22
|
import {
|
|
23
23
|
ConversationQueueMessageRejectedError
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-JAL3CH4G.js";
|
|
25
25
|
import {
|
|
26
26
|
getChatConfig,
|
|
27
27
|
isProviderRetryError
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-XFKIRN3Q.js";
|
|
29
29
|
import {
|
|
30
30
|
logException,
|
|
31
31
|
logInfo,
|
|
32
32
|
logWarn,
|
|
33
33
|
withLogContext
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-2LWPFSB4.js";
|
|
35
35
|
|
|
36
36
|
// src/chat/task-execution/worker.ts
|
|
37
37
|
var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|
|
@@ -59,7 +59,7 @@ function selectAttemptMessages(work) {
|
|
|
59
59
|
if (interrupts.length > 0) {
|
|
60
60
|
return selectContiguousActorBatch(interrupts);
|
|
61
61
|
}
|
|
62
|
-
return work.execution.status === "
|
|
62
|
+
return work.execution.status === "paused" ? [] : selectContiguousActorBatch(messages);
|
|
63
63
|
}
|
|
64
64
|
function nudgeIdempotencyKey(reason, conversationId, nowMs) {
|
|
65
65
|
return `${reason}:${conversationId}:${nowMs}`;
|
|
@@ -91,7 +91,7 @@ async function requestLostLeaseRecovery(args) {
|
|
|
91
91
|
);
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
const
|
|
94
|
+
const sliceRequested = await requestAnotherSlice({
|
|
95
95
|
conversationId: args.conversationId,
|
|
96
96
|
destination: args.destination,
|
|
97
97
|
leaseToken: args.leaseToken,
|
|
@@ -99,7 +99,7 @@ async function requestLostLeaseRecovery(args) {
|
|
|
99
99
|
nowMs: args.nowMs,
|
|
100
100
|
state: args.options.state
|
|
101
101
|
});
|
|
102
|
-
if (!
|
|
102
|
+
if (!sliceRequested) {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
const released = await releaseConversationWork({
|
|
@@ -343,7 +343,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
343
343
|
});
|
|
344
344
|
return { status: "lost_lease" };
|
|
345
345
|
}
|
|
346
|
-
const resumePending = leasedWork.execution.status === "
|
|
346
|
+
const resumePending = leasedWork.execution.status === "paused";
|
|
347
347
|
const attemptMessages = selectAttemptMessages(leasedWork);
|
|
348
348
|
attemptStartMessageIds = new Set(
|
|
349
349
|
leasedWork.messages.map((message2) => message2.inboundMessageId)
|
|
@@ -433,7 +433,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
433
433
|
return { status: "lost_lease" };
|
|
434
434
|
}
|
|
435
435
|
if (result.status === "yielded") {
|
|
436
|
-
const
|
|
436
|
+
const sliceRequested = await requestAnotherSlice({
|
|
437
437
|
conversationId,
|
|
438
438
|
destination,
|
|
439
439
|
leaseToken: lease.leaseToken,
|
|
@@ -441,7 +441,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
441
441
|
nowMs: now(options),
|
|
442
442
|
state: options.state
|
|
443
443
|
});
|
|
444
|
-
if (!
|
|
444
|
+
if (!sliceRequested) {
|
|
445
445
|
return { status: "lost_lease" };
|
|
446
446
|
}
|
|
447
447
|
return await yieldWork();
|
|
@@ -514,7 +514,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
514
514
|
if (!next || next.lease?.leaseToken !== lease.leaseToken) {
|
|
515
515
|
return { status: "lost_lease" };
|
|
516
516
|
}
|
|
517
|
-
if (next.execution.status !== "
|
|
517
|
+
if (next.execution.status !== "paused" && countPendingConversationMessages(next) === 0) {
|
|
518
518
|
break;
|
|
519
519
|
}
|
|
520
520
|
}
|
|
@@ -613,7 +613,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
613
613
|
recoveryRecorded = true;
|
|
614
614
|
return { status: "failed" };
|
|
615
615
|
}
|
|
616
|
-
const
|
|
616
|
+
const sliceRequested = await requestAnotherSlice({
|
|
617
617
|
conversationId,
|
|
618
618
|
destination,
|
|
619
619
|
leaseToken: lease.leaseToken,
|
|
@@ -621,7 +621,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
621
621
|
nowMs: errorNowMs,
|
|
622
622
|
state: options.state
|
|
623
623
|
});
|
|
624
|
-
if (
|
|
624
|
+
if (sliceRequested) {
|
|
625
625
|
await ensureConversationWake({
|
|
626
626
|
conversationId,
|
|
627
627
|
conversationStore: options.conversationStore,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-EM225ITJ.js";
|
|
4
4
|
import {
|
|
5
5
|
getSlackBotToken
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XFKIRN3Q.js";
|
|
7
7
|
import {
|
|
8
8
|
parseSlackChannelReferenceId
|
|
9
9
|
} from "./chunk-F3B2YJ76.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
setSpanAttributes,
|
|
13
13
|
setSpanStatus,
|
|
14
14
|
withSpan
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2LWPFSB4.js";
|
|
16
16
|
|
|
17
17
|
// src/chat/slack/client.ts
|
|
18
18
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
conversationQueueMessageSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JAL3CH4G.js";
|
|
4
4
|
import {
|
|
5
5
|
createVercelQueueClient
|
|
6
6
|
} from "./chunk-5I6ORJUY.js";
|
|
@@ -79,7 +79,10 @@ function verifyConversationQueueMessage(value, nowMs = Date.now()) {
|
|
|
79
79
|
}
|
|
80
80
|
return {
|
|
81
81
|
status: "verified",
|
|
82
|
-
message: {
|
|
82
|
+
message: {
|
|
83
|
+
schemaVersion: message.schemaVersion,
|
|
84
|
+
conversationId: message.conversationId
|
|
85
|
+
}
|
|
83
86
|
};
|
|
84
87
|
}
|
|
85
88
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
toCanonicalInputMessage,
|
|
4
4
|
toCanonicalOutputMessage,
|
|
5
5
|
toGenAiMessagesTraceAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JTGS3ZZE.js";
|
|
7
7
|
import {
|
|
8
8
|
extractGenAiUsageAttributes,
|
|
9
9
|
logException,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
normalizeGenAiFinishReason,
|
|
12
12
|
serializeGenAiAttribute,
|
|
13
13
|
withSpan
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2LWPFSB4.js";
|
|
15
15
|
|
|
16
16
|
// src/chat/services/provider-error.ts
|
|
17
17
|
var ProviderError = class extends Error {
|
|
@@ -195,31 +195,6 @@ function getProviderErrorAttributes(error) {
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
// src/chat/model-profile.ts
|
|
199
|
-
import { z } from "zod";
|
|
200
|
-
var STANDARD_MODEL_PROFILE = "standard";
|
|
201
|
-
var DEFAULT_HANDOFF_MODEL_PROFILE = "handoff";
|
|
202
|
-
var modelProfileSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
|
|
203
|
-
var ModelProfileNotConfiguredError = class extends Error {
|
|
204
|
-
constructor(profile) {
|
|
205
|
-
super(`Model profile "${profile}" is not configured`);
|
|
206
|
-
this.name = "ModelProfileNotConfiguredError";
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
function modelIdForProfile(config, profile) {
|
|
210
|
-
return profileConfig(config, profile).modelId;
|
|
211
|
-
}
|
|
212
|
-
function standardModelId(config) {
|
|
213
|
-
return modelIdForProfile(config, STANDARD_MODEL_PROFILE);
|
|
214
|
-
}
|
|
215
|
-
function profileConfig(config, profile) {
|
|
216
|
-
const profileConfig2 = Object.hasOwn(config.profiles, profile) ? config.profiles[profile] : void 0;
|
|
217
|
-
if (!profileConfig2) {
|
|
218
|
-
throw new ModelProfileNotConfiguredError(profile);
|
|
219
|
-
}
|
|
220
|
-
return profileConfig2;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
198
|
// src/chat/config.ts
|
|
224
199
|
import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
|
|
225
200
|
|
|
@@ -677,7 +652,7 @@ function normalizeSlackEmojiName(value) {
|
|
|
677
652
|
}
|
|
678
653
|
|
|
679
654
|
// src/chat/reasoning-level.ts
|
|
680
|
-
import { z
|
|
655
|
+
import { z } from "zod";
|
|
681
656
|
var TURN_REASONING_LEVELS = [
|
|
682
657
|
"none",
|
|
683
658
|
"low",
|
|
@@ -686,7 +661,32 @@ var TURN_REASONING_LEVELS = [
|
|
|
686
661
|
"xhigh"
|
|
687
662
|
];
|
|
688
663
|
function parseTurnReasoningLevel(value) {
|
|
689
|
-
return
|
|
664
|
+
return z.enum(TURN_REASONING_LEVELS).parse(value);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// src/chat/model-profile.ts
|
|
668
|
+
import { z as z2 } from "zod";
|
|
669
|
+
var STANDARD_MODEL_PROFILE = "standard";
|
|
670
|
+
var DEFAULT_HANDOFF_MODEL_PROFILE = "handoff";
|
|
671
|
+
var modelProfileSchema = z2.string().regex(/^[a-z][a-z0-9_-]*$/);
|
|
672
|
+
var ModelProfileNotConfiguredError = class extends Error {
|
|
673
|
+
constructor(profile) {
|
|
674
|
+
super(`Model profile "${profile}" is not configured`);
|
|
675
|
+
this.name = "ModelProfileNotConfiguredError";
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
function modelIdForProfile(config, profile) {
|
|
679
|
+
return profileConfig(config, profile).modelId;
|
|
680
|
+
}
|
|
681
|
+
function standardModelId(config) {
|
|
682
|
+
return modelIdForProfile(config, STANDARD_MODEL_PROFILE);
|
|
683
|
+
}
|
|
684
|
+
function profileConfig(config, profile) {
|
|
685
|
+
const profileConfig2 = Object.hasOwn(config.profiles, profile) ? config.profiles[profile] : void 0;
|
|
686
|
+
if (!profileConfig2) {
|
|
687
|
+
throw new ModelProfileNotConfiguredError(profile);
|
|
688
|
+
}
|
|
689
|
+
return profileConfig2;
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
// src/chat/config.ts
|
|
@@ -4,22 +4,22 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
canRouteResourceEvents,
|
|
6
6
|
getPlugins
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZIMRGFYL.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2UH3JI64.js";
|
|
11
11
|
import {
|
|
12
12
|
juniorEventTasks,
|
|
13
13
|
juniorSchedulerRuns,
|
|
14
14
|
juniorSchedulerTasks,
|
|
15
15
|
juniorStats
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-27TEJTZO.js";
|
|
17
17
|
import {
|
|
18
18
|
juniorDestinations
|
|
19
19
|
} from "./chunk-VFUK3X5B.js";
|
|
20
20
|
import {
|
|
21
21
|
logInfo
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-2LWPFSB4.js";
|
|
23
23
|
|
|
24
24
|
// src/chat/event-tasks/store.ts
|
|
25
25
|
import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
|