@iqai/adk 0.0.12 → 0.0.14
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/CHANGELOG.md +13 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +34 -10
- package/dist/index.mjs +33 -9
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @iqai/adk
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 25c9c8c: bug-fixes: session-managers, runner
|
|
8
|
+
new example: pglite
|
|
9
|
+
|
|
10
|
+
## 0.0.13
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 93b982b: Adds better sqlite3 dependency
|
|
15
|
+
|
|
3
16
|
## 0.0.12
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3489,9 +3489,10 @@ type index_SqliteSessionService = SqliteSessionService;
|
|
|
3489
3489
|
declare const index_SqliteSessionService: typeof SqliteSessionService;
|
|
3490
3490
|
declare const index_cloneSession: typeof cloneSession;
|
|
3491
3491
|
declare const index_generateSessionId: typeof generateSessionId;
|
|
3492
|
+
declare const index_sessionsSchema: typeof sessionsSchema;
|
|
3492
3493
|
declare const index_validateSession: typeof validateSession;
|
|
3493
3494
|
declare namespace index {
|
|
3494
|
-
export { index_InMemorySessionService as InMemorySessionService, type index_ListSessionOptions as ListSessionOptions, index_PgLiteSessionService as PgLiteSessionService, index_PostgresSessionService as PostgresSessionService, type index_Session as Session, type index_SessionService as SessionService, index_SessionState as SessionState, index_SqliteSessionService as SqliteSessionService, index_cloneSession as cloneSession, index_generateSessionId as generateSessionId, index_validateSession as validateSession };
|
|
3495
|
+
export { index_InMemorySessionService as InMemorySessionService, type index_ListSessionOptions as ListSessionOptions, index_PgLiteSessionService as PgLiteSessionService, index_PostgresSessionService as PostgresSessionService, type index_Session as Session, type index_SessionService as SessionService, index_SessionState as SessionState, index_SqliteSessionService as SqliteSessionService, index_cloneSession as cloneSession, index_generateSessionId as generateSessionId, index_sessionsSchema as sessionsSchema, index_validateSession as validateSession };
|
|
3495
3496
|
}
|
|
3496
3497
|
|
|
3497
3498
|
/**
|
|
@@ -3557,4 +3558,4 @@ declare class InMemoryRunner extends Runner {
|
|
|
3557
3558
|
|
|
3558
3559
|
declare const VERSION = "0.1.0";
|
|
3559
3560
|
|
|
3560
|
-
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingHandler, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, createSamplingHandler, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
|
|
3561
|
+
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingHandler, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, createSamplingHandler, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, sessionsSchema, validateSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -3489,9 +3489,10 @@ type index_SqliteSessionService = SqliteSessionService;
|
|
|
3489
3489
|
declare const index_SqliteSessionService: typeof SqliteSessionService;
|
|
3490
3490
|
declare const index_cloneSession: typeof cloneSession;
|
|
3491
3491
|
declare const index_generateSessionId: typeof generateSessionId;
|
|
3492
|
+
declare const index_sessionsSchema: typeof sessionsSchema;
|
|
3492
3493
|
declare const index_validateSession: typeof validateSession;
|
|
3493
3494
|
declare namespace index {
|
|
3494
|
-
export { index_InMemorySessionService as InMemorySessionService, type index_ListSessionOptions as ListSessionOptions, index_PgLiteSessionService as PgLiteSessionService, index_PostgresSessionService as PostgresSessionService, type index_Session as Session, type index_SessionService as SessionService, index_SessionState as SessionState, index_SqliteSessionService as SqliteSessionService, index_cloneSession as cloneSession, index_generateSessionId as generateSessionId, index_validateSession as validateSession };
|
|
3495
|
+
export { index_InMemorySessionService as InMemorySessionService, type index_ListSessionOptions as ListSessionOptions, index_PgLiteSessionService as PgLiteSessionService, index_PostgresSessionService as PostgresSessionService, type index_Session as Session, type index_SessionService as SessionService, index_SessionState as SessionState, index_SqliteSessionService as SqliteSessionService, index_cloneSession as cloneSession, index_generateSessionId as generateSessionId, index_sessionsSchema as sessionsSchema, index_validateSession as validateSession };
|
|
3495
3496
|
}
|
|
3496
3497
|
|
|
3497
3498
|
/**
|
|
@@ -3557,4 +3558,4 @@ declare class InMemoryRunner extends Runner {
|
|
|
3557
3558
|
|
|
3558
3559
|
declare const VERSION = "0.1.0";
|
|
3559
3560
|
|
|
3560
|
-
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingHandler, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, createSamplingHandler, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
|
|
3561
|
+
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingHandler, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, createSamplingHandler, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, sessionsSchema, validateSession };
|
package/dist/index.js
CHANGED
|
@@ -6245,6 +6245,7 @@ __export(sessions_exports, {
|
|
|
6245
6245
|
SqliteSessionService: () => SqliteSessionService,
|
|
6246
6246
|
cloneSession: () => cloneSession,
|
|
6247
6247
|
generateSessionId: () => generateSessionId,
|
|
6248
|
+
sessionsSchema: () => sessionsSchema,
|
|
6248
6249
|
validateSession: () => validateSession
|
|
6249
6250
|
});
|
|
6250
6251
|
|
|
@@ -6509,15 +6510,17 @@ var PostgresSessionService = class {
|
|
|
6509
6510
|
session.events = [];
|
|
6510
6511
|
}
|
|
6511
6512
|
session.events.push(event);
|
|
6513
|
+
if (event.content) {
|
|
6514
|
+
session.messages = session.messages || [];
|
|
6515
|
+
session.messages.push({
|
|
6516
|
+
role: event.author,
|
|
6517
|
+
content: event.content
|
|
6518
|
+
});
|
|
6519
|
+
}
|
|
6512
6520
|
session.updatedAt = /* @__PURE__ */ new Date();
|
|
6513
6521
|
await this.updateSession(session);
|
|
6514
6522
|
return event;
|
|
6515
6523
|
}
|
|
6516
|
-
// TODO: Consider if table creation/migration logic is needed here or handled externally (e.g., drizzle-kit migrations)
|
|
6517
|
-
// TODO: Implement methods corresponding to Python's append_event, list_events,
|
|
6518
|
-
// get_app_state, update_app_state, get_user_state, update_user_state
|
|
6519
|
-
// if full parity with Python's DatabaseSessionService is desired.
|
|
6520
|
-
// This would require defining corresponding Drizzle schemas for Events, AppState, UserState.
|
|
6521
6524
|
};
|
|
6522
6525
|
|
|
6523
6526
|
// src/sessions/pglite-session-service.ts
|
|
@@ -7096,6 +7099,7 @@ var Runner = class {
|
|
|
7096
7099
|
});
|
|
7097
7100
|
}
|
|
7098
7101
|
let lastPartialEvent = null;
|
|
7102
|
+
let assistantContent = "";
|
|
7099
7103
|
try {
|
|
7100
7104
|
for await (const response of this.agent.runStreaming(invocationContext)) {
|
|
7101
7105
|
const event = new Event({
|
|
@@ -7107,14 +7111,23 @@ var Runner = class {
|
|
|
7107
7111
|
partial: response.is_partial,
|
|
7108
7112
|
raw_response: response.raw_response
|
|
7109
7113
|
});
|
|
7110
|
-
|
|
7111
|
-
await this.sessionService.appendEvent(session, event);
|
|
7112
|
-
}
|
|
7114
|
+
await this.sessionService.appendEvent(session, event);
|
|
7113
7115
|
if (event.is_partial) {
|
|
7114
7116
|
lastPartialEvent = event;
|
|
7115
7117
|
}
|
|
7118
|
+
if (response.role === "assistant" && response.content) {
|
|
7119
|
+
assistantContent += response.content;
|
|
7120
|
+
}
|
|
7116
7121
|
yield event;
|
|
7117
7122
|
}
|
|
7123
|
+
if (assistantContent.trim()) {
|
|
7124
|
+
session.messages = session.messages || [];
|
|
7125
|
+
session.messages.push({
|
|
7126
|
+
role: "assistant",
|
|
7127
|
+
content: assistantContent
|
|
7128
|
+
});
|
|
7129
|
+
await this.sessionService.updateSession(session);
|
|
7130
|
+
}
|
|
7118
7131
|
} catch (error) {
|
|
7119
7132
|
console.error("Error running agent:", error);
|
|
7120
7133
|
if (lastPartialEvent && session.events && session.events.length === 0) {
|
|
@@ -7144,6 +7157,13 @@ var Runner = class {
|
|
|
7144
7157
|
author: "user",
|
|
7145
7158
|
content: typeof newMessage.content === "string" ? newMessage.content : null
|
|
7146
7159
|
});
|
|
7160
|
+
if (event.author === "user" || event.author === "assistant") {
|
|
7161
|
+
session.messages = session.messages || [];
|
|
7162
|
+
session.messages.push({
|
|
7163
|
+
role: event.author,
|
|
7164
|
+
content: event.content
|
|
7165
|
+
});
|
|
7166
|
+
}
|
|
7147
7167
|
await this.sessionService.appendEvent(session, event);
|
|
7148
7168
|
}
|
|
7149
7169
|
/**
|
|
@@ -7156,7 +7176,10 @@ var Runner = class {
|
|
|
7156
7176
|
}) {
|
|
7157
7177
|
return new InvocationContext({
|
|
7158
7178
|
sessionId: session.id,
|
|
7159
|
-
messages:
|
|
7179
|
+
messages: [
|
|
7180
|
+
...session.messages || [],
|
|
7181
|
+
...newMessage ? [newMessage] : []
|
|
7182
|
+
],
|
|
7160
7183
|
config: runConfig,
|
|
7161
7184
|
userId: session.userId,
|
|
7162
7185
|
appName: this.appName,
|
|
@@ -7259,4 +7282,5 @@ var VERSION = "0.1.0";
|
|
|
7259
7282
|
|
|
7260
7283
|
|
|
7261
7284
|
|
|
7262
|
-
|
|
7285
|
+
|
|
7286
|
+
exports.Agent = Agent; exports.Agents = agents_exports; exports.AnthropicLLM = AnthropicLLM; exports.AnthropicLLMConnection = AnthropicLLMConnection; exports.ApiKeyCredential = ApiKeyCredential; exports.ApiKeyScheme = ApiKeyScheme; exports.AuthConfig = AuthConfig; exports.AuthCredential = AuthCredential; exports.AuthCredentialType = AuthCredentialType; exports.AuthHandler = AuthHandler; exports.AuthScheme = AuthScheme; exports.AuthSchemeType = AuthSchemeType; exports.BaseAgent = BaseAgent; exports.BaseLLM = BaseLLM; exports.BaseLLMConnection = BaseLLMConnection; exports.BaseTool = BaseTool; exports.BasicAuthCredential = BasicAuthCredential; exports.BearerTokenCredential = BearerTokenCredential; exports.ExitLoopTool = ExitLoopTool; exports.FileOperationsTool = FileOperationsTool; exports.FunctionTool = FunctionTool; exports.GetUserChoiceTool = GetUserChoiceTool; exports.GoogleLLM = GoogleLLM; exports.GoogleSearch = GoogleSearch; exports.HttpRequestTool = HttpRequestTool; exports.HttpScheme = HttpScheme; exports.InMemoryMemoryService = InMemoryMemoryService; exports.InMemoryRunner = InMemoryRunner; exports.InMemorySessionService = InMemorySessionService; exports.InvocationContext = InvocationContext; exports.LLMRegistry = LLMRegistry; exports.LLMRequest = LLMRequest; exports.LLMResponse = LLMResponse; exports.LangGraphAgent = LangGraphAgent; exports.LoadMemoryTool = LoadMemoryTool; exports.LoopAgent = LoopAgent; exports.McpError = McpError; exports.McpErrorType = McpErrorType; exports.McpSamplingHandler = McpSamplingHandler; exports.McpToolset = McpToolset; exports.Memory = memory_exports; exports.Models = models_exports; exports.OAuth2Credential = OAuth2Credential; exports.OAuth2Scheme = OAuth2Scheme; exports.OpenAILLM = OpenAILLM; exports.OpenAILLMConnection = OpenAILLMConnection; exports.OpenIdConnectScheme = OpenIdConnectScheme; exports.ParallelAgent = ParallelAgent; exports.PersistentMemoryService = PersistentMemoryService; exports.PgLiteSessionService = PgLiteSessionService; exports.PostgresSessionService = PostgresSessionService; exports.RunConfig = RunConfig; exports.Runner = Runner; exports.SequentialAgent = SequentialAgent; exports.SessionState = SessionState; exports.Sessions = sessions_exports; exports.SqliteSessionService = SqliteSessionService; exports.StreamingMode = StreamingMode; exports.ToolContext = ToolContext; exports.Tools = tools_exports; exports.TransferToAgentTool = TransferToAgentTool; exports.UserInteractionTool = UserInteractionTool; exports.VERSION = VERSION; exports.adkToMcpToolType = adkToMcpToolType; exports.buildFunctionDeclaration = buildFunctionDeclaration; exports.cloneSession = cloneSession; exports.createFunctionTool = createFunctionTool; exports.createSamplingHandler = createSamplingHandler; exports.generateSessionId = generateSessionId; exports.getMcpTools = getMcpTools; exports.jsonSchemaToDeclaration = jsonSchemaToDeclaration; exports.mcpSchemaToParameters = mcpSchemaToParameters; exports.normalizeJsonSchema = normalizeJsonSchema; exports.registerProviders = registerProviders; exports.sessionsSchema = sessionsSchema; exports.validateSession = validateSession;
|
package/dist/index.mjs
CHANGED
|
@@ -6245,6 +6245,7 @@ __export(sessions_exports, {
|
|
|
6245
6245
|
SqliteSessionService: () => SqliteSessionService,
|
|
6246
6246
|
cloneSession: () => cloneSession,
|
|
6247
6247
|
generateSessionId: () => generateSessionId,
|
|
6248
|
+
sessionsSchema: () => sessionsSchema,
|
|
6248
6249
|
validateSession: () => validateSession
|
|
6249
6250
|
});
|
|
6250
6251
|
|
|
@@ -6509,15 +6510,17 @@ var PostgresSessionService = class {
|
|
|
6509
6510
|
session.events = [];
|
|
6510
6511
|
}
|
|
6511
6512
|
session.events.push(event);
|
|
6513
|
+
if (event.content) {
|
|
6514
|
+
session.messages = session.messages || [];
|
|
6515
|
+
session.messages.push({
|
|
6516
|
+
role: event.author,
|
|
6517
|
+
content: event.content
|
|
6518
|
+
});
|
|
6519
|
+
}
|
|
6512
6520
|
session.updatedAt = /* @__PURE__ */ new Date();
|
|
6513
6521
|
await this.updateSession(session);
|
|
6514
6522
|
return event;
|
|
6515
6523
|
}
|
|
6516
|
-
// TODO: Consider if table creation/migration logic is needed here or handled externally (e.g., drizzle-kit migrations)
|
|
6517
|
-
// TODO: Implement methods corresponding to Python's append_event, list_events,
|
|
6518
|
-
// get_app_state, update_app_state, get_user_state, update_user_state
|
|
6519
|
-
// if full parity with Python's DatabaseSessionService is desired.
|
|
6520
|
-
// This would require defining corresponding Drizzle schemas for Events, AppState, UserState.
|
|
6521
6524
|
};
|
|
6522
6525
|
|
|
6523
6526
|
// src/sessions/pglite-session-service.ts
|
|
@@ -7096,6 +7099,7 @@ var Runner = class {
|
|
|
7096
7099
|
});
|
|
7097
7100
|
}
|
|
7098
7101
|
let lastPartialEvent = null;
|
|
7102
|
+
let assistantContent = "";
|
|
7099
7103
|
try {
|
|
7100
7104
|
for await (const response of this.agent.runStreaming(invocationContext)) {
|
|
7101
7105
|
const event = new Event({
|
|
@@ -7107,14 +7111,23 @@ var Runner = class {
|
|
|
7107
7111
|
partial: response.is_partial,
|
|
7108
7112
|
raw_response: response.raw_response
|
|
7109
7113
|
});
|
|
7110
|
-
|
|
7111
|
-
await this.sessionService.appendEvent(session, event);
|
|
7112
|
-
}
|
|
7114
|
+
await this.sessionService.appendEvent(session, event);
|
|
7113
7115
|
if (event.is_partial) {
|
|
7114
7116
|
lastPartialEvent = event;
|
|
7115
7117
|
}
|
|
7118
|
+
if (response.role === "assistant" && response.content) {
|
|
7119
|
+
assistantContent += response.content;
|
|
7120
|
+
}
|
|
7116
7121
|
yield event;
|
|
7117
7122
|
}
|
|
7123
|
+
if (assistantContent.trim()) {
|
|
7124
|
+
session.messages = session.messages || [];
|
|
7125
|
+
session.messages.push({
|
|
7126
|
+
role: "assistant",
|
|
7127
|
+
content: assistantContent
|
|
7128
|
+
});
|
|
7129
|
+
await this.sessionService.updateSession(session);
|
|
7130
|
+
}
|
|
7118
7131
|
} catch (error) {
|
|
7119
7132
|
console.error("Error running agent:", error);
|
|
7120
7133
|
if (lastPartialEvent && session.events && session.events.length === 0) {
|
|
@@ -7144,6 +7157,13 @@ var Runner = class {
|
|
|
7144
7157
|
author: "user",
|
|
7145
7158
|
content: typeof newMessage.content === "string" ? newMessage.content : null
|
|
7146
7159
|
});
|
|
7160
|
+
if (event.author === "user" || event.author === "assistant") {
|
|
7161
|
+
session.messages = session.messages || [];
|
|
7162
|
+
session.messages.push({
|
|
7163
|
+
role: event.author,
|
|
7164
|
+
content: event.content
|
|
7165
|
+
});
|
|
7166
|
+
}
|
|
7147
7167
|
await this.sessionService.appendEvent(session, event);
|
|
7148
7168
|
}
|
|
7149
7169
|
/**
|
|
@@ -7156,7 +7176,10 @@ var Runner = class {
|
|
|
7156
7176
|
}) {
|
|
7157
7177
|
return new InvocationContext({
|
|
7158
7178
|
sessionId: session.id,
|
|
7159
|
-
messages:
|
|
7179
|
+
messages: [
|
|
7180
|
+
...session.messages || [],
|
|
7181
|
+
...newMessage ? [newMessage] : []
|
|
7182
|
+
],
|
|
7160
7183
|
config: runConfig,
|
|
7161
7184
|
userId: session.userId,
|
|
7162
7185
|
appName: this.appName,
|
|
@@ -7258,5 +7281,6 @@ export {
|
|
|
7258
7281
|
mcpSchemaToParameters,
|
|
7259
7282
|
normalizeJsonSchema,
|
|
7260
7283
|
registerProviders,
|
|
7284
|
+
sessionsSchema,
|
|
7261
7285
|
validateSession
|
|
7262
7286
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iqai/adk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Agent Development Kit for TypeScript with multi-provider LLM support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@google-cloud/vertexai": "^0.5.0",
|
|
26
26
|
"@google/genai": "^1.0.0",
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.11.1",
|
|
28
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
29
28
|
"axios": "^1.6.2",
|
|
29
|
+
"better-sqlite3": "^11.10.0",
|
|
30
30
|
"dotenv": "^16.4.7",
|
|
31
31
|
"drizzle-orm": "^0.43.1",
|
|
32
32
|
"openai": "^4.93.0",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"zod": "^3.24.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
37
38
|
"@types/node": "^20.17.30",
|
|
38
39
|
"tsup": "^8.4.0",
|
|
39
40
|
"typescript": "^5.3.2",
|