@olane/o-tools-common 0.6.12 → 0.7.1
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/agent/agents.tool.d.ts +10 -0
- package/dist/agent/agents.tool.d.ts.map +1 -0
- package/dist/agent/agents.tool.js +20 -0
- package/dist/agent/ai-agent.tool.d.ts +6 -0
- package/dist/agent/ai-agent.tool.d.ts.map +1 -0
- package/dist/agent/ai-agent.tool.js +10 -0
- package/dist/agent/base-agent.tool.d.ts +11 -0
- package/dist/agent/base-agent.tool.d.ts.map +1 -0
- package/dist/agent/base-agent.tool.js +30 -0
- package/dist/agent/human-agent.tool.d.ts +6 -0
- package/dist/agent/human-agent.tool.d.ts.map +1 -0
- package/dist/agent/human-agent.tool.js +10 -0
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +4 -0
- package/dist/agent/interfaces/agent.config.d.ts +6 -0
- package/dist/agent/interfaces/agent.config.d.ts.map +1 -0
- package/dist/agent/interfaces/agent.config.js +1 -0
- package/dist/agent/methods/agent.methods.d.ts +5 -0
- package/dist/agent/methods/agent.methods.d.ts.map +1 -0
- package/dist/agent/methods/agent.methods.js +30 -0
- package/dist/encryption/encryption.tool.d.ts +5 -3
- package/dist/encryption/encryption.tool.d.ts.map +1 -1
- package/dist/encryption/encryption.tool.js +2 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/init.d.ts +2 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +5 -16
- package/dist/leader/index.d.ts +2 -0
- package/dist/leader/index.d.ts.map +1 -0
- package/dist/leader/index.js +1 -0
- package/dist/leader/leader.node.d.ts +10 -0
- package/dist/leader/leader.node.d.ts.map +1 -0
- package/dist/leader/leader.node.js +63 -0
- package/dist/leader/methods/start.method.d.ts +3 -0
- package/dist/leader/methods/start.method.d.ts.map +1 -0
- package/dist/leader/methods/start.method.js +21 -0
- package/dist/plan/methods/plan.methods.d.ts +5 -0
- package/dist/plan/methods/plan.methods.d.ts.map +1 -0
- package/dist/plan/methods/plan.methods.js +8 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +2 -0
- package/dist/registry/interfaces/search.interface.d.ts +6 -0
- package/dist/registry/interfaces/search.interface.d.ts.map +1 -0
- package/dist/registry/interfaces/search.interface.js +1 -0
- package/dist/registry/methods/registry.methods.d.ts +5 -0
- package/dist/registry/methods/registry.methods.d.ts.map +1 -0
- package/dist/registry/methods/registry.methods.js +74 -0
- package/dist/registry/registry-memory.tool.d.ts +9 -0
- package/dist/registry/registry-memory.tool.d.ts.map +1 -0
- package/dist/registry/registry-memory.tool.js +51 -0
- package/dist/registry/registry.tool.d.ts +13 -0
- package/dist/registry/registry.tool.d.ts.map +1 -0
- package/dist/registry/registry.tool.js +15 -0
- package/dist/search/search.tool.d.ts +4 -3
- package/dist/search/search.tool.d.ts.map +1 -1
- package/dist/search/search.tool.js +4 -4
- package/dist/setup/index.d.ts +3 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +2 -0
- package/dist/setup/methods/setup.method.d.ts +5 -0
- package/dist/setup/methods/setup.method.d.ts.map +1 -0
- package/dist/setup/methods/setup.method.js +16 -0
- package/dist/setup/setup.tool.d.ts +11 -0
- package/dist/setup/setup.tool.d.ts.map +1 -0
- package/dist/setup/setup.tool.js +52 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +7 -0
- package/dist/storage/interfaces/get-data.response.d.ts +4 -0
- package/dist/storage/interfaces/get-data.response.d.ts.map +1 -0
- package/dist/storage/interfaces/get-data.response.js +1 -0
- package/dist/storage/interfaces/index.d.ts +2 -0
- package/dist/storage/interfaces/index.d.ts.map +1 -0
- package/dist/storage/interfaces/index.js +1 -0
- package/dist/storage/methods/storage.methods.d.ts +5 -0
- package/dist/storage/methods/storage.methods.d.ts.map +1 -0
- package/dist/storage/methods/storage.methods.js +65 -0
- package/dist/storage/placeholder.tool.d.ts +6 -0
- package/dist/storage/placeholder.tool.d.ts.map +1 -0
- package/dist/storage/placeholder.tool.js +10 -0
- package/dist/storage/providers/dht-storage-provider.tool.d.ts +12 -0
- package/dist/storage/providers/dht-storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/dht-storage-provider.tool.js +25 -0
- package/dist/storage/providers/disk-storage-provider.tool.d.ts +45 -0
- package/dist/storage/providers/disk-storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/disk-storage-provider.tool.js +134 -0
- package/dist/storage/providers/encrypted-storage-provider.tool.d.ts +1 -0
- package/dist/storage/providers/encrypted-storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/encrypted-storage-provider.tool.js +63 -0
- package/dist/storage/providers/memory-storage-provider.tool.d.ts +32 -0
- package/dist/storage/providers/memory-storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/memory-storage-provider.tool.js +65 -0
- package/dist/storage/providers/secure-storage-provider.tool.d.ts +25 -0
- package/dist/storage/providers/secure-storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/secure-storage-provider.tool.js +72 -0
- package/dist/storage/providers/storage-provider.tool.d.ts +11 -0
- package/dist/storage/providers/storage-provider.tool.d.ts.map +1 -0
- package/dist/storage/providers/storage-provider.tool.js +24 -0
- package/dist/storage/storage.tool.d.ts +12 -0
- package/dist/storage/storage.tool.d.ts.map +1 -0
- package/dist/storage/storage.tool.js +46 -0
- package/package.json +8 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
|
|
2
|
+
import { oRequest } from '@olane/o-core';
|
|
3
|
+
export declare class AgentsTool extends oVirtualTool {
|
|
4
|
+
private roundRobinIndex;
|
|
5
|
+
constructor(config: oToolConfig);
|
|
6
|
+
_tool_get_agents(request: oRequest): Promise<ToolResult>;
|
|
7
|
+
_tool_get_agent(request: oRequest): Promise<ToolResult>;
|
|
8
|
+
_tool_get_agent_by_id(request: oRequest): Promise<ToolResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=agents.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.tool.d.ts","sourceRoot":"","sources":["../../src/agent/agents.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnD,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,eAAe,CAAK;gBAEhB,MAAM,EAAE,WAAW;IAOzB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAIxD,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAIvD,qBAAqB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAGpE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { oVirtualTool } from '@olane/o-tool';
|
|
2
|
+
import { oAddress } from '@olane/o-core';
|
|
3
|
+
export class AgentsTool extends oVirtualTool {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
super({
|
|
6
|
+
...config,
|
|
7
|
+
address: new oAddress('o://agents'),
|
|
8
|
+
});
|
|
9
|
+
this.roundRobinIndex = 0;
|
|
10
|
+
}
|
|
11
|
+
async _tool_get_agents(request) {
|
|
12
|
+
throw new Error('Not implemented');
|
|
13
|
+
}
|
|
14
|
+
async _tool_get_agent(request) {
|
|
15
|
+
throw new Error('Not implemented');
|
|
16
|
+
}
|
|
17
|
+
async _tool_get_agent_by_id(request) {
|
|
18
|
+
throw new Error('Not implemented');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-agent.tool.d.ts","sourceRoot":"","sources":["../../src/agent/ai-agent.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,MAAM,EAAE,YAAY;CAMjC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { oVirtualTool, ToolResult } from '@olane/o-tool';
|
|
2
|
+
import { oRequest } from '@olane/o-core';
|
|
3
|
+
import { oAgentConfig } from './interfaces/agent.config.js';
|
|
4
|
+
export declare abstract class oAgentTool extends oVirtualTool {
|
|
5
|
+
protected respond: (intent: string) => Promise<string>;
|
|
6
|
+
protected answer: (intent: string) => Promise<string>;
|
|
7
|
+
constructor(config: oAgentConfig);
|
|
8
|
+
_tool_intent(request: oRequest): Promise<ToolResult>;
|
|
9
|
+
_tool_question(request: oRequest): Promise<ToolResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=base-agent.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent.tool.d.ts","sourceRoot":"","sources":["../../src/agent/base-agent.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,8BAAsB,UAAW,SAAQ,YAAY;IACnD,SAAS,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;gBAE1C,MAAM,EAAE,YAAY;IAU1B,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAWpD,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAU7D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { oVirtualTool } from '@olane/o-tool';
|
|
2
|
+
import { oAddress } from '@olane/o-core';
|
|
3
|
+
import { AGENT_METHODS } from './methods/agent.methods.js';
|
|
4
|
+
export class oAgentTool extends oVirtualTool {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
super({
|
|
7
|
+
...config,
|
|
8
|
+
address: config?.address || new oAddress('o://agent'),
|
|
9
|
+
methods: AGENT_METHODS,
|
|
10
|
+
});
|
|
11
|
+
this.respond = config.respond;
|
|
12
|
+
this.answer = config.answer;
|
|
13
|
+
}
|
|
14
|
+
async _tool_intent(request) {
|
|
15
|
+
const { intent, context } = request.params;
|
|
16
|
+
const response = await this.respond(intent);
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
resolution: response,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async _tool_question(request) {
|
|
23
|
+
const { question } = request.params;
|
|
24
|
+
const response = await this.answer(question);
|
|
25
|
+
return {
|
|
26
|
+
success: true,
|
|
27
|
+
answer: response,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"human-agent.tool.d.ts","sourceRoot":"","sources":["../../src/agent/human-agent.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,MAAM,EAAE,YAAY;CAMjC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { oAddress } from '@olane/o-core';
|
|
2
|
+
import { oAgentTool } from './base-agent.tool.js';
|
|
3
|
+
export class oHumanAgentTool extends oAgentTool {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
super({
|
|
6
|
+
...config,
|
|
7
|
+
address: config.address || new oAddress('o://human'),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.config.d.ts","sourceRoot":"","sources":["../../../src/agent/interfaces/agent.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.methods.d.ts","sourceRoot":"","sources":["../../../src/agent/methods/agent.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CA6BnD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const AGENT_METHODS = {
|
|
2
|
+
intent: {
|
|
3
|
+
name: 'intent',
|
|
4
|
+
description: 'Agent handler for resolving an intent.',
|
|
5
|
+
parameters: [
|
|
6
|
+
{
|
|
7
|
+
name: 'intent',
|
|
8
|
+
type: 'string',
|
|
9
|
+
value: 'string',
|
|
10
|
+
description: 'The intent to resolve.',
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
dependencies: [],
|
|
15
|
+
},
|
|
16
|
+
question_answer: {
|
|
17
|
+
name: 'question_answer',
|
|
18
|
+
description: 'Agent handler for answering a question.',
|
|
19
|
+
parameters: [
|
|
20
|
+
{
|
|
21
|
+
name: 'question',
|
|
22
|
+
type: 'string',
|
|
23
|
+
value: 'string',
|
|
24
|
+
description: 'The question to answer.',
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
dependencies: [],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ToolResult } from '@olane/o-tool';
|
|
2
2
|
import { oRequest } from '@olane/o-core';
|
|
3
|
-
|
|
3
|
+
import { oLaneTool } from '@olane/o-lane';
|
|
4
|
+
import { oNodeToolConfig } from '@olane/o-node';
|
|
5
|
+
export declare class EncryptionTool extends oLaneTool {
|
|
4
6
|
private encryptionService;
|
|
5
|
-
constructor(config:
|
|
7
|
+
constructor(config: oNodeToolConfig);
|
|
6
8
|
_tool_encrypt(request: oRequest): Promise<ToolResult>;
|
|
7
9
|
_tool_decrypt(request: oRequest): Promise<ToolResult>;
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.tool.d.ts","sourceRoot":"","sources":["../../src/encryption/encryption.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"encryption.tool.d.ts","sourceRoot":"","sources":["../../src/encryption/encryption.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,cAAe,SAAQ,SAAS;IAC3C,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,MAAM,EAAE,eAAe;IAU7B,aAAa,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAWrD,aAAa,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAU5D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { oVirtualTool } from '@olane/o-tool';
|
|
2
1
|
import { oAddress } from '@olane/o-core';
|
|
3
2
|
import { EncryptionService } from './lib/encryption.js';
|
|
4
3
|
import { ENCRYPTION_PARAMS } from './methods/encryption.methods.js';
|
|
5
|
-
|
|
4
|
+
import { oLaneTool } from '@olane/o-lane';
|
|
5
|
+
export class EncryptionTool extends oLaneTool {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
super({
|
|
8
8
|
...config,
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/init.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { RegistryMemoryTool } from '@olane/o-leader';
|
|
2
1
|
import { StorageTool } from '@olane/o-storage';
|
|
3
2
|
import { SearchTool } from './search/search.tool.js';
|
|
4
3
|
import { EncryptionTool } from './encryption/encryption.tool.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export declare const initCommonTools: (oNode: oVirtualTool) => (SearchTool | EncryptionTool | EncryptedPlanStorageTool | RegistryMemoryTool | StorageTool)[];
|
|
4
|
+
import { oLaneTool } from '@olane/o-lane';
|
|
5
|
+
export declare const initCommonTools: (oNode: oLaneTool) => Promise<(SearchTool | EncryptionTool | StorageTool)[]>;
|
|
8
6
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,eAAe,UAAiB,SAAS,2DA0BrD,CAAC"}
|
package/dist/init.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { RegistryMemoryTool } from '@olane/o-leader';
|
|
2
|
-
import { oAddress } from '@olane/o-core';
|
|
3
1
|
import { StorageTool } from '@olane/o-storage';
|
|
4
2
|
import { SearchTool } from './search/search.tool.js';
|
|
5
3
|
import { EncryptionTool } from './encryption/encryption.tool.js';
|
|
6
|
-
|
|
7
|
-
export const initCommonTools = (oNode) => {
|
|
4
|
+
export const initCommonTools = async (oNode) => {
|
|
8
5
|
const params = {
|
|
9
6
|
parent: oNode.address,
|
|
10
|
-
leader: oNode.
|
|
7
|
+
leader: oNode.leader,
|
|
11
8
|
};
|
|
12
9
|
const tools = [
|
|
13
|
-
new RegistryMemoryTool({
|
|
14
|
-
name: 'registry',
|
|
15
|
-
...params,
|
|
16
|
-
}),
|
|
17
10
|
new StorageTool({
|
|
18
11
|
name: 'storage',
|
|
19
12
|
...params,
|
|
@@ -26,14 +19,10 @@ export const initCommonTools = (oNode) => {
|
|
|
26
19
|
name: 'search',
|
|
27
20
|
...params,
|
|
28
21
|
}),
|
|
29
|
-
new EncryptedPlanStorageTool({
|
|
30
|
-
name: 'plan',
|
|
31
|
-
address: new oAddress('o://plan'),
|
|
32
|
-
...params,
|
|
33
|
-
}),
|
|
34
22
|
];
|
|
35
|
-
tools.
|
|
23
|
+
await Promise.all(tools.map(async (tool) => {
|
|
24
|
+
await tool.start();
|
|
36
25
|
oNode.addChildNode(tool);
|
|
37
|
-
});
|
|
26
|
+
}));
|
|
38
27
|
return tools;
|
|
39
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/leader/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './leader.node.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { oRequest } from '@olane/o-core';
|
|
2
|
+
import { oServerTool, oToolConfig } from '@olane/o-tool';
|
|
3
|
+
export declare class oLeaderNode extends oServerTool {
|
|
4
|
+
constructor(config: oToolConfig);
|
|
5
|
+
validateJoinRequest(request: oRequest): Promise<any>;
|
|
6
|
+
_tool_join_network(request: oRequest): Promise<any>;
|
|
7
|
+
_tool_save_plan(request: oRequest): Promise<any>;
|
|
8
|
+
_tool_index_network(request: oRequest): Promise<any>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=leader.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leader.node.d.ts","sourceRoot":"","sources":["../../src/leader/leader.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGzD,qBAAa,WAAY,SAAQ,WAAW;gBAC9B,MAAM,EAAE,WAAW;IAWzB,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpD,kBAAkB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAuBnD,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAUhD,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CA2B3D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { LEADER_ADRESS, NodeType, oAddress, } from '@olane/o-core';
|
|
2
|
+
import { oServerTool } from '@olane/o-tool';
|
|
3
|
+
import { START_METHOD } from './methods/start.method.js';
|
|
4
|
+
export class oLeaderNode extends oServerTool {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
super({
|
|
7
|
+
...config,
|
|
8
|
+
address: new oAddress(LEADER_ADRESS),
|
|
9
|
+
type: NodeType.LEADER,
|
|
10
|
+
methods: {
|
|
11
|
+
start: START_METHOD,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async validateJoinRequest(request) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
async _tool_join_network(request) {
|
|
19
|
+
const { caller, parent, transports } = request.params;
|
|
20
|
+
this.logger.debug('Joining network: ' + caller);
|
|
21
|
+
if (!caller || !parent || !transports) {
|
|
22
|
+
throw new Error('Invalid parameters provided, cannot join network');
|
|
23
|
+
}
|
|
24
|
+
await this.validateJoinRequest(request);
|
|
25
|
+
await this.use(new oAddress(parent), {
|
|
26
|
+
method: 'add_child',
|
|
27
|
+
params: {
|
|
28
|
+
address: caller,
|
|
29
|
+
transports: transports,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
message: 'Network joined!',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async _tool_save_plan(request) {
|
|
37
|
+
const { plan } = request.params;
|
|
38
|
+
this.logger.debug('Adding plan to network: ' + plan);
|
|
39
|
+
if (!this.config.networkName) {
|
|
40
|
+
this.logger.warn('No network name provided, cannot update config');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async _tool_index_network(request) {
|
|
45
|
+
// paginate through all the registered nodes and index them
|
|
46
|
+
const nodes = await this.use(new oAddress('o://leader/register'), {
|
|
47
|
+
method: 'find_all',
|
|
48
|
+
params: {},
|
|
49
|
+
});
|
|
50
|
+
const nodesArray = nodes.result.data;
|
|
51
|
+
for (let i = 0; i < nodesArray.length; i++) {
|
|
52
|
+
// first let's get the node's tools
|
|
53
|
+
const node = nodesArray[i];
|
|
54
|
+
const { result } = await this.use(new oAddress(node.address), {
|
|
55
|
+
method: 'index_network',
|
|
56
|
+
params: {},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
message: 'Network indexed!',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.method.d.ts","sourceRoot":"","sources":["../../../src/leader/methods/start.method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,YAAY,EAAE,OAoB1B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const START_METHOD = {
|
|
2
|
+
name: 'intent',
|
|
3
|
+
description: 'Resolve the intent of the task',
|
|
4
|
+
dependencies: [],
|
|
5
|
+
parameters: [
|
|
6
|
+
{
|
|
7
|
+
name: 'intent',
|
|
8
|
+
type: 'string',
|
|
9
|
+
value: 'string',
|
|
10
|
+
description: 'The intent of the task',
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'context',
|
|
15
|
+
type: 'string',
|
|
16
|
+
value: 'string',
|
|
17
|
+
description: 'The user input to the task',
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.methods.d.ts","sourceRoot":"","sources":["../../../src/plan/methods/plan.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAOhD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.interface.d.ts","sourceRoot":"","sources":["../../../src/registry/interfaces/search.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.methods.d.ts","sourceRoot":"","sources":["../../../src/registry/methods/registry.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAyErD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const REGISTRY_PARAMS = {
|
|
2
|
+
commit: {
|
|
3
|
+
name: 'commit',
|
|
4
|
+
description: 'Commit a node to the registry',
|
|
5
|
+
dependencies: [],
|
|
6
|
+
parameters: [
|
|
7
|
+
{
|
|
8
|
+
name: 'peerId',
|
|
9
|
+
type: 'string',
|
|
10
|
+
value: 'string',
|
|
11
|
+
description: 'The peerId to commit',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'address',
|
|
16
|
+
type: 'string',
|
|
17
|
+
value: 'string',
|
|
18
|
+
description: 'The address to commit',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'protocols',
|
|
22
|
+
type: 'array',
|
|
23
|
+
value: 'string[]',
|
|
24
|
+
description: 'The protocols to commit',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'transports',
|
|
28
|
+
type: 'array',
|
|
29
|
+
value: 'string[]',
|
|
30
|
+
description: 'The transports to commit',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'staticAddress',
|
|
34
|
+
type: 'string',
|
|
35
|
+
value: 'string',
|
|
36
|
+
description: 'The static address to commit',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
search: {
|
|
41
|
+
name: 'search',
|
|
42
|
+
description: 'Search for a node in the registry using simple query logic.',
|
|
43
|
+
dependencies: [],
|
|
44
|
+
parameters: [
|
|
45
|
+
{
|
|
46
|
+
name: 'staticAddress',
|
|
47
|
+
type: 'string',
|
|
48
|
+
value: 'string',
|
|
49
|
+
description: 'The static address to search for',
|
|
50
|
+
required: false,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'protocols',
|
|
54
|
+
type: 'array',
|
|
55
|
+
value: 'string[]',
|
|
56
|
+
description: 'The protocols to search for',
|
|
57
|
+
required: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'address',
|
|
61
|
+
type: 'string',
|
|
62
|
+
value: 'string',
|
|
63
|
+
description: 'The address to search for',
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
find_all: {
|
|
69
|
+
name: 'find_all',
|
|
70
|
+
description: 'Find all nodes in the registry',
|
|
71
|
+
dependencies: [],
|
|
72
|
+
parameters: [],
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RegistryTool } from './registry.tool.js';
|
|
2
|
+
import { oRequest } from '@olane/o-core';
|
|
3
|
+
export declare class RegistryMemoryTool extends RegistryTool {
|
|
4
|
+
_tool_commit(request: oRequest): Promise<any>;
|
|
5
|
+
_tool_find_all(request: oRequest): Promise<any>;
|
|
6
|
+
_tool_search(request: oRequest): Promise<any>;
|
|
7
|
+
_tool_remove(request: oRequest): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=registry-memory.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-memory.tool.d.ts","sourceRoot":"","sources":["../../src/registry/registry-memory.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,qBAAa,kBAAmB,SAAQ,YAAY;IAC5C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB7C,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA8B7C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAOpD"}
|