llm-agent-runtime 0.1.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.
- package/README.md +5 -0
- package/dist/agent.d.ts +20 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +37 -0
- package/dist/create-runtime.d.ts +17 -0
- package/dist/create-runtime.d.ts.map +1 -0
- package/dist/create-runtime.js +197 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/llm.d.ts +17 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +65 -0
- package/dist/redis.d.ts +9 -0
- package/dist/redis.d.ts.map +1 -0
- package/dist/redis.js +18 -0
- package/dist/services/agent-runner.d.ts +17 -0
- package/dist/services/agent-runner.d.ts.map +1 -0
- package/dist/services/agent-runner.js +18 -0
- package/dist/services/chat-cache.d.ts +16 -0
- package/dist/services/chat-cache.d.ts.map +1 -0
- package/dist/services/chat-cache.js +70 -0
- package/dist/services/conversation.d.ts +7 -0
- package/dist/services/conversation.d.ts.map +1 -0
- package/dist/services/conversation.js +56 -0
- package/dist/services/extract.d.ts +33 -0
- package/dist/services/extract.d.ts.map +1 -0
- package/dist/services/extract.js +64 -0
- package/dist/services/flow-router.d.ts +42 -0
- package/dist/services/flow-router.d.ts.map +1 -0
- package/dist/services/flow-router.js +167 -0
- package/dist/services/intent-embeddings.d.ts +17 -0
- package/dist/services/intent-embeddings.d.ts.map +1 -0
- package/dist/services/intent-embeddings.js +46 -0
- package/dist/services/intent-router.d.ts +21 -0
- package/dist/services/intent-router.d.ts.map +1 -0
- package/dist/services/intent-router.js +98 -0
- package/dist/types.d.ts +177 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/message.d.ts +9 -0
- package/dist/utils/message.d.ts.map +1 -0
- package/dist/utils/message.js +13 -0
- package/dist/utils/normalize.d.ts +3 -0
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/normalize.js +8 -0
- package/package.json +55 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
2
|
+
import type { Embeddings } from "@langchain/core/embeddings";
|
|
3
|
+
import type { DynamicStructuredTool } from "@langchain/core/tools";
|
|
4
|
+
import type { BaseCheckpointSaver } from "@langchain/langgraph-checkpoint";
|
|
5
|
+
/** Intent catalog entry used for embedding routing + sticky-flow rules. */
|
|
6
|
+
export type IntentDefinition = {
|
|
7
|
+
name: string;
|
|
8
|
+
examples: string[];
|
|
9
|
+
/** Persist this intent across turns until finalize marks complete. */
|
|
10
|
+
sticky?: boolean;
|
|
11
|
+
/** Short description for the LLM intent router. */
|
|
12
|
+
description?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Context passed into prompt builders (app-defined shape). */
|
|
15
|
+
export type PromptContext = {
|
|
16
|
+
hasConversationHistory: boolean;
|
|
17
|
+
intent: string;
|
|
18
|
+
intentScore?: number;
|
|
19
|
+
message?: string;
|
|
20
|
+
/** Arbitrary app context (userInfo, contactName, phone, etc.). */
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
export type IntentBinding = {
|
|
24
|
+
prompt: (ctx: PromptContext) => string;
|
|
25
|
+
tools: (phoneKey: string) => DynamicStructuredTool[];
|
|
26
|
+
};
|
|
27
|
+
export type IntentRegistry = Record<string, IntentBinding>;
|
|
28
|
+
export type DetectedIntentResult = {
|
|
29
|
+
intent: string;
|
|
30
|
+
score: number;
|
|
31
|
+
};
|
|
32
|
+
export type LlmIntentResult = DetectedIntentResult & {
|
|
33
|
+
action: "continue" | "switch" | "cancel";
|
|
34
|
+
reason?: string;
|
|
35
|
+
};
|
|
36
|
+
export type FlowState = {
|
|
37
|
+
active: boolean;
|
|
38
|
+
intent: string | null;
|
|
39
|
+
};
|
|
40
|
+
export type ChatFlowState = {
|
|
41
|
+
intent: string;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
};
|
|
44
|
+
export type FlowResolution = {
|
|
45
|
+
messageIntent: DetectedIntentResult;
|
|
46
|
+
flow: FlowState;
|
|
47
|
+
promptIntent: string;
|
|
48
|
+
llmResult?: LlmIntentResult;
|
|
49
|
+
};
|
|
50
|
+
export type LlmProvider = "ollama" | "openai";
|
|
51
|
+
export type LlmConfig = {
|
|
52
|
+
provider: LlmProvider;
|
|
53
|
+
model: string;
|
|
54
|
+
intentRouterModel?: string;
|
|
55
|
+
embeddingsModel?: string;
|
|
56
|
+
embeddingsProvider?: LlmProvider;
|
|
57
|
+
baseUrl?: string;
|
|
58
|
+
apiKey?: string;
|
|
59
|
+
temperature?: number;
|
|
60
|
+
};
|
|
61
|
+
export type CacheConfig = {
|
|
62
|
+
/** Exact-match answer cache (Redis). Default false. */
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
/** TTL for cached answers in seconds. Default 24h. */
|
|
65
|
+
ttlSeconds?: number;
|
|
66
|
+
/** TTL for sticky flow state. Default 30m. */
|
|
67
|
+
flowTtlSeconds?: number;
|
|
68
|
+
scope?: string;
|
|
69
|
+
};
|
|
70
|
+
export type TracingConfig = {
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
projectName?: string;
|
|
73
|
+
};
|
|
74
|
+
export type ToolCall = {
|
|
75
|
+
name?: string;
|
|
76
|
+
args?: Record<string, unknown>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Per-tool parser (same idea as Xel extractToolCall switch cases).
|
|
80
|
+
* Mutate `acc` to accumulate structured outputs; skip if already set (first-wins).
|
|
81
|
+
*/
|
|
82
|
+
export type ToolExtractor = (args: Record<string, unknown>, acc: Record<string, unknown>) => void;
|
|
83
|
+
/** toolName → extractor. Keys are LangChain tool `name` values. */
|
|
84
|
+
export type ToolExtractorMap = Record<string, ToolExtractor>;
|
|
85
|
+
export type FinalizeFlowInput = {
|
|
86
|
+
threadId: string;
|
|
87
|
+
promptIntent: string;
|
|
88
|
+
flow: FlowState;
|
|
89
|
+
toolOutputs: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
export type FinalizeFlowResult = {
|
|
92
|
+
flow: FlowState;
|
|
93
|
+
flowCompleted: boolean;
|
|
94
|
+
/** Extra fields the app wants returned from invoke (campaign, tickets, …). */
|
|
95
|
+
extras?: Record<string, unknown>;
|
|
96
|
+
};
|
|
97
|
+
export type InvokeInput = {
|
|
98
|
+
message: string;
|
|
99
|
+
threadId: string;
|
|
100
|
+
/** App context passed to prompts and optional phoneKey helper. */
|
|
101
|
+
context?: Record<string, unknown>;
|
|
102
|
+
/** Force an intent (skips hybrid routing). */
|
|
103
|
+
explicitIntent?: string;
|
|
104
|
+
phoneKey?: string;
|
|
105
|
+
};
|
|
106
|
+
export type InvokeResult = {
|
|
107
|
+
messages: unknown[];
|
|
108
|
+
answer?: string;
|
|
109
|
+
intent: DetectedIntentResult;
|
|
110
|
+
flow: FlowState;
|
|
111
|
+
toolOutputs: Record<string, unknown>;
|
|
112
|
+
flowCompleted: boolean;
|
|
113
|
+
router?: {
|
|
114
|
+
action: LlmIntentResult["action"];
|
|
115
|
+
reason?: string;
|
|
116
|
+
};
|
|
117
|
+
extras?: Record<string, unknown>;
|
|
118
|
+
};
|
|
119
|
+
export type AgentRuntimeConfig = {
|
|
120
|
+
redisUrl?: string;
|
|
121
|
+
llm: LlmConfig;
|
|
122
|
+
/** Intent catalog for embeddings + sticky flags. */
|
|
123
|
+
intents: IntentDefinition[];
|
|
124
|
+
/** Per-intent prompt + tools factory. */
|
|
125
|
+
intentRegistry: IntentRegistry;
|
|
126
|
+
/** Digit / short-code → intent (e.g. greeting menu "1" → create_campaign). */
|
|
127
|
+
menuMap?: Record<string, string>;
|
|
128
|
+
/** Map legacy/alias names onto catalog intents. */
|
|
129
|
+
intentAliases?: Record<string, string>;
|
|
130
|
+
defaultIntent?: string;
|
|
131
|
+
/** Override LLM router system prompt. */
|
|
132
|
+
routerSystemPrompt?: string | ((intents: IntentDefinition[]) => string);
|
|
133
|
+
/** Custom system prompt builder; default uses intentRegistry[intent].prompt. */
|
|
134
|
+
buildSystemPrompt?: (ctx: PromptContext) => string;
|
|
135
|
+
/**
|
|
136
|
+
* Per-tool extractors (Xel extractToolCall style).
|
|
137
|
+
* Prefer this over a custom `extractToolOutputs` unless you need full control.
|
|
138
|
+
*/
|
|
139
|
+
toolExtractors?: ToolExtractorMap;
|
|
140
|
+
/** Seed object for tool extractors (e.g. () => ({ tickets: [] })). */
|
|
141
|
+
initialToolOutputs?: () => Record<string, unknown>;
|
|
142
|
+
/** If true, unknown tool names are kept as raw args. Default false when using toolExtractors. */
|
|
143
|
+
includeUnknownToolOutputs?: boolean;
|
|
144
|
+
/** Full custom extractor. Overrides toolExtractors when provided. */
|
|
145
|
+
extractToolOutputs?: (messages: unknown[]) => Record<string, unknown>;
|
|
146
|
+
/**
|
|
147
|
+
* Decide when a sticky flow is done.
|
|
148
|
+
* Default: never auto-complete (app must clear via finalize or clearFlow).
|
|
149
|
+
*/
|
|
150
|
+
finalizeFlow?: (input: FinalizeFlowInput) => FinalizeFlowResult | Promise<FinalizeFlowResult>;
|
|
151
|
+
/** Derive phone/session key for tools. Default: phoneKey ?? threadId. */
|
|
152
|
+
resolvePhoneKey?: (input: {
|
|
153
|
+
threadId: string;
|
|
154
|
+
phoneKey?: string;
|
|
155
|
+
context?: Record<string, unknown>;
|
|
156
|
+
}) => string;
|
|
157
|
+
cache?: CacheConfig;
|
|
158
|
+
tracing?: TracingConfig;
|
|
159
|
+
recursionLimit?: number;
|
|
160
|
+
/** Sticky-flow switch thresholds (defaults match Xel-agent). */
|
|
161
|
+
thresholds?: {
|
|
162
|
+
switch?: number;
|
|
163
|
+
ambiguous?: number;
|
|
164
|
+
switchMargin?: number;
|
|
165
|
+
llmConfidence?: number;
|
|
166
|
+
embeddingConfidence?: number;
|
|
167
|
+
};
|
|
168
|
+
/** Inject pre-built models instead of creating from llm config. */
|
|
169
|
+
models?: {
|
|
170
|
+
chat?: BaseChatModel;
|
|
171
|
+
intentRouter?: BaseChatModel;
|
|
172
|
+
embeddings?: Embeddings;
|
|
173
|
+
};
|
|
174
|
+
/** Inject a custom checkpointer (skips redisUrl / MemorySaver). */
|
|
175
|
+
checkpointer?: BaseCheckpointSaver;
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG;IAC1B,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,qBAAqB,EAAE,CAAC;CACtD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s?: {
|
|
4
|
+
content?: unknown;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/** Returns the content of the most recent non-empty message. */
|
|
8
|
+
export declare const getLastMessageContent: (messages: CachedMessage[] | undefined) => string | undefined;
|
|
9
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/utils/message.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,GAChC,UAAU,aAAa,EAAE,GAAG,SAAS,KACpC,MAAM,GAAG,SAcX,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Returns the content of the most recent non-empty message. */
|
|
2
|
+
export const getLastMessageContent = (messages) => {
|
|
3
|
+
if (!Array.isArray(messages)) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
for (const message of messages.toReversed()) {
|
|
7
|
+
const content = message.content ?? message.kwargs?.content;
|
|
8
|
+
if (typeof content === "string" && content.trim()) {
|
|
9
|
+
return content;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM9C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "llm-agent-runtime",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable LangGraph agent runtime: intent routing, sticky flows, Redis checkpointer, optional answer cache",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
|
+
"test": "tsx --test src/**/*.test.ts",
|
|
23
|
+
"prepublishOnly": "pnpm build && pnpm test"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@langchain/core": "^1.2.0",
|
|
33
|
+
"@langchain/langgraph": "^1.4.0",
|
|
34
|
+
"@langchain/langgraph-checkpoint": "^1.1.0",
|
|
35
|
+
"zod": "^4.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@langchain/langgraph-checkpoint-redis": "^1.0.10",
|
|
39
|
+
"@langchain/ollama": "^1.3.0",
|
|
40
|
+
"@langchain/openai": "^1.5.1",
|
|
41
|
+
"redis": "^6.0.0"
|
|
42
|
+
},
|
|
43
|
+
"optionalDependencies": {
|
|
44
|
+
"langsmith": "^0.7.10"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@langchain/core": "^1.2.0",
|
|
48
|
+
"@langchain/langgraph": "^1.4.4",
|
|
49
|
+
"@langchain/langgraph-checkpoint": "^1.1.2",
|
|
50
|
+
"@types/node": "^25.9.3",
|
|
51
|
+
"tsx": "^4.23.0",
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"zod": "^4.4.3"
|
|
54
|
+
}
|
|
55
|
+
}
|