@theokit/agents 4.8.0 → 4.9.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.
@@ -938,12 +938,6 @@ interface RuntimeOverrides {
938
938
  */
939
939
  sdkTools?: readonly CustomTool[];
940
940
  }
941
- /**
942
- * Creates an agent stream factory using @theokit/sdk as the runtime.
943
- *
944
- * Returns a function that, given a message + sessionId, yields TheoKit
945
- * AgentStreamEvent via the SDK's Agent.create() + Run.stream() pipeline.
946
- */
947
941
  declare function createSdkAgentStream(compiled: CompiledAgentOptions, compiledTools: CompiledTool[], apiKey: string | (() => string | Promise<string>), overrides?: RuntimeOverrides): ((message: string, sessionId: string, factoryOpts?: {
948
942
  disableTools?: boolean;
949
943
  }) => AsyncIterable<StreamEvent>) & {
@@ -973,7 +967,7 @@ interface SdkAgentHandle {
973
967
  * surface (e.g. the ACP client) owns approval. Tools still execute; they are simply not HITL-gated here.
974
968
  */
975
969
  declare function toAgentFactory(def: AgentDefinition, opts: {
976
- apiKey: string;
970
+ apiKey: string | (() => string | Promise<string>);
977
971
  overrides?: RuntimeOverrides;
978
972
  }): (sessionId: string) => Promise<SdkAgentHandle>;
979
973
 
package/dist/bridge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { g as AGENT_BRAND, h as AfterToolCallContext, i as AgentBuilder, j as AgentDefinition, k as AgentDefinitionError, l as AgentExecutionContext, m as AgentManifest, f as AgentManifestEntry, n as AgentManifestSource, o as AgentManifestTool, q as AgentRoute, r as AgentRouteContext, s as AgentRunInfo, t as AgentStreamEvent, u as AgentTurnMetadata, v as AgentsPluginOptions, w as ApiErrorContext, x as ApiErrorDecision, y as ApiErrorPolicy, z as ApprovalRequiredEvent, B as ArtifactChunkEvent, E as ArtifactStartEvent, F as BackgroundDelegation, I as BeforeToolCallContext, J as BudgetExceededError, N as CheckpointSavedEvent, C as CompiledAgentOptions, O as CompiledContextWindow, a as CompiledTool, P as ContextualTool, V as DefineAgentConfig, W as DelegateFn, X as DelegateOptions, Y as DelegationError, D as DelegationResult, Z as DoneEvent, _ as ErrorEvent, $ as FileEditEvent, a5 as InferAgentInput, a6 as InferAgentToolNames, a7 as IterationEvent, a8 as LLMCallContext, ad as McpApprovalSpec, ae as McpRegistryConfig, af as McpRequestContext, ag as McpSelection, ah as PartialToolCallEvent, aj as ProcessInputContext, an as RunStartedEvent, ao as ScoreVerdict, ap as ScoredDelegation, aq as Scorer, ar as SdkAgentHandle, as as SdkMessage, at as Segment, aw as StateUpdateEvent, S as StreamEvent, ax as TextDeltaEvent, ay as ThinkingEvent, aA as ToolCallEvent, aB as ToolCallVeto, aC as ToolHooks, aD as ToolHooksPlugin, aE as ToolResultEvent, aF as ToolWalkResult, aH as ToolboxWalkResult, aI as agentsPlugin, aJ as buildModelSelection, aK as compileAgentDefinition, aL as compileAgentModule, aM as compileContextWindow, aN as compileProjectContext, aO as compileSkills, aP as compileTools, aQ as createAgentExecutionContext, aR as createApiErrorHandler, aS as createSdkAgentStream, aT as createThinkTagExtractor, aU as createToolHooksPlugin, aV as delegate, aW as delegateBackground, aX as delegateWithScoring, aY as extractThinkTagStream, aZ as generateAgentManifest, a_ as generateAgentRoutes, a$ as isAgentContext, b0 as isAgentDefinition, b1 as isApprovalRequired, b2 as isDone, b3 as isError, b4 as isPartialToolCall, b5 as isTextDelta, b6 as isToolCall, b7 as isToolResult, ba as mcpRegistry, bb as mcpToolApprovals, bd as presentUIMessageStream, be as projectContextMetadataOnlyKnobs, bi as resolveMcpServers, bj as runWithApiErrorHandling, bk as streamAgentResponse, bl as streamAgentUIMessages, bm as toAgentFactory, bn as translateSdkEvent } from './bridge-entry-CkpzmeJU.js';
1
+ export { g as AGENT_BRAND, h as AfterToolCallContext, i as AgentBuilder, j as AgentDefinition, k as AgentDefinitionError, l as AgentExecutionContext, m as AgentManifest, f as AgentManifestEntry, n as AgentManifestSource, o as AgentManifestTool, q as AgentRoute, r as AgentRouteContext, s as AgentRunInfo, t as AgentStreamEvent, u as AgentTurnMetadata, v as AgentsPluginOptions, w as ApiErrorContext, x as ApiErrorDecision, y as ApiErrorPolicy, z as ApprovalRequiredEvent, B as ArtifactChunkEvent, E as ArtifactStartEvent, F as BackgroundDelegation, I as BeforeToolCallContext, J as BudgetExceededError, N as CheckpointSavedEvent, C as CompiledAgentOptions, O as CompiledContextWindow, a as CompiledTool, P as ContextualTool, V as DefineAgentConfig, W as DelegateFn, X as DelegateOptions, Y as DelegationError, D as DelegationResult, Z as DoneEvent, _ as ErrorEvent, $ as FileEditEvent, a5 as InferAgentInput, a6 as InferAgentToolNames, a7 as IterationEvent, a8 as LLMCallContext, ad as McpApprovalSpec, ae as McpRegistryConfig, af as McpRequestContext, ag as McpSelection, ah as PartialToolCallEvent, aj as ProcessInputContext, an as RunStartedEvent, ao as ScoreVerdict, ap as ScoredDelegation, aq as Scorer, ar as SdkAgentHandle, as as SdkMessage, at as Segment, aw as StateUpdateEvent, S as StreamEvent, ax as TextDeltaEvent, ay as ThinkingEvent, aA as ToolCallEvent, aB as ToolCallVeto, aC as ToolHooks, aD as ToolHooksPlugin, aE as ToolResultEvent, aF as ToolWalkResult, aH as ToolboxWalkResult, aI as agentsPlugin, aJ as buildModelSelection, aK as compileAgentDefinition, aL as compileAgentModule, aM as compileContextWindow, aN as compileProjectContext, aO as compileSkills, aP as compileTools, aQ as createAgentExecutionContext, aR as createApiErrorHandler, aS as createSdkAgentStream, aT as createThinkTagExtractor, aU as createToolHooksPlugin, aV as delegate, aW as delegateBackground, aX as delegateWithScoring, aY as extractThinkTagStream, aZ as generateAgentManifest, a_ as generateAgentRoutes, a$ as isAgentContext, b0 as isAgentDefinition, b1 as isApprovalRequired, b2 as isDone, b3 as isError, b4 as isPartialToolCall, b5 as isTextDelta, b6 as isToolCall, b7 as isToolResult, ba as mcpRegistry, bb as mcpToolApprovals, bd as presentUIMessageStream, be as projectContextMetadataOnlyKnobs, bi as resolveMcpServers, bj as runWithApiErrorHandling, bk as streamAgentResponse, bl as streamAgentUIMessages, bm as toAgentFactory, bn as translateSdkEvent } from './bridge-entry-BmPk3TPf.js';
2
2
  import '@theokit/http';
3
3
  import '@theokit/sdk';
4
4
  import 'zod';
package/dist/bridge.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  streamAgentUIMessages,
44
44
  toAgentFactory,
45
45
  translateSdkEvent
46
- } from "./chunk-LEHFFIEO.js";
46
+ } from "./chunk-ZQKR6XQS.js";
47
47
  import "./chunk-7QVYU63E.js";
