@sentry/junior 0.146.0 → 0.148.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-SLJADYE5.js → agent-hooks-VAUYT6PD.js} +10 -10
- package/dist/api/conversations/access.d.ts +2 -1
- package/dist/api/conversations/archive.d.ts +3 -5
- package/dist/api/conversations/create.d.ts +6 -0
- package/dist/api/conversations/detail.d.ts +2 -295
- package/dist/api/conversations/event-list.d.ts +2 -192
- package/dist/api/conversations/list.d.ts +4 -66
- package/dist/api/conversations/routes.d.ts +1 -1
- package/dist/api/conversations/stats.d.ts +0 -54
- package/dist/api/http.d.ts +2 -6
- package/dist/api/locations/detail.d.ts +3 -111
- package/dist/api/locations/list.d.ts +0 -45
- package/dist/api/locations/query.d.ts +2 -1
- package/dist/api/locations/routes.d.ts +1 -1
- package/dist/api/people/list.d.ts +0 -29
- package/dist/api/people/profile.d.ts +2 -106
- package/dist/api/people/profile.query.d.ts +2 -1
- package/dist/api/people/routes.d.ts +1 -1
- package/dist/api/people/shared.d.ts +1 -1
- package/dist/api/people/spend.d.ts +3 -4
- package/dist/api/personal-tokens/routes.d.ts +2 -2
- package/dist/api/route.d.ts +8 -14
- package/dist/api/schema/conversation.d.ts +64 -29
- package/dist/api/schema/location.d.ts +4 -0
- package/dist/api/schema/person.d.ts +7 -3
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -1
- package/dist/api/stats.d.ts +0 -13
- package/dist/api/validation.d.ts +7 -0
- package/dist/api/viewer.d.ts +3 -0
- package/dist/api.d.ts +2 -1
- package/dist/api.js +630 -564
- package/dist/app.js +369 -309
- package/dist/{catalog-runtime-RQIMSDPR.js → catalog-runtime-WADOZVTB.js} +5 -5
- package/dist/chat/actor.d.ts +4 -1
- package/dist/chat/agent/prompt.d.ts +0 -2
- package/dist/chat/agent/request.d.ts +4 -5
- package/dist/chat/agent/resume.d.ts +1 -0
- package/dist/chat/agent/sandbox.d.ts +2 -2
- package/dist/chat/agent/tools.d.ts +0 -2
- package/dist/chat/agent-dispatch/context.d.ts +2 -2
- package/dist/chat/agent-dispatch/types.d.ts +2 -2
- package/dist/chat/agent-invocations/types.d.ts +52 -0
- package/dist/chat/api-turns/work.d.ts +103 -0
- package/dist/chat/capabilities/jr-rpc-command.d.ts +2 -2
- package/dist/chat/configuration/service.d.ts +5 -2
- package/dist/chat/configuration/sql.d.ts +9 -0
- package/dist/chat/configuration/types.d.ts +17 -13
- package/dist/chat/conversations/history.d.ts +63 -0
- package/dist/chat/conversations/projection.d.ts +10 -0
- package/dist/chat/conversations/provenance.d.ts +6 -0
- package/dist/chat/conversations/sql/actor-identity.d.ts +19 -0
- package/dist/chat/conversations/store.d.ts +1 -1
- package/dist/chat/credentials/unlink-provider.d.ts +2 -1
- package/dist/chat/credentials/user-token-store.d.ts +2 -0
- package/dist/chat/event-tasks/tool-support.d.ts +2 -0
- package/dist/chat/identities/sql.d.ts +8 -0
- package/dist/chat/logging.d.ts +2 -0
- package/dist/chat/mcp/auth-store.d.ts +0 -2
- package/dist/chat/mcp/oauth.d.ts +0 -2
- package/dist/chat/oauth-flow.d.ts +3 -1
- package/dist/chat/pi/client.d.ts +2 -0
- package/dist/chat/plugins/credential-hooks.d.ts +2 -0
- package/dist/chat/prompt.d.ts +0 -2
- package/dist/chat/resource-events/notification.d.ts +2 -1
- package/dist/chat/resource-events/store.d.ts +1 -1
- package/dist/chat/runtime/delivered-turn-state.d.ts +1 -4
- package/dist/chat/runtime/reply-executor.d.ts +1 -1
- package/dist/chat/runtime/slack-runtime.d.ts +2 -1
- package/dist/chat/runtime/thread-state.d.ts +8 -11
- package/dist/chat/runtime/turn-input.d.ts +4 -2
- package/dist/chat/runtime/turn-preparation.d.ts +11 -4
- package/dist/chat/sandbox/command-result.d.ts +2 -0
- package/dist/chat/sandbox/egress/schemas.d.ts +6 -0
- package/dist/chat/scheduled-tasks/tool-support.d.ts +7 -5
- package/dist/chat/scheduled-tasks/tools/create.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/list.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +4 -2
- package/dist/chat/scheduled-tasks/tools/update.d.ts +4 -2
- package/dist/chat/services/mcp-auth-orchestration.d.ts +0 -3
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
- package/dist/chat/services/provider-default-config.d.ts +2 -2
- package/dist/chat/services/subscribed-decision.d.ts +3 -0
- package/dist/chat/services/subscribed-reply-policy.d.ts +1 -0
- package/dist/chat/services/turn-result.d.ts +0 -3
- package/dist/chat/services/turn-router.d.ts +3 -0
- package/dist/chat/slack/assistant-thread/lifecycle.d.ts +0 -1
- package/dist/chat/slack/assistant-thread/title.d.ts +0 -3
- package/dist/chat/slack/channel.d.ts +26 -0
- package/dist/chat/slack/dispatch-turn.d.ts +2 -1
- package/dist/chat/slack/timestamp-param.d.ts +0 -2
- package/dist/chat/slack/{tools → tool-support}/canvas/api.d.ts +1 -1
- package/dist/chat/slack/tool-support/canvas/context.d.ts +11 -0
- package/dist/chat/slack/tool-support/channel-access.d.ts +42 -0
- package/dist/chat/slack/tool-support/channel-target.d.ts +27 -0
- package/dist/chat/slack/{tools → tool-support}/list/api.d.ts +8 -1
- package/dist/chat/slack/tool-support/list/params.d.ts +5 -0
- package/dist/chat/slack/tools/canvas/create.d.ts +3 -1
- package/dist/chat/slack/tools/canvas/edit.d.ts +2 -0
- package/dist/chat/slack/tools/canvas/read.d.ts +2 -0
- package/dist/chat/slack/tools/canvas/write.d.ts +2 -0
- package/dist/chat/slack/tools/{user-lookup.d.ts → channel-join.d.ts} +6 -5
- package/dist/chat/slack/tools/channel-list-messages.d.ts +5 -2
- package/dist/chat/slack/tools/conversation-message-search.d.ts +4 -8
- package/dist/chat/slack/tools/list/add-items.d.ts +4 -1
- package/dist/chat/slack/tools/list/create.d.ts +2 -0
- package/dist/chat/slack/tools/list/get-items.d.ts +5 -3
- package/dist/chat/slack/tools/list/update-item.d.ts +5 -1
- package/dist/chat/slack/tools/message-add-reaction.d.ts +3 -1
- package/dist/chat/slack/tools/public-search.d.ts +65 -2
- package/dist/chat/slack/tools/send-files.d.ts +3 -1
- package/dist/chat/slack/tools/thread-read.d.ts +4 -5
- package/dist/chat/slack/vision-cache.d.ts +5 -0
- package/dist/chat/source.d.ts +2 -0
- package/dist/chat/state/conversation.d.ts +4 -5
- package/dist/chat/task-execution/checkpoint.d.ts +1 -0
- package/dist/chat/task-execution/state.d.ts +9 -4
- package/dist/chat/task-execution/store.d.ts +3 -2
- package/dist/chat/task-execution/turn-cursor.d.ts +2 -0
- package/dist/chat/task-execution/worker.d.ts +2 -0
- package/dist/chat/tasks/read.d.ts +1 -1
- package/dist/chat/tool-support/structured-result.d.ts +1 -0
- package/dist/chat/tool-support/timed-out-tool-result.d.ts +11 -0
- package/dist/chat/tools/create-event-task.d.ts +2 -0
- package/dist/chat/tools/delete-event-task.d.ts +2 -0
- package/dist/chat/tools/handoff/tool.d.ts +2 -0
- package/dist/chat/tools/list-event-tasks.d.ts +2 -0
- package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
- package/dist/chat/tools/runtime/report-progress.d.ts +2 -0
- package/dist/chat/tools/runtime/spawn-agent.d.ts +2 -0
- package/dist/chat/tools/search-conversation-events.d.ts +3 -1
- package/dist/chat/tools/search-resource-event-types.d.ts +2 -0
- package/dist/chat/tools/search-tools.d.ts +2 -0
- package/dist/chat/tools/skill/load-skill.d.ts +2 -0
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +2 -0
- package/dist/chat/tools/stop-watching-resources.d.ts +2 -0
- package/dist/chat/tools/system-time.d.ts +2 -0
- package/dist/chat/tools/types.d.ts +11 -10
- package/dist/chat/tools/update-event-task.d.ts +2 -0
- package/dist/chat/tools/user-lookup.d.ts +29 -0
- package/dist/chat/tools/watch-resource-events.d.ts +4 -2
- package/dist/chat/tools/web/fetch-tool.d.ts +2 -0
- package/dist/chat/tools/web/image-generate.d.ts +2 -0
- package/dist/chat/tools/web/search.d.ts +2 -0
- package/dist/{chunk-GYEKOX7N.js → chunk-2B3PT3V2.js} +1 -1
- package/dist/{chunk-JLMVCNXL.js → chunk-45LOR4PU.js} +22 -4
- package/dist/{chunk-FGHADGIC.js → chunk-4AQZYNHM.js} +2 -2
- package/dist/{chunk-W65V465O.js → chunk-4EA2SFK2.js} +66 -4
- package/dist/{chunk-MKRIZ4VG.js → chunk-4GXJUYJV.js} +4 -2
- package/dist/{chunk-F7REGDKO.js → chunk-55F4QU2V.js} +2 -1
- package/dist/{chunk-M6ZWP4RI.js → chunk-7OEIXFC3.js} +2 -2
- package/dist/{chunk-MCFIXAV5.js → chunk-D3WPMGEX.js} +55 -37
- package/dist/{chunk-AISNSNDV.js → chunk-D6YX4NNN.js} +22 -10
- package/dist/chunk-DUY5CDAM.js +36 -0
- package/dist/{chunk-B63BF443.js → chunk-EAI67NTM.js} +9 -1
- package/dist/{chunk-FEKQHPVA.js → chunk-EINWQFXI.js} +9 -8
- package/dist/chunk-GDFF3BQG.js +136 -0
- package/dist/{chunk-X22KCSCO.js → chunk-GXYDVZKM.js} +7 -5
- package/dist/{chunk-X2WMBTS3.js → chunk-HLPLT3NY.js} +8 -5
- package/dist/{chunk-PB222GIA.js → chunk-HWQGBIH7.js} +1 -1
- package/dist/chunk-IL4EDBMV.js +566 -0
- package/dist/{chunk-HQE6EJS5.js → chunk-LAZGHEYU.js} +1 -1
- package/dist/{chunk-QG7OOKIN.js → chunk-LE5H7LMT.js} +1 -1
- package/dist/chunk-LNVEIJ2L.js +48 -0
- package/dist/{chunk-JUA6VU2Z.js → chunk-OJCP3C3J.js} +12 -23
- package/dist/{chunk-37JJDS4H.js → chunk-POSZWRGL.js} +1 -1
- package/dist/{chunk-TCEJ7XXM.js → chunk-QOWHHM3F.js} +1 -1
- package/dist/{chunk-H6U2U3EP.js → chunk-RRJV5UR5.js} +304 -65
- package/dist/{chunk-OFPYOC3M.js → chunk-ULAU5ZGU.js} +127 -120
- package/dist/{chunk-V6SRLKUB.js → chunk-V2FXMOEA.js} +2 -2
- package/dist/{chunk-GDQEU4I7.js → chunk-VCYSOXON.js} +296 -526
- package/dist/{chunk-BLETMLRX.js → chunk-VMNRXKAH.js} +1374 -989
- package/dist/{chunk-37EVZP66.js → chunk-VRHTNBA6.js} +167 -92
- package/dist/{chunk-FXDDDSPL.js → chunk-VY6W3T43.js} +4 -4
- package/dist/{chunk-ZDGHGY74.js → chunk-WCN4YSH7.js} +13 -6
- package/dist/{chunk-PH4Q3A6W.js → chunk-WOONT5ZP.js} +1 -1
- package/dist/{chunk-47OSH2ZO.js → chunk-XJ42NBP5.js} +395 -206
- package/dist/{chunk-SCGVWUZX.js → chunk-ZCHIC2GM.js} +92 -75
- package/dist/chunk-ZPL2RR7F.js +798 -0
- package/dist/cli/chat.js +33 -35
- 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/schema/agent-invocations.d.ts +20 -0
- package/dist/db/schema/conversation-annotations.d.ts +2 -2
- package/dist/db/schema/location-configurations.d.ts +127 -0
- package/dist/db/schema.d.ts +150 -3
- package/dist/{db-WWOMXWTT.js → db-XUKZRFFK.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-A6ZZX74U.js → oauth-callback-server-LPZMMGFI.js} +25 -26
- package/dist/{runner-KSGB2UAV.js → runner-DGKUTMPX.js} +22 -41
- package/dist/{skills-26QPWKVS.js → skills-P7YUFSXM.js} +6 -6
- package/dist/spawn-DSK3ZEVD.js +38 -0
- package/dist/{validation-OPSRGFGH.js → validation-S7U5M5NR.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-VMSW7STJ.js → work-GAA7TVAD.js} +18 -19
- package/dist/{worker-2JNFB7C7.js → worker-JXPJH3QB.js} +11 -10
- package/migrations/0024_misty_typhoid_mary.sql +12 -0
- package/migrations/meta/0024_snapshot.json +2275 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -5
- package/dist/api/health.d.ts +0 -7
- package/dist/api/personal-tokens/create.d.ts +0 -11
- package/dist/api/personal-tokens/list.d.ts +0 -12
- package/dist/api/personal-tokens/revoke.d.ts +0 -5
- package/dist/api/plugin-reports.d.ts +0 -63
- package/dist/api/plugins.d.ts +0 -8
- package/dist/api/runtime.d.ts +0 -24
- package/dist/api/skills.d.ts +0 -6
- package/dist/chat/slack/tools/canvas/context.d.ts +0 -18
- package/dist/chat/slack/tools/channel-access.d.ts +0 -30
- package/dist/chat/state/artifacts.d.ts +0 -30
- package/dist/chat/tool-support/turn-deadline-result.d.ts +0 -3
- package/dist/chunk-HLXXQI5Q.js +0 -238
- package/dist/chunk-LVW7BLLT.js +0 -115
- package/dist/chunk-Q6QZTTLS.js +0 -55
- package/dist/chunk-QSXZ42KX.js +0 -285
- package/dist/chunk-R776HKPK.js +0 -81
- package/dist/chunk-T5GXFFLA.js +0 -67
- package/dist/spawn-5LAJXZ2P.js +0 -39
- /package/dist/chat/slack/{tools → tool-support}/canvas/markdown.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/channel-capabilities.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/context.d.ts +0 -0
- /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type SlackTeamId } from "@/chat/slack/ids";
|
|
2
|
+
/** Create the tool that resolves people by identity provider and query. */
|
|
3
|
+
export declare function createUserLookupTool(teamId: SlackTeamId, providers: [string, ...string[]]): Omit<import("./definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
4
|
+
inputSchema: import("./definition").JsonSchemaObject;
|
|
5
|
+
outputSchema: import("./definition").JsonSchemaObject;
|
|
6
|
+
prepareArguments(args: unknown): {
|
|
7
|
+
provider: string;
|
|
8
|
+
query: string;
|
|
9
|
+
};
|
|
10
|
+
execute?: ((input: unknown, options: import("./definition").ToolExecuteOptions) => {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
target?: string | undefined;
|
|
13
|
+
truncated?: boolean | undefined;
|
|
14
|
+
timed_out?: boolean | undefined;
|
|
15
|
+
continuation?: {
|
|
16
|
+
arguments: Record<string, unknown>;
|
|
17
|
+
reason?: string | undefined;
|
|
18
|
+
} | undefined;
|
|
19
|
+
} | Promise<{
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
target?: string | undefined;
|
|
22
|
+
truncated?: boolean | undefined;
|
|
23
|
+
timed_out?: boolean | undefined;
|
|
24
|
+
continuation?: {
|
|
25
|
+
arguments: Record<string, unknown>;
|
|
26
|
+
reason?: string | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
}>) | undefined;
|
|
29
|
+
};
|
|
@@ -15,7 +15,7 @@ export declare function createWatchResourceEventsTool(context: ToolRuntimeContex
|
|
|
15
15
|
};
|
|
16
16
|
execute?: ((input: unknown, options: import("./definition").ToolExecuteOptions) => {
|
|
17
17
|
id: string;
|
|
18
|
-
subscription_status: "
|
|
18
|
+
subscription_status: "completed" | "active" | "cancelled";
|
|
19
19
|
identifier: string;
|
|
20
20
|
events: string[];
|
|
21
21
|
expiresAtMs: number;
|
|
@@ -30,13 +30,14 @@ export declare function createWatchResourceEventsTool(context: ToolRuntimeContex
|
|
|
30
30
|
};
|
|
31
31
|
target?: string | undefined;
|
|
32
32
|
truncated?: boolean | undefined;
|
|
33
|
+
timed_out?: boolean | undefined;
|
|
33
34
|
continuation?: {
|
|
34
35
|
arguments: Record<string, unknown>;
|
|
35
36
|
reason?: string | undefined;
|
|
36
37
|
} | undefined;
|
|
37
38
|
} | Promise<{
|
|
38
39
|
id: string;
|
|
39
|
-
subscription_status: "
|
|
40
|
+
subscription_status: "completed" | "active" | "cancelled";
|
|
40
41
|
identifier: string;
|
|
41
42
|
events: string[];
|
|
42
43
|
expiresAtMs: number;
|
|
@@ -51,6 +52,7 @@ export declare function createWatchResourceEventsTool(context: ToolRuntimeContex
|
|
|
51
52
|
};
|
|
52
53
|
target?: string | undefined;
|
|
53
54
|
truncated?: boolean | undefined;
|
|
55
|
+
timed_out?: boolean | undefined;
|
|
54
56
|
continuation?: {
|
|
55
57
|
arguments: Record<string, unknown>;
|
|
56
58
|
reason?: string | undefined;
|
|
@@ -13,6 +13,7 @@ export declare function createWebFetchTool(hooks: ToolHooks, options?: {
|
|
|
13
13
|
[x: string]: unknown;
|
|
14
14
|
target?: string | undefined;
|
|
15
15
|
truncated?: boolean | undefined;
|
|
16
|
+
timed_out?: boolean | undefined;
|
|
16
17
|
continuation?: {
|
|
17
18
|
arguments: Record<string, unknown>;
|
|
18
19
|
reason?: string | undefined;
|
|
@@ -21,6 +22,7 @@ export declare function createWebFetchTool(hooks: ToolHooks, options?: {
|
|
|
21
22
|
[x: string]: unknown;
|
|
22
23
|
target?: string | undefined;
|
|
23
24
|
truncated?: boolean | undefined;
|
|
25
|
+
timed_out?: boolean | undefined;
|
|
24
26
|
continuation?: {
|
|
25
27
|
arguments: Record<string, unknown>;
|
|
26
28
|
reason?: string | undefined;
|
|
@@ -23,6 +23,7 @@ export declare function createImageGenerateTool(hooks: Required<Pick<ToolHooks,
|
|
|
23
23
|
delivery: string;
|
|
24
24
|
target?: string | undefined;
|
|
25
25
|
truncated?: boolean | undefined;
|
|
26
|
+
timed_out?: boolean | undefined;
|
|
26
27
|
continuation?: {
|
|
27
28
|
arguments: Record<string, unknown>;
|
|
28
29
|
reason?: string | undefined;
|
|
@@ -41,6 +42,7 @@ export declare function createImageGenerateTool(hooks: Required<Pick<ToolHooks,
|
|
|
41
42
|
delivery: string;
|
|
42
43
|
target?: string | undefined;
|
|
43
44
|
truncated?: boolean | undefined;
|
|
45
|
+
timed_out?: boolean | undefined;
|
|
44
46
|
continuation?: {
|
|
45
47
|
arguments: Record<string, unknown>;
|
|
46
48
|
reason?: string | undefined;
|
|
@@ -10,6 +10,7 @@ export declare function createWebSearchTool(modelId: string, override?: WebSearc
|
|
|
10
10
|
[x: string]: unknown;
|
|
11
11
|
target?: string | undefined;
|
|
12
12
|
truncated?: boolean | undefined;
|
|
13
|
+
timed_out?: boolean | undefined;
|
|
13
14
|
continuation?: {
|
|
14
15
|
arguments: Record<string, unknown>;
|
|
15
16
|
reason?: string | undefined;
|
|
@@ -18,6 +19,7 @@ export declare function createWebSearchTool(modelId: string, override?: WebSearc
|
|
|
18
19
|
[x: string]: unknown;
|
|
19
20
|
target?: string | undefined;
|
|
20
21
|
truncated?: boolean | undefined;
|
|
22
|
+
timed_out?: boolean | undefined;
|
|
21
23
|
continuation?: {
|
|
22
24
|
arguments: Record<string, unknown>;
|
|
23
25
|
reason?: string | undefined;
|
|
@@ -68,6 +68,19 @@ var conversationFeedQuerySchema = z2.object({
|
|
|
68
68
|
}).strict();
|
|
69
69
|
var archiveConversationBodySchema = z2.object({ archived: z2.boolean(), lastSeenAt: z2.string().datetime() }).strict();
|
|
70
70
|
var archiveConversationResponseSchema = z2.object({ archived: z2.boolean() }).strict();
|
|
71
|
+
var createConversationBodySchema = z2.object({
|
|
72
|
+
idempotencyKey: z2.string().trim().min(1).max(200),
|
|
73
|
+
message: z2.string().trim().min(1).max(32e3)
|
|
74
|
+
}).strict();
|
|
75
|
+
var createConversationMessageBodySchema = z2.object({
|
|
76
|
+
idempotencyKey: z2.string().trim().min(1).max(200),
|
|
77
|
+
message: z2.string().trim().min(1).max(32e3)
|
|
78
|
+
}).strict();
|
|
79
|
+
var acceptedConversationMessageSchema = z2.object({
|
|
80
|
+
conversationId: z2.string().min(1),
|
|
81
|
+
messageId: z2.string().min(1),
|
|
82
|
+
status: z2.enum(["accepted", "duplicate"])
|
|
83
|
+
}).strict();
|
|
71
84
|
var actorIdentitySchema = z2.object({
|
|
72
85
|
email: z2.string().optional(),
|
|
73
86
|
fullName: z2.string().optional(),
|
|
@@ -105,6 +118,7 @@ var conversationSummaryReportSchema = z2.object({
|
|
|
105
118
|
auxiliaryCosts: conversationAuxiliaryCostsSchema.optional(),
|
|
106
119
|
conversationId: z2.string(),
|
|
107
120
|
isParticipant: z2.boolean(),
|
|
121
|
+
visibility: z2.enum(["private", "public"]).optional(),
|
|
108
122
|
status: conversationReportStatusSchema,
|
|
109
123
|
startedAt: z2.string(),
|
|
110
124
|
lastSeenAt: z2.string(),
|
|
@@ -242,6 +256,7 @@ var conversationReportTurnRoutedEventDataSchema = z2.object({
|
|
|
242
256
|
turnId: z2.string().min(1),
|
|
243
257
|
modelProfile: z2.string().min(1),
|
|
244
258
|
modelId: z2.string().min(1),
|
|
259
|
+
costUsd: z2.number().finite().nonnegative().optional(),
|
|
245
260
|
reasoningLevel: z2.string().min(1),
|
|
246
261
|
confidence: z2.number().min(0).max(1).optional(),
|
|
247
262
|
source: z2.enum(["configured", "inherited", "router"])
|
|
@@ -716,6 +731,9 @@ export {
|
|
|
716
731
|
conversationFeedQuerySchema,
|
|
717
732
|
archiveConversationBodySchema,
|
|
718
733
|
archiveConversationResponseSchema,
|
|
734
|
+
createConversationBodySchema,
|
|
735
|
+
createConversationMessageBodySchema,
|
|
736
|
+
acceptedConversationMessageSchema,
|
|
719
737
|
conversationAuxiliaryCostsSchema,
|
|
720
738
|
conversationSummaryReportSchema,
|
|
721
739
|
conversationReportEventDataSchema,
|
|
@@ -727,14 +745,14 @@ export {
|
|
|
727
745
|
conversationStatsReportSchema,
|
|
728
746
|
dailyConversationActivitySchema,
|
|
729
747
|
activityDays,
|
|
730
|
-
personParamsSchema,
|
|
731
|
-
actorDirectoryReportSchema,
|
|
732
|
-
actorProfileReportSchema,
|
|
733
|
-
personalSpendReportSchema,
|
|
734
748
|
locationParamsSchema,
|
|
735
749
|
locationActivityDayReportSchema,
|
|
736
750
|
locationDirectoryReportSchema,
|
|
737
751
|
locationDetailReportSchema,
|
|
752
|
+
personParamsSchema,
|
|
753
|
+
actorDirectoryReportSchema,
|
|
754
|
+
actorProfileReportSchema,
|
|
755
|
+
personalSpendReportSchema,
|
|
738
756
|
personalTokenMetadataSchema,
|
|
739
757
|
personalTokenListSchema,
|
|
740
758
|
createPersonalTokenBodySchema,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
botConfig
|
|
3
|
-
|
|
2
|
+
botConfig,
|
|
3
|
+
resolveGatewayModel
|
|
4
|
+
} from "./chunk-4GXJUYJV.js";
|
|
4
5
|
import {
|
|
5
6
|
logWarn
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EAI67NTM.js";
|
|
7
8
|
|
|
8
9
|
// src/chat/services/short-title.ts
|
|
9
10
|
var SHORT_TITLE_MAX_LENGTH = 60;
|
|
@@ -33,6 +34,7 @@ async function generateShortTitle(args) {
|
|
|
33
34
|
const result = await args.completeText({
|
|
34
35
|
modelId: botConfig.fastModelId,
|
|
35
36
|
temperature: 0,
|
|
37
|
+
promptName: `junior.${args.kind}_title`,
|
|
36
38
|
messages: [
|
|
37
39
|
{
|
|
38
40
|
role: "user",
|
|
@@ -67,9 +69,69 @@ async function resolveTaskTitle(args) {
|
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
// src/chat/services/context-budget.ts
|
|
73
|
+
var COMPACTION_TRIGGER_RATIO = 0.9;
|
|
74
|
+
var CONTEXT_INPUT_LIMIT_RATIO = 0.95;
|
|
75
|
+
var COMPACTION_TARGET_RATIO = 0.8;
|
|
76
|
+
var FALLBACK_CONTEXT_WINDOW_TOKENS = 4e5;
|
|
77
|
+
function positiveInteger(value, fallback) {
|
|
78
|
+
return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
79
|
+
}
|
|
80
|
+
function estimateTextTokens(text) {
|
|
81
|
+
return Math.ceil(text.length / 4);
|
|
82
|
+
}
|
|
83
|
+
function calculateContextCompactionTriggerTokens(model) {
|
|
84
|
+
const contextWindow = positiveInteger(
|
|
85
|
+
model.contextWindow,
|
|
86
|
+
FALLBACK_CONTEXT_WINDOW_TOKENS
|
|
87
|
+
);
|
|
88
|
+
return Math.max(1, Math.floor(contextWindow * COMPACTION_TRIGGER_RATIO));
|
|
89
|
+
}
|
|
90
|
+
function calculateContextInputLimitTokens(model) {
|
|
91
|
+
const contextWindow = positiveInteger(
|
|
92
|
+
model.contextWindow,
|
|
93
|
+
FALLBACK_CONTEXT_WINDOW_TOKENS
|
|
94
|
+
);
|
|
95
|
+
return Math.max(1, Math.floor(contextWindow * CONTEXT_INPUT_LIMIT_RATIO));
|
|
96
|
+
}
|
|
97
|
+
function calculateContextCompactionTargetTokens(triggerTokens) {
|
|
98
|
+
return Math.max(1, Math.floor(triggerTokens * COMPACTION_TARGET_RATIO));
|
|
99
|
+
}
|
|
100
|
+
function getModelContextBudget(modelId) {
|
|
101
|
+
const model = resolveGatewayModel(modelId);
|
|
102
|
+
const advertisedContextWindow = positiveInteger(
|
|
103
|
+
model.contextWindow,
|
|
104
|
+
FALLBACK_CONTEXT_WINDOW_TOKENS
|
|
105
|
+
);
|
|
106
|
+
return {
|
|
107
|
+
contextWindow: Math.min(
|
|
108
|
+
botConfig.contextWindowTokens,
|
|
109
|
+
advertisedContextWindow
|
|
110
|
+
)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function getAgentContextCompactionTriggerTokens(modelId) {
|
|
114
|
+
return calculateContextCompactionTriggerTokens(
|
|
115
|
+
getModelContextBudget(modelId)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
function getAgentContextInputLimitTokens(modelId) {
|
|
119
|
+
return calculateContextInputLimitTokens(getModelContextBudget(modelId));
|
|
120
|
+
}
|
|
121
|
+
function getConversationContextCompactionTriggerTokens() {
|
|
122
|
+
return calculateContextCompactionTriggerTokens(
|
|
123
|
+
getModelContextBudget(botConfig.fastModelId)
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
70
127
|
export {
|
|
71
128
|
SHORT_TITLE_MAX_LENGTH,
|
|
72
129
|
fallbackShortTitle,
|
|
73
130
|
generateShortTitle,
|
|
74
|
-
resolveTaskTitle
|
|
131
|
+
resolveTaskTitle,
|
|
132
|
+
estimateTextTokens,
|
|
133
|
+
calculateContextCompactionTargetTokens,
|
|
134
|
+
getAgentContextCompactionTriggerTokens,
|
|
135
|
+
getAgentContextInputLimitTokens,
|
|
136
|
+
getConversationContextCompactionTriggerTokens
|
|
75
137
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
toCanonicalInputMessage,
|
|
4
4
|
toCanonicalOutputMessage,
|
|
5
5
|
toGenAiMessagesTraceAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LE5H7LMT.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-EAI67NTM.js";
|
|
15
15
|
|
|
16
16
|
// src/chat/services/provider-error.ts
|
|
17
17
|
var ProviderError = class extends Error {
|
|
@@ -385,6 +385,7 @@ async function completeText(params) {
|
|
|
385
385
|
"gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
|
|
386
386
|
"gen_ai.request.model": params.modelId,
|
|
387
387
|
"gen_ai.output.type": "text",
|
|
388
|
+
...params.promptName ? { "gen_ai.prompt.name": params.promptName } : {},
|
|
388
389
|
"server.address": GEN_AI_SERVER_ADDRESS,
|
|
389
390
|
"server.port": GEN_AI_SERVER_PORT,
|
|
390
391
|
...hasCompactedConversationContext(params.messages) ? { "gen_ai.conversation.compacted": true } : {},
|
|
@@ -545,6 +546,7 @@ async function completeObject(params) {
|
|
|
545
546
|
"gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
|
|
546
547
|
"gen_ai.request.model": params.modelId,
|
|
547
548
|
"gen_ai.output.type": "json",
|
|
549
|
+
...params.promptName ? { "gen_ai.prompt.name": params.promptName } : {},
|
|
548
550
|
"server.address": GEN_AI_SERVER_ADDRESS,
|
|
549
551
|
"server.port": GEN_AI_SERVER_PORT,
|
|
550
552
|
"gen_ai.provider.auth_mode": credential?.mode ?? "api_key",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@sentry/junior",
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.148.0",
|
|
5
5
|
private: false,
|
|
6
6
|
publishConfig: {
|
|
7
7
|
access: "public"
|
|
@@ -73,6 +73,7 @@ var package_default = {
|
|
|
73
73
|
"@chat-adapter/state-redis": "4.29.0",
|
|
74
74
|
"@earendil-works/pi-agent-core": "catalog:",
|
|
75
75
|
"@earendil-works/pi-ai": "catalog:",
|
|
76
|
+
"@hono/zod-validator": "^0.9.0",
|
|
76
77
|
"@logtape/logtape": "^2.1.1",
|
|
77
78
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
78
79
|
"@neondatabase/serverless": "^1.1.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAndEnqueueAgentInvocation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OJCP3C3J.js";
|
|
4
4
|
import {
|
|
5
5
|
actorFromRouting,
|
|
6
6
|
toolInvocationDestination
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GDFF3BQG.js";
|
|
8
8
|
|
|
9
9
|
// src/chat/agent-invocations/spawn.ts
|
|
10
10
|
function bindSpawnAgent(request, options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_SQL_STATEMENT_TIMEOUT_MS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4GXJUYJV.js";
|
|
4
4
|
import {
|
|
5
5
|
juniorDestinations,
|
|
6
6
|
timestamptz
|
|
@@ -369,18 +369,34 @@ var juniorAgentInvocations = pgTable8(
|
|
|
369
369
|
]
|
|
370
370
|
);
|
|
371
371
|
|
|
372
|
+
// src/db/schema/location-configurations.ts
|
|
373
|
+
import { pgTable as pgTable9, primaryKey as primaryKey5, text as text9 } from "drizzle-orm/pg-core";
|
|
374
|
+
var juniorLocationConfigurations = pgTable9(
|
|
375
|
+
"junior_location_configurations",
|
|
376
|
+
{
|
|
377
|
+
locationId: text9("location_id").notNull().references(() => juniorDestinations.id, { onDelete: "cascade" }),
|
|
378
|
+
key: text9("key").notNull(),
|
|
379
|
+
value: text9("value").notNull(),
|
|
380
|
+
updatedAt: timestamptz("updated_at").notNull(),
|
|
381
|
+
updatedBy: text9("updated_by"),
|
|
382
|
+
source: text9("source"),
|
|
383
|
+
expiresAt: text9("expires_at")
|
|
384
|
+
},
|
|
385
|
+
(table) => [primaryKey5({ columns: [table.locationId, table.key] })]
|
|
386
|
+
);
|
|
387
|
+
|
|
372
388
|
// src/db/schema/event-tasks.ts
|
|
373
|
-
import { bigint, index as index7, jsonb as jsonb6, pgTable as
|
|
374
|
-
var juniorEventTasks =
|
|
389
|
+
import { bigint, index as index7, jsonb as jsonb6, pgTable as pgTable10, text as text10 } from "drizzle-orm/pg-core";
|
|
390
|
+
var juniorEventTasks = pgTable10(
|
|
375
391
|
"junior_event_tasks",
|
|
376
392
|
{
|
|
377
|
-
id:
|
|
378
|
-
teamId:
|
|
379
|
-
namespace:
|
|
380
|
-
identifier:
|
|
393
|
+
id: text10("id").primaryKey(),
|
|
394
|
+
teamId: text10("team_id").notNull(),
|
|
395
|
+
namespace: text10("namespace").notNull(),
|
|
396
|
+
identifier: text10("identifier").notNull(),
|
|
381
397
|
createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
382
398
|
/** Short display title generated from the task instruction. */
|
|
383
|
-
title:
|
|
399
|
+
title: text10("title"),
|
|
384
400
|
task: jsonb6("task_json").$type().notNull()
|
|
385
401
|
},
|
|
386
402
|
(table) => [
|
|
@@ -399,18 +415,18 @@ var juniorEventTasks = pgTable9(
|
|
|
399
415
|
);
|
|
400
416
|
|
|
401
417
|
// src/db/schema/stats.ts
|
|
402
|
-
import { date, integer as integer3, pgTable as
|
|
403
|
-
var juniorStats =
|
|
418
|
+
import { date, integer as integer3, pgTable as pgTable11, primaryKey as primaryKey6, text as text11 } from "drizzle-orm/pg-core";
|
|
419
|
+
var juniorStats = pgTable11(
|
|
404
420
|
"junior_stats",
|
|
405
421
|
{
|
|
406
422
|
date: date("date", { mode: "string" }).notNull(),
|
|
407
|
-
namespace:
|
|
408
|
-
metric:
|
|
409
|
-
name:
|
|
423
|
+
namespace: text11("namespace").notNull(),
|
|
424
|
+
metric: text11("metric").notNull(),
|
|
425
|
+
name: text11("name").notNull(),
|
|
410
426
|
count: integer3("count").notNull().default(0)
|
|
411
427
|
},
|
|
412
428
|
(table) => [
|
|
413
|
-
|
|
429
|
+
primaryKey6({
|
|
414
430
|
name: "junior_stats_date_namespace_metric_name_pk",
|
|
415
431
|
columns: [table.date, table.namespace, table.metric, table.name]
|
|
416
432
|
})
|
|
@@ -424,20 +440,20 @@ import {
|
|
|
424
440
|
check,
|
|
425
441
|
foreignKey as foreignKey3,
|
|
426
442
|
index as index8,
|
|
427
|
-
pgTable as
|
|
428
|
-
primaryKey as
|
|
429
|
-
text as
|
|
443
|
+
pgTable as pgTable12,
|
|
444
|
+
primaryKey as primaryKey7,
|
|
445
|
+
text as text12
|
|
430
446
|
} from "drizzle-orm/pg-core";
|
|
431
|
-
var juniorTaskExecutions =
|
|
447
|
+
var juniorTaskExecutions = pgTable12(
|
|
432
448
|
"junior_task_executions",
|
|
433
449
|
{
|
|
434
|
-
executionId:
|
|
435
|
-
kind:
|
|
436
|
-
namespace:
|
|
437
|
-
taskId:
|
|
438
|
-
conversationId:
|
|
450
|
+
executionId: text12("execution_id").notNull(),
|
|
451
|
+
kind: text12("kind").notNull(),
|
|
452
|
+
namespace: text12("namespace").notNull(),
|
|
453
|
+
taskId: text12("task_id").notNull(),
|
|
454
|
+
conversationId: text12("conversation_id"),
|
|
439
455
|
executedAtMs: bigint2("executed_at_ms", { mode: "number" }).notNull(),
|
|
440
|
-
status:
|
|
456
|
+
status: text12("status").$type().notNull()
|
|
441
457
|
},
|
|
442
458
|
(table) => [
|
|
443
459
|
check(
|
|
@@ -448,7 +464,7 @@ var juniorTaskExecutions = pgTable11(
|
|
|
448
464
|
"junior_task_executions_status_check",
|
|
449
465
|
sql4`${table.status} in ('blocked', 'completed', 'failed')`
|
|
450
466
|
),
|
|
451
|
-
|
|
467
|
+
primaryKey7({
|
|
452
468
|
name: "junior_task_executions_kind_namespace_execution_id_pk",
|
|
453
469
|
columns: [table.kind, table.namespace, table.executionId]
|
|
454
470
|
}),
|
|
@@ -476,21 +492,21 @@ var juniorTaskExecutions = pgTable11(
|
|
|
476
492
|
|
|
477
493
|
// src/db/schema/scheduled-tasks.ts
|
|
478
494
|
import { sql as sql5 } from "drizzle-orm";
|
|
479
|
-
import { bigint as bigint3, index as index9, jsonb as jsonb7, pgTable as
|
|
480
|
-
var juniorSchedulerTasks =
|
|
495
|
+
import { bigint as bigint3, index as index9, jsonb as jsonb7, pgTable as pgTable13, text as text13 } from "drizzle-orm/pg-core";
|
|
496
|
+
var juniorSchedulerTasks = pgTable13(
|
|
481
497
|
"junior_scheduler_tasks",
|
|
482
498
|
{
|
|
483
|
-
id:
|
|
484
|
-
teamId:
|
|
499
|
+
id: text13("id").primaryKey(),
|
|
500
|
+
teamId: text13("team_id").notNull(),
|
|
485
501
|
// TODO(v0.128.0): Remove after v0.127.x runtimes no longer write this column.
|
|
486
|
-
creatorSlackUserId:
|
|
487
|
-
creatorIdentityId:
|
|
488
|
-
status:
|
|
502
|
+
creatorSlackUserId: text13("creator_slack_user_id"),
|
|
503
|
+
creatorIdentityId: text13("creator_identity_id"),
|
|
504
|
+
status: text13("status").notNull(),
|
|
489
505
|
nextRunAtMs: bigint3("next_run_at_ms", { mode: "number" }),
|
|
490
506
|
runNowAtMs: bigint3("run_now_at_ms", { mode: "number" }),
|
|
491
507
|
createdAtMs: bigint3("created_at_ms", { mode: "number" }).notNull(),
|
|
492
508
|
/** Short display title generated from the task instruction. */
|
|
493
|
-
title:
|
|
509
|
+
title: text13("title"),
|
|
494
510
|
record: jsonb7("record").$type().notNull()
|
|
495
511
|
},
|
|
496
512
|
(table) => [
|
|
@@ -508,12 +524,12 @@ var juniorSchedulerTasks = pgTable12(
|
|
|
508
524
|
)
|
|
509
525
|
]
|
|
510
526
|
);
|
|
511
|
-
var juniorSchedulerRuns =
|
|
527
|
+
var juniorSchedulerRuns = pgTable13(
|
|
512
528
|
"junior_scheduler_runs",
|
|
513
529
|
{
|
|
514
|
-
id:
|
|
515
|
-
taskId:
|
|
516
|
-
status:
|
|
530
|
+
id: text13("id").primaryKey(),
|
|
531
|
+
taskId: text13("task_id").notNull(),
|
|
532
|
+
status: text13("status").notNull(),
|
|
517
533
|
scheduledForMs: bigint3("scheduled_for_ms", { mode: "number" }).notNull(),
|
|
518
534
|
record: jsonb7("record").$type().notNull()
|
|
519
535
|
},
|
|
@@ -539,6 +555,7 @@ var juniorSqlSchema = {
|
|
|
539
555
|
juniorConversationEvents,
|
|
540
556
|
juniorConversationBindings,
|
|
541
557
|
juniorConversations,
|
|
558
|
+
juniorLocationConfigurations,
|
|
542
559
|
juniorDestinations,
|
|
543
560
|
juniorEventTasks,
|
|
544
561
|
juniorIdentities,
|
|
@@ -809,6 +826,7 @@ export {
|
|
|
809
826
|
AGENT_INVOCATION_MAILBOX_STATUSES,
|
|
810
827
|
juniorAgentBindings,
|
|
811
828
|
juniorAgentInvocations,
|
|
829
|
+
juniorLocationConfigurations,
|
|
812
830
|
juniorEventTasks,
|
|
813
831
|
juniorStats,
|
|
814
832
|
juniorTaskExecutions,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTurnRequestDeadline
|
|
3
|
+
} from "./chunk-DUY5CDAM.js";
|
|
1
4
|
import {
|
|
2
5
|
CONVERSATION_WORK_CHECK_IN_INTERVAL_MS,
|
|
3
6
|
CONVERSATION_WORK_MAX_RETRIES,
|
|
@@ -18,37 +21,37 @@ import {
|
|
|
18
21
|
releaseConversationWork,
|
|
19
22
|
requestAnotherSlice,
|
|
20
23
|
startConversationWork
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-HLPLT3NY.js";
|
|
22
25
|
import {
|
|
23
26
|
ConversationQueueMessageRejectedError
|
|
24
27
|
} from "./chunk-JAL3CH4G.js";
|
|
25
28
|
import {
|
|
26
29
|
getChatConfig,
|
|
27
30
|
isProviderRetryError
|
|
28
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-4GXJUYJV.js";
|
|
29
32
|
import {
|
|
30
33
|
logException,
|
|
31
34
|
logInfo,
|
|
32
35
|
logWarn,
|
|
33
36
|
withLogContext
|
|
34
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-EAI67NTM.js";
|
|
35
38
|
|
|
36
39
|
// src/chat/task-execution/worker.ts
|
|
37
40
|
var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|
|
38
41
|
function now(options) {
|
|
39
42
|
return options.nowMs?.() ?? Date.now();
|
|
40
43
|
}
|
|
41
|
-
function
|
|
44
|
+
function selectContiguousTurnBatch(messages) {
|
|
42
45
|
const first = messages[0];
|
|
43
46
|
if (!first) {
|
|
44
47
|
return [];
|
|
45
48
|
}
|
|
46
|
-
const
|
|
47
|
-
(message) => message.input.authorId !== first.input.authorId
|
|
49
|
+
const nextTurnIndex = messages.findIndex(
|
|
50
|
+
(message) => message.input.authorId !== first.input.authorId || message.publishExternally !== first.publishExternally
|
|
48
51
|
);
|
|
49
52
|
return messages.slice(
|
|
50
53
|
0,
|
|
51
|
-
|
|
54
|
+
nextTurnIndex === -1 ? messages.length : nextTurnIndex
|
|
52
55
|
);
|
|
53
56
|
}
|
|
54
57
|
function selectAttemptMessages(work) {
|
|
@@ -57,9 +60,9 @@ function selectAttemptMessages(work) {
|
|
|
57
60
|
(message) => message.delivery === "interrupt"
|
|
58
61
|
);
|
|
59
62
|
if (interrupts.length > 0) {
|
|
60
|
-
return
|
|
63
|
+
return selectContiguousTurnBatch(interrupts);
|
|
61
64
|
}
|
|
62
|
-
return work.execution.status === "paused" ? [] :
|
|
65
|
+
return work.execution.status === "paused" ? [] : selectContiguousTurnBatch(messages);
|
|
63
66
|
}
|
|
64
67
|
function nudgeIdempotencyKey(reason, conversationId, nowMs) {
|
|
65
68
|
return `${reason}:${conversationId}:${nowMs}`;
|
|
@@ -283,7 +286,14 @@ async function processConversationWorkInContext(message, options) {
|
|
|
283
286
|
nowMs: now(options),
|
|
284
287
|
state: options.state
|
|
285
288
|
});
|
|
286
|
-
const
|
|
289
|
+
const requestDeadlineAtMs = getTurnRequestDeadline()?.deadlineAtMs;
|
|
290
|
+
const shouldYield = () => (
|
|
291
|
+
// Lease ownership is no longer confirmed, so this worker must stop.
|
|
292
|
+
leaseLost || // The worker soft limit reserves time to persist state and release the lease.
|
|
293
|
+
now(options) >= softYieldDeadlineMs || // Nested work can inherit an older host request deadline. Stop after that
|
|
294
|
+
// absolute deadline, even if this worker acquired its lease later.
|
|
295
|
+
requestDeadlineAtMs !== void 0 && Date.now() >= requestDeadlineAtMs
|
|
296
|
+
);
|
|
287
297
|
const checkIn = async () => {
|
|
288
298
|
const checkedIn = await checkInConversationWork({
|
|
289
299
|
conversationId,
|
|
@@ -377,6 +387,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
377
387
|
attemptMessageIds = attemptMessages.map(
|
|
378
388
|
(message2) => message2.inboundMessageId
|
|
379
389
|
);
|
|
390
|
+
const publishExternally = attemptMessages[0]?.publishExternally ?? false;
|
|
380
391
|
attemptSelectedMessageIds = new Set(attemptMessageIds);
|
|
381
392
|
const ack = async () => {
|
|
382
393
|
const acknowledged = await ackMessages({
|
|
@@ -407,6 +418,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
407
418
|
},
|
|
408
419
|
conversationId,
|
|
409
420
|
destination,
|
|
421
|
+
publishExternally,
|
|
410
422
|
shouldYield,
|
|
411
423
|
checkIn
|
|
412
424
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
3
|
+
getChatConfig
|
|
4
|
+
} from "./chunk-4GXJUYJV.js";
|
|
5
|
+
|
|
6
|
+
// src/chat/runtime/request-deadline.ts
|
|
7
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
8
|
+
var requestDeadlineStorage = new AsyncLocalStorage();
|
|
9
|
+
function createTurnRequestDeadline(startedAtMs) {
|
|
10
|
+
const requestBudgetMs = Math.max(
|
|
11
|
+
1,
|
|
12
|
+
getChatConfig().functionMaxDurationSeconds * 1e3 - FUNCTION_TIMEOUT_BUFFER_SECONDS * 1e3
|
|
13
|
+
);
|
|
14
|
+
return {
|
|
15
|
+
startedAtMs,
|
|
16
|
+
deadlineAtMs: startedAtMs + requestBudgetMs
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function getTurnRequestDeadline() {
|
|
20
|
+
return requestDeadlineStorage.getStore();
|
|
21
|
+
}
|
|
22
|
+
function runWithTurnRequestDeadline(callback, startedAtMs = Date.now()) {
|
|
23
|
+
const existingDeadline = requestDeadlineStorage.getStore();
|
|
24
|
+
if (existingDeadline) {
|
|
25
|
+
return callback();
|
|
26
|
+
}
|
|
27
|
+
return requestDeadlineStorage.run(
|
|
28
|
+
createTurnRequestDeadline(startedAtMs),
|
|
29
|
+
callback
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
getTurnRequestDeadline,
|
|
35
|
+
runWithTurnRequestDeadline
|
|
36
|
+
};
|