@economic/agents 2.3.11 → 2.3.13
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/index.d.mts +4 -10
- package/dist/index.mjs +10 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -25,11 +25,6 @@ interface AgentEnv {
|
|
|
25
25
|
type SqlFn = InstanceType<typeof Agent$1>["sql"];
|
|
26
26
|
type AgentConnectionStatus = "connecting" | "connected" | "disconnected" | "unauthorized";
|
|
27
27
|
type AgentConnectionType = "agent" | "chat" | "assistant";
|
|
28
|
-
type AgentConnectionState = {
|
|
29
|
-
status: AgentConnectionStatus;
|
|
30
|
-
type: AgentConnectionType; /** Set by `Assistant` so clients can derive the sub-agent routing name from state. */
|
|
31
|
-
subAgentName?: string;
|
|
32
|
-
};
|
|
33
28
|
//#endregion
|
|
34
29
|
//#region src/server/util/tools.d.ts
|
|
35
30
|
type ToolSet = Record<string, Tool>;
|
|
@@ -39,7 +34,7 @@ type Tool<Context extends Record<string, unknown> = Record<string, unknown>, INP
|
|
|
39
34
|
declare function tool<Context extends Record<string, unknown> = Record<string, unknown>, INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any>(tool: Tool<Context, INPUT, OUTPUT>): Tool$1<INPUT, OUTPUT>;
|
|
40
35
|
//#endregion
|
|
41
36
|
//#region src/server/agents/Agent.d.ts
|
|
42
|
-
declare abstract class Agent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown
|
|
37
|
+
declare abstract class Agent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown>, State = unknown> extends Think<Cloudflare.Env & AgentEnv, State> {
|
|
43
38
|
protected agentType: AgentConnectionType;
|
|
44
39
|
protected clientIp?: string;
|
|
45
40
|
protected forwardedFor?: string;
|
|
@@ -180,9 +175,8 @@ declare function migrateUserFromV1(deps: MigrationDeps): Promise<{
|
|
|
180
175
|
}>;
|
|
181
176
|
//#endregion
|
|
182
177
|
//#region src/server/agents/ChatAgent.d.ts
|
|
183
|
-
declare abstract class ChatAgent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown
|
|
178
|
+
declare abstract class ChatAgent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown>, State = unknown> extends Agent<RequestContext, UserContext, State> {
|
|
184
179
|
protected agentType: AgentConnectionType;
|
|
185
|
-
initialState: AgentConnectionState;
|
|
186
180
|
onStart(): Promise<void>;
|
|
187
181
|
configureSession(session: Session): Session;
|
|
188
182
|
onChatResponse(_result: ChatResponseResult): Promise<void>;
|
|
@@ -224,7 +218,7 @@ type Chat = {
|
|
|
224
218
|
declare const DELETE_CHAT_CALLBACK: "deleteChatCallback";
|
|
225
219
|
//#endregion
|
|
226
220
|
//#region src/server/agents/Assistant.d.ts
|
|
227
|
-
declare abstract class Assistant extends Agent$1<Cloudflare.Env & AgentEnv,
|
|
221
|
+
declare abstract class Assistant<State = unknown> extends Agent$1<Cloudflare.Env & AgentEnv, State> {
|
|
228
222
|
private _fix;
|
|
229
223
|
protected abstract fastModel: LanguageModel;
|
|
230
224
|
protected abstract agent: SubAgentClass<ChatAgent>;
|
|
@@ -284,4 +278,4 @@ declare function skill<Context extends Record<string, unknown> = Record<string,
|
|
|
284
278
|
//#region src/server/index.d.ts
|
|
285
279
|
declare function getCurrentToolContext(): any;
|
|
286
280
|
//#endregion
|
|
287
|
-
export { Agent, type
|
|
281
|
+
export { Agent, type AgentConnectionStatus, type AgentConnectionType, type AgentEnv, Assistant, ChatAgent, type FacetStub, type LegacyChatStub, type LegacyMessageFeedback, type MigrationDeps, type Skill, type SkillSource, type Tool, type ToolContext, type ToolSet, getCurrentToolContext, migrateUserFromV1, routeAgentRequest, skill, tool };
|
package/dist/index.mjs
CHANGED
|
@@ -387,9 +387,17 @@ function getChatRetentionMs(days) {
|
|
|
387
387
|
//#endregion
|
|
388
388
|
//#region src/server/features/migration.ts
|
|
389
389
|
async function listLegacyConversations(db, userId) {
|
|
390
|
-
|
|
390
|
+
try {
|
|
391
|
+
const { results } = await db.prepare(`SELECT durable_object_name, title, summary, created_at, updated_at
|
|
391
392
|
FROM conversations WHERE durable_object_name LIKE ? ORDER BY updated_at ASC`).bind(`${userId}:%`).all();
|
|
392
|
-
|
|
393
|
+
return results ?? [];
|
|
394
|
+
} catch (error) {
|
|
395
|
+
if (error instanceof Error && error.message.includes(`no such table: conversations`)) {
|
|
396
|
+
console.warn("[Migration] Legacy conversations table missing; skipping v1 migration", { userId });
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
393
401
|
}
|
|
394
402
|
async function listLegacyFeedback(db, durableObjectName) {
|
|
395
403
|
const { results } = await db.prepare(`SELECT message_id, rating, comment FROM message_ratings WHERE durable_object_name = ?`).bind(durableObjectName).all();
|
|
@@ -947,10 +955,6 @@ var ChatAgent = class extends Agent {
|
|
|
947
955
|
]], 0, void 0, Agent).e;
|
|
948
956
|
}
|
|
949
957
|
agentType = (_initProto(this), "chat");
|
|
950
|
-
initialState = {
|
|
951
|
-
status: "connecting",
|
|
952
|
-
type: "chat"
|
|
953
|
-
};
|
|
954
958
|
async onStart() {
|
|
955
959
|
await super.onStart();
|
|
956
960
|
ensureFeedbackTableExists(this.sql.bind(this));
|