@sekuire/sdk 0.1.4 → 0.1.5
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/config/loader.d.ts +1 -1
- package/dist/index.d.ts +69 -47
- package/dist/index.esm.js +996 -795
- package/dist/index.js +997 -794
- package/dist/llm/anthropic.d.ts +1 -1
- package/dist/llm/google.d.ts +1 -1
- package/dist/llm/index.d.ts +10 -10
- package/dist/llm/ollama.d.ts +1 -1
- package/dist/llm/openai.d.ts +1 -1
- package/dist/llm/types.d.ts +1 -1
- package/dist/memory/base.d.ts +1 -1
- package/dist/memory/in-memory.d.ts +1 -1
- package/dist/memory/index.d.ts +8 -8
- package/dist/memory/postgres.d.ts +1 -1
- package/dist/memory/redis.d.ts +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/tools/agent-invocation.d.ts +1 -1
- package/dist/tools/base.d.ts +3 -3
- package/dist/tools/calculator.d.ts +1 -1
- package/dist/tools/compliance-operations.d.ts +1 -1
- package/dist/tools/data-operations.d.ts +1 -1
- package/dist/tools/directory-operations.d.ts +1 -1
- package/dist/tools/file-operations.d.ts +1 -1
- package/dist/tools/google-workspace.d.ts +8 -0
- package/dist/tools/http-request.d.ts +1 -1
- package/dist/tools/index.d.ts +34 -31
- package/dist/tools/pattern-parser.d.ts +1 -1
- package/dist/tools/remote.d.ts +10 -0
- package/dist/tools/system-operations.d.ts +1 -1
- package/dist/tools/utility-operations.d.ts +1 -1
- package/dist/tools/verification-status.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var path$4 = require('node:path');
|
|
|
15
15
|
var https = require('https');
|
|
16
16
|
var http = require('http');
|
|
17
17
|
var url = require('url');
|
|
18
|
+
var zod = require('zod');
|
|
18
19
|
|
|
19
20
|
function _interopNamespaceDefault(e) {
|
|
20
21
|
var n = Object.create(null);
|
|
@@ -1664,14 +1665,14 @@ class SekuireClient {
|
|
|
1664
1665
|
/**
|
|
1665
1666
|
* Load sekuire.yml configuration file
|
|
1666
1667
|
*/
|
|
1667
|
-
async function loadConfig(configPath =
|
|
1668
|
+
async function loadConfig(configPath = './sekuire.yml') {
|
|
1668
1669
|
try {
|
|
1669
|
-
const content = await fs$2.readFile(configPath,
|
|
1670
|
+
const content = await fs$2.readFile(configPath, 'utf-8');
|
|
1670
1671
|
const config = yaml.load(content);
|
|
1671
1672
|
return resolveEnvVars(config);
|
|
1672
1673
|
}
|
|
1673
1674
|
catch (error) {
|
|
1674
|
-
if (error.code ===
|
|
1675
|
+
if (error.code === 'ENOENT') {
|
|
1675
1676
|
throw new Error(`Config file not found: ${configPath}`);
|
|
1676
1677
|
}
|
|
1677
1678
|
throw error;
|
|
@@ -1680,15 +1681,13 @@ async function loadConfig(configPath = "./sekuire.yml") {
|
|
|
1680
1681
|
/**
|
|
1681
1682
|
* Load system prompt from file
|
|
1682
1683
|
*/
|
|
1683
|
-
async function loadSystemPrompt(promptPath, basePath =
|
|
1684
|
+
async function loadSystemPrompt(promptPath, basePath = '.') {
|
|
1684
1685
|
try {
|
|
1685
|
-
const fullPath = path$3.isAbsolute(promptPath)
|
|
1686
|
-
|
|
1687
|
-
: path$3.join(basePath, promptPath);
|
|
1688
|
-
return await fs$2.readFile(fullPath, "utf-8");
|
|
1686
|
+
const fullPath = path$3.isAbsolute(promptPath) ? promptPath : path$3.join(basePath, promptPath);
|
|
1687
|
+
return await fs$2.readFile(fullPath, 'utf-8');
|
|
1689
1688
|
}
|
|
1690
1689
|
catch (error) {
|
|
1691
|
-
if (error.code ===
|
|
1690
|
+
if (error.code === 'ENOENT') {
|
|
1692
1691
|
throw new Error(`System prompt file not found: ${promptPath}`);
|
|
1693
1692
|
}
|
|
1694
1693
|
throw error;
|
|
@@ -1697,16 +1696,14 @@ async function loadSystemPrompt(promptPath, basePath = ".") {
|
|
|
1697
1696
|
/**
|
|
1698
1697
|
* Load tools configuration from JSON file
|
|
1699
1698
|
*/
|
|
1700
|
-
async function loadTools(toolsPath, basePath =
|
|
1699
|
+
async function loadTools(toolsPath, basePath = '.') {
|
|
1701
1700
|
try {
|
|
1702
|
-
const fullPath = path$3.isAbsolute(toolsPath)
|
|
1703
|
-
|
|
1704
|
-
: path$3.join(basePath, toolsPath);
|
|
1705
|
-
const content = await fs$2.readFile(fullPath, "utf-8");
|
|
1701
|
+
const fullPath = path$3.isAbsolute(toolsPath) ? toolsPath : path$3.join(basePath, toolsPath);
|
|
1702
|
+
const content = await fs$2.readFile(fullPath, 'utf-8');
|
|
1706
1703
|
return JSON.parse(content);
|
|
1707
1704
|
}
|
|
1708
1705
|
catch (error) {
|
|
1709
|
-
if (error.code ===
|
|
1706
|
+
if (error.code === 'ENOENT') {
|
|
1710
1707
|
throw new Error(`Tools file not found: ${toolsPath}`);
|
|
1711
1708
|
}
|
|
1712
1709
|
throw error;
|
|
@@ -1717,7 +1714,7 @@ async function loadTools(toolsPath, basePath = ".") {
|
|
|
1717
1714
|
* Supports ${VAR} and ${VAR:-default} syntax
|
|
1718
1715
|
*/
|
|
1719
1716
|
function resolveEnvVars(obj) {
|
|
1720
|
-
if (typeof obj ===
|
|
1717
|
+
if (typeof obj === 'string') {
|
|
1721
1718
|
// Match ${VAR} or ${VAR:-default}
|
|
1722
1719
|
return obj.replace(/\$\{([^}:]+)(?::-([^}]*))?\}/g, (match, varName, defaultValue) => {
|
|
1723
1720
|
const value = process.env[varName];
|
|
@@ -1727,7 +1724,7 @@ function resolveEnvVars(obj) {
|
|
|
1727
1724
|
if (Array.isArray(obj)) {
|
|
1728
1725
|
return obj.map((item) => resolveEnvVars(item));
|
|
1729
1726
|
}
|
|
1730
|
-
if (obj !== null && typeof obj ===
|
|
1727
|
+
if (obj !== null && typeof obj === 'object') {
|
|
1731
1728
|
const resolved = {};
|
|
1732
1729
|
for (const [key, value] of Object.entries(obj)) {
|
|
1733
1730
|
resolved[key] = resolveEnvVars(value);
|
|
@@ -1747,7 +1744,7 @@ function getAgentConfig(config, agentName) {
|
|
|
1747
1744
|
// Return first agent if no name specified
|
|
1748
1745
|
const firstKey = Object.keys(config.agents)[0];
|
|
1749
1746
|
if (!firstKey) {
|
|
1750
|
-
throw new Error(
|
|
1747
|
+
throw new Error('No agents defined in sekuire.yml');
|
|
1751
1748
|
}
|
|
1752
1749
|
return config.agents[firstKey];
|
|
1753
1750
|
}
|
|
@@ -1774,12 +1771,12 @@ function getAgentConfig(config, agentName) {
|
|
|
1774
1771
|
if (config.llm) {
|
|
1775
1772
|
return {
|
|
1776
1773
|
name: config.project.name,
|
|
1777
|
-
system_prompt:
|
|
1778
|
-
tools:
|
|
1774
|
+
system_prompt: './system_prompt.md',
|
|
1775
|
+
tools: './tools.json',
|
|
1779
1776
|
llm: config.llm,
|
|
1780
1777
|
};
|
|
1781
1778
|
}
|
|
1782
|
-
throw new Error(
|
|
1779
|
+
throw new Error('No agent configuration found in sekuire.yml');
|
|
1783
1780
|
}
|
|
1784
1781
|
|
|
1785
1782
|
function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
|
|
@@ -6702,8 +6699,8 @@ class AnthropicProvider {
|
|
|
6702
6699
|
async chat(messages, options) {
|
|
6703
6700
|
try {
|
|
6704
6701
|
// Anthropic requires system message separately
|
|
6705
|
-
const systemMessage = messages.find((m) => m.role ===
|
|
6706
|
-
const conversationMessages = messages.filter((m) => m.role !==
|
|
6702
|
+
const systemMessage = messages.find((m) => m.role === 'system');
|
|
6703
|
+
const conversationMessages = messages.filter((m) => m.role !== 'system');
|
|
6707
6704
|
const response = await this.client.messages.create({
|
|
6708
6705
|
model: this.model,
|
|
6709
6706
|
max_tokens: options?.max_tokens || 4096,
|
|
@@ -6713,14 +6710,14 @@ class AnthropicProvider {
|
|
|
6713
6710
|
system: systemMessage?.content || undefined,
|
|
6714
6711
|
messages: conversationMessages.map((m) => ({
|
|
6715
6712
|
role: m.role,
|
|
6716
|
-
content: m.content ||
|
|
6713
|
+
content: m.content || '',
|
|
6717
6714
|
})),
|
|
6718
6715
|
});
|
|
6719
6716
|
// Extract text content from response
|
|
6720
6717
|
const content = response.content
|
|
6721
|
-
.filter((block) => block.type ===
|
|
6718
|
+
.filter((block) => block.type === 'text')
|
|
6722
6719
|
.map((block) => block.text)
|
|
6723
|
-
.join(
|
|
6720
|
+
.join('');
|
|
6724
6721
|
return {
|
|
6725
6722
|
content,
|
|
6726
6723
|
model: response.model,
|
|
@@ -6739,8 +6736,8 @@ class AnthropicProvider {
|
|
|
6739
6736
|
async *chatStream(messages, options) {
|
|
6740
6737
|
try {
|
|
6741
6738
|
// Anthropic requires system message separately
|
|
6742
|
-
const systemMessage = messages.find((m) => m.role ===
|
|
6743
|
-
const conversationMessages = messages.filter((m) => m.role !==
|
|
6739
|
+
const systemMessage = messages.find((m) => m.role === 'system');
|
|
6740
|
+
const conversationMessages = messages.filter((m) => m.role !== 'system');
|
|
6744
6741
|
const stream = await this.client.messages.create({
|
|
6745
6742
|
model: this.model,
|
|
6746
6743
|
max_tokens: options?.max_tokens || 4096,
|
|
@@ -6750,22 +6747,22 @@ class AnthropicProvider {
|
|
|
6750
6747
|
system: systemMessage?.content || undefined,
|
|
6751
6748
|
messages: conversationMessages.map((m) => ({
|
|
6752
6749
|
role: m.role,
|
|
6753
|
-
content: m.content ||
|
|
6750
|
+
content: m.content || '',
|
|
6754
6751
|
})),
|
|
6755
6752
|
stream: true,
|
|
6756
6753
|
});
|
|
6757
6754
|
for await (const event of stream) {
|
|
6758
|
-
if (event.type ===
|
|
6759
|
-
if (event.delta.type ===
|
|
6755
|
+
if (event.type === 'content_block_delta') {
|
|
6756
|
+
if (event.delta.type === 'text_delta') {
|
|
6760
6757
|
yield {
|
|
6761
6758
|
content: event.delta.text,
|
|
6762
6759
|
};
|
|
6763
6760
|
}
|
|
6764
6761
|
}
|
|
6765
|
-
else if (event.type ===
|
|
6762
|
+
else if (event.type === 'message_stop') {
|
|
6766
6763
|
yield {
|
|
6767
|
-
content:
|
|
6768
|
-
finish_reason:
|
|
6764
|
+
content: '',
|
|
6765
|
+
finish_reason: 'stop',
|
|
6769
6766
|
};
|
|
6770
6767
|
}
|
|
6771
6768
|
}
|
|
@@ -6783,29 +6780,29 @@ class AnthropicProvider {
|
|
|
6783
6780
|
return this.maxTokens;
|
|
6784
6781
|
}
|
|
6785
6782
|
getProviderName() {
|
|
6786
|
-
return
|
|
6783
|
+
return 'anthropic';
|
|
6787
6784
|
}
|
|
6788
6785
|
getModelName() {
|
|
6789
6786
|
return this.model;
|
|
6790
6787
|
}
|
|
6791
6788
|
getMaxTokensForModel(model) {
|
|
6792
6789
|
// Context window sizes for Claude models
|
|
6793
|
-
if (model.includes(
|
|
6790
|
+
if (model.includes('claude-3-5-sonnet')) {
|
|
6794
6791
|
return 200000; // Claude 3.5 Sonnet
|
|
6795
6792
|
}
|
|
6796
|
-
if (model.includes(
|
|
6793
|
+
if (model.includes('claude-3-opus')) {
|
|
6797
6794
|
return 200000; // Claude 3 Opus
|
|
6798
6795
|
}
|
|
6799
|
-
if (model.includes(
|
|
6796
|
+
if (model.includes('claude-3-sonnet')) {
|
|
6800
6797
|
return 200000; // Claude 3 Sonnet
|
|
6801
6798
|
}
|
|
6802
|
-
if (model.includes(
|
|
6799
|
+
if (model.includes('claude-3-haiku')) {
|
|
6803
6800
|
return 200000; // Claude 3 Haiku
|
|
6804
6801
|
}
|
|
6805
|
-
if (model.includes(
|
|
6802
|
+
if (model.includes('claude-2.1')) {
|
|
6806
6803
|
return 200000; // Claude 2.1
|
|
6807
6804
|
}
|
|
6808
|
-
if (model.includes(
|
|
6805
|
+
if (model.includes('claude-2')) {
|
|
6809
6806
|
return 100000; // Claude 2.0
|
|
6810
6807
|
}
|
|
6811
6808
|
// Default fallback
|
|
@@ -8344,13 +8341,17 @@ class GoogleProvider {
|
|
|
8344
8341
|
async chat(messages, options) {
|
|
8345
8342
|
try {
|
|
8346
8343
|
// Convert tools to Gemini format
|
|
8347
|
-
const tools = options?.tools
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8344
|
+
const tools = options?.tools
|
|
8345
|
+
? [
|
|
8346
|
+
{
|
|
8347
|
+
functionDeclarations: options.tools.map((t) => ({
|
|
8348
|
+
name: t.function.name,
|
|
8349
|
+
description: t.function.description,
|
|
8350
|
+
parameters: t.function.parameters,
|
|
8351
|
+
})),
|
|
8352
|
+
},
|
|
8353
|
+
]
|
|
8354
|
+
: undefined;
|
|
8354
8355
|
const model = this.client.getGenerativeModel({
|
|
8355
8356
|
model: this.model,
|
|
8356
8357
|
generationConfig: {
|
|
@@ -8380,38 +8381,40 @@ class GoogleProvider {
|
|
|
8380
8381
|
...(tools && { tools }),
|
|
8381
8382
|
});
|
|
8382
8383
|
// Google Gemini uses a different message format
|
|
8383
|
-
const systemMessage = messages.find((m) => m.role ===
|
|
8384
|
-
const conversationMessages = messages.filter((m) => m.role !==
|
|
8384
|
+
const systemMessage = messages.find((m) => m.role === 'system');
|
|
8385
|
+
const conversationMessages = messages.filter((m) => m.role !== 'system');
|
|
8385
8386
|
// Build chat history with proper tool call support
|
|
8386
8387
|
const history = conversationMessages.slice(0, -1).map((m) => {
|
|
8387
|
-
if (m.role ===
|
|
8388
|
+
if (m.role === 'assistant' || m.role === 'model') {
|
|
8388
8389
|
return {
|
|
8389
|
-
role:
|
|
8390
|
-
parts: [{ text: m.content ||
|
|
8390
|
+
role: 'model',
|
|
8391
|
+
parts: [{ text: m.content || '' }],
|
|
8391
8392
|
};
|
|
8392
8393
|
}
|
|
8393
|
-
else if (m.role ===
|
|
8394
|
+
else if (m.role === 'tool') {
|
|
8394
8395
|
// Tool result message - Gemini expects this in a specific format
|
|
8395
8396
|
return {
|
|
8396
|
-
role:
|
|
8397
|
-
parts: [
|
|
8397
|
+
role: 'function',
|
|
8398
|
+
parts: [
|
|
8399
|
+
{
|
|
8398
8400
|
functionResponse: {
|
|
8399
8401
|
name: m.name,
|
|
8400
8402
|
response: {
|
|
8401
|
-
content: m.content
|
|
8402
|
-
}
|
|
8403
|
-
}
|
|
8404
|
-
}
|
|
8403
|
+
content: m.content,
|
|
8404
|
+
},
|
|
8405
|
+
},
|
|
8406
|
+
},
|
|
8407
|
+
],
|
|
8405
8408
|
};
|
|
8406
8409
|
}
|
|
8407
8410
|
else {
|
|
8408
8411
|
return {
|
|
8409
|
-
role:
|
|
8410
|
-
parts: [{ text: m.content ||
|
|
8412
|
+
role: 'user',
|
|
8413
|
+
parts: [{ text: m.content || '' }],
|
|
8411
8414
|
};
|
|
8412
8415
|
}
|
|
8413
8416
|
});
|
|
8414
|
-
const lastMessage = conversationMessages[conversationMessages.length - 1]?.content ||
|
|
8417
|
+
const lastMessage = conversationMessages[conversationMessages.length - 1]?.content || '';
|
|
8415
8418
|
// Start chat with history
|
|
8416
8419
|
const chat = model.startChat({
|
|
8417
8420
|
history,
|
|
@@ -8433,13 +8436,11 @@ class GoogleProvider {
|
|
|
8433
8436
|
type: 'function',
|
|
8434
8437
|
function: {
|
|
8435
8438
|
name: fc.name,
|
|
8436
|
-
arguments: JSON.stringify(fc.args)
|
|
8437
|
-
}
|
|
8439
|
+
arguments: JSON.stringify(fc.args),
|
|
8440
|
+
},
|
|
8438
8441
|
}));
|
|
8439
8442
|
// Only get text if no function calls (Gemini returns empty text when calling functions)
|
|
8440
|
-
const content = functionCalls && functionCalls.length > 0
|
|
8441
|
-
? ""
|
|
8442
|
-
: response.text();
|
|
8443
|
+
const content = functionCalls && functionCalls.length > 0 ? '' : response.text();
|
|
8443
8444
|
return {
|
|
8444
8445
|
content,
|
|
8445
8446
|
model: this.model,
|
|
@@ -8467,13 +8468,13 @@ class GoogleProvider {
|
|
|
8467
8468
|
stopSequences: options?.stop,
|
|
8468
8469
|
},
|
|
8469
8470
|
});
|
|
8470
|
-
const systemMessage = messages.find((m) => m.role ===
|
|
8471
|
-
const conversationMessages = messages.filter((m) => m.role !==
|
|
8471
|
+
const systemMessage = messages.find((m) => m.role === 'system');
|
|
8472
|
+
const conversationMessages = messages.filter((m) => m.role !== 'system');
|
|
8472
8473
|
const history = conversationMessages.slice(0, -1).map((m) => ({
|
|
8473
|
-
role: m.role ===
|
|
8474
|
-
parts: [{ text: m.content ||
|
|
8474
|
+
role: m.role === 'assistant' ? 'model' : 'user',
|
|
8475
|
+
parts: [{ text: m.content || '' }],
|
|
8475
8476
|
}));
|
|
8476
|
-
const lastMessage = conversationMessages[conversationMessages.length - 1]?.content ||
|
|
8477
|
+
const lastMessage = conversationMessages[conversationMessages.length - 1]?.content || '';
|
|
8477
8478
|
const chat = model.startChat({ history });
|
|
8478
8479
|
const prompt = systemMessage
|
|
8479
8480
|
? `${systemMessage.content}\n\nUser: ${lastMessage}`
|
|
@@ -8489,8 +8490,8 @@ class GoogleProvider {
|
|
|
8489
8490
|
}
|
|
8490
8491
|
// Final chunk with finish reason
|
|
8491
8492
|
yield {
|
|
8492
|
-
content:
|
|
8493
|
-
finish_reason:
|
|
8493
|
+
content: '',
|
|
8494
|
+
finish_reason: 'stop',
|
|
8494
8495
|
};
|
|
8495
8496
|
}
|
|
8496
8497
|
catch (error) {
|
|
@@ -8506,23 +8507,23 @@ class GoogleProvider {
|
|
|
8506
8507
|
return this.maxTokens;
|
|
8507
8508
|
}
|
|
8508
8509
|
getProviderName() {
|
|
8509
|
-
return
|
|
8510
|
+
return 'google';
|
|
8510
8511
|
}
|
|
8511
8512
|
getModelName() {
|
|
8512
8513
|
return this.model;
|
|
8513
8514
|
}
|
|
8514
8515
|
getMaxTokensForModel(model) {
|
|
8515
8516
|
// Context window sizes for Gemini models
|
|
8516
|
-
if (model.includes(
|
|
8517
|
+
if (model.includes('gemini-1.5-pro')) {
|
|
8517
8518
|
return 2000000; // 2M tokens!
|
|
8518
8519
|
}
|
|
8519
|
-
if (model.includes(
|
|
8520
|
+
if (model.includes('gemini-1.5-flash')) {
|
|
8520
8521
|
return 1000000; // 1M tokens
|
|
8521
8522
|
}
|
|
8522
|
-
if (model.includes(
|
|
8523
|
+
if (model.includes('gemini-pro')) {
|
|
8523
8524
|
return 32768;
|
|
8524
8525
|
}
|
|
8525
|
-
if (model.includes(
|
|
8526
|
+
if (model.includes('gemini-pro-vision')) {
|
|
8526
8527
|
return 16384;
|
|
8527
8528
|
}
|
|
8528
8529
|
// Default fallback
|
|
@@ -8536,7 +8537,7 @@ class GoogleProvider {
|
|
|
8536
8537
|
*/
|
|
8537
8538
|
class OllamaProvider {
|
|
8538
8539
|
constructor(config) {
|
|
8539
|
-
this.baseUrl = config.baseUrl ||
|
|
8540
|
+
this.baseUrl = config.baseUrl || 'http://localhost:11434';
|
|
8540
8541
|
this.model = config.model;
|
|
8541
8542
|
this.maxTokens = config.maxTokens || 4096;
|
|
8542
8543
|
}
|
|
@@ -8546,7 +8547,7 @@ class OllamaProvider {
|
|
|
8546
8547
|
model: this.model,
|
|
8547
8548
|
messages: messages.map((m) => ({
|
|
8548
8549
|
role: m.role,
|
|
8549
|
-
content: m.content ||
|
|
8550
|
+
content: m.content || '',
|
|
8550
8551
|
})),
|
|
8551
8552
|
stream: false,
|
|
8552
8553
|
options: {
|
|
@@ -8557,9 +8558,9 @@ class OllamaProvider {
|
|
|
8557
8558
|
},
|
|
8558
8559
|
};
|
|
8559
8560
|
const response = await fetch(`${this.baseUrl}/api/chat`, {
|
|
8560
|
-
method:
|
|
8561
|
+
method: 'POST',
|
|
8561
8562
|
headers: {
|
|
8562
|
-
|
|
8563
|
+
'Content-Type': 'application/json',
|
|
8563
8564
|
},
|
|
8564
8565
|
body: JSON.stringify(requestBody),
|
|
8565
8566
|
});
|
|
@@ -8570,7 +8571,7 @@ class OllamaProvider {
|
|
|
8570
8571
|
return {
|
|
8571
8572
|
content: data.message.content,
|
|
8572
8573
|
model: data.model,
|
|
8573
|
-
finish_reason: data.done ?
|
|
8574
|
+
finish_reason: data.done ? 'stop' : undefined,
|
|
8574
8575
|
usage: {
|
|
8575
8576
|
prompt_tokens: data.prompt_eval_count || 0,
|
|
8576
8577
|
completion_tokens: data.eval_count || 0,
|
|
@@ -8588,7 +8589,7 @@ class OllamaProvider {
|
|
|
8588
8589
|
model: this.model,
|
|
8589
8590
|
messages: messages.map((m) => ({
|
|
8590
8591
|
role: m.role,
|
|
8591
|
-
content: m.content ||
|
|
8592
|
+
content: m.content || '',
|
|
8592
8593
|
})),
|
|
8593
8594
|
stream: true,
|
|
8594
8595
|
options: {
|
|
@@ -8599,9 +8600,9 @@ class OllamaProvider {
|
|
|
8599
8600
|
},
|
|
8600
8601
|
};
|
|
8601
8602
|
const response = await fetch(`${this.baseUrl}/api/chat`, {
|
|
8602
|
-
method:
|
|
8603
|
+
method: 'POST',
|
|
8603
8604
|
headers: {
|
|
8604
|
-
|
|
8605
|
+
'Content-Type': 'application/json',
|
|
8605
8606
|
},
|
|
8606
8607
|
body: JSON.stringify(requestBody),
|
|
8607
8608
|
});
|
|
@@ -8609,7 +8610,7 @@ class OllamaProvider {
|
|
|
8609
8610
|
throw new Error(`Ollama API error: ${response.statusText}`);
|
|
8610
8611
|
}
|
|
8611
8612
|
if (!response.body) {
|
|
8612
|
-
throw new Error(
|
|
8613
|
+
throw new Error('Response body is null');
|
|
8613
8614
|
}
|
|
8614
8615
|
const reader = response.body.getReader();
|
|
8615
8616
|
const decoder = new TextDecoder();
|
|
@@ -8618,7 +8619,7 @@ class OllamaProvider {
|
|
|
8618
8619
|
if (done)
|
|
8619
8620
|
break;
|
|
8620
8621
|
const chunk = decoder.decode(value);
|
|
8621
|
-
const lines = chunk.split(
|
|
8622
|
+
const lines = chunk.split('\n').filter((line) => line.trim());
|
|
8622
8623
|
for (const line of lines) {
|
|
8623
8624
|
try {
|
|
8624
8625
|
const data = JSON.parse(line);
|
|
@@ -8629,8 +8630,8 @@ class OllamaProvider {
|
|
|
8629
8630
|
}
|
|
8630
8631
|
if (data.done) {
|
|
8631
8632
|
yield {
|
|
8632
|
-
content:
|
|
8633
|
-
finish_reason:
|
|
8633
|
+
content: '',
|
|
8634
|
+
finish_reason: 'stop',
|
|
8634
8635
|
};
|
|
8635
8636
|
}
|
|
8636
8637
|
}
|
|
@@ -8650,7 +8651,7 @@ class OllamaProvider {
|
|
|
8650
8651
|
return this.maxTokens;
|
|
8651
8652
|
}
|
|
8652
8653
|
getProviderName() {
|
|
8653
|
-
return
|
|
8654
|
+
return 'ollama';
|
|
8654
8655
|
}
|
|
8655
8656
|
getModelName() {
|
|
8656
8657
|
return this.model;
|
|
@@ -8888,7 +8889,7 @@ const safeJSON = (text) => {
|
|
|
8888
8889
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8889
8890
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8890
8891
|
|
|
8891
|
-
const VERSION = '6.
|
|
8892
|
+
const VERSION = '6.15.0'; // x-release-please-version
|
|
8892
8893
|
|
|
8893
8894
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8894
8895
|
const isRunningInBrowser = () => {
|
|
@@ -15857,7 +15858,7 @@ class OpenAIProvider {
|
|
|
15857
15858
|
tools: options?.tools,
|
|
15858
15859
|
});
|
|
15859
15860
|
return {
|
|
15860
|
-
content: response.choices[0]?.message?.content ||
|
|
15861
|
+
content: response.choices[0]?.message?.content || '',
|
|
15861
15862
|
model: response.model,
|
|
15862
15863
|
finish_reason: response.choices[0]?.finish_reason || undefined,
|
|
15863
15864
|
tool_calls: response.choices[0]?.message?.tool_calls,
|
|
@@ -15888,7 +15889,7 @@ class OpenAIProvider {
|
|
|
15888
15889
|
stream: true,
|
|
15889
15890
|
});
|
|
15890
15891
|
for await (const chunk of stream) {
|
|
15891
|
-
const content = chunk.choices[0]?.delta?.content ||
|
|
15892
|
+
const content = chunk.choices[0]?.delta?.content || '';
|
|
15892
15893
|
const finishReason = chunk.choices[0]?.finish_reason || undefined;
|
|
15893
15894
|
if (content || finishReason) {
|
|
15894
15895
|
yield {
|
|
@@ -15911,26 +15912,26 @@ class OpenAIProvider {
|
|
|
15911
15912
|
return this.maxTokens;
|
|
15912
15913
|
}
|
|
15913
15914
|
getProviderName() {
|
|
15914
|
-
return
|
|
15915
|
+
return 'openai';
|
|
15915
15916
|
}
|
|
15916
15917
|
getModelName() {
|
|
15917
15918
|
return this.model;
|
|
15918
15919
|
}
|
|
15919
15920
|
getMaxTokensForModel(model) {
|
|
15920
15921
|
// Context window sizes for common models
|
|
15921
|
-
if (model.includes(
|
|
15922
|
+
if (model.includes('gpt-4-turbo') || model.includes('gpt-4-1106')) {
|
|
15922
15923
|
return 128000;
|
|
15923
15924
|
}
|
|
15924
|
-
if (model.includes(
|
|
15925
|
+
if (model.includes('gpt-4-32k')) {
|
|
15925
15926
|
return 32768;
|
|
15926
15927
|
}
|
|
15927
|
-
if (model.includes(
|
|
15928
|
+
if (model.includes('gpt-4')) {
|
|
15928
15929
|
return 8192;
|
|
15929
15930
|
}
|
|
15930
|
-
if (model.includes(
|
|
15931
|
+
if (model.includes('gpt-3.5-turbo-16k')) {
|
|
15931
15932
|
return 16385;
|
|
15932
15933
|
}
|
|
15933
|
-
if (model.includes(
|
|
15934
|
+
if (model.includes('gpt-3.5-turbo')) {
|
|
15934
15935
|
return 4096;
|
|
15935
15936
|
}
|
|
15936
15937
|
// Default fallback
|
|
@@ -15944,14 +15945,14 @@ class OpenAIProvider {
|
|
|
15944
15945
|
function createLLMProvider(provider, config) {
|
|
15945
15946
|
const normalizedProvider = provider.toLowerCase();
|
|
15946
15947
|
switch (normalizedProvider) {
|
|
15947
|
-
case
|
|
15948
|
+
case 'openai':
|
|
15948
15949
|
return new OpenAIProvider(config);
|
|
15949
|
-
case
|
|
15950
|
+
case 'anthropic':
|
|
15950
15951
|
return new AnthropicProvider(config);
|
|
15951
|
-
case
|
|
15952
|
-
case
|
|
15952
|
+
case 'google':
|
|
15953
|
+
case 'gemini':
|
|
15953
15954
|
return new GoogleProvider(config);
|
|
15954
|
-
case
|
|
15955
|
+
case 'ollama':
|
|
15955
15956
|
return new OllamaProvider(config);
|
|
15956
15957
|
default:
|
|
15957
15958
|
throw new Error(`Unknown LLM provider: ${provider}. Supported providers: openai, anthropic, google, ollama`);
|
|
@@ -15967,7 +15968,7 @@ const llm = {
|
|
|
15967
15968
|
openai: (config) => {
|
|
15968
15969
|
return new OpenAIProvider({
|
|
15969
15970
|
...config,
|
|
15970
|
-
model: config.model ||
|
|
15971
|
+
model: config.model || 'gpt-4',
|
|
15971
15972
|
});
|
|
15972
15973
|
},
|
|
15973
15974
|
/**
|
|
@@ -15976,7 +15977,7 @@ const llm = {
|
|
|
15976
15977
|
anthropic: (config) => {
|
|
15977
15978
|
return new AnthropicProvider({
|
|
15978
15979
|
...config,
|
|
15979
|
-
model: config.model ||
|
|
15980
|
+
model: config.model || 'claude-3-5-sonnet-20241022',
|
|
15980
15981
|
});
|
|
15981
15982
|
},
|
|
15982
15983
|
/**
|
|
@@ -15985,7 +15986,7 @@ const llm = {
|
|
|
15985
15986
|
google: (config) => {
|
|
15986
15987
|
return new GoogleProvider({
|
|
15987
15988
|
...config,
|
|
15988
|
-
model: config.model ||
|
|
15989
|
+
model: config.model || 'gemini-1.5-pro',
|
|
15989
15990
|
});
|
|
15990
15991
|
},
|
|
15991
15992
|
/**
|
|
@@ -15994,11 +15995,241 @@ const llm = {
|
|
|
15994
15995
|
ollama: (config) => {
|
|
15995
15996
|
return new OllamaProvider({
|
|
15996
15997
|
...config,
|
|
15997
|
-
model: config.model ||
|
|
15998
|
+
model: config.model || 'llama2',
|
|
15998
15999
|
});
|
|
15999
16000
|
},
|
|
16000
16001
|
};
|
|
16001
16002
|
|
|
16003
|
+
class BaseMemoryStorage {
|
|
16004
|
+
}
|
|
16005
|
+
|
|
16006
|
+
class InMemoryStorage extends BaseMemoryStorage {
|
|
16007
|
+
constructor() {
|
|
16008
|
+
super(...arguments);
|
|
16009
|
+
this.storage = new Map();
|
|
16010
|
+
}
|
|
16011
|
+
async add(sessionId, message) {
|
|
16012
|
+
if (!this.storage.has(sessionId)) {
|
|
16013
|
+
this.storage.set(sessionId, []);
|
|
16014
|
+
}
|
|
16015
|
+
this.storage.get(sessionId).push(message);
|
|
16016
|
+
}
|
|
16017
|
+
async get(sessionId, limit) {
|
|
16018
|
+
const messages = this.storage.get(sessionId) || [];
|
|
16019
|
+
if (limit) {
|
|
16020
|
+
return messages.slice(-limit);
|
|
16021
|
+
}
|
|
16022
|
+
return messages;
|
|
16023
|
+
}
|
|
16024
|
+
async clear(sessionId) {
|
|
16025
|
+
this.storage.set(sessionId, []);
|
|
16026
|
+
}
|
|
16027
|
+
async delete(sessionId) {
|
|
16028
|
+
this.storage.delete(sessionId);
|
|
16029
|
+
}
|
|
16030
|
+
async exists(sessionId) {
|
|
16031
|
+
return this.storage.has(sessionId);
|
|
16032
|
+
}
|
|
16033
|
+
}
|
|
16034
|
+
|
|
16035
|
+
class PostgresStorage extends BaseMemoryStorage {
|
|
16036
|
+
constructor(config) {
|
|
16037
|
+
super();
|
|
16038
|
+
this.initialized = false;
|
|
16039
|
+
this.tableName = config.tableName || 'sekuire_memory';
|
|
16040
|
+
this.initPool(config);
|
|
16041
|
+
}
|
|
16042
|
+
async initPool(config) {
|
|
16043
|
+
try {
|
|
16044
|
+
const { Pool } = await import('pg');
|
|
16045
|
+
if (config.connectionString) {
|
|
16046
|
+
this.pool = new Pool({ connectionString: config.connectionString });
|
|
16047
|
+
}
|
|
16048
|
+
else {
|
|
16049
|
+
this.pool = new Pool({
|
|
16050
|
+
host: config.host || 'localhost',
|
|
16051
|
+
port: config.port || 5432,
|
|
16052
|
+
database: config.database,
|
|
16053
|
+
user: config.user,
|
|
16054
|
+
password: config.password,
|
|
16055
|
+
});
|
|
16056
|
+
}
|
|
16057
|
+
await this.createTableIfNotExists();
|
|
16058
|
+
this.initialized = true;
|
|
16059
|
+
}
|
|
16060
|
+
catch (error) {
|
|
16061
|
+
throw new Error(`Failed to initialize Postgres: ${error}`);
|
|
16062
|
+
}
|
|
16063
|
+
}
|
|
16064
|
+
async createTableIfNotExists() {
|
|
16065
|
+
const query = `
|
|
16066
|
+
CREATE TABLE IF NOT EXISTS ${this.tableName} (
|
|
16067
|
+
id SERIAL PRIMARY KEY,
|
|
16068
|
+
session_id VARCHAR(255) NOT NULL,
|
|
16069
|
+
role VARCHAR(50) NOT NULL,
|
|
16070
|
+
content TEXT NOT NULL,
|
|
16071
|
+
timestamp BIGINT NOT NULL,
|
|
16072
|
+
metadata JSONB,
|
|
16073
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
16074
|
+
);
|
|
16075
|
+
CREATE INDEX IF NOT EXISTS idx_${this.tableName}_session_id ON ${this.tableName}(session_id);
|
|
16076
|
+
`;
|
|
16077
|
+
await this.pool.query(query);
|
|
16078
|
+
}
|
|
16079
|
+
async add(sessionId, message) {
|
|
16080
|
+
if (!this.initialized)
|
|
16081
|
+
throw new Error('Postgres not initialized');
|
|
16082
|
+
const query = `
|
|
16083
|
+
INSERT INTO ${this.tableName} (session_id, role, content, timestamp, metadata)
|
|
16084
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
16085
|
+
`;
|
|
16086
|
+
await this.pool.query(query, [
|
|
16087
|
+
sessionId,
|
|
16088
|
+
message.role,
|
|
16089
|
+
message.content,
|
|
16090
|
+
message.timestamp,
|
|
16091
|
+
message.metadata ? JSON.stringify(message.metadata) : null,
|
|
16092
|
+
]);
|
|
16093
|
+
}
|
|
16094
|
+
async get(sessionId, limit) {
|
|
16095
|
+
if (!this.initialized)
|
|
16096
|
+
throw new Error('Postgres not initialized');
|
|
16097
|
+
let query = `
|
|
16098
|
+
SELECT role, content, timestamp, metadata
|
|
16099
|
+
FROM ${this.tableName}
|
|
16100
|
+
WHERE session_id = $1
|
|
16101
|
+
ORDER BY timestamp ASC
|
|
16102
|
+
`;
|
|
16103
|
+
if (limit) {
|
|
16104
|
+
query += ` LIMIT ${limit}`;
|
|
16105
|
+
}
|
|
16106
|
+
const result = await this.pool.query(query, [sessionId]);
|
|
16107
|
+
return result.rows.map((row) => ({
|
|
16108
|
+
role: row.role,
|
|
16109
|
+
content: row.content,
|
|
16110
|
+
timestamp: row.timestamp,
|
|
16111
|
+
metadata: row.metadata,
|
|
16112
|
+
}));
|
|
16113
|
+
}
|
|
16114
|
+
async clear(sessionId) {
|
|
16115
|
+
if (!this.initialized)
|
|
16116
|
+
throw new Error('Postgres not initialized');
|
|
16117
|
+
const query = `DELETE FROM ${this.tableName} WHERE session_id = $1`;
|
|
16118
|
+
await this.pool.query(query, [sessionId]);
|
|
16119
|
+
}
|
|
16120
|
+
async delete(sessionId) {
|
|
16121
|
+
await this.clear(sessionId);
|
|
16122
|
+
}
|
|
16123
|
+
async exists(sessionId) {
|
|
16124
|
+
if (!this.initialized)
|
|
16125
|
+
throw new Error('Postgres not initialized');
|
|
16126
|
+
const query = `SELECT COUNT(*) FROM ${this.tableName} WHERE session_id = $1`;
|
|
16127
|
+
const result = await this.pool.query(query, [sessionId]);
|
|
16128
|
+
return parseInt(result.rows[0].count) > 0;
|
|
16129
|
+
}
|
|
16130
|
+
async disconnect() {
|
|
16131
|
+
if (this.initialized) {
|
|
16132
|
+
await this.pool.end();
|
|
16133
|
+
this.initialized = false;
|
|
16134
|
+
}
|
|
16135
|
+
}
|
|
16136
|
+
}
|
|
16137
|
+
|
|
16138
|
+
class RedisStorage extends BaseMemoryStorage {
|
|
16139
|
+
constructor(config) {
|
|
16140
|
+
super();
|
|
16141
|
+
this.client = null;
|
|
16142
|
+
this.connected = false;
|
|
16143
|
+
this.keyPrefix = config.keyPrefix || 'sekuire:memory:';
|
|
16144
|
+
this.initClient(config);
|
|
16145
|
+
}
|
|
16146
|
+
async initClient(config) {
|
|
16147
|
+
try {
|
|
16148
|
+
const { createClient } = await import('redis');
|
|
16149
|
+
if (config.url) {
|
|
16150
|
+
this.client = createClient({ url: config.url });
|
|
16151
|
+
}
|
|
16152
|
+
else {
|
|
16153
|
+
this.client = createClient({
|
|
16154
|
+
socket: {
|
|
16155
|
+
host: config.host || 'localhost',
|
|
16156
|
+
port: config.port || 6379,
|
|
16157
|
+
},
|
|
16158
|
+
password: config.password,
|
|
16159
|
+
database: config.db || 0,
|
|
16160
|
+
});
|
|
16161
|
+
}
|
|
16162
|
+
this.client.on('error', (err) => {
|
|
16163
|
+
console.error('Redis client error:', err);
|
|
16164
|
+
});
|
|
16165
|
+
await this.client.connect();
|
|
16166
|
+
this.connected = true;
|
|
16167
|
+
}
|
|
16168
|
+
catch (error) {
|
|
16169
|
+
throw new Error(`Failed to initialize Redis: ${error}`);
|
|
16170
|
+
}
|
|
16171
|
+
}
|
|
16172
|
+
getKey(sessionId) {
|
|
16173
|
+
return `${this.keyPrefix}${sessionId}`;
|
|
16174
|
+
}
|
|
16175
|
+
async add(sessionId, message) {
|
|
16176
|
+
if (!this.connected)
|
|
16177
|
+
throw new Error('Redis not connected');
|
|
16178
|
+
const key = this.getKey(sessionId);
|
|
16179
|
+
await this.client.rPush(key, JSON.stringify(message));
|
|
16180
|
+
}
|
|
16181
|
+
async get(sessionId, limit) {
|
|
16182
|
+
if (!this.connected)
|
|
16183
|
+
throw new Error('Redis not connected');
|
|
16184
|
+
const key = this.getKey(sessionId);
|
|
16185
|
+
const start = limit ? -limit : 0;
|
|
16186
|
+
const messages = await this.client.lRange(key, start, -1);
|
|
16187
|
+
return messages.map((msg) => JSON.parse(msg));
|
|
16188
|
+
}
|
|
16189
|
+
async clear(sessionId) {
|
|
16190
|
+
if (!this.connected)
|
|
16191
|
+
throw new Error('Redis not connected');
|
|
16192
|
+
const key = this.getKey(sessionId);
|
|
16193
|
+
await this.client.del(key);
|
|
16194
|
+
}
|
|
16195
|
+
async delete(sessionId) {
|
|
16196
|
+
await this.clear(sessionId);
|
|
16197
|
+
}
|
|
16198
|
+
async exists(sessionId) {
|
|
16199
|
+
if (!this.connected)
|
|
16200
|
+
throw new Error('Redis not connected');
|
|
16201
|
+
const key = this.getKey(sessionId);
|
|
16202
|
+
return (await this.client.exists(key)) === 1;
|
|
16203
|
+
}
|
|
16204
|
+
async disconnect() {
|
|
16205
|
+
if (this.connected) {
|
|
16206
|
+
await this.client.quit();
|
|
16207
|
+
this.connected = false;
|
|
16208
|
+
}
|
|
16209
|
+
}
|
|
16210
|
+
}
|
|
16211
|
+
|
|
16212
|
+
function createMemoryStorage(config) {
|
|
16213
|
+
// Normalize type (support "buffer" as alias for "in-memory")
|
|
16214
|
+
const normalizedType = config.type === 'buffer' ? 'in-memory' : config.type;
|
|
16215
|
+
switch (normalizedType) {
|
|
16216
|
+
case 'in-memory':
|
|
16217
|
+
return new InMemoryStorage();
|
|
16218
|
+
case 'redis':
|
|
16219
|
+
if (!config.redis) {
|
|
16220
|
+
throw new Error('Redis config required for redis memory type');
|
|
16221
|
+
}
|
|
16222
|
+
return new RedisStorage(config.redis);
|
|
16223
|
+
case 'postgres':
|
|
16224
|
+
if (!config.postgres) {
|
|
16225
|
+
throw new Error('Postgres config required for postgres memory type');
|
|
16226
|
+
}
|
|
16227
|
+
return new PostgresStorage(config.postgres);
|
|
16228
|
+
default:
|
|
16229
|
+
throw new Error(`Unknown memory type: ${config.type}`);
|
|
16230
|
+
}
|
|
16231
|
+
}
|
|
16232
|
+
|
|
16002
16233
|
function getDefaultExportFromCjs (x) {
|
|
16003
16234
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
16004
16235
|
}
|
|
@@ -16636,10 +16867,10 @@ class Tool {
|
|
|
16636
16867
|
if (param.name in input) {
|
|
16637
16868
|
const value = input[param.name];
|
|
16638
16869
|
const actualType = typeof value;
|
|
16639
|
-
if (param.type ===
|
|
16870
|
+
if (param.type === 'object' && actualType !== 'object') {
|
|
16640
16871
|
throw new Error(`Parameter ${param.name} must be an object`);
|
|
16641
16872
|
}
|
|
16642
|
-
if (param.type !==
|
|
16873
|
+
if (param.type !== 'object' && actualType !== param.type) {
|
|
16643
16874
|
throw new Error(`Parameter ${param.name} must be of type ${param.type}`);
|
|
16644
16875
|
}
|
|
16645
16876
|
}
|
|
@@ -16651,7 +16882,7 @@ class Tool {
|
|
|
16651
16882
|
name: this.metadata.name,
|
|
16652
16883
|
description: this.metadata.description,
|
|
16653
16884
|
parameters: {
|
|
16654
|
-
type:
|
|
16885
|
+
type: 'object',
|
|
16655
16886
|
properties: Object.fromEntries(this.metadata.parameters.map((p) => [
|
|
16656
16887
|
p.name,
|
|
16657
16888
|
{
|
|
@@ -16660,9 +16891,7 @@ class Tool {
|
|
|
16660
16891
|
...(p.default && { default: p.default }),
|
|
16661
16892
|
},
|
|
16662
16893
|
])),
|
|
16663
|
-
required: this.metadata.parameters
|
|
16664
|
-
.filter((p) => p.required)
|
|
16665
|
-
.map((p) => p.name),
|
|
16894
|
+
required: this.metadata.parameters.filter((p) => p.required).map((p) => p.name),
|
|
16666
16895
|
},
|
|
16667
16896
|
};
|
|
16668
16897
|
}
|
|
@@ -16675,7 +16904,7 @@ class ToolRegistry {
|
|
|
16675
16904
|
register(tool) {
|
|
16676
16905
|
this.tools.set(tool.metadata.name, tool);
|
|
16677
16906
|
// Track by category
|
|
16678
|
-
const category = tool.metadata.category ||
|
|
16907
|
+
const category = tool.metadata.category || 'general';
|
|
16679
16908
|
if (!this.categories.has(category)) {
|
|
16680
16909
|
this.categories.set(category, new Set());
|
|
16681
16910
|
}
|
|
@@ -16755,7 +16984,7 @@ class AgentDiscoveryTool extends Tool {
|
|
|
16755
16984
|
};
|
|
16756
16985
|
}
|
|
16757
16986
|
async execute(input) {
|
|
16758
|
-
const { capability, tag, category, verified_only = false, scope = 'workspace' } = input;
|
|
16987
|
+
const { capability, tag, category, verified_only = false, scope = 'workspace', } = input;
|
|
16759
16988
|
try {
|
|
16760
16989
|
const workspaceId = process.env.SEKUIRE_WORKSPACE_ID;
|
|
16761
16990
|
const orgId = process.env.SEKUIRE_ORG_ID;
|
|
@@ -16843,7 +17072,7 @@ class AgentDelegationTool extends Tool {
|
|
|
16843
17072
|
};
|
|
16844
17073
|
}
|
|
16845
17074
|
async execute(input) {
|
|
16846
|
-
const { target_agent_id, capability, task, timeout_seconds = 30 } = input;
|
|
17075
|
+
const { target_agent_id, capability, task, timeout_seconds = 30, } = input;
|
|
16847
17076
|
try {
|
|
16848
17077
|
// Determine target agent
|
|
16849
17078
|
let targetId = target_agent_id;
|
|
@@ -16853,7 +17082,7 @@ class AgentDelegationTool extends Tool {
|
|
|
16853
17082
|
const discoveryResult = await discoveryTool.execute({
|
|
16854
17083
|
capability: String(capability),
|
|
16855
17084
|
verified_only: true,
|
|
16856
|
-
scope: 'workspace'
|
|
17085
|
+
scope: 'workspace',
|
|
16857
17086
|
});
|
|
16858
17087
|
// Parse first agent from discovery result (simplified)
|
|
16859
17088
|
const match = String(discoveryResult).match(/\(sekuire_agent_[a-zA-Z0-9]+\)/);
|
|
@@ -16972,38 +17201,38 @@ class AgentStatusTool extends Tool {
|
|
|
16972
17201
|
* Performs handshake and sends requests to verified agents
|
|
16973
17202
|
*/
|
|
16974
17203
|
class InvokeAgentTool {
|
|
16975
|
-
constructor(privateKey, publicKey, registryUrl =
|
|
17204
|
+
constructor(privateKey, publicKey, registryUrl = 'https://api.sekuire.com') {
|
|
16976
17205
|
this.privateKey = privateKey;
|
|
16977
17206
|
this.publicKey = publicKey;
|
|
16978
17207
|
this.registryUrl = registryUrl;
|
|
16979
|
-
this.name =
|
|
16980
|
-
this.description =
|
|
17208
|
+
this.name = 'invoke_agent';
|
|
17209
|
+
this.description = 'Invoke another Sekuire agent by performing a secure handshake and sending a request. Use this to delegate tasks to specialized agents.';
|
|
16981
17210
|
this.parameters = {
|
|
16982
|
-
type:
|
|
17211
|
+
type: 'object',
|
|
16983
17212
|
properties: {
|
|
16984
17213
|
agent_url: {
|
|
16985
|
-
type:
|
|
16986
|
-
description:
|
|
17214
|
+
type: 'string',
|
|
17215
|
+
description: 'The base URL of the agent to invoke (e.g., https://agent.example.com)',
|
|
16987
17216
|
},
|
|
16988
17217
|
agent_id: {
|
|
16989
|
-
type:
|
|
16990
|
-
description:
|
|
17218
|
+
type: 'string',
|
|
17219
|
+
description: 'Optional: The expected agent ID for verification',
|
|
16991
17220
|
},
|
|
16992
17221
|
request: {
|
|
16993
|
-
type:
|
|
16994
|
-
description:
|
|
17222
|
+
type: 'string',
|
|
17223
|
+
description: 'The request/query to send to the agent',
|
|
16995
17224
|
},
|
|
16996
17225
|
parameters: {
|
|
16997
|
-
type:
|
|
16998
|
-
description:
|
|
17226
|
+
type: 'object',
|
|
17227
|
+
description: 'Optional: Additional parameters to pass to the agent',
|
|
16999
17228
|
},
|
|
17000
17229
|
},
|
|
17001
|
-
required: [
|
|
17230
|
+
required: ['agent_url', 'request'],
|
|
17002
17231
|
};
|
|
17003
17232
|
this.metadata = {
|
|
17004
|
-
category:
|
|
17233
|
+
category: 'agent_communication',
|
|
17005
17234
|
requiresAuth: true,
|
|
17006
|
-
riskLevel:
|
|
17235
|
+
riskLevel: 'medium',
|
|
17007
17236
|
};
|
|
17008
17237
|
this.client = null;
|
|
17009
17238
|
}
|
|
@@ -17025,16 +17254,16 @@ class InvokeAgentTool {
|
|
|
17025
17254
|
if (!handshakeResult.verified) {
|
|
17026
17255
|
return JSON.stringify({
|
|
17027
17256
|
success: false,
|
|
17028
|
-
error:
|
|
17257
|
+
error: 'Failed to verify agent identity during handshake',
|
|
17029
17258
|
agent_id: handshakeResult.agentId,
|
|
17030
17259
|
});
|
|
17031
17260
|
}
|
|
17032
17261
|
// Send request to the agent
|
|
17033
17262
|
const response = await fetch(`${agent_url}/agent/invoke`, {
|
|
17034
|
-
method:
|
|
17263
|
+
method: 'POST',
|
|
17035
17264
|
headers: {
|
|
17036
|
-
|
|
17037
|
-
|
|
17265
|
+
'Content-Type': 'application/json',
|
|
17266
|
+
'X-Sekuire-Agent-Id': handshakeResult.agentId,
|
|
17038
17267
|
},
|
|
17039
17268
|
body: JSON.stringify({
|
|
17040
17269
|
request,
|
|
@@ -17060,7 +17289,7 @@ class InvokeAgentTool {
|
|
|
17060
17289
|
catch (error) {
|
|
17061
17290
|
return JSON.stringify({
|
|
17062
17291
|
success: false,
|
|
17063
|
-
error: error instanceof Error ? error.message :
|
|
17292
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
17064
17293
|
});
|
|
17065
17294
|
}
|
|
17066
17295
|
}
|
|
@@ -17069,30 +17298,30 @@ class InvokeAgentTool {
|
|
|
17069
17298
|
* Tool for searching the Sekuire registry for agents
|
|
17070
17299
|
*/
|
|
17071
17300
|
class SearchAgentsTool {
|
|
17072
|
-
constructor(privateKey, publicKey, registryUrl =
|
|
17301
|
+
constructor(privateKey, publicKey, registryUrl = 'https://api.sekuire.com') {
|
|
17073
17302
|
this.privateKey = privateKey;
|
|
17074
17303
|
this.publicKey = publicKey;
|
|
17075
17304
|
this.registryUrl = registryUrl;
|
|
17076
|
-
this.name =
|
|
17077
|
-
this.description =
|
|
17305
|
+
this.name = 'search_agents';
|
|
17306
|
+
this.description = 'Search the Sekuire registry for agents by name, capability, or description. Returns a list of verified agents.';
|
|
17078
17307
|
this.parameters = {
|
|
17079
|
-
type:
|
|
17308
|
+
type: 'object',
|
|
17080
17309
|
properties: {
|
|
17081
17310
|
query: {
|
|
17082
|
-
type:
|
|
17083
|
-
description:
|
|
17311
|
+
type: 'string',
|
|
17312
|
+
description: 'Search query (agent name, capability, or description)',
|
|
17084
17313
|
},
|
|
17085
17314
|
limit: {
|
|
17086
|
-
type:
|
|
17087
|
-
description:
|
|
17315
|
+
type: 'number',
|
|
17316
|
+
description: 'Maximum number of results to return (default: 10)',
|
|
17088
17317
|
},
|
|
17089
17318
|
},
|
|
17090
|
-
required: [
|
|
17319
|
+
required: ['query'],
|
|
17091
17320
|
};
|
|
17092
17321
|
this.metadata = {
|
|
17093
|
-
category:
|
|
17322
|
+
category: 'agent_communication',
|
|
17094
17323
|
requiresAuth: false,
|
|
17095
|
-
riskLevel:
|
|
17324
|
+
riskLevel: 'low',
|
|
17096
17325
|
};
|
|
17097
17326
|
this.client = null;
|
|
17098
17327
|
}
|
|
@@ -17130,7 +17359,7 @@ class SearchAgentsTool {
|
|
|
17130
17359
|
catch (error) {
|
|
17131
17360
|
return JSON.stringify({
|
|
17132
17361
|
success: false,
|
|
17133
|
-
error: error instanceof Error ? error.message :
|
|
17362
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
17134
17363
|
agents: [],
|
|
17135
17364
|
});
|
|
17136
17365
|
}
|
|
@@ -17140,26 +17369,26 @@ class SearchAgentsTool {
|
|
|
17140
17369
|
* Tool for getting detailed information about a specific agent
|
|
17141
17370
|
*/
|
|
17142
17371
|
class GetAgentInfoTool {
|
|
17143
|
-
constructor(privateKey, publicKey, registryUrl =
|
|
17372
|
+
constructor(privateKey, publicKey, registryUrl = 'https://api.sekuire.com') {
|
|
17144
17373
|
this.privateKey = privateKey;
|
|
17145
17374
|
this.publicKey = publicKey;
|
|
17146
17375
|
this.registryUrl = registryUrl;
|
|
17147
|
-
this.name =
|
|
17148
|
-
this.description =
|
|
17376
|
+
this.name = 'get_agent_info';
|
|
17377
|
+
this.description = 'Get detailed information about a specific Sekuire agent including its verification status, capabilities, and public key.';
|
|
17149
17378
|
this.parameters = {
|
|
17150
|
-
type:
|
|
17379
|
+
type: 'object',
|
|
17151
17380
|
properties: {
|
|
17152
17381
|
agent_id: {
|
|
17153
|
-
type:
|
|
17154
|
-
description:
|
|
17382
|
+
type: 'string',
|
|
17383
|
+
description: 'The unique identifier of the agent',
|
|
17155
17384
|
},
|
|
17156
17385
|
},
|
|
17157
|
-
required: [
|
|
17386
|
+
required: ['agent_id'],
|
|
17158
17387
|
};
|
|
17159
17388
|
this.metadata = {
|
|
17160
|
-
category:
|
|
17389
|
+
category: 'agent_communication',
|
|
17161
17390
|
requiresAuth: false,
|
|
17162
|
-
riskLevel:
|
|
17391
|
+
riskLevel: 'low',
|
|
17163
17392
|
};
|
|
17164
17393
|
this.client = null;
|
|
17165
17394
|
}
|
|
@@ -17198,7 +17427,7 @@ class GetAgentInfoTool {
|
|
|
17198
17427
|
catch (error) {
|
|
17199
17428
|
return JSON.stringify({
|
|
17200
17429
|
success: false,
|
|
17201
|
-
error: error instanceof Error ? error.message :
|
|
17430
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
17202
17431
|
});
|
|
17203
17432
|
}
|
|
17204
17433
|
}
|
|
@@ -17208,18 +17437,18 @@ class CalculatorTool extends Tool {
|
|
|
17208
17437
|
constructor() {
|
|
17209
17438
|
super(...arguments);
|
|
17210
17439
|
this.metadata = {
|
|
17211
|
-
name:
|
|
17212
|
-
description:
|
|
17440
|
+
name: 'calculator',
|
|
17441
|
+
description: 'Perform mathematical calculations',
|
|
17213
17442
|
parameters: [
|
|
17214
17443
|
{
|
|
17215
|
-
name:
|
|
17216
|
-
type:
|
|
17444
|
+
name: 'expression',
|
|
17445
|
+
type: 'string',
|
|
17217
17446
|
description: 'Mathematical expression to evaluate (e.g., "2 + 2 * 3")',
|
|
17218
17447
|
required: true,
|
|
17219
17448
|
},
|
|
17220
17449
|
],
|
|
17221
|
-
category:
|
|
17222
|
-
compliance_level:
|
|
17450
|
+
category: 'utility',
|
|
17451
|
+
compliance_level: 'public',
|
|
17223
17452
|
};
|
|
17224
17453
|
}
|
|
17225
17454
|
async execute(input) {
|
|
@@ -17227,15 +17456,15 @@ class CalculatorTool extends Tool {
|
|
|
17227
17456
|
const expression = input.expression;
|
|
17228
17457
|
// Basic validation to prevent code injection
|
|
17229
17458
|
if (!/^[\d\s+\-*/.()]+$/.test(expression)) {
|
|
17230
|
-
throw new Error(
|
|
17459
|
+
throw new Error('Invalid expression. Only numbers and basic operators (+, -, *, /, .) are allowed');
|
|
17231
17460
|
}
|
|
17232
17461
|
try {
|
|
17233
17462
|
// Safe evaluation using Function constructor with restricted scope
|
|
17234
|
-
const result = new Function(
|
|
17463
|
+
const result = new Function('return ' + expression)();
|
|
17235
17464
|
return `${expression} = ${result}`;
|
|
17236
17465
|
}
|
|
17237
17466
|
catch (error) {
|
|
17238
|
-
throw new Error(`Calculation failed: ${error instanceof Error ? error.message :
|
|
17467
|
+
throw new Error(`Calculation failed: ${error instanceof Error ? error.message : 'Invalid expression'}`);
|
|
17239
17468
|
}
|
|
17240
17469
|
}
|
|
17241
17470
|
}
|
|
@@ -17244,23 +17473,23 @@ class AuditLogTool extends Tool {
|
|
|
17244
17473
|
constructor() {
|
|
17245
17474
|
super(...arguments);
|
|
17246
17475
|
this.metadata = {
|
|
17247
|
-
name:
|
|
17248
|
-
description:
|
|
17476
|
+
name: 'audit_log',
|
|
17477
|
+
description: 'Log action for compliance audit trail',
|
|
17249
17478
|
parameters: [],
|
|
17250
|
-
category:
|
|
17251
|
-
compliance_level:
|
|
17479
|
+
category: 'compliance',
|
|
17480
|
+
compliance_level: 'public',
|
|
17252
17481
|
};
|
|
17253
17482
|
}
|
|
17254
17483
|
async execute(input) {
|
|
17255
17484
|
const logEntry = {
|
|
17256
17485
|
timestamp: new Date().toISOString(),
|
|
17257
17486
|
action: input.action,
|
|
17258
|
-
actor: input.actor ||
|
|
17487
|
+
actor: input.actor || 'system',
|
|
17259
17488
|
resource: input.resource,
|
|
17260
17489
|
metadata: input.metadata,
|
|
17261
17490
|
};
|
|
17262
17491
|
// In production, send to logging service
|
|
17263
|
-
console.log(
|
|
17492
|
+
console.log('[AUDIT]', JSON.stringify(logEntry));
|
|
17264
17493
|
return { logged: true };
|
|
17265
17494
|
}
|
|
17266
17495
|
}
|
|
@@ -17268,11 +17497,11 @@ class PiiDetectTool extends Tool {
|
|
|
17268
17497
|
constructor() {
|
|
17269
17498
|
super(...arguments);
|
|
17270
17499
|
this.metadata = {
|
|
17271
|
-
name:
|
|
17272
|
-
description:
|
|
17500
|
+
name: 'pii_detect',
|
|
17501
|
+
description: 'Detect personally identifiable information in text',
|
|
17273
17502
|
parameters: [],
|
|
17274
|
-
category:
|
|
17275
|
-
compliance_level:
|
|
17503
|
+
category: 'compliance',
|
|
17504
|
+
compliance_level: 'public',
|
|
17276
17505
|
};
|
|
17277
17506
|
}
|
|
17278
17507
|
async execute(input) {
|
|
@@ -17303,24 +17532,24 @@ class EncryptDataTool extends Tool {
|
|
|
17303
17532
|
constructor() {
|
|
17304
17533
|
super(...arguments);
|
|
17305
17534
|
this.metadata = {
|
|
17306
|
-
name:
|
|
17307
|
-
description:
|
|
17535
|
+
name: 'encrypt_data',
|
|
17536
|
+
description: 'Encrypt sensitive data',
|
|
17308
17537
|
parameters: [],
|
|
17309
|
-
category:
|
|
17310
|
-
compliance_level:
|
|
17538
|
+
category: 'compliance',
|
|
17539
|
+
compliance_level: 'public',
|
|
17311
17540
|
};
|
|
17312
17541
|
}
|
|
17313
17542
|
async execute(input) {
|
|
17314
17543
|
const key = input.key
|
|
17315
|
-
? Buffer.from(crypto$2.createHash(
|
|
17544
|
+
? Buffer.from(crypto$2.createHash('sha256').update(input.key).digest('hex').slice(0, 32))
|
|
17316
17545
|
: crypto$2.randomBytes(32);
|
|
17317
17546
|
const iv = crypto$2.randomBytes(16);
|
|
17318
|
-
const cipher = crypto$2.createCipheriv(
|
|
17319
|
-
let encrypted = cipher.update(input.data,
|
|
17320
|
-
encrypted += cipher.final(
|
|
17547
|
+
const cipher = crypto$2.createCipheriv('aes-256-cbc', key, iv);
|
|
17548
|
+
let encrypted = cipher.update(input.data, 'utf8', 'hex');
|
|
17549
|
+
encrypted += cipher.final('hex');
|
|
17321
17550
|
return {
|
|
17322
17551
|
encrypted,
|
|
17323
|
-
iv: iv.toString(
|
|
17552
|
+
iv: iv.toString('hex'),
|
|
17324
17553
|
};
|
|
17325
17554
|
}
|
|
17326
17555
|
}
|
|
@@ -17328,19 +17557,19 @@ class DecryptDataTool extends Tool {
|
|
|
17328
17557
|
constructor() {
|
|
17329
17558
|
super(...arguments);
|
|
17330
17559
|
this.metadata = {
|
|
17331
|
-
name:
|
|
17332
|
-
description:
|
|
17560
|
+
name: 'decrypt_data',
|
|
17561
|
+
description: 'Decrypt encrypted data (HIGH RISK)',
|
|
17333
17562
|
parameters: [],
|
|
17334
|
-
category:
|
|
17335
|
-
compliance_level:
|
|
17563
|
+
category: 'compliance',
|
|
17564
|
+
compliance_level: 'public',
|
|
17336
17565
|
};
|
|
17337
17566
|
}
|
|
17338
17567
|
async execute(input) {
|
|
17339
|
-
const key = Buffer.from(crypto$2.createHash(
|
|
17340
|
-
const iv = Buffer.from(input.iv,
|
|
17341
|
-
const decipher = crypto$2.createDecipheriv(
|
|
17342
|
-
let decrypted = decipher.update(input.encrypted,
|
|
17343
|
-
decrypted += decipher.final(
|
|
17568
|
+
const key = Buffer.from(crypto$2.createHash('sha256').update(input.key).digest('hex').slice(0, 32));
|
|
17569
|
+
const iv = Buffer.from(input.iv, 'hex');
|
|
17570
|
+
const decipher = crypto$2.createDecipheriv('aes-256-cbc', key, iv);
|
|
17571
|
+
let decrypted = decipher.update(input.encrypted, 'hex', 'utf8');
|
|
17572
|
+
decrypted += decipher.final('utf8');
|
|
17344
17573
|
return decrypted;
|
|
17345
17574
|
}
|
|
17346
17575
|
}
|
|
@@ -17353,7 +17582,7 @@ class JsonStringifyTool extends Tool {
|
|
|
17353
17582
|
description: 'Convert object to JSON string',
|
|
17354
17583
|
parameters: [],
|
|
17355
17584
|
category: 'data',
|
|
17356
|
-
compliance_level: 'public'
|
|
17585
|
+
compliance_level: 'public',
|
|
17357
17586
|
};
|
|
17358
17587
|
}
|
|
17359
17588
|
async execute(input) {
|
|
@@ -17368,7 +17597,7 @@ class CsvParseTool extends Tool {
|
|
|
17368
17597
|
description: 'Parse CSV string to array of objects',
|
|
17369
17598
|
parameters: [],
|
|
17370
17599
|
category: 'data',
|
|
17371
|
-
compliance_level: 'public'
|
|
17600
|
+
compliance_level: 'public',
|
|
17372
17601
|
};
|
|
17373
17602
|
}
|
|
17374
17603
|
async execute(input) {
|
|
@@ -17378,11 +17607,11 @@ class CsvParseTool extends Tool {
|
|
|
17378
17607
|
if (lines.length === 0)
|
|
17379
17608
|
return [];
|
|
17380
17609
|
const headers = hasHeaders
|
|
17381
|
-
? lines[0].split(delimiter).map(h => h.trim())
|
|
17610
|
+
? lines[0].split(delimiter).map((h) => h.trim())
|
|
17382
17611
|
: Array.from({ length: lines[0].split(delimiter).length }, (_, i) => `column${i}`);
|
|
17383
17612
|
const startIndex = hasHeaders ? 1 : 0;
|
|
17384
|
-
return lines.slice(startIndex).map(line => {
|
|
17385
|
-
const values = line.split(delimiter).map(v => v.trim());
|
|
17613
|
+
return lines.slice(startIndex).map((line) => {
|
|
17614
|
+
const values = line.split(delimiter).map((v) => v.trim());
|
|
17386
17615
|
const obj = {};
|
|
17387
17616
|
headers.forEach((header, i) => {
|
|
17388
17617
|
obj[header] = values[i] || '';
|
|
@@ -17399,7 +17628,7 @@ class CsvWriteTool extends Tool {
|
|
|
17399
17628
|
description: 'Convert array of objects to CSV string',
|
|
17400
17629
|
parameters: [],
|
|
17401
17630
|
category: 'data',
|
|
17402
|
-
compliance_level: 'public'
|
|
17631
|
+
compliance_level: 'public',
|
|
17403
17632
|
};
|
|
17404
17633
|
}
|
|
17405
17634
|
async execute(input) {
|
|
@@ -17414,7 +17643,7 @@ class CsvWriteTool extends Tool {
|
|
|
17414
17643
|
rows.push(headers.join(delimiter));
|
|
17415
17644
|
}
|
|
17416
17645
|
for (const item of input.data) {
|
|
17417
|
-
const values = headers.map(header => {
|
|
17646
|
+
const values = headers.map((header) => {
|
|
17418
17647
|
const value = item[header]?.toString() || '';
|
|
17419
17648
|
// Escape values containing delimiter or quotes
|
|
17420
17649
|
return value.includes(delimiter) || value.includes('"')
|
|
@@ -17434,7 +17663,7 @@ class YamlParseTool extends Tool {
|
|
|
17434
17663
|
description: 'Parse YAML string to object',
|
|
17435
17664
|
parameters: [],
|
|
17436
17665
|
category: 'data',
|
|
17437
|
-
compliance_level: 'public'
|
|
17666
|
+
compliance_level: 'public',
|
|
17438
17667
|
};
|
|
17439
17668
|
}
|
|
17440
17669
|
async execute(input) {
|
|
@@ -17480,7 +17709,7 @@ class XmlParseTool extends Tool {
|
|
|
17480
17709
|
description: 'Parse XML string to object',
|
|
17481
17710
|
parameters: [],
|
|
17482
17711
|
category: 'data',
|
|
17483
|
-
compliance_level: 'public'
|
|
17712
|
+
compliance_level: 'public',
|
|
17484
17713
|
};
|
|
17485
17714
|
}
|
|
17486
17715
|
async execute(input) {
|
|
@@ -17500,18 +17729,18 @@ class JsonParseTool extends Tool {
|
|
|
17500
17729
|
constructor() {
|
|
17501
17730
|
super(...arguments);
|
|
17502
17731
|
this.metadata = {
|
|
17503
|
-
name:
|
|
17504
|
-
description:
|
|
17732
|
+
name: 'json_parse',
|
|
17733
|
+
description: 'Parse and format JSON string',
|
|
17505
17734
|
parameters: [
|
|
17506
17735
|
{
|
|
17507
|
-
name:
|
|
17508
|
-
type:
|
|
17509
|
-
description:
|
|
17736
|
+
name: 'json',
|
|
17737
|
+
type: 'string',
|
|
17738
|
+
description: 'JSON string to parse',
|
|
17510
17739
|
required: true,
|
|
17511
17740
|
},
|
|
17512
17741
|
],
|
|
17513
|
-
category:
|
|
17514
|
-
compliance_level:
|
|
17742
|
+
category: 'data',
|
|
17743
|
+
compliance_level: 'internal',
|
|
17515
17744
|
};
|
|
17516
17745
|
}
|
|
17517
17746
|
async execute(input) {
|
|
@@ -17522,7 +17751,7 @@ class JsonParseTool extends Tool {
|
|
|
17522
17751
|
return JSON.stringify(parsed, null, 2);
|
|
17523
17752
|
}
|
|
17524
17753
|
catch (error) {
|
|
17525
|
-
throw new Error(`Invalid JSON: ${error instanceof Error ? error.message :
|
|
17754
|
+
throw new Error(`Invalid JSON: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17526
17755
|
}
|
|
17527
17756
|
}
|
|
17528
17757
|
}
|
|
@@ -17530,52 +17759,52 @@ class Base64EncodeTool extends Tool {
|
|
|
17530
17759
|
constructor() {
|
|
17531
17760
|
super(...arguments);
|
|
17532
17761
|
this.metadata = {
|
|
17533
|
-
name:
|
|
17534
|
-
description:
|
|
17762
|
+
name: 'base64_encode',
|
|
17763
|
+
description: 'Encode text to base64',
|
|
17535
17764
|
parameters: [
|
|
17536
17765
|
{
|
|
17537
|
-
name:
|
|
17538
|
-
type:
|
|
17539
|
-
description:
|
|
17766
|
+
name: 'text',
|
|
17767
|
+
type: 'string',
|
|
17768
|
+
description: 'Text to encode',
|
|
17540
17769
|
required: true,
|
|
17541
17770
|
},
|
|
17542
17771
|
],
|
|
17543
|
-
category:
|
|
17544
|
-
compliance_level:
|
|
17772
|
+
category: 'data',
|
|
17773
|
+
compliance_level: 'internal',
|
|
17545
17774
|
};
|
|
17546
17775
|
}
|
|
17547
17776
|
async execute(input) {
|
|
17548
17777
|
this.validate(input);
|
|
17549
17778
|
const text = input.text;
|
|
17550
|
-
return Buffer.from(text).toString(
|
|
17779
|
+
return Buffer.from(text).toString('base64');
|
|
17551
17780
|
}
|
|
17552
17781
|
}
|
|
17553
17782
|
class Base64DecodeTool extends Tool {
|
|
17554
17783
|
constructor() {
|
|
17555
17784
|
super(...arguments);
|
|
17556
17785
|
this.metadata = {
|
|
17557
|
-
name:
|
|
17558
|
-
description:
|
|
17786
|
+
name: 'base64_decode',
|
|
17787
|
+
description: 'Decode base64 string to text',
|
|
17559
17788
|
parameters: [
|
|
17560
17789
|
{
|
|
17561
|
-
name:
|
|
17562
|
-
type:
|
|
17563
|
-
description:
|
|
17790
|
+
name: 'base64',
|
|
17791
|
+
type: 'string',
|
|
17792
|
+
description: 'Base64 string to decode',
|
|
17564
17793
|
required: true,
|
|
17565
17794
|
},
|
|
17566
17795
|
],
|
|
17567
|
-
category:
|
|
17568
|
-
compliance_level:
|
|
17796
|
+
category: 'data',
|
|
17797
|
+
compliance_level: 'internal',
|
|
17569
17798
|
};
|
|
17570
17799
|
}
|
|
17571
17800
|
async execute(input) {
|
|
17572
17801
|
this.validate(input);
|
|
17573
17802
|
const base64Str = input.base64;
|
|
17574
17803
|
try {
|
|
17575
|
-
return Buffer.from(base64Str,
|
|
17804
|
+
return Buffer.from(base64Str, 'base64').toString('utf-8');
|
|
17576
17805
|
}
|
|
17577
17806
|
catch (error) {
|
|
17578
|
-
throw new Error(`Invalid base64: ${error instanceof Error ? error.message :
|
|
17807
|
+
throw new Error(`Invalid base64: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17579
17808
|
}
|
|
17580
17809
|
}
|
|
17581
17810
|
}
|
|
@@ -17583,37 +17812,37 @@ class HashTool extends Tool {
|
|
|
17583
17812
|
constructor() {
|
|
17584
17813
|
super(...arguments);
|
|
17585
17814
|
this.metadata = {
|
|
17586
|
-
name:
|
|
17587
|
-
description:
|
|
17815
|
+
name: 'hash',
|
|
17816
|
+
description: 'Generate cryptographic hash (md5, sha256, sha512, etc.)',
|
|
17588
17817
|
parameters: [
|
|
17589
17818
|
{
|
|
17590
|
-
name:
|
|
17591
|
-
type:
|
|
17592
|
-
description:
|
|
17819
|
+
name: 'text',
|
|
17820
|
+
type: 'string',
|
|
17821
|
+
description: 'Text to hash',
|
|
17593
17822
|
required: true,
|
|
17594
17823
|
},
|
|
17595
17824
|
{
|
|
17596
|
-
name:
|
|
17597
|
-
type:
|
|
17598
|
-
description:
|
|
17825
|
+
name: 'algorithm',
|
|
17826
|
+
type: 'string',
|
|
17827
|
+
description: 'Hash algorithm (default: sha256)',
|
|
17599
17828
|
required: false,
|
|
17600
17829
|
},
|
|
17601
17830
|
],
|
|
17602
|
-
category:
|
|
17603
|
-
compliance_level:
|
|
17831
|
+
category: 'data',
|
|
17832
|
+
compliance_level: 'internal',
|
|
17604
17833
|
};
|
|
17605
17834
|
}
|
|
17606
17835
|
async execute(input) {
|
|
17607
17836
|
this.validate(input);
|
|
17608
17837
|
const text = input.text;
|
|
17609
|
-
const algorithm = input.algorithm ||
|
|
17838
|
+
const algorithm = input.algorithm || 'sha256';
|
|
17610
17839
|
try {
|
|
17611
17840
|
const hash = crypto__namespace.createHash(algorithm);
|
|
17612
17841
|
hash.update(text);
|
|
17613
|
-
return hash.digest(
|
|
17842
|
+
return hash.digest('hex');
|
|
17614
17843
|
}
|
|
17615
17844
|
catch (error) {
|
|
17616
|
-
throw new Error(`Hash generation failed: ${error instanceof Error ? error.message :
|
|
17845
|
+
throw new Error(`Hash generation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17617
17846
|
}
|
|
17618
17847
|
}
|
|
17619
17848
|
}
|
|
@@ -17622,36 +17851,36 @@ class DirectoryListTool extends Tool {
|
|
|
17622
17851
|
constructor() {
|
|
17623
17852
|
super(...arguments);
|
|
17624
17853
|
this.metadata = {
|
|
17625
|
-
name:
|
|
17626
|
-
description:
|
|
17854
|
+
name: 'dir_list',
|
|
17855
|
+
description: 'List contents of a directory',
|
|
17627
17856
|
parameters: [
|
|
17628
17857
|
{
|
|
17629
|
-
name:
|
|
17630
|
-
type:
|
|
17631
|
-
description:
|
|
17858
|
+
name: 'path',
|
|
17859
|
+
type: 'string',
|
|
17860
|
+
description: 'Path to the directory',
|
|
17632
17861
|
required: true,
|
|
17633
17862
|
},
|
|
17634
17863
|
],
|
|
17635
|
-
category:
|
|
17636
|
-
compliance_level:
|
|
17864
|
+
category: 'directories',
|
|
17865
|
+
compliance_level: 'internal',
|
|
17637
17866
|
};
|
|
17638
17867
|
}
|
|
17639
17868
|
async execute(input) {
|
|
17640
17869
|
this.validate(input);
|
|
17641
17870
|
const dirPath = input.path;
|
|
17642
17871
|
if (this.policyEnforcer) {
|
|
17643
|
-
this.policyEnforcer.enforceFilesystem(dirPath,
|
|
17872
|
+
this.policyEnforcer.enforceFilesystem(dirPath, 'read');
|
|
17644
17873
|
}
|
|
17645
17874
|
try {
|
|
17646
17875
|
const files = await fs__namespace$1.readdir(dirPath, { withFileTypes: true });
|
|
17647
17876
|
const formatted = files.map((file) => {
|
|
17648
|
-
const type = file.isDirectory() ?
|
|
17877
|
+
const type = file.isDirectory() ? '[DIR]' : '[FILE]';
|
|
17649
17878
|
return `${type} ${file.name}`;
|
|
17650
17879
|
});
|
|
17651
|
-
return formatted.join(
|
|
17880
|
+
return formatted.join('\n');
|
|
17652
17881
|
}
|
|
17653
17882
|
catch (error) {
|
|
17654
|
-
throw new Error(`Failed to list directory: ${error instanceof Error ? error.message :
|
|
17883
|
+
throw new Error(`Failed to list directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17655
17884
|
}
|
|
17656
17885
|
}
|
|
17657
17886
|
}
|
|
@@ -17659,40 +17888,40 @@ class DirectoryMkdirTool extends Tool {
|
|
|
17659
17888
|
constructor() {
|
|
17660
17889
|
super(...arguments);
|
|
17661
17890
|
this.metadata = {
|
|
17662
|
-
name:
|
|
17663
|
-
description:
|
|
17891
|
+
name: 'dir_mkdir',
|
|
17892
|
+
description: 'Create a new directory',
|
|
17664
17893
|
parameters: [
|
|
17665
17894
|
{
|
|
17666
|
-
name:
|
|
17667
|
-
type:
|
|
17668
|
-
description:
|
|
17895
|
+
name: 'path',
|
|
17896
|
+
type: 'string',
|
|
17897
|
+
description: 'Path to the directory to create',
|
|
17669
17898
|
required: true,
|
|
17670
17899
|
},
|
|
17671
17900
|
{
|
|
17672
|
-
name:
|
|
17673
|
-
type:
|
|
17901
|
+
name: 'recursive',
|
|
17902
|
+
type: 'boolean',
|
|
17674
17903
|
description: "Create parent directories if they don't exist",
|
|
17675
17904
|
required: false,
|
|
17676
17905
|
},
|
|
17677
17906
|
],
|
|
17678
|
-
category:
|
|
17679
|
-
compliance_level:
|
|
17907
|
+
category: 'directories',
|
|
17908
|
+
compliance_level: 'restricted',
|
|
17680
17909
|
requires_approval: true,
|
|
17681
17910
|
};
|
|
17682
17911
|
}
|
|
17683
17912
|
async execute(input) {
|
|
17684
17913
|
this.validate(input);
|
|
17685
17914
|
const dirPath = input.path;
|
|
17686
|
-
const recursive = input.recursive === true || input.recursive ===
|
|
17915
|
+
const recursive = input.recursive === true || input.recursive === 'true';
|
|
17687
17916
|
if (this.policyEnforcer) {
|
|
17688
|
-
this.policyEnforcer.enforceFilesystem(dirPath,
|
|
17917
|
+
this.policyEnforcer.enforceFilesystem(dirPath, 'write');
|
|
17689
17918
|
}
|
|
17690
17919
|
try {
|
|
17691
17920
|
await fs__namespace$1.mkdir(dirPath, { recursive });
|
|
17692
17921
|
return `Successfully created directory ${dirPath}`;
|
|
17693
17922
|
}
|
|
17694
17923
|
catch (error) {
|
|
17695
|
-
throw new Error(`Failed to create directory: ${error instanceof Error ? error.message :
|
|
17924
|
+
throw new Error(`Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17696
17925
|
}
|
|
17697
17926
|
}
|
|
17698
17927
|
}
|
|
@@ -17700,18 +17929,18 @@ class DirectoryRmdirTool extends Tool {
|
|
|
17700
17929
|
constructor() {
|
|
17701
17930
|
super(...arguments);
|
|
17702
17931
|
this.metadata = {
|
|
17703
|
-
name:
|
|
17704
|
-
description:
|
|
17932
|
+
name: 'dir_rmdir',
|
|
17933
|
+
description: 'Remove an empty directory',
|
|
17705
17934
|
parameters: [
|
|
17706
17935
|
{
|
|
17707
|
-
name:
|
|
17708
|
-
type:
|
|
17709
|
-
description:
|
|
17936
|
+
name: 'path',
|
|
17937
|
+
type: 'string',
|
|
17938
|
+
description: 'Path to the directory to remove',
|
|
17710
17939
|
required: true,
|
|
17711
17940
|
},
|
|
17712
17941
|
],
|
|
17713
|
-
category:
|
|
17714
|
-
compliance_level:
|
|
17942
|
+
category: 'directories',
|
|
17943
|
+
compliance_level: 'restricted',
|
|
17715
17944
|
requires_approval: true,
|
|
17716
17945
|
};
|
|
17717
17946
|
}
|
|
@@ -17719,14 +17948,14 @@ class DirectoryRmdirTool extends Tool {
|
|
|
17719
17948
|
this.validate(input);
|
|
17720
17949
|
const dirPath = input.path;
|
|
17721
17950
|
if (this.policyEnforcer) {
|
|
17722
|
-
this.policyEnforcer.enforceFilesystem(dirPath,
|
|
17951
|
+
this.policyEnforcer.enforceFilesystem(dirPath, 'delete');
|
|
17723
17952
|
}
|
|
17724
17953
|
try {
|
|
17725
17954
|
await fs__namespace$1.rmdir(dirPath);
|
|
17726
17955
|
return `Successfully removed directory ${dirPath}`;
|
|
17727
17956
|
}
|
|
17728
17957
|
catch (error) {
|
|
17729
|
-
throw new Error(`Failed to remove directory: ${error instanceof Error ? error.message :
|
|
17958
|
+
throw new Error(`Failed to remove directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17730
17959
|
}
|
|
17731
17960
|
}
|
|
17732
17961
|
}
|
|
@@ -17734,18 +17963,18 @@ class DirectoryRmRecursiveTool extends Tool {
|
|
|
17734
17963
|
constructor() {
|
|
17735
17964
|
super(...arguments);
|
|
17736
17965
|
this.metadata = {
|
|
17737
|
-
name:
|
|
17738
|
-
description:
|
|
17966
|
+
name: 'dir_rm_recursive',
|
|
17967
|
+
description: 'Remove a directory and all its contents (DANGEROUS - use with caution)',
|
|
17739
17968
|
parameters: [
|
|
17740
17969
|
{
|
|
17741
|
-
name:
|
|
17742
|
-
type:
|
|
17743
|
-
description:
|
|
17970
|
+
name: 'path',
|
|
17971
|
+
type: 'string',
|
|
17972
|
+
description: 'Path to the directory to remove recursively',
|
|
17744
17973
|
required: true,
|
|
17745
17974
|
},
|
|
17746
17975
|
],
|
|
17747
|
-
category:
|
|
17748
|
-
compliance_level:
|
|
17976
|
+
category: 'directories',
|
|
17977
|
+
compliance_level: 'restricted',
|
|
17749
17978
|
requires_approval: true,
|
|
17750
17979
|
};
|
|
17751
17980
|
}
|
|
@@ -17753,14 +17982,14 @@ class DirectoryRmRecursiveTool extends Tool {
|
|
|
17753
17982
|
this.validate(input);
|
|
17754
17983
|
const dirPath = input.path;
|
|
17755
17984
|
if (this.policyEnforcer) {
|
|
17756
|
-
this.policyEnforcer.enforceFilesystem(dirPath,
|
|
17985
|
+
this.policyEnforcer.enforceFilesystem(dirPath, 'delete');
|
|
17757
17986
|
}
|
|
17758
17987
|
try {
|
|
17759
17988
|
await fs__namespace$1.rm(dirPath, { recursive: true, force: true });
|
|
17760
17989
|
return `Successfully removed directory and contents: ${dirPath}`;
|
|
17761
17990
|
}
|
|
17762
17991
|
catch (error) {
|
|
17763
|
-
throw new Error(`Failed to remove directory recursively: ${error instanceof Error ? error.message :
|
|
17992
|
+
throw new Error(`Failed to remove directory recursively: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17764
17993
|
}
|
|
17765
17994
|
}
|
|
17766
17995
|
}
|
|
@@ -17768,32 +17997,32 @@ class DirectoryExistsTool extends Tool {
|
|
|
17768
17997
|
constructor() {
|
|
17769
17998
|
super(...arguments);
|
|
17770
17999
|
this.metadata = {
|
|
17771
|
-
name:
|
|
17772
|
-
description:
|
|
18000
|
+
name: 'dir_exists',
|
|
18001
|
+
description: 'Check if a directory exists',
|
|
17773
18002
|
parameters: [
|
|
17774
18003
|
{
|
|
17775
|
-
name:
|
|
17776
|
-
type:
|
|
17777
|
-
description:
|
|
18004
|
+
name: 'path',
|
|
18005
|
+
type: 'string',
|
|
18006
|
+
description: 'Path to check',
|
|
17778
18007
|
required: true,
|
|
17779
18008
|
},
|
|
17780
18009
|
],
|
|
17781
|
-
category:
|
|
17782
|
-
compliance_level:
|
|
18010
|
+
category: 'directories',
|
|
18011
|
+
compliance_level: 'internal',
|
|
17783
18012
|
};
|
|
17784
18013
|
}
|
|
17785
18014
|
async execute(input) {
|
|
17786
18015
|
this.validate(input);
|
|
17787
18016
|
const dirPath = input.path;
|
|
17788
18017
|
if (this.policyEnforcer) {
|
|
17789
|
-
this.policyEnforcer.enforceFilesystem(dirPath,
|
|
18018
|
+
this.policyEnforcer.enforceFilesystem(dirPath, 'read');
|
|
17790
18019
|
}
|
|
17791
18020
|
try {
|
|
17792
18021
|
const stats = await fs__namespace$1.stat(dirPath);
|
|
17793
|
-
return stats.isDirectory() ?
|
|
18022
|
+
return stats.isDirectory() ? 'true' : 'false';
|
|
17794
18023
|
}
|
|
17795
18024
|
catch {
|
|
17796
|
-
return
|
|
18025
|
+
return 'false';
|
|
17797
18026
|
}
|
|
17798
18027
|
}
|
|
17799
18028
|
}
|
|
@@ -17801,11 +18030,11 @@ class DirectoryMoveTool extends Tool {
|
|
|
17801
18030
|
constructor() {
|
|
17802
18031
|
super(...arguments);
|
|
17803
18032
|
this.metadata = {
|
|
17804
|
-
name:
|
|
17805
|
-
description:
|
|
18033
|
+
name: 'dir_move',
|
|
18034
|
+
description: 'Move or rename directory',
|
|
17806
18035
|
parameters: [],
|
|
17807
|
-
category:
|
|
17808
|
-
compliance_level:
|
|
18036
|
+
category: 'directories',
|
|
18037
|
+
compliance_level: 'public',
|
|
17809
18038
|
};
|
|
17810
18039
|
}
|
|
17811
18040
|
async execute(input) {
|
|
@@ -17817,11 +18046,11 @@ class DirectoryCopyTool extends Tool {
|
|
|
17817
18046
|
constructor() {
|
|
17818
18047
|
super(...arguments);
|
|
17819
18048
|
this.metadata = {
|
|
17820
|
-
name:
|
|
17821
|
-
description:
|
|
18049
|
+
name: 'dir_copy',
|
|
18050
|
+
description: 'Copy directory recursively',
|
|
17822
18051
|
parameters: [],
|
|
17823
|
-
category:
|
|
17824
|
-
compliance_level:
|
|
18052
|
+
category: 'directories',
|
|
18053
|
+
compliance_level: 'public',
|
|
17825
18054
|
};
|
|
17826
18055
|
}
|
|
17827
18056
|
async execute(input) {
|
|
@@ -17833,11 +18062,11 @@ class DirectoryTreeTool extends Tool {
|
|
|
17833
18062
|
constructor() {
|
|
17834
18063
|
super(...arguments);
|
|
17835
18064
|
this.metadata = {
|
|
17836
|
-
name:
|
|
17837
|
-
description:
|
|
18065
|
+
name: 'dir_tree',
|
|
18066
|
+
description: 'Get directory tree structure',
|
|
17838
18067
|
parameters: [],
|
|
17839
|
-
category:
|
|
17840
|
-
compliance_level:
|
|
18068
|
+
category: 'directories',
|
|
18069
|
+
compliance_level: 'public',
|
|
17841
18070
|
};
|
|
17842
18071
|
}
|
|
17843
18072
|
async execute(input) {
|
|
@@ -17856,7 +18085,7 @@ class DirectoryTreeTool extends Tool {
|
|
|
17856
18085
|
}
|
|
17857
18086
|
}
|
|
17858
18087
|
else {
|
|
17859
|
-
tree.children.push({ name: entry.name, type:
|
|
18088
|
+
tree.children.push({ name: entry.name, type: 'file' });
|
|
17860
18089
|
}
|
|
17861
18090
|
}
|
|
17862
18091
|
return tree;
|
|
@@ -17869,18 +18098,18 @@ class FileReadTool extends Tool {
|
|
|
17869
18098
|
constructor() {
|
|
17870
18099
|
super(...arguments);
|
|
17871
18100
|
this.metadata = {
|
|
17872
|
-
name:
|
|
17873
|
-
description:
|
|
18101
|
+
name: 'file_read',
|
|
18102
|
+
description: 'Read contents of a file',
|
|
17874
18103
|
parameters: [
|
|
17875
18104
|
{
|
|
17876
|
-
name:
|
|
17877
|
-
type:
|
|
17878
|
-
description:
|
|
18105
|
+
name: 'path',
|
|
18106
|
+
type: 'string',
|
|
18107
|
+
description: 'Path to the file to read',
|
|
17879
18108
|
required: true,
|
|
17880
18109
|
},
|
|
17881
18110
|
],
|
|
17882
|
-
category:
|
|
17883
|
-
compliance_level:
|
|
18111
|
+
category: 'filesystem',
|
|
18112
|
+
compliance_level: 'restricted',
|
|
17884
18113
|
requires_approval: true,
|
|
17885
18114
|
};
|
|
17886
18115
|
}
|
|
@@ -17888,14 +18117,14 @@ class FileReadTool extends Tool {
|
|
|
17888
18117
|
this.validate(input);
|
|
17889
18118
|
const filePath = input.path;
|
|
17890
18119
|
if (this.policyEnforcer) {
|
|
17891
|
-
this.policyEnforcer.enforceFilesystem(filePath,
|
|
18120
|
+
this.policyEnforcer.enforceFilesystem(filePath, 'read');
|
|
17892
18121
|
}
|
|
17893
18122
|
try {
|
|
17894
|
-
const content = await fs__namespace$1.readFile(filePath,
|
|
18123
|
+
const content = await fs__namespace$1.readFile(filePath, 'utf-8');
|
|
17895
18124
|
return content;
|
|
17896
18125
|
}
|
|
17897
18126
|
catch (error) {
|
|
17898
|
-
throw new Error(`Failed to read file: ${error instanceof Error ? error.message :
|
|
18127
|
+
throw new Error(`Failed to read file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17899
18128
|
}
|
|
17900
18129
|
}
|
|
17901
18130
|
}
|
|
@@ -17903,24 +18132,24 @@ class FileWriteTool extends Tool {
|
|
|
17903
18132
|
constructor() {
|
|
17904
18133
|
super(...arguments);
|
|
17905
18134
|
this.metadata = {
|
|
17906
|
-
name:
|
|
17907
|
-
description:
|
|
18135
|
+
name: 'file_write',
|
|
18136
|
+
description: 'Write content to a file',
|
|
17908
18137
|
parameters: [
|
|
17909
18138
|
{
|
|
17910
|
-
name:
|
|
17911
|
-
type:
|
|
17912
|
-
description:
|
|
18139
|
+
name: 'path',
|
|
18140
|
+
type: 'string',
|
|
18141
|
+
description: 'Path to the file to write',
|
|
17913
18142
|
required: true,
|
|
17914
18143
|
},
|
|
17915
18144
|
{
|
|
17916
|
-
name:
|
|
17917
|
-
type:
|
|
17918
|
-
description:
|
|
18145
|
+
name: 'content',
|
|
18146
|
+
type: 'string',
|
|
18147
|
+
description: 'Content to write to the file',
|
|
17919
18148
|
required: true,
|
|
17920
18149
|
},
|
|
17921
18150
|
],
|
|
17922
|
-
category:
|
|
17923
|
-
compliance_level:
|
|
18151
|
+
category: 'filesystem',
|
|
18152
|
+
compliance_level: 'restricted',
|
|
17924
18153
|
requires_approval: true,
|
|
17925
18154
|
};
|
|
17926
18155
|
}
|
|
@@ -17929,14 +18158,14 @@ class FileWriteTool extends Tool {
|
|
|
17929
18158
|
const filePath = input.path;
|
|
17930
18159
|
const content = input.content;
|
|
17931
18160
|
if (this.policyEnforcer) {
|
|
17932
|
-
this.policyEnforcer.enforceFilesystem(filePath,
|
|
18161
|
+
this.policyEnforcer.enforceFilesystem(filePath, 'write');
|
|
17933
18162
|
}
|
|
17934
18163
|
try {
|
|
17935
|
-
await fs__namespace$1.writeFile(filePath, content,
|
|
18164
|
+
await fs__namespace$1.writeFile(filePath, content, 'utf-8');
|
|
17936
18165
|
return `Successfully wrote to ${filePath}`;
|
|
17937
18166
|
}
|
|
17938
18167
|
catch (error) {
|
|
17939
|
-
throw new Error(`Failed to write file: ${error instanceof Error ? error.message :
|
|
18168
|
+
throw new Error(`Failed to write file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17940
18169
|
}
|
|
17941
18170
|
}
|
|
17942
18171
|
}
|
|
@@ -17944,32 +18173,32 @@ class FileListTool extends Tool {
|
|
|
17944
18173
|
constructor() {
|
|
17945
18174
|
super(...arguments);
|
|
17946
18175
|
this.metadata = {
|
|
17947
|
-
name:
|
|
17948
|
-
description:
|
|
18176
|
+
name: 'file_list',
|
|
18177
|
+
description: 'List files in a directory',
|
|
17949
18178
|
parameters: [
|
|
17950
18179
|
{
|
|
17951
|
-
name:
|
|
17952
|
-
type:
|
|
17953
|
-
description:
|
|
18180
|
+
name: 'path',
|
|
18181
|
+
type: 'string',
|
|
18182
|
+
description: 'Path to the directory',
|
|
17954
18183
|
required: true,
|
|
17955
18184
|
},
|
|
17956
18185
|
],
|
|
17957
|
-
category:
|
|
17958
|
-
compliance_level:
|
|
18186
|
+
category: 'filesystem',
|
|
18187
|
+
compliance_level: 'internal',
|
|
17959
18188
|
};
|
|
17960
18189
|
}
|
|
17961
18190
|
async execute(input) {
|
|
17962
18191
|
this.validate(input);
|
|
17963
18192
|
const dirPath = input.path;
|
|
17964
18193
|
if (this.policyEnforcer) {
|
|
17965
|
-
this.policyEnforcer.enforceFilesystem(dirPath,
|
|
18194
|
+
this.policyEnforcer.enforceFilesystem(dirPath, 'read');
|
|
17966
18195
|
}
|
|
17967
18196
|
try {
|
|
17968
18197
|
const files = await fs__namespace$1.readdir(dirPath);
|
|
17969
|
-
return files.join(
|
|
18198
|
+
return files.join('\n');
|
|
17970
18199
|
}
|
|
17971
18200
|
catch (error) {
|
|
17972
|
-
throw new Error(`Failed to list directory: ${error instanceof Error ? error.message :
|
|
18201
|
+
throw new Error(`Failed to list directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
17973
18202
|
}
|
|
17974
18203
|
}
|
|
17975
18204
|
}
|
|
@@ -17977,24 +18206,24 @@ class FileAppendTool extends Tool {
|
|
|
17977
18206
|
constructor() {
|
|
17978
18207
|
super(...arguments);
|
|
17979
18208
|
this.metadata = {
|
|
17980
|
-
name:
|
|
17981
|
-
description:
|
|
18209
|
+
name: 'file_append',
|
|
18210
|
+
description: 'Append content to the end of a file',
|
|
17982
18211
|
parameters: [
|
|
17983
18212
|
{
|
|
17984
|
-
name:
|
|
17985
|
-
type:
|
|
17986
|
-
description:
|
|
18213
|
+
name: 'path',
|
|
18214
|
+
type: 'string',
|
|
18215
|
+
description: 'Path to the file',
|
|
17987
18216
|
required: true,
|
|
17988
18217
|
},
|
|
17989
18218
|
{
|
|
17990
|
-
name:
|
|
17991
|
-
type:
|
|
17992
|
-
description:
|
|
18219
|
+
name: 'content',
|
|
18220
|
+
type: 'string',
|
|
18221
|
+
description: 'Content to append',
|
|
17993
18222
|
required: true,
|
|
17994
18223
|
},
|
|
17995
18224
|
],
|
|
17996
|
-
category:
|
|
17997
|
-
compliance_level:
|
|
18225
|
+
category: 'files',
|
|
18226
|
+
compliance_level: 'restricted',
|
|
17998
18227
|
requires_approval: true,
|
|
17999
18228
|
};
|
|
18000
18229
|
}
|
|
@@ -18003,14 +18232,14 @@ class FileAppendTool extends Tool {
|
|
|
18003
18232
|
const filePath = input.path;
|
|
18004
18233
|
const content = input.content;
|
|
18005
18234
|
if (this.policyEnforcer) {
|
|
18006
|
-
this.policyEnforcer.enforceFilesystem(filePath,
|
|
18235
|
+
this.policyEnforcer.enforceFilesystem(filePath, 'write');
|
|
18007
18236
|
}
|
|
18008
18237
|
try {
|
|
18009
|
-
await fs__namespace$1.appendFile(filePath, content,
|
|
18238
|
+
await fs__namespace$1.appendFile(filePath, content, 'utf-8');
|
|
18010
18239
|
return `Successfully appended to ${filePath}`;
|
|
18011
18240
|
}
|
|
18012
18241
|
catch (error) {
|
|
18013
|
-
throw new Error(`Failed to append to file: ${error instanceof Error ? error.message :
|
|
18242
|
+
throw new Error(`Failed to append to file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
18014
18243
|
}
|
|
18015
18244
|
}
|
|
18016
18245
|
}
|
|
@@ -18018,18 +18247,18 @@ class FileDeleteTool extends Tool {
|
|
|
18018
18247
|
constructor() {
|
|
18019
18248
|
super(...arguments);
|
|
18020
18249
|
this.metadata = {
|
|
18021
|
-
name:
|
|
18022
|
-
description:
|
|
18250
|
+
name: 'file_delete',
|
|
18251
|
+
description: 'Delete a file',
|
|
18023
18252
|
parameters: [
|
|
18024
18253
|
{
|
|
18025
|
-
name:
|
|
18026
|
-
type:
|
|
18027
|
-
description:
|
|
18254
|
+
name: 'path',
|
|
18255
|
+
type: 'string',
|
|
18256
|
+
description: 'Path to the file to delete',
|
|
18028
18257
|
required: true,
|
|
18029
18258
|
},
|
|
18030
18259
|
],
|
|
18031
|
-
category:
|
|
18032
|
-
compliance_level:
|
|
18260
|
+
category: 'files',
|
|
18261
|
+
compliance_level: 'restricted',
|
|
18033
18262
|
requires_approval: true,
|
|
18034
18263
|
};
|
|
18035
18264
|
}
|
|
@@ -18037,14 +18266,14 @@ class FileDeleteTool extends Tool {
|
|
|
18037
18266
|
this.validate(input);
|
|
18038
18267
|
const filePath = input.path;
|
|
18039
18268
|
if (this.policyEnforcer) {
|
|
18040
|
-
this.policyEnforcer.enforceFilesystem(filePath,
|
|
18269
|
+
this.policyEnforcer.enforceFilesystem(filePath, 'delete');
|
|
18041
18270
|
}
|
|
18042
18271
|
try {
|
|
18043
18272
|
await fs__namespace$1.unlink(filePath);
|
|
18044
18273
|
return `Successfully deleted ${filePath}`;
|
|
18045
18274
|
}
|
|
18046
18275
|
catch (error) {
|
|
18047
|
-
throw new Error(`Failed to delete file: ${error instanceof Error ? error.message :
|
|
18276
|
+
throw new Error(`Failed to delete file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
18048
18277
|
}
|
|
18049
18278
|
}
|
|
18050
18279
|
}
|
|
@@ -18052,24 +18281,24 @@ class FileMoveTool extends Tool {
|
|
|
18052
18281
|
constructor() {
|
|
18053
18282
|
super(...arguments);
|
|
18054
18283
|
this.metadata = {
|
|
18055
|
-
name:
|
|
18056
|
-
description:
|
|
18284
|
+
name: 'file_move',
|
|
18285
|
+
description: 'Move or rename a file',
|
|
18057
18286
|
parameters: [
|
|
18058
18287
|
{
|
|
18059
|
-
name:
|
|
18060
|
-
type:
|
|
18061
|
-
description:
|
|
18288
|
+
name: 'from',
|
|
18289
|
+
type: 'string',
|
|
18290
|
+
description: 'Source file path',
|
|
18062
18291
|
required: true,
|
|
18063
18292
|
},
|
|
18064
18293
|
{
|
|
18065
|
-
name:
|
|
18066
|
-
type:
|
|
18067
|
-
description:
|
|
18294
|
+
name: 'to',
|
|
18295
|
+
type: 'string',
|
|
18296
|
+
description: 'Destination file path',
|
|
18068
18297
|
required: true,
|
|
18069
18298
|
},
|
|
18070
18299
|
],
|
|
18071
|
-
category:
|
|
18072
|
-
compliance_level:
|
|
18300
|
+
category: 'files',
|
|
18301
|
+
compliance_level: 'restricted',
|
|
18073
18302
|
requires_approval: true,
|
|
18074
18303
|
};
|
|
18075
18304
|
}
|
|
@@ -18078,15 +18307,15 @@ class FileMoveTool extends Tool {
|
|
|
18078
18307
|
const fromPath = input.from;
|
|
18079
18308
|
const toPath = input.to;
|
|
18080
18309
|
if (this.policyEnforcer) {
|
|
18081
|
-
this.policyEnforcer.enforceFilesystem(fromPath,
|
|
18082
|
-
this.policyEnforcer.enforceFilesystem(toPath,
|
|
18310
|
+
this.policyEnforcer.enforceFilesystem(fromPath, 'read');
|
|
18311
|
+
this.policyEnforcer.enforceFilesystem(toPath, 'write');
|
|
18083
18312
|
}
|
|
18084
18313
|
try {
|
|
18085
18314
|
await fs__namespace$1.rename(fromPath, toPath);
|
|
18086
18315
|
return `Successfully moved ${fromPath} to ${toPath}`;
|
|
18087
18316
|
}
|
|
18088
18317
|
catch (error) {
|
|
18089
|
-
throw new Error(`Failed to move file: ${error instanceof Error ? error.message :
|
|
18318
|
+
throw new Error(`Failed to move file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
18090
18319
|
}
|
|
18091
18320
|
}
|
|
18092
18321
|
}
|
|
@@ -18094,24 +18323,24 @@ class FileCopyTool extends Tool {
|
|
|
18094
18323
|
constructor() {
|
|
18095
18324
|
super(...arguments);
|
|
18096
18325
|
this.metadata = {
|
|
18097
|
-
name:
|
|
18098
|
-
description:
|
|
18326
|
+
name: 'file_copy',
|
|
18327
|
+
description: 'Copy a file to another location',
|
|
18099
18328
|
parameters: [
|
|
18100
18329
|
{
|
|
18101
|
-
name:
|
|
18102
|
-
type:
|
|
18103
|
-
description:
|
|
18330
|
+
name: 'from',
|
|
18331
|
+
type: 'string',
|
|
18332
|
+
description: 'Source file path',
|
|
18104
18333
|
required: true,
|
|
18105
18334
|
},
|
|
18106
18335
|
{
|
|
18107
|
-
name:
|
|
18108
|
-
type:
|
|
18109
|
-
description:
|
|
18336
|
+
name: 'to',
|
|
18337
|
+
type: 'string',
|
|
18338
|
+
description: 'Destination file path',
|
|
18110
18339
|
required: true,
|
|
18111
18340
|
},
|
|
18112
18341
|
],
|
|
18113
|
-
category:
|
|
18114
|
-
compliance_level:
|
|
18342
|
+
category: 'files',
|
|
18343
|
+
compliance_level: 'restricted',
|
|
18115
18344
|
requires_approval: true,
|
|
18116
18345
|
};
|
|
18117
18346
|
}
|
|
@@ -18120,15 +18349,15 @@ class FileCopyTool extends Tool {
|
|
|
18120
18349
|
const fromPath = input.from;
|
|
18121
18350
|
const toPath = input.to;
|
|
18122
18351
|
if (this.policyEnforcer) {
|
|
18123
|
-
this.policyEnforcer.enforceFilesystem(fromPath,
|
|
18124
|
-
this.policyEnforcer.enforceFilesystem(toPath,
|
|
18352
|
+
this.policyEnforcer.enforceFilesystem(fromPath, 'read');
|
|
18353
|
+
this.policyEnforcer.enforceFilesystem(toPath, 'write');
|
|
18125
18354
|
}
|
|
18126
18355
|
try {
|
|
18127
18356
|
await fs__namespace$1.copyFile(fromPath, toPath);
|
|
18128
18357
|
return `Successfully copied ${fromPath} to ${toPath}`;
|
|
18129
18358
|
}
|
|
18130
18359
|
catch (error) {
|
|
18131
|
-
throw new Error(`Failed to copy file: ${error instanceof Error ? error.message :
|
|
18360
|
+
throw new Error(`Failed to copy file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
18132
18361
|
}
|
|
18133
18362
|
}
|
|
18134
18363
|
}
|
|
@@ -18136,25 +18365,25 @@ class FileStatTool extends Tool {
|
|
|
18136
18365
|
constructor() {
|
|
18137
18366
|
super(...arguments);
|
|
18138
18367
|
this.metadata = {
|
|
18139
|
-
name:
|
|
18140
|
-
description:
|
|
18368
|
+
name: 'file_stat',
|
|
18369
|
+
description: 'Get file metadata (size, dates, type)',
|
|
18141
18370
|
parameters: [
|
|
18142
18371
|
{
|
|
18143
|
-
name:
|
|
18144
|
-
type:
|
|
18145
|
-
description:
|
|
18372
|
+
name: 'path',
|
|
18373
|
+
type: 'string',
|
|
18374
|
+
description: 'Path to the file',
|
|
18146
18375
|
required: true,
|
|
18147
18376
|
},
|
|
18148
18377
|
],
|
|
18149
|
-
category:
|
|
18150
|
-
compliance_level:
|
|
18378
|
+
category: 'files',
|
|
18379
|
+
compliance_level: 'internal',
|
|
18151
18380
|
};
|
|
18152
18381
|
}
|
|
18153
18382
|
async execute(input) {
|
|
18154
18383
|
this.validate(input);
|
|
18155
18384
|
const filePath = input.path;
|
|
18156
18385
|
if (this.policyEnforcer) {
|
|
18157
|
-
this.policyEnforcer.enforceFilesystem(filePath,
|
|
18386
|
+
this.policyEnforcer.enforceFilesystem(filePath, 'read');
|
|
18158
18387
|
}
|
|
18159
18388
|
try {
|
|
18160
18389
|
const stats = await fs__namespace$1.stat(filePath);
|
|
@@ -18169,7 +18398,7 @@ class FileStatTool extends Tool {
|
|
|
18169
18398
|
}, null, 2);
|
|
18170
18399
|
}
|
|
18171
18400
|
catch (error) {
|
|
18172
|
-
throw new Error(`Failed to get file stats: ${error instanceof Error ? error.message :
|
|
18401
|
+
throw new Error(`Failed to get file stats: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
18173
18402
|
}
|
|
18174
18403
|
}
|
|
18175
18404
|
}
|
|
@@ -18177,32 +18406,32 @@ class FileExistsTool extends Tool {
|
|
|
18177
18406
|
constructor() {
|
|
18178
18407
|
super(...arguments);
|
|
18179
18408
|
this.metadata = {
|
|
18180
|
-
name:
|
|
18181
|
-
description:
|
|
18409
|
+
name: 'file_exists',
|
|
18410
|
+
description: 'Check if a file exists',
|
|
18182
18411
|
parameters: [
|
|
18183
18412
|
{
|
|
18184
|
-
name:
|
|
18185
|
-
type:
|
|
18186
|
-
description:
|
|
18413
|
+
name: 'path',
|
|
18414
|
+
type: 'string',
|
|
18415
|
+
description: 'Path to check',
|
|
18187
18416
|
required: true,
|
|
18188
18417
|
},
|
|
18189
18418
|
],
|
|
18190
|
-
category:
|
|
18191
|
-
compliance_level:
|
|
18419
|
+
category: 'files',
|
|
18420
|
+
compliance_level: 'internal',
|
|
18192
18421
|
};
|
|
18193
18422
|
}
|
|
18194
18423
|
async execute(input) {
|
|
18195
18424
|
this.validate(input);
|
|
18196
18425
|
const filePath = input.path;
|
|
18197
18426
|
if (this.policyEnforcer) {
|
|
18198
|
-
this.policyEnforcer.enforceFilesystem(filePath,
|
|
18427
|
+
this.policyEnforcer.enforceFilesystem(filePath, 'read');
|
|
18199
18428
|
}
|
|
18200
18429
|
try {
|
|
18201
18430
|
await fs__namespace$1.access(filePath);
|
|
18202
|
-
return
|
|
18431
|
+
return 'true';
|
|
18203
18432
|
}
|
|
18204
18433
|
catch {
|
|
18205
|
-
return
|
|
18434
|
+
return 'false';
|
|
18206
18435
|
}
|
|
18207
18436
|
}
|
|
18208
18437
|
}
|
|
@@ -18214,71 +18443,172 @@ class FileChmodTool extends Tool {
|
|
|
18214
18443
|
description: 'Change file permissions',
|
|
18215
18444
|
parameters: [],
|
|
18216
18445
|
category: 'files',
|
|
18217
|
-
compliance_level: 'public'
|
|
18446
|
+
compliance_level: 'public',
|
|
18218
18447
|
};
|
|
18219
18448
|
}
|
|
18220
18449
|
async execute(input) {
|
|
18221
|
-
const mode = typeof input.mode === 'string'
|
|
18222
|
-
? parseInt(input.mode, 8)
|
|
18223
|
-
: input.mode;
|
|
18450
|
+
const mode = typeof input.mode === 'string' ? parseInt(input.mode, 8) : input.mode;
|
|
18224
18451
|
await fs__namespace$1.chmod(input.path, mode);
|
|
18225
18452
|
return { changed: true };
|
|
18226
18453
|
}
|
|
18227
18454
|
}
|
|
18228
18455
|
|
|
18456
|
+
class GoogleDocsCreateTool extends Tool {
|
|
18457
|
+
constructor() {
|
|
18458
|
+
super(...arguments);
|
|
18459
|
+
this.metadata = {
|
|
18460
|
+
name: 'google_docs_create',
|
|
18461
|
+
description: 'Create a Google Doc (optionally in a folder) and write initial content. Requires GOOGLE_ACCESS_TOKEN or GOOGLE_DRIVE_MOCK=true.',
|
|
18462
|
+
parameters: [
|
|
18463
|
+
{
|
|
18464
|
+
name: 'title',
|
|
18465
|
+
type: 'string',
|
|
18466
|
+
description: 'Document title',
|
|
18467
|
+
required: true,
|
|
18468
|
+
},
|
|
18469
|
+
{
|
|
18470
|
+
name: 'content',
|
|
18471
|
+
type: 'string',
|
|
18472
|
+
description: 'Initial document body text',
|
|
18473
|
+
required: false,
|
|
18474
|
+
},
|
|
18475
|
+
{
|
|
18476
|
+
name: 'folder_id',
|
|
18477
|
+
type: 'string',
|
|
18478
|
+
description: 'Optional Google Drive folder ID (uses GOOGLE_DRIVE_FOLDER_ID if omitted)',
|
|
18479
|
+
required: false,
|
|
18480
|
+
},
|
|
18481
|
+
],
|
|
18482
|
+
category: 'google-workspace',
|
|
18483
|
+
compliance_level: 'restricted',
|
|
18484
|
+
requires_approval: false,
|
|
18485
|
+
};
|
|
18486
|
+
}
|
|
18487
|
+
async execute(input) {
|
|
18488
|
+
this.validate(input);
|
|
18489
|
+
const title = String(input.title);
|
|
18490
|
+
const content = typeof input.content === 'string' ? input.content : '';
|
|
18491
|
+
const folderId = typeof input.folder_id === 'string' ? input.folder_id : '';
|
|
18492
|
+
const mockMode = (process.env.GOOGLE_DRIVE_MOCK || '').toLowerCase() === 'true';
|
|
18493
|
+
if (mockMode) {
|
|
18494
|
+
const fakeId = `mock_${Date.now().toString(36)}`;
|
|
18495
|
+
return {
|
|
18496
|
+
documentId: fakeId,
|
|
18497
|
+
url: `https://docs.google.com/document/d/${fakeId}/edit`,
|
|
18498
|
+
};
|
|
18499
|
+
}
|
|
18500
|
+
const accessToken = (process.env.GOOGLE_ACCESS_TOKEN || '').trim();
|
|
18501
|
+
if (!accessToken) {
|
|
18502
|
+
throw new Error('Missing GOOGLE_ACCESS_TOKEN (or set GOOGLE_DRIVE_MOCK=true).');
|
|
18503
|
+
}
|
|
18504
|
+
const effectiveFolderId = (folderId || process.env.GOOGLE_DRIVE_FOLDER_ID || '').trim();
|
|
18505
|
+
const driveCreateBody = {
|
|
18506
|
+
name: title,
|
|
18507
|
+
mimeType: 'application/vnd.google-apps.document',
|
|
18508
|
+
};
|
|
18509
|
+
if (effectiveFolderId) {
|
|
18510
|
+
driveCreateBody.parents = [effectiveFolderId];
|
|
18511
|
+
}
|
|
18512
|
+
const driveRes = await fetch('https://www.googleapis.com/drive/v3/files?supportsAllDrives=true', {
|
|
18513
|
+
method: 'POST',
|
|
18514
|
+
headers: {
|
|
18515
|
+
Authorization: `Bearer ${accessToken}`,
|
|
18516
|
+
'Content-Type': 'application/json',
|
|
18517
|
+
},
|
|
18518
|
+
body: JSON.stringify(driveCreateBody),
|
|
18519
|
+
});
|
|
18520
|
+
if (!driveRes.ok) {
|
|
18521
|
+
const text = await driveRes.text().catch(() => '');
|
|
18522
|
+
throw new Error(`Drive create failed: ${driveRes.status} ${driveRes.statusText} ${text}`);
|
|
18523
|
+
}
|
|
18524
|
+
const driveJson = (await driveRes.json());
|
|
18525
|
+
const documentId = driveJson.id;
|
|
18526
|
+
if (!documentId) {
|
|
18527
|
+
throw new Error('Drive create returned no file id');
|
|
18528
|
+
}
|
|
18529
|
+
if (content.trim().length > 0) {
|
|
18530
|
+
const docsRes = await fetch(`https://docs.googleapis.com/v1/documents/${documentId}:batchUpdate`, {
|
|
18531
|
+
method: 'POST',
|
|
18532
|
+
headers: {
|
|
18533
|
+
Authorization: `Bearer ${accessToken}`,
|
|
18534
|
+
'Content-Type': 'application/json',
|
|
18535
|
+
},
|
|
18536
|
+
body: JSON.stringify({
|
|
18537
|
+
requests: [
|
|
18538
|
+
{
|
|
18539
|
+
insertText: {
|
|
18540
|
+
location: { index: 1 },
|
|
18541
|
+
text: content,
|
|
18542
|
+
},
|
|
18543
|
+
},
|
|
18544
|
+
],
|
|
18545
|
+
}),
|
|
18546
|
+
});
|
|
18547
|
+
if (!docsRes.ok) {
|
|
18548
|
+
const text = await docsRes.text().catch(() => '');
|
|
18549
|
+
throw new Error(`Docs update failed: ${docsRes.status} ${docsRes.statusText} ${text}`);
|
|
18550
|
+
}
|
|
18551
|
+
}
|
|
18552
|
+
return {
|
|
18553
|
+
documentId,
|
|
18554
|
+
url: `https://docs.google.com/document/d/${documentId}/edit`,
|
|
18555
|
+
};
|
|
18556
|
+
}
|
|
18557
|
+
}
|
|
18558
|
+
|
|
18229
18559
|
class HttpRequestTool extends Tool {
|
|
18230
18560
|
constructor() {
|
|
18231
18561
|
super(...arguments);
|
|
18232
18562
|
this.metadata = {
|
|
18233
|
-
name:
|
|
18234
|
-
description:
|
|
18563
|
+
name: 'http_request',
|
|
18564
|
+
description: 'Make HTTP requests to external APIs',
|
|
18235
18565
|
parameters: [
|
|
18236
18566
|
{
|
|
18237
|
-
name:
|
|
18238
|
-
type:
|
|
18239
|
-
description:
|
|
18567
|
+
name: 'url',
|
|
18568
|
+
type: 'string',
|
|
18569
|
+
description: 'The URL to make the request to',
|
|
18240
18570
|
required: true,
|
|
18241
18571
|
},
|
|
18242
18572
|
{
|
|
18243
|
-
name:
|
|
18244
|
-
type:
|
|
18245
|
-
description:
|
|
18573
|
+
name: 'method',
|
|
18574
|
+
type: 'string',
|
|
18575
|
+
description: 'HTTP method (GET, POST, PUT, DELETE)',
|
|
18246
18576
|
required: false,
|
|
18247
|
-
default:
|
|
18577
|
+
default: 'GET',
|
|
18248
18578
|
},
|
|
18249
18579
|
{
|
|
18250
|
-
name:
|
|
18251
|
-
type:
|
|
18252
|
-
description:
|
|
18580
|
+
name: 'headers',
|
|
18581
|
+
type: 'object',
|
|
18582
|
+
description: 'HTTP headers as key-value pairs',
|
|
18253
18583
|
required: false,
|
|
18254
18584
|
},
|
|
18255
18585
|
{
|
|
18256
|
-
name:
|
|
18257
|
-
type:
|
|
18258
|
-
description:
|
|
18586
|
+
name: 'body',
|
|
18587
|
+
type: 'object',
|
|
18588
|
+
description: 'Request body for POST/PUT requests',
|
|
18259
18589
|
required: false,
|
|
18260
18590
|
},
|
|
18261
18591
|
],
|
|
18262
|
-
category:
|
|
18263
|
-
compliance_level:
|
|
18592
|
+
category: 'network',
|
|
18593
|
+
compliance_level: 'internal',
|
|
18264
18594
|
requires_approval: true,
|
|
18265
18595
|
};
|
|
18266
18596
|
}
|
|
18267
18597
|
async execute(input) {
|
|
18268
18598
|
this.validate(input);
|
|
18269
18599
|
const url = input.url;
|
|
18270
|
-
const method = input.method?.toUpperCase() ||
|
|
18600
|
+
const method = input.method?.toUpperCase() || 'GET';
|
|
18271
18601
|
const headers = input.headers || {};
|
|
18272
18602
|
const body = input.body;
|
|
18273
18603
|
if (this.policyEnforcer) {
|
|
18274
18604
|
try {
|
|
18275
18605
|
const parsedUrl = new URL(url);
|
|
18276
18606
|
// Remove trailing colon from protocol (e.g., 'https:' -> 'https')
|
|
18277
|
-
const protocol = parsedUrl.protocol.replace(
|
|
18607
|
+
const protocol = parsedUrl.protocol.replace(':', '');
|
|
18278
18608
|
this.policyEnforcer.enforceNetwork(parsedUrl.hostname, protocol);
|
|
18279
18609
|
}
|
|
18280
18610
|
catch (e) {
|
|
18281
|
-
if (e instanceof Error && e.message.includes(
|
|
18611
|
+
if (e instanceof Error && e.message.includes('Invalid URL')) {
|
|
18282
18612
|
throw new Error(`Invalid URL: ${url}`);
|
|
18283
18613
|
}
|
|
18284
18614
|
throw e;
|
|
@@ -18302,7 +18632,7 @@ class HttpRequestTool extends Tool {
|
|
|
18302
18632
|
if (axios.isAxiosError(error)) {
|
|
18303
18633
|
throw new Error(`HTTP request failed: ${error.response?.status} - ${error.message}`);
|
|
18304
18634
|
}
|
|
18305
|
-
throw new Error(`HTTP request failed: ${error instanceof Error ? error.message :
|
|
18635
|
+
throw new Error(`HTTP request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
18306
18636
|
}
|
|
18307
18637
|
}
|
|
18308
18638
|
}
|
|
@@ -18315,7 +18645,7 @@ class HttpPostTool extends Tool {
|
|
|
18315
18645
|
description: 'Send HTTP POST request',
|
|
18316
18646
|
parameters: [],
|
|
18317
18647
|
category: 'network',
|
|
18318
|
-
compliance_level: 'public'
|
|
18648
|
+
compliance_level: 'public',
|
|
18319
18649
|
};
|
|
18320
18650
|
}
|
|
18321
18651
|
async execute(input) {
|
|
@@ -18332,7 +18662,9 @@ class HttpPostTool extends Tool {
|
|
|
18332
18662
|
statusText: response.statusText,
|
|
18333
18663
|
headers: (() => {
|
|
18334
18664
|
const h = {};
|
|
18335
|
-
response.headers.forEach((v, k) => {
|
|
18665
|
+
response.headers.forEach((v, k) => {
|
|
18666
|
+
h[k] = v;
|
|
18667
|
+
});
|
|
18336
18668
|
return h;
|
|
18337
18669
|
})(),
|
|
18338
18670
|
body: await response.text(),
|
|
@@ -18347,7 +18679,7 @@ class HttpPutTool extends Tool {
|
|
|
18347
18679
|
description: 'Send HTTP PUT request',
|
|
18348
18680
|
parameters: [],
|
|
18349
18681
|
category: 'network',
|
|
18350
|
-
compliance_level: 'public'
|
|
18682
|
+
compliance_level: 'public',
|
|
18351
18683
|
};
|
|
18352
18684
|
}
|
|
18353
18685
|
async execute(input) {
|
|
@@ -18364,7 +18696,9 @@ class HttpPutTool extends Tool {
|
|
|
18364
18696
|
statusText: response.statusText,
|
|
18365
18697
|
headers: (() => {
|
|
18366
18698
|
const h = {};
|
|
18367
|
-
response.headers.forEach((v, k) => {
|
|
18699
|
+
response.headers.forEach((v, k) => {
|
|
18700
|
+
h[k] = v;
|
|
18701
|
+
});
|
|
18368
18702
|
return h;
|
|
18369
18703
|
})(),
|
|
18370
18704
|
body: await response.text(),
|
|
@@ -18379,7 +18713,7 @@ class HttpDeleteTool extends Tool {
|
|
|
18379
18713
|
description: 'Send HTTP DELETE request',
|
|
18380
18714
|
parameters: [],
|
|
18381
18715
|
category: 'network',
|
|
18382
|
-
compliance_level: 'public'
|
|
18716
|
+
compliance_level: 'public',
|
|
18383
18717
|
};
|
|
18384
18718
|
}
|
|
18385
18719
|
async execute(input) {
|
|
@@ -18392,7 +18726,9 @@ class HttpDeleteTool extends Tool {
|
|
|
18392
18726
|
statusText: response.statusText,
|
|
18393
18727
|
headers: (() => {
|
|
18394
18728
|
const h = {};
|
|
18395
|
-
response.headers.forEach((v, k) => {
|
|
18729
|
+
response.headers.forEach((v, k) => {
|
|
18730
|
+
h[k] = v;
|
|
18731
|
+
});
|
|
18396
18732
|
return h;
|
|
18397
18733
|
})(),
|
|
18398
18734
|
body: await response.text(),
|
|
@@ -18407,7 +18743,7 @@ class DownloadFileTool extends Tool {
|
|
|
18407
18743
|
description: 'Download file from URL',
|
|
18408
18744
|
parameters: [],
|
|
18409
18745
|
category: 'network',
|
|
18410
|
-
compliance_level: 'public'
|
|
18746
|
+
compliance_level: 'public',
|
|
18411
18747
|
};
|
|
18412
18748
|
}
|
|
18413
18749
|
async execute(input) {
|
|
@@ -18415,7 +18751,8 @@ class DownloadFileTool extends Tool {
|
|
|
18415
18751
|
const protocol = parsedUrl.protocol === 'https:' ? https__namespace : http__namespace;
|
|
18416
18752
|
return new Promise((resolve, reject) => {
|
|
18417
18753
|
const file = fs__namespace.createWriteStream(input.destination);
|
|
18418
|
-
protocol
|
|
18754
|
+
protocol
|
|
18755
|
+
.get(input.url, (response) => {
|
|
18419
18756
|
if (response.statusCode !== 200) {
|
|
18420
18757
|
reject(new Error(`Failed to download: ${response.statusCode}`));
|
|
18421
18758
|
return;
|
|
@@ -18429,7 +18766,8 @@ class DownloadFileTool extends Tool {
|
|
|
18429
18766
|
size: stats.size,
|
|
18430
18767
|
});
|
|
18431
18768
|
});
|
|
18432
|
-
})
|
|
18769
|
+
})
|
|
18770
|
+
.on('error', (err) => {
|
|
18433
18771
|
fs__namespace.unlinkSync(input.destination);
|
|
18434
18772
|
reject(err);
|
|
18435
18773
|
});
|
|
@@ -18444,7 +18782,7 @@ class DnsLookupTool extends Tool {
|
|
|
18444
18782
|
description: 'Perform DNS lookup',
|
|
18445
18783
|
parameters: [],
|
|
18446
18784
|
category: 'network',
|
|
18447
|
-
compliance_level: 'public'
|
|
18785
|
+
compliance_level: 'public',
|
|
18448
18786
|
};
|
|
18449
18787
|
}
|
|
18450
18788
|
async execute(input) {
|
|
@@ -18461,7 +18799,7 @@ class PingTool extends Tool {
|
|
|
18461
18799
|
description: 'Ping a host',
|
|
18462
18800
|
parameters: [],
|
|
18463
18801
|
category: 'network',
|
|
18464
|
-
compliance_level: 'public'
|
|
18802
|
+
compliance_level: 'public',
|
|
18465
18803
|
};
|
|
18466
18804
|
}
|
|
18467
18805
|
async execute(input) {
|
|
@@ -18492,10 +18830,10 @@ class ToolPatternParser {
|
|
|
18492
18830
|
*/
|
|
18493
18831
|
static getCategoryPrefix(category) {
|
|
18494
18832
|
const prefixMap = {
|
|
18495
|
-
files:
|
|
18496
|
-
directories:
|
|
18497
|
-
utilities:
|
|
18498
|
-
agent_communication:
|
|
18833
|
+
files: 'file',
|
|
18834
|
+
directories: 'dir',
|
|
18835
|
+
utilities: 'util',
|
|
18836
|
+
agent_communication: 'agent',
|
|
18499
18837
|
};
|
|
18500
18838
|
return prefixMap[category] || category;
|
|
18501
18839
|
}
|
|
@@ -18507,23 +18845,23 @@ class ToolPatternParser {
|
|
|
18507
18845
|
*/
|
|
18508
18846
|
static parse(pattern, registry) {
|
|
18509
18847
|
// Simple tool name (no colon)
|
|
18510
|
-
if (!pattern.includes(
|
|
18848
|
+
if (!pattern.includes(':')) {
|
|
18511
18849
|
return [pattern];
|
|
18512
18850
|
}
|
|
18513
|
-
const [category, operations] = pattern.split(
|
|
18851
|
+
const [category, operations] = pattern.split(':', 2);
|
|
18514
18852
|
// Validate category exists
|
|
18515
18853
|
if (!registry.hasCategory(category)) {
|
|
18516
18854
|
throw new Error(`Unknown tool category: ${category}`);
|
|
18517
18855
|
}
|
|
18518
18856
|
// Wildcard: all tools in category
|
|
18519
|
-
if (operations ===
|
|
18857
|
+
if (operations === '*') {
|
|
18520
18858
|
return registry.getToolsByCategory(category);
|
|
18521
18859
|
}
|
|
18522
18860
|
// Granular selection: [read,write,delete]
|
|
18523
|
-
if (operations.startsWith(
|
|
18861
|
+
if (operations.startsWith('[') && operations.endsWith(']')) {
|
|
18524
18862
|
const ops = operations
|
|
18525
18863
|
.slice(1, -1)
|
|
18526
|
-
.split(
|
|
18864
|
+
.split(',')
|
|
18527
18865
|
.map((s) => s.trim())
|
|
18528
18866
|
.filter((s) => s.length > 0);
|
|
18529
18867
|
// Convert category to singular form for tool naming
|
|
@@ -18562,11 +18900,11 @@ class GetCwdTool extends Tool {
|
|
|
18562
18900
|
constructor() {
|
|
18563
18901
|
super(...arguments);
|
|
18564
18902
|
this.metadata = {
|
|
18565
|
-
name:
|
|
18566
|
-
description:
|
|
18903
|
+
name: 'get_cwd',
|
|
18904
|
+
description: 'Get current working directory',
|
|
18567
18905
|
parameters: [],
|
|
18568
|
-
category:
|
|
18569
|
-
compliance_level:
|
|
18906
|
+
category: 'system',
|
|
18907
|
+
compliance_level: 'public',
|
|
18570
18908
|
};
|
|
18571
18909
|
}
|
|
18572
18910
|
async execute() {
|
|
@@ -18577,11 +18915,11 @@ class GetPlatformTool extends Tool {
|
|
|
18577
18915
|
constructor() {
|
|
18578
18916
|
super(...arguments);
|
|
18579
18917
|
this.metadata = {
|
|
18580
|
-
name:
|
|
18581
|
-
description:
|
|
18918
|
+
name: 'get_platform',
|
|
18919
|
+
description: 'Get system platform information',
|
|
18582
18920
|
parameters: [],
|
|
18583
|
-
category:
|
|
18584
|
-
compliance_level:
|
|
18921
|
+
category: 'system',
|
|
18922
|
+
compliance_level: 'public',
|
|
18585
18923
|
};
|
|
18586
18924
|
}
|
|
18587
18925
|
async execute() {
|
|
@@ -18603,26 +18941,26 @@ class EnvGetTool extends Tool {
|
|
|
18603
18941
|
constructor() {
|
|
18604
18942
|
super(...arguments);
|
|
18605
18943
|
this.metadata = {
|
|
18606
|
-
name:
|
|
18607
|
-
description:
|
|
18944
|
+
name: 'env_get',
|
|
18945
|
+
description: 'Get environment variable (read-only)',
|
|
18608
18946
|
parameters: [],
|
|
18609
|
-
category:
|
|
18610
|
-
compliance_level:
|
|
18947
|
+
category: 'system',
|
|
18948
|
+
compliance_level: 'public',
|
|
18611
18949
|
};
|
|
18612
18950
|
}
|
|
18613
18951
|
async execute(input) {
|
|
18614
|
-
return process.env[input.key] ||
|
|
18952
|
+
return process.env[input.key] || '';
|
|
18615
18953
|
}
|
|
18616
18954
|
}
|
|
18617
18955
|
class EnvSetTool extends Tool {
|
|
18618
18956
|
constructor() {
|
|
18619
18957
|
super(...arguments);
|
|
18620
18958
|
this.metadata = {
|
|
18621
|
-
name:
|
|
18622
|
-
description:
|
|
18959
|
+
name: 'env_set',
|
|
18960
|
+
description: 'Set environment variable (DANGEROUS)',
|
|
18623
18961
|
parameters: [],
|
|
18624
|
-
category:
|
|
18625
|
-
compliance_level:
|
|
18962
|
+
category: 'system',
|
|
18963
|
+
compliance_level: 'public',
|
|
18626
18964
|
};
|
|
18627
18965
|
}
|
|
18628
18966
|
async execute(input) {
|
|
@@ -18635,28 +18973,28 @@ class DateFormatTool extends Tool {
|
|
|
18635
18973
|
constructor() {
|
|
18636
18974
|
super(...arguments);
|
|
18637
18975
|
this.metadata = {
|
|
18638
|
-
name:
|
|
18639
|
-
description:
|
|
18976
|
+
name: 'date_format',
|
|
18977
|
+
description: 'Format dates in various formats',
|
|
18640
18978
|
parameters: [],
|
|
18641
|
-
category:
|
|
18642
|
-
compliance_level:
|
|
18979
|
+
category: 'utils',
|
|
18980
|
+
compliance_level: 'public',
|
|
18643
18981
|
};
|
|
18644
18982
|
}
|
|
18645
18983
|
async execute(input) {
|
|
18646
18984
|
const date = input.date ? new Date(input.date) : new Date();
|
|
18647
|
-
const format = input.format ||
|
|
18985
|
+
const format = input.format || 'iso';
|
|
18648
18986
|
switch (format.toLowerCase()) {
|
|
18649
|
-
case
|
|
18987
|
+
case 'iso':
|
|
18650
18988
|
return date.toISOString();
|
|
18651
|
-
case
|
|
18989
|
+
case 'date':
|
|
18652
18990
|
return date.toDateString();
|
|
18653
|
-
case
|
|
18991
|
+
case 'time':
|
|
18654
18992
|
return date.toTimeString();
|
|
18655
|
-
case
|
|
18993
|
+
case 'locale':
|
|
18656
18994
|
return date.toLocaleString();
|
|
18657
|
-
case
|
|
18995
|
+
case 'utc':
|
|
18658
18996
|
return date.toUTCString();
|
|
18659
|
-
case
|
|
18997
|
+
case 'unix':
|
|
18660
18998
|
return Math.floor(date.getTime() / 1000).toString();
|
|
18661
18999
|
default:
|
|
18662
19000
|
return date.toISOString();
|
|
@@ -18667,28 +19005,28 @@ class GenerateUuidTool extends Tool {
|
|
|
18667
19005
|
constructor() {
|
|
18668
19006
|
super(...arguments);
|
|
18669
19007
|
this.metadata = {
|
|
18670
|
-
name:
|
|
18671
|
-
description:
|
|
19008
|
+
name: 'generate_uuid',
|
|
19009
|
+
description: 'Generate UUID v4',
|
|
18672
19010
|
parameters: [],
|
|
18673
|
-
category:
|
|
18674
|
-
compliance_level:
|
|
19011
|
+
category: 'utils',
|
|
19012
|
+
compliance_level: 'public',
|
|
18675
19013
|
};
|
|
18676
19014
|
}
|
|
18677
19015
|
async execute() {
|
|
18678
19016
|
return crypto$2.randomBytes(16)
|
|
18679
|
-
.toString(
|
|
18680
|
-
.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,
|
|
19017
|
+
.toString('hex')
|
|
19018
|
+
.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '$1-$2-$3-$4-$5');
|
|
18681
19019
|
}
|
|
18682
19020
|
}
|
|
18683
19021
|
class RandomNumberTool extends Tool {
|
|
18684
19022
|
constructor() {
|
|
18685
19023
|
super(...arguments);
|
|
18686
19024
|
this.metadata = {
|
|
18687
|
-
name:
|
|
18688
|
-
description:
|
|
19025
|
+
name: 'random_number',
|
|
19026
|
+
description: 'Generate random number',
|
|
18689
19027
|
parameters: [],
|
|
18690
|
-
category:
|
|
18691
|
-
compliance_level:
|
|
19028
|
+
category: 'utils',
|
|
19029
|
+
compliance_level: 'public',
|
|
18692
19030
|
};
|
|
18693
19031
|
}
|
|
18694
19032
|
async execute(input) {
|
|
@@ -18701,11 +19039,11 @@ class SleepTool extends Tool {
|
|
|
18701
19039
|
constructor() {
|
|
18702
19040
|
super(...arguments);
|
|
18703
19041
|
this.metadata = {
|
|
18704
|
-
name:
|
|
18705
|
-
description:
|
|
19042
|
+
name: 'sleep',
|
|
19043
|
+
description: 'Delay execution for specified milliseconds',
|
|
18706
19044
|
parameters: [],
|
|
18707
|
-
category:
|
|
18708
|
-
compliance_level:
|
|
19045
|
+
category: 'utils',
|
|
19046
|
+
compliance_level: 'public',
|
|
18709
19047
|
};
|
|
18710
19048
|
}
|
|
18711
19049
|
async execute(input) {
|
|
@@ -18718,15 +19056,15 @@ class RegexMatchTool extends Tool {
|
|
|
18718
19056
|
constructor() {
|
|
18719
19057
|
super(...arguments);
|
|
18720
19058
|
this.metadata = {
|
|
18721
|
-
name:
|
|
18722
|
-
description:
|
|
19059
|
+
name: 'regex_match',
|
|
19060
|
+
description: 'Match text against regular expression',
|
|
18723
19061
|
parameters: [],
|
|
18724
|
-
category:
|
|
18725
|
-
compliance_level:
|
|
19062
|
+
category: 'utils',
|
|
19063
|
+
compliance_level: 'public',
|
|
18726
19064
|
};
|
|
18727
19065
|
}
|
|
18728
19066
|
async execute(input) {
|
|
18729
|
-
const regex = new RegExp(input.pattern, input.flags ||
|
|
19067
|
+
const regex = new RegExp(input.pattern, input.flags || 'g');
|
|
18730
19068
|
const matches = [];
|
|
18731
19069
|
const groups = [];
|
|
18732
19070
|
let match;
|
|
@@ -18743,11 +19081,11 @@ class UrlParseTool extends Tool {
|
|
|
18743
19081
|
constructor() {
|
|
18744
19082
|
super(...arguments);
|
|
18745
19083
|
this.metadata = {
|
|
18746
|
-
name:
|
|
18747
|
-
description:
|
|
19084
|
+
name: 'url_parse',
|
|
19085
|
+
description: 'Parse URL into components',
|
|
18748
19086
|
parameters: [],
|
|
18749
|
-
category:
|
|
18750
|
-
compliance_level:
|
|
19087
|
+
category: 'utils',
|
|
19088
|
+
compliance_level: 'public',
|
|
18751
19089
|
};
|
|
18752
19090
|
}
|
|
18753
19091
|
async execute(input) {
|
|
@@ -18788,51 +19126,48 @@ class VerificationStatusTool extends Tool {
|
|
|
18788
19126
|
constructor(registryUrl) {
|
|
18789
19127
|
super();
|
|
18790
19128
|
this.metadata = {
|
|
18791
|
-
name:
|
|
18792
|
-
description:
|
|
19129
|
+
name: 'get_verification_status',
|
|
19130
|
+
description: 'Check the verification and compliance status of this agent in the Sekuire registry. This tool is required for trust protocol compliance and must not be removed.',
|
|
18793
19131
|
parameters: [
|
|
18794
19132
|
{
|
|
18795
|
-
name:
|
|
18796
|
-
type:
|
|
18797
|
-
description:
|
|
19133
|
+
name: 'sekuire_id',
|
|
19134
|
+
type: 'string',
|
|
19135
|
+
description: 'The Sekuire ID of the agent to check (defaults to current agent)',
|
|
18798
19136
|
required: false,
|
|
18799
19137
|
},
|
|
18800
19138
|
{
|
|
18801
|
-
name:
|
|
18802
|
-
type:
|
|
18803
|
-
description:
|
|
19139
|
+
name: 'include_details',
|
|
19140
|
+
type: 'boolean',
|
|
19141
|
+
description: 'Include detailed verification information',
|
|
18804
19142
|
required: false,
|
|
18805
19143
|
},
|
|
18806
19144
|
],
|
|
18807
|
-
category:
|
|
18808
|
-
compliance_level:
|
|
19145
|
+
category: 'compliance',
|
|
19146
|
+
compliance_level: 'system', // System-level tool that cannot be disabled
|
|
18809
19147
|
};
|
|
18810
19148
|
// Default to production registry, or use custom URL
|
|
18811
|
-
this.registryUrl =
|
|
18812
|
-
registryUrl ||
|
|
18813
|
-
process.env.SEKUIRE_REGISTRY_URL ||
|
|
18814
|
-
"http://localhost:5556";
|
|
19149
|
+
this.registryUrl = registryUrl || process.env.SEKUIRE_REGISTRY_URL || 'http://localhost:5556';
|
|
18815
19150
|
}
|
|
18816
19151
|
async execute(input) {
|
|
18817
19152
|
this.validate(input);
|
|
18818
19153
|
const sekuireId = input.sekuire_id || this.getAgentId();
|
|
18819
19154
|
const includeDetails = input.include_details || false;
|
|
18820
19155
|
if (!sekuireId) {
|
|
18821
|
-
throw new Error(
|
|
19156
|
+
throw new Error('No Sekuire ID provided and unable to determine current agent ID');
|
|
18822
19157
|
}
|
|
18823
19158
|
try {
|
|
18824
19159
|
// Query the Sekuire registry API
|
|
18825
19160
|
const response = await fetch(`${this.registryUrl}/api/v1/agents/${sekuireId}`, {
|
|
18826
|
-
method:
|
|
19161
|
+
method: 'GET',
|
|
18827
19162
|
headers: {
|
|
18828
|
-
|
|
18829
|
-
|
|
19163
|
+
'Content-Type': 'application/json',
|
|
19164
|
+
'User-Agent': 'Sekuire-SDK/1.0',
|
|
18830
19165
|
},
|
|
18831
19166
|
});
|
|
18832
19167
|
if (!response.ok) {
|
|
18833
19168
|
if (response.status === 404) {
|
|
18834
19169
|
return JSON.stringify({
|
|
18835
|
-
status:
|
|
19170
|
+
status: 'error',
|
|
18836
19171
|
message: `Agent ${sekuireId} not found in registry. This agent may not be registered or verified.`,
|
|
18837
19172
|
is_verified: false,
|
|
18838
19173
|
is_compliant: false,
|
|
@@ -18844,7 +19179,7 @@ class VerificationStatusTool extends Tool {
|
|
|
18844
19179
|
// Build verification status response
|
|
18845
19180
|
const result = {
|
|
18846
19181
|
sekuire_id: agentData.sekuire_id,
|
|
18847
|
-
verification_status: agentData.verification_status ||
|
|
19182
|
+
verification_status: agentData.verification_status || 'Unverified',
|
|
18848
19183
|
reputation_score: agentData.reputation_score || 0,
|
|
18849
19184
|
security_score: agentData.security_score,
|
|
18850
19185
|
code_review_status: agentData.code_review_status,
|
|
@@ -18867,8 +19202,8 @@ class VerificationStatusTool extends Tool {
|
|
|
18867
19202
|
}
|
|
18868
19203
|
catch (error) {
|
|
18869
19204
|
return JSON.stringify({
|
|
18870
|
-
status:
|
|
18871
|
-
message: `Failed to verify agent status: ${error instanceof Error ? error.message :
|
|
19205
|
+
status: 'error',
|
|
19206
|
+
message: `Failed to verify agent status: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
18872
19207
|
is_verified: false,
|
|
18873
19208
|
is_compliant: false,
|
|
18874
19209
|
recommendation: "Unable to verify agent. Please ensure the agent is properly registered with 'sekuire publish'.",
|
|
@@ -18885,11 +19220,11 @@ class VerificationStatusTool extends Tool {
|
|
|
18885
19220
|
return envId;
|
|
18886
19221
|
// Try to read from .sekuire directory
|
|
18887
19222
|
try {
|
|
18888
|
-
const fs = require(
|
|
18889
|
-
const path = require(
|
|
18890
|
-
const sekuirePath = path.join(process.cwd(),
|
|
19223
|
+
const fs = require('node:fs');
|
|
19224
|
+
const path = require('node:path');
|
|
19225
|
+
const sekuirePath = path.join(process.cwd(), '.sekuire', 'agent.json');
|
|
18891
19226
|
if (fs.existsSync(sekuirePath)) {
|
|
18892
|
-
const config = JSON.parse(fs.readFileSync(sekuirePath,
|
|
19227
|
+
const config = JSON.parse(fs.readFileSync(sekuirePath, 'utf-8'));
|
|
18893
19228
|
return config.sekuire_id;
|
|
18894
19229
|
}
|
|
18895
19230
|
}
|
|
@@ -18904,7 +19239,7 @@ class VerificationStatusTool extends Tool {
|
|
|
18904
19239
|
extractComplianceFrameworks(manifest) {
|
|
18905
19240
|
const frameworks = [];
|
|
18906
19241
|
try {
|
|
18907
|
-
const manifestObj = typeof manifest ===
|
|
19242
|
+
const manifestObj = typeof manifest === 'string' ? JSON.parse(manifest) : manifest;
|
|
18908
19243
|
if (manifestObj?.agent?.compliance?.framework) {
|
|
18909
19244
|
frameworks.push(manifestObj.agent.compliance.framework);
|
|
18910
19245
|
}
|
|
@@ -18918,8 +19253,7 @@ class VerificationStatusTool extends Tool {
|
|
|
18918
19253
|
* Determine if agent is compliant based on verification status and checks
|
|
18919
19254
|
*/
|
|
18920
19255
|
isCompliant(agentData) {
|
|
18921
|
-
const hasVerification = agentData.verification_status ===
|
|
18922
|
-
agentData.verification_status === "Pending";
|
|
19256
|
+
const hasVerification = agentData.verification_status === 'Verified' || agentData.verification_status === 'Pending';
|
|
18923
19257
|
const hasGoodReputation = (Number(agentData.reputation_score) || 0) >= 0;
|
|
18924
19258
|
const hasSecurityScore = (Number(agentData.security_score) || 0) >= 60;
|
|
18925
19259
|
return hasVerification && hasGoodReputation && hasSecurityScore;
|
|
@@ -18930,9 +19264,9 @@ class VerificationStatusTool extends Tool {
|
|
|
18930
19264
|
calculateComplianceScore(agentData) {
|
|
18931
19265
|
let score = 0;
|
|
18932
19266
|
// Verification status (40 points)
|
|
18933
|
-
if (agentData.verification_status ===
|
|
19267
|
+
if (agentData.verification_status === 'Verified')
|
|
18934
19268
|
score += 40;
|
|
18935
|
-
else if (agentData.verification_status ===
|
|
19269
|
+
else if (agentData.verification_status === 'Pending')
|
|
18936
19270
|
score += 20;
|
|
18937
19271
|
// Reputation (30 points)
|
|
18938
19272
|
const repScore = Math.min(30, Math.floor((Number(agentData.reputation_score) || 0) / 10));
|
|
@@ -18941,7 +19275,7 @@ class VerificationStatusTool extends Tool {
|
|
|
18941
19275
|
const secScore = Math.min(20, Math.floor(((Number(agentData.security_score) || 0) / 100) * 20));
|
|
18942
19276
|
score += secScore;
|
|
18943
19277
|
// Code review (10 points)
|
|
18944
|
-
if (agentData.code_review_status ===
|
|
19278
|
+
if (agentData.code_review_status === 'approved')
|
|
18945
19279
|
score += 10;
|
|
18946
19280
|
return score;
|
|
18947
19281
|
}
|
|
@@ -18949,11 +19283,11 @@ class VerificationStatusTool extends Tool {
|
|
|
18949
19283
|
* Format the response for the agent
|
|
18950
19284
|
*/
|
|
18951
19285
|
formatResponse(result) {
|
|
18952
|
-
const statusEmoji = result.verification_status ===
|
|
18953
|
-
?
|
|
18954
|
-
: result.verification_status ===
|
|
18955
|
-
?
|
|
18956
|
-
:
|
|
19286
|
+
const statusEmoji = result.verification_status === 'Verified'
|
|
19287
|
+
? '✅'
|
|
19288
|
+
: result.verification_status === 'Pending'
|
|
19289
|
+
? '⏳'
|
|
19290
|
+
: '⚠️';
|
|
18957
19291
|
let response = `${statusEmoji} Agent Verification Status\n\n`;
|
|
18958
19292
|
response += `Sekuire ID: ${result.sekuire_id}\n`;
|
|
18959
19293
|
response += `Status: ${result.verification_status}\n`;
|
|
@@ -18962,14 +19296,14 @@ class VerificationStatusTool extends Tool {
|
|
|
18962
19296
|
response += `Security Score: ${result.security_score}/100\n`;
|
|
18963
19297
|
}
|
|
18964
19298
|
if (result.compliance_frameworks.length > 0) {
|
|
18965
|
-
response += `Compliance: ${result.compliance_frameworks.join(
|
|
19299
|
+
response += `Compliance: ${result.compliance_frameworks.join(', ')}\n`;
|
|
18966
19300
|
}
|
|
18967
|
-
response += `\nCompliant: ${result.is_compliant ?
|
|
19301
|
+
response += `\nCompliant: ${result.is_compliant ? 'Yes ✓' : 'No ✗'}\n`;
|
|
18968
19302
|
if (result.verification_details) {
|
|
18969
19303
|
response += `\nDetailed Verification:\n`;
|
|
18970
|
-
response += ` • Valid Signature: ${result.verification_details.has_valid_signature ?
|
|
18971
|
-
response += ` • Repository Verified: ${result.verification_details.repository_verified ?
|
|
18972
|
-
response += ` • Security Checks: ${result.verification_details.passes_security_checks ?
|
|
19304
|
+
response += ` • Valid Signature: ${result.verification_details.has_valid_signature ? '✓' : '✗'}\n`;
|
|
19305
|
+
response += ` • Repository Verified: ${result.verification_details.repository_verified ? '✓' : '✗'}\n`;
|
|
19306
|
+
response += ` • Security Checks: ${result.verification_details.passes_security_checks ? '✓' : '✗'}\n`;
|
|
18973
19307
|
response += ` • Compliance Score: ${result.verification_details.compliance_score}/100\n`;
|
|
18974
19308
|
}
|
|
18975
19309
|
if (!result.is_compliant) {
|
|
@@ -18984,25 +19318,25 @@ class WebSearchTool extends Tool {
|
|
|
18984
19318
|
constructor() {
|
|
18985
19319
|
super(...arguments);
|
|
18986
19320
|
this.metadata = {
|
|
18987
|
-
name:
|
|
18988
|
-
description:
|
|
19321
|
+
name: 'web_search',
|
|
19322
|
+
description: 'Search the web for information using various search engines',
|
|
18989
19323
|
parameters: [
|
|
18990
19324
|
{
|
|
18991
|
-
name:
|
|
18992
|
-
type:
|
|
18993
|
-
description:
|
|
19325
|
+
name: 'query',
|
|
19326
|
+
type: 'string',
|
|
19327
|
+
description: 'The search query',
|
|
18994
19328
|
required: true,
|
|
18995
19329
|
},
|
|
18996
19330
|
{
|
|
18997
|
-
name:
|
|
18998
|
-
type:
|
|
18999
|
-
description:
|
|
19331
|
+
name: 'num_results',
|
|
19332
|
+
type: 'number',
|
|
19333
|
+
description: 'Number of results to return',
|
|
19000
19334
|
required: false,
|
|
19001
19335
|
default: 5,
|
|
19002
19336
|
},
|
|
19003
19337
|
],
|
|
19004
|
-
category:
|
|
19005
|
-
compliance_level:
|
|
19338
|
+
category: 'web',
|
|
19339
|
+
compliance_level: 'public',
|
|
19006
19340
|
};
|
|
19007
19341
|
}
|
|
19008
19342
|
async execute(input) {
|
|
@@ -19010,14 +19344,14 @@ class WebSearchTool extends Tool {
|
|
|
19010
19344
|
const query = input.query;
|
|
19011
19345
|
const numResults = input.num_results || 5;
|
|
19012
19346
|
if (this.policyEnforcer) {
|
|
19013
|
-
this.policyEnforcer.enforceNetwork(
|
|
19347
|
+
this.policyEnforcer.enforceNetwork('api.duckduckgo.com', 'https');
|
|
19014
19348
|
}
|
|
19015
19349
|
// Use DuckDuckGo Instant Answer API (no auth required)
|
|
19016
19350
|
try {
|
|
19017
|
-
const response = await axios.get(
|
|
19351
|
+
const response = await axios.get('https://api.duckduckgo.com/', {
|
|
19018
19352
|
params: {
|
|
19019
19353
|
q: query,
|
|
19020
|
-
format:
|
|
19354
|
+
format: 'json',
|
|
19021
19355
|
no_html: 1,
|
|
19022
19356
|
},
|
|
19023
19357
|
});
|
|
@@ -19036,10 +19370,10 @@ class WebSearchTool extends Tool {
|
|
|
19036
19370
|
if (results.length === 0) {
|
|
19037
19371
|
return `No results found for query: ${query}`;
|
|
19038
19372
|
}
|
|
19039
|
-
return `Search results for "${query}":\n\n${results.join(
|
|
19373
|
+
return `Search results for "${query}":\n\n${results.join('\n\n')}`;
|
|
19040
19374
|
}
|
|
19041
19375
|
catch (error) {
|
|
19042
|
-
throw new Error(`Web search failed: ${error instanceof Error ? error.message :
|
|
19376
|
+
throw new Error(`Web search failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
19043
19377
|
}
|
|
19044
19378
|
}
|
|
19045
19379
|
}
|
|
@@ -19075,6 +19409,8 @@ function createDefaultToolRegistry(options) {
|
|
|
19075
19409
|
registry.register(new DownloadFileTool());
|
|
19076
19410
|
registry.register(new DnsLookupTool());
|
|
19077
19411
|
registry.register(new PingTool());
|
|
19412
|
+
// Google Workspace category
|
|
19413
|
+
registry.register(new GoogleDocsCreateTool());
|
|
19078
19414
|
// Data category
|
|
19079
19415
|
registry.register(new JsonParseTool());
|
|
19080
19416
|
registry.register(new JsonStringifyTool());
|
|
@@ -19145,6 +19481,8 @@ const builtInTools = {
|
|
|
19145
19481
|
DownloadFileTool,
|
|
19146
19482
|
DnsLookupTool,
|
|
19147
19483
|
PingTool,
|
|
19484
|
+
// Google Workspace
|
|
19485
|
+
GoogleDocsCreateTool,
|
|
19148
19486
|
// Data
|
|
19149
19487
|
JsonParseTool,
|
|
19150
19488
|
JsonStringifyTool,
|
|
@@ -19184,236 +19522,6 @@ const builtInTools = {
|
|
|
19184
19522
|
DecryptDataTool,
|
|
19185
19523
|
};
|
|
19186
19524
|
|
|
19187
|
-
class BaseMemoryStorage {
|
|
19188
|
-
}
|
|
19189
|
-
|
|
19190
|
-
class InMemoryStorage extends BaseMemoryStorage {
|
|
19191
|
-
constructor() {
|
|
19192
|
-
super(...arguments);
|
|
19193
|
-
this.storage = new Map();
|
|
19194
|
-
}
|
|
19195
|
-
async add(sessionId, message) {
|
|
19196
|
-
if (!this.storage.has(sessionId)) {
|
|
19197
|
-
this.storage.set(sessionId, []);
|
|
19198
|
-
}
|
|
19199
|
-
this.storage.get(sessionId).push(message);
|
|
19200
|
-
}
|
|
19201
|
-
async get(sessionId, limit) {
|
|
19202
|
-
const messages = this.storage.get(sessionId) || [];
|
|
19203
|
-
if (limit) {
|
|
19204
|
-
return messages.slice(-limit);
|
|
19205
|
-
}
|
|
19206
|
-
return messages;
|
|
19207
|
-
}
|
|
19208
|
-
async clear(sessionId) {
|
|
19209
|
-
this.storage.set(sessionId, []);
|
|
19210
|
-
}
|
|
19211
|
-
async delete(sessionId) {
|
|
19212
|
-
this.storage.delete(sessionId);
|
|
19213
|
-
}
|
|
19214
|
-
async exists(sessionId) {
|
|
19215
|
-
return this.storage.has(sessionId);
|
|
19216
|
-
}
|
|
19217
|
-
}
|
|
19218
|
-
|
|
19219
|
-
class PostgresStorage extends BaseMemoryStorage {
|
|
19220
|
-
constructor(config) {
|
|
19221
|
-
super();
|
|
19222
|
-
this.initialized = false;
|
|
19223
|
-
this.tableName = config.tableName || "sekuire_memory";
|
|
19224
|
-
this.initPool(config);
|
|
19225
|
-
}
|
|
19226
|
-
async initPool(config) {
|
|
19227
|
-
try {
|
|
19228
|
-
const { Pool } = await import('pg');
|
|
19229
|
-
if (config.connectionString) {
|
|
19230
|
-
this.pool = new Pool({ connectionString: config.connectionString });
|
|
19231
|
-
}
|
|
19232
|
-
else {
|
|
19233
|
-
this.pool = new Pool({
|
|
19234
|
-
host: config.host || "localhost",
|
|
19235
|
-
port: config.port || 5432,
|
|
19236
|
-
database: config.database,
|
|
19237
|
-
user: config.user,
|
|
19238
|
-
password: config.password,
|
|
19239
|
-
});
|
|
19240
|
-
}
|
|
19241
|
-
await this.createTableIfNotExists();
|
|
19242
|
-
this.initialized = true;
|
|
19243
|
-
}
|
|
19244
|
-
catch (error) {
|
|
19245
|
-
throw new Error(`Failed to initialize Postgres: ${error}`);
|
|
19246
|
-
}
|
|
19247
|
-
}
|
|
19248
|
-
async createTableIfNotExists() {
|
|
19249
|
-
const query = `
|
|
19250
|
-
CREATE TABLE IF NOT EXISTS ${this.tableName} (
|
|
19251
|
-
id SERIAL PRIMARY KEY,
|
|
19252
|
-
session_id VARCHAR(255) NOT NULL,
|
|
19253
|
-
role VARCHAR(50) NOT NULL,
|
|
19254
|
-
content TEXT NOT NULL,
|
|
19255
|
-
timestamp BIGINT NOT NULL,
|
|
19256
|
-
metadata JSONB,
|
|
19257
|
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
19258
|
-
);
|
|
19259
|
-
CREATE INDEX IF NOT EXISTS idx_${this.tableName}_session_id ON ${this.tableName}(session_id);
|
|
19260
|
-
`;
|
|
19261
|
-
await this.pool.query(query);
|
|
19262
|
-
}
|
|
19263
|
-
async add(sessionId, message) {
|
|
19264
|
-
if (!this.initialized)
|
|
19265
|
-
throw new Error("Postgres not initialized");
|
|
19266
|
-
const query = `
|
|
19267
|
-
INSERT INTO ${this.tableName} (session_id, role, content, timestamp, metadata)
|
|
19268
|
-
VALUES ($1, $2, $3, $4, $5)
|
|
19269
|
-
`;
|
|
19270
|
-
await this.pool.query(query, [
|
|
19271
|
-
sessionId,
|
|
19272
|
-
message.role,
|
|
19273
|
-
message.content,
|
|
19274
|
-
message.timestamp,
|
|
19275
|
-
message.metadata ? JSON.stringify(message.metadata) : null,
|
|
19276
|
-
]);
|
|
19277
|
-
}
|
|
19278
|
-
async get(sessionId, limit) {
|
|
19279
|
-
if (!this.initialized)
|
|
19280
|
-
throw new Error("Postgres not initialized");
|
|
19281
|
-
let query = `
|
|
19282
|
-
SELECT role, content, timestamp, metadata
|
|
19283
|
-
FROM ${this.tableName}
|
|
19284
|
-
WHERE session_id = $1
|
|
19285
|
-
ORDER BY timestamp ASC
|
|
19286
|
-
`;
|
|
19287
|
-
if (limit) {
|
|
19288
|
-
query += ` LIMIT ${limit}`;
|
|
19289
|
-
}
|
|
19290
|
-
const result = await this.pool.query(query, [sessionId]);
|
|
19291
|
-
return result.rows.map((row) => ({
|
|
19292
|
-
role: row.role,
|
|
19293
|
-
content: row.content,
|
|
19294
|
-
timestamp: row.timestamp,
|
|
19295
|
-
metadata: row.metadata,
|
|
19296
|
-
}));
|
|
19297
|
-
}
|
|
19298
|
-
async clear(sessionId) {
|
|
19299
|
-
if (!this.initialized)
|
|
19300
|
-
throw new Error("Postgres not initialized");
|
|
19301
|
-
const query = `DELETE FROM ${this.tableName} WHERE session_id = $1`;
|
|
19302
|
-
await this.pool.query(query, [sessionId]);
|
|
19303
|
-
}
|
|
19304
|
-
async delete(sessionId) {
|
|
19305
|
-
await this.clear(sessionId);
|
|
19306
|
-
}
|
|
19307
|
-
async exists(sessionId) {
|
|
19308
|
-
if (!this.initialized)
|
|
19309
|
-
throw new Error("Postgres not initialized");
|
|
19310
|
-
const query = `SELECT COUNT(*) FROM ${this.tableName} WHERE session_id = $1`;
|
|
19311
|
-
const result = await this.pool.query(query, [sessionId]);
|
|
19312
|
-
return parseInt(result.rows[0].count) > 0;
|
|
19313
|
-
}
|
|
19314
|
-
async disconnect() {
|
|
19315
|
-
if (this.initialized) {
|
|
19316
|
-
await this.pool.end();
|
|
19317
|
-
this.initialized = false;
|
|
19318
|
-
}
|
|
19319
|
-
}
|
|
19320
|
-
}
|
|
19321
|
-
|
|
19322
|
-
class RedisStorage extends BaseMemoryStorage {
|
|
19323
|
-
constructor(config) {
|
|
19324
|
-
super();
|
|
19325
|
-
this.client = null;
|
|
19326
|
-
this.connected = false;
|
|
19327
|
-
this.keyPrefix = config.keyPrefix || "sekuire:memory:";
|
|
19328
|
-
this.initClient(config);
|
|
19329
|
-
}
|
|
19330
|
-
async initClient(config) {
|
|
19331
|
-
try {
|
|
19332
|
-
const { createClient } = await import('redis');
|
|
19333
|
-
if (config.url) {
|
|
19334
|
-
this.client = createClient({ url: config.url });
|
|
19335
|
-
}
|
|
19336
|
-
else {
|
|
19337
|
-
this.client = createClient({
|
|
19338
|
-
socket: {
|
|
19339
|
-
host: config.host || "localhost",
|
|
19340
|
-
port: config.port || 6379,
|
|
19341
|
-
},
|
|
19342
|
-
password: config.password,
|
|
19343
|
-
database: config.db || 0,
|
|
19344
|
-
});
|
|
19345
|
-
}
|
|
19346
|
-
this.client.on("error", (err) => {
|
|
19347
|
-
console.error("Redis client error:", err);
|
|
19348
|
-
});
|
|
19349
|
-
await this.client.connect();
|
|
19350
|
-
this.connected = true;
|
|
19351
|
-
}
|
|
19352
|
-
catch (error) {
|
|
19353
|
-
throw new Error(`Failed to initialize Redis: ${error}`);
|
|
19354
|
-
}
|
|
19355
|
-
}
|
|
19356
|
-
getKey(sessionId) {
|
|
19357
|
-
return `${this.keyPrefix}${sessionId}`;
|
|
19358
|
-
}
|
|
19359
|
-
async add(sessionId, message) {
|
|
19360
|
-
if (!this.connected)
|
|
19361
|
-
throw new Error("Redis not connected");
|
|
19362
|
-
const key = this.getKey(sessionId);
|
|
19363
|
-
await this.client.rPush(key, JSON.stringify(message));
|
|
19364
|
-
}
|
|
19365
|
-
async get(sessionId, limit) {
|
|
19366
|
-
if (!this.connected)
|
|
19367
|
-
throw new Error("Redis not connected");
|
|
19368
|
-
const key = this.getKey(sessionId);
|
|
19369
|
-
const start = limit ? -limit : 0;
|
|
19370
|
-
const messages = await this.client.lRange(key, start, -1);
|
|
19371
|
-
return messages.map((msg) => JSON.parse(msg));
|
|
19372
|
-
}
|
|
19373
|
-
async clear(sessionId) {
|
|
19374
|
-
if (!this.connected)
|
|
19375
|
-
throw new Error("Redis not connected");
|
|
19376
|
-
const key = this.getKey(sessionId);
|
|
19377
|
-
await this.client.del(key);
|
|
19378
|
-
}
|
|
19379
|
-
async delete(sessionId) {
|
|
19380
|
-
await this.clear(sessionId);
|
|
19381
|
-
}
|
|
19382
|
-
async exists(sessionId) {
|
|
19383
|
-
if (!this.connected)
|
|
19384
|
-
throw new Error("Redis not connected");
|
|
19385
|
-
const key = this.getKey(sessionId);
|
|
19386
|
-
return (await this.client.exists(key)) === 1;
|
|
19387
|
-
}
|
|
19388
|
-
async disconnect() {
|
|
19389
|
-
if (this.connected) {
|
|
19390
|
-
await this.client.quit();
|
|
19391
|
-
this.connected = false;
|
|
19392
|
-
}
|
|
19393
|
-
}
|
|
19394
|
-
}
|
|
19395
|
-
|
|
19396
|
-
function createMemoryStorage(config) {
|
|
19397
|
-
// Normalize type (support "buffer" as alias for "in-memory")
|
|
19398
|
-
const normalizedType = config.type === "buffer" ? "in-memory" : config.type;
|
|
19399
|
-
switch (normalizedType) {
|
|
19400
|
-
case "in-memory":
|
|
19401
|
-
return new InMemoryStorage();
|
|
19402
|
-
case "redis":
|
|
19403
|
-
if (!config.redis) {
|
|
19404
|
-
throw new Error("Redis config required for redis memory type");
|
|
19405
|
-
}
|
|
19406
|
-
return new RedisStorage(config.redis);
|
|
19407
|
-
case "postgres":
|
|
19408
|
-
if (!config.postgres) {
|
|
19409
|
-
throw new Error("Postgres config required for postgres memory type");
|
|
19410
|
-
}
|
|
19411
|
-
return new PostgresStorage(config.postgres);
|
|
19412
|
-
default:
|
|
19413
|
-
throw new Error(`Unknown memory type: ${config.type}`);
|
|
19414
|
-
}
|
|
19415
|
-
}
|
|
19416
|
-
|
|
19417
19525
|
// Load environment variables
|
|
19418
19526
|
dotenv.config();
|
|
19419
19527
|
// Global cache for policy files to prevent repetitive disk I/O
|
|
@@ -20009,6 +20117,14 @@ class SekuireServer {
|
|
|
20009
20117
|
getAgentId() {
|
|
20010
20118
|
return this.agentId;
|
|
20011
20119
|
}
|
|
20120
|
+
/**
|
|
20121
|
+
* Handle incoming webhooks from other agents
|
|
20122
|
+
*/
|
|
20123
|
+
async handleWebhook(payload, signature) {
|
|
20124
|
+
// In a real implementation, we would verify the signature
|
|
20125
|
+
// For now, we just pass the payload through to be handled by the implementation
|
|
20126
|
+
return { received: true };
|
|
20127
|
+
}
|
|
20012
20128
|
}
|
|
20013
20129
|
/**
|
|
20014
20130
|
* Express.js middleware for Sekuire protocol
|
|
@@ -20032,6 +20148,11 @@ function createSekuireExpressMiddleware(server) {
|
|
|
20032
20148
|
await server.handleAuth(req.body, clientNonce);
|
|
20033
20149
|
return res.json({ success: true });
|
|
20034
20150
|
}
|
|
20151
|
+
else if (req.path === "/sekuire/webhook" && req.method === "POST") {
|
|
20152
|
+
const signature = req.headers["x-sekuire-signature"];
|
|
20153
|
+
const result = await server.handleWebhook(req.body, signature);
|
|
20154
|
+
return res.json(result);
|
|
20155
|
+
}
|
|
20035
20156
|
next();
|
|
20036
20157
|
}
|
|
20037
20158
|
catch (error) {
|
|
@@ -20084,6 +20205,86 @@ function createSekuireFastifyPlugin(server) {
|
|
|
20084
20205
|
return { error: error.message };
|
|
20085
20206
|
}
|
|
20086
20207
|
});
|
|
20208
|
+
fastify.post("/sekuire/webhook", async (request, reply) => {
|
|
20209
|
+
try {
|
|
20210
|
+
const signature = request.headers["x-sekuire-signature"];
|
|
20211
|
+
const result = await server.handleWebhook(request.body, signature);
|
|
20212
|
+
return result;
|
|
20213
|
+
}
|
|
20214
|
+
catch (error) {
|
|
20215
|
+
reply.code(500);
|
|
20216
|
+
return { error: error.message };
|
|
20217
|
+
}
|
|
20218
|
+
});
|
|
20219
|
+
};
|
|
20220
|
+
}
|
|
20221
|
+
|
|
20222
|
+
/**
|
|
20223
|
+
* Create a tool for discovering other agents in the Sekuire network
|
|
20224
|
+
*/
|
|
20225
|
+
function createDiscoveryTool(client) {
|
|
20226
|
+
return {
|
|
20227
|
+
name: 'discover_agents',
|
|
20228
|
+
description: "Search for other AI agents in the Sekuire network by capability or name. Use this to find agents that can help with specific tasks (e.g., 'jira', 'google drive').",
|
|
20229
|
+
schema: zod.z.object({
|
|
20230
|
+
query: zod.z.string().describe("The search query (e.g., 'jira', 'drive', 'github')"),
|
|
20231
|
+
}),
|
|
20232
|
+
execute: async ({ query }) => {
|
|
20233
|
+
try {
|
|
20234
|
+
const agents = await client.searchAgents(query);
|
|
20235
|
+
if (agents.length === 0) {
|
|
20236
|
+
return `No agents found matching '${query}'.`;
|
|
20237
|
+
}
|
|
20238
|
+
return agents.map((a) => ({
|
|
20239
|
+
name: a.name,
|
|
20240
|
+
id: a.sekuire_id,
|
|
20241
|
+
description: a.description,
|
|
20242
|
+
status: a.verification_status,
|
|
20243
|
+
}));
|
|
20244
|
+
}
|
|
20245
|
+
catch (error) {
|
|
20246
|
+
return `Error searching for agents: ${error.message}`;
|
|
20247
|
+
}
|
|
20248
|
+
},
|
|
20249
|
+
};
|
|
20250
|
+
}
|
|
20251
|
+
/**
|
|
20252
|
+
* Create a tool for delegating tasks to other agents
|
|
20253
|
+
*/
|
|
20254
|
+
function createDelegationTool(client) {
|
|
20255
|
+
return {
|
|
20256
|
+
name: 'delegate_task',
|
|
20257
|
+
description: "Delegate a task to another agent. Requires the target agent's Sekuire ID (found via discover_agents).",
|
|
20258
|
+
schema: zod.z.object({
|
|
20259
|
+
agent_id: zod.z.string().describe('The Sekuire ID of the target agent'),
|
|
20260
|
+
task: zod.z.string().describe('The task description or message to send to the agent'),
|
|
20261
|
+
context: zod.z.record(zod.z.any()).optional().describe('Optional context data to pass'),
|
|
20262
|
+
}),
|
|
20263
|
+
execute: async ({ agent_id, task, context }) => {
|
|
20264
|
+
try {
|
|
20265
|
+
// 1. Get Agent Info
|
|
20266
|
+
const agentInfo = await client.getAgentInfo(agent_id);
|
|
20267
|
+
// 2. Perform Handshake & Auth (Simulated for this phase as we don't have dynamic URLs yet)
|
|
20268
|
+
// In a real scenario:
|
|
20269
|
+
// const handshake = await client.connect(agentInfo.url);
|
|
20270
|
+
// 3. Send Task
|
|
20271
|
+
// const result = await client.sendTask(handshake.session, { task, context });
|
|
20272
|
+
// For the demo/prototype phase without dynamic routing:
|
|
20273
|
+
// We simulate the success message. The actual inter-process communication
|
|
20274
|
+
// would happen here via HTTP/WebSocket.
|
|
20275
|
+
return {
|
|
20276
|
+
status: 'success',
|
|
20277
|
+
message: `Task successfully delegated to ${agentInfo.name || agent_id}`,
|
|
20278
|
+
details: {
|
|
20279
|
+
recipient: agent_id,
|
|
20280
|
+
task_summary: task.substring(0, 50) + '...',
|
|
20281
|
+
},
|
|
20282
|
+
};
|
|
20283
|
+
}
|
|
20284
|
+
catch (error) {
|
|
20285
|
+
return `Error delegating task to agent ${agent_id}: ${error.message}`;
|
|
20286
|
+
}
|
|
20287
|
+
},
|
|
20087
20288
|
};
|
|
20088
20289
|
}
|
|
20089
20290
|
|
|
@@ -20146,6 +20347,8 @@ exports.builtInTools = builtInTools;
|
|
|
20146
20347
|
exports.calculateSekuireId = calculateSekuireId;
|
|
20147
20348
|
exports.createAgent = createAgent;
|
|
20148
20349
|
exports.createDefaultToolRegistry = createDefaultToolRegistry;
|
|
20350
|
+
exports.createDelegationTool = createDelegationTool;
|
|
20351
|
+
exports.createDiscoveryTool = createDiscoveryTool;
|
|
20149
20352
|
exports.createLLMProvider = createLLMProvider;
|
|
20150
20353
|
exports.createMemoryStorage = createMemoryStorage;
|
|
20151
20354
|
exports.createSekuireClient = createSekuireClient;
|