@defai.digital/mcp-server 13.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +214 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +7 -0
- package/dist/bin.js.map +1 -0
- package/dist/bootstrap.d.ts +89 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +161 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/rate-limiter.d.ts +136 -0
- package/dist/middleware/rate-limiter.d.ts.map +1 -0
- package/dist/middleware/rate-limiter.js +262 -0
- package/dist/middleware/rate-limiter.js.map +1 -0
- package/dist/prompts/agent-guide.d.ts +16 -0
- package/dist/prompts/agent-guide.d.ts.map +1 -0
- package/dist/prompts/agent-guide.js +391 -0
- package/dist/prompts/agent-guide.js.map +1 -0
- package/dist/prompts/explain-workflow.d.ts +15 -0
- package/dist/prompts/explain-workflow.d.ts.map +1 -0
- package/dist/prompts/explain-workflow.js +157 -0
- package/dist/prompts/explain-workflow.js.map +1 -0
- package/dist/prompts/index.d.ts +39 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +83 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/review-changes.d.ts +15 -0
- package/dist/prompts/review-changes.d.ts.map +1 -0
- package/dist/prompts/review-changes.js +102 -0
- package/dist/prompts/review-changes.js.map +1 -0
- package/dist/prompts/troubleshoot-session.d.ts +15 -0
- package/dist/prompts/troubleshoot-session.d.ts.map +1 -0
- package/dist/prompts/troubleshoot-session.js +156 -0
- package/dist/prompts/troubleshoot-session.js.map +1 -0
- package/dist/registry-accessor.d.ts +83 -0
- package/dist/registry-accessor.d.ts.map +1 -0
- package/dist/registry-accessor.js +153 -0
- package/dist/registry-accessor.js.map +1 -0
- package/dist/resources/agents.d.ts +40 -0
- package/dist/resources/agents.d.ts.map +1 -0
- package/dist/resources/agents.js +123 -0
- package/dist/resources/agents.js.map +1 -0
- package/dist/resources/config.d.ts +57 -0
- package/dist/resources/config.d.ts.map +1 -0
- package/dist/resources/config.js +222 -0
- package/dist/resources/config.js.map +1 -0
- package/dist/resources/index.d.ts +38 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +132 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/policies.d.ts +40 -0
- package/dist/resources/policies.d.ts.map +1 -0
- package/dist/resources/policies.js +122 -0
- package/dist/resources/policies.js.map +1 -0
- package/dist/resources/sessions.d.ts +30 -0
- package/dist/resources/sessions.d.ts.map +1 -0
- package/dist/resources/sessions.js +64 -0
- package/dist/resources/sessions.js.map +1 -0
- package/dist/resources/workflows.d.ts +40 -0
- package/dist/resources/workflows.d.ts.map +1 -0
- package/dist/resources/workflows.js +143 -0
- package/dist/resources/workflows.js.map +1 -0
- package/dist/schema-registry.d.ts +23 -0
- package/dist/schema-registry.d.ts.map +1 -0
- package/dist/schema-registry.js +225 -0
- package/dist/schema-registry.js.map +1 -0
- package/dist/server.d.ts +63 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +393 -0
- package/dist/server.js.map +1 -0
- package/dist/session-accessor.d.ts +23 -0
- package/dist/session-accessor.d.ts.map +1 -0
- package/dist/session-accessor.js +39 -0
- package/dist/session-accessor.js.map +1 -0
- package/dist/shared-registry.d.ts +23 -0
- package/dist/shared-registry.d.ts.map +1 -0
- package/dist/shared-registry.js +235 -0
- package/dist/shared-registry.js.map +1 -0
- package/dist/stdio.d.ts +6 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +152 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tool-namespacing.d.ts +28 -0
- package/dist/tool-namespacing.d.ts.map +1 -0
- package/dist/tool-namespacing.js +80 -0
- package/dist/tool-namespacing.js.map +1 -0
- package/dist/tools/ability.d.ts +55 -0
- package/dist/tools/ability.d.ts.map +1 -0
- package/dist/tools/ability.js +560 -0
- package/dist/tools/ability.js.map +1 -0
- package/dist/tools/agent.d.ts +73 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +895 -0
- package/dist/tools/agent.js.map +1 -0
- package/dist/tools/config.d.ts +36 -0
- package/dist/tools/config.d.ts.map +1 -0
- package/dist/tools/config.js +265 -0
- package/dist/tools/config.js.map +1 -0
- package/dist/tools/design.d.ts +42 -0
- package/dist/tools/design.d.ts.map +1 -0
- package/dist/tools/design.js +736 -0
- package/dist/tools/design.js.map +1 -0
- package/dist/tools/discuss.d.ts +40 -0
- package/dist/tools/discuss.d.ts.map +1 -0
- package/dist/tools/discuss.js +331 -0
- package/dist/tools/discuss.js.map +1 -0
- package/dist/tools/file-system.d.ts +63 -0
- package/dist/tools/file-system.d.ts.map +1 -0
- package/dist/tools/file-system.js +513 -0
- package/dist/tools/file-system.js.map +1 -0
- package/dist/tools/guard.d.ts +29 -0
- package/dist/tools/guard.d.ts.map +1 -0
- package/dist/tools/guard.js +311 -0
- package/dist/tools/guard.js.map +1 -0
- package/dist/tools/index.d.ts +35 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +178 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory.d.ts +101 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +704 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/orchestration.d.ts +58 -0
- package/dist/tools/orchestration.d.ts.map +1 -0
- package/dist/tools/orchestration.js +714 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/review.d.ts +40 -0
- package/dist/tools/review.d.ts.map +1 -0
- package/dist/tools/review.js +319 -0
- package/dist/tools/review.js.map +1 -0
- package/dist/tools/scaffold.d.ts +27 -0
- package/dist/tools/scaffold.d.ts.map +1 -0
- package/dist/tools/scaffold.js +495 -0
- package/dist/tools/scaffold.js.map +1 -0
- package/dist/tools/session.d.ts +75 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +749 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/telemetry.d.ts +58 -0
- package/dist/tools/telemetry.d.ts.map +1 -0
- package/dist/tools/telemetry.js +638 -0
- package/dist/tools/telemetry.js.map +1 -0
- package/dist/tools/trace.d.ts +29 -0
- package/dist/tools/trace.d.ts.map +1 -0
- package/dist/tools/trace.js +191 -0
- package/dist/tools/trace.js.map +1 -0
- package/dist/tools/workflow.d.ts +26 -0
- package/dist/tools/workflow.d.ts.map +1 -0
- package/dist/tools/workflow.js +269 -0
- package/dist/tools/workflow.js.map +1 -0
- package/dist/trace-wrapper.d.ts +79 -0
- package/dist/trace-wrapper.d.ts.map +1 -0
- package/dist/trace-wrapper.js +151 -0
- package/dist/trace-wrapper.js.map +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/artifact-store.d.ts +49 -0
- package/dist/utils/artifact-store.d.ts.map +1 -0
- package/dist/utils/artifact-store.js +102 -0
- package/dist/utils/artifact-store.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/response.d.ts +139 -0
- package/dist/utils/response.d.ts.map +1 -0
- package/dist/utils/response.js +293 -0
- package/dist/utils/response.js.map +1 -0
- package/dist/validation.d.ts +223 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +372 -0
- package/dist/validation.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Agent Resources
|
|
3
|
+
*
|
|
4
|
+
* Read-only access to agent registry via MCP resources protocol.
|
|
5
|
+
*
|
|
6
|
+
* Invariants:
|
|
7
|
+
* - INV-MCP-RES-001: Resources are read-only
|
|
8
|
+
* - INV-MCP-RES-002: Invalid URIs return clear error
|
|
9
|
+
*/
|
|
10
|
+
import type { MCPResource, ResourceHandler } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Agents list resource
|
|
13
|
+
*/
|
|
14
|
+
export declare const agentsListResource: MCPResource;
|
|
15
|
+
/**
|
|
16
|
+
* Agent by ID resource template
|
|
17
|
+
*/
|
|
18
|
+
export declare const agentByIdResource: MCPResource;
|
|
19
|
+
/**
|
|
20
|
+
* Handler for automatosx://agents
|
|
21
|
+
*
|
|
22
|
+
* INV-MCP-RES-001: Read-only - returns agent list from registry
|
|
23
|
+
*/
|
|
24
|
+
export declare const handleAgentsList: ResourceHandler;
|
|
25
|
+
/**
|
|
26
|
+
* Handler for automatosx://agents/{id}
|
|
27
|
+
*
|
|
28
|
+
* INV-MCP-RES-001: Read-only - returns agent details
|
|
29
|
+
* INV-MCP-RES-002: Returns error for invalid ID
|
|
30
|
+
*/
|
|
31
|
+
export declare const handleAgentById: ResourceHandler;
|
|
32
|
+
/**
|
|
33
|
+
* All agent resources
|
|
34
|
+
*/
|
|
35
|
+
export declare const AGENT_RESOURCES: MCPResource[];
|
|
36
|
+
/**
|
|
37
|
+
* Agent resource handlers map
|
|
38
|
+
*/
|
|
39
|
+
export declare const AGENT_RESOURCE_HANDLERS: Record<string, ResourceHandler>;
|
|
40
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/resources/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAsB,eAAe,EAAE,MAAM,aAAa,CAAC;AAQpF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAKhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAK/B,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAkB9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,eAwD7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,WAAW,EAGxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAGnE,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Agent Resources
|
|
3
|
+
*
|
|
4
|
+
* Read-only access to agent registry via MCP resources protocol.
|
|
5
|
+
*
|
|
6
|
+
* Invariants:
|
|
7
|
+
* - INV-MCP-RES-001: Resources are read-only
|
|
8
|
+
* - INV-MCP-RES-002: Invalid URIs return clear error
|
|
9
|
+
*/
|
|
10
|
+
import { getSharedRegistry } from '../shared-registry.js';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Resource Definitions
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Agents list resource
|
|
16
|
+
*/
|
|
17
|
+
export const agentsListResource = {
|
|
18
|
+
uri: 'automatosx://agents',
|
|
19
|
+
name: 'Agents',
|
|
20
|
+
description: 'List of all registered agents',
|
|
21
|
+
mimeType: 'application/json',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Agent by ID resource template
|
|
25
|
+
*/
|
|
26
|
+
export const agentByIdResource = {
|
|
27
|
+
uri: 'automatosx://agents/{id}',
|
|
28
|
+
name: 'Agent by ID',
|
|
29
|
+
description: 'Get a specific agent by its ID',
|
|
30
|
+
mimeType: 'application/json',
|
|
31
|
+
};
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Resource Handlers
|
|
34
|
+
// ============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Handler for automatosx://agents
|
|
37
|
+
*
|
|
38
|
+
* INV-MCP-RES-001: Read-only - returns agent list from registry
|
|
39
|
+
*/
|
|
40
|
+
export const handleAgentsList = async () => {
|
|
41
|
+
const registry = await getSharedRegistry();
|
|
42
|
+
const agents = await registry.list();
|
|
43
|
+
const agentSummaries = agents.map((a) => ({
|
|
44
|
+
agentId: a.agentId,
|
|
45
|
+
displayName: a.displayName,
|
|
46
|
+
description: a.description,
|
|
47
|
+
team: a.team,
|
|
48
|
+
enabled: a.enabled,
|
|
49
|
+
capabilities: a.capabilities,
|
|
50
|
+
}));
|
|
51
|
+
return {
|
|
52
|
+
uri: 'automatosx://agents',
|
|
53
|
+
mimeType: 'application/json',
|
|
54
|
+
text: JSON.stringify({ agents: agentSummaries, total: agents.length }, null, 2),
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Handler for automatosx://agents/{id}
|
|
59
|
+
*
|
|
60
|
+
* INV-MCP-RES-001: Read-only - returns agent details
|
|
61
|
+
* INV-MCP-RES-002: Returns error for invalid ID
|
|
62
|
+
*/
|
|
63
|
+
export const handleAgentById = async (uri, params) => {
|
|
64
|
+
const id = params?.id;
|
|
65
|
+
if (id === undefined) {
|
|
66
|
+
return {
|
|
67
|
+
uri,
|
|
68
|
+
mimeType: 'application/json',
|
|
69
|
+
text: JSON.stringify({
|
|
70
|
+
error: 'INVALID_URI',
|
|
71
|
+
message: 'Agent ID is required',
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const registry = await getSharedRegistry();
|
|
76
|
+
const agent = await registry.get(id);
|
|
77
|
+
if (agent === undefined) {
|
|
78
|
+
return {
|
|
79
|
+
uri,
|
|
80
|
+
mimeType: 'application/json',
|
|
81
|
+
text: JSON.stringify({
|
|
82
|
+
error: 'RESOURCE_NOT_FOUND',
|
|
83
|
+
message: `Agent "${id}" not found`,
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
uri,
|
|
89
|
+
mimeType: 'application/json',
|
|
90
|
+
text: JSON.stringify({
|
|
91
|
+
agentId: agent.agentId,
|
|
92
|
+
displayName: agent.displayName,
|
|
93
|
+
version: agent.version,
|
|
94
|
+
description: agent.description,
|
|
95
|
+
role: agent.role,
|
|
96
|
+
expertise: agent.expertise,
|
|
97
|
+
capabilities: agent.capabilities,
|
|
98
|
+
team: agent.team,
|
|
99
|
+
tags: agent.tags,
|
|
100
|
+
enabled: agent.enabled,
|
|
101
|
+
workflow: agent.workflow?.map((s) => ({
|
|
102
|
+
stepId: s.stepId,
|
|
103
|
+
name: s.name,
|
|
104
|
+
type: s.type,
|
|
105
|
+
})),
|
|
106
|
+
}, null, 2),
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* All agent resources
|
|
111
|
+
*/
|
|
112
|
+
export const AGENT_RESOURCES = [
|
|
113
|
+
agentsListResource,
|
|
114
|
+
agentByIdResource,
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* Agent resource handlers map
|
|
118
|
+
*/
|
|
119
|
+
export const AGENT_RESOURCE_HANDLERS = {
|
|
120
|
+
'automatosx://agents': handleAgentsList,
|
|
121
|
+
'automatosx://agents/{id}': handleAgentById,
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/resources/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,GAAG,EAAE,qBAAqB;IAC1B,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,+BAA+B;IAC5C,QAAQ,EAAE,kBAAkB;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAgB;IAC5C,GAAG,EAAE,0BAA0B;IAC/B,IAAI,EAAE,aAAa;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AAuB,GAAoC;IACtE,qBAAqB,EAAE,gBAAgB;IACvC,0BAA0B,EAAE,eAAe;CAC5C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Config Resources
|
|
3
|
+
*
|
|
4
|
+
* Per PRD Section 13.2: MCP Resources for configuration access.
|
|
5
|
+
*
|
|
6
|
+
* Resources:
|
|
7
|
+
* - automatosx://config - Read-only access to merged configuration
|
|
8
|
+
* - automatosx://config/global - Global configuration
|
|
9
|
+
* - automatosx://config/local - Local (project) configuration
|
|
10
|
+
* - automatosx://config/events - Configuration change audit trail
|
|
11
|
+
*
|
|
12
|
+
* Invariants:
|
|
13
|
+
* - INV-MCP-RES-001: Resources are read-only
|
|
14
|
+
* - INV-MCP-RES-003: Sensitive data is never exposed via resources
|
|
15
|
+
*/
|
|
16
|
+
import type { MCPResource, ResourceHandler } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Config resource - merged configuration
|
|
19
|
+
*/
|
|
20
|
+
export declare const configResource: MCPResource;
|
|
21
|
+
/**
|
|
22
|
+
* Global config resource
|
|
23
|
+
*/
|
|
24
|
+
export declare const configGlobalResource: MCPResource;
|
|
25
|
+
/**
|
|
26
|
+
* Local config resource
|
|
27
|
+
*/
|
|
28
|
+
export declare const configLocalResource: MCPResource;
|
|
29
|
+
/**
|
|
30
|
+
* Config events resource - audit trail
|
|
31
|
+
*/
|
|
32
|
+
export declare const configEventsResource: MCPResource;
|
|
33
|
+
/**
|
|
34
|
+
* All config resources
|
|
35
|
+
*/
|
|
36
|
+
export declare const CONFIG_RESOURCES: MCPResource[];
|
|
37
|
+
/**
|
|
38
|
+
* Handler for automatosx://config
|
|
39
|
+
*/
|
|
40
|
+
export declare const handleConfigResource: ResourceHandler;
|
|
41
|
+
/**
|
|
42
|
+
* Handler for automatosx://config/global
|
|
43
|
+
*/
|
|
44
|
+
export declare const handleConfigGlobalResource: ResourceHandler;
|
|
45
|
+
/**
|
|
46
|
+
* Handler for automatosx://config/local
|
|
47
|
+
*/
|
|
48
|
+
export declare const handleConfigLocalResource: ResourceHandler;
|
|
49
|
+
/**
|
|
50
|
+
* Handler for automatosx://config/events
|
|
51
|
+
*/
|
|
52
|
+
export declare const handleConfigEventsResource: ResourceHandler;
|
|
53
|
+
/**
|
|
54
|
+
* All config resource handlers
|
|
55
|
+
*/
|
|
56
|
+
export declare const CONFIG_RESOURCE_HANDLERS: Record<string, ResourceHandler>;
|
|
57
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/resources/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAsB,eAAe,EAAE,MAAM,aAAa,CAAC;AAUpF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,WAK5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAKlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAKjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAKlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,EAKzC,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAkClC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,eAkCxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,eAmCvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,eA2CxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAKpE,CAAC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Config Resources
|
|
3
|
+
*
|
|
4
|
+
* Per PRD Section 13.2: MCP Resources for configuration access.
|
|
5
|
+
*
|
|
6
|
+
* Resources:
|
|
7
|
+
* - automatosx://config - Read-only access to merged configuration
|
|
8
|
+
* - automatosx://config/global - Global configuration
|
|
9
|
+
* - automatosx://config/local - Local (project) configuration
|
|
10
|
+
* - automatosx://config/events - Configuration change audit trail
|
|
11
|
+
*
|
|
12
|
+
* Invariants:
|
|
13
|
+
* - INV-MCP-RES-001: Resources are read-only
|
|
14
|
+
* - INV-MCP-RES-003: Sensitive data is never exposed via resources
|
|
15
|
+
*/
|
|
16
|
+
import { createConfigStore, getConfigRepository, } from '@defai.digital/config-domain';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Resource Definitions
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Config resource - merged configuration
|
|
22
|
+
*/
|
|
23
|
+
export const configResource = {
|
|
24
|
+
uri: 'automatosx://config',
|
|
25
|
+
name: 'Configuration',
|
|
26
|
+
description: 'Current AutomatosX configuration (merged global + local)',
|
|
27
|
+
mimeType: 'application/json',
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Global config resource
|
|
31
|
+
*/
|
|
32
|
+
export const configGlobalResource = {
|
|
33
|
+
uri: 'automatosx://config/global',
|
|
34
|
+
name: 'Global Configuration',
|
|
35
|
+
description: 'Global AutomatosX configuration (~/.automatosx/config.json)',
|
|
36
|
+
mimeType: 'application/json',
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Local config resource
|
|
40
|
+
*/
|
|
41
|
+
export const configLocalResource = {
|
|
42
|
+
uri: 'automatosx://config/local',
|
|
43
|
+
name: 'Local Configuration',
|
|
44
|
+
description: 'Local project configuration (.automatosx/config.json)',
|
|
45
|
+
mimeType: 'application/json',
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Config events resource - audit trail
|
|
49
|
+
*/
|
|
50
|
+
export const configEventsResource = {
|
|
51
|
+
uri: 'automatosx://config/events',
|
|
52
|
+
name: 'Config Events',
|
|
53
|
+
description: 'Configuration change audit trail (event sourcing)',
|
|
54
|
+
mimeType: 'application/json',
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* All config resources
|
|
58
|
+
*/
|
|
59
|
+
export const CONFIG_RESOURCES = [
|
|
60
|
+
configResource,
|
|
61
|
+
configGlobalResource,
|
|
62
|
+
configLocalResource,
|
|
63
|
+
configEventsResource,
|
|
64
|
+
];
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Resource Handlers
|
|
67
|
+
// ============================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Handler for automatosx://config
|
|
70
|
+
*/
|
|
71
|
+
export const handleConfigResource = async (uri, _params) => {
|
|
72
|
+
try {
|
|
73
|
+
const store = createConfigStore();
|
|
74
|
+
const config = await store.readMerged();
|
|
75
|
+
if (config === undefined) {
|
|
76
|
+
return {
|
|
77
|
+
uri,
|
|
78
|
+
mimeType: 'application/json',
|
|
79
|
+
text: JSON.stringify({
|
|
80
|
+
error: 'CONFIG_NOT_FOUND',
|
|
81
|
+
message: 'No configuration found. Run "ax setup" first.',
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
uri,
|
|
87
|
+
mimeType: 'application/json',
|
|
88
|
+
text: JSON.stringify(config, null, 2),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
uri,
|
|
94
|
+
mimeType: 'application/json',
|
|
95
|
+
text: JSON.stringify({
|
|
96
|
+
error: 'CONFIG_READ_ERROR',
|
|
97
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Handler for automatosx://config/global
|
|
104
|
+
*/
|
|
105
|
+
export const handleConfigGlobalResource = async (uri, _params) => {
|
|
106
|
+
try {
|
|
107
|
+
const store = createConfigStore();
|
|
108
|
+
const config = await store.read('global');
|
|
109
|
+
if (config === undefined) {
|
|
110
|
+
return {
|
|
111
|
+
uri,
|
|
112
|
+
mimeType: 'application/json',
|
|
113
|
+
text: JSON.stringify({
|
|
114
|
+
error: 'CONFIG_NOT_FOUND',
|
|
115
|
+
message: 'No global configuration found. Run "ax setup" first.',
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
uri,
|
|
121
|
+
mimeType: 'application/json',
|
|
122
|
+
text: JSON.stringify(config, null, 2),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return {
|
|
127
|
+
uri,
|
|
128
|
+
mimeType: 'application/json',
|
|
129
|
+
text: JSON.stringify({
|
|
130
|
+
error: 'CONFIG_READ_ERROR',
|
|
131
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Handler for automatosx://config/local
|
|
138
|
+
*/
|
|
139
|
+
export const handleConfigLocalResource = async (uri, _params) => {
|
|
140
|
+
try {
|
|
141
|
+
const store = createConfigStore();
|
|
142
|
+
const config = await store.read('local');
|
|
143
|
+
if (config === undefined) {
|
|
144
|
+
return {
|
|
145
|
+
uri,
|
|
146
|
+
mimeType: 'application/json',
|
|
147
|
+
text: JSON.stringify({
|
|
148
|
+
error: 'CONFIG_NOT_FOUND',
|
|
149
|
+
message: 'No local configuration found for this project.',
|
|
150
|
+
hint: 'Run "ax setup --local" to create project-specific configuration.',
|
|
151
|
+
}),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
uri,
|
|
156
|
+
mimeType: 'application/json',
|
|
157
|
+
text: JSON.stringify(config, null, 2),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
return {
|
|
162
|
+
uri,
|
|
163
|
+
mimeType: 'application/json',
|
|
164
|
+
text: JSON.stringify({
|
|
165
|
+
error: 'CONFIG_READ_ERROR',
|
|
166
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
167
|
+
}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Handler for automatosx://config/events
|
|
173
|
+
*/
|
|
174
|
+
export const handleConfigEventsResource = async (uri, _params) => {
|
|
175
|
+
try {
|
|
176
|
+
const repository = getConfigRepository();
|
|
177
|
+
// Get events from both scopes
|
|
178
|
+
const [globalEvents, localEvents] = await Promise.all([
|
|
179
|
+
repository.getEvents('global', { limit: 50 }),
|
|
180
|
+
repository.getEvents('local', { limit: 50 }),
|
|
181
|
+
]);
|
|
182
|
+
// Combine and sort by timestamp (newest first)
|
|
183
|
+
const allEvents = [...globalEvents, ...localEvents].sort((a, b) => {
|
|
184
|
+
return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
uri,
|
|
188
|
+
mimeType: 'application/json',
|
|
189
|
+
text: JSON.stringify({
|
|
190
|
+
events: allEvents,
|
|
191
|
+
total: allEvents.length,
|
|
192
|
+
scopes: {
|
|
193
|
+
global: globalEvents.length,
|
|
194
|
+
local: localEvents.length,
|
|
195
|
+
},
|
|
196
|
+
}, null, 2),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
// If repository not initialized, return empty events
|
|
201
|
+
return {
|
|
202
|
+
uri,
|
|
203
|
+
mimeType: 'application/json',
|
|
204
|
+
text: JSON.stringify({
|
|
205
|
+
events: [],
|
|
206
|
+
total: 0,
|
|
207
|
+
scopes: { global: 0, local: 0 },
|
|
208
|
+
message: 'Event store not initialized. Events are stored in memory during session.',
|
|
209
|
+
}, null, 2),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* All config resource handlers
|
|
215
|
+
*/
|
|
216
|
+
export const CONFIG_RESOURCE_HANDLERS = {
|
|
217
|
+
'automatosx://config': handleConfigResource,
|
|
218
|
+
'automatosx://config/global': handleConfigGlobalResource,
|
|
219
|
+
'automatosx://config/local': handleConfigLocalResource,
|
|
220
|
+
'automatosx://config/events': handleConfigEventsResource,
|
|
221
|
+
};
|
|
222
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/resources/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,GAAG,EAAE,qBAAqB;IAC1B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0DAA0D;IACvE,QAAQ,EAAE,kBAAkB;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,GAAG,EAAE,4BAA4B;IACjC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,6DAA6D;IAC1E,QAAQ,EAAE,kBAAkB;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAgB;IAC9C,GAAG,EAAE,2BAA2B;IAChC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,uDAAuD;IACpE,QAAQ,EAAE,kBAAkB;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,GAAG,EAAE,4BAA4B;IACjC,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,mDAAmD;IAChE,QAAQ,EAAE,kBAAkB;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAk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,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE,SAAS,CAAC,MAAM;gBACvB,MAAM,EAAE;oBACN,MAAM,EAAE,YAAY,CAAC,MAAM;oBAC3B,KAAK,EAAE,WAAW,CAAC,MAAM;iBAC1B;aACF,EAAE,IAAI,EAAE,CAAC,CAAC;SACZ,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;QACrD,OAAO;YACL,GAAG;YACH,QAAQ,EAAE,kBAAkB;YAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;gBAC/B,OAAO,EAAE,0EAA0E;aACpF,EAAE,IAAI,EAAE,CAAC,CAAC;SACZ,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAoC;IACvE,qBAAqB,EAAE,oBAAoB;IAC3C,4BAA4B,EAAE,0BAA0B;IACxD,2BAA2B,EAAE,yBAAyB;IACtD,4BAA4B,EAAE,0BAA0B;CACzD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Resources Registry
|
|
3
|
+
*
|
|
4
|
+
* Combines all resource definitions and handlers.
|
|
5
|
+
*
|
|
6
|
+
* Invariants:
|
|
7
|
+
* - INV-MCP-RES-001: Resources are read-only
|
|
8
|
+
* - INV-MCP-RES-002: Invalid URIs return clear error
|
|
9
|
+
* - INV-MCP-RES-003: Sensitive data is never exposed via resources
|
|
10
|
+
*/
|
|
11
|
+
import type { MCPResource, MCPResourceContent, ResourceHandler } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* All MCP resources
|
|
14
|
+
*/
|
|
15
|
+
export declare const ALL_RESOURCES: MCPResource[];
|
|
16
|
+
/**
|
|
17
|
+
* All resource handlers
|
|
18
|
+
*/
|
|
19
|
+
export declare const RESOURCE_HANDLERS: Record<string, ResourceHandler>;
|
|
20
|
+
/**
|
|
21
|
+
* Finds the matching resource handler for a URI
|
|
22
|
+
*/
|
|
23
|
+
export declare function findResourceHandler(uri: string): {
|
|
24
|
+
handler: ResourceHandler;
|
|
25
|
+
params: Record<string, string>;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Reads a resource by URI
|
|
29
|
+
*
|
|
30
|
+
* INV-MCP-RES-002: Returns error for invalid URI
|
|
31
|
+
*/
|
|
32
|
+
export declare function readResource(uri: string): Promise<MCPResourceContent>;
|
|
33
|
+
export * from './workflows.js';
|
|
34
|
+
export * from './agents.js';
|
|
35
|
+
export * from './policies.js';
|
|
36
|
+
export * from './sessions.js';
|
|
37
|
+
export * from './config.js';
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA4BpF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,EAMtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAM7D,CAAC;AA0DF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,SAAS,CAkB1E;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgB3E;AAGD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Resources Registry
|
|
3
|
+
*
|
|
4
|
+
* Combines all resource definitions and handlers.
|
|
5
|
+
*
|
|
6
|
+
* Invariants:
|
|
7
|
+
* - INV-MCP-RES-001: Resources are read-only
|
|
8
|
+
* - INV-MCP-RES-002: Invalid URIs return clear error
|
|
9
|
+
* - INV-MCP-RES-003: Sensitive data is never exposed via resources
|
|
10
|
+
*/
|
|
11
|
+
// Import resource definitions and handlers
|
|
12
|
+
import { WORKFLOW_RESOURCES, WORKFLOW_RESOURCE_HANDLERS, } from './workflows.js';
|
|
13
|
+
import { AGENT_RESOURCES, AGENT_RESOURCE_HANDLERS, } from './agents.js';
|
|
14
|
+
import { POLICY_RESOURCES, POLICY_RESOURCE_HANDLERS, } from './policies.js';
|
|
15
|
+
import { SESSION_RESOURCES, SESSION_RESOURCE_HANDLERS, } from './sessions.js';
|
|
16
|
+
import { CONFIG_RESOURCES, CONFIG_RESOURCE_HANDLERS, } from './config.js';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Combined Exports
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* All MCP resources
|
|
22
|
+
*/
|
|
23
|
+
export const ALL_RESOURCES = [
|
|
24
|
+
...WORKFLOW_RESOURCES,
|
|
25
|
+
...AGENT_RESOURCES,
|
|
26
|
+
...POLICY_RESOURCES,
|
|
27
|
+
...SESSION_RESOURCES,
|
|
28
|
+
...CONFIG_RESOURCES,
|
|
29
|
+
];
|
|
30
|
+
/**
|
|
31
|
+
* All resource handlers
|
|
32
|
+
*/
|
|
33
|
+
export const RESOURCE_HANDLERS = {
|
|
34
|
+
...WORKFLOW_RESOURCE_HANDLERS,
|
|
35
|
+
...AGENT_RESOURCE_HANDLERS,
|
|
36
|
+
...POLICY_RESOURCE_HANDLERS,
|
|
37
|
+
...SESSION_RESOURCE_HANDLERS,
|
|
38
|
+
...CONFIG_RESOURCE_HANDLERS,
|
|
39
|
+
};
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// URI Pattern Matching
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Parses a URI template and extracts parameter names
|
|
45
|
+
* e.g., "automatosx://workflows/{id}" -> ["id"]
|
|
46
|
+
*/
|
|
47
|
+
function extractTemplateParams(template) {
|
|
48
|
+
const matches = template.match(/\{([^}]+)\}/g);
|
|
49
|
+
if (matches === null) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return matches.map((m) => m.slice(1, -1));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Escapes special regex characters in a string
|
|
56
|
+
*/
|
|
57
|
+
function escapeRegex(str) {
|
|
58
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Matches a URI against a template and extracts parameters
|
|
62
|
+
* e.g., matchUriTemplate("automatosx://workflows/abc", "automatosx://workflows/{id}")
|
|
63
|
+
* returns { id: "abc" }
|
|
64
|
+
*/
|
|
65
|
+
function matchUriTemplate(uri, template) {
|
|
66
|
+
// Convert template to regex, escaping special characters first
|
|
67
|
+
const paramNames = extractTemplateParams(template);
|
|
68
|
+
// First escape all regex special chars, then replace escaped \{...\} with capture groups
|
|
69
|
+
const escaped = escapeRegex(template);
|
|
70
|
+
const regexPattern = escaped.replace(/\\\{([^}]+)\\\}/g, '([^/]+)');
|
|
71
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
72
|
+
const matchResult = uri.match(regex);
|
|
73
|
+
if (matchResult === null) {
|
|
74
|
+
return { match: false, params: {} };
|
|
75
|
+
}
|
|
76
|
+
// Extract parameter values
|
|
77
|
+
const params = {};
|
|
78
|
+
paramNames.forEach((name, index) => {
|
|
79
|
+
const value = matchResult[index + 1];
|
|
80
|
+
if (value !== undefined) {
|
|
81
|
+
params[name] = value;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return { match: true, params };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Finds the matching resource handler for a URI
|
|
88
|
+
*/
|
|
89
|
+
export function findResourceHandler(uri) {
|
|
90
|
+
// First try exact match
|
|
91
|
+
const exactHandler = RESOURCE_HANDLERS[uri];
|
|
92
|
+
if (exactHandler !== undefined) {
|
|
93
|
+
return { handler: exactHandler, params: {} };
|
|
94
|
+
}
|
|
95
|
+
// Try template matching
|
|
96
|
+
for (const [template, handler] of Object.entries(RESOURCE_HANDLERS)) {
|
|
97
|
+
if (template.includes('{')) {
|
|
98
|
+
const result = matchUriTemplate(uri, template);
|
|
99
|
+
if (result.match) {
|
|
100
|
+
return { handler, params: result.params };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Reads a resource by URI
|
|
108
|
+
*
|
|
109
|
+
* INV-MCP-RES-002: Returns error for invalid URI
|
|
110
|
+
*/
|
|
111
|
+
export async function readResource(uri) {
|
|
112
|
+
const result = findResourceHandler(uri);
|
|
113
|
+
if (result === undefined) {
|
|
114
|
+
return {
|
|
115
|
+
uri,
|
|
116
|
+
mimeType: 'application/json',
|
|
117
|
+
text: JSON.stringify({
|
|
118
|
+
error: 'RESOURCE_NOT_FOUND',
|
|
119
|
+
message: `No resource handler for URI: ${uri}`,
|
|
120
|
+
availableResources: ALL_RESOURCES.map((r) => r.uri),
|
|
121
|
+
}),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return result.handler(uri, result.params);
|
|
125
|
+
}
|
|
126
|
+
// Re-export individual resources for direct access
|
|
127
|
+
export * from './workflows.js';
|
|
128
|
+
export * from './agents.js';
|
|
129
|
+
export * from './policies.js';
|
|
130
|
+
export * from './sessions.js';
|
|
131
|
+
export * from './config.js';
|
|
132
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,2CAA2C;AAC3C,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,GAAG,kBAAkB;IACrB,GAAG,eAAe;IAClB,GAAG,gBAAgB;IACnB,GAAG,iBAAiB;IACpB,GAAG,gBAAgB;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,GAAG,0BAA0B;IAC7B,GAAG,uBAAuB;IAC1B,GAAG,wBAAwB;IAC3B,GAAG,yBAAyB;IAC5B,GAAG,wBAAwB;CAC5B,CAAC;AAEF,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;GAGG;AACH,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAA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