48
48
  export {
49
49
  AGENT_BRAND,
@@ -1164,6 +1164,10 @@ function buildSdkTools(compiledTools, defineTool, extraSdkTools = [], runContext
1164
1164
  ];
1165
1165
  }
1166
1166
  __name(buildSdkTools, "buildSdkTools");
1167
+ async function resolverApiKey(k) {
1168
+ return typeof k === "function" ? await k() : k;
1169
+ }
1170
+ __name(resolverApiKey, "resolverApiKey");
1167
1171
  function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
1168
1172
  const model = overrides.model ?? compiled.model ?? "openai/gpt-4o-mini";
1169
1173
  const reasoningEffort = overrides.reasoningEffort ?? compiled.reasoningEffort;
@@ -1201,7 +1205,7 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
1201
1205
  keys: runContext !== void 0 ? Object.keys(runContext) : []
1202
1206
  });
1203
1207
  try {
1204
- const apiKeyResolvida = typeof apiKey === "function" ? await apiKey() : apiKey;
1208
+ const apiKeyResolvida = await resolverApiKey(apiKey);
1205
1209
  yield* streamSdkAgent(rt, compiled, sdkTools, {
1206
1210
  apiKey: apiKeyResolvida,
1207
1211
  model,
@@ -1311,8 +1315,9 @@ function toAgentFactory(def, opts) {
1311
1315
  baseDir: overrides.baseDir
1312
1316
  };
1313
1317
  const extra = buildExtraCreateOptions(overrides, compiled);
1318
+ const apiKeyResolvida = await resolverApiKey(opts.apiKey);
1314
1319
  const agent = await rt.Agent.getOrCreate(sessionId, {
1315
- apiKey: opts.apiKey,
1320
+ apiKey: apiKeyResolvida,
1316
1321
  model: buildModelSelection(model, reasoningEffort),
1317
1322
  tools: sdkTools,
1318
1323
  ...m8,
@@ -3506,4 +3511,4 @@ export {
3506
3511
  generateAgentManifest,
3507
3512
  agentsPlugin
3508
3513
  };
3509
- //# sourceMappingURL=chunk-LEHFFIEO.js.map
3514
+ //# sourceMappingURL=chunk-ZQKR6XQS.js.map