@economic/agents 2.2.2 → 2.2.3
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 -3
- package/dist/index.mjs +6 -14
- package/dist/v1.d.mts +1 -1
- package/dist/v1.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as JwtAuthConfig, t as routeAgentRequest } from "./route-agent-request-DmwIOBJS.mjs";
|
|
2
|
+
import { Agent as Agent$1, Connection, ConnectionContext, SubAgentClass } from "agents";
|
|
2
3
|
import { ChatResponseResult, Session, StepConfig, Think, ToolCallContext, ToolCallDecision, TurnConfig, TurnContext } from "@cloudflare/think";
|
|
3
4
|
import { JSONValue, LanguageModel, Tool as Tool$1, UIMessage } from "ai";
|
|
4
|
-
import { Agent as Agent$1, Connection, ConnectionContext, SubAgentClass } from "agents";
|
|
5
5
|
//#region src/server/types.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The context object available throughout an agent's lifetime — passed via
|
|
@@ -46,7 +46,6 @@ interface Skill<Context extends Record<string, unknown> = Record<string, unknown
|
|
|
46
46
|
declare function skill<Context extends Record<string, unknown> = Record<string, unknown>>(definition: Skill<Context>): Skill<Context>;
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/server/agents/Agent.d.ts
|
|
49
|
-
declare function getCurrentToolContext(): any;
|
|
50
49
|
declare abstract class Agent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown>> extends Think<Cloudflare.Env & AgentEnv, AgentConnectionState> {
|
|
51
50
|
initialState: AgentConnectionState;
|
|
52
51
|
protected clientIp?: string;
|
|
@@ -84,7 +83,6 @@ declare abstract class Agent<RequestContext extends Record<string, unknown> = Re
|
|
|
84
83
|
* Returns the remote skills to be loaded from SKILLS_BUCKET.
|
|
85
84
|
* @returns The remote skills to be loaded from SKILLS_BUCKET.
|
|
86
85
|
*/
|
|
87
|
-
protected getRemoteSkills(): string[];
|
|
88
86
|
/**
|
|
89
87
|
* Returns the skills to load for the agent.
|
|
90
88
|
* @returns The skills to load for the agent.
|
|
@@ -274,4 +272,7 @@ declare abstract class Assistant extends Agent$1<Cloudflare.Env & AgentEnv, Agen
|
|
|
274
272
|
private registerInstance;
|
|
275
273
|
}
|
|
276
274
|
//#endregion
|
|
275
|
+
//#region src/server/index.d.ts
|
|
276
|
+
declare function getCurrentToolContext(): any;
|
|
277
|
+
//#endregion
|
|
277
278
|
export { Agent, type AgentConnectionState, type AgentConnectionStatus, type AgentConnectionType, type AgentEnv, Assistant, ChatAgent, type FacetStub, type LegacyChatStub, type LegacyMessageFeedback, type MigrationDeps, type Skill, type Tool, type ToolContext, type ToolSet, getCurrentToolContext, migrateUserFromV1, routeAgentRequest, skill, tool };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { i as verifyJwt, n as createAgentTracer, r as extractTokenFromConnectRequest, t as routeAgentRequest } from "./route-agent-request-DKDvDYnR.mjs";
|
|
2
|
+
import { Agent as Agent$1, callable, getCurrentAgent } from "agents";
|
|
2
3
|
import { Think } from "@cloudflare/think";
|
|
3
4
|
import { Output, convertToModelMessages, generateText, jsonSchema, pruneMessages, tool as tool$1 } from "ai";
|
|
4
|
-
import { Agent as Agent$1, callable, getCurrentAgent } from "agents";
|
|
5
|
-
import { R2SkillProvider } from "agents/experimental/memory/session";
|
|
6
5
|
import { nanoid } from "nanoid";
|
|
7
6
|
import { createCompactFunction } from "agents/experimental/memory/utils";
|
|
8
7
|
//#region src/server/util/tools.ts
|
|
@@ -56,9 +55,6 @@ async function registerAgent(db, input) {
|
|
|
56
55
|
}
|
|
57
56
|
//#endregion
|
|
58
57
|
//#region src/server/agents/Agent.ts
|
|
59
|
-
function getCurrentToolContext() {
|
|
60
|
-
return getCurrentAgent().agent._lastBody;
|
|
61
|
-
}
|
|
62
58
|
var Agent = class extends Think {
|
|
63
59
|
initialState = {
|
|
64
60
|
status: "connecting",
|
|
@@ -156,12 +152,6 @@ var Agent = class extends Think {
|
|
|
156
152
|
let configuredSession = session.withContext("soul", { provider: { get: async () => {
|
|
157
153
|
return this.getSystemPrompt(this._requestContext !== void 0 ? this._buildToolContext() : void 0);
|
|
158
154
|
} } }).withContext("critical-rules", { provider: { get: async () => SECURITY_RULES_PROMPT } }).withContext("turn-protocol-rules", { provider: { get: async () => TURN_PROTOCOL_RULES_PROMPT } });
|
|
159
|
-
const remoteSkills = this.getRemoteSkills();
|
|
160
|
-
if (remoteSkills.length) if (this.env.SKILLS_BUCKET) configuredSession = configuredSession.withContext("skills", { provider: new R2SkillProvider(this.env.SKILLS_BUCKET, {
|
|
161
|
-
prefix: "skills/",
|
|
162
|
-
keys: remoteSkills
|
|
163
|
-
}) });
|
|
164
|
-
else console.error("[Agent] Connection rejected: Remote skills defined, but no SKILLS_BUCKET R2 binding found");
|
|
165
155
|
const localSkills = this.getSkills();
|
|
166
156
|
if (localSkills.length) configuredSession = configuredSession.withContext("local-skills", { provider: new LocalSkillProvider(localSkills) });
|
|
167
157
|
return configuredSession.withCachedPrompt();
|
|
@@ -244,9 +234,6 @@ var Agent = class extends Think {
|
|
|
244
234
|
* Returns the remote skills to be loaded from SKILLS_BUCKET.
|
|
245
235
|
* @returns The remote skills to be loaded from SKILLS_BUCKET.
|
|
246
236
|
*/
|
|
247
|
-
getRemoteSkills() {
|
|
248
|
-
return [];
|
|
249
|
-
}
|
|
250
237
|
/**
|
|
251
238
|
* Returns the skills to load for the agent.
|
|
252
239
|
* @returns The skills to load for the agent.
|
|
@@ -787,4 +774,9 @@ function skill(definition) {
|
|
|
787
774
|
return definition;
|
|
788
775
|
}
|
|
789
776
|
//#endregion
|
|
777
|
+
//#region src/server/index.ts
|
|
778
|
+
function getCurrentToolContext() {
|
|
779
|
+
return getCurrentAgent().agent._lastBody;
|
|
780
|
+
}
|
|
781
|
+
//#endregion
|
|
790
782
|
export { Agent, Assistant, ChatAgent, getCurrentToolContext, migrateUserFromV1, routeAgentRequest, skill, tool };
|
package/dist/v1.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as JwtAuthConfig, t as routeAgentRequest } from "./route-agent-request-DmwIOBJS.mjs";
|
|
2
|
-
import { LanguageModel, StreamTextOnFinishCallback, ToolSet, UIMessage, generateText, streamText } from "ai";
|
|
3
2
|
import { Agent as Agent$1, Connection, ConnectionContext } from "agents";
|
|
3
|
+
import { LanguageModel, StreamTextOnFinishCallback, ToolSet, UIMessage, generateText, streamText } from "ai";
|
|
4
4
|
import { AIChatAgent, ChatResponseResult, OnChatMessageOptions } from "@cloudflare/ai-chat";
|
|
5
5
|
|
|
6
6
|
//#region src/server/features/skills/index.d.ts
|
package/dist/v1.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as verifyJwt, n as createAgentTracer, r as extractTokenFromConnectRequest, t as routeAgentRequest } from "./route-agent-request-DKDvDYnR.mjs";
|
|
2
|
-
import { Output, convertToModelMessages, generateText, jsonSchema, stepCountIs, streamText, tool } from "ai";
|
|
3
2
|
import { Agent as Agent$1, callable, getCurrentAgent } from "agents";
|
|
3
|
+
import { Output, convertToModelMessages, generateText, jsonSchema, stepCountIs, streamText, tool } from "ai";
|
|
4
4
|
import { AIChatAgent } from "@cloudflare/ai-chat";
|
|
5
5
|
//#region src/server/features/skills/index.ts
|
|
6
6
|
const TOOL_NAME_ACTIVATE_SKILL = "activate_skill";
|