@sentry/junior 0.154.0 → 0.156.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-VEHV2QUA.js → agent-hooks-CCAR46PQ.js} +11 -12
- package/dist/api/conversations/list.d.ts +5 -3
- package/dist/api/conversations/membership.d.ts +16 -0
- package/dist/api/locations/detail.d.ts +2 -0
- package/dist/api/schema/conversation.d.ts +22 -4
- package/dist/api/schema/location.d.ts +2 -0
- package/dist/api/schema/person.d.ts +2 -0
- package/dist/api/schema.js +1 -1
- package/dist/api.js +331 -188
- package/dist/app.js +154 -51
- package/dist/catalog-runtime-3SNKYCBG.js +16 -0
- package/dist/chat/agent/types.d.ts +2 -0
- package/dist/chat/attachments/storage.d.ts +12 -0
- package/dist/chat/attachments/store.d.ts +52 -0
- package/dist/chat/attachments/vercel.d.ts +3 -0
- package/dist/chat/conversations/retention.d.ts +4 -0
- package/dist/chat/conversations/sql/event-actor.d.ts +14 -0
- package/dist/chat/conversations/sql/event-lock.d.ts +1 -1
- package/dist/chat/conversations/sql/participants.d.ts +17 -0
- package/dist/chat/ingress/bot-mention.d.ts +13 -0
- package/dist/chat/plugins/unfinished-work.d.ts +8 -0
- package/dist/chat/runtime/agent-runner.d.ts +4 -0
- package/dist/chat/runtime/slack-resume.d.ts +1 -1
- package/dist/chat/services/conversation-memory.d.ts +1 -1
- package/dist/chat/slack/tools/send-files.d.ts +17 -11
- package/dist/chat/state/conversation.d.ts +3 -1
- package/dist/chat/tools/types.d.ts +2 -0
- package/dist/{chunk-XYMCZGH6.js → chunk-3FFUC32L.js} +8 -10
- package/dist/{chunk-4U4MNYGP.js → chunk-3L2PMOSR.js} +6 -8
- package/dist/{chunk-PTJ75ZWR.js → chunk-4ZZDTHFC.js} +94 -9
- package/dist/{chunk-DAJZZFU7.js → chunk-53W3LZEW.js} +386 -93
- package/dist/{chunk-F7QUK3YP.js → chunk-6CINHXIL.js} +5 -5
- package/dist/{chunk-6VWMX7NS.js → chunk-6JUU7J2B.js} +4 -4
- package/dist/{chunk-HUO3UTAQ.js → chunk-7MA4HV4W.js} +1 -1
- package/dist/{chunk-O4AQDOKA.js → chunk-7RAETIYO.js} +7 -7
- package/dist/{chunk-4R2XCKUH.js → chunk-A6WPDFHQ.js} +1 -1
- package/dist/{chunk-CZD6M57V.js → chunk-AIJRG227.js} +191 -126
- package/dist/{chunk-RUIXF3YQ.js → chunk-BDUENQD3.js} +1 -1
- package/dist/{chunk-NUG3VYHL.js → chunk-CK2H7CFO.js} +2 -2
- package/dist/{chunk-HOGJ6TBT.js → chunk-CN2XSVKF.js} +6 -6
- package/dist/{chunk-3567VGCN.js → chunk-EDJ64P2P.js} +1 -1
- package/dist/{chunk-6PJXR4BC.js → chunk-GKC43TLS.js} +2 -2
- package/dist/{chunk-A6LWN4K6.js → chunk-GSBPZHLQ.js} +11 -11
- package/dist/{chunk-Y654CTW2.js → chunk-IIO5PFZX.js} +366 -138
- package/dist/{chunk-F2Q3ZHW2.js → chunk-IZEBHYI4.js} +1 -1
- package/dist/{chunk-QGR6QTC4.js → chunk-JUJR6WTL.js} +4 -4
- package/dist/{chunk-ZQT4RHUO.js → chunk-KBGMYLSV.js} +4 -1
- package/dist/{chunk-DK2FSQHS.js → chunk-KCA5MKHU.js} +5 -5
- package/dist/{chunk-NNN2WYAD.js → chunk-MC57E5U5.js} +1 -1
- package/dist/{chunk-6AF5GOZA.js → chunk-MJE7XKWP.js} +1 -1
- package/dist/{chunk-7CPN5JTA.js → chunk-NTNU6T2D.js} +3 -3
- package/dist/{chunk-NG4IAOVD.js → chunk-OGZPRMZA.js} +1 -1
- package/dist/{chunk-UCH55IGZ.js → chunk-OMQJB7YN.js} +28 -37
- package/dist/{chunk-2XNVS6RC.js → chunk-PMFGVLDU.js} +12 -11
- package/dist/{chunk-65IAU2L2.js → chunk-SE3D225X.js} +1 -1
- package/dist/{chunk-CCAU73CE.js → chunk-SRJA6QLM.js} +2 -2
- package/dist/{chunk-7RFWIHPM.js → chunk-TN4LVILT.js} +5 -5
- package/dist/{chunk-3ZR2R5EQ.js → chunk-TNXGMFWV.js} +1 -1
- package/dist/{chunk-HZF5P5UN.js → chunk-V7YE4WCP.js} +58 -7
- package/dist/{chunk-MSOZLASC.js → chunk-WD7SEUZO.js} +2 -2
- package/dist/{chunk-UG5UCHHJ.js → chunk-X5NZQH5U.js} +4 -2
- package/dist/{chunk-3HX67UPN.js → chunk-X7W45B5G.js} +1 -1
- package/dist/{chunk-FVY7AJ46.js → chunk-ZNWRYNCA.js} +7 -7
- package/dist/cli/chat.js +36 -36
- package/dist/cli/check.js +8 -9
- package/dist/cli/init.js +41 -7
- package/dist/cli/plugins.js +15 -16
- package/dist/cli/snapshot-create.js +11 -12
- package/dist/cli/upgrade.js +9 -10
- package/dist/db/schema/attachments.d.ts +178 -0
- package/dist/db/schema/conversation-events.d.ts +20 -0
- package/dist/db/schema/conversation-participants.d.ts +63 -0
- package/dist/db/schema.d.ts +255 -1
- package/dist/{db-SOJJLMJK.js → db-TYUUKGJX.js} +8 -8
- package/dist/handlers/retention.d.ts +4 -1
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-GCJROMVO.js → oauth-callback-server-AWVDKPR5.js} +26 -26
- package/dist/{runner-SY6KDQCN.js → runner-JUQXMACC.js} +15 -16
- package/dist/{sandbox-egress-signals-EKPAVWQL.js → sandbox-egress-signals-U3ZX7C5W.js} +3 -4
- package/dist/{skills-XJ2LJ2ML.js → skills-4GZTZX4V.js} +8 -9
- package/dist/spawn-32SSRWU4.js +37 -0
- package/dist/{validation-XQWY6QRY.js → validation-DRLNJRND.js} +8 -9
- package/dist/version.js +1 -1
- package/dist/{work-FFT5JAOU.js → work-TGIXRRJY.js} +20 -21
- package/dist/worker-IFXZOYED.js +24 -0
- package/migrations/0026_conversation_event_actor_and_participants.sql +140 -0
- package/migrations/0027_attachment_storage.sql +16 -0
- package/migrations/meta/0026_snapshot.json +2424 -0
- package/migrations/meta/0027_snapshot.json +2554 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +10 -7
- package/dist/catalog-runtime-AK5MY63F.js +0 -17
- package/dist/chunk-F3B2YJ76.js +0 -57
- package/dist/spawn-QFCQREEP.js +0 -38
- package/dist/worker-JAITK72F.js +0 -25
|
@@ -2,13 +2,17 @@ import type { StreamFn } from "@earendil-works/pi-agent-core";
|
|
|
2
2
|
import { type AgentRun, type SpawnAgent } from "@/chat/agent/types";
|
|
3
3
|
import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
|
|
4
4
|
import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
|
|
5
|
+
import type { AttachmentStorage } from "@/chat/attachments/storage";
|
|
5
6
|
/** Run one agent-run slice behind runtime-owned orchestration boundaries. */
|
|
6
7
|
export interface AgentRunner {
|
|
7
8
|
run(run: AgentRun): Promise<AgentRunOutcome>;
|
|
8
9
|
}
|
|
9
10
|
/** Compose the agent executor with stable host dependencies. */
|
|
10
11
|
export declare function createAgentRunner(execute: (run: AgentRun, streamFn?: StreamFn) => Promise<AgentRunOutcome>, options?: {
|
|
12
|
+
attachmentStorage?: AttachmentStorage;
|
|
11
13
|
bindSpawnAgent?: (run: AgentRun) => SpawnAgent | undefined;
|
|
12
14
|
streamFn?: StreamFn;
|
|
13
15
|
tracePropagation?: SandboxEgressTracePropagationConfig;
|
|
14
16
|
}): AgentRunner;
|
|
17
|
+
/** Abort a timed-out agent run and wait briefly for its work to settle. */
|
|
18
|
+
export declare function runAgentWithTimeout(agentRunner: AgentRunner, run: AgentRun, timeoutMs: number | undefined): Promise<AgentRunOutcome>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentRun } from "@/chat/agent/types";
|
|
2
2
|
import type { AgentRunResult } from "@/chat/services/turn-result";
|
|
3
|
-
import type
|
|
3
|
+
import { type AgentRunner } from "@/chat/runtime/agent-runner";
|
|
4
4
|
import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
|
|
5
5
|
import { type AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
|
|
6
6
|
import type { SlackMessageTs } from "@/chat/slack/timestamp";
|
|
@@ -22,7 +22,7 @@ export declare function upsertConversationMessage(conversation: ThreadConversati
|
|
|
22
22
|
export declare function recordDeliveredAssistantMessage(args: {
|
|
23
23
|
conversation: ThreadConversationState;
|
|
24
24
|
sessionId: string;
|
|
25
|
-
source?: "web";
|
|
25
|
+
source?: "slack" | "web";
|
|
26
26
|
text: string;
|
|
27
27
|
userMessageId?: string;
|
|
28
28
|
}): string;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { AttachmentStorage } from "@/chat/attachments/storage";
|
|
2
|
+
import type { JuniorSqlDatabase } from "@/db/db";
|
|
1
3
|
import type { SlackToolContext } from "@/chat/slack/tool-support/context";
|
|
2
4
|
import { type SandboxFileMaterializationInput, type SandboxFileUpload } from "@/chat/tools/sandbox/file-uploads";
|
|
3
5
|
import type { ToolState } from "@/chat/tools/types";
|
|
4
6
|
/** Convert a model-supplied sandbox file path into bytes safe for Slack upload. */
|
|
5
7
|
export type MaterializeFile = (input: SandboxFileMaterializationInput) => Promise<SandboxFileUpload>;
|
|
6
8
|
/** Create the Slack side-effect tool for active-conversation file messages. */
|
|
7
|
-
export declare function createSendFilesTool(context: SlackToolContext, state: ToolState, materializeFile: MaterializeFile
|
|
9
|
+
export declare function createSendFilesTool(context: SlackToolContext, state: ToolState, materializeFile: MaterializeFile, attachments?: {
|
|
10
|
+
conversationId: string;
|
|
11
|
+
db: JuniorSqlDatabase;
|
|
12
|
+
storage: AttachmentStorage;
|
|
13
|
+
}): Omit<import("../../tools/definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
8
14
|
inputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
9
15
|
outputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
10
16
|
prepareArguments(args: unknown): {
|
|
@@ -17,10 +23,11 @@ export declare function createSendFilesTool(context: SlackToolContext, state: To
|
|
|
17
23
|
};
|
|
18
24
|
execute?: ((input: unknown, options: import("../../tools/definition").ToolExecuteOptions) => {
|
|
19
25
|
[x: string]: unknown;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
attachment_refs: {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}[];
|
|
30
|
+
target?: string | undefined;
|
|
24
31
|
truncated?: boolean | undefined;
|
|
25
32
|
timed_out?: boolean | undefined;
|
|
26
33
|
continuation?: {
|
|
@@ -28,13 +35,13 @@ export declare function createSendFilesTool(context: SlackToolContext, state: To
|
|
|
28
35
|
reason?: string | undefined;
|
|
29
36
|
} | undefined;
|
|
30
37
|
deduplicated?: boolean | undefined;
|
|
31
|
-
file_ids?: string[] | undefined;
|
|
32
38
|
} | Promise<{
|
|
33
39
|
[x: string]: unknown;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
attachment_refs: {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}[];
|
|
44
|
+
target?: string | undefined;
|
|
38
45
|
truncated?: boolean | undefined;
|
|
39
46
|
timed_out?: boolean | undefined;
|
|
40
47
|
continuation?: {
|
|
@@ -42,6 +49,5 @@ export declare function createSendFilesTool(context: SlackToolContext, state: To
|
|
|
42
49
|
reason?: string | undefined;
|
|
43
50
|
} | undefined;
|
|
44
51
|
deduplicated?: boolean | undefined;
|
|
45
|
-
file_ids?: string[] | undefined;
|
|
46
52
|
}>) | undefined;
|
|
47
53
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type ConversationRole = "assistant" | "system" | "user";
|
|
2
2
|
export interface ConversationAuthor {
|
|
3
|
+
email?: string;
|
|
3
4
|
fullName?: string;
|
|
4
5
|
isBot?: boolean;
|
|
5
6
|
userId?: string;
|
|
@@ -7,7 +8,8 @@ export interface ConversationAuthor {
|
|
|
7
8
|
}
|
|
8
9
|
export interface ConversationMessageMeta {
|
|
9
10
|
attachmentCount?: number;
|
|
10
|
-
|
|
11
|
+
/** Known message provenance. Omit when unknown; never invent a default. */
|
|
12
|
+
source?: "slack" | "web";
|
|
11
13
|
eventType?: string;
|
|
12
14
|
explicitMention?: boolean;
|
|
13
15
|
imageAttachmentCount?: number;
|
|
@@ -10,6 +10,7 @@ import type { SlackActionToken } from "@/chat/slack/action-token";
|
|
|
10
10
|
import type { ModelProfile } from "@/chat/model-profile";
|
|
11
11
|
import type { GeneratedArtifactFileRef } from "@/chat/tools/sandbox/file-uploads";
|
|
12
12
|
import type { SpawnAgent } from "@/chat/agent/types";
|
|
13
|
+
import type { AttachmentStorage } from "@/chat/attachments/storage";
|
|
13
14
|
interface HandoffControl {
|
|
14
15
|
/** Non-empty catalog of configured targets. */
|
|
15
16
|
profiles: readonly [ModelProfile, ...ModelProfile[]];
|
|
@@ -52,6 +53,7 @@ export interface ToolHooks {
|
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
interface BaseToolRuntimeContext {
|
|
56
|
+
attachmentStorage?: AttachmentStorage;
|
|
55
57
|
handoff?: HandoffControl;
|
|
56
58
|
spawnAgent?: SpawnAgent;
|
|
57
59
|
/**
|
|
@@ -4,45 +4,43 @@ import {
|
|
|
4
4
|
isConversationScopedChannel,
|
|
5
5
|
isDmChannel,
|
|
6
6
|
normalizeSlackConversationId
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NTNU6T2D.js";
|
|
8
8
|
import {
|
|
9
9
|
getConversationEventStore,
|
|
10
10
|
getDb
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IIO5PFZX.js";
|
|
12
12
|
import {
|
|
13
13
|
juniorConversationAnnotations,
|
|
14
14
|
juniorConversationEvents,
|
|
15
15
|
juniorIdentities,
|
|
16
16
|
juniorUsers
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-AIJRG227.js";
|
|
18
18
|
import {
|
|
19
19
|
SANDBOX_WORKSPACE_ROOT
|
|
20
20
|
} from "./chunk-EM225ITJ.js";
|
|
21
21
|
import {
|
|
22
22
|
getStateAdapter
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MC57E5U5.js";
|
|
24
24
|
import {
|
|
25
25
|
botConfig,
|
|
26
26
|
completeObject,
|
|
27
27
|
embedTexts,
|
|
28
28
|
getSlackBotToken,
|
|
29
29
|
standardModelId
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-GKC43TLS.js";
|
|
31
31
|
import {
|
|
32
32
|
isActorUserId,
|
|
33
|
-
parseActorUserId
|
|
34
|
-
} from "./chunk-HZF5P5UN.js";
|
|
35
|
-
import {
|
|
33
|
+
parseActorUserId,
|
|
36
34
|
parseSlackChannelReferenceId,
|
|
37
35
|
parseSlackMessageTs,
|
|
38
36
|
parseSlackTeamId
|
|
39
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-V7YE4WCP.js";
|
|
40
38
|
import {
|
|
41
39
|
logException,
|
|
42
40
|
logInfo,
|
|
43
41
|
logWarn,
|
|
44
42
|
normalizeIdentityEmail
|
|
45
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-X7W45B5G.js";
|
|
46
44
|
|
|
47
45
|
// src/chat/plugins/agent-hooks.ts
|
|
48
46
|
import {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
instructionProvenanceFor,
|
|
14
14
|
sanitizePostgresJson,
|
|
15
15
|
withConversationEventLock
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IIO5PFZX.js";
|
|
17
17
|
import {
|
|
18
18
|
SANDBOX_WORKSPACE_ROOT,
|
|
19
19
|
sleep
|
|
@@ -23,26 +23,24 @@ import {
|
|
|
23
23
|
fenceLock,
|
|
24
24
|
getStateAdapter,
|
|
25
25
|
withLock
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MC57E5U5.js";
|
|
27
27
|
import {
|
|
28
28
|
botConfig,
|
|
29
29
|
completeText,
|
|
30
30
|
escapeXml,
|
|
31
31
|
resolveGatewayModel,
|
|
32
32
|
unwrapCurrentInstruction
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-GKC43TLS.js";
|
|
34
34
|
import {
|
|
35
|
+
parseSlackMessageTs,
|
|
35
36
|
toStoredSlackActor
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import {
|
|
38
|
-
parseSlackMessageTs
|
|
39
|
-
} from "./chunk-F3B2YJ76.js";
|
|
37
|
+
} from "./chunk-V7YE4WCP.js";
|
|
40
38
|
import {
|
|
41
39
|
getActiveTraceId,
|
|
42
40
|
logException,
|
|
43
41
|
logWarn,
|
|
44
42
|
setSpanAttributes
|
|
45
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-X7W45B5G.js";
|
|
46
44
|
|
|
47
45
|
// src/chat/turn-context-tag.ts
|
|
48
46
|
var TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
@@ -1,34 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAgentRunFeatureDisabled
|
|
3
|
+
} from "./chunk-RF6J3DIO.js";
|
|
1
4
|
import {
|
|
2
5
|
resolveBaseUrl
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7RAETIYO.js";
|
|
7
|
+
import {
|
|
8
|
+
isExperimentalFeatureEnabled
|
|
9
|
+
} from "./chunk-5IDFPCON.js";
|
|
4
10
|
import {
|
|
5
11
|
createPluginLogger,
|
|
6
12
|
getPlugins
|
|
7
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-3FFUC32L.js";
|
|
8
14
|
import {
|
|
9
15
|
getSlackClient,
|
|
10
16
|
withSlackRetries
|
|
11
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NTNU6T2D.js";
|
|
12
18
|
import {
|
|
13
19
|
getDb,
|
|
14
20
|
parseDestination
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-IIO5PFZX.js";
|
|
16
22
|
import {
|
|
17
23
|
sleep
|
|
18
24
|
} from "./chunk-EM225ITJ.js";
|
|
19
25
|
import {
|
|
20
26
|
acquireActiveLock,
|
|
21
27
|
getStateAdapter
|
|
22
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-MC57E5U5.js";
|
|
23
29
|
import {
|
|
24
30
|
pluginCatalogRuntime
|
|
25
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-EDJ64P2P.js";
|
|
26
32
|
import {
|
|
27
33
|
fetchWithBoundedOAuthErrorBodies
|
|
28
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-WD7SEUZO.js";
|
|
29
35
|
import {
|
|
30
36
|
isRecord
|
|
31
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-X7W45B5G.js";
|
|
32
38
|
|
|
33
39
|
// src/chat/capabilities/router.ts
|
|
34
40
|
var ProviderCredentialRouter = class {
|
|
@@ -140,6 +146,83 @@ async function issueProviderCredentialLease(input) {
|
|
|
140
146
|
return await getSandboxEgressRouter().issue(input);
|
|
141
147
|
}
|
|
142
148
|
|
|
149
|
+
// src/chat/runtime/agent-runner.ts
|
|
150
|
+
var AGENT_ABORT_SETTLE_GRACE_MS = 5e3;
|
|
151
|
+
function createAgentRunner(execute, options) {
|
|
152
|
+
const attachmentStorage = options?.attachmentStorage;
|
|
153
|
+
const streamFn = options?.streamFn;
|
|
154
|
+
const tracePropagation = options?.tracePropagation;
|
|
155
|
+
const bindSpawnAgent = options?.bindSpawnAgent;
|
|
156
|
+
const canBindSpawn = Boolean(bindSpawnAgent) && isExperimentalFeatureEnabled("subagents");
|
|
157
|
+
return {
|
|
158
|
+
run: async (run) => {
|
|
159
|
+
const spawnAgent = bindSpawnAgent && canBindSpawn && !isAgentRunFeatureDisabled(run.disabledFeatures, "subagents") ? bindSpawnAgent(run) : void 0;
|
|
160
|
+
const nextRun = {
|
|
161
|
+
...run,
|
|
162
|
+
environment: {
|
|
163
|
+
...run.environment,
|
|
164
|
+
attachmentStorage: run.environment?.attachmentStorage ?? attachmentStorage,
|
|
165
|
+
sandboxTracePropagation: run.environment?.sandboxTracePropagation ?? tracePropagation
|
|
166
|
+
},
|
|
167
|
+
...spawnAgent ? {
|
|
168
|
+
durability: {
|
|
169
|
+
...run.durability,
|
|
170
|
+
spawnAgent
|
|
171
|
+
}
|
|
172
|
+
} : {}
|
|
173
|
+
};
|
|
174
|
+
return await execute(nextRun, streamFn);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
async function waitForAgentSettlement(runPromise) {
|
|
179
|
+
let timeoutId;
|
|
180
|
+
const settleGrace = new Promise((resolve) => {
|
|
181
|
+
timeoutId = setTimeout(resolve, AGENT_ABORT_SETTLE_GRACE_MS);
|
|
182
|
+
timeoutId.unref?.();
|
|
183
|
+
});
|
|
184
|
+
await Promise.race([
|
|
185
|
+
runPromise.then(
|
|
186
|
+
() => void 0,
|
|
187
|
+
() => void 0
|
|
188
|
+
),
|
|
189
|
+
settleGrace
|
|
190
|
+
]);
|
|
191
|
+
if (timeoutId) {
|
|
192
|
+
clearTimeout(timeoutId);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function runAgentWithTimeout(agentRunner, run, timeoutMs) {
|
|
196
|
+
if (typeof timeoutMs !== "number") {
|
|
197
|
+
return await agentRunner.run(run);
|
|
198
|
+
}
|
|
199
|
+
const timeoutError = new Error(
|
|
200
|
+
`executeAgentRun timed out after ${timeoutMs}ms`
|
|
201
|
+
);
|
|
202
|
+
const abortController = new AbortController();
|
|
203
|
+
const signal = run.signal ? AbortSignal.any([run.signal, abortController.signal]) : abortController.signal;
|
|
204
|
+
const runPromise = agentRunner.run({ ...run, signal });
|
|
205
|
+
let timeoutId;
|
|
206
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
207
|
+
timeoutId = setTimeout(() => {
|
|
208
|
+
abortController.abort(timeoutError);
|
|
209
|
+
reject(timeoutError);
|
|
210
|
+
}, timeoutMs);
|
|
211
|
+
});
|
|
212
|
+
try {
|
|
213
|
+
return await Promise.race([runPromise, timeoutPromise]);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (abortController.signal.aborted) {
|
|
216
|
+
await waitForAgentSettlement(runPromise);
|
|
217
|
+
}
|
|
218
|
+
throw error;
|
|
219
|
+
} finally {
|
|
220
|
+
if (timeoutId) {
|
|
221
|
+
clearTimeout(timeoutId);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
143
226
|
// src/chat/mcp/errors.ts
|
|
144
227
|
var McpProviderError = class extends Error {
|
|
145
228
|
phase;
|
|
@@ -1159,5 +1242,7 @@ export {
|
|
|
1159
1242
|
deleteMcpStoredOAuthCredentials,
|
|
1160
1243
|
deleteMcpServerSessionId,
|
|
1161
1244
|
createMcpOAuthClientProvider,
|
|
1162
|
-
finalizeMcpAuthorization
|
|
1245
|
+
finalizeMcpAuthorization,
|
|
1246
|
+
createAgentRunner,
|
|
1247
|
+
runAgentWithTimeout
|
|
1163
1248
|
};
|