@inkeep/agents-run-api 0.0.0-dev-20260113172432 → 0.0.0-dev-20260114183157
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/agents/Agent.js +10 -17
- package/dist/agents/types.d.ts +4 -2
- package/dist/agents/versions/v1/Phase1Config.d.ts +4 -3
- package/dist/agents/versions/v1/Phase1Config.js +20 -12
- package/dist/create-app.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/utils/token-estimator.d.ts +6 -52
- package/dist/utils/token-estimator.js +2 -38
- package/package.json +2 -2
package/dist/agents/Agent.js
CHANGED
|
@@ -19,7 +19,7 @@ import { withJsonPostProcessing } from "../utils/json-postprocessor.js";
|
|
|
19
19
|
import { calculateBreakdownTotal, estimateTokens } from "../utils/token-estimator.js";
|
|
20
20
|
import { createDelegateToAgentTool, createTransferToAgentTool } from "./relationTools.js";
|
|
21
21
|
import { SystemPromptBuilder } from "./SystemPromptBuilder.js";
|
|
22
|
-
import { Phase1Config } from "./versions/v1/Phase1Config.js";
|
|
22
|
+
import { Phase1Config, V1_BREAKDOWN_SCHEMA } from "./versions/v1/Phase1Config.js";
|
|
23
23
|
import { Phase2Config } from "./versions/v1/Phase2Config.js";
|
|
24
24
|
import { z } from "@hono/zod-openapi";
|
|
25
25
|
import { ContextResolver, CredentialStuffer, MCPServerType, MCPTransportType, McpClient, ModelFactory, TemplateEngine, agentHasArtifactComponents, createMessage, generateId, getContextConfigById, getCredentialReference, getFullAgentDefinition, getFunction, getFunctionToolsForSubAgent, getLedgerArtifacts, getToolsForAgent, getUserScopedCredentialReference, listTaskIdsByContextId, parseEmbeddedJson } from "@inkeep/agents-core";
|
|
@@ -1316,20 +1316,10 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
|
|
|
1316
1316
|
const conversationId = runtimeContext?.metadata?.conversationId;
|
|
1317
1317
|
if (conversationId) this.setConversationId(conversationId);
|
|
1318
1318
|
const { conversationHistory, contextBreakdown } = await this.buildConversationHistory(contextId, taskId, userMessage, streamRequestId, initialContextBreakdown);
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
"context.breakdown.tools_tokens": contextBreakdown.toolsSection,
|
|
1324
|
-
"context.breakdown.artifacts_tokens": contextBreakdown.artifactsSection,
|
|
1325
|
-
"context.breakdown.data_components_tokens": contextBreakdown.dataComponents,
|
|
1326
|
-
"context.breakdown.artifact_components_tokens": contextBreakdown.artifactComponents,
|
|
1327
|
-
"context.breakdown.transfer_instructions_tokens": contextBreakdown.transferInstructions,
|
|
1328
|
-
"context.breakdown.delegation_instructions_tokens": contextBreakdown.delegationInstructions,
|
|
1329
|
-
"context.breakdown.thinking_preparation_tokens": contextBreakdown.thinkingPreparation,
|
|
1330
|
-
"context.breakdown.conversation_history_tokens": contextBreakdown.conversationHistory,
|
|
1331
|
-
"context.breakdown.total_tokens": contextBreakdown.total
|
|
1332
|
-
});
|
|
1319
|
+
const breakdownAttributes = {};
|
|
1320
|
+
for (const componentDef of V1_BREAKDOWN_SCHEMA) breakdownAttributes[componentDef.spanAttribute] = contextBreakdown.components[componentDef.key] ?? 0;
|
|
1321
|
+
breakdownAttributes["context.breakdown.total_tokens"] = contextBreakdown.total;
|
|
1322
|
+
span.setAttributes(breakdownAttributes);
|
|
1333
1323
|
const { primaryModelSettings, modelSettings, hasStructuredOutput, shouldStreamPhase1, timeoutMs } = this.configureModelSettings();
|
|
1334
1324
|
let response;
|
|
1335
1325
|
let textResponse;
|
|
@@ -1499,8 +1489,11 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
|
|
|
1499
1489
|
}
|
|
1500
1490
|
const conversationHistoryTokens = estimateTokens(conversationHistory);
|
|
1501
1491
|
const updatedContextBreakdown = {
|
|
1502
|
-
|
|
1503
|
-
|
|
1492
|
+
components: {
|
|
1493
|
+
...initialContextBreakdown.components,
|
|
1494
|
+
conversationHistory: conversationHistoryTokens
|
|
1495
|
+
},
|
|
1496
|
+
total: initialContextBreakdown.total
|
|
1504
1497
|
};
|
|
1505
1498
|
calculateBreakdownTotal(updatedContextBreakdown);
|
|
1506
1499
|
return {
|
package/dist/agents/types.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { AssembleResult } from "../utils/token-estimator.js";
|
|
2
|
-
import { Artifact, ArtifactComponentApiInsert, DataComponentApiInsert } from "@inkeep/agents-core";
|
|
2
|
+
import { Artifact, ArtifactComponentApiInsert, BreakdownComponentDef, DataComponentApiInsert } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/agents/types.d.ts
|
|
5
5
|
interface VersionConfig<TConfig> {
|
|
6
6
|
loadTemplates(): Map<string, string>;
|
|
7
7
|
assemble(templates: Map<string, string>, config: TConfig): AssembleResult;
|
|
8
|
+
/** Returns the breakdown schema defining which components this version tracks */
|
|
9
|
+
getBreakdownSchema(): BreakdownComponentDef[];
|
|
8
10
|
}
|
|
9
11
|
interface SystemPromptV1 {
|
|
10
12
|
corePrompt: string;
|
|
@@ -25,4 +27,4 @@ interface ToolData {
|
|
|
25
27
|
usageGuidelines?: string;
|
|
26
28
|
}
|
|
27
29
|
//#endregion
|
|
28
|
-
export { SystemPromptV1, ToolData, VersionConfig };
|
|
30
|
+
export { type BreakdownComponentDef, SystemPromptV1, ToolData, VersionConfig };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { AssembleResult } from "../../../utils/token-estimator.js";
|
|
1
|
+
import { AssembleResult, BreakdownComponentDef } from "../../../utils/token-estimator.js";
|
|
2
2
|
import { SystemPromptV1, ToolData, VersionConfig } from "../../types.js";
|
|
3
|
-
import { McpTool } from "@inkeep/agents-core";
|
|
3
|
+
import { McpTool, V1_BREAKDOWN_SCHEMA } from "@inkeep/agents-core";
|
|
4
4
|
|
|
5
5
|
//#region src/agents/versions/v1/Phase1Config.d.ts
|
|
6
6
|
declare class Phase1Config implements VersionConfig<SystemPromptV1> {
|
|
7
7
|
loadTemplates(): Map<string, string>;
|
|
8
|
+
getBreakdownSchema(): BreakdownComponentDef[];
|
|
8
9
|
static convertMcpToolsToToolData(mcpTools: McpTool[] | undefined): ToolData[];
|
|
9
10
|
private isToolDataArray;
|
|
10
11
|
private normalizeSchema;
|
|
@@ -24,4 +25,4 @@ declare class Phase1Config implements VersionConfig<SystemPromptV1> {
|
|
|
24
25
|
private generateParametersXml;
|
|
25
26
|
}
|
|
26
27
|
//#endregion
|
|
27
|
-
export { Phase1Config };
|
|
28
|
+
export { Phase1Config, V1_BREAKDOWN_SCHEMA };
|
|
@@ -5,6 +5,7 @@ import thinking_preparation_default from "../../../_virtual/_raw_/home/runner/wo
|
|
|
5
5
|
import tool_default from "../../../_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/phase1/tool.js";
|
|
6
6
|
import artifact_default from "../../../_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/shared/artifact.js";
|
|
7
7
|
import artifact_retrieval_guidance_default from "../../../_virtual/_raw_/home/runner/work/agents/agents/agents-run-api/templates/v1/shared/artifact-retrieval-guidance.js";
|
|
8
|
+
import { V1_BREAKDOWN_SCHEMA } from "@inkeep/agents-core";
|
|
8
9
|
import { convertZodToJsonSchema, isZodSchema } from "@inkeep/agents-core/utils/schema-conversion";
|
|
9
10
|
|
|
10
11
|
//#region src/agents/versions/v1/Phase1Config.ts
|
|
@@ -19,6 +20,9 @@ var Phase1Config = class Phase1Config {
|
|
|
19
20
|
templates.set("thinking-preparation", thinking_preparation_default);
|
|
20
21
|
return templates;
|
|
21
22
|
}
|
|
23
|
+
getBreakdownSchema() {
|
|
24
|
+
return V1_BREAKDOWN_SCHEMA;
|
|
25
|
+
}
|
|
22
26
|
static convertMcpToolsToToolData(mcpTools) {
|
|
23
27
|
if (!mcpTools || mcpTools.length === 0) return [];
|
|
24
28
|
const toolData = [];
|
|
@@ -45,17 +49,17 @@ var Phase1Config = class Phase1Config {
|
|
|
45
49
|
return inputSchema;
|
|
46
50
|
}
|
|
47
51
|
assemble(templates, config) {
|
|
48
|
-
const breakdown = createEmptyBreakdown();
|
|
52
|
+
const breakdown = createEmptyBreakdown(this.getBreakdownSchema());
|
|
49
53
|
const systemPromptTemplateContent = templates.get("system-prompt");
|
|
50
54
|
if (!systemPromptTemplateContent) throw new Error("System prompt template not loaded");
|
|
51
|
-
breakdown.systemPromptTemplate = estimateTokens(systemPromptTemplateContent.replace("{{CORE_INSTRUCTIONS}}", "").replace("{{AGENT_CONTEXT_SECTION}}", "").replace("{{ARTIFACTS_SECTION}}", "").replace("{{TOOLS_SECTION}}", "").replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", "").replace("{{TRANSFER_INSTRUCTIONS}}", "").replace("{{DELEGATION_INSTRUCTIONS}}", ""));
|
|
55
|
+
breakdown.components["systemPromptTemplate"] = estimateTokens(systemPromptTemplateContent.replace("{{CORE_INSTRUCTIONS}}", "").replace("{{AGENT_CONTEXT_SECTION}}", "").replace("{{ARTIFACTS_SECTION}}", "").replace("{{TOOLS_SECTION}}", "").replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", "").replace("{{TRANSFER_INSTRUCTIONS}}", "").replace("{{DELEGATION_INSTRUCTIONS}}", ""));
|
|
52
56
|
let systemPrompt = systemPromptTemplateContent;
|
|
53
57
|
if (config.corePrompt && config.corePrompt.trim()) {
|
|
54
|
-
breakdown.coreInstructions = estimateTokens(config.corePrompt);
|
|
58
|
+
breakdown.components["coreInstructions"] = estimateTokens(config.corePrompt);
|
|
55
59
|
systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
|
|
56
60
|
} else systemPrompt = systemPrompt.replace(/<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g, "");
|
|
57
61
|
const agentContextSection = this.generateAgentContextSection(config.prompt);
|
|
58
|
-
breakdown.agentPrompt = estimateTokens(agentContextSection);
|
|
62
|
+
breakdown.components["agentPrompt"] = estimateTokens(agentContextSection);
|
|
59
63
|
systemPrompt = systemPrompt.replace("{{AGENT_CONTEXT_SECTION}}", agentContextSection);
|
|
60
64
|
const toolData = (this.isToolDataArray(config.tools) ? config.tools : Phase1Config.convertMcpToolsToToolData(config.tools)).map((tool) => ({
|
|
61
65
|
...tool,
|
|
@@ -64,21 +68,25 @@ var Phase1Config = class Phase1Config {
|
|
|
64
68
|
const hasArtifactComponents = Boolean(config.artifactComponents && config.artifactComponents.length > 0);
|
|
65
69
|
const artifactsSection = this.generateArtifactsSection(templates, config.artifacts, hasArtifactComponents, config.artifactComponents, config.hasAgentArtifactComponents);
|
|
66
70
|
const artifactInstructionsTokens = this.getArtifactInstructionsTokens(templates, hasArtifactComponents, config.artifactComponents, config.hasAgentArtifactComponents, (config.artifacts?.length ?? 0) > 0);
|
|
67
|
-
breakdown.systemPromptTemplate += artifactInstructionsTokens;
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
breakdown.components["systemPromptTemplate"] += artifactInstructionsTokens;
|
|
72
|
+
const actualArtifactsXml = config.artifacts?.length > 0 ? config.artifacts.map((artifact) => this.generateArtifactXml(templates, artifact)).join("\n ") : "";
|
|
73
|
+
breakdown.components["artifactsSection"] = estimateTokens(actualArtifactsXml);
|
|
74
|
+
if (hasArtifactComponents) {
|
|
75
|
+
const creationInstructions = this.getArtifactCreationInstructions(hasArtifactComponents, config.artifactComponents);
|
|
76
|
+
breakdown.components["artifactComponents"] = estimateTokens(creationInstructions);
|
|
77
|
+
}
|
|
70
78
|
systemPrompt = systemPrompt.replace("{{ARTIFACTS_SECTION}}", artifactsSection);
|
|
71
79
|
const toolsSection = this.generateToolsSection(templates, toolData);
|
|
72
|
-
breakdown.toolsSection = estimateTokens(toolsSection);
|
|
80
|
+
breakdown.components["toolsSection"] = estimateTokens(toolsSection);
|
|
73
81
|
systemPrompt = systemPrompt.replace("{{TOOLS_SECTION}}", toolsSection);
|
|
74
82
|
const thinkingPreparationSection = this.generateThinkingPreparationSection(templates, config.isThinkingPreparation);
|
|
75
|
-
breakdown.thinkingPreparation = estimateTokens(thinkingPreparationSection);
|
|
83
|
+
breakdown.components["thinkingPreparation"] = estimateTokens(thinkingPreparationSection);
|
|
76
84
|
systemPrompt = systemPrompt.replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", thinkingPreparationSection);
|
|
77
85
|
const transferSection = this.generateTransferInstructions(config.hasTransferRelations);
|
|
78
|
-
breakdown.transferInstructions = estimateTokens(transferSection);
|
|
86
|
+
breakdown.components["transferInstructions"] = estimateTokens(transferSection);
|
|
79
87
|
systemPrompt = systemPrompt.replace("{{TRANSFER_INSTRUCTIONS}}", transferSection);
|
|
80
88
|
const delegationSection = this.generateDelegationInstructions(config.hasDelegateRelations);
|
|
81
|
-
breakdown.delegationInstructions = estimateTokens(delegationSection);
|
|
89
|
+
breakdown.components["delegationInstructions"] = estimateTokens(delegationSection);
|
|
82
90
|
systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
|
|
83
91
|
calculateBreakdownTotal(breakdown);
|
|
84
92
|
return {
|
|
@@ -432,4 +440,4 @@ ${creationInstructions}
|
|
|
432
440
|
};
|
|
433
441
|
|
|
434
442
|
//#endregion
|
|
435
|
-
export { Phase1Config };
|
|
443
|
+
export { Phase1Config, V1_BREAKDOWN_SCHEMA };
|
package/dist/create-app.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SandboxConfig } from "./types/execution-context.js";
|
|
2
2
|
import { CredentialStoreRegistry, ServerConfig } from "@inkeep/agents-core";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
|
-
import * as
|
|
4
|
+
import * as hono_types0 from "hono/types";
|
|
5
5
|
|
|
6
6
|
//#region src/create-app.d.ts
|
|
7
|
-
declare function createExecutionHono(serverConfig: ServerConfig, credentialStores: CredentialStoreRegistry, sandboxConfig?: SandboxConfig): Hono<
|
|
7
|
+
declare function createExecutionHono(serverConfig: ServerConfig, credentialStores: CredentialStoreRegistry, sandboxConfig?: SandboxConfig): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { createExecutionHono };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { createExecutionHono } from "./create-app.js";
|
|
|
3
3
|
import "./env.js";
|
|
4
4
|
import { CredentialStore, ServerConfig } from "@inkeep/agents-core";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
|
-
import * as
|
|
6
|
+
import * as hono_types1 from "hono/types";
|
|
7
7
|
|
|
8
8
|
//#region src/index.d.ts
|
|
9
|
-
declare const app: Hono<
|
|
9
|
+
declare const app: Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
|
|
10
10
|
declare function createExecutionApp(config?: {
|
|
11
11
|
serverConfig?: ServerConfig;
|
|
12
12
|
credentialStores?: CredentialStore[];
|
|
13
13
|
sandboxConfig?: SandboxConfig;
|
|
14
|
-
}): Hono<
|
|
14
|
+
}): Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { Hono, type NativeSandboxConfig, type SandboxConfig, type VercelSandboxConfig, createExecutionApp, createExecutionHono, app as default };
|
|
@@ -1,47 +1,8 @@
|
|
|
1
|
+
import * as _inkeep_agents_core1 from "@inkeep/agents-core";
|
|
2
|
+
import { BreakdownComponentDef, ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown } from "@inkeep/agents-core";
|
|
3
|
+
|
|
1
4
|
//#region src/utils/token-estimator.d.ts
|
|
2
|
-
|
|
3
|
-
* Token estimation utility for context tracking.
|
|
4
|
-
*
|
|
5
|
-
* Uses character-based approximation (~4 characters per token) which:
|
|
6
|
-
* - Works universally for all models (OpenAI, Anthropic, Gemini, custom)
|
|
7
|
-
* - Requires no external dependencies
|
|
8
|
-
* - Is fast (simple string length calculation)
|
|
9
|
-
* - Is accurate enough for relative comparisons between context components
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Breakdown of estimated token usage for each context component.
|
|
13
|
-
* All values are approximate token counts.
|
|
14
|
-
*/
|
|
15
|
-
interface ContextBreakdown {
|
|
16
|
-
/** Base system prompt template tokens */
|
|
17
|
-
systemPromptTemplate: number;
|
|
18
|
-
/** Core instructions (corePrompt) tokens */
|
|
19
|
-
coreInstructions: number;
|
|
20
|
-
/** Agent-level context (prompt) tokens */
|
|
21
|
-
agentPrompt: number;
|
|
22
|
-
/** Tools section (MCP, function, relation tools) tokens */
|
|
23
|
-
toolsSection: number;
|
|
24
|
-
/** Artifacts section tokens */
|
|
25
|
-
artifactsSection: number;
|
|
26
|
-
/** Data components section tokens (Phase 2) */
|
|
27
|
-
dataComponents: number;
|
|
28
|
-
/** Artifact component instructions tokens */
|
|
29
|
-
artifactComponents: number;
|
|
30
|
-
/** Transfer instructions tokens */
|
|
31
|
-
transferInstructions: number;
|
|
32
|
-
/** Delegation instructions tokens */
|
|
33
|
-
delegationInstructions: number;
|
|
34
|
-
/** Thinking preparation instructions tokens */
|
|
35
|
-
thinkingPreparation: number;
|
|
36
|
-
/** Conversation history tokens */
|
|
37
|
-
conversationHistory: number;
|
|
38
|
-
/** Total estimated tokens */
|
|
39
|
-
total: number;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Creates an empty context breakdown with all values set to 0.
|
|
43
|
-
*/
|
|
44
|
-
declare function createEmptyBreakdown(): ContextBreakdown;
|
|
5
|
+
|
|
45
6
|
/**
|
|
46
7
|
* Estimates the number of tokens in a text string using character-based approximation.
|
|
47
8
|
*
|
|
@@ -49,13 +10,6 @@ declare function createEmptyBreakdown(): ContextBreakdown;
|
|
|
49
10
|
* @returns Estimated token count (approximately text.length / 4)
|
|
50
11
|
*/
|
|
51
12
|
declare function estimateTokens(text: string | undefined | null): number;
|
|
52
|
-
/**
|
|
53
|
-
* Calculates the total from all breakdown components and updates the total field.
|
|
54
|
-
*
|
|
55
|
-
* @param breakdown - The context breakdown to calculate total for
|
|
56
|
-
* @returns The breakdown with updated total
|
|
57
|
-
*/
|
|
58
|
-
declare function calculateBreakdownTotal(breakdown: ContextBreakdown): ContextBreakdown;
|
|
59
13
|
/**
|
|
60
14
|
* Result from prompt assembly that includes both the prompt and token breakdown.
|
|
61
15
|
*/
|
|
@@ -63,7 +17,7 @@ interface AssembleResult {
|
|
|
63
17
|
/** The assembled prompt string */
|
|
64
18
|
prompt: string;
|
|
65
19
|
/** Token breakdown for each component */
|
|
66
|
-
breakdown: ContextBreakdown;
|
|
20
|
+
breakdown: _inkeep_agents_core1.ContextBreakdown;
|
|
67
21
|
}
|
|
68
22
|
//#endregion
|
|
69
|
-
export { AssembleResult, ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
|
|
23
|
+
export { AssembleResult, type BreakdownComponentDef, type ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
+
import { calculateBreakdownTotal, createEmptyBreakdown } from "@inkeep/agents-core";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/token-estimator.ts
|
|
2
|
-
/**
|
|
3
|
-
* Token estimation utility for context tracking.
|
|
4
|
-
*
|
|
5
|
-
* Uses character-based approximation (~4 characters per token) which:
|
|
6
|
-
* - Works universally for all models (OpenAI, Anthropic, Gemini, custom)
|
|
7
|
-
* - Requires no external dependencies
|
|
8
|
-
* - Is fast (simple string length calculation)
|
|
9
|
-
* - Is accurate enough for relative comparisons between context components
|
|
10
|
-
*/
|
|
11
4
|
const CHARS_PER_TOKEN = 4;
|
|
12
5
|
/**
|
|
13
|
-
* Creates an empty context breakdown with all values set to 0.
|
|
14
|
-
*/
|
|
15
|
-
function createEmptyBreakdown() {
|
|
16
|
-
return {
|
|
17
|
-
systemPromptTemplate: 0,
|
|
18
|
-
coreInstructions: 0,
|
|
19
|
-
agentPrompt: 0,
|
|
20
|
-
toolsSection: 0,
|
|
21
|
-
artifactsSection: 0,
|
|
22
|
-
dataComponents: 0,
|
|
23
|
-
artifactComponents: 0,
|
|
24
|
-
transferInstructions: 0,
|
|
25
|
-
delegationInstructions: 0,
|
|
26
|
-
thinkingPreparation: 0,
|
|
27
|
-
conversationHistory: 0,
|
|
28
|
-
total: 0
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
6
|
* Estimates the number of tokens in a text string using character-based approximation.
|
|
33
7
|
*
|
|
34
8
|
* @param text - The text to estimate tokens for
|
|
@@ -38,16 +12,6 @@ function estimateTokens(text) {
|
|
|
38
12
|
if (!text) return 0;
|
|
39
13
|
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
40
14
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Calculates the total from all breakdown components and updates the total field.
|
|
43
|
-
*
|
|
44
|
-
* @param breakdown - The context breakdown to calculate total for
|
|
45
|
-
* @returns The breakdown with updated total
|
|
46
|
-
*/
|
|
47
|
-
function calculateBreakdownTotal(breakdown) {
|
|
48
|
-
breakdown.total = breakdown.systemPromptTemplate + breakdown.coreInstructions + breakdown.agentPrompt + breakdown.toolsSection + breakdown.artifactsSection + breakdown.dataComponents + breakdown.artifactComponents + breakdown.transferInstructions + breakdown.delegationInstructions + breakdown.thinkingPreparation + breakdown.conversationHistory;
|
|
49
|
-
return breakdown;
|
|
50
|
-
}
|
|
51
15
|
|
|
52
16
|
//#endregion
|
|
53
17
|
export { calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260114183157",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"hono": "^4.10.4",
|
|
42
42
|
"jmespath": "^0.16.0",
|
|
43
43
|
"llm-info": "^1.0.69",
|
|
44
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
44
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260114183157"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@hono/zod-openapi": "^1.1.5",
|