MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getAgentRuntimeImpl

Function getAgentRuntimeImpl

sdk/src/impl/agent-runtime.ts:27–115  ·  view source on GitHub ↗
(
  params: {
    logger?: Logger
    apiKey: string
    clientEnv?: ClientEnv
  } & Pick<
    AgentRuntimeScopedDeps,
    | 'handleStepsLogChunk'
    | 'requestToolCall'
    | 'requestMcpToolData'
    | 'requestFiles'
    | 'requestOptionalFile'
    | 'sendAction'
    | 'sendSubagentChunk'
  >,
)

Source from the content-addressed store, hash-verified

25const databaseAgentCache: DatabaseAgentCache = new Map()
26
27export function getAgentRuntimeImpl(
28 params: {
29 logger?: Logger
30 apiKey: string
31 clientEnv?: ClientEnv
32 } & Pick<
33 AgentRuntimeScopedDeps,
34 | 'handleStepsLogChunk'
35 | 'requestToolCall'
36 | 'requestMcpToolData'
37 | 'requestFiles'
38 | 'requestOptionalFile'
39 | 'sendAction'
40 | 'sendSubagentChunk'
41 >,
42): AgentRuntimeDeps & AgentRuntimeScopedDeps {
43 const {
44 logger,
45 apiKey,
46 clientEnv = clientEnvDefault,
47 handleStepsLogChunk,
48 requestToolCall,
49 requestMcpToolData,
50 requestFiles,
51 requestOptionalFile,
52 sendAction,
53 sendSubagentChunk,
54 } = params
55
56 const trackSdkRuntimeEvent: TrackEventFn = (eventParams) => {
57 if (
58 clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT === 'prod' &&
59 !shouldTrackAnalyticsEvent({
60 event: eventParams.event,
61 distinctId: eventParams.userId,
62 properties: eventParams.properties,
63 })
64 ) {
65 return
66 }
67
68 trackCommonEvent(eventParams)
69 }
70
71 return {
72 // Environment
73 clientEnv,
74 ciEnv: getCiEnv(),
75
76 // Database
77 getUserInfoFromApiKey,
78 fetchAgentFromDatabase,
79 startAgentRun,
80 finishAgentRun,
81 addAgentStep,
82
83 // Billing
84 consumeCreditsWithFallback: async () =>

Callers 1

runOnceFunction · 0.90

Calls 2

getCiEnvFunction · 0.90
successFunction · 0.90

Tested by

no test coverage detected