@keystrokehq/keystroke 0.0.162 → 0.0.164
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/action.cjs +1 -1
- package/dist/action.mjs +1 -1
- package/dist/agent.cjs +19 -36
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +1 -1
- package/dist/agent.d.mts +1 -1
- package/dist/agent.mjs +19 -36
- package/dist/agent.mjs.map +1 -1
- package/dist/config.d.cts +2 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/credentials.cjs +1 -1
- package/dist/credentials.mjs +1 -1
- package/dist/{dist-mblcM3Bv.cjs → dist-BNB2mfIe.cjs} +3 -3
- package/dist/{dist-mblcM3Bv.cjs.map → dist-BNB2mfIe.cjs.map} +1 -1
- package/dist/{dist-BIbZjRd7.mjs → dist-B_b7urZi.mjs} +1 -2
- package/dist/dist-B_b7urZi.mjs.map +1 -0
- package/dist/{dist-DXzvN8aq.mjs → dist-BjWzektn.mjs} +20 -160
- package/dist/{dist-DXzvN8aq.mjs.map → dist-BjWzektn.mjs.map} +1 -1
- package/dist/{dist-lWDTuftA.cjs → dist-DK1mbPAf.cjs} +1 -2
- package/dist/dist-DK1mbPAf.cjs.map +1 -0
- package/dist/{dist-CQH7Ircq.mjs → dist-DpsVuMhU.mjs} +3 -3
- package/dist/{dist-CQH7Ircq.mjs.map → dist-DpsVuMhU.mjs.map} +1 -1
- package/dist/{dist-DiqTL3ZF.cjs → dist-DqmPOnX5.cjs} +25 -177
- package/dist/{dist-DiqTL3ZF.cjs.map → dist-DqmPOnX5.cjs.map} +1 -1
- package/dist/index-CaW3JRFU.d.cts.map +1 -1
- package/dist/index-CaW3JRFU.d.mts.map +1 -1
- package/dist/{index-IVnunyAF.d.mts → index-DMr0802v.d.mts} +3 -2
- package/dist/index-DMr0802v.d.mts.map +1 -0
- package/dist/{index-DIm3_7or.d.cts → index-DuGLQUMl.d.cts} +3 -2
- package/dist/index-DuGLQUMl.d.cts.map +1 -0
- package/dist/{mistral-DuG294d1.cjs → mistral-CV_wqkNv.cjs} +2 -2
- package/dist/{mistral-DuG294d1.cjs.map → mistral-CV_wqkNv.cjs.map} +1 -1
- package/dist/{mistral-CDuUHkpO.mjs → mistral-Cf8bwl7k.mjs} +2 -2
- package/dist/{mistral-CDuUHkpO.mjs.map → mistral-Cf8bwl7k.mjs.map} +1 -1
- package/dist/{sse-DCsg_ELF.cjs → sse-DowizN6O.cjs} +2 -2
- package/dist/{sse-DCsg_ELF.cjs.map → sse-DowizN6O.cjs.map} +1 -1
- package/dist/{sse-BBd2aLiw.mjs → sse-Duxm9CEQ.mjs} +2 -2
- package/dist/{sse-BBd2aLiw.mjs.map → sse-Duxm9CEQ.mjs.map} +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.d.cts +1 -1
- package/dist/trigger.d.mts +1 -1
- package/dist/trigger.mjs +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +1 -1
- package/package.json +1 -1
- package/dist/dist-BIbZjRd7.mjs.map +0 -1
- package/dist/dist-lWDTuftA.cjs.map +0 -1
- package/dist/index-DIm3_7or.d.cts.map +0 -1
- package/dist/index-IVnunyAF.d.mts.map +0 -1
package/dist/agent.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { l as ThinkingLevel, u as getModel } from "./index-Dr-3nl0A.cjs";
|
|
2
|
-
import { A as loadAssetManifest, B as runLlm, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentAssets, G as AgentModelIdSchema, H as AgentCreateInput, I as resolveAgentId, J as parseAgentCreateInput, K as DEFAULT_THINKING_LEVEL, L as resolveAgentTools, M as normalizeAgentDefinition, N as prepareAgentSession, O as forceToolChoice, P as prompt, R as resolveAgentWorkspaceRoot, S as buildAgentRuntime, T as defineSubagentTool, U as AgentCreateInputSchema, V as snapshot, W as AgentModelId, X as resolveThinkingLevel, Y as resolveAgentModel, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as messages, k as getSubagentToolMetadata, l as DefineSubagentToolInput, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, q as ThinkingLevelSchema, r as AgentConfig, s as AgentSnapshot, t as Agent, u as ForcedToolChoice, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as runAgentPrompt } from "./index-
|
|
2
|
+
import { A as loadAssetManifest, B as runLlm, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentAssets, G as AgentModelIdSchema, H as AgentCreateInput, I as resolveAgentId, J as parseAgentCreateInput, K as DEFAULT_THINKING_LEVEL, L as resolveAgentTools, M as normalizeAgentDefinition, N as prepareAgentSession, O as forceToolChoice, P as prompt, R as resolveAgentWorkspaceRoot, S as buildAgentRuntime, T as defineSubagentTool, U as AgentCreateInputSchema, V as snapshot, W as AgentModelId, X as resolveThinkingLevel, Y as resolveAgentModel, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as messages, k as getSubagentToolMetadata, l as DefineSubagentToolInput, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, q as ThinkingLevelSchema, r as AgentConfig, s as AgentSnapshot, t as Agent, u as ForcedToolChoice, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as runAgentPrompt } from "./index-DuGLQUMl.cjs";
|
|
3
3
|
import { a as McpDefinition, c as McpServerOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpConnection, l as McpStdioOptions, m as connectMcpStdio, n as McpAuthOptions, o as McpDefinitionInput, p as connectMcpServer, r as McpCallToolOptions, s as McpHttpTransport, t as ToolCredentialResolver, u as McpStdioTransport } from "./index-CsGfxjDx.cjs";
|
|
4
4
|
export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentModelId, AgentModelIdSchema, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineSubagentToolInput, type ForcedToolChoice, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, forceToolChoice, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, runLlm, snapshot };
|
package/dist/agent.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { l as ThinkingLevel, u as getModel } from "./index-0KyTNuR1.mjs";
|
|
2
|
-
import { A as loadAssetManifest, B as runLlm, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentAssets, G as AgentModelIdSchema, H as AgentCreateInput, I as resolveAgentId, J as parseAgentCreateInput, K as DEFAULT_THINKING_LEVEL, L as resolveAgentTools, M as normalizeAgentDefinition, N as prepareAgentSession, O as forceToolChoice, P as prompt, R as resolveAgentWorkspaceRoot, S as buildAgentRuntime, T as defineSubagentTool, U as AgentCreateInputSchema, V as snapshot, W as AgentModelId, X as resolveThinkingLevel, Y as resolveAgentModel, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as messages, k as getSubagentToolMetadata, l as DefineSubagentToolInput, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, q as ThinkingLevelSchema, r as AgentConfig, s as AgentSnapshot, t as Agent, u as ForcedToolChoice, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as runAgentPrompt } from "./index-
|
|
2
|
+
import { A as loadAssetManifest, B as runLlm, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentAssets, G as AgentModelIdSchema, H as AgentCreateInput, I as resolveAgentId, J as parseAgentCreateInput, K as DEFAULT_THINKING_LEVEL, L as resolveAgentTools, M as normalizeAgentDefinition, N as prepareAgentSession, O as forceToolChoice, P as prompt, R as resolveAgentWorkspaceRoot, S as buildAgentRuntime, T as defineSubagentTool, U as AgentCreateInputSchema, V as snapshot, W as AgentModelId, X as resolveThinkingLevel, Y as resolveAgentModel, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as messages, k as getSubagentToolMetadata, l as DefineSubagentToolInput, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, q as ThinkingLevelSchema, r as AgentConfig, s as AgentSnapshot, t as Agent, u as ForcedToolChoice, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as runAgentPrompt } from "./index-DMr0802v.mjs";
|
|
3
3
|
import { a as McpDefinition, c as McpServerOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpConnection, l as McpStdioOptions, m as connectMcpStdio, n as McpAuthOptions, o as McpDefinitionInput, p as connectMcpServer, r as McpCallToolOptions, s as McpHttpTransport, t as ToolCredentialResolver, u as McpStdioTransport } from "./index-BAIg1_V_.mjs";
|
|
4
4
|
export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentModelId, AgentModelIdSchema, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineSubagentToolInput, type ForcedToolChoice, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, forceToolChoice, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, runLlm, snapshot };
|
package/dist/agent.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { $ as Options, $t as IsMap, An as IsSymbol$1, At as Unreachable, Bn as __require, Bt as IsRef$1, Cn as IsMinLength$2, Ct as IsInteger$2, Dn as IsObject$1, Dt as IsCodec, En as IsNumber$1, Et as IsBigInt$2, Fn as Symbols, Ft as IsUnion, G as ensureWorkspaceDir, Gt as IsArray$2, Ht as IsFunction$2, In as guard_exports, It as Union, Jt as IsOptional, K as materializeSandbox, Kt as Base, Ln as __commonJSMin, Lt as IsObject$2, Mn as IsUnsafePropertyKey, Mt as IsEnum$1, Nn as IsValueLike, Nt as IsCyclic, On as IsObjectNotArray$1, Ot as Hash, Pn as Keys$1, Pt as Unknown, Q as Instantiate, Qt as Get$3, Rt as _Object_, Sn as IsMaxLength$2, St as IsIterator$2, Tn as IsNull$1, Tt as IsBoolean$2, Ut as IsConstructor$2, Vt as Ref$1, W as defineSandbox, Wt as IsAsyncIterator$2, X as resolveSandboxRoot, Xt as IsPromise, Yt as Optional, Z as Evaluate$1, Zt as IsSchema$1, _n as IsGreaterThan$1, _t as IsLiteralBigInt, a as createSandbox, an as EveryAll, at as RecordPattern, bn as IsLessEqualThan$1, bt as IsLiteralString, c as defineTool$1, cn as IsAsyncIterator$1, ct as EnumToUnion, d as resolveRunProvider, dn as IsClassInstance, dt as String$1, en as IsSet, et as Compare, fn as IsConstructor$1, ft as IsSymbol$2, gn as IsGreaterEqualThan$1, gt as IsLiteral, hn as IsFunction$1, ht as IsNull$2, i as createJustBashProvider, in as Every$1, it as IsRecord, jn as IsUndefined$1, jt as IsIntersect, kn as IsString$1, kt as hash_exports, ln as IsBigInt$1, lt as TemplateLiteralDecode, mn as IsEqual$1, mt as Number$1, nn as Entries$2, nt as IsVoid, o as defaultWorkspacesRoot, on as HasPropertyKey$1, ot as RecordValue, pn as IsDeepEqual$1, pt as IsNumber$2, q as packAssetDirs, qt as IsBase, r as createInvokeToolBridge, rn as EntriesRegExp, rt as IsUndefined$2, s as defineSkill, sn as IsArray$1, st as IsTuple, tn as IsTypeArray, tt as IsTemplateLiteral, u as materializeSkills, un as IsBoolean$1, ut as IsString$2, vn as IsInteger$1, vt as IsLiteralBoolean, wn as IsMultipleOf$1, wt as Boolean$1, xn as IsLessThan$1, xt as Literal, yn as IsIterator$1, yt as IsLiteralNumber, zn as __exportAll, zt as IsNever } from "./dist-Dv44b9V1.mjs";
|
|
2
|
-
import { T as toolParameters, c as isAction, f as resolveActionTool, o as getRunSignal, s as getWorkflowRunHandle, u as isWithinActionExecution } from "./dist-
|
|
2
|
+
import { T as toolParameters, c as isAction, f as resolveActionTool, o as getRunSignal, s as getWorkflowRunHandle, u as isWithinActionExecution } from "./dist-B_b7urZi.mjs";
|
|
3
3
|
import "./env-api-keys-mjSaOeuP.mjs";
|
|
4
4
|
import { i as getModel, t as AssistantMessageEventStream } from "./event-stream-C7YBbzsc.mjs";
|
|
5
5
|
import "./json-parse-Drlv-g_X.mjs";
|
|
6
|
-
import { C as
|
|
6
|
+
import { C as connectMcpStdio, S as connectMcpServer, T as isMcp, _ as captureConsole, a as resolveActionCredentials, b as withSpan, c as addAgentSessionDuration, d as getAgentByRoute, f as getSession, g as touchSession, h as resolveRunSourceFromTraceContext, i as isCredentialError, l as appendEvent, m as recordLlmUsageFromAssistantMessage, n as captureCredentialToolErrors, o as resolveMcpTools, p as listMessageEvents, r as createCredentialResolver, s as MESSAGE_EVENT_TYPE$1, t as buildCredentialRunContext, u as createSession, v as getTraceContext, w as defineMcp, x as connectMcpDefinition } from "./dist-BjWzektn.mjs";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -900,7 +900,7 @@ function loadGoogleVertexProviderModule() {
|
|
|
900
900
|
return googleVertexProviderModulePromise;
|
|
901
901
|
}
|
|
902
902
|
function loadMistralProviderModule() {
|
|
903
|
-
mistralProviderModulePromise ||= import("./mistral-
|
|
903
|
+
mistralProviderModulePromise ||= import("./mistral-Cf8bwl7k.mjs").then((module) => {
|
|
904
904
|
const provider = module;
|
|
905
905
|
return {
|
|
906
906
|
stream: provider.streamMistral,
|
|
@@ -13757,8 +13757,8 @@ function shouldPersistAgentEvent(event) {
|
|
|
13757
13757
|
return !SKIPPED_EVENT_TYPES.has(event.type);
|
|
13758
13758
|
}
|
|
13759
13759
|
async function persistSessionEvent(options) {
|
|
13760
|
-
const { sessionId,
|
|
13761
|
-
const seq = await appendEvent(sessionId, eventType, payload
|
|
13760
|
+
const { sessionId, memoryConfig, eventType, payload } = options;
|
|
13761
|
+
const seq = await appendEvent(sessionId, eventType, payload);
|
|
13762
13762
|
if (memoryConfig) try {
|
|
13763
13763
|
await appendSessionLine(memoryConfig, sessionId, {
|
|
13764
13764
|
seq,
|
|
@@ -13772,18 +13772,15 @@ async function persistSessionEvent(options) {
|
|
|
13772
13772
|
return seq;
|
|
13773
13773
|
}
|
|
13774
13774
|
async function persistAgentEvent(sessionId, event, options) {
|
|
13775
|
-
const runId = options?.runId ?? null;
|
|
13776
13775
|
const memoryConfig = options?.memoryConfig;
|
|
13777
13776
|
await persistSessionEvent({
|
|
13778
13777
|
sessionId,
|
|
13779
|
-
runId,
|
|
13780
13778
|
memoryConfig,
|
|
13781
13779
|
eventType: event.type,
|
|
13782
13780
|
payload: event
|
|
13783
13781
|
});
|
|
13784
13782
|
if (event.type === "message_end") await persistSessionEvent({
|
|
13785
13783
|
sessionId,
|
|
13786
|
-
runId,
|
|
13787
13784
|
memoryConfig,
|
|
13788
13785
|
eventType: MESSAGE_EVENT_TYPE$1,
|
|
13789
13786
|
payload: event.message
|
|
@@ -13801,21 +13798,13 @@ async function prepareAgentSession(agentId, sessionId, options) {
|
|
|
13801
13798
|
async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
13802
13799
|
const { sessionId } = await prepareAgentSession(agentId, input.sessionId);
|
|
13803
13800
|
const priorMessages = await listMessageEvents(sessionId);
|
|
13804
|
-
const runSource = await resolveAgentRunSourceFromSession(sessionId);
|
|
13805
|
-
const runId = await createAgentRun({
|
|
13806
|
-
sessionId,
|
|
13807
|
-
agentId,
|
|
13808
|
-
sourceKind: runSource.sourceKind,
|
|
13809
|
-
sourceId: runSource.sourceId,
|
|
13810
|
-
ranByUserId: runSource.ranByUserId
|
|
13811
|
-
});
|
|
13812
13801
|
const runPrompt = async () => {
|
|
13813
|
-
let promptError = null;
|
|
13814
13802
|
let runtime;
|
|
13815
13803
|
let unsubscribe;
|
|
13816
13804
|
let onAbort;
|
|
13817
13805
|
const pendingHandlers = /* @__PURE__ */ new Set();
|
|
13818
13806
|
const signal = getRunSignal();
|
|
13807
|
+
let promptDurationMs = 0;
|
|
13819
13808
|
try {
|
|
13820
13809
|
runtime = await agent.buildRuntime({
|
|
13821
13810
|
agentId,
|
|
@@ -13833,14 +13822,11 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
13833
13822
|
unsubscribe = activeRuntime.pi.subscribe((event) => {
|
|
13834
13823
|
if (!shouldPersistAgentEvent(event)) return;
|
|
13835
13824
|
const tracked = (async () => {
|
|
13836
|
-
await persistAgentEvent(sessionId, event, {
|
|
13837
|
-
runId,
|
|
13838
|
-
memoryConfig
|
|
13839
|
-
});
|
|
13825
|
+
await persistAgentEvent(sessionId, event, { memoryConfig });
|
|
13840
13826
|
if (event.type === "message_end" && event.message.role === "assistant") {
|
|
13841
13827
|
const usage = llmUsageFromAssistantMessage(event.message);
|
|
13842
13828
|
if (usage) await recordLlmUsageFromAssistantMessage({
|
|
13843
|
-
|
|
13829
|
+
sessionId,
|
|
13844
13830
|
usage
|
|
13845
13831
|
});
|
|
13846
13832
|
}
|
|
@@ -13853,24 +13839,27 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
13853
13839
|
onAbort = () => activeRuntime.pi.abort();
|
|
13854
13840
|
if (signal.aborted) onAbort();
|
|
13855
13841
|
else signal.addEventListener("abort", onAbort, { once: true });
|
|
13856
|
-
const
|
|
13842
|
+
const promptStartedAt = Date.now();
|
|
13843
|
+
let snapshot;
|
|
13844
|
+
try {
|
|
13845
|
+
snapshot = await captureConsole(async () => prompt(activeRuntime, input.message));
|
|
13846
|
+
} finally {
|
|
13847
|
+
promptDurationMs = Math.max(0, Date.now() - promptStartedAt);
|
|
13848
|
+
}
|
|
13857
13849
|
const credentialError = activeRuntime.takeCredentialError?.();
|
|
13858
13850
|
if (credentialError && isCredentialError(credentialError)) throw credentialError;
|
|
13851
|
+
const responseMessages = messages(snapshot);
|
|
13859
13852
|
await touchSession(sessionId);
|
|
13860
13853
|
return {
|
|
13861
13854
|
sessionId,
|
|
13862
|
-
|
|
13863
|
-
messages: messages(snapshot),
|
|
13855
|
+
messages: responseMessages,
|
|
13864
13856
|
error: errorMessage(snapshot) ?? null,
|
|
13865
13857
|
canceled: signal.aborted
|
|
13866
13858
|
};
|
|
13867
|
-
} catch (error) {
|
|
13868
|
-
promptError = error;
|
|
13869
|
-
throw error;
|
|
13870
13859
|
} finally {
|
|
13871
13860
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
13872
13861
|
unsubscribe?.();
|
|
13873
|
-
await Promise.allSettled(
|
|
13862
|
+
await Promise.allSettled(pendingHandlers);
|
|
13874
13863
|
if (runtime) {
|
|
13875
13864
|
try {
|
|
13876
13865
|
runtime.memory?.reindexSessions();
|
|
@@ -13881,13 +13870,7 @@ async function runAgentPrompt(agent, agentId, input, options = {}) {
|
|
|
13881
13870
|
await Promise.all(runtime.mcpConnections.map((connection) => connection.close()));
|
|
13882
13871
|
await runtime.sandbox.dispose();
|
|
13883
13872
|
}
|
|
13884
|
-
|
|
13885
|
-
await finalizeAgentRunFromPrompt({
|
|
13886
|
-
runId,
|
|
13887
|
-
status: promptError ? "failed" : signal.aborted ? "canceled" : "completed",
|
|
13888
|
-
error: promptError,
|
|
13889
|
-
finishedAt
|
|
13890
|
-
});
|
|
13873
|
+
await addAgentSessionDuration(sessionId, promptDurationMs);
|
|
13891
13874
|
}
|
|
13892
13875
|
};
|
|
13893
13876
|
if (options.skipAgentSessionSpan) return runWithinAgentPromptExecution(runPrompt);
|