@olane/o-storage 0.7.6 → 0.7.8
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/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/methods/os-config.methods.d.ts +3 -0
- package/dist/src/methods/os-config.methods.d.ts.map +1 -0
- package/dist/src/methods/os-config.methods.js +148 -0
- package/dist/src/os-config-storage.tool.d.ts +76 -0
- package/dist/src/os-config-storage.tool.d.ts.map +1 -0
- package/dist/src/os-config-storage.tool.js +351 -0
- package/dist/src/storage.tool.d.ts.map +1 -1
- package/dist/src/storage.tool.js +14 -0
- package/package.json +7 -7
package/dist/src/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ export * from './storage.tool.js';
|
|
|
2
2
|
export * from './providers/index.js';
|
|
3
3
|
export * from './interfaces/index.js';
|
|
4
4
|
export * from './placeholder.tool.js';
|
|
5
|
+
export * from './os-config-storage.tool.js';
|
|
6
|
+
export * from './methods/placeholder-storage.methods.js';
|
|
7
|
+
export * from './methods/storage.methods.js';
|
|
8
|
+
export * from './methods/os-config.methods.js';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC;AACzD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,3 +2,7 @@ export * from './storage.tool.js';
|
|
|
2
2
|
export * from './providers/index.js';
|
|
3
3
|
export * from './interfaces/index.js';
|
|
4
4
|
export * from './placeholder.tool.js';
|
|
5
|
+
export * from './os-config-storage.tool.js';
|
|
6
|
+
export * from './methods/placeholder-storage.methods.js';
|
|
7
|
+
export * from './methods/storage.methods.js';
|
|
8
|
+
export * from './methods/os-config.methods.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os-config.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/os-config.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAmJrD,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export const OS_CONFIG_METHODS = {
|
|
2
|
+
save_config: {
|
|
3
|
+
name: 'save_config',
|
|
4
|
+
description: 'Save OS instance configuration to storage',
|
|
5
|
+
dependencies: [],
|
|
6
|
+
parameters: [
|
|
7
|
+
{
|
|
8
|
+
name: 'osName',
|
|
9
|
+
type: 'string',
|
|
10
|
+
value: 'string',
|
|
11
|
+
description: 'Name of the OS instance',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'config',
|
|
16
|
+
type: 'object',
|
|
17
|
+
value: 'object',
|
|
18
|
+
description: 'OS instance configuration object',
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
load_config: {
|
|
24
|
+
name: 'load_config',
|
|
25
|
+
description: 'Load OS instance configuration from storage',
|
|
26
|
+
dependencies: [],
|
|
27
|
+
parameters: [
|
|
28
|
+
{
|
|
29
|
+
name: 'osName',
|
|
30
|
+
type: 'string',
|
|
31
|
+
value: 'string',
|
|
32
|
+
description: 'Name of the OS instance',
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
list_configs: {
|
|
38
|
+
name: 'list_configs',
|
|
39
|
+
description: 'List all OS instance configurations',
|
|
40
|
+
dependencies: [],
|
|
41
|
+
parameters: [],
|
|
42
|
+
},
|
|
43
|
+
delete_config: {
|
|
44
|
+
name: 'delete_config',
|
|
45
|
+
description: 'Delete OS instance configuration',
|
|
46
|
+
dependencies: [],
|
|
47
|
+
parameters: [
|
|
48
|
+
{
|
|
49
|
+
name: 'osName',
|
|
50
|
+
type: 'string',
|
|
51
|
+
value: 'string',
|
|
52
|
+
description: 'Name of the OS instance to delete',
|
|
53
|
+
required: true,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
add_lane_to_config: {
|
|
58
|
+
name: 'add_lane_to_config',
|
|
59
|
+
description: 'Add a lane CID to the OS instance startup configuration',
|
|
60
|
+
dependencies: [],
|
|
61
|
+
parameters: [
|
|
62
|
+
{
|
|
63
|
+
name: 'osName',
|
|
64
|
+
type: 'string',
|
|
65
|
+
value: 'string',
|
|
66
|
+
description: 'Name of the OS instance',
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'cid',
|
|
71
|
+
type: 'string',
|
|
72
|
+
value: 'string',
|
|
73
|
+
description: 'Content ID of the lane to add',
|
|
74
|
+
required: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
remove_lane_from_config: {
|
|
79
|
+
name: 'remove_lane_from_config',
|
|
80
|
+
description: 'Remove a lane CID from the OS instance startup configuration',
|
|
81
|
+
dependencies: [],
|
|
82
|
+
parameters: [
|
|
83
|
+
{
|
|
84
|
+
name: 'osName',
|
|
85
|
+
type: 'string',
|
|
86
|
+
value: 'string',
|
|
87
|
+
description: 'Name of the OS instance',
|
|
88
|
+
required: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'cid',
|
|
92
|
+
type: 'string',
|
|
93
|
+
value: 'string',
|
|
94
|
+
description: 'Content ID of the lane to remove',
|
|
95
|
+
required: true,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
get_lanes: {
|
|
100
|
+
name: 'get_lanes',
|
|
101
|
+
description: 'Get all lane CIDs for an OS instance',
|
|
102
|
+
dependencies: [],
|
|
103
|
+
parameters: [
|
|
104
|
+
{
|
|
105
|
+
name: 'osName',
|
|
106
|
+
type: 'string',
|
|
107
|
+
value: 'string',
|
|
108
|
+
description: 'Name of the OS instance',
|
|
109
|
+
required: true,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
update_metadata: {
|
|
114
|
+
name: 'update_metadata',
|
|
115
|
+
description: 'Update metadata for an OS instance (e.g., last indexed time)',
|
|
116
|
+
dependencies: [],
|
|
117
|
+
parameters: [
|
|
118
|
+
{
|
|
119
|
+
name: 'osName',
|
|
120
|
+
type: 'string',
|
|
121
|
+
value: 'string',
|
|
122
|
+
description: 'Name of the OS instance',
|
|
123
|
+
required: true,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'metadata',
|
|
127
|
+
type: 'object',
|
|
128
|
+
value: 'object',
|
|
129
|
+
description: 'Metadata object to merge into the config',
|
|
130
|
+
required: true,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
get_metadata: {
|
|
135
|
+
name: 'get_metadata',
|
|
136
|
+
description: 'Get metadata for an OS instance',
|
|
137
|
+
dependencies: [],
|
|
138
|
+
parameters: [
|
|
139
|
+
{
|
|
140
|
+
name: 'osName',
|
|
141
|
+
type: 'string',
|
|
142
|
+
value: 'string',
|
|
143
|
+
description: 'Name of the OS instance',
|
|
144
|
+
required: true,
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ToolResult } from '@olane/o-tool';
|
|
2
|
+
import { oRequest } from '@olane/o-core';
|
|
3
|
+
import { oLaneTool } from '@olane/o-lane';
|
|
4
|
+
import { oNodeToolConfig } from '@olane/o-node';
|
|
5
|
+
export interface OSConfigStorageConfig extends oNodeToolConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Storage backend to use for OS configuration.
|
|
8
|
+
* - 'disk': Local filesystem (default for local OS)
|
|
9
|
+
* - 'memory': In-memory storage (volatile)
|
|
10
|
+
* - string: Any other storage backend address
|
|
11
|
+
*/
|
|
12
|
+
storageBackend?: 'disk' | 'memory' | string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* OS Configuration Storage Tool
|
|
16
|
+
*
|
|
17
|
+
* Provides a unified interface for OS instance configuration management.
|
|
18
|
+
* Delegates to appropriate storage providers based on environment configuration.
|
|
19
|
+
*
|
|
20
|
+
* Storage Backends:
|
|
21
|
+
* - 'disk': Local filesystem storage (default for local OS deployments)
|
|
22
|
+
* - 'memory': In-memory storage (volatile, for testing)
|
|
23
|
+
* - string: Any other storage backend address
|
|
24
|
+
*
|
|
25
|
+
* Address: o://os-config
|
|
26
|
+
*/
|
|
27
|
+
export declare class OSConfigStorageTool extends oLaneTool {
|
|
28
|
+
private storageBackend;
|
|
29
|
+
private configKeyPrefix;
|
|
30
|
+
constructor(config: OSConfigStorageConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Get the storage address for the configured backend
|
|
33
|
+
*/
|
|
34
|
+
private getStorageAddress;
|
|
35
|
+
/**
|
|
36
|
+
* Generate storage key for OS config
|
|
37
|
+
*/
|
|
38
|
+
private getConfigKey;
|
|
39
|
+
/**
|
|
40
|
+
* Save OS instance configuration
|
|
41
|
+
*/
|
|
42
|
+
_tool_save_config(request: oRequest): Promise<ToolResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Load OS instance configuration
|
|
45
|
+
*/
|
|
46
|
+
_tool_load_config(request: oRequest): Promise<ToolResult>;
|
|
47
|
+
/**
|
|
48
|
+
* List all OS instance configurations
|
|
49
|
+
*/
|
|
50
|
+
_tool_list_configs(request: oRequest): Promise<ToolResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Delete OS instance configuration
|
|
53
|
+
*/
|
|
54
|
+
_tool_delete_config(request: oRequest): Promise<ToolResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Add a lane CID to OS instance startup configuration
|
|
57
|
+
*/
|
|
58
|
+
_tool_add_lane_to_config(request: oRequest): Promise<ToolResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Remove a lane CID from OS instance startup configuration
|
|
61
|
+
*/
|
|
62
|
+
_tool_remove_lane_from_config(request: oRequest): Promise<ToolResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Get all lane CIDs for an OS instance
|
|
65
|
+
*/
|
|
66
|
+
_tool_get_lanes(request: oRequest): Promise<ToolResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Update metadata for an OS instance
|
|
69
|
+
*/
|
|
70
|
+
_tool_update_metadata(request: oRequest): Promise<ToolResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Get metadata for an OS instance
|
|
73
|
+
*/
|
|
74
|
+
_tool_get_metadata(request: oRequest): Promise<ToolResult>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=os-config-storage.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os-config-storage.tool.d.ts","sourceRoot":"","sources":["../../src/os-config-storage.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC7C;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,eAAe,CAAgB;gBAE3B,MAAM,EAAE,qBAAqB;IAiBzC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA2B/D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgC/D;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAsBhE;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA0BjE;;OAEG;IACG,wBAAwB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA8DtE;;OAEG;IACG,6BAA6B,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmE3E;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAkC7D;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmDnE;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAoBjE"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { oAddress, oRequest } from '@olane/o-core';
|
|
2
|
+
import { oLaneTool } from '@olane/o-lane';
|
|
3
|
+
import { OS_CONFIG_METHODS } from './methods/os-config.methods.js';
|
|
4
|
+
/**
|
|
5
|
+
* OS Configuration Storage Tool
|
|
6
|
+
*
|
|
7
|
+
* Provides a unified interface for OS instance configuration management.
|
|
8
|
+
* Delegates to appropriate storage providers based on environment configuration.
|
|
9
|
+
*
|
|
10
|
+
* Storage Backends:
|
|
11
|
+
* - 'disk': Local filesystem storage (default for local OS deployments)
|
|
12
|
+
* - 'memory': In-memory storage (volatile, for testing)
|
|
13
|
+
* - string: Any other storage backend address
|
|
14
|
+
*
|
|
15
|
+
* Address: o://os-config
|
|
16
|
+
*/
|
|
17
|
+
export class OSConfigStorageTool extends oLaneTool {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super({
|
|
20
|
+
...config,
|
|
21
|
+
address: new oAddress('o://os-config'),
|
|
22
|
+
description: 'OS instance configuration storage management',
|
|
23
|
+
methods: OS_CONFIG_METHODS,
|
|
24
|
+
});
|
|
25
|
+
this.configKeyPrefix = 'os-config:';
|
|
26
|
+
// Determine storage backend from config or environment
|
|
27
|
+
this.storageBackend =
|
|
28
|
+
config.storageBackend ||
|
|
29
|
+
process.env.OS_CONFIG_STORAGE ||
|
|
30
|
+
'disk';
|
|
31
|
+
this.logger.info(`OS Config Storage using backend: ${this.storageBackend}`);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the storage address for the configured backend
|
|
35
|
+
*/
|
|
36
|
+
getStorageAddress() {
|
|
37
|
+
return new oAddress(`o://${this.storageBackend}`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate storage key for OS config
|
|
41
|
+
*/
|
|
42
|
+
getConfigKey(osName) {
|
|
43
|
+
return `${this.configKeyPrefix}${osName}`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Save OS instance configuration
|
|
47
|
+
*/
|
|
48
|
+
async _tool_save_config(request) {
|
|
49
|
+
const { osName, config } = request.params;
|
|
50
|
+
try {
|
|
51
|
+
this.logger.debug(`Saving config for OS instance: ${osName}`);
|
|
52
|
+
await this.use(this.getStorageAddress(), {
|
|
53
|
+
method: 'put',
|
|
54
|
+
params: {
|
|
55
|
+
key: this.getConfigKey(osName),
|
|
56
|
+
value: JSON.stringify(config),
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
message: `OS configuration saved for: ${osName}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.logger.error('Failed to save OS config:', error);
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: `Failed to save configuration: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Load OS instance configuration
|
|
74
|
+
*/
|
|
75
|
+
async _tool_load_config(request) {
|
|
76
|
+
const { osName } = request.params;
|
|
77
|
+
try {
|
|
78
|
+
this.logger.debug(`Loading config for OS instance: ${osName}`);
|
|
79
|
+
const result = await this.use(this.getStorageAddress(), {
|
|
80
|
+
method: 'get',
|
|
81
|
+
params: {
|
|
82
|
+
key: this.getConfigKey(osName),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
const configData = result.result.data;
|
|
86
|
+
if (!configData || !configData.value) {
|
|
87
|
+
return {
|
|
88
|
+
success: false,
|
|
89
|
+
error: `No configuration found for OS instance: ${osName}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return JSON.parse(configData.value);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.logger.error('Failed to load OS config:', error);
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
error: `Failed to load configuration: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* List all OS instance configurations
|
|
104
|
+
*/
|
|
105
|
+
async _tool_list_configs(request) {
|
|
106
|
+
try {
|
|
107
|
+
this.logger.debug('Listing all OS configurations');
|
|
108
|
+
// For disk backend, we need to list directory contents
|
|
109
|
+
// For other backends, we'd need to implement a list operation
|
|
110
|
+
// This is a simplified implementation
|
|
111
|
+
return {
|
|
112
|
+
success: true,
|
|
113
|
+
message: 'List operation not fully implemented yet - use ConfigManager.listOSInstances() for now',
|
|
114
|
+
data: [],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
this.logger.error('Failed to list OS configs:', error);
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: `Failed to list configurations: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Delete OS instance configuration
|
|
127
|
+
*/
|
|
128
|
+
async _tool_delete_config(request) {
|
|
129
|
+
const { osName } = request.params;
|
|
130
|
+
try {
|
|
131
|
+
this.logger.debug(`Deleting config for OS instance: ${osName}`);
|
|
132
|
+
await this.use(this.getStorageAddress(), {
|
|
133
|
+
method: 'delete',
|
|
134
|
+
params: {
|
|
135
|
+
key: this.getConfigKey(osName),
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
message: `OS configuration deleted for: ${osName}`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
this.logger.error('Failed to delete OS config:', error);
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: `Failed to delete configuration: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Add a lane CID to OS instance startup configuration
|
|
153
|
+
*/
|
|
154
|
+
async _tool_add_lane_to_config(request) {
|
|
155
|
+
const { osName, cid } = request.params;
|
|
156
|
+
try {
|
|
157
|
+
this.logger.debug(`Adding lane ${cid} to config for OS instance: ${osName}`);
|
|
158
|
+
// Load current config
|
|
159
|
+
const loadResult = await this._tool_load_config(new oRequest({
|
|
160
|
+
id: request.id,
|
|
161
|
+
method: request.method,
|
|
162
|
+
params: {
|
|
163
|
+
_connectionId: request.params._connectionId,
|
|
164
|
+
_requestMethod: request.params._requestMethod,
|
|
165
|
+
osName,
|
|
166
|
+
},
|
|
167
|
+
}));
|
|
168
|
+
const config = loadResult;
|
|
169
|
+
// Initialize lanes array if it doesn't exist
|
|
170
|
+
if (!config.oNetworkConfig) {
|
|
171
|
+
config.oNetworkConfig = {};
|
|
172
|
+
}
|
|
173
|
+
if (!config.oNetworkConfig.lanes) {
|
|
174
|
+
config.oNetworkConfig.lanes = [];
|
|
175
|
+
}
|
|
176
|
+
// Add CID if not already present
|
|
177
|
+
if (!config.oNetworkConfig.lanes.includes(cid)) {
|
|
178
|
+
config.oNetworkConfig.lanes.push(cid);
|
|
179
|
+
// Save updated config
|
|
180
|
+
await this._tool_save_config(new oRequest({
|
|
181
|
+
id: request.id,
|
|
182
|
+
method: request.method,
|
|
183
|
+
params: {
|
|
184
|
+
_connectionId: request.params._connectionId,
|
|
185
|
+
_requestMethod: request.params._requestMethod,
|
|
186
|
+
osName,
|
|
187
|
+
config,
|
|
188
|
+
},
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
message: `Lane ${cid} added to OS configuration: ${osName}`,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
this.logger.error('Failed to add lane to OS config:', error);
|
|
198
|
+
return {
|
|
199
|
+
success: false,
|
|
200
|
+
error: `Failed to add lane: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Remove a lane CID from OS instance startup configuration
|
|
206
|
+
*/
|
|
207
|
+
async _tool_remove_lane_from_config(request) {
|
|
208
|
+
const { osName, cid } = request.params;
|
|
209
|
+
try {
|
|
210
|
+
this.logger.debug(`Removing lane ${cid} from config for OS instance: ${osName}`);
|
|
211
|
+
// Load current config
|
|
212
|
+
const loadResult = await this._tool_load_config(new oRequest({
|
|
213
|
+
id: request.id,
|
|
214
|
+
method: request.method,
|
|
215
|
+
params: {
|
|
216
|
+
_connectionId: request.params._connectionId,
|
|
217
|
+
_requestMethod: request.params._requestMethod,
|
|
218
|
+
osName,
|
|
219
|
+
},
|
|
220
|
+
}));
|
|
221
|
+
if (!loadResult.success) {
|
|
222
|
+
return loadResult;
|
|
223
|
+
}
|
|
224
|
+
const config = loadResult.data;
|
|
225
|
+
if (!config.oNetworkConfig?.lanes) {
|
|
226
|
+
return {
|
|
227
|
+
success: true,
|
|
228
|
+
message: 'No lanes found in configuration',
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// Remove CID if present
|
|
232
|
+
const index = config.oNetworkConfig.lanes.indexOf(cid);
|
|
233
|
+
if (index > -1) {
|
|
234
|
+
config.oNetworkConfig.lanes.splice(index, 1);
|
|
235
|
+
// Save updated config
|
|
236
|
+
await this._tool_save_config(new oRequest({
|
|
237
|
+
id: request.id,
|
|
238
|
+
method: request.method,
|
|
239
|
+
params: {
|
|
240
|
+
_connectionId: request.params._connectionId,
|
|
241
|
+
_requestMethod: request.params._requestMethod,
|
|
242
|
+
osName,
|
|
243
|
+
config,
|
|
244
|
+
},
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
success: true,
|
|
249
|
+
message: `Lane ${cid} removed from OS configuration: ${osName}`,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
this.logger.error('Failed to remove lane from OS config:', error);
|
|
254
|
+
return {
|
|
255
|
+
success: false,
|
|
256
|
+
error: `Failed to remove lane: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get all lane CIDs for an OS instance
|
|
262
|
+
*/
|
|
263
|
+
async _tool_get_lanes(request) {
|
|
264
|
+
const { osName } = request.params;
|
|
265
|
+
try {
|
|
266
|
+
this.logger.debug(`Getting lanes for OS instance: ${osName}`);
|
|
267
|
+
// Load current config
|
|
268
|
+
const loadResult = await this._tool_load_config(new oRequest({
|
|
269
|
+
id: request.id,
|
|
270
|
+
method: request.method,
|
|
271
|
+
params: {
|
|
272
|
+
_connectionId: request.params._connectionId,
|
|
273
|
+
_requestMethod: request.params._requestMethod,
|
|
274
|
+
osName,
|
|
275
|
+
},
|
|
276
|
+
}));
|
|
277
|
+
const config = loadResult;
|
|
278
|
+
const lanes = config.oNetworkConfig?.lanes || [];
|
|
279
|
+
return {
|
|
280
|
+
lanes,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
this.logger.error('Failed to get lanes from OS config:', error);
|
|
285
|
+
return {
|
|
286
|
+
success: false,
|
|
287
|
+
error: `Failed to get lanes: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Update metadata for an OS instance
|
|
293
|
+
*/
|
|
294
|
+
async _tool_update_metadata(request) {
|
|
295
|
+
const { osName, metadata } = request.params;
|
|
296
|
+
this.logger.debug(`Updating metadata for OS instance: ${osName}`);
|
|
297
|
+
// Load current config (or create new one if doesn't exist)
|
|
298
|
+
const loadResult = await this._tool_load_config(new oRequest({
|
|
299
|
+
id: request.id,
|
|
300
|
+
method: request.method,
|
|
301
|
+
params: {
|
|
302
|
+
_connectionId: request.params._connectionId,
|
|
303
|
+
_requestMethod: request.params._requestMethod,
|
|
304
|
+
osName,
|
|
305
|
+
},
|
|
306
|
+
}));
|
|
307
|
+
let config = {};
|
|
308
|
+
if (loadResult.success) {
|
|
309
|
+
config = loadResult.data;
|
|
310
|
+
}
|
|
311
|
+
// Initialize metadata object if it doesn't exist
|
|
312
|
+
if (!config.metadata) {
|
|
313
|
+
config.metadata = {};
|
|
314
|
+
}
|
|
315
|
+
// Merge new metadata with existing metadata
|
|
316
|
+
config.metadata = {
|
|
317
|
+
...config.metadata,
|
|
318
|
+
...metadata,
|
|
319
|
+
};
|
|
320
|
+
// Save updated config
|
|
321
|
+
await this._tool_save_config(new oRequest({
|
|
322
|
+
id: request.id,
|
|
323
|
+
method: request.method,
|
|
324
|
+
params: {
|
|
325
|
+
_connectionId: request.params._connectionId,
|
|
326
|
+
_requestMethod: request.params._requestMethod,
|
|
327
|
+
osName,
|
|
328
|
+
config,
|
|
329
|
+
},
|
|
330
|
+
}));
|
|
331
|
+
return config.metadata;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get metadata for an OS instance
|
|
335
|
+
*/
|
|
336
|
+
async _tool_get_metadata(request) {
|
|
337
|
+
const { osName } = request.params;
|
|
338
|
+
this.logger.debug(`Getting metadata for OS instance: ${osName}`);
|
|
339
|
+
// Load current config
|
|
340
|
+
const config = await this._tool_load_config(new oRequest({
|
|
341
|
+
id: request.id,
|
|
342
|
+
method: request.method,
|
|
343
|
+
params: {
|
|
344
|
+
_connectionId: request.params._connectionId,
|
|
345
|
+
_requestMethod: request.params._requestMethod,
|
|
346
|
+
osName,
|
|
347
|
+
},
|
|
348
|
+
}));
|
|
349
|
+
return config.metadata || {};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.tool.d.ts","sourceRoot":"","sources":["../../src/storage.tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.tool.d.ts","sourceRoot":"","sources":["../../src/storage.tool.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,MAAM,EAAE,eAAe;IAS7B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAoDlC"}
|
package/dist/src/storage.tool.js
CHANGED
|
@@ -3,6 +3,7 @@ import { DiskStorageProvider } from './providers/disk-storage-provider.tool.js';
|
|
|
3
3
|
import { MemoryStorageProvider } from './providers/memory-storage-provider.tool.js';
|
|
4
4
|
import { SecureStorageProvider } from './providers/secure-storage-provider.tool.js';
|
|
5
5
|
import { PlaceholderTool } from './placeholder.tool.js';
|
|
6
|
+
import { OSConfigStorageTool } from './os-config-storage.tool.js';
|
|
6
7
|
import { oLaneTool } from '@olane/o-lane';
|
|
7
8
|
export class StorageTool extends oLaneTool {
|
|
8
9
|
constructor(config) {
|
|
@@ -45,5 +46,18 @@ export class StorageTool extends oLaneTool {
|
|
|
45
46
|
});
|
|
46
47
|
await node.start();
|
|
47
48
|
this.addChildNode(node);
|
|
49
|
+
// Add OS Config Storage Tool for managing OS instance configurations
|
|
50
|
+
// Note: This tool provides a unified interface that delegates to storage providers.
|
|
51
|
+
// For Lambda/cloud deployments, use 'supabase' backend (configured in o-network-lambda).
|
|
52
|
+
// For local deployments, use 'disk' or 'memory' backend.
|
|
53
|
+
node = new OSConfigStorageTool({
|
|
54
|
+
name: 'os-config',
|
|
55
|
+
parent: this.address,
|
|
56
|
+
leader: this.leader,
|
|
57
|
+
storageBackend: process.env.OS_CONFIG_STORAGE ||
|
|
58
|
+
'disk',
|
|
59
|
+
});
|
|
60
|
+
await node.start();
|
|
61
|
+
this.addChildNode(node);
|
|
48
62
|
}
|
|
49
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-storage",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"typescript": "5.4.5"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@olane/o-config": "^0.7.
|
|
60
|
-
"@olane/o-core": "^0.7.
|
|
61
|
-
"@olane/o-lane": "^0.7.
|
|
62
|
-
"@olane/o-node": "^0.7.
|
|
63
|
-
"@olane/o-protocol": "^0.7.
|
|
64
|
-
"@olane/o-tool": "^0.7.
|
|
59
|
+
"@olane/o-config": "^0.7.7",
|
|
60
|
+
"@olane/o-core": "^0.7.7",
|
|
61
|
+
"@olane/o-lane": "^0.7.7",
|
|
62
|
+
"@olane/o-node": "^0.7.7",
|
|
63
|
+
"@olane/o-protocol": "^0.7.7",
|
|
64
|
+
"@olane/o-tool": "^0.7.7"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"debug": "^4.4.1",
|