basileus-agentkit-plugin 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/.nvmrc +1 -0
- package/.prettierrc +7 -0
- package/dist/actions/aleph.d.ts +2 -0
- package/dist/actions/aleph.js +114 -0
- package/dist/actions/aleph.js.map +1 -0
- package/dist/actions/compound/compoundActionProvider.d.ts +2 -0
- package/dist/actions/compound/compoundActionProvider.js +130 -0
- package/dist/actions/compound/compoundActionProvider.js.map +1 -0
- package/dist/actions/compound/constants.d.ts +194 -0
- package/dist/actions/compound/constants.js +134 -0
- package/dist/actions/compound/constants.js.map +1 -0
- package/dist/actions/compound/index.d.ts +1 -0
- package/dist/actions/compound/index.js +2 -0
- package/dist/actions/compound/index.js.map +1 -0
- package/dist/actions/compound/schemas.d.ts +42 -0
- package/dist/actions/compound/schemas.js +41 -0
- package/dist/actions/compound/schemas.js.map +1 -0
- package/dist/actions/compound/utils.d.ts +15 -0
- package/dist/actions/compound/utils.js +260 -0
- package/dist/actions/compound/utils.js.map +1 -0
- package/dist/actions/constants.d.ts +69 -0
- package/dist/actions/constants.js +50 -0
- package/dist/actions/constants.js.map +1 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/agent-loop.d.ts +14 -0
- package/dist/agent-loop.js +60 -0
- package/dist/agent-loop.js.map +1 -0
- package/dist/aleph-publisher.d.ts +9 -0
- package/dist/aleph-publisher.js +41 -0
- package/dist/aleph-publisher.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/summarizer.d.ts +3 -0
- package/dist/summarizer.js +21 -0
- package/dist/summarizer.js.map +1 -0
- package/dist/tools.d.ts +6 -0
- package/dist/tools.js +30 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet.d.ts +17520 -0
- package/dist/wallet.js +47 -0
- package/dist/wallet.js.map +1 -0
- package/dist/x402-tracker.d.ts +2 -0
- package/dist/x402-tracker.js +39 -0
- package/dist/x402-tracker.js.map +1 -0
- package/eslint.config.js +26 -0
- package/package.json +86 -0
- package/src/actions/aleph.ts +145 -0
- package/src/actions/compound/compoundActionProvider.ts +166 -0
- package/src/actions/compound/constants.ts +140 -0
- package/src/actions/compound/index.ts +1 -0
- package/src/actions/compound/schemas.ts +45 -0
- package/src/actions/compound/utils.ts +367 -0
- package/src/actions/constants.ts +53 -0
- package/src/actions/index.ts +2 -0
- package/src/agent-loop.ts +93 -0
- package/src/aleph-publisher.ts +44 -0
- package/src/index.ts +11 -0
- package/src/summarizer.ts +30 -0
- package/src/tools.ts +40 -0
- package/src/types.ts +17 -0
- package/src/wallet.ts +73 -0
- package/src/x402-tracker.ts +43 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AuthenticatedAlephHttpClient } from "@aleph-sdk/client";
|
|
2
|
+
import { importAccountFromPrivateKey } from "@aleph-sdk/ethereum";
|
|
3
|
+
import { ItemType } from "@aleph-sdk/message";
|
|
4
|
+
export class AlephPublisher {
|
|
5
|
+
privateKey;
|
|
6
|
+
client = null;
|
|
7
|
+
channel;
|
|
8
|
+
constructor(privateKey, channel) {
|
|
9
|
+
this.privateKey = privateKey;
|
|
10
|
+
this.channel = channel ?? "basileus";
|
|
11
|
+
}
|
|
12
|
+
async init() {
|
|
13
|
+
try {
|
|
14
|
+
const account = importAccountFromPrivateKey(this.privateKey);
|
|
15
|
+
this.client = new AuthenticatedAlephHttpClient(account);
|
|
16
|
+
console.log("[aleph] Publisher initialized");
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.error("[aleph] Failed to init publisher:", err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async publish(postType, activity) {
|
|
23
|
+
if (!this.client) {
|
|
24
|
+
console.warn("[aleph] Publisher not initialized, skipping publish");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await this.client.createPost({
|
|
29
|
+
postType,
|
|
30
|
+
content: activity,
|
|
31
|
+
channel: this.channel,
|
|
32
|
+
storageEngine: ItemType.inline,
|
|
33
|
+
});
|
|
34
|
+
console.log(`[aleph] Published ${postType}`);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.error(`[aleph] Failed to publish ${postType}:`, err);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=aleph-publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aleph-publisher.js","sourceRoot":"","sources":["../src/aleph-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,MAAM,OAAO,cAAc;IAKf;IAJF,MAAM,GAAwC,IAAI,CAAC;IACnD,OAAO,CAAS;IAExB,YACU,UAAkB,EAC1B,OAAgB;QADR,eAAU,GAAV,UAAU,CAAQ;QAG1B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,UAAU,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,2BAA2B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7D,IAAI,CAAC,MAAM,GAAG,IAAI,4BAA4B,CAAC,OAAO,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAsB,EAAE,QAAuB;QAC3D,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;YACpE,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;gBAC3B,QAAQ;gBACR,OAAO,EAAE,QAAQ;gBACjB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,aAAa,EAAE,QAAQ,CAAC,MAAM;aAC/B,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,6BAA6B,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { installX402Tracker, drainX402TxHashes } from "./x402-tracker.js";
|
|
2
|
+
export { AlephPublisher } from "./aleph-publisher.js";
|
|
3
|
+
export { runAgentLoop, createLLMClient } from "./agent-loop.js";
|
|
4
|
+
export type { AgentLoopOptions, AgentLoopResult } from "./agent-loop.js";
|
|
5
|
+
export { actionsToTools } from "./tools.js";
|
|
6
|
+
export { summarizePhase } from "./summarizer.js";
|
|
7
|
+
export { createAlephActionProvider } from "./actions/aleph.js";
|
|
8
|
+
export { compoundFixedProvider } from "./actions/compound/index.js";
|
|
9
|
+
export { createAgentWallet, getBalances } from "./wallet.js";
|
|
10
|
+
export type { WalletInfo } from "./wallet.js";
|
|
11
|
+
export type { ToolExecution, ActivityType, AgentActivity } from "./types.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { installX402Tracker, drainX402TxHashes } from "./x402-tracker.js";
|
|
2
|
+
export { AlephPublisher } from "./aleph-publisher.js";
|
|
3
|
+
export { runAgentLoop, createLLMClient } from "./agent-loop.js";
|
|
4
|
+
export { actionsToTools } from "./tools.js";
|
|
5
|
+
export { summarizePhase } from "./summarizer.js";
|
|
6
|
+
export { createAlephActionProvider } from "./actions/aleph.js";
|
|
7
|
+
export { compoundFixedProvider } from "./actions/compound/index.js";
|
|
8
|
+
export { createAgentWallet, getBalances } from "./wallet.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export async function summarizePhase(client, model, phaseType, reasoning, toolExecutions) {
|
|
2
|
+
const toolSummary = toolExecutions
|
|
3
|
+
.map((t) => {
|
|
4
|
+
const name = t.name.replace(/^[A-Za-z]+Provider_/, "");
|
|
5
|
+
return t.txHash ? `${name} (tx: ${t.txHash.slice(0, 10)}...)` : name;
|
|
6
|
+
})
|
|
7
|
+
.join(", ");
|
|
8
|
+
const prompt = `Summarize this ${phaseType} phase in 1-2 short sentences. Focus on what was done and the outcome. No preamble.
|
|
9
|
+
|
|
10
|
+
Reasoning: ${reasoning.slice(0, 1000)}
|
|
11
|
+
${toolSummary ? `Tools called: ${toolSummary}` : "No tools called."}`;
|
|
12
|
+
try {
|
|
13
|
+
const result = await client.chatCompletion(model, [{ role: "user", content: prompt }]);
|
|
14
|
+
return result.choices[0].message.content ?? reasoning.slice(0, 200);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
console.warn(`[summarizer] Failed to summarize ${phaseType}:`, err);
|
|
18
|
+
return reasoning.slice(0, 200);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=summarizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,cAA+B;IAE/B,MAAM,WAAW,GAAG,cAAc;SAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,MAAM,GAAG,kBAAkB,SAAS;;aAE/B,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;EACnC,WAAW,CAAC,CAAC,CAAC,iBAAiB,WAAW,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAEpE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACvF,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,oCAAoC,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;QACpE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
package/dist/tools.d.ts
ADDED
package/dist/tools.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
|
+
export function actionsToTools(actions) {
|
|
3
|
+
const actionMap = new Map();
|
|
4
|
+
const tools = actions.map((action) => {
|
|
5
|
+
actionMap.set(action.name, action.invoke);
|
|
6
|
+
return {
|
|
7
|
+
type: "function",
|
|
8
|
+
function: {
|
|
9
|
+
name: action.name,
|
|
10
|
+
description: action.description,
|
|
11
|
+
parameters: zodToJsonSchema(action.schema, { target: "openApi3" }),
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
const executeTool = async (name, argsJson) => {
|
|
16
|
+
const handler = actionMap.get(name);
|
|
17
|
+
if (!handler) {
|
|
18
|
+
return `Error: unknown tool "${name}"`;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const args = JSON.parse(argsJson);
|
|
22
|
+
return await handler(args);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return `Error executing ${name}: ${err instanceof Error ? err.message : String(err)}`;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return { tools, executeTool };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js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package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ToolExecution {
|
|
2
|
+
name: string;
|
|
3
|
+
args?: Record<string, string>;
|
|
4
|
+
result?: string;
|
|
5
|
+
txHash?: string;
|
|
6
|
+
meta?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export type ActivityType = "inventory" | "survival" | "strategy" | "error";
|
|
9
|
+
export interface AgentActivity {
|
|
10
|
+
summary: string;
|
|
11
|
+
model: string;
|
|
12
|
+
cycleId: string;
|
|
13
|
+
tools?: ToolExecution[];
|
|
14
|
+
txHashes?: string[];
|
|
15
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|