@keystrokehq/keystroke 0.0.159 → 0.0.160
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.d.cts +3 -3
- package/dist/action.d.mts +3 -3
- package/dist/action.mjs +1 -1
- package/dist/agent-types.d.cts +1 -1
- package/dist/agent-types.d.mts +1 -1
- package/dist/agent.cjs +162 -5
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +4 -4
- package/dist/agent.d.mts +4 -4
- package/dist/agent.mjs +161 -6
- package/dist/agent.mjs.map +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/credentials.cjs +1 -1
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.mts +1 -1
- package/dist/credentials.mjs +1 -1
- package/dist/{dist-lYNbBwe5.mjs → dist-BAzfOMfz.mjs} +3 -3
- package/dist/{dist-lYNbBwe5.mjs.map → dist-BAzfOMfz.mjs.map} +1 -1
- package/dist/{dist-u0RYk4-X.cjs → dist-BkkOal_e.cjs} +3 -3
- package/dist/{dist-u0RYk4-X.cjs.map → dist-BkkOal_e.cjs.map} +1 -1
- package/dist/{dist-DALSxODo.mjs → dist-C8t_Snfd.mjs} +32 -5
- package/dist/dist-C8t_Snfd.mjs.map +1 -0
- package/dist/{dist-D5jH3nQI.cjs → dist-DFXV_Io5.cjs} +7 -1
- package/dist/{dist-D5jH3nQI.cjs.map → dist-DFXV_Io5.cjs.map} +1 -1
- package/dist/{dist-XKCtZShd.mjs → dist-DM1Na5CA.mjs} +2 -2
- package/dist/{dist-XKCtZShd.mjs.map → dist-DM1Na5CA.mjs.map} +1 -1
- package/dist/{dist-DhBV2U_0.cjs → dist-fqWJTm0u.cjs} +37 -4
- package/dist/dist-fqWJTm0u.cjs.map +1 -0
- package/dist/{index-BcMCpDKh.d.cts → index-0KyTNuR1.d.mts} +5 -5
- package/dist/{index-Bd_asjgz.d.mts.map → index-0KyTNuR1.d.mts.map} +1 -1
- package/dist/{index-CUrU-w2Y.d.cts → index-BAIg1_V_.d.mts} +3 -3
- package/dist/{index-Qnwdoq7U.d.mts.map → index-BAIg1_V_.d.mts.map} +1 -1
- package/dist/{index-DuYf0Fdc.d.cts → index-BbwuSuxl.d.mts} +29 -7
- package/dist/index-BbwuSuxl.d.mts.map +1 -0
- package/dist/{index-B4HxxDhO.d.cts → index-Bjg-QRlL.d.cts} +2 -2
- package/dist/{index-B4HxxDhO.d.cts.map → index-Bjg-QRlL.d.cts.map} +1 -1
- package/dist/{index-BNcrFoZi.d.cts → index-CaW3JRFU.d.cts} +15 -2
- package/dist/{index-BNcrFoZi.d.mts.map → index-CaW3JRFU.d.cts.map} +1 -1
- package/dist/{index-BNcrFoZi.d.mts → index-CaW3JRFU.d.mts} +15 -2
- package/dist/{index-BNcrFoZi.d.cts.map → index-CaW3JRFU.d.mts.map} +1 -1
- package/dist/{index-Bbe9CzYo.d.mts → index-CgMisiAc.d.mts} +7 -4
- package/dist/index-CgMisiAc.d.mts.map +1 -0
- package/dist/{index-Qnwdoq7U.d.mts → index-CsGfxjDx.d.cts} +3 -3
- package/dist/{index-CUrU-w2Y.d.cts.map → index-CsGfxjDx.d.cts.map} +1 -1
- package/dist/{index-CqbBhKYv.d.mts → index-CxjY9wjs.d.mts} +2 -2
- package/dist/{index-CqbBhKYv.d.mts.map → index-CxjY9wjs.d.mts.map} +1 -1
- package/dist/{index-BmXIGJlQ.d.cts → index-D7upoVsK.d.cts} +7 -4
- package/dist/index-D7upoVsK.d.cts.map +1 -0
- package/dist/{index-CyCx29m7.d.mts → index-DaxRr-x9.d.cts} +29 -7
- package/dist/index-DaxRr-x9.d.cts.map +1 -0
- package/dist/{index-jLW9DNA0.d.cts → index-DkQoSfqQ.d.cts} +12 -4
- package/dist/index-DkQoSfqQ.d.cts.map +1 -0
- package/dist/{index-Bd_asjgz.d.mts → index-Dr-3nl0A.d.cts} +5 -5
- package/dist/{index-BcMCpDKh.d.cts.map → index-Dr-3nl0A.d.cts.map} +1 -1
- package/dist/{index-BUmyUoC2.d.mts → index-p6yOVMbx.d.mts} +12 -4
- package/dist/index-p6yOVMbx.d.mts.map +1 -0
- package/dist/{mistral-CWlaNuqc.mjs → mistral-BRIv8KXE.mjs} +2 -2
- package/dist/{mistral-CWlaNuqc.mjs.map → mistral-BRIv8KXE.mjs.map} +1 -1
- package/dist/{mistral-DIpD1PUg.cjs → mistral-DUKMgFL1.cjs} +2 -2
- package/dist/{mistral-DIpD1PUg.cjs.map → mistral-DUKMgFL1.cjs.map} +1 -1
- package/dist/sandbox.d.cts +1 -1
- package/dist/sandbox.d.mts +1 -1
- package/dist/{sse-DuzdM7Va.mjs → sse-Ba5sWI6l.mjs} +2 -2
- package/dist/{sse-DuzdM7Va.mjs.map → sse-Ba5sWI6l.mjs.map} +1 -1
- package/dist/{sse-DXvz9wn_.cjs → sse-jvB09Ct-.cjs} +2 -2
- package/dist/{sse-DXvz9wn_.cjs.map → sse-jvB09Ct-.cjs.map} +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.d.cts +3 -3
- package/dist/trigger.d.mts +3 -3
- package/dist/trigger.mjs +1 -1
- package/dist/workflow.cjs +2 -1
- package/dist/workflow.d.cts +3 -2
- package/dist/workflow.d.mts +3 -2
- package/dist/workflow.mjs +2 -2
- package/package.json +1 -1
- package/dist/dist-DALSxODo.mjs.map +0 -1
- package/dist/dist-DhBV2U_0.cjs.map +0 -1
- package/dist/index-BUmyUoC2.d.mts.map +0 -1
- package/dist/index-Bbe9CzYo.d.mts.map +0 -1
- package/dist/index-BmXIGJlQ.d.cts.map +0 -1
- package/dist/index-CyCx29m7.d.mts.map +0 -1
- package/dist/index-DuYf0Fdc.d.cts.map +0 -1
- package/dist/index-jLW9DNA0.d.cts.map +0 -1
package/dist/agent.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as ThinkingLevel, u as getModel } from "./index-
|
|
2
|
-
import { A as
|
|
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-
|
|
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 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, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
|
|
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-DaxRr-x9.cjs";
|
|
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
|
+
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
|
-
import { l as ThinkingLevel, u as getModel } from "./index-
|
|
2
|
-
import { A as
|
|
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-
|
|
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 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, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
|
|
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-BbwuSuxl.mjs";
|
|
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
|
+
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 { 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-DM1Na5CA.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 isMcp, S as defineMcp, a as resolveActionCredentials, b as connectMcpServer, c as appendEvent, d as getSession, f as listMessageEvents, g as getTraceContext, h as captureConsole, i as isCredentialError, l as createSession, m as touchSession, n as captureCredentialToolErrors, o as resolveMcpTools, p as resolveRunSourceFromTraceContext, r as createCredentialResolver, s as MESSAGE_EVENT_TYPE$1, t as buildCredentialRunContext, u as getAgentByRoute, v as withSpan, x as connectMcpStdio, y as connectMcpDefinition } from "./dist-
|
|
6
|
+
import { C as isMcp, S as defineMcp, a as resolveActionCredentials, b as connectMcpServer, c as appendEvent, d as getSession, f as listMessageEvents, g as getTraceContext, h as captureConsole, i as isCredentialError, l as createSession, m as touchSession, n as captureCredentialToolErrors, o as resolveMcpTools, p as resolveRunSourceFromTraceContext, r as createCredentialResolver, s as MESSAGE_EVENT_TYPE$1, t as buildCredentialRunContext, u as getAgentByRoute, v as withSpan, x as connectMcpStdio, y as connectMcpDefinition } from "./dist-BAzfOMfz.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-BRIv8KXE.mjs").then((module) => {
|
|
904
904
|
const provider = module;
|
|
905
905
|
return {
|
|
906
906
|
stream: provider.streamMistral,
|
|
@@ -1025,6 +1025,9 @@ function resolveApiProvider(api) {
|
|
|
1025
1025
|
function streamSimple(model, context, options) {
|
|
1026
1026
|
return resolveApiProvider(model.api).streamSimple(model, context, options);
|
|
1027
1027
|
}
|
|
1028
|
+
async function completeSimple(model, context, options) {
|
|
1029
|
+
return streamSimple(model, context, options).result();
|
|
1030
|
+
}
|
|
1028
1031
|
//#endregion
|
|
1029
1032
|
//#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/schema/types/_guard.mjs
|
|
1030
1033
|
function IsGuardInterface(value) {
|
|
@@ -13384,7 +13387,7 @@ function readMd(path, limit) {
|
|
|
13384
13387
|
chars: content.length
|
|
13385
13388
|
};
|
|
13386
13389
|
}
|
|
13387
|
-
function extractText(content) {
|
|
13390
|
+
function extractText$1(content) {
|
|
13388
13391
|
if (typeof content === "string") return content;
|
|
13389
13392
|
if (Array.isArray(content)) {
|
|
13390
13393
|
const parts = [];
|
|
@@ -13438,7 +13441,7 @@ function extractSessionRows(file) {
|
|
|
13438
13441
|
continue;
|
|
13439
13442
|
}
|
|
13440
13443
|
if (obj.type !== "message" || !obj.message) continue;
|
|
13441
|
-
const text = extractText(obj.message.content);
|
|
13444
|
+
const text = extractText$1(obj.message.content);
|
|
13442
13445
|
if (!text) continue;
|
|
13443
13446
|
rows.push({
|
|
13444
13447
|
line_no: i + 1,
|
|
@@ -14161,7 +14164,159 @@ function defineSubagentTool(input) {
|
|
|
14161
14164
|
subagentTool[SUBAGENT_TOOL] = metadata;
|
|
14162
14165
|
return subagentTool;
|
|
14163
14166
|
}
|
|
14167
|
+
/**
|
|
14168
|
+
* Best-effort provider `tool_choice` for forcing a named tool. Returns `undefined`
|
|
14169
|
+
* when the API shape is unknown so callers can rely on prompt + validate + retry.
|
|
14170
|
+
*/
|
|
14171
|
+
function forceToolChoice(api, toolName) {
|
|
14172
|
+
switch (api) {
|
|
14173
|
+
case "anthropic-messages": return {
|
|
14174
|
+
type: "tool",
|
|
14175
|
+
name: toolName
|
|
14176
|
+
};
|
|
14177
|
+
case "openai-completions":
|
|
14178
|
+
case "openai-responses":
|
|
14179
|
+
case "azure-openai-responses": return {
|
|
14180
|
+
type: "function",
|
|
14181
|
+
function: { name: toolName }
|
|
14182
|
+
};
|
|
14183
|
+
case "bedrock-converse-stream": return { tool: { name: toolName } };
|
|
14184
|
+
case "google-generative-ai":
|
|
14185
|
+
case "google-vertex": return "any";
|
|
14186
|
+
default: return;
|
|
14187
|
+
}
|
|
14188
|
+
}
|
|
14189
|
+
const RESPOND_TOOL_NAME = "respond";
|
|
14190
|
+
const STRUCTURED_OUTPUT_INSTRUCTION = "Respond only by calling `respond` with arguments matching the schema; do not answer in plain text.";
|
|
14191
|
+
const MAX_OBJECT_ATTEMPTS = 3;
|
|
14192
|
+
/** Same validation as `defineAgent` — format check before catalog lookup. */
|
|
14193
|
+
function resolvePromptModel(model) {
|
|
14194
|
+
return resolveAgentModel(AgentModelIdSchema.parse(model));
|
|
14195
|
+
}
|
|
14196
|
+
/**
|
|
14197
|
+
* pi-ai types tool `parameters` as TypeBox `TSchema`, but providers consume JSON Schema
|
|
14198
|
+
* at runtime. Same bridge as `resolveActionTool` in `@keystrokehq/action`.
|
|
14199
|
+
*/
|
|
14200
|
+
function buildToolParameters(schema) {
|
|
14201
|
+
return toolParameters(schema);
|
|
14202
|
+
}
|
|
14203
|
+
function extractText(message) {
|
|
14204
|
+
return message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
14205
|
+
}
|
|
14206
|
+
function extractToolCall(message) {
|
|
14207
|
+
return message.content.find((part) => part.type === "toolCall");
|
|
14208
|
+
}
|
|
14209
|
+
function needsEnvelope(schema) {
|
|
14210
|
+
const json = z.toJSONSchema(schema, { target: "draft-2020-12" });
|
|
14211
|
+
if (typeof json !== "object" || json === null || !("type" in json)) return true;
|
|
14212
|
+
return json.type !== "object";
|
|
14213
|
+
}
|
|
14214
|
+
function wrapSchemaForTool(schema) {
|
|
14215
|
+
if (!needsEnvelope(schema)) return {
|
|
14216
|
+
toolSchema: schema,
|
|
14217
|
+
unwrap: (args) => args
|
|
14218
|
+
};
|
|
14219
|
+
const envelopeSchema = z.object({ result: schema });
|
|
14220
|
+
return {
|
|
14221
|
+
toolSchema: envelopeSchema,
|
|
14222
|
+
unwrap: (args) => envelopeSchema.parse(args).result
|
|
14223
|
+
};
|
|
14224
|
+
}
|
|
14225
|
+
function buildRespondTool(schema) {
|
|
14226
|
+
return {
|
|
14227
|
+
name: RESPOND_TOOL_NAME,
|
|
14228
|
+
description: "Return the final result.",
|
|
14229
|
+
parameters: buildToolParameters(schema)
|
|
14230
|
+
};
|
|
14231
|
+
}
|
|
14232
|
+
function resolvePromptReasoning(thinkingLevel) {
|
|
14233
|
+
if (!thinkingLevel || thinkingLevel === "off") return;
|
|
14234
|
+
return thinkingLevel;
|
|
14235
|
+
}
|
|
14236
|
+
function formatValidationError(error) {
|
|
14237
|
+
return error instanceof Error ? error.message : String(error);
|
|
14238
|
+
}
|
|
14239
|
+
async function runPromptText(opts) {
|
|
14240
|
+
const model = resolvePromptModel(opts.model);
|
|
14241
|
+
const reasoning = resolvePromptReasoning(opts.thinkingLevel);
|
|
14242
|
+
const message = await completeSimple(model, {
|
|
14243
|
+
systemPrompt: opts.system,
|
|
14244
|
+
messages: [{
|
|
14245
|
+
role: "user",
|
|
14246
|
+
content: opts.prompt,
|
|
14247
|
+
timestamp: Date.now()
|
|
14248
|
+
}]
|
|
14249
|
+
}, {
|
|
14250
|
+
...reasoning !== void 0 ? { reasoning } : {},
|
|
14251
|
+
...opts.temperature !== void 0 ? { temperature: opts.temperature } : {},
|
|
14252
|
+
...opts.maxTokens !== void 0 ? { maxTokens: opts.maxTokens } : {}
|
|
14253
|
+
});
|
|
14254
|
+
if (message.stopReason === "error") throw new Error(message.errorMessage ?? "LLM request failed");
|
|
14255
|
+
return extractText(message);
|
|
14256
|
+
}
|
|
14257
|
+
async function runPromptObject(opts) {
|
|
14258
|
+
const schema = opts.outputSchema;
|
|
14259
|
+
if (!schema) throw new Error("outputSchema is required for structured LLM output");
|
|
14260
|
+
const model = resolvePromptModel(opts.model);
|
|
14261
|
+
const reasoning = resolvePromptReasoning(opts.thinkingLevel);
|
|
14262
|
+
const { toolSchema, unwrap } = wrapSchemaForTool(schema);
|
|
14263
|
+
const tool = buildRespondTool(toolSchema);
|
|
14264
|
+
const toolChoice = forceToolChoice(model.api, RESPOND_TOOL_NAME);
|
|
14265
|
+
const systemPrompt = [opts.system, STRUCTURED_OUTPUT_INSTRUCTION].filter(Boolean).join("\n\n");
|
|
14266
|
+
const messages = [{
|
|
14267
|
+
role: "user",
|
|
14268
|
+
content: opts.prompt,
|
|
14269
|
+
timestamp: Date.now()
|
|
14270
|
+
}];
|
|
14271
|
+
let lastError;
|
|
14272
|
+
for (let attempt = 0; attempt < MAX_OBJECT_ATTEMPTS; attempt++) {
|
|
14273
|
+
let message;
|
|
14274
|
+
let toolCall;
|
|
14275
|
+
try {
|
|
14276
|
+
message = await completeSimple(model, {
|
|
14277
|
+
systemPrompt,
|
|
14278
|
+
messages,
|
|
14279
|
+
tools: [tool]
|
|
14280
|
+
}, {
|
|
14281
|
+
...reasoning !== void 0 ? { reasoning } : {},
|
|
14282
|
+
...opts.temperature !== void 0 ? { temperature: opts.temperature } : {},
|
|
14283
|
+
...opts.maxTokens !== void 0 ? { maxTokens: opts.maxTokens } : {},
|
|
14284
|
+
...toolChoice !== void 0 ? { toolChoice } : {}
|
|
14285
|
+
});
|
|
14286
|
+
if (message.stopReason === "error") throw new Error(message.errorMessage ?? "LLM request failed");
|
|
14287
|
+
toolCall = extractToolCall(message);
|
|
14288
|
+
if (!toolCall) throw new Error("Model did not return a tool call");
|
|
14289
|
+
return schema.parse(unwrap(toolCall.arguments));
|
|
14290
|
+
} catch (error) {
|
|
14291
|
+
lastError = error;
|
|
14292
|
+
if (attempt === MAX_OBJECT_ATTEMPTS - 1) break;
|
|
14293
|
+
const correction = `Validation failed: ${formatValidationError(error)}. Call respond again with valid arguments.`;
|
|
14294
|
+
if (message && toolCall) messages.push(message, {
|
|
14295
|
+
role: "toolResult",
|
|
14296
|
+
toolCallId: toolCall.id,
|
|
14297
|
+
toolName: toolCall.name,
|
|
14298
|
+
content: [{
|
|
14299
|
+
type: "text",
|
|
14300
|
+
text: correction
|
|
14301
|
+
}],
|
|
14302
|
+
isError: true,
|
|
14303
|
+
timestamp: Date.now()
|
|
14304
|
+
});
|
|
14305
|
+
else if (message) messages.push(message, {
|
|
14306
|
+
role: "user",
|
|
14307
|
+
content: correction,
|
|
14308
|
+
timestamp: Date.now()
|
|
14309
|
+
});
|
|
14310
|
+
}
|
|
14311
|
+
}
|
|
14312
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
14313
|
+
}
|
|
14314
|
+
/** One-shot LLM generation for workflow `promptLlm` steps (pi-ai transport). */
|
|
14315
|
+
async function runLlm(opts) {
|
|
14316
|
+
if (opts.outputSchema) return runPromptObject(opts);
|
|
14317
|
+
return runPromptText(opts);
|
|
14318
|
+
}
|
|
14164
14319
|
//#endregion
|
|
14165
|
-
export { AgentCreateInputSchema, AgentModelIdSchema, DEFAULT_THINKING_LEVEL, SUBAGENT_TOOL, SessionAgentMismatchError, ThinkingLevelSchema, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentId, resolveAgentModel, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
|
|
14320
|
+
export { AgentCreateInputSchema, AgentModelIdSchema, DEFAULT_THINKING_LEVEL, SUBAGENT_TOOL, SessionAgentMismatchError, ThinkingLevelSchema, 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 };
|
|
14166
14321
|
|
|
14167
14322
|
//# sourceMappingURL=agent.mjs.map
|